Skip to content

Commit

Permalink
mac/last_be: Simplify LiteEthMACTXLastBE using an FSM, fix sink.ready…
Browse files Browse the repository at this point in the history
… corner case.
  • Loading branch information
enjoy-digital committed Apr 27, 2021
1 parent ca82b03 commit 6febb1a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions liteeth/mac/last_be.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ def __init__(self, dw):

# # #

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

Expand Down

0 comments on commit 6febb1a

Please sign in to comment.