From 91ab3b40ce10cf625bd6431d763580e0eb1fd1e1 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sat, 24 Dec 2022 23:46:35 -0500 Subject: [PATCH] replay_buffer: Fix If the lower bits of m_ptr is the same as s_ptr when we get s_axis_last (that is, we are full), then we will immediately end (since m_ptr will equal last_ptr). Fix this by including all of s_ptr in last_ptr. Fixes: 52325f2 ("Add AXI stream replay buffer") Signed-off-by: Sean Anderson --- rtl/axis_replay_buffer.v | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rtl/axis_replay_buffer.v b/rtl/axis_replay_buffer.v index 6ed37c7..d0f8595 100644 --- a/rtl/axis_replay_buffer.v +++ b/rtl/axis_replay_buffer.v @@ -9,8 +9,8 @@ * replayable will remain true until BUF_SIZE + 1 handshakes have occured * without a replay. In particular, it is possible to restart a packet * even after a handshake with m_axis_last set. To support this late replay - * feature, done must be asserted when the consumer is does not wish to - * perform any more replays. + * feature, done must be asserted when the consumer does not wish to perform + * any more replays. * * In general, this buffer will add two cycles of latency. Additionally, there * will may some latency when replayable goes low. This is because the slave @@ -67,8 +67,7 @@ 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; - reg [BUF_WIDTH - 1:0] last_ptr, last_ptr_next; + 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 last, last_next; reg full, empty, replayable_next, we, re; @@ -113,7 +112,7 @@ module axis_replay_buffer ( /* read the next datum (if it's available)... */ m_axis_valid_next = !empty; - m_axis_last_next = last && m_ptr[BUF_WIDTH - 1:0] == last_ptr; + m_axis_last_next = last && m_ptr == last_ptr; re = !empty; m_ptr_next = m_ptr + !empty; /* ...except if we need to stall */ @@ -124,7 +123,6 @@ module axis_replay_buffer ( m_ptr_next = m_ptr; end - replayable_next = replayable; sent_last_next = sent_last; if (m_axis_valid && m_axis_ready) begin