soc/interconnect/packet/Packetizer: fix last_be for 10gbe.

This commit is contained in:
Florent Kermarrec 2020-12-03 17:07:04 +01:00
parent 168c5380cf
commit 5e10552f3f
1 changed files with 12 additions and 6 deletions

View File

@ -186,6 +186,15 @@ class Packetizer(Module):
if header_words != 1: if header_words != 1:
self.sync += If(sr_shift, sr.eq(sr[data_width:])) 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 -------------------------------------------------------------------------------------- # FSM --------------------------------------------------------------------------------------
self.submodules.fsm = fsm = FSM(reset_state="IDLE") self.submodules.fsm = fsm = FSM(reset_state="IDLE")
fsm_from_idle = Signal() fsm_from_idle = Signal()
@ -231,9 +240,11 @@ class Packetizer(Module):
) )
) )
) )
source_last_be = getattr(source, "last_be", Signal())
fsm.act("ALIGNED-DATA-COPY", fsm.act("ALIGNED-DATA-COPY",
source.valid.eq(sink.valid), source.valid.eq(sink.valid),
source.last.eq(sink.last), source.last.eq(sink.last),
source_last_be.eq(last_be),
source.data.eq(sink.data), source.data.eq(sink.data),
If(source.valid & source.ready, If(source.valid & source.ready,
sink.ready.eq(1), sink.ready.eq(1),
@ -247,6 +258,7 @@ class Packetizer(Module):
fsm.act("UNALIGNED-DATA-COPY", fsm.act("UNALIGNED-DATA-COPY",
source.valid.eq(sink.valid | sink_d.last), source.valid.eq(sink.valid | sink_d.last),
source.last.eq(sink_d.last), source.last.eq(sink_d.last),
source_last_be.eq(last_be_d),
If(fsm_from_idle, If(fsm_from_idle,
source.data[:max(header_leftover*8, 1)].eq(sr[min(header_offset_multiplier*data_width, len(sr)-1):]) source.data[:max(header_leftover*8, 1)].eq(sr[min(header_offset_multiplier*data_width, len(sr)-1):])
).Else( ).Else(
@ -266,12 +278,6 @@ class Packetizer(Module):
if hasattr(sink, "error") and hasattr(source, "error"): if hasattr(sink, "error") and hasattr(source, "error"):
self.comb += source.error.eq(sink.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 ------------------------------------------------------------------------------------- # Depacketizer -------------------------------------------------------------------------------------
class Depacketizer(Module): class Depacketizer(Module):