replay_buffer: Fix s_ptr passing m_ptr

The condition for determining s_axis_ready only looks at whether we are
currently full, not whether we will be full on the next cycle (which is
what matters). Make it take into account whether we are going to
increment s_ptr during the current cycle. Also increase the ratio to
ensure we trigger this case, as a ration of 2 doesn't make the slave
slow enough to catch this.

Fixes: 52325f2 ("Add AXI stream replay buffer")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2023-01-02 18:47:07 -05:00
parent 91ab3b40ce
commit acfd5f62d2
2 changed files with 13 additions and 10 deletions

View File

@ -67,10 +67,10 @@ module axis_replay_buffer (
reg m_axis_valid_next, m_axis_last_next;
reg sent_last, sent_last_next;
reg [DATA_WIDTH - 1:0] buffer [(2 ** BUF_WIDTH) - 1:0];
reg [BUF_WIDTH:0] m_ptr, m_ptr_next, s_ptr, s_ptr_next, last_ptr, last_ptr_next;
reg [DATA_WIDTH - 1:0] s_data, m_data;
reg [BUF_WIDTH:0] m_ptr, m_ptr_next, s_ptr, s_ptr_next, last_ptr,
last_ptr_next, max_s_ptr;
reg last, last_next;
reg full, empty, replayable_next, we, re;
reg full, full_next, empty, replayable_next, we, re;
initial begin
m_ptr = 0;
@ -86,9 +86,6 @@ module axis_replay_buffer (
end
always @(*) begin
empty = s_ptr == m_ptr;
full = s_ptr == { ~m_ptr[BUF_WIDTH], m_ptr[BUF_WIDTH - 1:0] };
we = 0;
s_ptr_next = s_ptr;
last_next = last;
@ -102,10 +99,16 @@ module axis_replay_buffer (
end
end
empty = s_ptr == m_ptr;
max_s_ptr = { ~m_ptr[BUF_WIDTH], m_ptr[BUF_WIDTH - 1:0] };
full = s_ptr == max_s_ptr;
/* Value of full assuming no movement on the master interface */
full_next = s_ptr_next == max_s_ptr;
if (replayable)
s_axis_ready_next = &s_ptr[BUF_WIDTH - 1:0] == s_ptr[BUF_WIDTH];
else
s_axis_ready_next = !full;
s_axis_ready_next = !full_next;
if (last_next)
s_axis_ready_next = 0;

View File

@ -10,7 +10,7 @@ from .util import ClockEnable, lookahead, timeout
BUF_SIZE = 54
@timeout(15, 'us')
@timeout(30, 'us')
async def test_replay(buf, in_ratio, out_ratio):
buf.s_axis_valid.value = 0
buf.s_axis_last.value = 0
@ -81,6 +81,6 @@ async def test_replay(buf, in_ratio, out_ratio):
await recv(packet)
replay_tests = TestFactory(test_replay)
replay_tests.add_option('in_ratio', (1, 2))
replay_tests.add_option('out_ratio', (1, 2))
replay_tests.add_option('in_ratio', (1, 4))
replay_tests.add_option('out_ratio', (1, 4))
replay_tests.generate_tests()