DRAM in One Picture

DRAM holds the most bits for the money, because one bit is one tiny charge. The charge leaks, and everything else about DRAM follows from that.

You Will Be Able To

  • Describe a DRAM cell, and say why it is much smaller than an SRAM cell.
  • Explain why a read must be followed by a write back, and why every row needs a refresh.
  • Work out how long a row may wait for its refresh, and what a late refresh does.
Lesson
S3.14
Time
22 min
Runs on
Your browser
Check
6 questions

A phone holds four gigabytes of working memory. Suppose the chip stopped tending that memory. The content would start to fade within a fraction of a second, with the power still on.

Before You Start

You need S3.1: the six kinds of memory, and that an SRAM bit is a loop of transistors.

You also need the idea of a capacitor: a part that holds an electric charge for a while.

Five questions this page answers
Question
1How does a DRAM cell hold a bit, and why is it so small?
2What does a read do to a cell, and what must follow it?
3Why must a DRAM be refreshed?
4What happens when a refresh comes too late?
5Why does DRAM sit in chips of its own, behind a controller?

The Idea: A Bit That Is Only a Charge

An SRAM bit is a loop of transistors that drives its own value. So it holds for as long as the power is on. It needs six transistors. A DRAM bit is far simpler: one capacitor and one switch. A charge on the capacitor means 1. No charge means 0.

That cell is tiny, and so DRAM packs ten to twenty times more bits into the same area. It is the only way to give a phone gigabytes of memory. The price comes in two parts.

First, a read destroys what it reads. The charge of one cell is so small that reading it empties it. So every read is followed at once by a write back of the same value. The chip does this by itself.

Second, the charge leaks. A full cell slowly empties, even when nobody touches it. After some milliseconds, a 1 can no longer be told from a 0. So the chip must visit every row in time, read it and write it back. That visit is called a refresh, and it never stops.

A memory that must be visited on a schedule cannot simply sit on a bus. It needs a controller that keeps the schedule and fits the reads of the processor in between.

New Words

New words on this page
WordMeaning
CapacitorA part that holds an electric charge. A small one holds little charge, and loses it within milliseconds.
Cell of a memoryThe circuit that holds one bit. A DRAM cell is one capacitor and one switch.
Row of a memoryThe cells that one row line opens together. A read or a refresh always handles a whole row.
Bit lineThe wire that connects all cells of one column to the edge of the memory.
Sense amplifierA circuit at the end of a bit line. It turns a tiny change of voltage into a clear 1 or 0.
Sense levelThe charge that a cell needs for a 1 to be read as a 1.
Destructive readA read that empties the cell it reads. The value must be written back.
RefreshTo read a row and write the same values back, at full charge.
Refresh intervalThe longest time a row may wait between two refreshes.
DRAM controllerThe logic that sends reads, writes and refreshes to a DRAM, each at its proper time.

One Picture: The Cell and Its Refresh

One Cell, One Row, and the RefreshStep through the picture. It starts with one cell and ends with the logic that keeps every row alive.
  • Control / FSM
  • Bus
  • Memory
  • Processor
One Cell, One Row, and the RefreshStep through the picture. It starts with one cell and ends with the logic that keeps every row alive. component Row line opens every switch ofone row component Switch one transistor component Capacitor charge means 1, nocharge means 0 component Bit line a long wire shared byone column component Sense amplifier decides 1 or 0, andwrites it back component DRAM controller refreshes every rowin turn openclosed: the chargestaysopen: the charge runsouta small changewritten back, fullone row at a time
  1. component Switchone transistor
    • closed: the charge stays → Capacitor
    • open: the charge runs out → Bit line
  2. component Capacitorcharge means 1, no charge means 0
  3. component Row lineopens every switch of one row
    • open → Switch
  4. component Bit linea long wire shared by one column
    • a small change → Sense amplifier
  5. component Sense amplifierdecides 1 or 0, and writes it back
    • written back, full → Capacitor
  6. component DRAM controllerrefreshes every row in turn
    • one row at a time → Row line
  1. One cell

    A bit is a charge on a capacitor, behind one switch. A full capacitor is a 1, and an empty one is a 0. That is the whole cell.

  2. A read empties it

    The row line opens the switch. The charge runs out onto the bit line, which is far larger than the capacitor. The cell is now empty.

  3. The sense amplifier decides, and writes back

    The bit line changed by a tiny amount. The sense amplifier decides 1 or 0 from that, and writes a full value back into the cell.

  4. The charge leaks

    Even with the switch closed, the charge slowly leaks away. After some milliseconds a 1 looks like a 0.

  5. The refresh

    So every row is read and written back before that happens, again and again, for as long as the power is on.

