S
Scott
Hello,
I could use a little help resolving a simulation issue. I wrote a
generic dual port ram that can be used to infer Xilinx BlockRams
because I got tired of using CoreGen to generate multiple instances
for different configurations. I synthesized the design using
Synplicity, and it correctly infers BlockRams with all ports connected
up as I would expect. However, when I tried to simulate this stand
alone, the array can not be written. My guess is the two processes
that write to the memory are causing problems. If there is a ways to
correct this, I would appreciate it. I am using ModelSim.
--------------------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity dpram_cc is
generic
(
width : integer:=8;
depth : integer:=256;
addr : integer:=8
);
port
(
clk : in std_logic;
a_en : in std_logic; -- port a enable
a_wr : in std_logic; -- port a write
a_addr : in std_logic_vector(addr-1 downto 0); -- port a
address
a_data_in : in std_logic_vector(width-1 downto 0); -- port a
data in
a_data_out : out std_logic_vector(width-1 downto 0); -- port a
data out
b_en : in std_logic; -- port b
enable
b_wr : in std_logic; -- port b
write
b_addr : in std_logic_vector(addr-1 downto 0); -- port b
address
b_data_in : in std_logic_vector(width-1 downto 0); -- port b
data in
b_data_out : out std_logic_vector(width-1 downto 0) -- port b
data out
);
end dpram_cc;
architecture rtl of dpram_cc is
type mem is array (0 to depth-1) of std_logic_vector(width-1 downto
0);
signal ram : mem;
-- xilinx synthesis attribute for using block rams
attribute syn_ramstyle : string;
attribute syn_ramstyle of ram : signal is "block_ram";
begin
--
*************************************************************************
-- port a write
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (a_wr = '1') and (a_en = '1') then
ram(to_integer(unsigned(a_addr))) <= a_data_in;
end if;
end if;
end process;
--
*************************************************************************
-- port a read
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (a_en = '1') then
a_data_out <= ram(to_integer(unsigned(a_addr)));
end if;
end if;
end process;
--
*************************************************************************
-- port b write
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (b_wr = '1') and (b_en = '1') then
ram(to_integer(unsigned(b_addr))) <= b_data_in;
end if;
end if;
end process;
--
*************************************************************************
-- port a read
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (b_en = '1') then
b_data_out <= ram(to_integer(unsigned(b_addr)));
end if;
end if;
end process;
end rtl;
I could use a little help resolving a simulation issue. I wrote a
generic dual port ram that can be used to infer Xilinx BlockRams
because I got tired of using CoreGen to generate multiple instances
for different configurations. I synthesized the design using
Synplicity, and it correctly infers BlockRams with all ports connected
up as I would expect. However, when I tried to simulate this stand
alone, the array can not be written. My guess is the two processes
that write to the memory are causing problems. If there is a ways to
correct this, I would appreciate it. I am using ModelSim.
--------------------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity dpram_cc is
generic
(
width : integer:=8;
depth : integer:=256;
addr : integer:=8
);
port
(
clk : in std_logic;
a_en : in std_logic; -- port a enable
a_wr : in std_logic; -- port a write
a_addr : in std_logic_vector(addr-1 downto 0); -- port a
address
a_data_in : in std_logic_vector(width-1 downto 0); -- port a
data in
a_data_out : out std_logic_vector(width-1 downto 0); -- port a
data out
b_en : in std_logic; -- port b
enable
b_wr : in std_logic; -- port b
write
b_addr : in std_logic_vector(addr-1 downto 0); -- port b
address
b_data_in : in std_logic_vector(width-1 downto 0); -- port b
data in
b_data_out : out std_logic_vector(width-1 downto 0) -- port b
data out
);
end dpram_cc;
architecture rtl of dpram_cc is
type mem is array (0 to depth-1) of std_logic_vector(width-1 downto
0);
signal ram : mem;
-- xilinx synthesis attribute for using block rams
attribute syn_ramstyle : string;
attribute syn_ramstyle of ram : signal is "block_ram";
begin
--
*************************************************************************
-- port a write
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (a_wr = '1') and (a_en = '1') then
ram(to_integer(unsigned(a_addr))) <= a_data_in;
end if;
end if;
end process;
--
*************************************************************************
-- port a read
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (a_en = '1') then
a_data_out <= ram(to_integer(unsigned(a_addr)));
end if;
end if;
end process;
--
*************************************************************************
-- port b write
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (b_wr = '1') and (b_en = '1') then
ram(to_integer(unsigned(b_addr))) <= b_data_in;
end if;
end if;
end process;
--
*************************************************************************
-- port a read
--
*************************************************************************
process (clk)
begin
if (clk'event and clk='1') then
if (b_en = '1') then
b_data_out <= ram(to_integer(unsigned(b_addr)));
end if;
end if;
end process;
end rtl;