From 03975d6f304d6dbb3cd594bcf62a20940c2dbca2 Mon Sep 17 00:00:00 2001 From: Fischer Moseley <42497969+fischermoseley@users.noreply.github.com> Date: Sat, 28 Mar 2026 21:08:22 -0600 Subject: [PATCH] ethernet: fix off-by-one bug in bridge --- src/manta/ethernet/bridge.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/manta/ethernet/bridge.py b/src/manta/ethernet/bridge.py index 4d3a21c..0b648f8 100644 --- a/src/manta/ethernet/bridge.py +++ b/src/manta/ethernet/bridge.py @@ -18,6 +18,7 @@ class EthernetBridge(wiring.Component): msg_type = Signal(MessageTypes) seq_num_expected = Signal(13) + seen_first = Signal() seen_last = Signal() count = Signal(7) @@ -67,19 +68,19 @@ class EthernetBridge(wiring.Component): # Once that hits zero and seen_last is high, we're done! # Send write response and wait for it to clock out - m.d.sync += seen_last.eq( - seen_last | (self.sink.last & self.sink.valid & self.sink.ready) - ) m.d.sync += count.eq( count + (self.sink.valid & self.sink.ready) - self.bus_sink.p.valid ) with m.If(self.sink.valid & self.sink.ready): - m.d.sync += self.bus_source.p.addr.eq(self.bus_source.p.addr + 1) + m.d.sync += self.bus_source.p.addr.eq(self.bus_source.p.addr + seen_first) m.d.sync += self.bus_source.p.data.eq(self.sink.data) m.d.sync += self.bus_source.p.rw.eq(1) m.d.sync += self.bus_source.p.valid.eq(1) + m.d.sync += seen_first.eq(1) + m.d.sync += seen_last.eq(seen_last | self.sink.last) + with m.Else(): m.d.sync += self.bus_source.p.data.eq(0) # just for clarity of debugging m.d.sync += self.bus_source.p.rw.eq(0) # just for clarity of debugging @@ -90,6 +91,7 @@ class EthernetBridge(wiring.Component): m.d.sync += self.source.valid.eq(0) m.d.sync += self.source.last.eq(0) # just for clarity of debugging m.d.sync += self.source.data.eq(0) # just for clarity of debugging + m.d.sync += seen_first.eq(0) m.next = "IDLE" with m.Else():