You need to READ a VHDL tutorial. You still have significant mistakes in your code that unfortunately nobody has pointed out yet. I don't have the time or inclination to teach you VHDL, so find a tutorial and read it carefully.
Here are couple of issues I'll point out.
1) fix your sensitivity lists for the processes
This:
Code:
process(clk, s_clk, rstn, wr_en, wr_addr, data_in, rd_en)
should be this:
and this:
Code:
read_process : process(s_clk, rd_addr, wr_en, rd_en, memory)
should be this:
Code:
read_process : process(s_clk)
This is wrong it's in a different process than where you are assigning rd_ptr
Code:
if rstn = '0' then
rd_ptr <= (others => '0');
same with data_o, which is also split across two processes.
A signal should only be assigned in a single process, do not assign signals in multiple processes it will cause multiple driver problems.
Here is the standard active low reset flip-flop template follow it religiously.
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
| ff_template : process (clk, rst_n) -- no other signals appear in the sensitivity list for a reset flip-flop
begin
if rst_n = '0' then
my_ff <= '0';
elsif rising_edge(clk) then
-- my_ff assignment_code goes here
end if;
end process; |
If you want the memory to be a RAM then you need to use the proper template for a RAM implementation, as coded now you are more likely to generate a bunch of flip-flops for the memory.
I also don't understand why you are decrimenting the rd_ptr and incrimenting the wr_ptr. If you write to 0,1,2,3 addresses then you should be reading from 0,1,2,3 if you intend a circular buffer, perhaps your intention is to reverse the contents of the packet?
- - - Updated - - -
Your testbench should not be performing delays like
wait for clock_period;, such statements result in race conditions with the clock generation and you end up with delta cycle problems in the simulation, where the clock captures the leading edge of the rd_en.
I mentioned before that you need to add delays to all your signals that are applied to your DUT if you want to use wait for statements in your testbench stimulus.
If you use
rd_en <= '1' after 1 ns; the rd_ptr signal will go X on the trailing end of the rd_en instead of at the leading edge of rd_en.