Add clear to AXI stream models

This commit is contained in:
Alex Forencich
2021-01-02 16:15:51 -08:00
parent f6823fc8fd
commit 7748f871f4
2 changed files with 16 additions and 1 deletions

View File

@@ -256,11 +256,11 @@ Note: _byte_size_, _byte_lanes_, `len(tdata)`, and `len(tkeep)` are all related,
* `recv_nowait(compact=True)`: receive a frame as a `GmiiFrame` (non-blocking) (sink)
* `read(count)`: read _count_ bytes from buffer (blocking) (sink/monitor)
* `read_nowait(count)`: read _count_ bytes from buffer (non-blocking) (sink/monitor)
* `read(count)`: read _count_ bytes from buffer (sink/monitor)
* `count()`: returns the number of items in the queue (all)
* `empty()`: returns _True_ if the queue is empty (all)
* `full()`: returns _True_ if the queue occupancy limits are met (sink)
* `idle()`: returns _True_ if no transfer is in progress (all) or if the queue is not empty (source)
* `clear()`: drop all data in queue (all)
* `wait()`: wait for idle (source)
* `wait(timeout=0, timeout_unit='ns')`: wait for frame received (sink)
* `set_pause_generator(generator)`: set generator for pause signal, generator will be advanced on every clock cycle (source/sink)

View File

@@ -333,6 +333,11 @@ class AxiStreamSource(Reset):
def idle(self):
return self.empty() and not self.active
def clear(self):
self.queue.clear()
self.queue_occupancy_bytes = 0
self.queue_occupancy_frames = 0
async def wait(self):
while not self.idle():
await RisingEdge(self.clock)
@@ -576,6 +581,11 @@ class AxiStreamSink(Reset):
def idle(self):
return not self.active
def clear(self):
self.queue.clear()
self.queue_occupancy_bytes = 0
self.queue_occupancy_frames = 0
async def wait(self, timeout=0, timeout_unit='ns'):
if not self.empty():
return
@@ -781,6 +791,11 @@ class AxiStreamMonitor(Reset):
def idle(self):
return not self.active
def clear(self):
self.queue.clear()
self.queue_occupancy_bytes = 0
self.queue_occupancy_frames = 0
async def wait(self, timeout=0, timeout_unit='ns'):
if not self.empty():
return