1 -------------------------------------------------------------------------------
2 -- Description: This file implements a dual-SRAM
3 -------------------------------------------------------------------------------
6 use IEEE.std_logic_1164.
all;
7 use IEEE.numeric_std.
all;
10 -- This entity will infferr two identical block rams
11 -- to permit two reads in the same clock cicle.
13 entity dual_syncram
is
15 DEPTH
: positive
:= 64; -- How many slots
16 DATA_WIDTH
: positive
:= 16; -- How many bits per slot
17 ADDR_WIDTH
: positive
:= 6 -- = ceil(log2(DEPTH))
22 wr_addr
: in unsigned
(ADDR_WIDTH
-1 downto 0);
23 wr_data
: in signed
(DATA_WIDTH
-1 downto 0);
24 rd1_addr
: in unsigned
(ADDR_WIDTH
-1 downto 0);
25 rd1_data
: out signed
(DATA_WIDTH
-1 downto 0);
26 rd2_addr
: in unsigned
(ADDR_WIDTH
-1 downto 0);
27 rd2_data
: out signed
(DATA_WIDTH
-1 downto 0)
29 end entity dual_syncram
;
31 architecture rtl
of dual_syncram
is
33 type MEM_TYPE
is array(0 to DEPTH
-1) of
34 signed
(DATA_WIDTH
-1 downto 0);
35 signal memory
: MEM_TYPE
;
40 if ( rising_edge
(clk
) ) then
41 if ( wr_e
= '1' ) then
42 memory
( to_integer
(wr_addr
) ) <= wr_data
;
44 rd1_data
<= memory
( to_integer
(rd1_addr
) );
45 rd2_data
<= memory
( to_integer
(rd2_addr
) );