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.sync += [
If(sink.valid & sink.ready,
If(sink.last,
ongoing.eq(1)
).Elif(sink.last_be,
ongoing.eq(0)
)
)
]
self.comb += [
source.valid.eq(sink.valid & ongoing),
self.submodules.fsm = fsm = FSM(reset_state="COPY")
fsm.act("COPY",
sink.connect(source, omit={"last", "last_be"}),
source.last.eq(sink.last_be),
source.data.eq(sink.data),
sink.ready.eq(source.ready)
]
If(sink.valid & sink.ready,
# If last Byte but not last packet token.
If(sink.last_be & ~sink.last,
NextState("WAIT-LAST")
)
)
)
fsm.act("WAIT-LAST",
# Accept incoming stream until we receive last packet token.
sink.ready.eq(1),
If(sink.valid & sink.last,
NextState("COPY")
)
)
# MAC RX Last BE -----------------------------------------------------------------------------------