# Lockstep scenarios and expected results ## Scenarios A scenario is a program, a host and a number of boundaries, run on both cores: `target/release/trace` here and `scripts/reference_trace.py` on spc700-python (its own `DebugSession`, access tracking on, each record its own `step_record_to_dict`, written with sorted keys and no spaces, less the disassembly text). `scripts/lockstep.py` streams both traces into SHA-256 digests; a scenario passes when the digests and line counts are equal, so every boundary's kind, cycles, instruction bytes, state before and after, and every cycle (`read`, `write` or `internal`, address, value, dummy flag) are equal. On a difference both traces are written out and the reference's `first_trace_divergence` says where. `scenarios/` holds the generated random-memory ones (`scripts/make_scenarios.py`); the program scenarios name fetched files by path and are written to the gitignored `external/scenarios/`. ```json { "fill": {"seed": 12345}, "memory": [{"address": 512, "hex": "e8ff"}], "registers": {"a": 0, "x": 0, "y": 0, "sp": 239, "pc": 512, "psw": 2}, "steps": 50000, "events": [{"step": 20, "action": "reset"}, {"step": 90, "action": "jump", "pc": 4096, "psw": 32}], "program": {"file": "spc_tests0.bin", "org": 768, "spctest": true}, "until_stop": true, "accesses": true } ``` | Key | Meaning | | --- | --- | | `fill` | 64 KiB from a 32-bit xorshift (`x ^= x << 13; x ^= x >> 17; x ^= x << 5`, from `seed | 1`; each byte the top byte after a step). | | `memory` | `hex` blocks written over the fill. | | `program` | Run this file in the harness instead (`Harness.load_file` at `org`, no IPL ROM); with `spctest`, ports 1-3 are set and the S-CPU side scripted as the reference's `run_spctest` does for its first program. | | `registers` | Any of `a x y sp pc psw` set before the first step. | | `steps` | Boundaries to run and record (at most, with `until_stop`). | | `events` | Between steps, before boundary `step`: `reset` (`SPC700.reset()`, whose two vector reads are not in any record), or `jump` (PC and PSW set, the core running again). | | `until_stop` | With `program`: stop where the harness's `run` stops (a finished script, a stopped core, a branch to itself). | | `accesses` | Record every cycle (default true). | ## SingleStepTests-shaped lockstep Rungs 0 and 1 run cases in the SingleStepTests format on both cores with nothing masked: `target/release/sst DIR --dump OUT` and `scripts/reference_sst.py DIR --out OUT`, one line per case: the name, the final `a x y sp pc psw stopped`, the step's cycle count, every memory byte the case holds or touched, and every cycle as `kind:address:value:dummy`. The files must be equal byte for byte. ## Expected results `expected/` holds the reference's results, measured at the pin (docs/status.md): `sst.txt` (the reference's rung 1 total), `programs.txt` (`scripts/reference_programs.py`'s lines for rungs 2 and 3) and `mame/*.txt` (`scripts/reference_replay.py`'s line for each rung 4 trace).