# Handoff: build `n64-python`, the Nintendo 64 board ## Context you are inheriting The N64 is the family's first **era 3** board built from scratch (charter: tightly coupled 32-bit CPUs, transaction level in the specification, Python too slow for long runs, cases short and targeted, threaded `-fast` needed, turbo likely). Before anything else read [domains-and-speed.md](domains-and-speed.md): it decides how this board is tested; then [execution-architecture.md](execution-architecture.md) for how each part will be run fast. Cores: **vr4300-python** (`../vr4300-python`, Phase 0 done tonight) and **rsp-python** (`../rsp-python`, Phase 0 documents only, proposed). Everything else is in the board. Models: sega32x-python (an era-3 board on a RISC core, with `docs/domains.md` and `docs/claims.md`), pcengine-python (Phase 0 shape, sockets), gameboy-python (the skip-boot vs real-boot discipline: the N64's HLE boot is the same question). Rules that bind: the charter and CLAUDE.md (MIT; GPL and other closed-box emulators are never read or fetched into this repository; romsets by `NO_INTRO_DIR` / `MAME_ROMPATH`); never ship, copy, disassemble or read Nintendo firmware (PIF ROM, PIF and CIC SM5 code, IPL3s); oracle tiers; Python 3.11 floor, PyPy green; no hardware probes; run anything reading `reference/` with `python -I`. ## Scope (first build) NTSC console, 4 and 8 MiB, the CPU and RSP cores pinned, the RDP, MI, PI, SI, AI, VI, RI, RDRAM, a functional boot plus the player-supplied-PIF path, controllers, Controller Pak, Rumble Pak, EEPROM 4K/16K, SRAM, FlashRAM, RTC. Later: PAL and MPAL rows (timing tables and X1 only), Transfer Pak (pins gameboy-python), the 768 Kbit banked SRAM, 64DD (a separate add-on board, `n64dd-python`), iQue Player (a separate board), Aleck64 (arcade, separate). ## Proposed names - `n64-python`, package `n64_python`; class `N64` with a machine row (`MachineRow(region, memory_mib, vr4300_prid, mi_version)`). - Packages: `bus` (the physical map responder and RDRAM arbiter), `rdram` (9-bit bytes, RI), `mi`, `pi` (and `cartridge`), `si`, `pif` (PIF RAM, the joybus frame, boot), `joybus` (controller, paks, EEPROM, RTC), `ai`, `vi` (scan-out and filters), `rdp` (its own sub-packages per stage), `sp` (the SP interface registers, IMEM/DMEM, SP DMA: the board side of the RSP), `saves`, `boot` (HLE IPL1-2 and optionally IPL3). ## The import boundary - **vr4300-python** owns everything inside the CPU chip and speaks SysAD transactions with a duration; the board's `bus` answers them (memory-map.md) and drives Int0 from the MI, NMI and pre-NMI (Int2) from the PIF. - **rsp-python** owns the scalar and vector units and the pipeline; it reads IMEM and DMEM through a memory object the board gives it (so collisions with the CPU are the board's rule), and reaches COP0 c0-c15 through a callable (the SP and DPC registers are the board's). - The RDP, the interfaces and RDRAM stay in the board. **Chip rule** check: none has a second user in the family (the RCP appears only in N64-family machines: iQue, Aleck64, 64DD setups), so no split. If iQue or Aleck64 boards are built, the RCP blocks are shared by **pinning n64-python**, never by copying. ## Sockets (for add-on boards, pinned by them) - The PI bus (domain 1 and 2 address ranges, the 64DD's ranges), the cartridge interrupt line, and the boot path's "64DD present" branch (IPL2 jumps to 0xA6000000): the 64DD board. - The joybus port device interface (four controller ports, the cartridge channel): paks and other controllers. - The memory row (4/8 MiB) and the RCP version: iQue. ## Domains, channels, sync points (from M1, per the charter and the JIT proposal) As domains-and-speed.md: CPU, RSP, RDP, RCP interfaces, PIF; RDRAM through one arbiter (the order of record); every uncached RCP register access, every IMEM/DMEM access across sides, every DMA start and completion, SYNC_FULL, VI line compares and AI buffer starts are sync points; memory kinds declared (ROM, RDRAM, IMEM/DMEM, registers, PIF RAM) with who can write each. ## Unknowns (U) and contradictions (C) Unknowns (with the judge that could settle each): - U1. RDRAM arbitration between CPU, RSP DMA, RDP, VI, AI, PI, SI: order and cost of simultaneous requests (nemu64-test `timing`; none complete). - U2. The RCP's response time to CPU register reads (wiki: "about 5-6 PClock, MI about 2", unattributed) (nemu64-test `timing`). - U3. A PI bus timing formula from LAT/PWD/PGS/RLS (n64_pi_dma_test timings). - U4. RDRAM-to-cart PI DMA and page-size effects (untested on the wiki; a test ROM would be needed: we have none). - U5. SI DMA duration and the joybus timing as the CPU sees it (no judge held; mimi?). - U6. Whether bank (open-row) RDRAM timing is visible to any judge. - U7. TMEM banking; the RDP command FIFO size; the TBC rows of the RDP corruption table. - U8. The VI's filter arithmetic in detail (dedither, AA, divot): krom VI tests, photos. - U9. Everything IPL3 leaves for the game (registers, 0x80000300 block) for the HLE boot (MAME detector; libdragon's IPL3 source is open and says what *it* leaves). - U10. The CIC-6105 challenge algorithm from a source that is not a firmware transcription. - U11. Controller button bit order (image only on the wiki; libdragon `joybus.h`). - U12. Multi-bank Controller Pak behaviour with missing banks. - U13. Transfer Pak protocol (not on the wiki). - U14. 768 Kbit banked SRAM mechanics. - U15. Why MAME's PIF image is 2,048 bytes against No-Intro's 1,984. - U16. The IMEM/DMEM collision rule's exact form (wiki: "typically" the CPU wins). - U17. MI_VERSION across revisions; EBus normal-mode default; repeat-mode reads hanging. - U18. What a normal-mode CPU write does to the RDRAM's hidden 9th bits (not on the wiki; ares sets them from the data, OBSERVED only): a CPU write then an EBus-mode read decides it (execution-architecture.md, X7). Contradictions (from the pinned pages): - C1. 64DD registers in PI domain 1 (Memory map) or 2 (Parallel Interface). - C2. CIC "Challenge" and "Reset" both coded 10 (CIC-NUS) vs RESET = 11 (PIF-NUS). - C3. SysAD sub-word and 64-bit write data: "aligned and repeated, LSB word first" (SysAD Interface) vs "shifted, MSB first" (Memory map). - C4. "All retail units use 2 MiB modules" vs the page's own table of 36 Mbit single chips. - C5. PAL "525 lines" in a VI example vs V_TOTAL 625. - C6. AI DACRATE example frequency vs the Video DAC page's VCLK. - C7. NTSC H_START 108 vs "usually 96". - C8. IPL1 0xD4 bytes (53 words) vs "52 instructions". - C9. The same SI packet type code for RD64B and WR64B. - C10. Rumble Pak motor address range (Joybus vs Rumble Pak pages). - C11. Coverage 0-8 (needs 4 bits) vs 3-bit memory coverage. - C12. MI_MODE bit 9 meaning in the read vs write layouts. - C13. RSP pipeline: vector-register write latency "3-cycle" (CPU Core page) vs 4-cycle with a 3-cycle stall (Pipeline page); MFC0 latency 2 (SSTEP note) vs 3. - C14. Set Color Image needs a sync (Commands) vs 0 corrupted cycles (Pipeline). ## Milestones M1-M7 with exit tests: [validation.md](validation.md). Python never boots a commercial game as a gate; M7's slices start from Rust-tier save states. ## Open decisions for Aubrey (each with my recommendation) 1. **Names**: `n64-python` / `n64_python`, `vr4300-python`, `rsp-python`. *Recommend* yes. 2. **The RSP as its own core** (CPU rule: it is a CPU; one machine uses it). *Recommend* yes, `rsp-python`, built after vr4300-python's rung 1 and alongside the board's M2. It shares no code with vr4300-python (different width, no exceptions, IMEM wrap, a vector unit): citing the same MIPS encodings is not sharing code. 3. **The RDP stays in the board** (chip rule: one machine). *Recommend* yes, as a package with a pin-shaped interface. 4. **The RDP's modelling level.** A pixel-by-pixel pipeline in the specification, with the documented cross-pixel hazards (RH#001-004, the 2-cycle bugs) reproduced by modelling the one-pixel lags they come from, and the sync corruption tables as data. *Recommend* this over a "correct programs only" RDP: shipped games hit the hazards. Mark every TBC row HYPOTHESIS. 5. **Boot.** Functional IPL1-IPL2 by default (no Nintendo code needed), the cartridge's IPL3 run on the core; the player-supplied PIF ROM path (`N64_PIF_ROM`, read in place) as the judge of the functional boot, like gameboy-python's skip-boot vs real boot. *Recommend* both, functional first; a functional IPL3 later only for speed in the Rust tiers. 6. **The 6105 challenge** (56 images). *Recommend* deferring it to M7: look for a clean-room description first; if none, document it as a concession or require the player-supplied path. 7. **Gate without sweeps.** Test ROMs plus a curated slice list started from Rust save states; no full-library sweep in Python, ever. *Recommend* recording this in the board's claims document as the N64's gate, and asking whether it should become an era-3 rule in the methodology (Aubrey's document). 8. **Save-type metadata.** A board-side table keyed by game code (from ares's database, ISC, with its notice; or built from the census plus SaveTest-N64 runs). *Recommend* ares's table with notice, as `MIT AND ISC` on that one data file. 9. **Transfer Pak**: pin gameboy-python for the GB cartridge; *recommend* after M5. 10. **nemu64-test build** (MIT, needs `cargo`, a MIPS target and `nust64` from crates.io). *Recommend* building it once locally in M1 (a few minutes, one core), pinning the ROM's SHA-256, not committing it. 11. **Unlicensed test-ROM repositories in an MIT repo's `reference/`** (rsp-ruination, n64_pi_dma_test, the cache tests, Dillon's release zip). The new rule (CLAUDE.md, 2026-11-25) keeps closed-box *emulators and models* out of MIT repositories; these are test programs and dumps, never built here. *Recommend* keeping them as run-only data; move them to emu-tools-gpl2 if Aubrey reads the rule as covering them. 12. **Local until M2, then public** after a provenance check (nothing from GPL sources or Nintendo code), with the family's minimal CI. *Recommend*. 13. **iQue, 64DD, Aleck64**: separate boards that pin n64-python, not modes. *Recommend*, all after M7, 64DD first if any (22 disk images and 13 BIOS files in the No-Intro 64DD set). ## What was not verified in this phase (candour) - No test ROM was built; only krom's CPUADD and RSPCPUADD were run, under MAME. - The n64brew pages were read through two digests made tonight by sub-agents (facts paraphrased with section tags), plus direct reads of CIC-NUS, PIF-NUS (seeds table), ROM Header and VR4300; claims carried from the digests were not all re-read in the pages. - The leaked Nintendo SDK documents were not fetched; parallel-rdp, ares and cen64 were fetched and not read. - All speed figures for N64 parts are HYPOTHESIS with arithmetic shown; the family's measured figures are the SH-2's and the 68000's. - The census's CIC names are FITTED to anchor titles; its save types are ares's.