Treat the 6502 as atrainer aircraft. A 12-week practice plan
The goal is not a more complete NES. It is to take a chip small enough to finish, end to end, and turn XiangShan's verification inner loop, CI gates and backend flow into muscle memory.
Reference model, per-instruction DiffTest, a CI skeleton and a Lean 4 formal model with refinement proofs are in place; generative flow, frame-level comparison and the backend loop are missing.
Rubric v2: formal verification is the ninth dimension (10%). The 2026-11-15 and 2026-11-16 points are restated, so v1 and v2 totals are not directly comparable.
One story, three loops.
XiangShan states its goal as "an agile development process for high-performance processors": a reference model, differential verification, generated descriptions, continuous regression, plus a roughly six-month iteration and tapeout cycle. The 6502 is small enough that one person can walk the whole chain.
XiangShan alignment: 46 / 100
Nine dimensions, weighted by how much each matters in the XiangShan-style flow; formal verification is the ninth since rubric v2. Only reproducible evidence counts: it must run, be checkable, and repeat. Plans, slogans and percentage-complete bars earn nothing.
| Dimension | Weight | Score | Evidence in this repo | Gap |
|---|---|---|---|---|
| Reference model | 14% | 9.0 | NEMU 6502EMU; golden-reference design and checklist; frame/audio hashes; snapshots and replay; labs/am6502 builds its images reproducibly | DiffTest is still CPU-only; PPU/APU/mapper are outside the protocol |
| Lockstep DiffTest | 22% | 6.5 | sim/difftest smoke test; labs/am6502 make difftest retires the same 64 KiB image on NEMU and RTL instruction by instruction (PC/A/X/Y/SP/P) with a first-divergence report; hello 1,216 and Klaus 200k instructions match | Flat images only; bus/PPU/APU transactions, SoC level and frame hashes are outside the protocol; no checkpoint resume |
| Formal verification | 10% | 4.0 | formal/ Lean 4 model: the 151-opcode decoder is proved equal to the RTL dispatch; exhaustive ADC/SBC (binary and BCD), CMP, shift and BIT specifications; mrun n m = step m refinement for 19 instructions; 15 kernel-run program tests; Lean↔RTL co-simulation of 4 programs; lean.yml gate | 19/151 instructions refined; IRQ/NMI entry and reset not refined; cycle counts follow the current RTL; one bv_decide certificate trust point |
| Generation | 14% | 0.0 | — | Zero .scala files; hand-written SystemVerilog only |
| CI gates | 14% | 4.5 | pages.yml deploys the site; am6502.yml runs flat images, the cartridge on three backends and the per-instruction DiffTest; lean.yml type-checks the proofs and the RTL/decode cross-check | Not a required check yet; no lint, coverage or deterministic double runs; Klaus is not in CI |
| Checkpoints | 9% | 4.0 | REF side has snapshots, state hashes, input replay | RTL side has no export/restore; cannot replay from cycle N |
| Performance evaluation | 9% | 2.5 | GEM6502 event kernel, timing-bus experiment, area report | G0–G2 still partial; no counters, no change-to-benefit report |
| Backend loop | 6% | 2.0 | Yosys per-module area, 55nm cost model | No bitstream, no PDK, no DFT or timing closure |
| Open collaboration | 2% | 8.0 | README, technical docs, contributing guide, golden checklist; root MIT licence and THIRD_PARTY_NOTICES published | No code of conduct or issue templates; contribution just unblocked, no outside contributions yet |
| Total | 100% | 45.9 | C · rubric v2 (nine dimensions); the v1 eight-dimension total was 46.8 and is not directly comparable | |
Score history: a line that only goes up
Every review leaves a point with the reason it moved; only reproducible evidence counts. The numbers match the table above; generated by site/tools/render-scorecard.js.
| Date | Total | Delta | Grade | What changed |
|---|---|---|---|---|
| 2026-11-15 | 30.9 | — | D+ | First scorecard (original eight-dimension baseline, restated under the nine-dimension v2 weights)
|
| 2026-11-16 | 41.9 | +11.0 | C | am6502 M1–M3 landed; root MIT licence published (restated under the nine-dimension weights)
|
| 2026-11-22 | 45.9 | +4.0 | C | Rubric v2: formal verification becomes the ninth dimension (10%); earlier points restated
|
git log, rtl/, labs/am6502/ and the actual CI output. Last review: 2026-11-16 (am6502 M1–M3 landed).
Twelve weeks, raise the score.
Ordered by learning return: close the inner loop first, then add gates, then touch generation and backend. The pace is a suggestion, not a promise.
| Week | What to do | Acceptance output | Projected gain |
|---|---|---|---|
| 1–2 | Finish DiffTest: per-instruction retire (am6502 covers flat images) + bus/PPU transaction compare | make difftest, one command, first divergence on failure | +2.5 |
| 3–4 | Finish CI: am6502.yml already runs flat/cartridge/DiffTest; add lint, coverage and same-seed double runs | Red PR cannot merge; traces uploaded on failure | +3.0 |
| 5–6 | Checkpoints: snapshot at any cycle → restore → continue lockstep | Reproduce the same divergence from cycle N | +2 |
| 7–9 | Rewrite one module in Chisel (ALU or a PPU submodule) and co-sim against the SV version | Equivalent versions + a parameterised demo | +7.5 |
| 10–11 | Add counters to GEM6502 and run a "bus latency → cycles/stall" experiment | A one-page reproducible report | +1.5 |
| 12 | Yosys → OpenROAD/SKY130 PPA on a small module | A one-page area/timing report | +2.1 |
| Target | Move the alignment score from 47 to 65–68 in 12 weeks | ≈ +19 | |
What you keep, what you don't.
The 6502 gives you process muscle, not microarchitecture taste. Knowing the difference keeps you from drifting into NES peripherals.
| Transfers to XiangShan | Does not transfer |
|---|---|
| The full mental model of reference + differential verification | OoO, speculation, branch prediction |
| Generated / parameterised hardware construction | Cache coherence, multi-core, NoC |
| CI, regression, golden hashes, deterministic replay | Real PPA optimisation (the 6502 is too small) |
| Checkpoints, replay, first-divergence localisation | Design taste for high-performance microarchitecture |
| Checklist thinking for backend and tapeout gates | Commercial PDK / DFT / sign-off engineering |
Next stage: switch the vehicle to a small RISC-V core (NutShell is XiangShan's predecessor) or read XiangShan's Chisel source directly. The 6502's job is to shorten the loop before you switch.
Close the inner loop first.
One command, one PASS, one divergence — start there.