Learning path · XiangShan alignment

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.

3 loops inner / middle / outer
8 dimensions XiangShan-style checklist
46 / 100 current alignment score
XIANGSHAN ALIGNMENT
46/100 C · inner loop + formal

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.

  • Reference9.0
  • DiffTest6.5
  • Formal4.0
  • Generation0.0
  • CI gates4.5
  • Checkpoints4.0
  • Perf model2.5
  • Backend2.0
  • Collaboration8.0
02Scorecard

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.

DimensionWeightScoreEvidence in this repoGap
Reference model14%9.0NEMU 6502EMU; golden-reference design and checklist; frame/audio hashes; snapshots and replay; labs/am6502 builds its images reproduciblyDiffTest is still CPU-only; PPU/APU/mapper are outside the protocol
Lockstep DiffTest22%6.5sim/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 matchFlat images only; bus/PPU/APU transactions, SoC level and frame hashes are outside the protocol; no checkpoint resume
Formal verification10%4.0formal/ 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 gate19/151 instructions refined; IRQ/NMI entry and reset not refined; cycle counts follow the current RTL; one bv_decide certificate trust point
Generation14%0.0—Zero .scala files; hand-written SystemVerilog only
CI gates14%4.5pages.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-checkNot a required check yet; no lint, coverage or deterministic double runs; Klaus is not in CI
Checkpoints9%4.0REF side has snapshots, state hashes, input replayRTL side has no export/restore; cannot replay from cycle N
Performance evaluation9%2.5GEM6502 event kernel, timing-bus experiment, area reportG0–G2 still partial; no counters, no change-to-benefit report
Backend loop6%2.0Yosys per-module area, 55nm cost modelNo bitstream, no PDK, no DFT or timing closure
Open collaboration2%8.0README, technical docs, contributing guide, golden checklist; root MIT licence and THIRD_PARTY_NOTICES publishedNo code of conduct or issue templates; contribution just unblocked, no outside contributions yet
Total100%45.9C · 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.

02040608010012-week target 65–6830.92026-11-1541.92026-11-1645.92026-11-22
DateTotalDeltaGradeWhat changed
2026-11-1530.9—D+First scorecard (original eight-dimension baseline, restated under the nine-dimension v2 weights)
  • Reference 8.5, DiffTest 4.0, CI 1.5
  • Generation 0, checkpoints 4.0, performance 2.5, backend 2.0, collaboration 5.0
2026-11-1641.9+11.0Cam6502 M1–M3 landed; root MIT licence published (restated under the nine-dimension weights)
  • DiffTest 4.0 → 6.5: the same image retires instruction by instruction on NEMU and RTL
  • CI 1.5 → 4.5: am6502.yml runs flat images, the cartridge on three backends and the DiffTest
  • Reference 8.5 → 9.0: am6502 images are built reproducibly
  • Collaboration 5.0 → 8.0: root MIT licence and THIRD_PARTY_NOTICES published
2026-11-2245.9+4.0CRubric v2: formal verification becomes the ninth dimension (10%); earlier points restated
  • New formal-verification dimension 0 → 4.0/10: the 151-opcode decode matches the RTL dispatch, BCD/ALU proofs cover all operands, and 19 instructions are refined
  • Nine-dimension weights: reference 14, DiffTest 22, generation 14, formal 10, CI 14, checkpoints 9, performance 9, backend 6, collaboration 2
  • Earlier points restated: 2026-11-15 34.4 → 30.9, 2026-11-16 46.8 → 41.9; v1 and v2 totals are not directly comparable
Method: dimension score (0–10) × weight. The weight reflects importance to the XiangShan-style flow, not the value of the project. This is an engineering judgement, not a certification; evidence expires, so re-check against git log, rtl/, labs/am6502/ and the actual CI output. Last review: 2026-11-16 (am6502 M1–M3 landed).
0312 weeks

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.

WeekWhat to doAcceptance outputProjected gain
1–2Finish DiffTest: per-instruction retire (am6502 covers flat images) + bus/PPU transaction comparemake difftest, one command, first divergence on failure+2.5
3–4Finish CI: am6502.yml already runs flat/cartridge/DiffTest; add lint, coverage and same-seed double runsRed PR cannot merge; traces uploaded on failure+3.0
5–6Checkpoints: snapshot at any cycle → restore → continue lockstepReproduce the same divergence from cycle N+2
7–9Rewrite one module in Chisel (ALU or a PPU submodule) and co-sim against the SV versionEquivalent versions + a parameterised demo+7.5
10–11Add counters to GEM6502 and run a "bus latency → cycles/stall" experimentA one-page reproducible report+1.5
12Yosys → OpenROAD/SKY130 PPA on a small moduleA one-page area/timing report+2.1
TargetMove the alignment score from 47 to 65–68 in 12 weeks≈ +19
Do not skip steps: Chisel before DiffTest gives you two implementations you cannot trust; backend before gates mistakes "synthesises" for "correct". Until the inner loop closes, no outer-loop point counts.
04What transfers

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 XiangShanDoes not transfer
The full mental model of reference + differential verificationOoO, speculation, branch prediction
Generated / parameterised hardware constructionCache coherence, multi-core, NoC
CI, regression, golden hashes, deterministic replayReal PPA optimisation (the 6502 is too small)
Checkpoints, replay, first-divergence localisationDesign taste for high-performance microarchitecture
Checklist thinking for backend and tapeout gatesCommercial 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.

Next step

Close the inner loop first.

One command, one PASS, one divergence — start there.