# Domains, channels and speed The charter asks each specification to name its domains (parts that keep their own time and meet the others only at channels) and channels, and the brief asks for the speed arithmetic and whether the no-JIT path (Rust -fast, then a cached interpreter, then threads at the channels) reaches real time. Clocks and sources: memory-map.md "Clocks". ## Domains | # | Domain | Clock | Contents | | --- | --- | --- | --- | | D1 | system bus | ~25.05 MHz ticks (CPU at half rate, MCLK stretched by MADAM) | the ARM60, MADAM (arbiter, DMA stack, cel engine, matrix engine, SPORT functions), memory, CLIO's registers, timers and interrupt controller | | D2 | display | CV25M 24.5454 MHz (NTSC), own crystal or genlock | CLIO's display path: S-bus capture, CLUTs, interpolator, encoder output; the line and field timing the encoder owns | | D3 | audio DSP | ~25.05 MHz ticks, reset every 568 (or by the DAC word clock under AUDLOCK) | the DSPP, its EI/I/EO memories, FIFOs, the output stack | | D4 | CD drive | its own mechanism; 2x CLV | the drive, its buffer and command processing, behind the XBUS FIFOs | | D5 | player bus | 2 bits per video line, once per field | the controller chain | D1 is one domain on purpose: the CPU and the cel engine share the D-bus at tick level under the arbiter, and **the CPU is stalled whenever the cel engine runs** ('235 table 1.8), so they cannot run apart without changing what the CPU observes. That serialisation is also good news for speed (below). ## Channels | Between | Channel | Sync point | | --- | --- | --- | | D1-D2 | VRAM (the S-port reads the lines the cel engine and CPU write); the VDL and CLUT words (S-port and 4 D-bus header words per entry); the PCSC sync code CLIO->MADAM; VCNT/HCNT reads; VINT0/VINT1 | the line: start-video and mid-line transfers are D1 bus events at fixed H-counter ticks, so D2 may run a line behind D1 with the line's VRAM snapshot taken at the read transfers | | D1-D3 | 13 + 4 DMA FIFOs (D1 moves words; the DSP pops and pushes); EI/N writes and EO reads by the CPU; the semaphore; the interrupt word (3EE) and DMA interrupts | each FIFO's DMA request (two samples left) and every CPU access to DSP memory; otherwise D3 runs ahead by up to 2 samples per FIFO | | D1-D4 | XBUS command/status/data FIFOs, EXINT, two DMA groups | each strobe and each chunk-ready interrupt; the drive is slow (300 KB/s) | | D1-D5 | one 32-bit shift register and its DMA, once per field from line 17 | once per field | | D2-D3 | none in hardware (audio output timing is D3's) | | The specification runs them serially in one order of record (D1 ticks, with D2 per line, D3 per tick batch, D4/D5 at their events), as psx-python and segacd-python do. ## What has to run each second (arithmetic shown) | Part | Need | Basis | | --- | --- | --- | | ARM60 | 8 M instructions/s typical, 12.5 M worst | 12.5 MHz, >= 1 cycle each; MAME's model 5.2-6.3 M/s (arm60-python handoff brief) | | cel engine | up to 9 M pixels/s while running | SDK gpg 1gpgb; 50 MB/s bus (madam.md) | | DSPP | up to 22.9 M ticks/s (44,100 x ~520 usable ticks); ~5-10 M DSP instructions/s at full load | dspp.md | | display | 320 x 240 x 59.94 = 4.6 M source pixels/s; 640 x 480-equivalent interpolated output = 18.4 M output pixels/s | display.md | | DMA | audio worst ~0.3 M words/s (13 channels x 44,100 / 2); everything else small | memory-map.md | D1's time is shared: in a fraction f of each second the cel engine owns the bus and the CPU is asleep, in 1 - f the CPU runs. So D1's cost per second is about (1 - f) x CPU_cost + f x CEL_cost(9 M pixels/s), not their sum. ## Cost per unit (estimates; label DERIVED until measured) - CPU: arm7tdmi-rust measures 33.9-39.6 M instructions/s native and 41.5 M in wasm on this machine under load (arm7tdmi-rust docs/status.md); an ARM60 of the same shape: ~30 ns per instruction including a board's bus dispatch, so 12.5 M/s = ~0.37 s per second, 8 M/s = ~0.25 s. - Cel engine at transaction level (each pixel: unpack, decode, PPMP on three components, corner and fill decision, a write; no per-tick arbitration inside a burst): 60-120 host instructions per destination pixel, ~20-40 ns, so 9 M pixels/s = 0.18-0.36 s per second. - DSPP per instruction (not per tick): ~15-25 ns per instruction, 5-10 M/s = 0.08-0.25 s per second. - Display: a pure producer from a per-line log (VDL words, VRAM line snapshot): ~5-10 ns per output pixel, 18.4 M/s = 0.09-0.18 s per second. ## Does the no-JIT path reach real time? | Target | D1 (worst: f = 0.5) | D3 | D2 | Single thread total | With threads at the channels (D1 / D3 / D2) | Verdict | | --- | --- | --- | --- | --- | --- | --- | | desktop native (3do-rust-fast) | 0.28-0.37 s | 0.08-0.25 | 0.09-0.18 | 0.45-0.8 s | 0.37 / 0.25 / 0.18 | real time on one thread, with margin on three | | desktop browser (wasm, threads optional) | about the same (arm7tdmi wasm ≈ native) | | | 0.5-0.9 s | | real time; thin at the worst case without threads | | phone native (no JIT; assume 1/3 of desktop) | 0.85-1.1 s | 0.25-0.75 | 0.27-0.54 | 1.4-2.4 s | 1.1 / 0.75 / 0.54 | **needs threads** at the D1/D3/D2 channels; D1 alone is at the limit in the worst case, so the turbo tier's cached interpreter for the ARM60 and a whole-span fast path for the cel engine are the next steps | | phone browser (assume 1/4) | 1.1-1.5 s | | | 1.9-3.2 s | 1.5 / 1.0 / 0.7 | not real time at the worst case even threaded; turbo needed (cel spans, cached interpreter); recompilation is not the answer because the CPU is not the cost | | 3do-python (PyPy) | CPU ~0.8 M/s (arm7tdmi-python), cel engine ~0.2-0.5 M pixels/s | ~1 M ticks/s | | about 1/20 to 1/100 of real time | | the specification only: short, targeted cases | The CPU is cheap; the cel engine and the DSP are the cost; recompilation would not pay (`recompile: none` is the stated capability). All figures are estimates until 3do-rust is measured on each target, as the charter requires. ## Sync points and memory kinds (for the JIT proposal's declarations) - Sync points: each D-bus transaction to MADAM or CLIO registers; start-video and mid-line S-port transfers (fixed H ticks); FIFO DMA requests; CPU accesses to DSP memory; field boundaries (PBUS, VDL top of field). - Memory kinds: DRAM and VRAM (written by the CPU, the cel engine, DMA, SPORT functions; read by the S-port); ROM (read-only, overlay at reset); NVRAM (slow bus); SYSRAM (supervisor only); register space (MADAM, CLIO). A cached ARM60 interpreter must invalidate on cel-engine, DMA and SPORT writes, not only on CPU stores (the ARM60 has no cache to bound this).