# Domains and speed Read with the charter's "Domains and channels" and "Capabilities" and the accepted JIT proposal (emulator-lineage `docs/proposals/2026-11-jit.md`, the no-JIT path first). The compact Mac is an era-2 machine: one CPU, every bus cycle observable, no recompilation needed. Everything here is a proposal for the specification to confirm. ## Domains **One domain on one clock.** C16M (15.6672 MHz) drives the pixel clock, C8M (the 68000 and the IWM's FCLK), the E clock (C8M/10, the VIA), and the SCC's 3.672 MHz is derived on the board (DOC: IM3 III-17, III-25; GMFH ch. 3). The CPU and the video/sound fetch share RAM by slots; nothing runs on an unrelated clock except the keyboard's MCU (its own 6 MHz or 3 MHz crystal: a separate domain if modelled at chip level, meeting the board only at the keyboard's clock and data lines) and the RTC's 32.768 kHz crystal (only the one-second edge crosses). Order of record inside one CPU clock (proposed): the glue's slot owner for this clock (video, sound/disk-speed, or CPU); the video word fetch if this is its slot; the IWM's FCLK step(s); the drive's bit position; the E-clock edge and the VIA's tick when C8M/10 says so; then the CPU's access in its slot (stalled otherwise); interrupt lines (VIA, SCC, switch) combined into /IPL2-0 and sampled by the CPU at its boundary. ## Channels (named now for `-fast` producers and catch-up) | Channel | From -> to | Mechanism | Lazy or threaded in `-fast` | | --- | --- | --- | --- | | Video fetch | RAM -> picture | one word per 8 clocks while shown; address a function of (line, word, vPage2) | **picture as a producer**: log CPU writes to the screen buffer with their clock (and vPage2 changes), render lines beside the CPU. The CPU's stalls depend only on the clock, not on the data, so the bus trace is unchanged | | Sound / disk speed | RAM -> PWM, ASG | one word per line | audio as a producer from (buffer writes, volume, vSndEnb/PB7 log); the drive speed by catch-up | | Interleave stall | glue -> CPU | a pure function of the clock | computed, not simulated | | VIA | CPU <-> VIA -> IRQ | E-clock synchronous accesses; timers underflow at computable clocks | catch-up with the next underflow as a sync point | | IWM / drive | drive -> IWM -> CPU | data register reads, SENSE | catch-up between CPU accesses: the IWM's inputs change only at transitions under the head (a function of time and the track) and at CPU accesses | | SCC | CPU <-> SCC; mouse -> DCD; host serial | registers; external-status interrupt | catch-up; host serial via a FIFO | | Keyboard | keyboard <-> VIA CB1/CB2 | 8 clocked bits, 330/400 µs cycles | protocol-level: events at computable clocks; chip-level MCU: its own domain at the line channel | | RTC | CPU <-> RTC via VIA PB0-2; one-second -> CA2 | bit-banged | on demand | | SCSI | CPU <-> 5380 <-> targets | polled registers | targets by catch-up | ## Instructions per second (the need, arithmetic shown) - CPU clocks: 7,833,600 a second; 130,240 a frame at 60.15 Hz. - Instructions: MAME 0.285 ran **969,119 instructions in 120 frames** of the Plus ROM's boot (to cycle 15,628,793): **16.1 clocks each, about 8,080 a frame, 486,000 a second** (OBSERVED; the boot is dominated by MOVEM RAM tests and VIA wait loops, and MAME charges no RAM contention, so real code with the interleave runs fewer). Ordinary 68000 code averages 8-12 clocks an instruction, so **the need is 0.5-1.0 M instructions a second**. - Video: 32 words x 342 lines x 60.15 = 658,000 word fetches a second; 10.5 M pixels a second if drawn by pixel, 658,000 if drawn by word (16 pixels at a time by table). - Sound: 22,255 samples a second. - VIA: 783,360 E-clock ticks a second. - IWM: up to 7.83 M FCLK steps a second while the drive is enabled; 489,600 bit cells a second under the head. Stepped per FCLK this is the heaviest load; by catch-up per bit cell it is one twentieth of that. ## Does the no-JIT path reach real time? | Target | Tier | Estimate | Basis | | --- | --- | --- | --- | | desktop, PyPy | `mac-python` (reference) | **near real time with the drive idle, 1/3 to 1/2 with the IWM stepped per FCLK** (HYPOTHESIS) | m68000-python alone runs about 33 M instructions a second on PyPy on a tight loop (its README, 2026-09-25); megadrive-python on PyPy runs a 68000 + Z80 + VDP + FM at about a third of real time (its README); the Mac's per-clock work is lighter than the Mega Drive's VDP and FM. Reference boards are correct, not fast (Aubrey's rule) | | desktop, CPython | reference | 5-10% of real time (HYPOTHESIS) | m68000-python: 1.4 M instructions a second on CPython bare | | desktop | `mac-rust` / `-fast` | several times real time | megadrive-rust runs 4-6x real time unoptimised (its README); m68000-rust-fast 191 M instructions a second bare | | phone, native, no JIT | `-fast` | real time with margin (HYPOTHESIS: to measure) | 1 M instructions a second against a core that does about 190 M bare; picture and audio as producers | | browser (WebAssembly) | `-fast` | real time | m68000-rust-fast's base loop: about 112 M instructions a second under Node (its README) | **Conclusion: `recompile: none` on every target.** A cached interpreter is not needed; threads only for producers (picture, audio); a `-turbo` is not expected for this machine. ## Capabilities (to measure when built) Snapshot: RAM (128K-4 MB), the VIA, SCC, IWM, RTC/PRAM, 5380 states, the drive (head, motor, rpm filter state, bit position) and the disk images' written tracks: 0.2-4.1 MB plus image deltas. Run-ahead and rewind cheap on the 128K/512K, heavier (4 MB snapshots) on a 4 MB Plus: the host decides. Concessions: none expected; the sound filter is a host choice.