# Domains and speed ## Domains | Domain | Contents | Clock | | --- | --- | --- | | **C: CPU pair** | the main and sub Z80s, their ROMs, the shared RAMs (video, sprite, work), the sub's own RAM (map A), I/O ports and DIPs, the rotary inputs, the collision ports | 3.35 or 4 MHz (MAME; crystals U1) | | **V: video** | the text, background and sprite generators, the line buffers, the palette PROMs | the dot clock (U1) | | **A: sound** | the sound Z80, its ROM and RAM, the YM3526 / Y8950 / YM3812 (or AYs), the Y8950's ADPCM ROM, the YM3014 | 4 MHz | The main and the sub are one domain: they touch the same RAM on any instruction (the charter: tightly coupled processors usually stay one). V reads the RAMs C writes; it is a separate domain only if the arbitration (U2) gives it its own slots. ## Channels | Channel | Between | What crosses | | --- | --- | --- | | shared video and sprite RAM | C to V | CPU writes; V's fetches (and, if arbitrated, the slots C waits for) | | vertical blank and the CPU interrupts | V to C | the frame interrupt (U4: which line, which CPU) | | sound command latch | C to A | one byte, its doorbell interrupt | | sound status / acknowledge (MAME's $F800) | A to C | busy or done (U5) | | main-sub doorbells ($C700, $C000) | inside C | NMI to the sub; the main's path U4 | **Sync points:** a C-A meeting only at a latch write or a status read; V-C at every shared-RAM access while drawing, unless U2 shows separated slots. **Memory kinds:** ROM (program, tiles, PROMs: never written), shared RAM (written by both C CPUs), local RAM (sub's $F000 on map A, the sound CPU's), I/O. No CPU ever writes ROM, and no DMA exists, so a cached interpreter has nothing to invalidate except on code run from RAM (none seen at boot). ## Instructions per second (the arithmetic) - Main Z80, 1985-86 boards: 3.35 MHz / 7.17 cycles per instruction (OBSERVED, MAME `ikari` main, 27,906 instructions in 199,967 cycles) = **0.47 M/s**. Sub: the same, **0.47 M/s** (upper bound; it waits on the main much of the time). 1987-88 boards at 4 MHz: **0.56 M/s** each. - Sound Z80: 4 MHz / about 7 = **0.57 M/s** (assumed the same mix). - **Total: 1.5 M Z80 instructions a second (1985-86), 1.7 M (1987-88).** - FM: each OPL chip makes 4 MHz / 72 = 55,556 samples a second of 18 operator slots: **1.0 M slot steps per chip**; two chips (ikari, athena, victroad, psychos, gwar) **2.0 M**. The Y8950's ADPCM adds one decoder step per sample (0.06 M). - Video: unknown dot clock (U1). If it is near the 68000 boards' measured 6 MHz (HYPOTHESIS), about **6 M dots a second**. ## What that means per tier - **x-python (PyPy):** z80-python's base workload measured 66.6 M instructions a second on PyPy 7.3.20 and 2.7 M on CPython 3.14 (its validation.md, best samples on a loaded i9; a micro-benchmark without a board's bus callbacks). Three Z80s need 1.7 M: far inside PyPy, marginal on CPython. ym2413-python plays nine channels at "about 11 times real time on PyPy" (its README); an OPL has the same order of work, so two chips are a few times real time. The per-dot video is the cost. Expect near real time on PyPy without FM and below it with (HYPOTHESIS until the board runs). Reference boards are correct, not fast. - **x-rust:** z80-rust measures about 50 M instructions a second natively (its README, a plain ZEXALL loop on an i9-13900K): 30 times the need. A phone at a tenth of that still has three times the need; a browser (WebAssembly, typically half native) fifteen. **Real time on desktop, phone and browser with `recompile: none`.** - **x-rust-fast:** z80-rust-fast runs 350-400 M instructions a second (its README): only for headroom (run-ahead of one or two frames, Aubrey's habit, doubles or triples the work). - **Threads:** possible at the C-A channel (the latch); not needed. - **Turbo, JIT:** not needed on any target, the iPhone included.