Chapter 23 of 39

RAM & ROM: SRAM, DRAM & Types of ROM

When you switch off your laptop, the document you forgot to save is gone, but the laptop still knows how to start up the next morning. Two very different kinds of memory are at work here. One is fast and rewritable but forgets everything without power. The other keeps its contents for years but is slow or awkward to change.

The first kind is RAM (random-access memory), and the second is ROM (read-only memory) and its modern descendants like flash. In Memory Hierarchy we saw that caches are built from SRAM and main memory from DRAM. In this chapter we open up the chips and see what a single bit actually looks like inside each technology, because that explains why SRAM is fast, why DRAM is cheap and needs refreshing, and why there are so many types of ROM.

RAM is read-write memory in which any location can be accessed in the same amount of time; it is volatile (contents are lost when power is removed). ROM is non-volatile memory whose contents are written during manufacture or by a special programming process, and which is mainly read during normal operation.

A small naming confusion first: ROM chips are also random-access (any address can be read in the same time). The names are historical. "RAM" in practice means read-write, volatile memory, and "ROM" means mostly-read, non-volatile memory.


The Two Families of RAM

All semiconductor RAM is organized as a grid of cells, each storing one bit. A horizontal word line selects a row of cells; vertical bit lines carry the data in and out. What differs between SRAM and DRAM is how a single cell holds its bit.

Static RAM (SRAM)

An SRAM cell is essentially a tiny latch: two inverters connected in a loop, so each one keeps the other's output steady. The loop has two stable states, which represent 0 and 1. Two extra access transistors connect the latch to the bit lines when the word line is active. Since each CMOS inverter uses two transistors, the standard cell has six transistors (6T).

          word line
   ---------+--------------------------+---------
            |                          |
          [T5]     +---|>o---+       [T6]      T1..T4: two cross-coupled
            |      |         |         |       inverters (the latch)
   bit  ----+------+         +---------+---- bit-bar
   line            |         |                 T5, T6: access transistors
                   +---o<|---+
                  (inverter 2 drives inverter 1 and vice versa)

Key properties:

  • Static: the latch keeps the bit as long as power is on. No refreshing is needed.

  • Fast: the latch actively drives the bit lines, so reading is quick and does not destroy the stored value.

  • Large cell: six transistors per bit means few bits per mm2 and a high cost per bit.

  • Used for: caches (L1, L2, L3), register files, small on-chip buffers.

Dynamic RAM (DRAM)

A DRAM cell stores a bit as charge on a tiny capacitor. One transistor acts as a switch between the capacitor and the bit line. That is just one transistor and one capacitor (1T1C) per bit.

            word line
   ------------+-------------
               |
   bit line --[T]--+
                   |
                  === C    charged   = 1
                   |       discharged = 0
                  GND

This simplicity has big consequences:

  • Dense and cheap: one transistor plus a capacitor is far smaller than six transistors, so DRAM packs many more bits into the same area. That is why main memory is DRAM.

  • Leaks: the capacitor slowly loses its charge through leakage currents. After some milliseconds, a 1 would look like a 0. So every cell must be read and rewritten periodically. This is called refresh, and it is why the memory is called dynamic.

  • Destructive read: the capacitor is tiny compared with the bit line. When the cell is connected, its charge spreads onto the bit line and only a very small voltage change appears. A sense amplifier detects that change and amplifies it to a full 0 or 1, and then writes the value back into the cell. Reading therefore always includes a restore.

  • Slower than SRAM, because of sensing, restoring and refresh.

SRAM vs DRAM

FeatureSRAMDRAM
Storage elementCross-coupled inverters (latch)Capacitor
Transistors per bit6 (typical)1 (plus a capacitor)
Refresh needed?NoYes, periodically
ReadNon-destructiveDestructive, data is written back after reading
SpeedFasterSlower
DensityLowHigh
Cost per bitHighLow
PowerNo refresh power; leakage in large arraysNeeds refresh power even when idle
Address pinsFull address given at onceUsually multiplexed: row address, then column address
Typical useCache memory, register filesMain memory
Volatile?YesYes

A common exam trap: both SRAM and DRAM are volatile. "Static" does not mean non-volatile; it means "no refresh needed while power is on".


Inside a DRAM Access

DRAM cells are arranged in large 2-D arrays (and a chip has several such arrays called banks). An access happens in phases:

  1. Precharge: bit lines are set to a middle voltage so a small change either way can be sensed.

  2. Row activate (RAS, row address strobe): the row address selects one word line. All cells in that row dump their charge onto their bit lines, and the sense amplifiers latch the whole row (thousands of bits). This set of latched bits is called the row buffer. The sense amplifiers also restore the row's cells.

  3. Column access (CAS, column address strobe): the column address picks the required bits out of the row buffer and sends them out (or writes new bits into it).

  4. Precharge again before a different row can be opened.

