DDR5 memory: how a byte is stored
Main memory (RAM) holds the code and data of running programs while the computer is on. Each bit in it is a charge in a capacitor with an area of thousandths of a square micrometer, and this charge leaks away within milliseconds. To read a byte, the memory controller in the processor breaks the address down into channel, bank, row and column and sends the chips a series of commands: open the row, read the column, close the row. Hence the main property of memory: neighboring data is read quickly, scattered data slowly.
The DDR5 module
A DIMM module is a 133 × 31 mm printed circuit board with 288 contacts. On it are DRAM chips, a PMIC power chip and the SPD — a small memory describing the module (capacity, organization, timings, XMP/EXPO overclocking profiles) together with a temperature sensor. The firmware reads the SPD at every startup to know how to handle the module.
Capacity is built up from chips. A typical DDR5 die is 16 Gbit (2 GB). A 16 GB module is 8 such chips, each 8 bits wide: together 64 bits of data, that is, two 32-bit subchannels. A 32 GB module is usually 16 chips in two ranks: two sets of 8 chips share the same data lines and take turns. Server modules add chips for an error-correcting code (ECC).
In DDR5 the voltage regulator moved from the motherboard onto the module: the PMIC receives 5 V and produces 1.1 V for the chips and 1.8 V for auxiliary circuits. Overclocking profiles raise the voltage to 1.25–1.4 V, and the module gets noticeably warm — which is why heatsinks are put on them.
The number in the name is the transfer rate, not the frequency. DDR5-6000 transfers 6000 million bits per second on each data line (6000 MT/s), while the bus clock frequency is 3000 MHz: data is sent on both edges of the clock, hence Double Data Rate. The cell arrays inside the die run far slower — at hundreds of megahertz; the interface speed comes from the fact that a single internal access reads many bits at once, which are then sent out one after another.
The model shows a “magnifying glass”: from a chip on the module to its die, from the die to a single bank, from the bank to a single cell. The scale changes roughly a millionfold — from centimeters to fractions of a micrometer.
The DRAM die: groups and banks
A 16 Gbit DDR5 die (x8 organization) is divided into 32 banks, grouped into 8 groups of 4. A bank is an independent cell array with its own row decoder and its own row buffer. Along the edge of the die is the interface: line receivers and transmitters, command logic, refresh counters.
Why so many banks? Opening a row is slow (≈ 10 ns), while transferring data from an already open row is fast. While one bank opens a row, another delivers data, and a third closes its row. The memory controller juggles dozens of requests and distributes them across banks so that the data bus is never idle.
Bank groups appeared because the internal buses of the die cannot keep up with the external interface. Back-to-back accesses to the same group require a longer pause (tCCD_L), to different groups a shorter one (tCCD_S). So the controller tries to alternate groups — like a cashier serving different windows in turn.
Which bank and which row are read is decided by the address. The controller breaks the physical address into fields: the byte within a 64-byte cache line, channel, group, bank, column, row. In the teaching model the mapping is straightforward (byte — bits 0–5, channel — bit 6, bank — 7–8, group — 9–11, column — 12–21, row — 22–37); real controllers additionally scramble the bits (XOR) so that typical access patterns do not all hit one bank.
A DDR5 die also has built-in error correction (on-die ECC): 8 check bits are stored for every 128 bits, and a single error is corrected inside the chip. This is no substitute for full ECC memory: it protects only the cell array, not transfers over the bus, and the processor never learns about such corrections.
The bank: rows, decoder, row buffer, columns
A bank of a 16 Gbit die is an array of 65,536 rows of 8192 cells each (1 KB per row in each die; in a rank of eight dies a row is opened in all of them at once — about 8 KB). The cells are connected by a grid: wordlines run along the rows, bitlines along the columns, and each cell sits at an intersection.
The row decoder receives a 16-bit row number and raises exactly one wordline out of 65,536. All 8192 transistors of that row open, and each capacitor is connected to its bitline. This is the ACT command — “activate the row.”
The row buffer is a row of sense amplifiers, one per bitline. A cell’s charge is tiny, and the voltage on the line shifts by only tens to hundreds of millivolts from the midpoint. The amplifier — a latch of two inverters connected back to back — “pulls” this deviation all the way to a full 0 or 1. Now the whole row sits in the buffer at clean levels and, in the same motion, is written back into the cells.
Column selection is a multiplexer between the buffer and the data bus. The RD command specifies a column, and the needed piece is selected from the open row: an x8 chip delivers 16 × 8 = 128 bits in one BL16 burst. The four chips of a 32-bit subchannel together give 64 bytes — exactly one processor cache line. A WR write works the same way, except that data goes from the bus into the buffer and from the buffer into the cells.
While a row is open, it can be read as many times as you like — this is a row hit, and only the CL latency is needed. To access a different row in the same bank, the current one must first be closed: the PRE (precharge) command disconnects the row and equalizes the bitlines to half the supply voltage. Only then can a new one be opened. That is why the order of accesses matters: sequential reads almost always hit the open row, while random ones usually do not.
The cell: a transistor and a capacitor
A DRAM cell is one transistor and one capacitor (1T1C). A charged capacitor is 1, a discharged one is 0. The transistor acts as a switch: its gate is connected to the wordline, and when the row is activated, it connects the capacitor to the bitline.
The capacitor’s capacitance is on the order of 10 femtofarads; at a voltage of about a volt that is a few tens of thousands of electrons. To fit such a capacitance into an area of ≈ 0.002 µm², the capacitor is made as a tall, narrow pillar — its height is dozens of times its diameter. All DRAM miniaturization runs up against the capacitor: you cannot shrink the capacitance much, or the signal will drown in noise.
Reading destroys the data. The bitline is much longer and has far more capacitance than the cell capacitor; when they are connected, the charge is shared, and only a small deviation from the midpoint remains on the line. The amplifier amplifies it and at the same time recharges the capacitor to the full level. So reading and restoring are a single operation, and a row can be closed only after restoration has finished (the minimum time tRAS).
The charge leaks away — through the closed transistor and through the dielectric. Most cells hold their data for seconds, but the weakest ones for much less, so the standard guarantees retention only if every row is refreshed once every 32 ms. In the model the leakage is sped up so that you can see it.
Why not store a bit in a flip-flop, as in the processor’s cache? A static memory (SRAM) cell is 6 transistors; it is faster and needs no refresh, but takes 10–20 times more area. So SRAM is used for megabytes of cache, and DRAM for gigabytes of main memory. This is the memory hierarchy: small and fast next to the core, large and slow farther away.
The data bus: from die to processor
The data bus in the model is the path from the row buffer to the memory controller in the processor. In a real PC this path includes: column selection and the die’s internal buses, output drivers, chip contacts, module traces, the slot contact, a few centimeters of board traces and the socket contacts. Each link adds reflections and attenuation, and at 6000 MT/s a bit lasts only 0.17 ns — the receiver is left with a very narrow “window” in which the signal can be read reliably.
Several techniques help. On-die termination (ODT) suppresses reflections at the end of the line. The equalizer in DDR5 receivers (DFE) subtracts the “echo” of previous bits from the current bit. DQS strobes travel along with each byte’s data, and the receiver latches the bits using a signal that has traveled the same path. And training at startup tunes delays and thresholds for the specific board and the specific module.
The memory controller is part of the processor and is, in essence, a scheduler. It holds a queue of requests from all cores, reorders them (serving hits to open rows first, batching writes together), observes dozens of timing constraints and inserts refreshes on time. Real memory speed depends on its quality no less than on the numbers on the module’s label.
Data travels in bursts. A BL16 burst over a 32-bit subchannel is 16 transfers of 4 bytes = 64 bytes, exactly one cache line; at 6000 MT/s it lasts ≈ 2.7 ns. The peak bandwidth of a module is 64 bits × 6000 MT/s = 48 GB/s, and of two channels 96 GB/s. In practice you get 70–85% of peak: part of the time goes to switching rows, switching between reads and writes, and refresh.
A read step by step: the processor needs a byte
Suppose a program loads a value from memory, and the needed data is in none of the caches (L1, L2, L3). This is a miss, and a request for the whole 64-byte cache line goes to the memory controller. Just the path from the core through all the caches to the controller takes tens of nanoseconds.
1. The controller breaks the physical address into channel, bank group, bank, row and column. 2. It checks its table: what is currently open in this bank? There are three possible cases: the bank is closed, the needed row is open, or a different row is open.
3a. A hit — the needed row is already open: an RD command right away. After CL = 30 clocks (10 ns at 3000 MHz) data starts flowing, and the burst lasts another 8 clocks (≈ 2.7 ns) — ≈ 13 ns in total. 3b. The bank is closed: ACT, wait tRCD = 10 ns for the row to open and the amplifiers to settle, then RD — ≈ 23 ns. 3c. A conflict — a different row is open: PRE, wait tRP = 10 ns, then ACT and RD — ≈ 33 ns.
4. The data arrives at the processor; the controller assembles the cache line and passes it to L3, L2, L1 and into the register. From the core’s point of view the whole thing takes 60–100 ns. At 5 GHz that is 300–500 clock cycles, during which the core could have executed more than a thousand instructions. That is why the processor needs caches, data prefetching and out-of-order execution.
The level’s demo walks through exactly these cases: a read to a closed bank, a read of the same row (fast), a read of a different row in the same bank (slowest of all), a write to another bank (proceeds in parallel), a refresh (all rows are closed) and a miss again. The address field shows which bits went into which field.
Refresh: memory that forgets
Every ≈ 3.9 µs (the tREFI interval) the controller sends a REF command. Which rows to refresh the chip decides on its own: an internal counter goes round in a circle, and over 8192 commands — 32 ms — every row of every bank gets refreshed. The refresh itself is simply opening a row and closing it: the amplifiers restore the charge.
While an all-bank refresh is in progress, the die is unavailable for tRFC ≈ 295 ns (for a 16 Gbit die). 295 ns out of every 3900 is about 7.5% of the time. That is why DDR5 introduced same-bank refresh (REFsb): one bank in each group is refreshed at a time, while the rest keep working.
Leakage depends on temperature: when heated above ≈ 85 °C the charge drains faster, and the refresh interval is halved. That is what the temperature sensor on the module is for.
A related problem is Row Hammer. If the same row is opened very often, electrical interference speeds up leakage in neighboring rows, and a bit there can flip before the next refresh. This has already been exploited in attacks. DDR5 defends itself with additional mechanisms — the RFM command and, in newer versions of the standard, per-row activation counters — which refresh the “neighbors” of too frequently opened rows in time.
Timings, latency and bandwidth
The timings on the label, for example CL30-36-36, are delays in bus clock cycles: CL (from the read command to the data), tRCD (from opening a row to reading), tRP (closing a row). The model uses DDR5-6000 CL30-30-30. To compare modules, a timing is converted to nanoseconds: CL × 2000 / MT/s. DDR5-6000 CL30 is 30 × 2000 / 6000 = 10 ns; DDR4-3200 CL16 is also 10 ns. The absolute latency of the cells has barely changed for twenty years and stays around 10–15 ns.
What grows is bandwidth: DDR4-3200 gives 25.6 GB/s per channel, DDR5-6000 48 GB/s. This is achieved through the width of internal reads and the burst length, not by speeding up the cells: the physics of the capacitor and long bitlines does not allow them to be made much faster.
Hence two modes of operation. Sequential traversal of an array: rows are opened rarely, the processor’s prefetcher knows in advance what will be needed, and data flows at close to peak speed. Random accesses (walking a linked list, a hash table larger than the cache): almost every access is a cache miss and a row change, and the program is limited by latency rather than bandwidth. The difference can be tens of times.
The time scale: a register — a fraction of a nanosecond, L1 — ≈ 1 ns, L2 — 3–4 ns, L3 — 10–15 ns, main memory — 60–100 ns, NVMe SSD — 50–100 µs (a thousand times longer), hard drive — milliseconds. Each level down is slower, but larger and cheaper per byte.
Common misconceptions
“More megahertz is always faster.” Frequency raises bandwidth, but if the timings in clock cycles grow proportionally, the latency in nanoseconds stays the same. Many programs and games care about latency; archivers, video encoding and integrated graphics care about bandwidth.
“Memory holds data as long as the computer is on.” More precisely — as long as the controller refreshes the rows. Without refresh, data starts disappearing within fractions of a second; when cooled, noticeably later, and “cold boot” attacks are based on this.
“Memory is 80% used, so there isn’t enough.” The operating system deliberately fills “free” memory with a file cache and gives it to programs on first demand. A memory shortage is revealed by something else — constant swapping to disk.
“Two 8 GB modules are the same as one 16 GB module.” In capacity — yes; in speed — no: two modules in different channels give twice the bandwidth. This is especially noticeable for integrated graphics, which borrows memory from the processor.