# Lockstep scenarios A scenario is a program, a host, a row and a number of boundaries, run on both cores: `target/release/trace` here and `scripts/reference_trace.py` on w65c02-python (its own `W65C02Session`, access tracking on, written with its own `write_trace`). `scripts/lockstep.py` runs both and compares the two traces with the reference's `first_trace_divergence`, reading them as the scenario's row; a scenario passes when it prints `traces are identical`. `scenarios/` holds the hand-assembled ones, written by `scripts/make_scenarios.py` from the bytes in it (nothing third-party). The ones that name a fetched program by path (rung 1's Dormann and Clark runs) and the random-memory ones (rung 4) are written to the gitignored `external/scenarios/`. ## Format ```json { "row": "g65sc02", "memory": [{"address": 512, "hex": "e8e8cb"}, {"address": 0, "file": "image.bin", "length": 4096}], "registers": {"pc": 1024}, "reset": true, "steps": 40, "events": [{"step": 20, "action": "reset"}, {"access": 77, "action": "irq"}], "stalls": [{"access": 90, "halted": 3, "during": [{"cycle": 2, "action": "nmi"}]}], "accesses": true } ``` | Key | Meaning | | --- | --- | | `row` | `w65c02s`, `r65c02`, `g65sc02` or `lynx2cell` (the reference's `harness.ROWS` keys). | | `memory` | 64 KB, zero except these blocks: `hex` bytes, or a `file` (relative to the scenario), optionally its first `length` bytes. | | `registers` | Any of `a x y s pc p` set before the first step. | | `reset` | Request a reset before the first step. | | `steps` | Boundaries to run and record. | | `events` | Host actions: `irq`, `irq_clear`, `nmi`, `nmi_clear`, `reset`. With `step: n`, made before boundary `n` (from 0). With `access: k`, made inside the bus callback of access `k` (counted from 0 over the whole run, reads and writes), before the access completes; several at one access run in the order listed. | | `stalls` | Cycles held by RDY: the callback of access `k` (a read **or a write**: the 65C02 stops on write cycles too, the reference's U12) calls `note_stall()`, then for each of the `halted` cycles makes that cycle's `during` actions and calls `note_stall()` again, then completes the access. | | `accesses` | Record every bus access in the trace (default true), with its kind: `rs` an opcode fetch, `rf` another read at PC, `r`, `w`. |