Skip to content

Commit e6b6df0

Browse files
committed
library/util_axis_fifo_asym: fix tlast behavior when tkeep=0
Fix tvalid low when tlast is present. Before this commit, util_axis_fifo would suppress all transfers with tkeep=0, even if tlast was asserted. This commit makes it so transfers with tlast asserted are preserved. The AXI-Streaming spec allows us to suppress transfers for which all tkeep bits are 0 (all bytes are null bytes), but only in the case when tlast=0 as well. Transfers where tlast is asserted can't be suppressed even when all bytes are null. Signed-off-by: Laez Barbosa <laez.barbosa@analog.com>
1 parent 33f0540 commit e6b6df0

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

library/util_axis_fifo_asym/util_axis_fifo_asym.v

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,13 @@ module util_axis_fifo_asym #(
152152

153153
if (TKEEP_EN) begin
154154

155+
// tlast is asserted for the atomic fifo instances on the following conditions:
156+
// - for the most significant instance, tlast is the input tlast if any of the tkeep bits is asserted (so we are not suppressing this transfer)
157+
// - for the other instances, we store the input tlast if all the following instances have tkeep=0 for all bits (so all null bytes)
158+
// thus, the tlast is stored on the most significant instance that has non-null bytes (meaning not all tkeep bits are 0).
159+
// if all bytes are null (tkeep=0) for all instances, the least significant instance will store tlast.
155160
assign s_axis_tlast_int_s[i] = (i==RATIO-1) ? ((|s_axis_tkeep[M_DATA_WIDTH/8*i+:M_DATA_WIDTH/8]) ? s_axis_tlast : 1'b0) :
156-
(((|s_axis_tkeep[M_DATA_WIDTH/8*i+:M_DATA_WIDTH/8]) & (~(|s_axis_tkeep[M_DATA_WIDTH/8*(i+1)+:M_DATA_WIDTH/8]))) ? s_axis_tlast : 1'b0);
161+
(((~(|s_axis_tkeep[M_DATA_WIDTH/8*(i+1)+:(RATIO-i-1)*M_DATA_WIDTH/8]))) ? s_axis_tlast : 1'b0);
157162

158163
end else begin
159164

@@ -225,7 +230,17 @@ module util_axis_fifo_asym #(
225230

226231
// VALID/EMPTY/ALMOST_EMPTY is driven by the current atomic instance
227232
assign m_axis_valid_int = m_axis_valid_int_s >> m_axis_counter;
228-
assign m_axis_valid = m_axis_valid_int & (|m_axis_tkeep);
233+
234+
// When TLAST_EN=1, we still have to assert m_axis_valid when tlast is
235+
// high even if all bytes are null due to tkeep. AXI-Streaming only allows
236+
// us to suppress transfers with all tkeep bits deasserted if tlast is
237+
// also deasserted.
238+
if (TLAST_EN) begin
239+
assign m_axis_valid = m_axis_valid_int & ((|m_axis_tkeep) || m_axis_tlast);
240+
end else begin
241+
assign m_axis_valid = m_axis_valid_int & (|m_axis_tkeep);
242+
end
243+
229244
assign m_axis_tlast = m_axis_tlast_int_s >> m_axis_counter;
230245

231246
// the FIFO has the same level as the last atomic instance

0 commit comments

Comments
 (0)