From acfd5f62d2e3a53fff0675caa592934bb0d4dc11 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 2 Jan 2023 18:47:07 -0500 Subject: [PATCH] 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 --- rtl/axis_replay_buffer.v | 17 ++++++++++------- tb/axis_replay_buffer.py | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/rtl/axis_replay_buffer.v b/rtl/axis_replay_buffer.v index d0f8595..1f305fb 100644 --- a/rtl/axis_replay_buffer.v +++ b/rtl/axis_replay_buffer.v @@ -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; diff --git a/tb/axis_replay_buffer.py b/tb/axis_replay_buffer.py index 76d26bb..63e0ba8 100644 --- a/tb/axis_replay_buffer.py +++ b/tb/axis_replay_buffer.py @@ -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()