# arm7tdmi-rust > **Lineage:** arm7tdmi-python → **arm7tdmi-rust** · > fixes start in arm7tdmi-python and flow down by merges · > [family charter](https://github.com/alewman/emulator-lineage/blob/main/docs/charter.md) A Rust **ARM7TDMI** core (ARMv4T: ARM and Thumb, the Game Boy Advance's CPU) transcribed module for module from [arm7tdmi-python](https://github.com/alewman/arm7tdmi-python) at `f492a9a` and proven equivalent to it bus cycle for bus cycle. Tier `x-rust` of the charter, and the first step toward a play-gba site (a Rust GBA board would pin this). "Matches the Python" is what this repository proves; how well the Python matches the ARM7TDMI (ARM's documents, hardware-verified test ROMs, an emulator-derived corpus as a detector, no GBA on hand) is the reference's `docs/validation.md` and `docs/undocumented-behavior.md`. The crate is `arm7tdmi` (the reference's name without `_python`). No dependencies in the library (the binaries read JSON with `serde_json`). ```rust use arm7tdmi::{Bus, ARM7TDMI, CODE}; struct Ram(Vec); impl Bus for Ram { fn read(&mut self, address: u32, width: u32, _access: u32) -> u32 { let at = (address & !(width / 8 - 1)) as usize % self.0.len(); (0..(width / 8) as usize).rev().fold(0, |v, i| v << 8 | self.0[at + i] as u32) } fn write(&mut self, address: u32, width: u32, value: u32, _access: u32) { let at = (address & !(width / 8 - 1)) as usize % self.0.len(); for i in 0..(width / 8) as usize { self.0[at + i] = (value >> (8 * i)) as u8; } } // idle(address, coprocessor_cycle) has a default that ignores internal cycles. } let mut ram = Ram(vec![0; 0x1000]); ram.0[0..4].copy_from_slice(&0xEAFF_FFFEu32.to_le_bytes()); // B . at the reset vector let mut cpu = ARM7TDMI::new(ram); cpu.reset(); // Supervisor mode, ARM state, the two refill fetches at 0 and 4 let cycles = cpu.step(); // the branch: 3 bus cycles (S, then the refill N and S) assert_eq!(cycles, 3); assert_eq!(cpu.pipeline[0], 0xEAFF_FFFE); let _ = CODE; ``` As in the reference, **every bus cycle is one callback, internal cycles included**, in chip order, each with the address the core drives, the width (8/16/32) and the access bits (`SEQ`, `CODE`, `LOCK`, the TRM's cycle types: merged IS reports S, and a GBA board maps it with `gba_access`). The host advances its devices inside the callbacks; `step()` returns the number made. `irq` and `fiq` are levels sampled at the start of each step. The one change Rust forces on the contract: `idle(address, coprocessor_cycle)` receives the CP14 flag the reference's callback reads from `cpu.coprocessor_cycle` (a Rust callback cannot see the CPU calling it). The reference's tools (disassembler, debugger, console) are not transcribed; its minimal harness and its CLI (`arm7tdmi ROM [--trace FILE]`, without `--debug`) are. ## Certification Against arm7tdmi-python `f492a9a`, the gate `scripts/ladder.sh` (commands, counts and commits in [docs/status.md](docs/status.md)): | Rung | Result | | --- | --- | | 0 decode tables, the reference's bus-schedule test transcribed | tables equal (4,096 ARM, 1,024 Thumb); 13 tests pass | | 1 SingleStepTests ARM7TDMI, the reference's gate transcribed | 2,192,923 of 2,192,923 gated cases; every file's counts equal to the reference's (excluded C2 5,578, C6 1,499, C7 50,000) | | 2 every corpus case in lockstep | 2,250,000 of 2,250,000 identical (every bus cycle, cycles, final state) | | 3 the reference's 15 CPU test ROMs through the CLI | 15 of 15 pass, and 8 of 8 other CLI cases; output and JSON Lines bus trace byte for byte the reference CLI's | | 4 the same ROMs, one lockstep slice per instruction | 15 of 15 identical | | 5 96 random-memory scenarios with IRQ and FIQ, 16 mask scenarios, 8 T-setting MSR scenarios | 120 of 120 identical | | 6 multiplies against zaydlang's hardware-fuzzed model | 7,000,000 of 7,000,000 | | 7 seeded faults | 52 of 52 caught; none by the emulator-derived corpus alone | **Speed** (not this tier's goal; docs/status.md "Speed"): 34-40 million instructions a second on one core natively, about 40 million as wasm32 under Node, on the test-ROM suite (a busy shared machine; about 40 times the reference on PyPy). Found on the way and reported to the reference (docs/status.md "Reported to the reference"): an MSR that sets T leaves ARM words in the pipeline and the next Thumb step indexes past the decode table (an `IndexError` in the reference, the same panic here; behaviour kept, not fixed downstream). ## Layout `src/` mirrors the reference module for module (`_core.py` → `core.rs`, the mixins as `impl` blocks); `src/tables.rs` is generated from the reference's tables (`scripts/gen_tables.py`). Binaries: `arm7tdmi` (the CLI), `arm7-sst` (rungs 1-2), `arm7-trace` (rungs 4-5), `arm7-multiply` (rung 6), `arm7-bench`. `wasm/` is a measuring host for wasm32 under Node. `scripts/env.sh` says where the reference and its data are (by environment variable; `scripts/fetch_reference.sh` clones the pinned reference into `external/`). Provenance: [docs/provenance.md](docs/provenance.md). ## Licence MIT (see `LICENSE`), except `booth_multiply` in `src/multiply.rs`, a transcription of zaydlang's multiplication model (Zlib), notice kept in the file and in `NOTICE`. Nothing third-party is committed: the corpus, the test ROMs and the model are read in place from the reference's `reference/` directory.