mac/last_be: Simplify LiteEthMACTXLastBE using an FSM, fix sink.ready corner case.

This commit is contained in:
Florent Kermarrec 2021-04-27 18:04:47 +02:00
parent ca82b03e35
commit 6febb1aaab
1 changed files with 15 additions and 13 deletions

View File

@ -17,22 +17,24 @@ class LiteEthMACTXLastBE(Module):
# # # # # #
ongoing = Signal(reset=1) self.submodules.fsm = fsm = FSM(reset_state="COPY")
self.sync += [ fsm.act("COPY",
sink.connect(source, omit={"last", "last_be"}),
source.last.eq(sink.last_be),
If(sink.valid & sink.ready, If(sink.valid & sink.ready,
If(sink.last, # If last Byte but not last packet token.
ongoing.eq(1) If(sink.last_be & ~sink.last,
).Elif(sink.last_be, NextState("WAIT-LAST")
ongoing.eq(0)
) )
) )
] )
self.comb += [ fsm.act("WAIT-LAST",
source.valid.eq(sink.valid & ongoing), # Accept incoming stream until we receive last packet token.
source.last.eq(sink.last_be), sink.ready.eq(1),
source.data.eq(sink.data), If(sink.valid & sink.last,
sink.ready.eq(source.ready) NextState("COPY")
] )
)
# MAC RX Last BE ----------------------------------------------------------------------------------- # MAC RX Last BE -----------------------------------------------------------------------------------