# Handoff: build `arm60-python`, the 3DO's CPU core ## Context you are inheriting Chips are cores, boards compose cores, CPUs always get their own core (charter). This core's first user is `3do-python` (`../3do-python`, Phase 0 done in parallel; do not edit it from here). A board that finds a corner of this core raises it **on the core**. The nearest model is `arm7tdmi-python` (`../arm7tdmi-python`): the ARM6's successor, built, gated by 2.19 M SingleStepTests cases and hardware test ROMs. Copy its **shape** (mixins by instruction family, one handler per decode row, generated decode tables with `--check`, `state.py`, `disasm.py`, `debug.py`, `console.py`, `trace.py`, the readability test, the per-cycle bus contract), never its code (core-choice.md, option B). `arm946es-python` (`../arm946es-python`, Phase 0) made the same choice for the ARM9. Also read `../emulator-lineage/docs/proposals/2026-11-jit.md` (accepted): handlers in the restricted form, timing as data; the 3DO does not need recompilation (below), so do not bend anything for it. Rules: Python >= 3.11, CPython and PyPy; modern forms; MIT; no GPL/LGPL source read; FreeDO, 4DO and Opera never read (provenance.md); no firmware in the repository; local git only. ### Read in this order README.md; docs/start-here.md; docs/core-choice.md; docs/isa-v3.md; docs/timing.md; docs/validation.md; docs/mame-oracle.md; docs/provenance.md; then the ARM60 data sheet chapters 3, 4 and 7 in full (`reference/docs/arm60-zarlink.pdf`), DDI 0100E chapter A8, and arm7tdmi-python's docs/handoff-brief.md and docs/timing.md for the shape. ## Scope In: the ARMv3 integer core as the ARM60 implements it: registers and banking (6 32-bit modes, 4 26-bit modes), the PSRs and MRS/MSR, the 26-bit R15 and TEQP/TSTP/CMPP/CMNP, exceptions (address and vector exceptions included), the barrel shifter, the 2-bit Booth multiplier with its timing, loads and stores with both abort models, LDM/STM, SWP with LOCK, the coprocessor handshake as an interface (absent by default), the four configuration inputs, and every bus cycle (N/S/I/C) in chip order. Out (3do-python): memory, MADAM's wait states and MCLK stretching, the ROM overlay, the abort sources (MADAM's fence and privilege checks), CLIO's FIQ/IRQ sources. ## Proposed names - Repository `arm60-python`, package **`arm60_python`**; class **`arm60_python.ARM60`**. Constructor: `ARM60(read, write, idle=None, *, bigend=True, lateabt=True, prog32=True, data32=True)` with setters for the four inputs (they may change while running, DS 3.1). Defaults are the 3DO's as far as known (bigend OBSERVED; the others U4/U5, provisional). - Modules after arm7tdmi-python: `_alu.py`, `_psr.py` (32- and 26-bit), `_modes.py`, `_multiply.py` (the ARM6 Booth model), `_transfer.py`, `_block.py`, `_swap.py`, `_branch.py`, `_exception.py`, `_coprocessor.py` (the handshake protocol; absent by default), `_tables.py` (generated), `access.py`, `cpu.py`, `state.py`, `disasm.py`, `debug.py`, `console.py`, `trace.py`. ## The bus contract arm7tdmi-python's, so boards see one interface: `read(address, width, access) -> int`, `write(address, width, value, access)`, `idle(address)`, one call per cycle, internal cycles included, `width` 8 or 32 (no 16 on this bus), `access` a set of `SEQ`, `CODE`, `LOCK`, plus `USER` (nTRANS low). `irq`/`fiq` levels sampled at instruction ends through the synchroniser (U9). An abort is the board's answer to a cycle: `read`/`write` raise or return a flag the core turns into a prefetch or data abort (settle the form in the first commit; arm7tdmi- python has no abort input because the GBA has none). The core rotates non-aligned word loads; the board returns the aligned bus word in its own byte order (BIGEND tells the core which lane a byte load takes, DS 4.7.3). ## Unknowns (U) and contradictions (C) - U1 What ARMv4-only encodings (halfword loads, long multiplies, BX) do on the ARM60 (DS 4.1 says some undefined codes do not trap). Default: undefined trap, HYPOTHESIS. - U2 (folded into U1.) - U3 Values of the PSRs' reserved bits 27:8 on read. - U4 The 3DO's LATEABT strap. - U5 The 3DO's PROG32/DATA32 straps (firmware uses 32-bit modes: PROG32 high). - U6 Whether a read of 0x0-0x1F in a 26-bit mode of the 32-bit configuration aborts. - U7 Whether MADAM merges I-then-S cycles (board question; timing.md). - U8 The C flag after MULS/MLAS. - U9 The interrupt synchroniser's delay relative to the board's edge. - C1 Data processing writing R15: summary table 23 (+1I+1N) vs per-cycle table 8 (+1N+1S). Table 8 taken. - C2 MRC/MCR I-cycle counts swapped between the ARM60 and ARM7TDMI summaries (no effect on the 3DO). - C3 MAME runs the ARM60 as an ARMv4 core: its traces cannot judge ARMv3-only behaviour. ## Rungs (exit tests in validation.md) 0 tooling and decode; 1 the data sheet's per-cycle tables as unit tests; 2 the shared-subset differential against arm7tdmi-python's corpus; 3 26-bit modes against DDI 0100E A8; 4 MAME lockstep on 3do-python (FZ-10 BIOS); 5 seeded faults. ## Domains and speed **Domains and channels.** The core is part of one domain on the 3DO: the CPU and MADAM's bus (3do-python docs/domains.md). Its channels are the bus callbacks (every cycle), the nFIQ and nIRQ levels, and the abort answer. Sync points: every bus cycle that reaches MADAM or CLIO registers, VRAM shared with the cel engine, or DRAM shared with DMA; interrupt sampling at instruction ends. **Instructions per second needed.** 12.5 MHz (3dodev wiki and devnotes, tier 3; MAME runs it at 12.50 MHz). Each instruction takes at least one cycle, so 12.5 M instructions/s is the hard ceiling; MADAM's costs (sequential RAM 2 ticks, non-sequential 5, ROM 35; 3dodev wiki, ticks of the ~25 MHz system clock, i.e. 1, 2.5 and 17.5 CPU cycles if a tick is half a CPU cycle, HYPOTHESIS) put typical code nearer 5-8 M/s. MAME's model runs 5.2-6.3 M/s (mame-oracle.md). Plan on **8 M/s typical, 12.5 M/s worst**. **What the no-JIT path gives** (measured on the nearest core, arm7tdmi-rust docs/status.md, a loaded 32-CPU machine, lower bounds): arm7tdmi-python under PyPy 0.83 M instructions/s; arm7tdmi-rust native 33.9-39.6 M/s; wasm under Node 41.5 M/s. An ARMv3 core of the same shape should land in the same range (it is a subset, with a simpler multiplier timing loop). | Target | Expected arm60-rust(-fast) rate | Need | Verdict for the CPU alone | | --- | --- | --- | --- | | desktop native | 34-40 M/s (lower bound) | 8-12.5 M/s | real time with 3-5x headroom; no JIT | | browser (wasm, desktop) | about 40 M/s | 8-12.5 M/s | real time; no JIT | | phone native (iOS forbids JIT) | assume 1/3 of desktop: 11-13 M/s | 8-12.5 M/s | real time, thin margin at worst-case code; -fast's exact optimisations should suffice | | phone browser | assume 1/4-1/3 of desktop: 10-13 M/s | 8-12.5 M/s | borderline at worst case; a cached interpreter in turbo (no cache to model on the ARM60, so invalidation is by writes to code pages) is the next step, not a JIT | | arm60-python (PyPy) | about 0.8 M/s | 8 M/s | 1/10 of real time: the specification, short targeted cases only | The CPU is not the 3DO's cost; the cel engine is (3do-python docs/domains.md). The phone figures are assumptions until a 3DO Rust tier is measured on a phone. ## Open decisions for Aubrey 1. **Its own repository, not an `arch` axis on arm7tdmi-python** (core-choice.md, option B). Recommended: the 26-bit modes rewrite R15 handling in a certified core, the variant test would ride into the GBA's fast Rust tiers, and one chip per line keeps the readability contract. Alternative A (the axis) is closer here than for the ARM9 because the pipeline, bus and most timings are shared; choose it if one ARM codebase matters more than the above. 2. **Implement the 26-bit modes in the first build (rung 3), although the 3DO does not use them.** Recommended: they are the ARM60's specification and cheap once the PSR module is designed for them; an Acorn board would need them. Deferring them would mean redesigning `_psr.py` later. 3. **Default for absent ARMv4 encodings: the undefined trap, HYPOTHESIS (U1).** Recommended (2026-11-12 rule: default and mark provisional). 4. **Defaults for the 3DO straps: big-endian, late abort, PROG32 and DATA32 high, provisional.** Recommended; MADAM's abort reasons (3do-python) may later show the abort model. 5. **The differential detector reads arm7tdmi-python's fetched corpus from the sibling (`../arm7tdmi-python/reference/`) instead of fetching 840 MB again.** Recommended. 6. **FreeDO and its descendants (4DO, Opera) stay unread and unrun until you decide**: their licence forbids commercial use of anything learned from them, which an MIT core cannot honour. Recommended: excluded (not even a closed box) for this core, which does not need them. 7. **dwedit.org set aside for its robots.txt** (provenance.md); arm7tdmi-python still pins its DDI 0029E copy, and arm7tdmi-python and arm946es-python pin ARM's documentation service, whose robots.txt disallows every crawler. Recommended: re-source DDI 0029E (an ARM-hosted or bitsavers copy) and decide whether ARM's blanket disallow counts as an AI wall.