From abb78308ffcf266d23d94e899964a30b2e2cf937 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Wed, 17 Mar 2021 18:02:11 -0700 Subject: [PATCH] Defer idle event until completion of transfer --- cocotbext/axi/axis.py | 4 ++-- cocotbext/axi/stream.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocotbext/axi/axis.py b/cocotbext/axi/axis.py index 2910d99..c095536 100644 --- a/cocotbext/axi/axis.py +++ b/cocotbext/axi/axis.py @@ -469,8 +469,6 @@ class AxiStreamSource(AxiStreamBase, AxiStreamPause): if (tready_sample and tvalid_sample) or not tvalid_sample: if frame is None and not self.queue.empty(): frame = self.queue.get_nowait() - if self.queue.empty(): - self.idle_event.set() self.queue_occupancy_bytes -= len(frame) self.queue_occupancy_frames -= 1 frame.sim_time_start = get_sim_time() @@ -520,6 +518,8 @@ class AxiStreamSource(AxiStreamBase, AxiStreamPause): if hasattr(self.bus, "tlast"): self.bus.tlast <= 0 self.active = bool(frame) + if not frame and self.queue.empty(): + self.idle_event.set() class AxiStreamMonitor(AxiStreamBase): diff --git a/cocotbext/axi/stream.py b/cocotbext/axi/stream.py index be2e4af..b8a51c7 100644 --- a/cocotbext/axi/stream.py +++ b/cocotbext/axi/stream.py @@ -219,8 +219,6 @@ class StreamSource(StreamBase, StreamPause): 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()) - if self.queue.empty(): - self.idle_event.set() if self.valid is not None: self.valid <= 1 self.active = True @@ -228,6 +226,8 @@ class StreamSource(StreamBase, StreamPause): if self.valid is not None: self.valid <= 0 self.active = not self.queue.empty() + if self.queue.empty(): + self.idle_event.set() class StreamMonitor(StreamBase):