The PI, the SI and the AI
Three of the RCP's interfaces move data between RDRAM and the outside: the parallel bus with the cartridge (PI), the serial bus with the PIF
(SI), and the sound (AI). Their code is in crates/n64emu-core: pi.rs, si.rs, ai.rs, and rcp.rs, which joins them.
What is on the buses is the cartridge's and the PIF's: Cartridges and Controllers and the PIF.
On the console: the PI is a bus of 16 bits to the cartridge, with its address and data on the same lines. The processor reads the ROM
through it directly, or the PI copies blocks between the cartridge and RDRAM by DMA. The SI is a serial bus to the PIF: a game
writes 64 bytes of commands into the PIF's RAM, the PIF talks to the controllers and the cartridge's EEPROM over the joybus, and the game
reads the answers back. The AI does no work on the sound: it reads samples of 16 bits, left and right, from RDRAM at the rate that
the game sets, and gives them to the audio DAC. The processor or the RSP mixes them first. Each of the three raises an interrupt in the MI
when it is done, and the AI when a buffer begins.
The PI
Source: n64brew's Parallel Interface page, and its Memory map for direct accesses.
Its settings
Each domain has four settings. They say how long an access takes, in cycles of the RCP:
| Part | Cycles |
| The address | 45, then LAT + 1. The page says that ALE_L is high for at least 14 cycles. 45 is fitted to one console (below) |
| Each 16 bits | PWD + 1, then RLS + 1 |
| A new address | at the start, and at each page of 2^(PGS + 2) bytes |
Domain 2 is for 05000000 to 05FFFFFF and 08000000 to 0FFFFFFF, and domain 1 for the rest. n64brew's two pages do not agree about
05000000: the Memory map says domain 1, the PI's page domain 2, with a table. n64emu takes the table, which is a guess.
With the settings of all official cartridges (64, 18, 7, 3), 512 bytes take 5,998 cycles: about 5.3 MB a second.
The address's time is fitted to our own measurement on one console, the owner's (record m2-2026-12-01, from our program
tools/console/m2.c). With those settings, a DMA of 128 and of 512 bytes from the cartridge into RDRAM, with one
address each, took 1,209 and 4,577 Count ticks at the least of 32 (one tick each 2 cycles of the processor). With 14 cycles for the address,
n64emu gave 1,190 and 4,549, and with 45 it gives 1,214 and 4,573. The difference between the two lengths was right before, so the time of each
16 bits is as the settings say. The program sees the end only when it reads PI_STATUS, about every 12 ticks, so values near 45 give the same.
Where the 31 cycles more than the page's 14 are spent is not known.
Direct accesses
A read takes 32 bits as two halves. A write goes on by itself, and the processor does not wait: while it is on the bus, PI_STATUS says so,
a read anywhere on the bus gives the word that it writes, and another write is lost (Memory map). Guesses: the cartridge gets the write
at once, and not at its end, and an access during a DMA is as at any other time.
DMA
It moves blocks of at most 128 bytes, the PI's own buffer. Each fills the buffer from the bus and then writes it to RDRAM. A block ends where a
row of RDRAM ends (2 KiB). The page describes faults, and n64emu has them:
- The first block starts in the buffer where the address starts in its 8 bytes, and its end is counted from the buffer's start. So it loses as
many bytes at its end as it skips, and can write nothing. Example from the page: 8 bytes to an address that ends in 6 write only 2.
- An odd length is rounded up to 16 bits, but not in the first block, unless that reaches the end of the buffer.
- After the first block, RDRAM's address goes to the next multiple of 8.
- PI_WR_LEN reads
7F, and less by the start's place in its 8 bytes after a transfer of less than 8 bytes. PI_RD_LEN reads 7F.
- PI_CART_ADDR moves on during a block, and PI_DRAM_ADDR only at its end.
Guesses: a DMA from RDRAM to the bus uses the same bytes of the buffer (the page did not look at this direction). A DMA that comes during
another is lost and sets the error bit, and writing bit 0 of PI_STATUS clears it with no interrupt.
An example, step by step: a game asks for 300 bytes from the cartridge at 10000000 to RDRAM at 1000.
- Writing PI_WR_LEN starts the DMA. The first block is 128 bytes, as
1000 is at a multiple of 8.
- The PI puts the address on the bus (79 cycles), and moves 64 halves of 16 bits (23 cycles each). At the end of the block, an event comes.
- Then the block's bytes are written to RDRAM, and its time on the memory is counted. The next block starts when that is done.
- The third block has 44 bytes. After it, an event ends the DMA: PI_STATUS is no longer busy, and the PI's interrupt is set in the MI.
The SI
Source: n64brew's Serial Interface page, and its Memory map. Nothing that was used says how fast the serial bus is. n64brew's PIF-NUS
page says that the PIF gets a clock of 16 MHz from the RCP, which would be 4 cycles, and not how many make a bit. So a bit is 32 cycles, and an
access has 12 bits of its own besides its data, both guesses (SI_BIT, SI_HEAD). A word takes 1,408 cycles, and 64 bytes 16,768.
| What the processor does | What happens |
| Reads a word of the PIF | It waits for the word. When the SI is busy, it waits for that first, also for a DMA (a guess for a DMA). Then it gets what the PIF has after it |
| Writes a word | It does not wait. While it is on the bus, SI_STATUS has both busy bits, and another direct write is lost. At its end, there is an interrupt |
| SI_PIF_AD_RD64B | The PIF runs the joybus first and says how long that takes. Its 64 bytes reach RDRAM after that and the SI's own time. Then the interrupt |
| SI_PIF_AD_WR64B | 64 bytes are read from RDRAM at its start (a guess), and reach the PIF at its end |
| SI_PIF_AD_WR4B and _RD4B | a word to or from the PIF at the address of the last access, with an interrupt at the end (a guess for the read) |
| Writing SI_STATUS | clears the interrupt |
A DMA that comes while the SI is busy sets the error bit, which stays. After a DMA, SI_DRAM_ADDR is the last word's (the page says so for
reading, and it is a guess for writing). The states of the SI's machines in SI_STATUS are not known, and read as 0.
Before the game has ended its boot, the PIF does not run the joybus (Controllers and the PIF). The SI does not depend on this.
The AI
Source: n64brew's Audio Interface page.
- A sample lasts DACRATE + 1 clocks of the VI (the page's rule,
SAMPLE_MORE in timing.rs). Measured on one console, the owner's
(record m2-2026-12-01): our program played two lengths at DACRATE 1103 and 599, which give 1.178 and 1.034 clocks more than
DACRATE without either clock's rate (1 means the rule). The page's example is wrong: it gives 44,136 Hz for 1103, which is 1103 clocks. A
sample is never shorter than 132 clocks, a limit of ours: the page says that a bit has to be 66 times faster than a sample.
- Two buffers: one that plays and one that waits. A third is lost, and a length of 0 is no buffer (guesses). The interrupt comes when a buffer
begins. AI_LENGTH reads what is left of the one that plays, and AI_STATUS says whether one waits and one plays.
- The fault at 8 KiB: when a buffer ends at a multiple of 8 KiB, the next one plays from 8 KiB further on, also when it comes later (the page).
- Samples are read from RDRAM 8 bytes at a time, left and then right (a guess), at the time that each pair plays. Guesses: a buffer ends when
its last sample has been played, nothing plays while DMA is off or the bit clock is 0, and there is silence when nothing plays.
The same record does not fit the first of them: on the console, AI_LENGTH read 0 at most 31 Count ticks before AI_STATUS's BUSY
cleared (for 130,560 bytes, never at all before it), and in n64emu it reads 0 two samples before, when the last 8 bytes are read. It is not
changed yet: the times until BUSY clears do not fit either way better.
- AI_STATUS's count goes down from DACRATE / 2 two times in each sample. Where in a sample it is at a time is a guess. The bit clock is too fast
to be read, as the page says, and reads as 0.
Nothing runs until something could tell. The AI is run up to the time before anything changes RDRAM that it still has to read, before each
of the RDP's commands, before its registers are used, and at the end of each frame.
What comes out
The sound is 48,000 samples a second, as 16-bit stereo, whatever DACRATE is. n64emu goes in straight lines from one of the AI's samples to the
next. That is our choice, and not how the console's DAC sounds. It is simple, and loses some of the highest tones. All of it is whole
numbers: a time is in quarters of a tick, which makes a sample of the output exactly 15,625 of them, and the place between two samples has 16 bits.
So each machine gives the same samples. No time is lost or gained: where the output is, is in the state, and ten seconds always have 480,000
samples (a test). A frame has no fixed number of them, and the output is one of the AI's samples late.
Sources
| Page | What was used | What was not, and why |
| n64brew, Parallel Interface | the registers, domains, timing of the bus, DMA with its faults, open bus | the iQue's registers, which another console has. Its link to a test repository was not followed |
| n64brew, Serial Interface | the registers, the four kinds of access, busy bits and errors | the iQue's part |
| n64brew, Audio Interface | the registers, the two buffers, the 8 KiB fault, the clocks | |
| n64brew, PIF-NUS | that the PIF has a clock of 16 MHz from the RCP, and that a reset leaves the RCP as it is | the sections about startup and checksums were not read. The page says that its facts rest on the PIF's own program, which was dumped; the owner allowed the page |
| n64brew, Memory map | direct accesses of both buses | |
What we need and could not find: the SI's bit rate and how long an access takes, when the bytes of a PI block reach RDRAM, how long the AI's
reads take, and whether a buffer ends at its last sample.