# Domains, channels and speed ## Domains | Domain | Clock | Contents | Why it is its own domain | | --- | --- | --- | --- | | **C: the computer** | the machine clock, 1.789773 MHz NTSC / 1.773447 MHz PAL ([AHRM] 4.2) | CPU, ANTIC, GTIA (two colour clocks per machine cycle), POKEY, PIA, memory and MMU, cartridge | one clock drives every chip, as on the 5200 (a5200-python docs/architecture.md: one domain) | | **D: a disk drive** (one per drive) | the drive's own oscillator: 6507 at 0.5 MHz (810) or 1 MHz (1050) ([AHRM] 10.10, 10.16) | at transaction level: the SIO protocol device and its rotation clock; at chip level (a later board): 6507, RIOT, FDC, the disk surface | unrelated crystal; meets the computer only on the SIO lines | | **T: the tape** | the tape's own motion (600 baud data, FSK audio) | the recorder: motor, data bit stream, audio track | runs only while MOTOR is low; meets the computer on SIO DATA IN, MOTOR and the audio input | Printers, modems and the 850 are further SIO devices, each its own domain if ever built. ## Channels | Channel | Between | Kind | | --- | --- | --- | | SIO DATA OUT | POKEY serial output → every peripheral | line, bit level (19,200 baud: one bit every 93.2 machine cycles; 600 baud: 2,983) | | SIO DATA IN | the sending peripheral → POKEY serial input (SERIN and SKSTAT bit 4) | line, bit level; readable on any cycle (Acid800 `pokey_serdirect`) | | SIO COMMAND | PIA CB2 → peripherals | line | | SIO MOTOR | PIA CA2 → tape | line | | SIO PROCEED, INTERRUPT | peripherals → PIA CA1, CB1 | interrupt lines (unused by disks and tape) | | SIO CLOCK IN/OUT | POKEY clock pins ↔ synchronous peripherals | line (unused by Atari's disks and tape) | | AUDIO IN | tape audio → the computer's audio mix | analog sum, a pure producer | Inside domain C the chips meet only through a5200-python's eleven named channels (bus, HALT, RDY, NMI, /IRQ, AN0-AN2, CONSOL, POT0-7, dump, keyboard matrix, TRIG0-3, cartridge enables), plus four new ones: the PIA's ports and control lines, the PIA's /IRQ (wired-OR with POKEY's), RNMI (400/800 Reset key into ANTIC) and the reset line (XL/XE), and the cartridge's RD4/RD5 (RD5 also into TRIG3 on the XL/XE). **Order of record (x-python):** domain C runs cycle by cycle in a5200-python's order with the PIA added at the bus access; a drive or tape domain runs in its own clock and is stepped up to the computer's current time whenever a channel line changes or is read (the computer sampling DATA IN; the drive's next scheduled edge), earlier time first, the computer first on a tie. The drive's edges carry their own time stamps converted at the channel. ## Speed: the need, with the arithmetic The board's work is per machine cycle, not per instruction: every one of the 1,789,773 cycles a second runs ANTIC's step, GTIA's two colour clocks and POKEY's tick, whether the CPU or ANTIC owns it. So the need is **1.79 M board cycles a second** (about 0.4-0.6 M 6502 instructions: 3-4 cycles each on average, with ANTIC taking 10-40 % of cycles depending on the display: [AHRM] 2.2 "~60-90 % of the maximum speed"). - A drive at transaction level adds almost nothing (a few events per byte). - A chip-level 810 adds 0.5 M cycles a second of a 6507 with an FDC and a RIOT (about 0.12-0.17 M instructions); a 1050 adds 1.0 M cycles (0.25-0.33 M instructions). Per cycle these are cheaper than the computer's (no video chips): HYPOTHESIS, a third of a computer cycle each, so +10-20 % total. Measured on the 5200, the same chips in the same order (OBSERVED, a5200-python and a5200-rust READMEs, this loaded shared machine): | Implementation | Pac-Man frames a second | x real time (59.92) | | --- | --- | --- | | a5200-python on CPython 3.14 | 2.6 | 0.04 | | a5200-python on PyPy 3.11 | 16.9 | 0.28 | | a5200-rust (x-rust tier) native | 375 | 6.3 | The computer board adds the PIA and the MMU decode (cheap) and the SIO work above, so **expect about the 5200's figures**: the Python specification runs Acid800 tests and short boots (a test of about one emulated second takes about 4 s on PyPy), not play. ## Does the no-JIT path reach real time? There is nothing for a JIT to do on a 1.79 MHz 6502 board; the question is only whether the interpreter tiers are fast enough. | Target | Estimate (x-rust 6.3x native, from a5200-rust) | Verdict | | --- | --- | --- | | desktop, native | 6.3x; ~5x with a chip-level 1050 | real time with x-rust; run-ahead of 1-2 frames fits | | browser (WebAssembly) | HYPOTHESIS: wasm at 0.5-0.7 of native → 3-4.5x | real time with x-rust; run-ahead of 1 frame fits | | phone (native, no JIT, e.g. iPhone) | HYPOTHESIS: a phone core at 0.3-0.5 of this desktop's → 2-3x | real time with x-rust; one frame of run-ahead (Aubrey's usual) doubles the work and is tight: an `-fast` tier pays here | | phone, browser | 1-2x | real time likely only with `-fast`; run-ahead needs it | So: **x-rust reaches real time everywhere; x-rust-fast is wanted for run-ahead on phones and phone browsers** (the a2600 and a5200 lines show what -fast gives on these chips: a2600-rust-fast x1.886). A cached interpreter has little to cache (one 6502), and threads help only at the SIO channel: a chip-level drive on its own thread, synchronised at SIO line changes. That is worth it only if the drive boards are built and measured to cost more than the hypothesis above. Turbo (per-line ANTIC/GTIA fast paths) is not needed for real time; it would be for weak handhelds with run-ahead. `recompile: none` (the charter's capability) holds for every target.