# Domains and speed ## Domains and channels Charter: a domain keeps its own time and meets the others only at channels. ### F2 | Domain | Contents | Clock | | --- | --- | --- | | main | 68000, work RAM, palette, the video chips' RAM and registers, I/O, the video timing and picture | 12 MHz CPU; video clock U4 | | sound | Z80, its RAM and ROM bank, YM2610 (and its ADPCM ROMs) | 4 MHz Z80, 8 MHz YM2610 | | Channel | Between | Kind | | --- | --- | --- | | TC0140SYT | main 68000 (master port 320000h/320002h on Cameltry) and Z80 (slave E200h/E201h) | nibble-wide command registers with status flags, and the Z80's interrupt and reset lines from the master side (which line: HYPOTHESIS) | | reset | main to sound | the master side's reset of the Z80 | The video chips stay in the main domain: the 68000 reads their RAM and registers on its own cycles, and every picture depends on mid-frame writes (row scroll, sprite buffers). The picture itself may become a pure producer in `-fast` (drawing a line from a register and RAM snapshot taken at the line's start), once the latch timing (U1) is known. ### F3 | Domain | Contents | Clock | | --- | --- | --- | | main | 68EC020, work RAM, palette, FDP graphics RAM and line RAM, FIO, EEPROM, timer, video timing and picture | 15.238 MHz (C1); 26.686 MHz video | | sound | 68000/68EC000, its RAM, OTIS (and its sample ROMs), ESP (and its delay RAM), DUART, volume, DAC | 15.238 MHz; ESP 8 MHz (C5); DUART 4 MHz | | Channel | Between | Kind | | --- | --- | --- | | MB8421 dual-port RAM | main C00000h-C007FFh, sound 140000h | 2 KiB shared memory; the MB8421's two mailbox interrupt locations (HYPOTHESIS that F3 wires them: unchecked) | | sound reset | main C80000h/C80100h to the sound CPU | reset lines | | (sound bank) | main 300000h "sound bank switch" in MAME's map | a main-side latch read by the sound side: what it selects is U17 | Inside the sound domain OTIS and the ESP meet over a serial bus at the sample clock; they can be stepped in sample order with the 68000 catching up at its bus accesses to them. ## Sync points - Main to sound: every main-CPU access to the MB8421, the reset latches and the bank latch; every sound-CPU access to the MB8421 (F3). The TC0140SYT ports (F2). - Interrupts: vertical blank (both), F3 levels 2, 3 and the programmable level 5 (a once-per-line rate in games: f3-board.md); the sound CPU's timer. ## Memory kinds (for save states and, later, block caching) ROM: program, graphics, sample ROMs (cartridge on F3). RAM: work RAM, sound RAM. Shared: the MB8421 (F3), the TC0140SYT registers (F2). Video RAM written by the CPU and read by the video chips. No self-modifying code risk outside RAM; F3 sound programs run from RAM after upload (the sound CPU's RAM sits at 0, `sound-address.txt`). ## The instructions-per-second need Observed in MAME 0.285 (closed box, tier 5: instruction counts, not timing), two frames traced deep in attract mode ([mame-oracle.md](mame-oracle.md)): | CPU | Clock | Traced | Per second | Ceiling (HYPOTHESIS) | | --- | --- | --- | ---: | ---: | | F2 68000 (Cameltry) | 12 MHz | 26,350 lines / 2 frames | 13.2 k x 60 = **0.79 M** | 12 MHz / 4 cycles = 3.0 M | | F2 Z80 (Cameltry) | 4 MHz | 13,283 / 2 | 6.6 k x 60 = **0.40 M** | 4 MHz / 4 = 1.0 M | | F3 68EC020 (Darius Gaiden) | 15.238 MHz (16 in MAME) | 56,260 / 2 | 28.1 k x 58.94 = **1.66 M** | 15.238 / 3 (cache hits) = 5.1 M | | F3 sound 68000 (Darius Gaiden) | 15.238 MHz | 87,150 / 2 | 43.6 k x 58.94 = **2.57 M** (mostly a wait loop) | 15.238 / 4 = 3.8 M | Non-CPU work per second: | Part | Arithmetic | Per second | | --- | --- | ---: | | F2 video | 320 x 224 x 60 = 4.30 M pixels; up to 5 layers (2 tilemaps, text, sprites, ROZ) | ~21.5 M layer-pixels | | F3 video | 320 x 232 x 58.94 = 4.38 M pixels; up to 8 layers into 2 half-pixels, blended | ~35 M layer-pixels, plus scaled sprites drawn into the framebuffer (budget U7) | | YM2610 | 8 MHz / 144 = 55.56 kHz (ym2610-python clocking-and-output.md); 4 FM + 3 SSG + 7 ADPCM channels | 55.56 k samples | | OTIS | 32 voices x 29.762 kHz | 0.95 M voice-samples (interpolate, 4-pole filter, 2 volumes) | | ESP | 8 MHz / 29.762 kHz = 268 clocks per sample; one instruction per clock at most (HYPOTHESIS, no datasheet) | up to 8 M simple operations | **Worst case to plan for:** F2 about 4 M instructions/s of two CPUs plus ~20 M layer-pixels; F3 about 9 M instructions/s of two CPUs, ~8 M DSP operations, ~1 M voice-samples and ~35 M layer-pixels. ## Does the no-JIT path reach real time? Measured family interpreter rates (this machine, i9-13900K, one core): `m68000-python` 0.65-1.39 M instructions/s on CPython 3.14, 18.7-33.5 M on PyPy 7.3.20 (its validation.md); `m68000-rust-fast` 104.6-112 M on its gate, 191 M synthetic (its build record; psx-python domains.md); `z80-rust` about 50 M (its README). A 68020 interpreter in the family's style does not exist; HYPOTHESIS: a transcription runs at half the 68000 `-fast` rate (more decode work, the cache tag check, bus sizing): 30-60 M. | Target (ratios as in psx-python domains.md, HYPOTHESIS) | F2 need: ~4 M CPU + video | F3 need: ~9 M CPU + DSP + video | Verdict | | --- | --- | --- | --- | | Python reference, PyPy | CPUs fit (19-34 M); per-dot video in Python is the cost | the 68020 core unknown; ESP + OTIS + per-dot video in Python | **below real time, by design**; rungs use short windows, as every family board | | Desktop, `x-rust` (transcription) | x10-x25 margin on the CPUs | x5-x10 on CPUs; video and sound a core each | real time | | `x-rust-fast` with threads (sound domain on its own core) | large margin | margin | real time, run-ahead 1-2 frames | | iPhone app, native (~0.8x), no JIT | real time | real time | **no JIT needed** | | Browser wasm (~0.6x) | real time | real time with the sound domain on a worker | no JIT needed | | Phone browser, A55 handheld (~0.2x) | real time from `-fast` | marginal: 9 M CPU + DSP + video at 0.2x of desktop; `-fast` threads (sound apart) likely enough, a cached interpreter is the fallback | `recompile: none` expected everywhere; measure before planning a turbo | `recompile: none` is the stated capability for both boards. No turbo tier is planned; build one only if a measured target fails (charter: tiers exist only where a target needs them).