Here's a question that separates people who've memorized DRAM terms from people who understand controllers: "Given a physical address, how does the memory controller decide which channel, bank, row and column it goes to?" The answer is address mapping, and the choice of mapping can swing bandwidth as much as the scheduler does.
The pieces of a DRAM address
A DDR5 system splits every physical address into fields:
- Channel: which independent memory channel (each DDR5 DIMM has two 32-bit subchannels).
- Rank: which set of chips on the channel.
- Bank group and bank: which of the 32 banks in a DDR5 device (8 bank groups of 4 banks for 16 Gb parts).
- Row: which row inside the bank gets activated.
- Column: which burst inside that open row.
The controller's job is to decide which address bits feed which field.
The naive mapping and why it hurts
The simplest mapping puts the fields in order from top to bottom: row bits at the top, then bank, then column at the bottom. Sequential addresses then march through the columns of one row, which is great: lots of row hits.
The trouble comes when a sequential stream runs off the end of a row. It moves to the next row in the same bank, which is a row conflict. Worse, two arrays that happen to be a multiple of the row-and-bank size apart map to the same bank and different rows, so accessing them alternately thrashes that bank.
Better mappings
Real controllers use a few standard tricks:
- Put channel and bank-group bits low. Consecutive cache lines (or small groups of them) go to different channels and bank groups, so a streaming access spreads across the hardware and gets the short tCCD_S spacing instead of tCCD_L.
- Keep some column bits below them. You still want a few consecutive accesses in the same row to get row hits. The design question is how many.
- XOR hashing. Bank bits are XORed with some row bits. Two addresses that would collide in the naive mapping now land in different banks. This is cheap in hardware (a handful of XOR gates) and removes most pathological conflicts.
A worked example
Take a naive mapping where the row bits start at address bit 20 and the bank and column bits sit below it. Two arrays exactly 1 MB apart then differ only in their row bits, so element i of each array lands in the same bank but a different row. A loop that reads a[i] then b[i] gets a row conflict on every access. XOR the bank bits with low row bits and a[i] and b[i] now land in different banks, because their row bits differ. Both rows can stay open, and most accesses become hits.
The trade-off interviewers want to hear
Spreading accesses across banks and channels (interleaving) improves parallelism, but it reduces row locality, since fewer consecutive accesses share a row. Keeping more column bits low improves locality but concentrates traffic. The right mapping depends on the workload, which is why controllers often make it configurable.
How to answer in an interview
List the fields, explain why naive row-bank-column mapping causes conflicts, then propose low-order channel and bank-group interleaving plus XOR bank hashing. Close with the locality-versus-parallelism trade-off.
Free cheat sheet
DDR5 bank organization and every DDR5-4800 timing on one page: download it free. For the full guide with 30 interview questions and model answers, see the DRAM & DDR5 Interview Field Guide.
This article was generated with AI from the author's study notes.
Top comments (0)