-- asynchronous use of lpm_rom -- this program reads the values in a rom using a counter as an address indicator. The -- data read appear one clock cycle behind the change of address, and a delay. library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; use IEEE.STD_LOGIC_UNSIGNED.all; LIBRARY lpm; -- required for the use of lpm functions USE lpm.lpm_components.ALL; entity rom is generic ( rom_data_width : positive := 3; -- width of data in rom rom_address_width : positive := 4; -- width of address in rom rom_data_size : positive := 10); -- number of values in rom PORT( clock : in std_logic; --system clock rom_data: out std_logic_vector(rom_data_width -1 downto 0)); -- data in address indicated by "counter" end rom; architecture behavior of rom is signal counter : std_logic_vector(rom_address_width -1 downto 0) := "0000"; -- address counter begin obtain_rom : lpm_rom GENERIC MAP (lpm_widthad => rom_address_width, -- size of address of rom lpm_numwords => 10, -- total number of values lpm_outdata => "UNREGISTERED", lpm_address_control => "UNREGISTERED", lpm_file => "primes.mif", -- file to be read lpm_width => rom_data_width) -- width of data PORT MAP ( address => counter, q => rom_data); address_count : process(clock) is begin if rising_edge(clock) then if counter = "1001" then counter <= (others => '0'); -- counter wraps at nine else counter <= counter + 1; end if; end if; end process; end behavior;