# Handoff: build `rsp-python`, the N64's Reality Signal Processor core (proposed) ## Context Proposed by the N64 Phase 0 (2026-11-25) under the CPU rule. Its board is n64-python (`../n64-python`: read its `docs/rsp.md` for the boundary and `docs/domains-and-speed.md` for why the vector unit's form matters to the Rust tiers). This repository holds Phase 0 documents only: no fetch scripts of its own yet (the pins live in n64-python), no code. ## Scope The scalar unit, the vector unit, the pipeline (dual issue, latencies, stalls), the COP0 and COP2 moves, the reciprocal tables. **Not** the SP interface registers, IMEM/DMEM storage, the SP DMA engine or the RDP's XBUS: those are the board's, because the CPU, RSP and RDP all reach them. ## Proposed names `rsp-python`, package `rsp_python`, class `RSP`; modules `_decode.py` (generated from a transcribed opcode table), `scalar.py`, `vector/` (`multiply.py`, `arith.py`, `select.py`, `logic.py`, `reciprocal.py`, `loadstore.py`), `pipeline.py`. The vector unit is written lane by lane in plain Python (eight explicit 16-bit lanes and 48-bit accumulators), one handler per instruction with the lane rule in its docstring: readable first. A SIMD form belongs to `rsp-rust-fast` (one 128-bit register per vector register, exact). ## Boundary - In: an IMEM/DMEM memory object (the board decides collisions with the CPU), a COP0 callable for c0-c15 (the board's SP and DPC registers), a clock. - Out: BREAK (the board sets HALT/BROKE and maybe the interrupt), each COP0 access with its cycle (a sync point), each DMEM access the board needs to order against the XBUS. ## Unknowns - U1. The full instruction set beyond the wiki's tables: VSUB, VSUBC, VMULQ, VMACQ, VRNDN, VRNDP and the rest (nemu64-test has tests for them). - U2. Flag semantics of VCO/VCC/VCE per instruction (judge: nemu64-test, rsp-ruination). - U3. The store-two-cycles-after-a-load stall's length (rsp_timing). - U4. VRCP/VRSQ tables: size, construction, precision (op_vmov_vrcp, stresstests_div). The tables must be generated from a described rule or measured outputs, never copied from an emulator's source unless its licence allows and the notice goes with them. - U5. BREAK's full behaviour; the halt-mid-sequence corruption bug (never isolated). - U6. Whether `LWU` exists on the RSP (nemu64-test has `op_lwu`; the wiki lists no 64-bit loads but LWU is a 32-bit load with zero extension in MIPS III). Contradictions: vector-register write latency 3 (CPU Core page) vs 4 with a 3-cycle stall (Pipeline page); MFC0 latency 2 (SSTEP note) vs 3; the LRV pseudo-code's mask (`~16`, presumably `~15`); SWV listed under the same opcode as LSV/SSV (n64brew: RSP CPU Core). ## Open decisions for Aubrey 1. **Make it a core** (`rsp-python`), as the CPU rule says. *Recommend* yes; the board's M2 builds it. 2. **Plain lane-by-lane Python** in the specification; SIMD only in `-fast`. *Recommend* yes. 3. **Microcode HLE** (replacing the graphics or audio microcode with native code) is a turbo **concession**, off by default, never in this core. *Recommend* recording that now so no one reaches for it in the specification. 4. **The restricted handler form** (JIT proposal decision 2) from day one, as for vr4300-python. *Recommend* yes.