wishbone: fix race condition in rx path

When no rx slot is available, the current code path sends the FSM through
DISCARD-REMAINING to TERMINATE, which tries to signal the slot to the user
even though nothing has been received. This can lead to data corruption.
This commit is contained in:
Arne Jansen 2022-12-08 09:58:01 +01:00
parent e3176c9386
commit 2b6d4ee51b
1 changed files with 11 additions and 1 deletions

View File

@ -91,7 +91,7 @@ class LiteEthMACSRAMWriter(Module, AutoCSR):
) )
).Else( ).Else(
NextValue(errors, errors + 1), NextValue(errors, errors + 1),
NextState("DISCARD-REMAINING") NextState("DISCARD-ALL")
) )
) )
) )
@ -104,6 +104,16 @@ class LiteEthMACSRAMWriter(Module, AutoCSR):
) )
) )
) )
fsm.act("DISCARD-ALL",
If(sink.valid & sink.last,
If((sink.last_be) != 0,
NextState("DISCARD")
).Else(
NextValue(length, 0),
NextState("WRITE")
)
)
)
fsm.act("DISCARD", fsm.act("DISCARD",
NextValue(length, 0), NextValue(length, 0),
NextState("WRITE") NextState("WRITE")