Read the diagram as text
  • Row line: opens every switch of one row
  • Switch: one transistor
  • Capacitor: charge means 1, no charge means 0
  • Bit line: a long wire shared by one column
  • Sense amplifier: decides 1 or 0, and writes it back
  • DRAM controller: refreshes every row in turn
  • Row line → Switch: open
  • Switch → Capacitor: closed: the charge stays
  • Switch → Bit line: open: the charge runs out
  • Bit line → Sense amplifier: a small change
  • Sense amplifier → Capacitor: written back, full
  • DRAM controller → Row line: one row at a time

One cell of a DRAM and what keeps it alive. A real chip has billions of cells.

The Smallest Example, Worked by Hand

One cell, in a model with small numbers. A 1 is written as a charge of 8. One unit leaks away in each tick. A read sees a 1 when the charge is 4 or more: that is the sense level.

One cell that holds a 1, tick by tick
TickChargeRead asA refresh now would write back
0811, at charge 8
1711
2611
3511
4411: the last safe tick
5300: the bit is lost

The charge may fall from 8 to 4, which takes 4 ticks. So the refresh interval of this cell is 4 ticks.

Look at the last row. At tick 5 the cell reads as 0. A refresh at that moment does not help. It reads 0 and writes 0 back, at full strength. From then on the wrong value is perfectly stable.

A cell that holds a 0 has no charge to lose. In this model it stays at 0 for ever, so only the 1s are in danger.

The Rules

  1. Rule 1: A DRAM bit is a charge on a capacitor, behind one switch.

    The cell is tiny, so DRAM holds many times more bits than SRAM in the same area.

  2. Rule 2: A read empties the cell.

    So the chip writes the value back at once, after every read.

  3. Rule 3: The charge leaks, with the power on.

    A 1 that is left alone turns into a 0.

  4. Rule 4: A refresh reads a row and writes it back.

    Every row must get one before any of its 1s falls below the sense level.

  5. Rule 5: A late refresh makes the error permanent.

    It reads the wrong value and writes that back at full charge.

  6. Rule 6: The refresh schedule belongs to a controller.

    A row that is being refreshed cannot serve a read, so the controller fits both in.

Sources for These Rules

The textbook "Computer Organization and Design" by Patterson and Hennessy, section 5.2, "DRAM Technology". It gives one transistor for each bit and a charge that must be refreshed. A refresh reads a row and writes it back.

The textbook "Digital Design and Computer Architecture" by Harris and Harris, section 5.5.2. It gives the cell of one transistor and one capacitor, the read that destroys the content, and a refresh every few milliseconds.

The textbook "CMOS VLSI Design" by Weste and Harris, section 12.3: the cell, the bit line and the sense amplifier. It also gives the special manufacturing process that makes DRAM 10 to 20 times denser than SRAM.

The charge of 8, the leak of one unit in each tick and the sense level of 4 are numbers of our model. A real cell leaks unevenly, faster when it is hot, and its refresh interval is some milliseconds.

Our reference library holds no DRAM standard. This page states no command, no timing value and no refresh interval of a real part.

Now Run It

The lab at the end of this page is test code. It models one row of four cells, each as a number for its charge. It writes 1011 into the row, and then lets time pass.

Printed by the lab on Icarus. The four charges are printed with bit 3 on the left.
t=0 write 1011   | charge 8 0 8 8 | reads as 1011
t=3 wait 3       | charge 5 0 5 5 | reads as 1011
t=3 refresh      | charge 8 0 8 8 | reads as 1011
t=7 wait 4       | charge 4 0 4 4 | reads as 1011
t=7 refresh      | charge 8 0 8 8 | reads as 1011
t=11 wait 4       | charge 4 0 4 4 | reads as 1011

Rule 3 at work: the second row. After 3 ticks, each 1 has fallen from 8 to 5. The cell that holds a 0 stays at 0.

Rule 4 at work: the rows that say "refresh". Each one brings the three 1s back to 8. The row is refreshed after 3 ticks and then after 4 more.

The rows at t=7 and t=11 show the limit from the hand table. The charge is exactly 4, the row still reads as 1011, and one more tick would lose it.

This lab leaves out the electronics. Charge is a whole number, the leak is steady, and a refresh takes no time. It also leaves out the controller. A later page shows one on a large chip.

Why It Is Built This Way

Design choiceThe alternativeWhat the choice buys, and costs
One capacitor and one switch for a bitThe loop of six transistors of an SRAMTen to twenty times more bits in the same area. Reads that destroy, and a leak.
A refresh for every row, all the timeA cell that holds its chargeThe tiny cell stays usable. The memory uses power even when idle, and is sometimes busy with itself.
DRAM in chips of its ownDRAM on the same chip as the processorA factory that is tuned for capacitors. A fast and difficult link between the two chips.
A controller in front of the DRAMThe DRAM straight on the busRefresh is hidden from the processor. One more block to design and to check.

The Trap: The Refresh That Came Late

A power-saving feature stretches the refresh by one tick, from four ticks to five. On the bench the memory test still passes, because the bench is cool and real cells leak slowly then. In a warm room, the product starts to crash. Here is the row of the lab with a refresh after five ticks:

