# 65816-rust > **Lineage:** 65816-python → **65816-rust** · > fixes start in 65816-python and flow down by merges · > [family charter](https://github.com/alewman/emulator-lineage/blob/main/docs/charter.md) A Rust **WDC 65C816** core transcribed from [65816-python](https://github.com/alewman/65816-python) at `71092a4` and proven equivalent to it at every processor boundary: boundary kind, cycles, every bus cycle in order with its address, value and VDA/VPA/VPB/MLB pins, and all of `CpuState`. It is the CPU of the SNES's Ricoh 5A22, for a future Rust SNES board (the first step toward a play-snes site). Tier `x-rust` of the charter: "matches the Python" is what this repository proves; how well the Python matches the datasheet, the corpus, the hardware-verified test ROMs and MAME is the reference's `docs/validation.md`. The crate is `w65c816`, the reference's import name (Cargo does not allow a package name that starts with a digit). It is built on 6502-rust's 65xx-family frame (`sixfiveohtwo::frame::{Frame, Part}`), as the reference is built on 6502-python's `CPUFrame`, exactly as w65c02-rust and huc6280-rust are. ```rust use w65c816::{Bus, Frame, Signals, W65C816}; struct Ram(Vec); impl Bus for Ram { fn read(&mut self, address: u32, _: &mut Frame, _: Signals) -> u8 { self.0[address as usize] } fn write(&mut self, address: u32, value: u8, _: &mut Frame, _: Signals) { self.0[address as usize] = value; } // idle(address, frame, signals): every IO cycle; the default touches nothing. } let mut cpu = W65C816::new(Ram(vec![0; 1 << 24])); cpu.frame.request_reset(); let cycles = cpu.step(); // 7: reset, one bus callback per cycle let state = cpu.capture_state(); // cpu.restore_state(&state) ``` Every cycle is one callback, IO cycles included, in the chip's order, with its 24-bit address: the 5A22 times every cycle by what it is (6, 8 or 12 master clocks), so the board decides each cycle's length. Each callback gets `&mut Frame` (raise or drop IRQ, NMI and ABORT in the cycle it happens; `note_stall()`) and `Signals`: the cycle's kind (`vda()`, `vpa()`, `vpb()`, `mlb()`) and the `e`, `m`, `x_flag` pins, which the reference's host reads off the CPU object. ## Layout Each `src/*.rs` file is the transcription of one `w65c816/*.py` module, with the same handler names, the same 256-entry dispatch table (generated from the reference's and checked against it on every run) and the hardware comments carried over: `core` (`_core.py`), `alu`, `loads`, `shifts`, `control`, `block`, `dispatch`, `cpu`, `state`, `trace` (with `debug.py`'s boundary kinds and access kinds) and `harness` (the minimal SNES-shaped host the test ROMs and the MAME replay run in). Where Rust forced a difference, the module header says so. Not transcribed: the reference's disassembler (beyond the operand sizes a trace needs), debug session, console and command line (Python-side tooling; a trace written here is read by the reference's reader). ## Certification Against 65816-python `71092a4`, the gate `scripts/ladder.sh` (commands, numbers and commits in [docs/status.md](docs/status.md)); rungs 0-5 are the reference's own: | Rung | Result | | --- | --- | | 0 the bus schedule: the opcode table, and the reference's rung 0 states (its generator and seeds) | 256 entries equal; 256,000 instructions, every cycle identical | | 1 SingleStepTests 65816, 512 files, judged with the reference's readings | 5,080,136 pass, 264 excluded (C4), 0 fail: the reference's counts | | 2 gilyon's cputest-full and -basic in the harness | "Success" at $0649 and $0452, the reference's cycles and PC | | 3 krom's 23 CPU tests in the harness | 977 PASS rows, no FAIL, every line the reference's | | 4 seven games replayed against MAME 0.285 | 55,576,306 instructions, 0 divergences, 0 unexplained clocks; every summary the reference's | | 5 the 508,400 SingleStepTests states P65C816 votes on | every cycle identical, nothing masked (the HDL itself is not re-run) | | 6 trace lockstep: interrupt workouts, random memory, the ROMs to their end | 42 of 42 scenarios identical (6.5 million boundaries) | | 7 the frame carries the core, no NMOS code linked | 10 tests; no `Mos6502` symbol in any binary | | 8 seeded faults | 38 of 38 caught (one after a harness DMA scenario closed a blind spot) | `scripts/env.sh` says where the reference and its data are (by environment variable). The provenance of everything here: [docs/provenance.md](docs/provenance.md); third-party notices: [NOTICE.md](NOTICE.md). ## Licence MIT (see `LICENSE`), except one function of the rung 4 tool, `MIT AND BSD-3-Clause` (MAME's `bus_5A22_cycle_burst`, as the reference transcribed it; notice in `NOTICE.md`). The decimal adder (`src/alu.rs`) transcribes the reference's clean-room rewrite of 2026-11-25, written from Bruce Clark's *Decimal Mode* (6502.org); the old adder, which the reference's audit found translated from bsnes's GPL code, is gone (on branch `cleanroom-decimal`, docs/provenance.md). Nothing third-party is committed: the corpus, the test ROMs and the MAME traces are read in place from the reference's checkout.