# Handoff: build `arm11-python`, the Nintendo 3DS's ARM11 MPCore ## Context you are inheriting The 3DS's application processor is ARM's ARM11 MPCore: ARMv6K, two MP11 CPUs (four on the New 3DS), a VFP11 each, a VMSAv6 MMU, coherent L1 caches through the SCU, and the Distributed Interrupt Controller. It is the family's first multiprocessor ARM and its first ARM with an MMU. Its board is n3ds-python (`../n3ds-python`, Phase 0 tonight), which also composes arm946es-python (the ARM9, `../arm946es-python`, Phase 0 2026-11-26) and, for the legacy modes, arm7tdmi-python (`../arm7tdmi-python`, built). How the three relate: [core-choice.md](core-choice.md). Read in this order: [core-choice.md](core-choice.md), [isa-v6k.md](isa-v6k.md), [mmu-caches-mpcore.md](mmu-caches-mpcore.md), [vfp.md](vfp.md), [timing.md](timing.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [provenance.md](provenance.md); then arm946es-python's and arm7tdmi-python's docs for the family's ARM shape, and n3ds-python's execution-architecture.md for how this core will be run fast. Rules that bind: the charter and CLAUDE.md (MIT; Citra, its forks, Panda3DS, Mikage, dynarmic, QEMU and MAME's ARM code are never read or fetched here); never copy or read the 3DS boot ROMs (identified by SHA-1 in n3ds-python's census); evidence tags; Python 3.11 floor, PyPy green; no hardware probes; run anything reading `reference/` with `python -I`. ## Scope (first build) The ARM and Thumb instruction sets of ARMv6K, CP15 (VMSAv6 MMU, TLBs, caches, barriers, thread IDs, performance monitors as registers), the v6 exception model, the VFP11 with its bounce behaviour, 1-4 MP11 CPUs with the SCU (MESI on shared lines), exclusive monitors, the distributor and CPU interfaces, the private timers and watchdogs. Later: CP14 debug beyond what software reads, Jazelle beyond trivial BXJ, parity, power-down modes. ## Proposed names - `arm11-python`, package `arm11_python`. - `MPCore(cpus=2|4, icache_kb, dcache_kb, revision, bus)`: the macrocell, one object. - `MP11` (one CPU: registers, decode, execute, CP15, its MicroTLBs and L1 caches), `VFP11`, `SCU`, `Distributor`, `CPUInterface`, `PrivateTimer`, `Watchdog`. - Modules by instruction family as in arm7tdmi-python (`alu`, `media`, `multiply`, `loadstore`, `exclusive`, `branch`, `psr`, `cp15`, `vfp`, `thumb`), plus `mmu`, `cache`, `scu`, `gic` (named after the TRM's "Distributed Interrupt Controller"; the module name is a proposal), `timers`, `state`, `disasm`, `trace`. ## The bus contract (proposal, settle in the first commit) - The core issues **AXI-like transactions** past its L1s: `(cpu_id, kind, address, size, attributes, data)` with kinds line fill, write-back, non-cacheable read/write, strongly ordered or device access, exclusive; the board answers with data and a **duration in ARM11 clocks**. Non-cacheable and device accesses go out one by one; cacheable ones only on misses and write-backs. - **Interrupt lines in**: the board drives lines 20h-7Fh of the distributor (GBATEK's list) and nothing else; the core drives each CPU's IRQ/FIQ internally. - **Clock**: one integer time base, the ARM11 clock, shared by all CPUs and the private timers. A New 3DS clock-mode change (the board's CFG11) changes the ratio of that clock to the board's base clock, applied when all CPUs are in WFI (GBATEK CFG11_MPCORE_CLKCNT). - **CPU start**: CPU0 runs from reset; the board holds CPU1-3 (on the 3DS the boot ROM parks CPU1 until a software interrupt, and CPU2/3 are started through CFG11). The core exposes `hold(cpu)` and `release(cpu, vector)`. - **Order of record**: serial, one instruction per CPU in turn (FITTED for determinism: mmu-caches-mpcore.md), each instruction charging its time; a CPU waiting in WFI is skipped until an interrupt is pending for it. ## Unknowns (U) and contradictions (C) - U1. The 3DS's L1 cache sizes (16, 32 or 64 KB): read c0,c0,1. - U2. The MPCore revision (r0p? to r2p0): read c0,c0,0. Which TRM issue applies follows. - U3. Whether 3DS software runs with CP15 c1.U = 1 (v6 unaligned access) and with A = 0. - U4. Which TLB structures "Round-Robin" replacement covers, and the reset pointer. - U5. SWP/SWPB atomicity against the other CPUs (bus lock or not), and its timing. - U6. What advances the L1 round-robin replacement pointer. - U7. The exclusive reservation granule (TRM value to read and cite) and what clears the global monitor. - U8. Whether any 3DS title reads CP14. - U9. Whether any 3DS title executes BXJ or enters Jazelle state. - U10. The FPSCR each title runs with (RunFast or full compliance); the README of lioncash/3dscputests says Cubic Ninja enables RunFast (OBSERVED in its author's notes). - U11. TestFloat's licence and whether its vectors cover the VFP11's default-NaN rules. - U12. The MP11's cycle behaviour beyond the TRM's best-case tables (it disclaims exactness): no judge exists. Contradictions: - C1. GBATEK's ARM11 map marks 00000000h "ARM11 Bootrom mirror ;also ITCM in ARM11 ?"; DDI 0360F's ID_MMFR0 reports TCM support 0x0 (not supported). The TRM's reading is taken; the mirror is the boot ROM's. - C2. GBATEK marks the CPU2/CPU3 timer aliases at 17E00900h/17E00A00h "N/A in 3DS?" and elsewhere says starting CPU2/3 "enables corresponding registers at 17E00900h/17E00A00h" (CFG11_MPCORE_BOOTCNT): on the New 3DS they exist once the CPUs are started; on the Old 3DS (two CPUs) they are absent. Taken as a machine-row property. ## Rungs 0-7 as [validation.md](validation.md), each with its command and count. The core is done for the board's first milestone at rung 2 (single CPU, no MMU) and for its game milestones at rung 6. ## Domains and speed **Domains and channels.** The MPCore is **one domain** (charter: tightly coupled processors sharing memory usually stay one). Its channels to the board are the AXI transactions, the interrupt lines and the clock-mode register. Inside it, the CPUs meet at shared memory, the SCU, the monitors and the distributor at instruction granularity, so threads per CPU would need a synchronisation per shared access: not exact and cheap at once (n3ds-python execution-architecture.md). **Instructions per second needed** (HYPOTHESIS, arithmetic shown): - Old 3DS: 268.1 MHz (4 x 67.028 MHz: GBATEK gives "268MHz" and the 67.027964 MHz base) x 0.5-0.8 instructions per clock (0.8 is GBATEK's predicted SUBS+BNE loop, 2 instructions in 2.5 clocks; 0.5 allows for misses and interlocks) = **134-215 M instructions/s for a busy CPU**. The application runs on CPU0; CPU1 runs the system's services, busy a fraction of the time (HYPOTHESIS: 10-30 %). Total about 150-280 M/s. - New 3DS at 804 MHz: x3 per CPU, **400-640 M/s per busy CPU**, with up to two application CPUs for New 3DS titles (HYPOTHESIS). **Budgets** in desktop-equivalent host cycles per guest instruction on one core (n64-python's host assumptions: desktop 5.0e9, phone app 4.0e9, phone browser 2.4e9): | Load | Rate | Desktop | Phone app | Phone browser | | --- | ---: | ---: | ---: | ---: | | Old 3DS CPU0, busy | 160 M/s | 31 | 25 | 15 | | Old 3DS CPU0 + CPU1 on one thread | 200 M/s | 25 | 20 | 12 | | New 3DS CPU at 804 MHz, busy | 480 M/s | 10 | 8 | 5 | **Measured yardsticks** (family): arm7tdmi-rust 39.6 M instructions/s native with fat LTO (its docs/status.md, 2026-11-25, load 58-65), about 126-146 host cycles per instruction at 5.0-5.8 GHz, for a per-bus-cycle ARMv4T core with no MMU or caches; sh2-rust-fast about 145 cycles on an E-core; the N64's design target with cheap time-keeping 25-60 cycles (n64-python execution-architecture.md, HYPOTHESIS). arm7tdmi-python on PyPy: 0.83 M/s. **Does the no-JIT path reach real time?** - **Desktop**: an exact instruction-level interpreter with timing as data, a cached decode and a TLB/cache fast path would need about 25-31 cycles per instruction for a busy Old 3DS CPU0. That is at the bottom of the N64's design range and about 5x faster than the family's measured ARM core. **At the edge for Old 3DS titles; not reached for New 3DS titles at 804 MHz** (10 cycles). HYPOTHESIS, to be measured. - **Phone app** (no JIT on iOS): 20-25 cycles: **not reached** for busy Old 3DS titles by any exact interpreter the family has measured; light titles and idle-heavy ones may fit. - **Phone browser**: 12-15 cycles: **not reached** without `recompile: wasm`. - **Threads**: the MPCore stays one domain, so threads do not rescue the CPU side; they pay for the GPU, the DSP and the producers (n3ds-python). - The Python specification: 0.2-0.8 M instructions/s (HYPOTHESIS from arm7tdmi-python's 0.83 M/s, discounted for the MMU and caches): 1/200 to 1/1,000 of one busy CPU. Test programs and slices only (the late-era proposal's L1). So this core is where the family's `recompile: none` rule meets its limit: the capability record must say plainly that full speed on phones and in browsers needs recompilation (`wasm` in a browser) or is not offered. ## Open decisions for Aubrey 1. **A new core, not an axis on arm946es-python.** *Recommend* yes (core-choice.md). 2. **Modelling level: instruction level** with an interlock scoreboard, a modelled branch predictor, TLBs and caches as state, transaction-level memory; not stage-by-stage. *Recommend* yes, provisional (timing.md: ARM's TRM itself disclaims exact cycles). 3. **The core owns the whole MPCore macrocell** (SCU, distributor, private timers), with the L2C-310 in the board. *Recommend* yes. 4. **Order of record: one instruction per CPU in turn**, FITTED for determinism. *Recommend* yes, provisional. 5. **MAME's ARM code stays closed** (not even its licence lines read). *Recommend* yes, as arm946es-python asked. 6. **An ARMv6K single-step corpus generated by a closed box (QEMU's arm11mpcore) built in emu-tools-gpl**, used as a tier-5 detector at volume. *Recommend* yes: no hardware-captured corpus exists. 7. **VFP as a softfloat in Python** (no host floats). *Recommend* yes. 8. **The ARM11 MPCore TRM's source.** It is pinned from a third-party mirror under a `/private/` path because ARM's documentation service disallows automated clients. *Recommend* Aubrey downloads ARM's copy by hand once; if its SHA-256 matches, keep the pin and note it; if not, pin ARM's copy as a `manual` entry. 9. **arm946es-python's TRM pins** fetch from documentation-service.arm.com, whose robots.txt disallows all clients (found tonight). *Recommend* converting them to `manual` entries in that repository (their hashes stay) at its next session. 10. **Speed honesty in the capability record**: state `recompile: none` reaches real time for Old 3DS titles on desktop at best, and not on phones or in browsers. *Recommend* yes, and that a block cache in arm11-rust-turbo be the first turbo work for this line. ## What was not verified in this phase (candour) - No ARMv6 instruction stream was traced from a judge; MAME's one frame had none. - The 3DS's cache sizes and revision are unknown; every configuration value is the TRM's range or GBATEK's statement. - Chapter 15's tables were located, not transcribed; the build session reads them. - All speed figures are HYPOTHESIS with arithmetic shown.