Skip to content

Commit d99a25f

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 0e2e11c commit d99a25f

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
@@ -153,8 +153,13 @@ module util_axis_fifo_asym #(
153153

154154
if (TKEEP_EN) begin
155155

156+
// tlast is asserted for the atomic fifo instances on the following conditions:
157+
// - 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)
158+
// - for the other instances, we store the input tlast if all the following instances have tkeep=0 for all bits (so all null bytes)
159+
// thus, the tlast is stored on the most significant instance that has non-null bytes (meaning not all tkeep bits are 0).
160+
// if all bytes are null (tkeep=0) for all instances, the least significant instance will store tlast.
156161
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) :
157-
(((|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);
162+
(((~(|s_axis_tkeep[M_DATA_WIDTH/8*(i+1)+:(RATIO-i-1)*M_DATA_WIDTH/8]))) ? s_axis_tlast : 1'b0);
158163

159164
end else begin
160165

@@ -226,7 +231,17 @@ module util_axis_fifo_asym #(
226231

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

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

0 commit comments

Comments
 (0)