Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate outputs when valid signal is low #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cocotbext/axi/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def clear(self):
self.idle_event.set()
self.active_event.clear()

def invalidate_outputs(self):
for sig in self._signals+self._optional_signals:
if hasattr(self.bus, sig):
if sig not in (self._valid_signal, self._ready_signal):
v = getattr(self.bus, sig).value
v.binstr = 'x'*len(v)
getattr(self.bus, sig).value = v

def _handle_reset(self, state):
if state:
self.log.info("Reset asserted")
Expand Down Expand Up @@ -253,6 +261,7 @@ async def _run(self):
has_ready = self.ready is not None

clock_edge_event = RisingEdge(self.clock)
valid_outputs = False

while True:
await clock_edge_event
Expand All @@ -264,11 +273,15 @@ async def _run(self):
if (ready_sample and valid_sample) or (not valid_sample):
if not self.queue.empty() and not self.pause:
self.bus.drive(self.queue.get_nowait())
valid_outputs = True
self.dequeue_event.set()
if has_valid:
self.valid.value = 1
self.active = True
else:
if valid_outputs:
self.invalidate_outputs()
valid_outputs = False
if has_valid:
self.valid.value = 0
self.active = not self.queue.empty()
Expand Down