Capture without ready¶
Count three events on a bus with only valid. The source sends None
because data is also absent. The sink starts capturing at initialisation;
all three events arrive before the first recv() call.
import cocotb
from cocotb.clock import Clock
from cocotb.handle import HierarchyObject
from coaxi import AxiStreamBus, AxiStreamSink, AxiStreamSource
@cocotb.test(timeout_time=1000, timeout_unit="ns")
async def no_ready(dut: HierarchyObject) -> None:
clock = dut.beat_clock
cocotb.start_soon(Clock(clock, 10, unit="ns").start(start_high=False))
bus = AxiStreamBus.bind(dut, valid=dut.plain_valid, data=False, ready=False)
source = AxiStreamSource(bus, clock)
sink = AxiStreamSink(bus, clock, buffer_capacity=3)
await source.initialise()
await sink.initialise()
for _ in range(3):
await source.send(None)
for _ in range(3):
event = await sink.recv()
assert event.data is None
assert event.last is None
await source.close()
await sink.close()
uv run --locked pytest -q tests/test_simulation.py -k no_ready
The fixture’s plain_valid signal is in
stream_dut.vhd. On a stream
with data, bind data as usual and leave ready=False. There is no way to
stall the sender. Set buffer_capacity for the total number of undelivered
transfers you expect; overflow stops capture and requires initialise().