Skip to content

Commit

Permalink
stream: Fix BFM implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanthom committed Dec 12, 2024
1 parent 9eac0a4 commit 4062557
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lambdalib/interface/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from amaranth import *
from amaranth.hdl.rec import *
from amaranth.lib import fifo
from amaranth.sim import Settle, Passive


__all__ = ["Endpoint", "SyncFIFO", "AsyncFIFO"]
Expand Down Expand Up @@ -66,17 +67,16 @@ def bfm_send(self, pkts, timeout=100):
for key, val in pkt.items():
yield getattr(self, key).eq(val)

yield
elapsed = 1

yield Settle()
elapsed = 1
while not (yield self.ready):
yield
yield Settle()
elapsed += 1
if elapsed >= timeout:
raise Exception("timeout")

yield
yield self.valid.eq(0)

def bfm_read(self, timeout=100):
Expand All @@ -91,10 +91,14 @@ def bfm_read(self, timeout=100):
if elapsed >= timeout:
raise Exception("timeout")

res = {}
for key, _ in self.description.payload_layout:
res[key] = yield getattr(self, key)

yield
yield self.ready.eq(0)

return {key: getattr(self, key) for key, _ in self.description}
return res


class _FIFOWrapper:
Expand Down

0 comments on commit 4062557

Please sign in to comment.