Binome
Full Member level 3
- Joined
- Nov 16, 2009
- Messages
- 153
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Location
- Lyon, France
- Activity points
- 2,412
I've made a dual port ram (I hope):
component:
testbench:
and here is the result:
why is data_out ok after 32ns?
component:
Code:
---------------------------------------------------------------------------------------------
-- Company: CEA --
-- Engineer: Romain Michard - romain.michard@cea.fr --
-- Create Date: 10/03/2016 --
-- Module Name: ram_mem --
-- Project Name: SEEL- PROJECT " Smart Sensor" --
-- Additional Comments: --
-- This module is a memory ram. --
---------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity 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 ram_mem;
architecture RTL of ram_mem is
type data_ram is array (0 to 2**address_size-1) of std_logic_vector(data_size-1 downto 0);
signal signal_ram : data_ram := (others => (others => '0'));
begin
process(clock)
begin
if rising_edge(clock) then
if (enable_write = '1') then
signal_ram(to_integer(unsigned(address))) <= data_in;
end if;
end if;
end process;
process(clock)
begin
if rising_edge(clock) then
if (enable_read = '1') then
data_out <= signal_ram(to_integer(unsigned(address)));
end if;
end if;
end process;
end RTL;
Code:
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;
why is data_out ok after 32ns?