Altera_Forum
Honored Contributor
17 years agotrue dual port RAM
Hello,
I am trying to implement a true dual port RAM. It compiles on Quartus, and when I simulate it with a waveform, it works as I want. But when I try to run it on ModelSim Altera, output is undefined. Does any one has ever solved that problem because I did not find any examples on internet. Thanks for help. Here is the code:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.ALL;
ENTITY ram512x36 IS
PORT
(
address_a : IN STD_LOGIC_VECTOR (8 DOWNTO 0);
address_b : IN STD_LOGIC_VECTOR (8 DOWNTO 0);
clock_a : IN STD_LOGIC ;
clock_b : IN STD_LOGIC ;
data_a : IN STD_LOGIC_VECTOR (35 DOWNTO 0);
data_b : IN STD_LOGIC_VECTOR (35 DOWNTO 0);
wren_a : IN STD_LOGIC:='1' ;
wren_b : IN STD_LOGIC:='1' ;
q_a : OUT STD_LOGIC_VECTOR (35 DOWNTO 0):="000000000000000000000000000000000000";
q_b : OUT STD_LOGIC_VECTOR (35 DOWNTO 0):="000000000000000000000000000000000000"
);
END ram512x36;
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.ALL;
ARCHITECTURE SYN OF ram512x36 IS
Type mem_tram_type is array (0 to 511) of std_logic_vector(35 downto 0);
signal dpram_mem_trame : mem_tram_type:=(others => (others =>'0'));
attribute block_ram : boolean;
attribute block_ram of dpram_mem_trame : signal is true;
signal w_q_a : STD_LOGIC_VECTOR (35 DOWNTO 0):="000000000000000000000000000000000000";
signal w_q_b : STD_LOGIC_VECTOR (35 DOWNTO 0):="000000000000000000000000000000000000";
signal reg_rd_address_a : std_logic_vector(8 DOWNTO 0);
signal reg_rd_address_b : std_logic_vector(8 DOWNTO 0);
begin
q_a <= dpram_mem_trame(conv_integer(unsigned(reg_rd_address_a))) ;
q_b <= dpram_mem_trame(conv_integer(unsigned(reg_rd_address_b))) ;
------------------------------------------------------------------------
-----------------------------------
portA : process(clock_a)
-----------------------------------
begin
if clock_a'event and clock_a='1' then
if wren_a='1' then
reg_rd_address_a <= address_a;
dpram_mem_trame(conv_integer(unsigned(address_a))) <= data_a;
else
reg_rd_address_a <= address_a;
end if;
end if;
-----------------------------------
end process;
-----------------------------------
portB : process(clock_b)
-----------------------------------
begin
if clock_b'event and clock_b='1' then
if wren_b='1' then
reg_rd_address_b <= address_b;
dpram_mem_trame(conv_integer(unsigned(address_b))) <= data_b;
else
reg_rd_address_b <= address_b;
end if;
end if;
-----------------------------------
end process;
-----------------------------------
END SYN;