Forum Discussion
Altera_Forum
Honored Contributor
18 years agoInferring a ROM
Has anyone used a HEX (Intel format) file to infer a ROM? I'd like to build a look-up table for waveform generation using a 32768 x 16 ROM and would prefer not to type in all of the values manually....
Altera_Forum
Honored Contributor
18 years agoHello,
here's an example for ROM inferred from HDL, just a few snippets --- Quote Start --- GENERIC ( NNCO : INTEGER := 10; -- output amplitude resolution NAKKUI : INTEGER := 10; -- akku integer bits = phase resolution ); -- -- ARCHITECTURE rtl OF nco IS CONSTANT ROMSIZE : INTEGER := 2**(NAKKUI-1); CONSTANT ROMMAX : INTEGER := 2**(NNCO-1)-1; TYPE SINTAB IS ARRAY(0 TO ROMSIZE-1) OF STD_LOGIC_VECTOR (NNCO-2 DOWNTO 0); SIGNAL SINROM: SINTAB; BEGIN -- For FPGA devices, this construct infers ROM sine table, -- for RAMless devices (MAX II) an LE based table instead -- only the 0..pi positive half is represented GENROM: FOR idx in 0 TO ROMSIZE-1 GENERATE CONSTANT x: REAL := SIN(real(idx)*MATH_PI/real(ROMSIZE)); CONSTANT xn: UNSIGNED (NNCO-2 DOWNTO 0) := CONV_UNSIGNED(INTEGER(x*real(ROMMAX)),NNCO-1); BEGIN SINROM(idx) <= STD_LOGIC_VECTOR(xn); END GENERATE; --- Quote End --- I hope the method can be seen from the snippets. Regards, Frank