# Domains, channels and speed ## Domains and channels (proposed; HYPOTHESIS until the CUS117 is understood) Every processor runs at 1.536 MHz from what appears to be one master clock (OBSERVED clocks, all 49.152 MHz / 32), so System 1 is **one clock** but can still be scheduled as separate domains that meet only at channels (charter, "Domains and channels"). | Domain | Parts | Why one domain | | --- | --- | --- | | **Main** | main 6809, sub 6809, CUS117, main RAM, the key custom, C116, C123, sprite generator, screen | the two 6809s share every device through the CUS117 and are reset and interrupted by it: tightly coupled, one domain (like the 32X's SH-2 pair) | | **Sound** | sound 6809, YM2151, CUS30, sound RAM | its own program and RAM | | **MCU** | HD63701V0 (CUS64), voice ROMs, DACs, inputs, NVRAM | its own program, the I/O | | Channel | Between | Kind | | --- | --- | --- | | triram, 2 KB | main (CUS117 $2FF000), sound ($7000), MCU ($C000) | shared memory, three ports | | CUS30 registers and wave RAM, 1 KB | main (CUS117 $2FE000), sound ($5000) | shared device | | reset lines of sub, sound, MCU | main (CUS117) -> each | lines | | interrupt lines (vblank and others) | CUS117 -> main, sub; ? -> sound, MCU | lines (U2) | | screen / video | main domain -> host | producer | | audio mix (YM2151 + CUS30 + DACs) | sound and MCU domains -> host | producer | The specification runs the domains serially in one order of record (the four processors interleaved by E cycle, earlier bus time first, a fixed CPU order on a tie: main, sub, sound, MCU). The sync points for threads in `-fast` are the triram, the CUS30 window and the lines. Since the triram is polled constantly by all three sides (it is the handshake), threads at that channel are unlikely to pay on this board; the cheap producers (picture drawing from a register log, audio synthesis) are the realistic split. ## How much work (arithmetic shown) | Load | Per second | Arithmetic | | --- | --- | --- | | CPU cycles | 6.144 M | 4 processors x 1.536 MHz | | Instructions (measured, Pac-Mania, MAME trace) | ~1.11 M | main 645,933 + sub 507,826 + sound 517,825 + MCU 541,708 = 2.21 M in 2.0 s (the three slaves include their pre-reset run) | | Video dots | 6.144 M | 384 x 264 x 60.606 | | Visible pixels | 3.91 M | 288 x 224 x 60.606 | | YM2151 samples | 55,930 | 3,579,545 / 64 | | CUS30 output | 192,000 samples (MAME's internal rate) | MAME log | ## Can the no-JIT path reach real time? Measured family speeds (their own records): z80-rust ~50 M instructions a second on this desktop; m68000-rust 101-157 M; megadrive-rust (a 7.67 MHz 68000, a 3.58 MHz Z80, the VDP, YM2612 and PSG in cycle lockstep) 4-6x real time with sound, and play-md runs the Mega Drive in the browser. - **Instructions are not the problem.** 1.11 M instructions a second against a plain-Rust 8-bit core at the z80-rust rate (~50 M) is ~2% of one desktop core. - **The board is.** Cycle lockstep across four processors is 6.144 M bus cycles a second, about 55% of the Mega Drive's 11.25 M (7.67 + 3.58); the video is 6.144 M dots against the Mega Drive's ~5.4 M (H40: 342 x 262 x 60). So System 1 is a Mega-Drive-sized load. HYPOTHESIS: plain Rust (`namcos1-rust`) runs at roughly the Mega Drive's multiple of real time, 4-6x, on this desktop. - **Desktop: yes, plain Rust.** **Browser on desktop: yes** (WebAssembly ~1.5-2x slower than native leaves 2-4x). **Phone, native: likely, with `-fast`**: a phone core at a third to a half of this desktop's single-thread speed leaves 1.3-3x, too thin for run-ahead without `-fast`. **Phone browser: needs `-fast`, then the cached interpreter** (decode once per instruction address; all program code is ROM except the HD63701's RAM, so invalidation is trivial); threads are unlikely to help here (above). No board on this list needs a JIT; `recompile: none` should meet every target. All of this is to be measured on the devices, not assumed. - **Python** (the reference): 1.11 M instructions a second plus 6.1 M dots is far beyond CPython and very likely beyond PyPy for real time (the instruction rate alone is within what the family's PyPy 8-bit cores report, but four lockstepped CPUs plus a dot-level video model cost far more than one core's loop; HYPOTHESIS, to measure at milestone 1). The reference is correct, not fast (Aubrey's rule): tests are short and targeted.