# Domains and speed Where the Spectrum's domains and channels fall (charter, "Domains and channels"), how fast each tier must be, and whether the no-JIT path reaches real time on every target (charter, capabilities, `recompile: native | wasm | none`; emulator-lineage `docs/proposals/2026-11-jit.md`, accepted 2026-11-25). Phase 0: the board does not exist, so every speed figure below is an **estimate** with its arithmetic shown, anchored on measured sibling boards where one exists. ## Domains and channels The Spectrum is era 1: one crystal (14 MHz on the 48K, DIE: the netlist's clock module divides "OSC ... 14 MHz on the board"; the 128K models' crystal, divided to 3.5469 MHz for the CPU, is not given in the pinned sources), one CPU, and a video chip that stops the CPU's clock on every contended access. Everything a program can observe at a T-state lives in one domain. | Domain | Time base | Parts | Why | | --- | --- | --- | --- | | **Main** | CPU T-states (the ULA's CPU clock, after stretching) | z80-python, ULA/gate array (video, contention, port FE, /INT, floating bus, snow), ROM and RAM, paging, keyboard, tape (EAR level as a function of time), beeper level | the ULA decides the length of every Z80 T-state; splitting them would make every access a sync point | | **AY** (128K models) | AY input clocks (CPU/2) | ay8910-python | meets the CPU only at FFFD/BFFD; its output is a pure function of the register-write log over time | | **FDC and drive** (+3) | the FDC's clock and the disc's rotation | uPD765A, drive mechanics, disc image | meets the CPU only at 2FFD/3FFD and the motor bit in 1FFD; **stepped inside the main domain in the order of record** (as segacd-python steps its drive on the sub CPU's clock), because +3DOS polls the status register byte by byte | | Channel | Between | Sync point for a threaded tier | | --- | --- | --- | | OUT FFFD / BFFD (register select, data) | main -> AY | none for writes: appended to a log the AY drains (producer) | | IN FFFD (register read, incl. port A input) | AY -> main | **join**: the AY must have consumed the log up to this T; port A's input pins are main-domain state, so a read needs only the register file, not the sound | | 2FFD / 3FFD, 1FFD bit 3 | main <-> FDC | every access (same domain in the order of record) | | beeper / MIC level | main -> audio out | none: a level log, a producer | | frame picture | main -> host | none: the ULA's per-cell output log, a producer | Order of record (x-python): the main domain runs T-state by T-state as far as the ULA is concerned; the AY is caught up at each AY port access and at frame end; the FDC is stepped in the main loop. This is the catch-up-at-the-channel pattern of sega32x-python and segacd-python. Memory kinds (the cached interpreter's invalidation map): ROM, never written; RAM banks, written only by the CPU (there is no DMA on any model; the ULA only reads); the mapping changes on writes to 7FFD (all models with paging) and 1FFD (+2A/+3). A cached block is invalidated by a CPU write to its bytes or by a paging write. Self-modifying code is common on the Spectrum (loaders, decompressors, sprite routines). ## The need, with arithmetic - CPU: 3,500,000 T/s (48K) or 3,546,900 T/s (128K models), minus nothing: contention stretches T-states, it does not remove them, so the board must deliver 69,888 (or 70,908) T-states per frame at 50.08 (50.02) frames/s. - Instructions: Z80 instructions take 4-23 T; at a typical 7-9 T per instruction on game code (HYPOTHESIS: no Spectrum measurement here; ColecoVision's measured instruction mix is the nearest family figure to take when the board exists), 3.5 M T/s is about 390,000-500,000 instructions/s, before contention lengthens some. - ULA: the picture changes in 8-pixel cells every 4 T: 448 / 8 = 56 cells a line x 312 lines = 17,472 cell updates a frame, 875,000 a second (48K), plus one contention lookup per access (about 1.5-2 accesses per instruction: 0.6-1 M lookups/s). - AY: 1,773,450 input clocks/s; ay8910-python's internal step is every 8 input clocks: about 222,000 steps/s. ## Tier by tier, target by target (estimates) | Tier | Desktop | Phone (native app) | Browser (desktop / phone) | | --- | --- | --- | --- | | x-python, CPython | ~0.2-0.5 x real time | - | - | | x-python, PyPy | ~0.5-2 x real time | - | - | | x-rust | well above real time | above real time | above real time | | x-rust-fast | far above (run-ahead and rewind affordable) | above, with run-ahead 1-2 | above | Anchors (MEASURED on siblings, not this board): colecovision-python, a Z80 at 3.58 MHz with a TMS9918A and SN76489, runs at 0.3-0.5 x real time on CPython and 0.6-2.9 x on PyPy (its README and docs/results.md). The Spectrum adds per-access contention arithmetic and a cheaper video chip (no sprites), so the same band is the honest guess. z80-wasm (a z80-rust-fast build in WebAssembly) runs Galaxian's 3.072 MHz Z80 at full speed in the browser, live at galaxian.supertux.com: the Spectrum's CPU load is of the same order. **The no-JIT path reaches real time on every target** (desktop, iPhone app, browser), on x-rust already and with room on x-rust-fast: `recompile: none`, as the JIT proposal's family table says for era 1 ("the CPU is a small share of the frame; nothing to gain"). Threads are not needed; the AY as a producer thread is available if a weak handheld wants it. A turbo tier is not expected to be needed except for deep run-ahead on weak devices; build it only if a target measures the need (charter: tiers exist only where a target needs them). Python is fast enough on PyPy for the test programs the ladder uses (each runs a few seconds of emulated time), so the specification can be exercised by its judges directly.