Skip to content

Commit

Permalink
docs/stdlib/stream: correct comment in example code about when data loss
Browse files Browse the repository at this point in the history
In the example code the condition `done & self.stream.valid & ~self.stream.ready`
is not sufficient to cause the payload to be discarded. That is because the done
bit remains high. In case of a very slow stream, the first two quickly arriving
serial transactions will never be lost, even if the first transaction has not
been processed yet, when the second one arrives.
However if a 3rd transaction arrives as well, then the 2nd transaction will be
discarded.
  • Loading branch information
purdeaandrei committed Aug 4, 2024
1 parent dd1d8d5 commit 74a6cf3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/stdlib/stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ In this example, the external device does not provide a way to pause data transm
m.d.sync += done.eq(0)
with m.Elif(self.stream.ready):
m.d.sync += self.stream.valid.eq(0)
# Payload is discarded if `done & self.stream.valid & ~self.stream.ready`.
# Pending payload in `data` is discarded if:
# `done & self.stream.valid & ~self.stream.ready`,
# and a new serial transaction begins

return m

Expand Down

0 comments on commit 74a6cf3

Please sign in to comment.