|
|
@@ -51,7 +51,17 @@ async def wait_control_epoch(dut, previous: int, label: str) -> None:
|
|
|
)
|
|
|
|
|
|
|
|
|
+async def wait_host_idle(dut) -> None:
|
|
|
+ await wait_for(
|
|
|
+ dut,
|
|
|
+ lambda: int(dut.host_locked_mon.value) == 0,
|
|
|
+ cycles=6000,
|
|
|
+ label="Host selector idle unlock",
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
async def send_noise(dut, rng: random.Random) -> None:
|
|
|
+ await wait_host_idle(dut)
|
|
|
before_commit = int(dut.target_commit_count_mon.value)
|
|
|
before_response = int(dut.host_response_count_mon.value)
|
|
|
# A bad-CRC target-shaped frame plus arbitrary bytes must not commit or
|
|
|
@@ -62,6 +72,7 @@ async def send_noise(dut, rng: random.Random) -> None:
|
|
|
await send_uart(getattr(dut, f"host_{port}_rx"), corrupt, HOST_CLKS_PER_BIT)
|
|
|
await send_uart(getattr(dut, f"host_{port}_rx"), bytes(rng.randrange(256) for _ in range(5)), HOST_CLKS_PER_BIT)
|
|
|
await clock_cycles(dut, 1400)
|
|
|
+ await wait_host_idle(dut)
|
|
|
assert int(dut.target_commit_count_mon.value) == before_commit
|
|
|
assert int(dut.host_response_count_mon.value) == before_response
|
|
|
|
|
|
@@ -83,6 +94,7 @@ async def recover_safe(dut) -> None:
|
|
|
|
|
|
|
|
|
async def validate_snapshot(dut, port: str, counters: dict[str, int]) -> dict[str, object]:
|
|
|
+ await wait_host_idle(dut)
|
|
|
snapshot = await get_snapshot(dut, port)
|
|
|
assert snapshot["control_state"] in range(7)
|
|
|
for name in ("ptc_requested", "ptc_applied", "front_requested", "front_applied", "rear_requested", "rear_applied"):
|
|
|
@@ -142,8 +154,10 @@ async def test_accelerated_randomized_system_soak(dut):
|
|
|
elif action == 1:
|
|
|
port = "rs232" if iteration & 1 else "ttl"
|
|
|
target = rng.choice((58, 63, 70, 75))
|
|
|
+ await wait_host_idle(dut)
|
|
|
kind, payload = await host_transaction(dut, port, SET_TARGET, bytes([target]))
|
|
|
assert (kind, payload) == (SET_TARGET_ACK, b"")
|
|
|
+ await wait_host_idle(dut)
|
|
|
kind, payload = await host_transaction(dut, port, SET_TARGET, bytes([target]))
|
|
|
assert (kind, payload) == (SET_TARGET_ACK, b"")
|
|
|
counters["set_target"] += 2
|
|
|
@@ -166,6 +180,7 @@ async def test_accelerated_randomized_system_soak(dut):
|
|
|
front = [rng.randint(20, 70) for _ in range(4)]
|
|
|
rear = [rng.randint(20, 70) for _ in range(4)]
|
|
|
duration = rng.randint(1, 3)
|
|
|
+ await wait_host_idle(dut)
|
|
|
kind, payload = await host_transaction(
|
|
|
dut, "rs232", SET_STIMULUS, bytes([duration, *ptc, *front, *rear])
|
|
|
)
|