Altera_Forum
Honored Contributor
11 years agoVHDL writing in memory
Hi,
I have a hardware design running on a Cyclone IV FPGA and a software part running on a Nios II cpu on the very same FPGA. Both are sharing a dual port FPGA memory. I want the hardware part to write data on the memory and the software part to read it. The reading seems to be OK but the writing is not. Here is the VHDL code I use:library ieee;use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;
entity ctrl is
port(
data : out std_logic_vector(7 downto 0);
wen : out std_logic := '0';
addr : out std_logic_vector(14 downto 0):=(others=>'0');
clk : in std_logic);
end ctrl;
architecture rtl of ctrl is
signal step : integer := 1;
begin
process(clk)
begin
if clk'event and clk='1' then
data <= "00000001";
if step<4 then
step <= step+1;
end if;
addr <= std_logic_vector(to_unsigned(step, addr'length));
wen <= '1';
end if;
end process;
end rtl;
What I'd expect is the values written at addresses 2, 3 and 4 to be 1 but I only read 1 at address 4, others are 0. I'm sure I'm messing something up in the sequential and concurrent statements but I can't solve this. Could someone help me? Thanks.