# Domains and speed The charter's "Domains and channels" and "Capabilities", applied to the Mono-I CD-i. Every number marked *estimate* waits for cdi-rust to measure it. ## Clocks (DOC unless marked) | Clock | Rate | Source | | --- | --- | --- | | SCC68070 crystal / CPU clock | 30 MHz / **15 MHz** | MAME `-listxml` (OBSERVED) and data sheet Fig.18 | | SCC68070 timer | 30 MHz / 192 = 156.25 kHz (6.40 us) | data sheet 5.13 | | MCD212 CLK | 30 MHz (PAL) / 30.2097 MHz (NTSC TV) / 28 MHz (NTSC monitor) | MCD212 5.2-5.3; which crystal each player fits is U6 | | Video line | 1,920 CLK = 64.0 us (PAL); field 312 lines (50 Hz) or 262 (60 Hz) | MCD212 Tables 5-5, 5-6 | | DRAM display period | 32 CLK = 2 system slots | MCD212 4.2 | | Slave and servo MCUs | 4 MHz oscillator, 2 MHz internal | MAME (OBSERVED); 6805 family | | CD | 75 sectors/s (every CD-i player is single speed), 2,352 bytes a sector | Green Book III | | Audio | ADPCM 37.8 / 18.9 kHz; CD-DA 44.1 kHz | Green Book IV | ## Domains | Domain | What is in it | Why it is one domain | | --- | --- | --- | | **D1 main** | SCC68070 core with its on-chip DMA, timer, UART, I2C, MMU and interrupt controller; the MCD212's **system controller** (DRAM arbiter, ROM/IO decode, DTACK and BERR, reset sequencer, watchdog), its **video timing** and its **ICA/DCA engines and display fetches**; DRAM, ROM, the timekeeper NVRAM | every CPU DRAM access waits for a system slot whose position is set by the video timing (MCD212 4.2: one every 16 CLK during display); ICA/DCA instructions change registers at line and field positions the CPU polls (CSR1R display-active bit, the INT). Splitting them would put a channel on every memory access | | **D2 picture** (pure producer) | the MCD212's pixel pipeline: file decoding (bitmap, RL7, RL3, mosaic), CLUT/DYUV/RGB555, transparency, regions, weights, cursor, backdrop, RGB888 out | it reads only what D1 hands it; nothing it computes is visible to software | | **D3 disc** | the disc image and drive model (sector clock, seek, spin-up), the CDIC (sector decoding, filtering, buffers, ADPCM routing), its PCB5010 partner as a function | its own clock (the disc's 75 Hz sector rate); it meets D1 only through the CDIC window and three lines | | **D4 slave** | the slave MC68HC05C8 running its firmware (or the functional slave), the pointing-device serial port, the IR receiver, the front-display I2C | its own 4 MHz clock | | **D5 servo** | the servo MC68HC05C8 and the drive's mechanics as seen by it | its own clock; optional (D3 can model the drive functionally) | | **D6 sound** (pure producer) | ADPCM decoding, CD-DA, attenuation and mute, mixing, the DACs | it reads the CDIC's audio buffers and control state over time; nothing it computes is visible to software | | D7 DVC (later) | FMV/FMA (or IMPEG), its DSP56001, its RAM | its own clocks; channels: DMA, IN4, its register window | ## Channels | Channel | Between | Kind | | --- | --- | --- | | CDIC window `300000-303FFF` (buffers and registers), DTACK delay | D1-D3 | shared memory, word accesses | | CDIC interrupt (IN4) | D3 -> D1 | interrupt line | | DMA channel 1 REQ/ACK (sectors to memory) | D3 <-> D1 | handshake | | slave channels A-D `310001-310007`, DTACK delay | D1-D4 | four byte ports | | slave interrupt (IN2) | D4 -> D1 | interrupt line | | slave <-> servo SPI (500 kHz, measured on a 210/05) | D4-D5 | serial | | drive control and status (servo or functional drive) | D5/D4 -> D3 | ports | | pointer port (1200/9600 baud), IR, front-panel keys | host -> D4 | input | | display-fetch log: per line, the words each channel fetched and the register writes with their dot positions | D1 -> D2 | FIFO | | audio state log: buffer contents and control writes with times | D3 -> D6 | FIFO | | SCC68070 UART (`/t2`) | D1 -> host | serial | **Order of record** (x-python): D1 runs instruction by instruction. D3, D4 and D5 are caught up to D1's time whenever D1 touches one of their channels, and at their own events (the next sector, the slave's timer), with D1 seeing their interrupts at the step the catch-up places them. D2 and D6 run once per line and once per audio block from their logs. This is sega32x-python's catch-up-at-the-channel pattern; the domains.md of segacd-python shows a drive stepped inside another domain the same way. ## The instructions-per-second need **SCC68070.** The CPU clock is 15 MHz. The fastest instruction is 7 clocks (`MOVE.W Dn,Dn`, `ADDQ`, `MOVEQ`: data sheet Tables 12, 15), so the ceiling is 15,000,000 / 7 = **2.14 M instructions/s**. A busy loop from the boot's module scan costs 51 clocks per four instructions without wait states (18 + 13 + 7 + 13), i.e. 15 M / 51 x 4 = 1.18 M/s; MAME, with its wait states, runs that loop at 0.43 M/s and the idle shell at 0.027 M/s (mame-oracle.md). **Design need: 1.2 M/s sustained, 2.2 M/s peak.** **MC68HC05C8 x 2** (slave, servo): 2 MHz bus clock; 6805 instructions take 2-11 cycles, about 4 on average (*estimate*): 0.5 M/s each, **1 M/s** together if both run as firmware. **MCD212 pixels.** PAL normal resolution: 384 x 280 x 50 = 5.38 M pixels/s per plane; two planes plus the mix and cursor: about 16 M pixel operations/s. High resolution (768 x 560 interlaced, 25 frames/s) is 10.75 M per plane per second: about **32 M pixel operations/s worst case**. The arbiter itself costs nothing per slot if D1 computes each CPU access's wait arithmetically from the dot position (the slot schedule is periodic). **CD and audio.** 75 sectors/s x 2,352 bytes = 176 KB/s through the CDIC; ADPCM 2 x 37,800 samples/s at most, CD-DA 2 x 44,100. Negligible. ## Does the no-JIT path reach real time? Measured family numbers used: m68000-python about 1.4 M instructions/s on CPython and 33 M on PyPy (its README, `base` workload); m68000-rust 156 M/s, m68000-rust-fast 191 M/s native and 112 M/s as WebAssembly under Node on the desktop (their READMEs). A phone is taken as 3-5x slower than this desktop (*estimate*; play-gb and play-md report per device). | Tier and target | SCC68070 (need 1.2-2.2 M/s) | Pixels (16-32 M ops/s) | Verdict | | --- | --- | --- | --- | | cdi-python, CPython | ~1.4 M/s for the bare 68000 core, less with the board's bus: **0.2-0.5x real time** (*estimate*) | a few M ops/s: 0.1-0.2x | a specification: short targeted cases, as era-3 boards are | | cdi-python, PyPy | 33 M/s bare: the CPU fits | 30-100 M ops/s *estimate* | **near real time possible** on PyPy, not a goal (reference boards: correct, not fast) | | cdi-rust-fast, desktop native | 70-150x margin | trivial | real time single-threaded | | cdi-rust-fast, phone app (iOS, no JIT) | 15-50x margin | ample | real time single-threaded | | cdi-rust-fast, browser (WebAssembly) | ~50x desktop, 10-30x phone | ample | real time single-threaded | **Answer: the CD-i needs no JIT and no turbo tier on any target.** `recompile: none` everywhere. Threads at the channels (D2 picture and D6 sound as producers; D3/D4 at their channels) are available from cdi-rust-fast but not needed; run-ahead of 1-2 frames (Aubrey's habit) multiplies the cost by 2-3, still inside every margin above. The DVC row adds an MPEG-1 decoder (352 x 288 at 25 frames/s), a few percent of a desktop core in Rust (*estimate*), threadable as its own producer. A cached interpreter for the 68070 is not needed and is not planned. ## Capabilities (to be measured by cdi-rust) Save states: D1 holds at least 1 MB of DRAM (Green Book VIII: "two separate banks each of a minimum size of 512KB", a total of at least 1 MB; the Mono-I's fitted size is U7), 512 KB ROM (not saved), 8 KB NVRAM, the CDIC's 16 KB, the slave's 176 bytes of RAM; a snapshot well under 2 MB before compression. Deterministic save states, rewind and run-ahead are all expected to fit; the NVRAM image and the clock epoch come from the host so a run repeats exactly.