From 5e10552f3f5e0cef7a3c86d2042f8d4fe4169ef9 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 3 Dec 2020 17:07:04 +0100 Subject: [PATCH] soc/interconnect/packet/Packetizer: fix last_be for 10gbe. --- litex/soc/interconnect/packet.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/litex/soc/interconnect/packet.py b/litex/soc/interconnect/packet.py index 21177b251..8c7530d3b 100644 --- a/litex/soc/interconnect/packet.py +++ b/litex/soc/interconnect/packet.py @@ -186,6 +186,15 @@ class Packetizer(Module): if header_words != 1: self.sync += If(sr_shift, sr.eq(sr[data_width:])) + # Last BE ---------------------------------------------------------------------------------- + last_be = Signal(data_width//8) + last_be_d = Signal(data_width//8) + if hasattr(sink, "last_be") and hasattr(source, "last_be"): + rotate_by = header.length%bytes_per_clk + x = [sink.last_be[(i + rotate_by)%bytes_per_clk] for i in range(bytes_per_clk)] + self.comb += last_be.eq(Cat(*x)) + self.sync += last_be_d.eq(last_be) + # FSM -------------------------------------------------------------------------------------- self.submodules.fsm = fsm = FSM(reset_state="IDLE") fsm_from_idle = Signal() @@ -231,9 +240,11 @@ class Packetizer(Module): ) ) ) + source_last_be = getattr(source, "last_be", Signal()) fsm.act("ALIGNED-DATA-COPY", source.valid.eq(sink.valid), source.last.eq(sink.last), + source_last_be.eq(last_be), source.data.eq(sink.data), If(source.valid & source.ready, sink.ready.eq(1), @@ -247,6 +258,7 @@ class Packetizer(Module): fsm.act("UNALIGNED-DATA-COPY", source.valid.eq(sink.valid | sink_d.last), source.last.eq(sink_d.last), + source_last_be.eq(last_be_d), If(fsm_from_idle, source.data[:max(header_leftover*8, 1)].eq(sr[min(header_offset_multiplier*data_width, len(sr)-1):]) ).Else( @@ -266,12 +278,6 @@ class Packetizer(Module): if hasattr(sink, "error") and hasattr(source, "error"): self.comb += source.error.eq(sink.error) - # Last BE ---------------------------------------------------------------------------------- - if hasattr(sink, "last_be") and hasattr(source, "last_be"): - rotate_by = header.length%bytes_per_clk - x = [sink.last_be[(i + rotate_by)%bytes_per_clk] for i in range(bytes_per_clk)] - self.comb += source.last_be.eq(Cat(*x)) - # Depacketizer ------------------------------------------------------------------------------------- class Depacketizer(Module):