Two useful consequences:

  • The row and column addresses are sent at different times, so DRAM chips can share the same address pins for both. This address multiplexing halves the number of address pins. It is discussed with chip pin counts in Main Memory Organization & Memory Chips.

  • Once a row is open, more columns of the same row can be read quickly, without another activation. Modern DRAM uses this to deliver bursts of data, which fits perfectly with filling a cache block.


DRAM Refresh

Refresh is done one row at a time: activating a row reads every cell in it into the sense amplifiers and writes it back at full strength. So refreshing the whole chip means activating every row once within the refresh period (also called the retention time or refresh window).

For common DDR3 and DDR4 memory at normal temperatures, the refresh window is 64 ms, spread over 8192 refresh commands, so one refresh command is issued about every 64 ms / 8192 = 7.8 µs. DDR5 halves the window to 32 ms (one refresh about every 3.9 µs), and the rate doubles again at high temperatures, because leakage grows with temperature.

Refresh Strategies

StrategyHow it worksEffect
Burst refreshAll rows are refreshed one after another in a single block of time, once per refresh period.Memory is unavailable for one long stretch; bad for real-time response.
Distributed refreshRow refreshes are spread evenly over the period: one row every (refresh period / number of rows).Many short pauses instead of one long one; the usual approach.
Self-refreshIn a low-power state, the DRAM refreshes itself with an internal timer and counter.Keeps data while the system sleeps (for example, laptop suspend).

Older asynchronous DRAMs also used names like RAS-only refresh, CAS-before-RAS refresh and hidden refresh for how the controller triggered each row refresh. Modern SDRAM uses an auto-refresh command, with the row counter kept inside the chip.

Worked Example 1: Refresh Overhead

A DRAM chip has 8192 rows. Refreshing one row takes 60 ns, and every row must be refreshed once every 4 ms. What percentage of time is spent on refresh, and what percentage is available for reads and writes?

Time to refresh all rows = 8192 x 60 ns = 491,520 ns = 491.52 us
Refresh period           = 4 ms = 4000 us

Fraction spent refreshing = 491.52 / 4000 = 0.12288  -> 12.29 %
Available for read/write  = 100 - 12.29             =  87.71 %

When a memory module is built from many chips, they are normally refreshed in parallel (all chips refresh the same row number at the same time), so the overhead is calculated from one chip's rows, not the total over all chips. This is a classic GATE detail.

Worked Example 2: Distributed Refresh Interval

A DRAM must refresh 8192 rows every 64 ms using distributed refresh. How often must a row refresh be issued?

Interval = 64 ms / 8192 = 7.8125 us

This is exactly the 7.8 µs figure used by DDR3/DDR4.

Worked Example 3

A DRAM has 214 rows. Each row refresh takes 40 ns and the refresh period is 2 ms. Find the percentage of time available for normal memory operations.

Refresh time = 16384 x 40 ns = 655,360 ns = 0.65536 ms
Fraction     = 0.65536 / 2   = 0.32768  -> 32.77 % for refresh
Available    = 100 - 32.77   = 67.23 %

Types of DRAM

DRAM has evolved mainly to deliver more data per second, since the basic cell latency has improved only slowly.

TypeKey idea
Asynchronous DRAM (including FPM and EDO)No clock; the controller drives RAS and CAS signals and waits fixed delays. Fast Page Mode (FPM) and Extended Data Out (EDO) allowed several column accesses within one open row.
SDRAM (synchronous DRAM)All operations are timed by a clock shared with the memory controller. Commands are pipelined, multiple internal banks can work in parallel, and data comes out in programmable bursts. Transfers once per clock cycle (later called SDR SDRAM).
DDR SDRAMDouble Data Rate: transfers data on both the rising and the falling edge of the clock, giving twice the data rate of SDR at the same clock.
DDR2, DDR3, DDR4, DDR5Each generation lowers the voltage and raises the data rate, mostly by fetching more bits internally per access (prefetch) and sending them out faster on the bus.
LPDDRLow-power DRAM for phones and laptops.
GDDR, HBMGraphics DRAM with very high bandwidth; HBM stacks DRAM dies vertically next to the processor with a very wide interface.
GenerationInternal prefetchSupply voltage (standard)
DDR2n2.5 V
DDR24n1.8 V
DDR38n1.5 V (1.35 V for DDR3L)
DDR48n (with bank groups)1.2 V
DDR516n1.1 V

