# Domains and speed Read with the charter's "Domains and channels" and "Capabilities", and the JIT proposal (emulator-lineage `docs/proposals/2026-11-jit.md`, accepted 2026-11-25: the no-JIT path first). Everything here is a proposal for the specification to confirm. ## Domains | Domain | Holds | Clock | Why | | --- | --- | --- | --- | | **C: CPU** | TMS9900, console ROM, scratchpad, the 16/8-bit multiplexer, TMS9901 (its timer counts φ/64), keyboard and joysticks, cartridge ROM/RAM, the 32K expansion and PEB card memory | 48 MHz crystal → 3.000 MHz | one bus master; everything it touches without a separate clock | | **V: video** | TMS9918A/9929A and its 16 KiB VRAM | 10.738635 MHz crystal | its own crystal; meets C only at the four VDP ports and its interrupt line | | **G: GROMCLK devices** | the console's and the cartridge's GROMs, the TMS9919 sound chip | 447 kHz = V's crystal / 24 | locked to V's crystal but scheduled apart from it: they never talk to the VDP. The GROMs are stepped **inside C's order of record** (the charter allows it, saying so): they answer only the CPU, synchronously, through READY, so their GROMCLK phase is computed from the common timeline at each access. The sound chip is a pure producer: its channel is a timestamped write log | | **S: speech** (add-on) | TMS5220-family synthesizer, two TMS6100 VSMs | its own 640 kHz RC oscillator | own clock; meets C at 9000/9400, READY and the AUDIO IN line | | **D: disk** (later row) | FD1771 and the drives | the card's own clock | own clock; meets C through its DSR ROM window, CRU bits and memory-mapped registers | **The common timeline.** The CPU (3,000,000 Hz) and the VDP (10,738,635 Hz, MAME's figure for the NTSC crystal) share no clock. gcd(3,000,000, 10,738,635) = 15, so a tick of 1 / 2,147,727,000,000 s makes both exact: one CPU clock = 715,909 ticks, one VDP master clock = 200,000 ticks, one GROMCLK = 4,800,000 ticks. A 64-bit counter holds about 99 days of ticks. (If the PAL machine's crystal differs, its row gets its own tick; MAME runs `ti99_4ae` at the same pixel clock, OBSERVED.) The order of record on a tie: C first. ## Channels | Channel | From → to | Mechanism | Sync point for | | --- | --- | --- | --- | | VDP ports 8800/8802/8C00/8C02 | C ↔ V | CPU memory cycles through the multiplexer | every access: V is brought up to the access's tick first (status reads clear flags; data reads and writes move the VRAM pointer) | | VDP interrupt | V → C | /INT level → 9901 INT2 → CPU level 1 | the edge's tick: C must not run past the next possible edge (computable ahead from V's line counter when the mode is known) | | GROM ports 9800/9802/9C00/9C02 | C ↔ G | CPU memory cycles + READY | every access (inside C's order of record) | | sound port 8400 | C → G | write | a timestamped write log consumed by the synthesis (pure producer) | | speech ports 9000/9400 | C ↔ S | CPU memory cycles + READY | every access; S also raises nothing but its status (no interrupt line on the 99/4A) | | audio | G, S, cassette → host | sample streams | none (producers) | | I/O port, cartridge port | C ↔ add-ons | the sockets (peb.md) | every access to the card's window | MAME's bus census (closed box; `tests/detectors/mame-bus-census-2026-11-26.txt`, OBSERVED) gives the traffic on these channels with no cartridge: | Window | VDP read | VDP write | GROM read | GROM write | sound | DSR space | | --- | --- | --- | --- | --- | --- | --- | | power-on to frame 120 (1.99 s) | 4,196 | 24,326 (+ 24,326 read-before-write reads) | 11,853 | 6,300 (+ 6,300 reads) | 7 (+ 7) | 16 | | title screen, 1 s | 60 | 0 | 6,643 | 3,322 (+ 3,322 reads) | 0 | 0 | So the channels are crossed some 10-30 thousand times a second: rare against the CPU's roughly 0.8-1.5 M machine cycles a second (one crossing in 30-100), which is what makes per-access synchronisation cheap. ## Sync points, memory kinds, timing as data (the JIT proposal's declarations) - **Sync points**: every row of the channel table, and the CPU's interrupt sampling point. - **Memory kinds**: console ROM (ROM), scratchpad (RAM, code runs there: the console copies routines into it; written only by the CPU), cartridge ROM (ROM, banked by writes), cartridge RAM/NVRAM, 32K expansion (RAM, written by the CPU only: there is no DMA on the 99/4A until a PEB card with HOLD), GROMs (not CPU-executable: GPL bytecode read through a port), VRAM (not CPU-executable). - **Timing as data**: tms9900-python's `timing.py` (its brief), the multiplexer's wait states and the GROM READY durations in one table here, each tagged. ## Instructions per second, with the arithmetic - **CPU**: at most 3,000,000 / 8 = 375,000 instructions/s (the shortest instructions, no waits); MAME at the title screen: 161,014 instructions in 1.001 s (tms9900-python docs/mame-oracle.md), 18.7 clocks each. Code on the 8-bit bus only lowers the rate. - **VDP**: 342 dots × 262 lines × 59.92 frames = 5.37 M dots/s (MAME's `listxml` screen: pixclock 5,369,317 Hz, OBSERVED), or 10.74 M master clocks/s in tms9918-python's unit. - **Sound**: 447,443 / 2 = 223,722 ticks/s (video-and-sound.md), three tone counters and one LFSR per tick. - **GROMs**: a few thousand to ~10,000 byte accesses/s (above); negligible. - **Speech** (add-on): 8,000 samples/s through a ten-stage lattice = 80,000 filter steps/s, plus frame interpolation every 3.125 ms. The VDP dominates: about 5.4 M dots/s against 0.16-0.375 M CPU instructions/s. ## Does the no-JIT path reach real time? | Target | Expected | Why | | --- | --- | --- | | Python, PyPy (the reference) | about 0.3-0.5 × real time | tms9918-python alone renders Graphics II with sprites at 56.9 frames/s on PyPy (0.95 ×, its README, measured 2026-11-12); the CPU at the machine-cycle contract (~1 M cycle callbacks/s) adds about as much again. Enough for every rung ("reference boards are correct, not fast") | | Rust (`ti99-rust`), desktop | many times real time | the same order as a2600-rust or gameboy-rust boards; the VDP is the cost | | Rust -fast, phone and browser (wasm, no JIT) | real time with margin | a 5.4 M dot/s TMS9918A and a 0.4 M instruction/s CPU is far below what the family's -fast boards already do in browsers (play-2600, play-gb, play-md run larger loads) | | Threads at domain channels | optional, not needed | the VDP could draw from a register-write log as a pure producer (the charter's example) if a weak target wants it; sound and speech are producers already | So `recompile: none` on every target. No cached interpreter is needed for the TMS9900 (prune what does not pay); no turbo tier is expected to be needed except for run-ahead on weak phones, which a -fast board at this load should cover.