The FHDL ROM specification language allows one to specify the number of address bits, the number of bits per word, and the contents of each word. See Chapter III for a more sophisticated ROM specification language. The contents of a word must be specified in hexadecimal. If a ROM of constants is to be created, the FHDL ROM specification language may be preferable to the ROM preprocessor language.
| rom1: | circuit | |
| inputs | address | |
| outputs | romout | |
| wire | address,width=8 | |
| wire | romout,width=16 | |
| romword | 7ffe | |
| romword | 8000 | |
| romword | 0001 | |
| romword | 07ff | |
| endcircuit |
| abc: | circuit | |
| inputs | address | |
| outputs | o1,o2,o3 | |
| wire | address,width=8 | |
| wire | o1,width=4 | |
| wire | o2,width=4 | |
| wire | o3,width=4 | |
| romword | a,b,c | |
| romword | d,e,f | |
| romword | 0,1,2 | |
| romword | 3,4,5 | |
| endcircuit |
As both examples illustrate, it is not necessary to specify a value for each word in the ROM. When the FHDL compiler generates simulation code for the rom, the input address is checked against the address of the last word specified, and if the input address is larger, a run-time error message is issued. This provides a convenient method for determining whether invalid ROM addresses are being issued.