# Start here: the machine, the clocks, the module shape, the cost Read [README.md](../README.md) first, then this, then [memory-map.md](memory-map.md), [bus-arbitration.md](bus-arbitration.md), [interrupts.md](interrupts.md), [video.md](video.md), [object-processor.md](object-processor.md), [blitter.md](blitter.md), [jerry.md](jerry.md), [eeprom.md](eeprom.md), [file-formats.md](file-formats.md), [sockets.md](sockets.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), and last [handoff-brief.md](handoff-brief.md) (scope, boundary, milestones, the U and C lists, the open decisions). Nothing here is code: this is Phase 0. ## The machine in one paragraph Three processors and two DMA engines share **one 64-bit bus to 2 MiB of DRAM**. Tom (the "graphics" chip) holds the memory controller and bus arbiter, the video time base, the **Object Processor** (a display-list engine that builds each scan line into a line buffer), the **Blitter** and the **GPU** (a 32-bit RISC processor with 4 KiB of local RAM). Jerry holds the **DSP** (the same RISC design with 8 KiB of local RAM and a wave-table ROM), timers, the I2S serial port that carries audio out (and CD data in), a UART, the joystick decodes and GPIO strobes. A **68000** at half the system clock is the default bus owner and the lowest-priority master. A cartridge (up to 6 MiB, 8/16/32 bits wide) holds the game and, usually, a 128-byte serial EEPROM. The boot ROM checks an RSA-signed header by running decrypted code on the GPU. ## The machines as data | | NTSC console | PAL console | CoJag (not this repository) | | --- | --- | --- | --- | | System clock (Tom, Jerry, GPU, DSP, bus) | 26.590906 MHz | 26.593900 MHz [TR10 p.6] | 26 MHz from 52 MHz (MAME) | | Host CPU | 68000 at 13.295453 MHz | 68000 at 13.29695 MHz (C3) | R3041 or 68EC020 | | `JOYBUTS` bit 4 | 1 | 0 | n/a | | Video constants | the boot ROM's NTSC set (measured) | the boot ROM's PAL set (U6: not traced) | game-set | | Straps (`MA` pins) | `ROMHI` 1, `BIGEND` 1, `NOCPU` 0 (MiSTer's choice; U1) | same | `CPU32` 1 on the 32-bit hosts | | DRAM | 2 MiB, 64 bits | same | 8 MiB shared | | Cartridge / EEPROM | yes | yes | no; IDE, EEPROM on board | **Scope**: the NTSC console first; PAL is a row (a strap and a clock), cheap from day one; CoJag is a later consumer of the Tom and Jerry classes ([sockets.md](sockets.md)); the Jaguar CD is an add-on board. ## Clocks and time Everything is counted in **system clocks** (26.590906 MHz NTSC). The 68000 runs at exactly half: one 68000 clock is two system clocks, so `m68000-python`'s clock counts double onto the timeline. A line is **1,690** system clocks (`HP` = `$34C`, two half-lines of 845); a field 262 lines (`VP` = `$20B`: 524 half-lines), 442,780 clocks, 60.05 Hz. Video and system clocks are the same oscillator in the console but are named separately in the model (CoJag, PAL). There is **one timeline** and the **bus memory cycle** is the unit of arbitration ([bus-arbitration.md](bus-arbitration.md)): each master asks the bus for a cycle and is told when it completes; a master that does not touch the bus (the GPU or DSP running in local RAM) runs free until its next external access, interrupt or register write. The scheduler always advances the master that is furthest behind, up to the next clock at which another master could affect it. ## The module shape (proposed) ``` src/jaguar_python/ machine.py the machine table (clocks, straps, region), loaded once console.py the 68000 (m68000-python), its 16-bit bus view, the boot ROM, reset bus.py arbiter (11 request levels), memory controller costs (MEMCON1/2), refresh memory.py DRAM, the address decode of memory-map.md, the reset-time ROM mirror tom/ __init__.py Tom: registers, INT1/INT2, PIT, the 16-bit I/O pairing latch (GPU_CPU) video.py HC/VC time base, VI, line buffers, CLUT, CRY/RGB pixel path op.py the Object Processor state machine (OB.NET's states) blitter.py the Blitter at bus-cycle level (BLIT.NET's states) jerry/ __init__.py Jerry: registers, J_INT, clocks, PITs, the DSP's 16-bit bus i2s.py I2S transmit/receive, SMODE, word-strobe interrupt; PWM DACs uart.py ComLynx/JagLink UART pads.py JOYSTICK/JOYBUTS matrix, Team Tap, rotary cartridge.py ROM cartridge, header reading for --skip-boot only, EEPROM attachment eeprom.py 93C46-family state machine sockets.py the Protocols of sockets.md and their test-only fakes loaders.py J64, Alpine ROM, ABS/COFF/JAGR executables (--skip-boot) system.py run_frame, the scheduler cli.py run, screenshot, trace, lockstep ``` `jrisc-python` (the GPU and DSP) and `m68000-python` are pinned by git revision; nothing is copied. Tom and Jerry are classes with no module-level state, taking their host interface as constructor arguments, so a CoJag board can instantiate them later. ## Performance: what pure Python can expect Workload, measured with MAME on *Tempest 2000* ([mame-oracle.md](mame-oracle.md)): the **DSP executes about 18 M instructions per second** (306,894 in one frame, all from local RAM), the **GPU about 8.7 M** (290,535 in two frames), the 68000 about 1 M (boot ROM trace: about 2 M lines in 2 s). About **28 M RISC and 68000 instructions per emulated second**, before the Object Processor (per line: header reads, data phrases, write-backs) and the Blitter (per bus cycle). That game is a heavy DSP user; a GPU-driven 3D game shifts the load to the GPU and Blitter. Reference speeds of the family: `m68000-python` runs about 33 M instructions per second on PyPy 7.3.20 and 1.4 M on CPython 3.14 (its README, `base` workload). A JRISC instruction is simpler than a 68000 one, but a faithful one also carries the prefetch queue, scoreboard and local-bus arbitration, and the board adds an arbitration call per external memory cycle. Estimate, to be measured at milestone M6 (not before): **PyPy about 0.2-0.5x real time** on a game like *Tempest 2000* with arbitration on, **CPython about 1-3%**. Reference boards are "correct, not fast" (family rule); speed is a later `-fast` fork's job. Two levers that keep the reference honest and cost nothing in correctness: a halted processor (`GO` = 0, or waiting on an interrupt) costs nothing until something wakes it, and a RISC processor running in local RAM is advanced in one call up to the next clock at which another master could see it. ## Where everything lives locally - References: `reference/` (git-ignored), filled by `scripts/fetch_references.py` (`--verify` checks the 13 pins); OCR of three binder sections by `scripts/ocr_scans.py`. - ROMs: read in place from the No-Intro tree and `/jaguar`; boot ROM and wave ROM from the MAME `jaguar.zip` ([file-formats.md](file-formats.md)). - MAME runs: `scripts/mame_trace.py` into `tests/mame_traces/` (git-ignored). - The census: `scripts/census.py`, output `tests/detectors/census-2026-11-11.txt`.