# Execution architecture: what each tier can be, the backends, and the honest limits Phase 0, 2026-11-26. Aubrey's aim: "construct a comprehensible, testable model of the machine, and then find the fastest way to execute that model". This page places the GameCube against n64-python's execution-architecture.md and the late-era method proposal (emulator-lineage docs/proposals/2026-11-late-era-method.md, a draft: its decisions L1-L8 are cited as proposed, not as rules). Numbers and their arithmetic are in [domains-and-speed.md](domains-and-speed.md). Every emulator technique named here is an implementation choice, never hardware evidence; another project's technique is named with its licence (pureikyubu: CC0, readable; Dolphin: GPL-2.0-or-later, closed box, its source never opened, its behaviour named only as OBSERVED where a public non-source record shows it). ## The answer in one page 1. **The Python specification can be:** the readable definition of every block; the place every fix lands first; and a runner of **test programs and short slices**. At 0.3-1.5 M Gekko instructions a second on PyPy (HYPOTHESIS) against a 300 M/s need, it runs at 1/200 to 1/1,000 of real time for the CPU alone, and its software rasteriser at seconds to a minute per frame (a 640 x 480 frame at overdraw 2 is 614,400 shaded pixels; at 20-100 µs a pixel in Python that is 12-61 s: HYPOTHESIS). A game's boot to its first frame (2-10 emulated seconds: HYPOTHESIS, 0.6-3 G instructions) would take 7 minutes to 3 hours of CPU time alone (0.6e9 / 1.5e6 = 400 s; 3e9 / 0.3e6 = 10,000 s). **The Python specification never boots a commercial game as a gate case.** It validates on test programs (our own, homebrew, the closed-box hwtests route) and on slices started from states a Rust tier writes (late-era method L1, L3). 2. **`gamecube-rust` is the first tier that runs games** (L2), in per-bus-cycle lockstep with Python on the test programs and the slice list; its claim is "identical to the specification on N slices and M test programs", never more. 3. **`-fast`** carries the exact interpreter with cheap time-keeping (time from data, one deadline compare: the SH-2 lesson), paired singles on SIMD where bit-exact, the DSP on its own thread, the GX front end on the CPU thread and its pixel back end on threads. By the estimates it reaches 0.3-0.8x real time on a desktop for typical games, less on phones (domains-and-speed.md). 4. **Turbo** is where real time comes from: Gekko and DSP block recompilation (native where allowed, wasm in browsers), exact idle-loop fast-forward (L8), and a **GPU backend** for the pixel pipeline under the observable contract, per pixel and per device (L6). 5. **Named concessions** are unavoidable on iOS native apps (no JIT) and likely in phone browsers (domains-and-speed.md lists them). ## Backends per component Tiers follow the charter: what keeps every bus cycle identical goes in `-fast`; what keeps only the observable contract goes in turbo; recompilation is a turbo fast path with the interpreter as fallback; what changes results is a named concession, off by default. ### Gekko (gekko-python, then -rust, -rust-fast, -rust-turbo) | Backend | Tier | What it changes | Notes | | --- | --- | --- | --- | | interpreter: generated decode, one handler per row, the timing table, caches with tags, PLRU and data, MMU with TLBs | x-python, x-rust | nothing | the specification and its transcription | | exact fast interpreter: packed decode, time charged from the table, one deadline compare, deferred time flushed at each bus transaction | x-rust-fast | layouts only | the SH-2 lesson: time-keeping is the cost | | cached interpreter keyed by I-cache line | x-rust-fast if exact by lockstep | the fetch path and decode | tree pseudo-LRU is idempotent under repeated hits to the same way (HYPOTHESIS: to check against UM chapter 3's PLRU algorithm), so a decoded line may update PLRU once per entry. Invalidated by `icbi`, a line refill, HID0 flash invalidate, a BAT/SR/TLB change that remaps it, and a state load | | paired singles on host SIMD (two f32 lanes: SSE, NEON, wasm SIMD128) | x-rust-fast **only where proven bit-exact** | arithmetic layout | IEEE single rounding per lane is exact for add/sub/mul/div in round-to-nearest; fused multiply-adds, the estimates (`ps_res`, `ps_rsqrte`), non-IEEE mode, denormal flushing and directed rounding take the specification's software path (U9, U5 in gekko-python). wasm has no rounding-mode control and baseline wasm no FMA | | quantized loads/stores as table-driven conversions | x-rust-fast | layout | exact integer arithmetic; the scale as an exponent add | | block compilation to native code | turbo, `recompile: native` | dispatch, register traffic | blocks end at every sync point (domains-and-speed.md); the locked cache and WGP addresses are sync-sensitive stores; invalidation from DVD, ARAM, DSP and EFB-copy DMA into RAM | | block compilation to wasm | turbo, `recompile: wasm` | as above, in browsers | modules per hot region (HYPOTHESIS: module compiles cost milliseconds) | | exact idle-loop fast-forward (a loop whose only input is one channel value with a known next change and fixed iteration cost) | turbo (L8) | skips iterations; interrupts still at their exact ticks | pureikyubu measured half of a title's instructions in a Dolphin OS wait loop (OBSERVED); its own skip is a different, inexact mechanism with a cap | ### DSP (gcdsp core, proposed) | Backend | Tier | Notes | | --- | --- | --- | | interpreter, 40-bit accumulators, the parallel-move decode, the accelerator and DMA as devices | x-python, x-rust | readable first | | DSP on its own thread, synchronised at the mailboxes and DSP control | x-rust-fast if the lockstep holds (conservative: the DSP runs ahead until the CPU's next mailbox access) | mailbox polling by both sides is dense in some ucodes (HYPOTHESIS): a polling CPU reading the DSP's mailbox every few instructions makes cross-thread handshakes cost more than they save (n64-python's cost model: 500-1,500 host cycles a handshake); then the DSP runs **ahead** with a log of channel reads and an exact rollback on a CPU write that lands before one of them, as n64-python proposes for the RSP | | block cache keyed by IRAM content hash and start PC | -fast if exact | ucode is re-uploaded for every task (HYPOTHESIS from YAGCD 5.6.2.4's boot mails); keying by content keeps decoded blocks across uploads, as n64-python proposes for the RSP's IMEM | | block compilation | turbo | | | ucode HLE | **concession** `dsp_hle` | changes timing and arithmetic; measured against LLE | ### GX: a timing front end and a pixel back end The split n64-python proposes for the RDP fits the GX, with one GameCube twist: **the EFB is on the chip**, so the back end's results reach the rest of the machine only through copies, peeks and the bounding box. - **Front end** (on the CPU's thread, in order of record): the CP's FIFO reader, register loads, the vertex loader and XF (which a GPU backend also needs as data), primitive setup, and a **timing estimate per primitive** that gives the CP's read pointer, the watermark interrupts, tokens and FINISH their ticks. Whether the GX's timing is a function of commands and state alone (so that the front end can know it without shading pixels) is an open question (U21): if early-Z or texture-cache misses change the time a draw takes, the front end must model them. - **Back end** (the pixels): rasterisation, texturing, TEV, PE, writing the EFB. It may run behind the front end on threads, or on a GPU. It meets the machine only at **joins**: 1. an EFB copy (the copied rectangle must be finished before the copy's RAM writes happen at their tick); 2. a CPU EFB peek or poke at 0x08000000; 3. a bounding-box read; 4. a texture, TLUT or vertex-array read of RAM that the CPU or a DMA has written since the back end last caught up (the back end must read RAM as it was at the draw's tick: a hazard map over RAM pages with copy-on-write snapshots, as n64-python's RDRAM proposal does); 5. the VI reading an XFB the copy writes. - **GPU backend** (turbo, L6): the back end in GPU compute or a graphics API (Vulkan, Metal, WebGPU), the software back end of `-fast` as the fallback, the host able to turn it off, proven **per pixel** against the software back end over the same command streams (every EFB byte as seen at every join) and **per device** (a start-up conformance set; `gpu_backend: verified | failed | absent`). TEV integer arithmetic maps to integer shader arithmetic; texture filtering must be done in the shader, not by the GPU's fixed-function samplers, to stay exact (HYPOTHESIS: the GX's filter weights are unlikely to match a host sampler bit for bit). Joins are expensive on a GPU (0.1-1 ms each): EFB peeks are the backend's worst case, hence the `efb_peek_coarse` concession. - **Upscaling, texture replacement, widescreen hacks, anisotropic filtering beyond the hardware's** are concessions (they change the video output), off by default. ### VI, AI, drive, EXI, SI Cheap: the VI's counters and per-line XFB fetch, the AI's sample stream (a producer), the drive's command model and its DMA (a timed event per transfer), the EXI and SI devices (stepped in the CPU domain). None needs more than `-fast`'s ordinary care. The VI's filters and the final scaling are producers that may run on another thread. ## State transplant (late-era method L3) The board's state format is shared by x-python and x-rust from M1 (L3), declared in a schema file in this repository (L4): every domain's tick; the event queue; the GX FIFO's pointers and any commands in flight; the GX front end's state and the back end drained to the cut; the EFB and TMEM; the DSP's registers, memories, accelerator and DMA; ARAM; the CPU's registers, caches with tags, PLRU and data, TLBs, the locked cache, the DMA queue, the write-gather buffer; every interface's registers; the drive model's position. Not held: decoded blocks, compiled code, GPU resources. The cut is between two Gekko instructions. About 43 MB raw (domains-and-speed.md). ## Testing the backends against each other - Python against `gamecube-rust`: per-bus-cycle lockstep on test programs and slices. - `gamecube-rust` against `-fast`: per-cycle lockstep over whole games (Rust against Rust is cheap). - `-fast` against turbo: the observable contract (every CPU read value and its tick, every interrupt as taken, the video output, the audio output, save states), per pixel for the GPU backend, with seeded faults aimed at what recompilers and GPU backends get wrong (a stale block after a DVD load into code, a missed join before an EFB copy, a lane computed with host FMA, a texture sampled by the host's filter). ## What the GameCube asks of the method that the N64 did not - **A floating-point CPU whose rounding corners are undocumented** (paired singles, FMA, estimates): the specification must choose and say so, and every tier must reproduce the choice bit for bit; host SIMD is allowed only where proven equal. - **An on-chip frame buffer** whose contents are visible only through joins: the GPU backend's cost is set by the number of joins a title makes, which only a run can count. - **A second programmable processor with uploaded code** (the DSP), like the RSP. - **A drive with its own CPU and firmware** that the specification replaces with a functional model: the first family board where a whole subsystem is functional by design.