Memory and the bus
On the console, the processor has one bus, SysAD, to the RCP. Everything else is on the far side of it: RDRAM, the RSP and the RDP,
the interfaces, and through them the cartridge and the PIF. RDRAM is the console's only main memory, made by Rambus's design: a few chips
on one synchronous bus, which the RI drives. Every part that uses memory takes turns on that bus. The MI collects the
interrupts of all parts into one line to the processor, and has the modes that the boot code needs to set up the chips.
The processor reaches everything through the RCP. The RCP decides what is at an address, how long an access takes, and who gets the main
memory (RDRAM) when several want it. This page says how n64emu does that. The code is in crates/n64emu-core: bus.rs, memory.rs,
rdram.rs and mi.rs. All its numbers that are guesses are in one file, timing.rs, so that a measurement can replace each.
What is where
| Physical address | What is there | Source |
00000000 to 03EFFFFF | RDRAM: 4 MiB, or 8 MiB with the Expansion Pak (a setting) | n64brew, Memory map |
03F00000 to 03FFFFFF | the chips' registers. From 03F80000, a write goes to all chips | Memory map, RDRAM Interface |
04000000 to 040BFFFF | the RSP: DMEM, IMEM, registers, program counter | Memory map |
04100000, 04200000 | the RDP's command interface (VI and DPC), and its tests (read as 0) | Reality Display Processor/Interface |
04300000 to 048FFFFF | MI, VI, AI, PI, RI, SI. Each one's registers repeat in its megabyte | Memory map |
05000000 to 1FBFFFFF, 1FD00000 to 7FFFFFFF | the parallel bus (PI) | Memory map, Parallel Interface |
1FC00000 to 1FCFFFFF | the PIF, through the SI | Memory map, Serial Interface |
040C0000 to 040FFFFF, 04900000 to 04FFFFFF, 80000000 and up | nothing. A read never gets an answer, so the processor stops until a reset. A write is lost (a guess for what the processor does then) | Memory map |
The bus finds the place with one comparison for RDRAM, which most accesses are, and then a match on bits 20 and up.
How the RCP takes each size of access
- RDRAM takes every size, and writes only the bytes that are stored.
- Everything else takes 32 bits. For a read, the device gives its word, and the processor takes its part. For a write, the device takes
the whole word that the processor drove, also for a byte or a halfword. That word has the stored part at its place in big-endian order,
and more of the register to the left of it (NEC's manual, figure 1-4). What is to the right is 0, a guess.
- n64brew contradicts itself here. The Memory map has both
S0 << 8 and S0 << 16 for a byte at offset 1. The MIPS Interface page's
examples of repeated writes have << 8 for that byte, and << 16 for a halfword at offset 2, where the manual's order has no shift.
Measured on one console, the owner's, for VI_ORIGIN (a 24-bit register: record m2-2026-12-01, from our program
tools/console/m2.c, group 3): after 00C3C3C3, SB of 5A at offsets 0 to 3 left 00000000, 005A0000, 00005A00 and 0000005A, and
SH of 5AA5 at 0 and 2 left 00A50000 and 00005AA5 (its bits 31 to 24 cannot be written). LB and LH of 00A1B2C3 gave the byte or the
halfword at its place, with its sign. This is the manual's order, with 0 to the right, and n64emu gives the same 14 figures. The
MIPS Interface page's shifts are wrong for this register. That every other register of the RCP takes them the same way is a guess: they
are all on the same bus to the processor, and n64emu has the one rule for all. What is to the left of a byte was 0 in the program's
registers, so "more of the register to the left" is still the manual's word only.
- A 64-bit store gives a device its high word, and a 64-bit read of a device never gets an answer (Memory map). A store of part of a word
(
SWL and others) gives a device the whole word that holds its bytes, which is a guess.
- The parallel bus has its own fault (Memory map): it ignores only the lowest bit of the address, so a halfword at
10000002 is the one at 10000004.
- Only RDRAM answers the cache's line reads and writes. Elsewhere a line read never gets an answer (Memory map), and a line write is lost.
For the range of RDRAM's registers, the pages do not settle it: the Memory map says that "the RDRAM area" answers cached accesses, in its section
about the memory alone. The RI's page says that the RI turns every access from
00000000 to 03FFFFFF into RDRAM's packets. That is the likelier
reading, so a line read there is answered: the register's word first, and 0 after it (a guess). A developer can choose that it hangs instead
(Guesses::register_lines_hang).
RDRAM
The chips
A console has chips of 2 MiB, two of them, and the Expansion Pak has two more (n64brew, RDRAM). At power-on, no chip answers: a
game's own boot code finds them through their registers, gives each its place and turns it on. n64emu has what that needs, from n64brew's
RDRAM and RDRAM Interface pages and their list of the steps (which the owner allowed, as they rest on boot code):
- A register write to one chip reaches the first chip of the chain that is still off, or one that is on at that place. One to
03F80000 reaches all.
- Delay is wrong after a reset, so a normal write gives the chip garbage. Each chip takes 4 bytes at the time that its Delay says, from what
the RI sends. So the MI's repeated write of 16 bytes sets it, as the steps do.
- A chip takes the first 4 bytes of the 8 that the RI sends, the upper half of the bus. So reading a register that is at 4 in its 8 bytes
(DeviceId, Mode, RefRow) needs the MI's upper mode, as the MI otherwise takes the other half (MIPS Interface page).
- What a write in the MI's normal mode puts in the other half is a guess: the same word. The MIPS Interface page says that normal mode is right
only for registers at even offsets, but its table for the repeat mode shows a 32-bit write as its word in both halves. That the bus has this in
normal mode too is the likelier reading, and then such writes work. A developer can choose zeros, or what the last such write had there
(
Guesses::odd_register_writes). One game's boot code writes DeviceId to all chips in normal mode, and the console boots it, as the owner has seen.
A test runs the page's steps with those writes in normal mode: only the default sets up the memory.
- Where Delay is written: the pages differ. The RDRAM page's table has Delay at
08, and so do two examples on the RI page. The page's
list of steps writes it to A3F80004, which is DeviceId in that table, and its section about resets says that the chip then reads "halfway
between two words". n64emu follows the table: a write reaches the register at its address. A developer can choose the other reading
(Guesses::late_writes_take_next_register): bytes that a chip takes late are the next register's, so that a write to 04 that comes 6 bytes
late reaches Delay. Nothing else says so. A test runs the page's steps with Delay at 08 and the table, and at 04 and the other
reading: both set up all of the memory, for 4 and 8 MiB, and each address with the other reading finds no chip.
- Current: a chip gives what is read only when its current is enough. When it is set by hand and is too low, it reads zeros. That threshold
(
ENOUGH in rdram.rs) is a guess, as real chips all differ. The way the steps find the current works with it.
- What a chip says it is, is the value that n64brew shows from a console (
B4190010). Its maker is NEC, a choice.
- Where no chip answers, reads give 0, and the RI notes it in RI_ERROR. n64brew shows other values there on a console too, whose origin
is not known, so n64emu does not have them.
- A read of a register that no chip answers also gives 0, and does not hang. No page says it for registers. The RI's page says it for the memory,
and the RDRAM page that a chip answers register reads only after it has an id and is on. That the RI does the same for both is the likelier reading. A
developer can choose that it hangs instead (
Guesses::registers_without_chip_hang).
- After power-on, each chip's DeviceId is 0 and it is off (Mode's DeviceEnable is 0), as the RDRAM page's tables have it. Only the first chip
of the chain that is off takes a register write that is not to all, and only at its place. Writes to all reach every chip.
tests/real.rs runs our own program that does these steps with the real processor (programs::set_up_memory).
How long an access takes
The numbers of the chip are from NEC's data book of 1995, for the uPD488170L (pages 298 and 299), in its clocks of 4 ns, four of which are
a cycle of the RCP. NEC's chip is one of those that n64brew lists. Whether the console's chips have the same numbers is not known.
| NEC's clocks |
| From a request to its data, when the row is open | 10 for a read, 4 for a write |
| More, when another row was open and nothing was written to it | 22 |
| More, when it was written to | 30 |
| 8 bytes | 4 |
| After a read, after a write | 2, 4 |
The RI keeps which row of each bank of 1 MiB is open, and whether it was written to (RDRAM Interface, "Bank Status Tracking"). n64emu keeps
the same, and RI_BANK_STATUS shows it. A refresh comes at each line of the picture when RI_REFRESH has it on (RDRAM Interface). It takes as many
cycles as that register says for a clean or a dirty bank, and leaves the rows open but no longer written to (NEC, 8.2.2).
The rest are guesses, fitted to measurements that someone else made on a console and published on n64brew's MIPS Interface page. They
were not made by us, and we do not know with which console, and with what else was running:
| n64brew measured, for 1 MiB | n64emu | The guesses that were fitted |
| 64-bit writes without the cache: 25.7 ms | within 3% | 6 cycles from SysAD to a write's request, 3 after it |
| Repeated writes of 128 bytes: 3.80 ms | within 3% | the same |
| The RSP's DMA: 2.58 ms | within 3% | 25 cycles before each row of a DMA, and none between two bursts of 128 bytes, both fitted to our own measurement (below) |
A test (the_memory_takes_as_long_as_n64brew_measured) checks all three. No read is in them. How long the RSP's DMA really takes is on the
list for the owner's console.
A read is fitted to our own measurement on one console, the owner's (a US console, NTSC, with the Expansion Pak:
record m1-2026-12-01, from our program tools/console/m1.c). The program times one load in Count
ticks (one each 2 cycles of the processor), 64 times at each of three phases (0, 1 and 2 NOPs between reading Count and the load), and keeps
the least, the most and the sum. n64emu runs the same ROM (n64emu-dev --isviewer), and its record is decoded by the same decode.py. The
least times are the ones that were fitted:
| Least, in Count ticks, at phases 0, 1, 2 | The console | n64emu before | n64emu now |
| A load that hits the data cache | 2, 2, 3 | 2, 2, 3 | 2, 2, 3 |
| A load that misses it (a line of 16 bytes) | 18, 19, 19 | 14, 15, 15 | 18, 18, 19 |
| An uncached load (4 bytes) | 17, 18, 18 | 13, 14, 14 | 17, 18, 18 |
Before, both kinds were 4 ticks short, the same for 16 bytes as for 4, so what was missing is in the way there and back and not in the transfer.
The fit: 7 cycles of the RCP from the data to SysAD, in place of 2 (READ_ANSWER). It still has 4 from SysAD to the request
(READ_REQUEST). The record gives only their sum: 9 and 2 give the same least times, so how the 11 cycles are split is a guess. With one cycle
less (6 in all more) or more (8), fewer of the six figures come out. One figure is not explained: the miss at phase 1 is 18 in n64emu and 19
on the console. No whole number of cycles in these guesses gives all six, and no mechanism for it is assumed here. Since the PI's time was
fitted to program 2 (PI_ADDRESS, in the PI's page), n64emu gives 19 there too, and all nine least figures are the console's.
That explains nothing either: the boot is shorter or longer, so the program runs at other times than the refresh and the VI's reads, and
with PI_ADDRESS at 14 it is 18 again. In n64emu, the least of 64 trials still depends on that. The hits, which do not use the
memory, were right before and are now. PRId (0B10h) and FCR0 (0A00h) are also this console's, and the processor's crate has them.
The spread (the most of the 64 trials, up to 55 ticks on the console) is not fitted. n64emu gives one of the same size with the fit: the
most are 57, 32 and 46 ticks for a miss and 33, 44 and 32 for an uncached load, where the console had 44, 55 and 35, and 45, 40 and 40, and the
sums are within 6% (n64emu 1,223, 1,232 and 1,250 for a miss, the console 1,231, 1,305 and 1,297). In n64emu, what comes between is the
refresh and the VI's bursts. Which of them it is on the console, the record does not say.
Who gets the memory
Whoever asks first is served first, which is a guess. A transfer of a DMA is long, so others can come between its bursts of 128 bytes:
a short access during one waits for the end of the burst, and the DMA is not made longer. The VI reads each line in bursts that are spread over
the line, which is also a guess. How many lines it reads for its filters is not known, so it is one. While the RDP draws, each short access waits 8
cycles more, half a burst, as how often the RDP uses the memory is not known.
This is a model, so that time grows with what uses the memory. It is no measurement of how the RCP chooses.
The MI
Its interrupt line goes to the processor's first pin, when a bit of MI_INTERRUPT is in MI_MASK (MIPS Interface). Each bit of the mask has one
bit that sets it and one that clears it, and both together do nothing. MI_VERSION is 02020102, which the page says most consoles have.
Its modes change what the processor's accesses to RDRAM do (MIPS Interface):
-
Repeat: the next write is repeated, as many bytes as the mode says, and then the mode ends. Only a write that sets the mode (bit 8)
changes how many bytes: our program 2 read 0F in MI_MODE after writing only 400 and 200 to it, which is what the boot code had left
(record m2-2026-12-01), and n64emu reads the same. The page's table has every write change it. The RI loses a carry from bit 2 to bit 3, so a
write that begins in the middle of 8 bytes can end early, or write nothing. A word is repeated twice in 8 bytes, a line gives its last 8. Reads
are as usual, as the page only says that they can hang.
-
EBus: the ninth bits. A read gives the 4 ninth bits of its word in its lowest 4 bits, and 0 in the others. A write writes the bytes and the
ninth bits of the bytes that it stores. Both are guesses: the page only says that the 4 bits are mapped there.
-
Upper: a word always goes through the upper half of the 8 bytes. It matters for the chips' registers. For memory, a read takes the word at
the multiple of 8 (a guess).
-
Any other write, and each DMA, writes the ninth bits of the bytes that it stores (NINTH_BITS in timing.rs). Measured in part on one
console, the owner's (record m2-2026-12-01, group 4, read in EBus mode):
| Written | Each word's ninth bits |
7F in every byte, with SH, SW, SD, a cache line, the PI's DMA or the RSP's DMA | F |
80 in every byte, in all of these ways, and with SB | 0 |
00 in a word, and then 80 in one byte with SB | 0 |
7F in every byte, one byte at a time with SB | 5: the second and the fourth byte's (the first byte's is bit 3, as n64emu has them) |
n64emu now gives the same in all 74 figures. The rule: each byte that is written gets bit 0 of the second byte of its 16 bits, as that
byte is on the bus, where a byte that SB does not write is 0 (as on VI_ORIGIN above). Guesses: that it is bit 0 (any of bits 0 to 6 fits
the record; bit 0 is the one that a 16-bit pixel has for its coverage, which the two ninth bits extend), and that the other byte's bit stays
when SB writes one. Another rule fits the record as well: both bits of the 16 bits are written, each from its own byte (NinthBits::OwnByte,
n64emu-dev --ninth-bits own-byte). The MIPS Interface page's "sign extension of each byte" is wrong: bytes of 80 give clear bits.
The RDP's own writes are n64-rdp's.
How long a register takes
An access to a register of the RCP takes 6 of the processor's cycles, and one of the MI 2 (Memory map: "5-6", and "about 2"). The RSP's memories
take the same, as a guess.
Sources
| Page or document | What was used | What was not, and why |
| n64brew, Memory map | the map, sizes, what hangs, the PI's halfword fault, times of registers | the byte lanes, where its two examples contradict each other and the manual. "In official documentation, this region is named ...": a name, not used |
| n64brew, MIPS Interface | the registers, the modes, the measurements of time | the byte lanes of its examples, as above |
| n64brew, RDRAM Interface | the RI's registers, banks, errors, the dropped carry, refresh | the page cites libultra's header for a name (RI_WERROR), and nothing from that is used. RI_SELECT's values are from the boot code, which the owner allowed |
| n64brew, RDRAM | the chips, their registers, Delay after a reset, the steps to set them up | its pseudocode of a libultra function (how much memory there is) was seen and is not used. The current's own steps are not run, only a threshold that they find |
| NEC, 1995 data book, uPD488170L | the times above | |
| NEC, VR4300 User's Manual | the order of bytes on SysAD | |
What we need and could not find: how the RCP chooses between those who want the memory, how long the VI and the RDP use it, whether the
console's chips have NEC's times, and what is read where no chip answers.