The same model with other steps.
t=0 write 1011   | charge 8 0 8 8 | reads as 1011
t=5 wait 5       | charge 3 0 3 3 | reads as 0000
t=5 refresh      | charge 0 0 0 0 | reads as 0000
t=6 wait 1       | charge 0 0 0 0 | reads as 0000

Rule 5 at work. At t=5 the charges are 3, below the sense level, and the row reads as 0000. The refresh then writes 0000 back: the charges become 0. One tick later the row is still 0000, and it will stay so.

Nothing reported an error. The memory accepted every command and answered every read. This is why refresh settings are never tuned by trying them out on one board.

At Scale

This page1 row of 4 cells
A phonebillions of cells, in chips beside the main chip

This section looks ahead. A real DRAM has billions of cells, and a controller that does far more than refresh.

  1. The controller and its link

    The commands, the fast link and its tuning: the memory of a large chip.

  2. Sleep

    A sleeping phone must still refresh its DRAM, or lose everything. The DRAM can do it alone, in a special low-power state.

  3. Small chips do without

    A chip like ap_soc has 64 KiB of SRAM and no DRAM. Below a few mebibytes, SRAM on the chip is simpler and cheaper.

  4. Errors

    With billions of leaking cells, single wrong bits do happen. Large memories carry extra bits to find and repair them.

Try It

Run the lab. Check the charges after each wait against the hand table.

Change the first leak(3) to leak(5). Predict what the row reads as at the end.

Set SENSE to 2. Work out the new refresh interval, and test it with one long wait.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: t=0 write 1011 | charge 8 0 8 8 | reads as 1011 t=3 wait 3 | charge 5 0 5 5 | reads as 1011 t=3 refresh | charge 8 0 8 8 | reads as 1011 t=7 wait 4 | charge 4 0 4 4 | reads as 1011 t=7 refresh | charge 8 0 8 8 | reads as 1011 t=11 wait 4 | charge 4 0 4 4 | reads as 1011

Check Yourself

Predict the outputIn this run a 1 is written as a charge of 10, and the sense level is 4. The row 0110 is refreshed after 6 ticks and then waits 6 more. What does the last row say?
// One row of a DRAM: four cells. Each cell is a charge, and the charge leaks away.
// Time is in ticks of this model. A real cell leaks over some milliseconds.
module tb;
  localparam FULL  = 10;        // the charge of a 1 that was just written
  localparam SENSE = 4;        // a read calls a charge of SENSE or more a 1
  int charge [0:3];
  int now = 0, refreshes = 0;
  logic [3:0] seen;

  task automatic show(input string what);
    for (int i = 0; i < 4; i++) seen[i] = (charge[i] >= SENSE);
    $display("t=%0d %-12s | charge %0d %0d %0d %0d | reads as %b", now, what, charge[3], charge[2], charge[1], charge[0], seen);
  endtask
  task automatic write_row(input logic [3:0] bits);
    for (int i = 0; i < 4; i++) charge[i] = bits[i] ? FULL : 0;
  endtask
  task automatic leak(input int ticks);            // one unit of charge leaks away in each tick
    repeat (ticks) begin
      now++;
      for (int i = 0; i < 4; i++) if (charge[i] > 0) charge[i]--;
    end
    show($sformatf("wait %0d", ticks));
  endtask
  // A read empties the cells onto the bit lines, so the row must be written back at once.
  // A refresh is exactly that: read the row, and write back what was read.
  task automatic refresh;
    for (int i = 0; i < 4; i++) seen[i] = (charge[i] >= SENSE);
    write_row(seen);
    refreshes++;
    show("refresh");
  endtask

  initial begin
    write_row(4'b0110);  show("write 0110");
    leak(6);
    refresh;
    leak(6);
  end
endmodule
ConceptWhat holds one bit in a DRAM?
ConceptWhat must follow every read of a DRAM cell?
ConceptWhy must a DRAM be refreshed?
ConceptA refresh reaches a row after its 1s have fallen below the sense level. What happens?
ConceptWhy does a DRAM need a controller between it and the bus?

Common Mistakes

Wrong Treat DRAM like a large SRAM.

Its charge leaks, and a read empties the cell.

Fix Plan for a controller that refreshes every row in time.

Wrong Expect a late refresh to repair a weak bit.

A refresh writes back what it reads. Below the sense level it reads 0.

Fix Keep every row inside its refresh interval, in every state of the chip.

Wrong Stop the refresh while the processor sleeps.

The cells leak whether or not anybody reads them.

Fix Keep the refresh running, or accept that the content is lost.

Remember

  • A DRAM bit is a charge on a capacitor behind one switch: tiny, so DRAM is very dense.
  • A read empties the cell, so the value is written back at once.
  • The charge leaks, so every row is refreshed on a schedule, for as long as the power is on.
  • A late refresh writes the wrong value back. A controller owns the schedule.

Practice

Report a problem with this page