library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tb_mem is
end tb_mem;
architecture test of tb_mem is
component ram_mem is
generic(
data_size : integer := 12;
address_size : integer := 2
);
port(
clock : in std_logic;
enable_write : in std_logic;
enable_read : in std_logic;
address : in std_logic_vector (address_size-1 downto 0);
data_in : in std_logic_vector(data_size-1 downto 0);
data_out : out std_logic_vector(data_size-1 downto 0)
);
end component ram_mem;
signal s_clock: std_logic := '0';
signal s_enable_write : std_logic := '0';
signal s_enable_read : std_logic := '0';
signal s_data_in : std_logic_vector(11 downto 0) := (others => '0');
signal s_data_out : std_logic_vector(11 downto 0) := (others => '0');
signal s_address : std_logic_vector (1 downto 0);
begin
comp : ram_mem
generic map(
data_size => 12, -- pixel size
address_size => 2 -- row size
)
port map(
clock => s_clock,
enable_write => s_enable_write,
enable_read => s_enable_read,
address => s_address,
data_in => s_data_in,
data_out => s_data_out
);
clock : process
begin
wait for 1 ns;
s_clock <= not s_clock;
end process;
write : process
begin
wait for 8 ns;
s_enable_write <= not s_enable_write;
end process;
read : process
begin
wait for 7 ns;
s_enable_read <= '1';
wait for 1 ns;
s_enable_read <= '0';
end process;
test_vectors : process
begin
wait for 14 ns;
for i in 0 to 15 loop
s_address <= std_logic_vector(to_unsigned(15-i, 2));
s_data_in <= std_logic_vector(to_unsigned(15-i, 12));
wait for 8 ns;
end loop;
wait;
end process;
end test;