Start and recover with a reset pinΒΆ
The VHDL reset pin starts at U. The test writes 1 and calls initialise()
on both endpoints while the clock is stopped. Initialisation samples the
settled pin and returns while reset is asserted. The test starts the clock,
releases reset, and calls wait_available() before sending.
The test then asserts reset during a stalled send, checks for TransferReset
and valid going low, and sends a different value after release.
import cocotb
from cocotb.clock import Clock
from cocotb.handle import HierarchyObject, LogicObject
from cocotb.triggers import ReadOnly, RisingEdge, FallingEdge
from coaxi import AxiStreamBus, AxiStreamSink, AxiStreamSource, TransferReset
@cocotb.test(timeout_time=1000, timeout_unit="ns")
async def reset_recovery(dut: HierarchyObject) -> None:
clock, reset = dut.beat_clock, dut.startup_reset
assert isinstance(clock, LogicObject)
reset.value = 1
bus = AxiStreamBus.bind(dut, prefix="plain", t_prefix=False)
source = AxiStreamSource(bus, clock, reset=reset, reset_active_high=True)
sink = AxiStreamSink(bus, clock, reset=reset, reset_active_high=True)
await source.initialise()
await sink.initialise()
Clock(clock, 10, unit="ns").start(start_high=False)
for _ in range(3):
await RisingEdge(clock)
reset.value = 0
await source.wait_available()
await sink.wait_available()
async def interrupted_send() -> None:
try:
await source.send(42)
except TransferReset:
return
raise AssertionError("send returned without a receiver")
stalled = cocotb.start_soon(interrupted_send())
await FallingEdge(clock)
await ReadOnly()
assert int(dut.plain_valid.value) == 1
assert int(dut.plain_ready.value) == 0
await RisingEdge(clock)
reset.value = 1
await stalled
await ReadOnly()
assert int(dut.plain_valid.value) == 0
await RisingEdge(clock)
reset.value = 0
await source.wait_available()
await sink.wait_available()
sending = cocotb.start_soon(source.send(7))
received = await sink.recv()
await sending
assert str(received.data) == "00000111"
await source.close()
await sink.close()
uv run --locked pytest -q tests/test_simulation.py -k reset_recovery
The shared plain bus and startup_reset pin in
stream_dut.vhd have no HDL
logic between the endpoints. In a DUT test, reset its logic separately or
connect the same pin to it. Check what was accepted before retrying
interrupted work: this test checks ready was low, but a transfer can be
accepted before its send returns.
A pin-only reset restarts healthy endpoints after the release interval. It
does not clear an earlier fault or cancellation; call initialise() for
those. See Reset-pin monitoring.