Reading a DDR Name: Bandwidth Calculation

The number in a name like DDR4-3200 is the data rate in mega-transfers per second (MT/s), not the clock frequency. Since DDR transfers twice per clock, the I/O bus clock is half of that, 1600 MHz.

Peak bandwidth of a DDR4-3200 module with a 64-bit (8-byte) data bus:

Bandwidth = transfers per second x bytes per transfer
          = 3200 x 10^6  x  8 B
          = 25.6 x 10^9 B/s = 25.6 GB/s

A DDR5-4800 module also carries 64 data bits in total (as two independent 32-bit sub-channels), so its peak is 4800 × 106 × 8 B = 38.4 GB/s. For comparison, old SDR SDRAM at 133 MHz with a 64-bit bus gave about 133 × 106 × 8 B ≈ 1.07 GB/s.

Bandwidth went up enormously, but latency did not. DDR4-3200 with CAS latency 22 (cycles of the 1600 MHz clock) has a CAS delay of 22 / 1.6 GHz = 13.75 ns; DDR5-4800 with CL 40 (2400 MHz clock) has 40 / 2.4 GHz ≈ 16.7 ns. A bigger CL number does not automatically mean slower memory: always convert cycles to nanoseconds. This flat latency is exactly why caches matter so much.


ROM and Its Family

Every computer needs some memory that keeps its contents without power: at minimum, the first code the processor runs after reset (the boot firmware, BIOS or UEFI on a PC). Embedded systems such as washing machines or microcontrollers often keep their entire program in non-volatile memory.

Most programmable ROM types store a bit using a floating-gate transistor: a MOS transistor with an extra gate completely surrounded by insulator. Electrons trapped on this floating gate change the transistor's threshold voltage, and they stay there for years without power. The types differ mainly in how the bits are written and erased.

Mask ROM

The data is built into the chip by the manufacturer using the photolithography mask during fabrication. It can never be changed. It is the cheapest per chip in very large quantities, but the mask is expensive and any bug means making new chips. Used for fixed firmware in mass-produced devices.

PROM (Programmable ROM)

Manufactured blank. The user programs it once with a device programmer, which blows tiny fuses (or creates connections with antifuses) for the bits that should change. After that it cannot be changed. Also called OTP (one-time programmable) memory.

EPROM (Erasable PROM)

Uses floating-gate transistors that are programmed electrically, by forcing electrons onto the floating gate with a high voltage. To erase it, the chip is exposed to ultraviolet light through a small quartz window on the package for several minutes; the UV light lets the trapped electrons escape. Erasure is all-or-nothing (the whole chip), it needs the chip to be removed from the circuit, and the number of erase cycles is limited.

EEPROM (Electrically Erasable PROM)

Also written E2PROM. It can be erased and rewritten electrically, in the circuit, and individual bytes can be changed. Writing is much slower than reading, and each cell survives only a limited number of write/erase cycles. Its cells are larger than EPROM cells, so it is used for small amounts of data that change occasionally: configuration settings, calibration values, serial numbers.

Flash Memory

Flash is a kind of EEPROM designed for density: it erases in large blocks at once (in a "flash") instead of byte by byte. That simplification makes the cells small and cheap. Writing (programming) can be done in smaller units, but a location cannot be rewritten until its whole block is erased.

FeatureNOR flashNAND flash
Read accessRandom, byte/word level, fastPage by page (a few KB at a time)
Execute code directly from it (XIP)YesNot practical; code is copied to RAM first
Density / cost per bitLower density, more expensiveMuch higher density, cheaper
Write and erase speedSlowerFaster
Typical useBoot firmware, microcontroller program memorySSDs, USB drives, memory cards, phone storage

How SSDs use NAND flash (pages, blocks, wear levelling, garbage collection) is covered in Secondary Storage: Magnetic Disks & SSDs.

Comparison of ROM Types

TypeWho writes itHow it is erasedErase granularityRewritable in circuit?
Mask ROMManufacturer (during fabrication)Cannot be erased–No
PROMUser, onceCannot be erased–No
EPROMUser, with a programmerUltraviolet lightWhole chipNo (removed for erasing)
EEPROMUser / systemElectricallyByteYes
FlashUser / systemElectricallyBlockYes

RAM vs ROM at a Glance

