# The RCP's interfaces: MI, PI, SI, AI, VI, RI and the RDRAM Source: n64brew pages pinned in `scripts/pinned_wiki.json` (CC BY-SA 4.0, facts only, tier 3), digested 2026-11-25. Registers are listed by offset from each block's base (memory-map.md). Evidence is given where the wiki gives it. ## MI, the MIPS interface (0x04300000): the interrupt controller - Set/clear register pairs: writing 1 acts, 0 does nothing, set and clear together leaves the state. - MI_MODE (0x00): RDRAM access modes (normal; "upper" for odd RDRAM registers; EBus, which maps the low bits of a word onto the RDRAM's 9th bits; repeat/"init" mode, which writes a pattern of RepeatCount+1 bytes, used by IPL3) and the DP-interrupt clear (write bit 11). The read and write layouts reuse bit 9 differently (C13: to check). - MI_VERSION (0x04): 0x02020102 on most consoles; 0x01010101 and 0x02010202 are quoted by documents and emulators; the full set is unknown ("testing should be performed"). - MI_INTERRUPT (0x08, read-only): DP (SYNC_FULL done), PI (DMA done), VI (V_CURRENT == V_INTR), AI (a buffer *starts*), SI (DMA done), SP (BREAK with INTBREAK, or SP_STATUS SET_INTR). - MI_MASK (0x0C): a set/clear bit pair per source. Masking gates only the CPU line; unmasking a pending source raises the interrupt at once. The MI drives the VR4300's Int0. ## PI, the parallel interface (0x04600000): cartridge, saves, 64DD - Bus: 32-bit addresses, 16-bit data, multiplexed (ALE_H latches A31-16, ALE_L A15-0); a DMA sends an address per page, then a burst; direct I/O is two 16-bit transfers. - Registers: PI_DRAM_ADDR, PI_CART_ADDR (both advance to the first address after the last word), PI_RD_LEN (RDRAM to cart; start), PI_WR_LEN (cart to RDRAM; start; reads back 0x7F, or 0x7F minus the misalignment after a transfer under 8 bytes), PI_STATUS (DMA busy, IO busy, error, interrupt; write: reset controller, clear interrupt), and per domain LAT, PWD, PGS, RLS (0x14-0x20 domain 1, 0x24-0x30 domain 2). In RCP cycles of 16 ns: LAT+1 from ALE_L to /RD, PWD+1 strobe low, RLS+1 strobe high, pages of 2^(PGS+2) bytes. IPL2 sets domain 1 from header bytes 1-3; official ROMs use LAT 0x40, PWD 0x12, PGS 7, RLS 3. **No page gives a full timing formula** (U3): the board derives one from these definitions plus the pinout's ALE minimum widths, and n64_pi_dma_test's timing dumps judge it. - **DMA corners (MEASURED by rasky on hardware: `reference/src/n64_pi_dma_test`, dumps for every misalignment, lengths 1-384, page-end distances 0-128, and timings)**: defined only for an 8-aligned RDRAM address, a 2-aligned cart address and an even length; internally a 128-byte buffer, blocks limited by the remaining length, the 2 KiB RDRAM page and 128; odd blocks fetch an extra byte; the first block starts at the misalignment m and has two bugs (length counted from 0, not m; a 6-byte hole when full); DRAM_ADDR rounds up to 8 after the first block. Only cart-to-RDRAM with default timing was studied; RDRAM-to-cart and page-size effects are untested (U4). - Cartridge domains: ROM at 0x10000000 (domain 1); SRAM/FlashRAM at 0x08000000 (domain 2; FlashRAM wants LAT 5, PWD 0xC, PGS 0xF, RLS 2; SRAM is said to use PGS 0xD). ## SI, the serial interface (0x04800000): the PIF - SI_DRAM_ADDR; SI_PIF_AD_RD64B (start PIF RAM to RDRAM: the PIF first **executes the joybus frame**, so this DMA's duration depends on the devices); SI_PIF_AD_WR64B (RDRAM to PIF RAM; "TODO" on the wiki); SI_PIF_AD_WR4B/RD4B (effectively broken: wired to the "current data" latch); SI_STATUS (interrupt, DMA/PCH state, DMA error that only a power cycle clears, read pending (meaning unknown), IO busy, DMA busy; any write acks the interrupt). - Wire packets to the PIF: RD4B, WR4B, RD64B, WR64B (the page gives one type code to two packets: C9). - **No SI DMA duration is given** (U5): the joybus timing (4 µs per bit, 3 µs console stop, 62.5 µs reply window) plus the copy bound it. ## AI, the audio interface (0x04500000) - No sample memory: DMA feeds the DAC at the playback rate, 16-bit stereo; double-buffered (one playing, one queued: AI_STATUS FULL); the interrupt fires when a buffer **starts**. - AI_DRAM_ADDR (8-aligned), AI_LENGTH (8-aligned; reads give bytes remaining), AI_CONTROL (DMA enable), AI_STATUS (FULL, BUSY, ENABLED, a word clock and bit clock, a COUNT field counting at the VI clock), AI_DACRATE (sample rate = VCLK / (DACRATE + 1)), AI_BITRATE (bit clock = VCLK / 2 / (BITRATE + 1)). - **Delayed-carry bug** (OBSERVED, libdragon carries a workaround): a buffer whose last sample ends exactly on an 8 KiB boundary makes the *next* buffer start 0x2000 later. The cause is a guess. - The wiki's example (DACRATE 1103 gives 44136 Hz on NTSC) implies VCLK ~48.73 MHz, not the 48.681818 MHz of the Video DAC page (which gives ~44096 Hz) (C6). - The DAC (BU9480F, later inside AVDC/MAV) upsamples by two: an analogue stage the board does not model (sound: "good enough", Aubrey 2026-11-13). ## VI, the video interface (0x04400000) - Registers (all 32-bit, full-word writes): VI_CTRL (type 16/32-bit or off, gamma, gamma dither, divot, serrate, AA mode, dedither, pixel advance; bit 5 must stay 0, "can damage hardware"), VI_ORIGIN (8-aligned), VI_WIDTH, VI_V_INTR (reset 0x3FF), VI_V_CURRENT (half- line and field; a write clears the interrupt), VI_BURST, VI_V_TOTAL (525/524 NTSC/MPAL, 625/624 PAL half-lines minus one), VI_H_TOTAL (line length in quarter pixels minus one: NTSC 3093, PAL 3177; also drives the RDRAM refresh), VI_H_TOTAL_LEAP, VI_H_VIDEO, VI_V_VIDEO, VI_V_BURST, VI_X_SCALE, VI_Y_SCALE (2.10 fixed point), test registers. - Output: 4 VCLK per pixel (one sync slot + 7-bit R, G, B), about 12.3 M pixels/s. VCLK = X1 x 17 / 5 (NTSC, MPAL) or x 14 / 5 (PAL): 48.681818, 48.628322, 49.656530 MHz. - The filter pipeline: dedither on fully covered pixels (tuned for the RDP's magic-square dither), the AA filter on partially covered pixels (from the hidden coverage bits), divot at edges, gamma. **This is where the RDP's coverage becomes a picture**: a board that skips it shows the RDP's buffer, not the TV's picture. - Errata (OBSERVED, libdragon issues #159 and #759): REPLICATE + 16-bit + X_SCALE <= 0x200 + H_START < 128 gives 64 good then 64 garbage pixels; X_SCALE above 0x800 (32 bpp) or 0xE00 (16 bpp) runs out of fetches; V_INTR with bit 0 clear in interlace fires a line early in odd fields; WIDTH < 8 can crash the VI ("not fully understood"). - Contradictions: PAL "525 lines" in an example against V_TOTAL's 625 (C5); NTSC H_START 108 vs "usually 96" (C7). ## RDRAM and the RI (0x04700000) - 4 MiB (Jumper Pak) or 8 MiB (Expansion Pak). **Each byte has a 9th bit**, usable only by the RDP and VI (the antialiasing coverage of the colour buffer; reachable by the CPU in MI EBus mode). So the board stores RDRAM as 9-bit bytes, or as bytes plus a parallel hidden bit plane. - RDRAM registers (DeviceType, DeviceId, Delay, Mode, RefInterval, RefRow, RasInterval, MinInterval, AddressSelect, DeviceManufacturer, Row), little-endian contents, mirroring every 0x40; IPL3's init sequence (12 steps on the RDRAM page, from the 6102 IPL3's decompilation: current calibration, Delay through repeat mode, placing each chip on a 2 MB boundary, RI_REFRESH). - RI registers: RI_MODE, RI_CONFIG (auto current control), RI_CURRENT_LOAD, RI_SELECT (IPL3 uses 0x14; **writing any non-zero value lets a young emulator skip RDRAM init**, per nemu64-test's README), RI_REFRESH (refresh triggered by the VI's hsync), RI_LATENCY, RI_ERROR (set during IPL3; "Over" on any access to 0x00800000-0x03EFFFFF), RI_BANK_STATUS (one open 2 KiB row per 1 MiB bank, tracked for the bottom 8 MiB only). - **The board models RDRAM at the transaction level**: who asks (CPU, RSP DMA, RDP, VI, AI, PI, SI), when, how many bytes, and the RI's latency, including the open-row (bank) state if the timing judges need it (U6). The RDRAM's own protocol (Rambus packets) is not modelled: no judge sees it, and IPL3's register writes need only to be accepted and to produce the values IPL3 reads back (DeviceType, manufacturer). - Expansion Pak detection: osGetMemSize probes from 0xA0300000 in 1 MB steps; IPL3 stores the size at 0x80000318 (0x800003F0 for CIC 6105).