# Domains and speed Where the boards' **domains** and **channels** fall (charter, "Domains and channels"), how many operations a second each part needs, and whether the no-JIT path reaches real time (charter, capabilities: `recompile: native | wasm | none`; emulator-lineage `docs/proposals/2026-11-jit.md`, accepted 2026-11-25). Phase 0: nothing here is measured on this board, because it does not exist. Rates the games ask for are MAME's (OBSERVED, closed box); every speed for our tiers is an **estimate** with its arithmetic shown. ## Part 1: domains and channels | Domain | Time base | Parts | Why it is one domain | | --- | --- | --- | --- | | **Main** | TMS34010 machine states (INCLK / 8: 5.0, 6.0 or 6.25 MHz) and the 8 MHz dot clock | TMS34010; DMA blitter; VRAM and its serial side; palette; video timing and the display interrupt; CMOS, inputs, watchdog, control register; the protection device (Y, T) | the DMA takes the bus from the CPU by HOLD/HLDA (T-unit schematic, DOC) and the CPU polls its busy bit thousands of times a frame; the video timing is the CPU's own I/O registers; the autoerase and screen refresh use the same VRAM. Splitting any of it would make every access a sync point | | **Sound (Williams)** | the 6809E's E clock (2 MHz) | 6809E (two on Narc), YM2151, MSM6295 or HC-55516, DAC, PIA, bank registers, sound RAM and ROM | its own crystal and oscillator (3.58 MHz, 8 MHz: parts lists, DOC); meets the main board only at the command latch, the status/talkback port and reset | | **Sound (DCS)** | ADSP-2105 instruction cycles (10 MHz) | ADSP-2105, its boot and sound ROM banking, RAM, the autobuffered DAC | its own 10 MHz crystal (DOC); meets the main board only at the input/output latches, a status bit and reset | | **Security PIC** (Wolf only) | PIC16C57 instruction cycles (4 MHz / 4) | PIC16C57 | meets the main board only at its serial port | | **Picture out** | lines | palette lookup of each line's serial-register pixels | a **pure producer**: nothing it does is visible to the CPU (the CPU-visible timing stays in Main) | Narc's two sound 6809s share a command register and sync latches (map-narc.txt): they are one domain (tightly coupled, charter). ### Channels and sync points | Channel | Between | Sync point | | --- | --- | --- | | sound command write (Y `01E00000`; T `01D01020-3F`; Wolf `01680000`) and its interrupt on the sound CPU | Main -> Sound | every write: the sound domain runs to the main CPU's time first, then sees the latch | | sound status / talkback read (T `01D00000`; ADPCM `3C00` talkback) | Sound -> Main | every read (`mk` reads status about 1.2 times a frame on average; bursts at boot) | | sound reset | Main -> Sound | every write of the control bit | | DCS input/output latches and status | Main <-> DCS | every access | | PIC serial port (Wolf `01600000`) | Main <-> PIC | every access | | picture lines | Main -> Picture out | none for the CPU: the line's pixels and the palette are captured into a log the producer drains | **Order of record** (x-python, serial): the main domain runs; at each channel access it first runs the other domain up to the main CPU's time (the catch-up pattern of sega32x-python and segacd-python). The sound domain is otherwise run in slices at the end of each main slice. ### Memory kinds (who may write each region: the cached interpreter's invalidation map) | Region | Written by | Code runs from it? | | --- | --- | --- | | program ROM (`FF800000-`) | nobody | **yes: all main-CPU code** (OBSERVED: every PC in every trace is `FFxxxxxx`) | | image ROMs (`02000000-`) | nobody | no | | main RAM | CPU only (the DMA writes VRAM, not RAM) | not seen | | VRAM, palette, CMOS | CPU, DMA (VRAM), autoerase (VRAM) | no | | sound CPU ROM banks | nobody | yes (bank switches change what is mapped, not its contents) | | DCS program RAM | the DSP's boot loader (from the sound ROMs, at reset and at re-boot) | **yes**: all DSP code is RAM loaded by boot (sound-dcs.md) | | PIC program EPROM | nobody | yes | So the main CPU and the 6809 execute only ROM: a decoded-instruction cache needs invalidation only on bank switches (6809) and never on stores. The DSP's cache is invalidated on each boot load. ## Part 2: what each part needs per second | Part | Need | Arithmetic and basis | | --- | ---: | --- | | TMS34010, ceiling | 6.25 M instructions/s | 50 MHz / 8 = 6.25 M machine states (DOC); the fastest instructions take one state | | TMS34010, as the games run in MAME | 1.8-2.8 M instructions/s | `term2` 100,172 / 2 frames x 54.70684 = 2.74 M; `mk` 76,348 -> 2.09 M; `umk3` 67,236 -> 1.84 M (OBSERVED; cpu-needs.md) | | DMA blitter | 11-12 M pixels/s in a busy scene | `mk` 203,327 and `umk3` 216,540 width-times-height per frame, x 54.7 (OBSERVED counts, HYPOTHESIS that they are pixels); about 2 screens a frame | | Picture out | 5.6-5.7 M pixels/s | 101,600-104,960 visible pixels x 54.7 | | 6809E (each) | 0.5-1.0 M instructions/s | 2 MHz E clock at 2-4 cycles per instruction; MAME ran `mk`'s 6809 at 14,456 instructions / 2 frames = 0.40 M/s (OBSERVED) | | YM2151 | 1.79 M operator slots/s | 3.579545 MHz / 64 = 55.93 kHz samples x 32 slots (ym2151-python start-here.md, DOC) | | MSM6295 | 30 k voice-samples/s | 1 MHz / 132 = 7,576 Hz x 4 voices (msm6295-python, DOC; pin 7 as wired is to be read) | | HC-55516 | <= 0.03 M bits/s | one bit per clock the 6809 writes (sound-williams.md) | | ADSP-2105 | **10 M instructions/s** | input clock = instruction rate (ADSP-2100 manual section 9, DOC); MAME executed 325,069 in 2 frames = 8.9 M/s, 98.7 % of them in a wait loop (OBSERVED) | | PIC16C57 (Wolf) | 1 M instructions/s | 4 MHz / 4 (data sheet, DOC; MAME's clock) | The heaviest single item is the **DCS DSP at 10 M instructions a second** (MK II, every Wolf game), then the main CPU at up to 6.25 M, then the DMA's pixels. ## Part 3: is an interpreter enough without recompilation? ### What the family has measured (this machine: i9-13900K, one core) | Interpreter | Measured | Source | | --- | --- | --- | | m68000-python | 1.4 M instructions/s CPython, 33 M PyPy, a microbenchmark | m68000-python README (2026-09-25) | | sh2-python in a board | about 0.1-0.2 M instructions/s | sh2-rust docs/status.md, quoted in psx-python domains.md | | sh2-rust (plain transcription) | 30-47 M instructions/s native, 20-27 M wasm | sh2-rust README | | z80-rust (plain) | about 50 M instructions/s | z80-rust README | | m68000-rust-fast | 191 M instructions/s, synthetic | m68000-rust-fast README | | `-fast` over the transcription | x1.4-x1.9 | a2600, megadrive, m68000 forks | ### Estimates for this board (HYPOTHESIS until midwayyunit-rust measures them) - **tms34010-rust:** bit-field memory and two register files cost more per instruction than a Z80; take sh2-rust's range: **30-50 M instructions/s native**. Against the 6.25 M ceiling, 12-21 % of a core; against MAME's 2-3 M, 4-9 %. - **DMA in Rust:** 2-5 ns per pixel (a ROM fetch, transparency, scale step, VRAM write) x 12 M = **24-60 ms per emulated second** (2-6 % of a core). - **adsp2100-rust:** one 24-bit word per instruction, one cycle each, no flags beyond ASTAT: simpler than an SH-2: **40-100 M instructions/s**. 10 M needed: 10-25 % of a core, and an **exact** wait-loop skip (run to the next event that can change the polled register, gated as identical) removes about 98.7 % of it in `-fast`. - **6809, YM2151, MSM6295 in Rust:** 1-3 % of a core together (z80-rust's speed for the 6809; sn76489-rust's 117x real time as the scale for a PSG; an FM chip at 32 slots costs more). | Target | Main domain (CPU + DMA + picture) at the ceiling | DCS domain | Verdict, `recompile: none` | | --- | --- | --- | --- | | Desktop, native (1.0x) | 15-27 % of a core (x-rust) | 10-25 % (x-rust), ~1 % with the exact wait skip | **real time at x-rust on one core, 2.5-4x margin** | | iPhone app (no JIT; ~0.8x) | 19-34 % | 13-31 % | real time at x-rust; -fast gives run-ahead room | | Browser, desktop (wasm ~0.6x) | 25-45 % | 17-42 % | real time at x-rust (one thread: 42-87 % total); -fast for margin | | Browser, iPhone Safari (~0.5x) | 30-54 % | 20-50 % | -fast plus the wait skip, or the DCS domain on a worker thread | | ARM handheld (A55 class, ~0.2x) | 75-135 % | 50-125 % | **-fast plus threads at the sound channel**: main on one core, sound on another; the wait skip makes DCS small | Ratios between targets are the same assumptions psx-python's domains.md used (HYPOTHESIS, to be measured on the devices). **No target needs recompilation**: the main CPU's code is ROM (Part 1), so a cached interpreter is exact by construction if a later tier wants one, but the arithmetic says it is not needed. ### The Python specification At PyPy's rate for a board-level interpreter (0.1-1 M instructions/s for the CPU, by sh2-python and the 68000 microbenchmark bracketing it) the main CPU alone runs at about **1/3 to 1/60 of real time**, and the DCS DSP (10 M/s) at **1/10 to 1/100**. Python rungs therefore use short, targeted windows: the board diagnostics (`yunittst`, the games' POST), single attract scenes, and save points; long runs belong to the Rust tiers' lockstep, as era 2-3 boards do. The ADPCM games (no DSP) are the Python tier's natural first targets. The numbers that would replace these estimates: tms34010-rust's instructions/s on the `yunittst` run; the DMA's pixels/s in midwayyunit-rust on the `mk` fight scene; adsp2100-rust's instructions/s on `mk2`'s DCS boot; a phone run.