2 use ieee.std_logic_1164.
all;
3 use ieee.std_logic_unsigned.
all;
5 entity ram_dual_port
is
7 addr_width
: natural
:= 9; --512x8
8 data_width
: natural
:= 8
11 write_en
: in std_logic;
12 waddr
: in std_logic_vector (addr_width
- 1 downto 0);
14 raddr
: in std_logic_vector (addr_width
- 1 downto 0);
16 din
: in std_logic_vector (data_width
- 1 downto 0);
17 dout
: out std_logic_vector (data_width
- 1 downto 0)
20 architecture rtl
of ram_dual_port
is
21 type mem_type
is array ((2** addr_width
) - 1 downto 0) of std_logic_vector(data_width
- 1 downto 0);
22 signal mem
: mem_type
;
24 process (wclk
) -- Write memory.
26 if (rising_edge
(wclk
)) then
27 if (write_en
= '1') then
28 mem
(conv_integer
(waddr
)) <= din
; -- Using write address bus.
33 process (rclk
) -- Read memory.
35 if (rising_edge
(rclk
)) then
36 dout
<= mem
(conv_integer
(raddr
)); -- Using read address bus.