Low Level ROM Specifications

High-Level ROM Specifications

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.

In FHDL, a ROM is a circuit containing only "romword" statements and input/output declarations. The following is an example.
 
rom1: circuit  
  inputs address
  outputs romout
  wire address,width=8
  wire romout,width=16
  romword 7ffe
  romword 8000
  romword 0001
  romword 07ff
  endcircuit  
 
As this example shows, each "romword" instruction supplies the value for one word of the ROM. ROM addresses are assigned consecutively starting with zero. The word values must be specified in hexadecimal, without the "0x" prefix. There must be exactly one input, and the width of the input must be explicitly declared to be the number of address bits in the ROM. There must be at least one output, and each output should have a declared width. The maximum width for any input or output is 32. ROMs with word length greater than 32 may be constructed using multiple outputs. When a ROM has multiple outputs, each "romword" instruction must specify the value of each output as illustrated below.
 
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.