entity rom_1 is
Port ( wr , rd , cs : in std_logic;
data_in : in std_logic_vector ( 7 downto 0 );
adr : in std_logic_vector(7 downto 0 );
dout : out std_logic_vector(7 downto 0) );
end rom_1;
architecture Behavioral of rom_1 is
subtype word is std_logic_vector(7 downto 0);
type memory is array ( 0 to 255 ) of word ;
signal adr_in : integer range 0 to 255;
signal rom :memory;
begin
adr_in <= conv_integer ( adr );
process ( rd ,cs )
begin
if cs = '1' then
if rd = '0' then
dout <= rom ( adr_in ) ;
end if ;
end if ;
end process;
process ( wr , cs )
begin
if( cs = '1' ) then
if ( wr = '0' ) then
rom ( adr_in ) <= data_in ;
end if;
end if ;
end process;