I'm sorry for my delayed reply.
Here's my code
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_signed.all;
use ieee.math_real.all;
library std;
entity association is
generic
( DEPTH : natural:=2;
LABEL_WIDTH : natural := 8;
ADDR_WIDTH : natural := 6
);
port
(
clk ,reset , in_fv , in_dv : in std_logic;
in_data : in std_logic_vector((LABEL_WIDTH -1) downto 0);
addr : in natural range 0 to 2**ADDR_WIDTH - 1;
q : out std_logic_vector((LABEL_WIDTH -1) downto 0)
);
end association ;
architecture rtl of association is
component row_buffer is
generic (
PIPLINE_LENGHT : integer;
WORD_SIZE : integer
);
port (
clk_proc : in std_logic;
reset_n : in std_logic;
enable_i : in std_logic;
in_data : in std_logic_vector (WORD_SIZE-1 downto 0);
out_data : out std_logic_vector (WORD_SIZE-1 downto 0)
);
end component;
component merger is
generic
(
DATA_WIDTH : natural := 8;
ADDR_WIDTH : natural := 6
);
port
(
clk : in std_logic;
addr_a : in natural range 0 to 2**ADDR_WIDTH - 1;
data_a : in std_logic_vector((DATA_WIDTH-1) downto 0);
we_a : in std_logic := '1';
q_a : out std_logic_vector((DATA_WIDTH -1) downto 0)
);
end component;
signal out1 , out2 : std_logic_vector((LABEL_WIDTH -1) downto 0);
begin
row_buffer_inst: row_buffer
generic map (DEPTH,LABEL_WIDTH)
port map (clk,reset,in_fv and in_dv, in_data,out1);
merger_inst: merger
generic map (LABEL_WIDTH,ADDR_WIDTH)
port map (clk,addr,out1,in_fv and in_dv,out2);
q<=out2;
end rtl;
the row buffer is a simple shift register :
library ieee;
use ieee.std_logic_1164.all;
entity row_buffer is
generic (
PIPLINE_LENGHT : integer;
WORD_SIZE : integer
);
port (
clk_proc : in std_logic;
reset_n : in std_logic;
enable_i : in std_logic;
in_data : in std_logic_vector (WORD_SIZE-1 downto 0);
out_data : out std_logic_vector (WORD_SIZE-1 downto 0)
);
end row_buffer;
architecture arch of row_buffer is
type cell_t is array (0 to (PIPLINE_LENGHT-1)) of std_logic_vector ( (WORD_SIZE-1) downto 0);
signal cell : cell_t;
begin
process(clk_proc,reset_n)
variable i : integer := 0;
begin
if ( reset_n = '1' ) then
cell <= (others =>(others => '0'));
elsif (rising_edge(clk_proc)) then
if (enable_i='1') then
cell(0) <= in_data;
for i in 1 to (PIPLINE_LENGHT-1) loop
cell(i) <= cell(i-1);
end loop;
out_data<= cell(PIPLINE_LENGHT - 1);
end if;
end if;
end process;
end arch;
and here's the merger (true dual port ram ) :
library ieee;
use ieee.std_logic_1164.all;
entity merger is
generic
(
DATA_WIDTH : natural := 8;
ADDR_WIDTH : natural := 6
);
port
(
clk : in std_logic;
addr_a : in natural range 0 to 2**ADDR_WIDTH - 1;
addr_b : in natural range 0 to 2**ADDR_WIDTH - 1;
data_a : in std_logic_vector((DATA_WIDTH-1) downto 0);
data_b : in std_logic_vector((DATA_WIDTH-1) downto 0);
we_a : in std_logic := '1';
we_b : in std_logic := '1';
q_a : out std_logic_vector((DATA_WIDTH -1) downto 0);
q_b : out std_logic_vector((DATA_WIDTH -1) downto 0)
);
end merger;
architecture rtl of merger is
-- Build a 2-D array type for the RAM
subtype word_t is std_logic_vector((DATA_WIDTH-1) downto 0);
type memory_t is array(2**ADDR_WIDTH-1 downto 0) of word_t;
-- Declare the RAM
shared variable ram : memory_t;
begin
-- Port A
process(clk)
begin
if(rising_edge(clk)) then
if(we_a = '1') then
ram(addr_a) := data_a;
end if;
end if;
end process;
-- Port B
process(clk)
begin
if(rising_edge(clk)) then
if(we_b = '1') then
ram(addr_b) := data_b;
end if;
end if;
end process;
q_a <= ram(addr_a);
q_b <= ram(addr_b);
end rtl;
This is my testbench :
http://www.alteraforum.com/forum/attachment.php?attachmentid=13045&stc=1