FeatureRAM (SRAM, DRAM)ROM family (ROM, PROM, EPROM, EEPROM, flash)
VolatilityVolatileNon-volatile
WritingAs fast and as easy as reading, unlimitedImpossible, once only, or slow with limited cycles
Main jobHold running programs and their dataHold firmware, boot code, fixed tables, long-term data
ExamplesCache (SRAM), main memory (DRAM)BIOS/UEFI chip, microcontroller program memory, SSD

Since flash is used for SSDs that are written all the time, the line between "ROM" and "storage" is blurry today. For exams, remember the classification by volatility and how writing works.


Common Mistakes

  • Saying SRAM is non-volatile. SRAM and DRAM both lose data without power. "Static" refers only to the absence of refresh.

  • Thinking DRAM refresh is done cell by cell. It is done a whole row at a time. Refresh time = number of rows × time per row refresh.

  • Multiplying rows by the number of chips in refresh-overhead problems. Chips in a module are refreshed in parallel.

  • Treating the "3200" in DDR4-3200 as MHz. It is MT/s; the bus clock is 1600 MHz.

  • Comparing CAS latencies across generations in cycles. Convert to nanoseconds first.

  • Mixing up EPROM and EEPROM. EPROM: UV erase of the whole chip outside the circuit. EEPROM: electrical erase, byte by byte, in the circuit.

  • Saying flash can overwrite a byte in place. A block must be erased before its pages can be written again.


GATE / Interview Questions

Why does DRAM need refreshing but SRAM does not?

A DRAM bit is charge on a capacitor, which leaks away within milliseconds, so it must be read and rewritten periodically. An SRAM bit is held by a latch of cross-coupled inverters that actively maintains its state as long as power is applied.

Why is cache made of SRAM and main memory of DRAM?

SRAM is fast but needs about 6 transistors per bit, so it is expensive and low-density: ideal for small, fast caches. DRAM needs 1 transistor and 1 capacitor per bit, so it is dense and cheap: ideal for large main memory, where some extra latency is acceptable.

What is meant by "DRAM read is destructive"?

Connecting the cell to the bit line shares (and so drains) its stored charge. The sense amplifier amplifies the small signal and then writes the value back to the cell, so every read includes a restore.

A DRAM chip has 213 rows; one row refresh takes 50 ns, and the refresh period is 2 ms. What percentage of time is available for read/write?

Refresh time = 8192 × 50 ns = 409.6 µs. Fraction = 409.6 / 2000 = 20.48%. Available = 79.52%.

What is the peak bandwidth of a DDR4-2400 module with a 64-bit bus?

2400 × 106 transfers/s × 8 bytes = 19.2 GB/s. Its I/O clock is 1200 MHz, with transfers on both edges.

Differentiate EPROM, EEPROM and flash.

All use floating-gate transistors. EPROM is erased by UV light, whole chip at once, outside the circuit. EEPROM is erased electrically in the circuit, byte by byte. Flash is erased electrically in large blocks, which makes it denser and cheaper, and is used for SSDs and firmware.

Where would you use NOR flash instead of NAND flash?

Where code must be executed directly from the chip with fast random reads, such as boot firmware or a microcontroller's program memory. NAND is preferred for bulk storage because it is denser and cheaper.

What is the difference between burst and distributed refresh?

Burst refresh refreshes all rows in one continuous block each period, making memory unavailable for that whole time. Distributed refresh spreads the row refreshes evenly (e.g. one row every 64 ms / 8192 = 7.8 µs), giving many short pauses instead.


Summary

  • RAM is volatile read-write memory; ROM and its relatives are non-volatile and mainly read.

  • SRAM: 6-transistor latch per bit, no refresh, fast, non-destructive read, expensive and low density; used for caches.

  • DRAM: 1 transistor + 1 capacitor per bit, dense and cheap, but leaks and needs row-by-row refresh (64 ms window / 7.8 µs interval for DDR3/DDR4; 32 ms / 3.9 µs for DDR5); reads are destructive and restored by sense amplifiers; used for main memory.

  • Refresh overhead = (rows × time per row) / refresh period; chips are refreshed in parallel.

  • DRAM evolved from asynchronous to SDRAM (clocked, banks, bursts) to DDR (both clock edges) and DDR2–DDR5 (bigger prefetch, lower voltage). DDR4-3200 on a 64-bit bus peaks at 25.6 GB/s, but latency has stayed around 15 ns.

  • ROM family: mask ROM (factory), PROM (once, fuses), EPROM (UV erase), EEPROM (electrical, byte erase), flash (electrical, block erase; NOR for code, NAND for storage).

Next, in Main Memory Organization & Memory Chips, we connect many such chips together to build a complete main memory of the required size and word width.