From af26f968e92deaf91045ff281fe735371d2c94be Mon Sep 17 00:00:00 2001 From: Purdea Andrei Date: Sun, 4 Aug 2024 10:29:07 +0300 Subject: [PATCH] docs/stdlib/stream: correct comment in example code about discarded data 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. --- docs/stdlib/stream.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/stdlib/stream.rst b/docs/stdlib/stream.rst index acdcf9a48..75a959847 100644 --- a/docs/stdlib/stream.rst +++ b/docs/stdlib/stream.rst @@ -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