# Domains, channels and speed ## Domains (charter, "Domains and channels") | Domain | Parts | Clock | | --- | --- | --- | | **Main** | MC6809E, video address generator and video output, DRAM, colour RAM, Special Chips, the ROM-board and widget PIAs, CMOS, watchdog, reset | the 12 MHz crystal: E = 1 MHz, everything locked to it (DEF-T) | | **Sound** (one per sound board; two on Sinistar cockpit and Blaster) | MC6808, its RAM and ROM, its PIA, the MC1408 DAC, and on Sinistar the speech module's ROMs and HC-55516 (driven bit by bit by the 6808, so stepped inside this domain) | its own 3.58 MHz crystal: E = 894,886 Hz, unrelated to the main crystal | The specification keeps a single timeline in a common unit (the order of record: main first on a tie) and converts each domain's cycles at the channels. ## Channels | Channel | From → to | What crosses | Sync point | | --- | --- | --- | --- | | Sound command | main (ROM-board PIA port B write) → sound (its PIA port B, CB1 edge → IRQ) | 6 or 7 bits and a strobe | the main CPU's write to the ROM-board PIA's port B | | Audio out | sound (DAC writes, CVSD output) → host | samples | a pure producer: the host mixes | | Inputs | host → main PIAs | switch levels | at frame or poll boundaries, recorded for replay | There is **no channel from the sound domain back to the main domain** (DEF-T: the CB2 handshake "is not implemented"; nothing else connects them). So the sound domain can run behind the main domain by any amount and stay deterministic: it needs only the time-stamped list of commands. That makes it the textbook case for a thread in `-fast`, if a target ever needs one. Inside the main domain the blitter and the CPU share one bus (the CPU halted while the chips run), and the video reads interleave every microsecond: they are one domain at cycle level, never split. ## Instructions per second needed - Main: 1,000,000 E cycles a second. A 6809 instruction averages roughly 4 cycles (HYPOTHESIS until measured on a Williams workload: the core's table runs from 2 to 20), so about **250,000 instructions a second**; during blits the CPU is halted and the chips spend one or two cycles a byte, so the bus total never exceeds 1,000,000 events a second. - Video: 16,640 fetches a frame x 60.096 = **1,000,000 fetches a second** (one per microsecond), 6 pixels each. - Sound: 894,886 cycles a second, about 4-5 cycles per 6800 instruction: **about 200,000 instructions a second** per sound board. - Whole machine: about 450,000 instructions and 2 million cycle-steps (main + sound) a second, plus the video's million fetches. ## Does each tier reach real time? | Tier | Estimate | Basis | | --- | --- | --- | | `williams-python` on PyPy | likely real time | m6800-python's benchmark: 45-82 M instructions/s on PyPy 3.11 for the bare core, and its Williams sound-board host ran 30 emulated seconds in 1.9 s on PyPy (15x real time) and 4.0 s on CPython 3.14 (7.5x) (MEASURED there; its README). The main board adds a 6809 of similar size, the blitter and per-microsecond video: an order of magnitude more work than the sound board alone would still leave PyPy near or above real time. To measure at milestone 2 | | `williams-python` on CPython | slower than real time likely | the reference board is correct, not fast (Aubrey's rule) | | `williams-rust` / `-fast`, desktop | far above real time | 2-3 M cycle-steps a second is a few percent of one core | | phone (native, no JIT) | real time with the plain interpreter | the same arithmetic; the family's Rust boards for heavier machines (Mega Drive, PC Engine) run real time on phones without a JIT | | browser (WASM) | real time | as play-2600 and play-nes, which run heavier per-cycle machines | **The no-JIT path reaches real time everywhere**: `recompile: none` is the stated capability; no cached interpreter and no threads are needed (the sound thread is available but not required). A `-turbo` tier is not expected to be needed; run-ahead of one or two frames on a phone would double or triple the load and still fit. ## Capabilities, as the board will report them Save states: small (48 KB DRAM + 1 KB CMOS + colour RAM, PIAs, blitter registers, two CPUs' state; well under 100 KB), deterministic; run-ahead and rewind cheap. Measured numbers come with milestone 2.