# Execution architecture and the GPU-backend question Phase 0, 2026-11-26, in the shape of [n64-python's](../../n64-python/docs/execution-architecture.md): for each component, the backends that could run the model, the tier each belongs to under the charter, the sync points, how each backend is tested against the specification, and a numbers table. Nothing here was measured on a System 22 or on a family core for it: none exists. Tags as in [domains-and-speed.md](domains-and-speed.md). **Every emulator technique named here is an implementation choice, never hardware evidence.** ## The answer in one page 1. **The CPU side is small.** About 29 M guest instructions a second at peak (two DSPs at 10 M machine cycles each, a 68020, an MCU), which a table-timed interpreter covers on one core on every target (15-34 % of a desktop core, up to 70 % of a phone browser's). 2. **The renderer is the cost**, and it is the part with the least evidence: a texture-mapping, Gouraud-shaded, depth-cued rasteriser with no document, judged only by MAME's imperfect pictures. 37-55 M pixels a second at 80-200 host cycles each is 3-11 G cycles a second. 3. **Its join with the CPUs is cheap.** Neither 68020 map shows a frame-buffer window (OBSERVED), so the back end's output is needed only by the video output at the frame. The front end (primitive intake, whatever "busy" or timing the DSPs can see: U5) runs on the CPU thread; the pixel back end may lag up to a frame on threads or the GPU. This is the N64's front/back split with far fewer joins than the N64's shared RDRAM forces. 4. **So the GPU question has a good answer on paper:** a GPU back end in turbo, integer-only, held to the software rasteriser per pixel at each frame join, proven per device at start-up (n64-python decision X5), with one join per frame. Its weakness is upstream: the software rasteriser it is held to is itself a functional model with a tier-5 judge, so "exact" means "equal to our specification", never "equal to the hardware". ## Components ### MC68020 / MC68EC020 (`m68020-python`, then -rust, -rust-fast) Instruction level with transaction-level bus timing: the manual gives only best/cache/worst bounds (UM020 9.1-9.2), so cycle-exact overlap is not specifiable from evidence. Time charged per instruction from tables, plus per-transaction costs on cache misses and accesses outside the cache. The 256-byte direct-mapped cache (UM020 7.1.1) has no replacement state beyond its tags, so, as on the VR4300, a decoded line can be reused without re-checking for the rest of the line (an exact `-fast` technique). The game code runs from ROM: a cached interpreter never invalidates except for RAM-resident code, which must still be detected. | Backend | Tier | | --- | --- | | table-timed interpreter | x-python, x-rust | | decoded-line reuse inside a cache line; one deadline compare | -fast | | block cache, exact idle fast-forward on the 89-93 % spin loops | turbo | ### TMS320C25 x 2 (`tms320c25-python`) Cycle level from tier-2 documents (C2X's pipeline and timing). The master and slave talk through ports, densely by assumption: one domain, one thread. Programs live in the C71's mask ROM and in RAM loaded by the 68020; a cached interpreter invalidates on writes to program RAM. | Backend | Tier | | --- | --- | | interpreter with per-instruction machine cycles from tables (decision 5) | x-python, x-rust | | cached decode, one deadline compare per block | -fast if the lockstep holds | | exact fast-forward of port-wait loops | turbo | ### The renderer (in the board) | Backend | Tier | Notes | | --- | --- | --- | | software rasteriser, sequential, readable | x-python, x-rust | the judge for everything below; functional (no hardware evidence of its pixel rules) | | front end on the CPU thread, back end lagging up to the frame join | -fast (the frame and every DSP-visible signal identical) | needs U5: the DSP-visible timing must not depend on shaded pixel values (as n64-python X3) | | back end in scanline bands on N threads | -fast if exact | only if no state crosses pixels outside a band (translucency reads the destination, which is band-local) | | back end on the GPU (Vulkan, Metal, WebGPU compute), integer arithmetic only | turbo | proven per device at start-up; one join per frame | | higher resolution, filtering, widescreen | concessions | change the video output | **The observable contract for the renderer:** every pixel of each output frame, and every value a DSP or the 68020 reads that the renderer drives (status, counters), at the cycle it reads it. ### MCU and C352 An interpreter for the 7700 (`m7700-python`), cycle level from SW7700/UM37702. The C352 is a producer (sound synthesis from register state over time) once its register writes are logged. ## Sync points and their cost | Channel | Rate (to measure) | Kind | | --- | --- | --- | | 68020 <-> master DSP through `polygonram` and its registers | per display list, a few per frame (HYPOTHESIS) | inline catch-up on the CPU thread | | master <-> slave DSP ports | dense (HYPOTHESIS) | inside one domain | | DSP -> renderer front end | per primitive | inline, front end on the same thread | | renderer back end -> video | once a frame | the only join for threads or the GPU | | 68020 <-> MCU shared RAM | per frame for inputs and sound commands (HYPOTHESIS) | the MCU domain may run ahead to the next shared-RAM access | ## Deterministic testing across backends - Lockstep at block boundaries for the cached interpreters (CPU state, time, every cross-domain read at the same cycle); at every frame join for the renderer back ends (a CRC of the frame, and the front end's DSP-visible values at every read). - Seeded faults: a block reused after the 68020 rewrote DSP program RAM; a band split on a translucent primitive that crosses the band edge; a GPU path rounding a Gouraud step differently; a frame join skipped; the MCU run ahead past a 68020 write to shared RAM. - Replays: captured primitive streams (start state, primitives, textures referenced) run through the software rasteriser and each back end, compared per frame. - Never reported as hardware accuracy: "the GPU renderer matches the software renderer" is a differential claim, and the software renderer's own judge is MAME's picture (tier 5). ## Numbers Host assumptions (HYPOTHESIS, as n64-python): desktop 5.0e9, phone app 4.0e9, phone browser 2.4e9 desktop-equivalent cycles a second per core. | Component | Guest rate | Desktop | Phone app | Phone browser | Likely exact cost | Verdict | | --- | --- | ---: | ---: | ---: | --- | --- | | DSPs (2) on one thread | 20 M machine cycles/s (DOC, MAME clock) | 250 | 200 | 120 | 20-50 (HYPOTHESIS) | fits everywhere if timing is table-driven | | 68020 | ~8 M/s peak (HYPOTHESIS), 3.6 M in MAME | 625 | 500 | 300 | 40-80 (HYPOTHESIS; m68000-rust is ~35-50 per 68000 instruction, MEASURED 101-157 M/s) | fits | | MCU | ~1 M/s | 5,000 | 4,000 | 2,400 | ~40 | negligible | | All CPUs on one thread | ~29 M/s | 172 | 138 | 83 | ~25-60 averaged | 15-34 % / 19-42 % / 32-70 % of a core | | Renderer, full layer | 18.4 M px/s | 272 per px | 217 | 130 | 80-200 per pixel (HYPOTHESIS: tile-map texel fetch, 3+ interpolants, depth-cue blend, depth test, translucency) | 0.3-0.7 / 0.4-0.9 / 0.6-1.5 cores | | Renderer, overdraw 2-3 | 37-55 M px/s | 91-135 per px | 73-108 | 44-65 | 80-200 | 0.6-2.2 / 0.75-2.75 / 1.25-4.6 cores: threads or the GPU | | Python spec (for scale) | DSP perhaps 0.3-1 M instr/s on PyPy | | | | | slices only | **Without recompilation:** desktop, yes (one CPU thread plus 1-3 renderer threads); phone app, at the edge (2-3 renderer threads, or Metal compute); phone browser, only with WebGPU compute or a named concession (for example a lower internal resolution, recorded as such). Recompilation does not move this board: the CPUs already fit. ## Measure first (in this order) 1. A DSP job's host cycles per instruction in `tms320c25-rust` (shared with namcos21-python). 2. The renderer's primitive stream for one Ridge Racer frame, captured from a trace of the DSP output ports once the board's DSP domain runs (U1), then the software rasteriser's ns per pixel on it. 3. Pixels drawn per frame (overdraw) in three racing games and Time Crisis. 4. Whether anything CPU-visible depends on the renderer mid-frame (U5): if not, the frame join is the only one.