Files

30 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""Independent preflight models for L02; they never claim physical FPGA execution."""
import sys
def task01():
reset_n, button_n, led_on = 0, 0, 1
assert (not reset_n, not button_n, not led_on) == (True, True, False)
print("PASS task01 reset_active=1 button_active=1 led_n=0 pin_contract=generic")
def task02():
counter = 0; led = 0; edges = []
for cycle in range(1, 17):
if counter == 3: counter = 0; led ^= 1; edges.append(cycle)
else: counter += 1
assert edges == [4, 8, 12, 16]
print("PASS task02 reset_known=1 led_edges=4,8,12,16 divider=4")
def task03():
states = ["idle", "cable", "identified", "configured", "observed"]
assert states == ["idle", "cable", "identified", "configured", "observed"]
print("PASS task03 order=cable,id,configure,observe workflow_model=complete hardware_observed=0 claim=preflight-only")
TASKS = {"task01_pin_polarity": task01, "task02_bringup_blinker": task02, "task03_programming_gate": task03}
if len(sys.argv) != 2 or sys.argv[1] not in TASKS: raise SystemExit(f"usage: {sys.argv[0]} {'|'.join(TASKS)}")
TASKS[sys.argv[1]]()