Skip to main content
Be Bitwise

Memory Elements & Register Files

Digital Logic Design · Hardware Foundations track

6 min read

In this module

Storing State in Hardware

Combinational circuits crunch inputs into outputs instantly, then forget the whole affair. To build a processor we need circuits that remember — that can hold a bit of data and keep it stable until we decide to change it. These memory elements are the bedrock of registers, caches, and every other piece of on-chip storage.

The SRAM Bit Cell

The most important memory element in a processor is the Static RAM (SRAM) cell. Where DRAM stores bits as charge on a capacitor and needs constant refreshing, SRAM uses a bistable circuit and holds its data as long as power's flowing.

The 6-Transistor (6T) Cell

The standard SRAM cell uses 6 transistors:

The two cross-coupled inverters form a bistable latch. The circuit naturally settles into one of two stable states — storing a 0 or a 1 — because each inverter's output feeds the other's input, locking the value in via a tight feedback loop.

The two access transistors connect the cell to the bit lines whenever the word line is asserted. Reading: raise the word line and let sense amplifiers pick up the tiny voltage difference between BL and BL'. Writing: drive the bit lines to the desired value before asserting the word line, overpowering whatever the cell was storing.

Try both operations on the cell below. On SRAM, write a bit, read it, wait as long as you like and read it again: the feedback loop holds the value with no help. Then switch to DRAM and leak some charge. A capacitor drains on its own, so once the level falls far enough the cell needs a refresh before the bit becomes unreadable. Reads cost something too, because sensing a DRAM cell drains it and the value has to be written back.

Memory Cell Operation

Word Line
LOW
6T Cell
1
Bit Line
---
Idle

The 6T SRAM cell uses two cross-coupled inverters to hold a stable bit value. Reading asserts the word line and detects a small voltage difference on the bit lines via sense amplifiers. Writing drives the bit lines to the desired value before asserting the word line. SRAM retains data as long as power is supplied, with no refresh needed.

Why 6 Transistors?

The 6T cell strikes the right balance between area, speed, and stability. Simpler 4T cells save area at the cost of stability. Beefier 8T cells add a separate read port to dodge read-disturb issues, at the cost of area. The 6T cell wins in caches because it packs densely and reads fast. Register files are different: a single 6T cell has only one access port, and a register file needs several reads and a write in the same cycle, so it uses larger custom multi-ported cells (8T and up, growing with the port count).

SRAM vs DRAM Trade-offs

PropertySRAM (6T)DRAM (1T1C)
Transistors per bit61 transistor + 1 capacitor
SpeedVery fast (~1 ns)Slower (~50 ns)
DensityLow (large cell)High (small cell)
PowerNo refresh, but leaks constantly (a large share of power in big caches at modern nodes)Needs periodic refresh
Used forRegisters, L1/L2/L3 cacheMain memory (DDR)
Cost per bitHighLow

That trade-off is exactly why processors use a memory hierarchy — small, fast SRAM for registers and caches sitting next to the CPU, paired with large, dense DRAM holding main memory.

Register Files

A register file is an array of multi-ported SRAM-style cells organised so the CPU can read and write named registers inside a single clock cycle.

Organisation

A typical 32-register file for a 64-bit processor:

Most register files have:

  • 2 read ports: Allow reading two register values simultaneously (needed for instructions like ADD R1, R2, R3 that read two source operands)
  • 1 write port: Allow writing back a result
  • Decoder logic: Converts a register number (e.g., 5 bits for 32 registers) into a word line that selects the correct row

The decoder takes the register number as input and asserts exactly one word line, selecting that register's row of SRAM cells for reading or writing.

Multi-Ported Register Files

Superscalar processors that issue multiple instructions per cycle need more ports. A 6-wide superscalar might need 12 read ports and 6 write ports. Each additional port adds wires and transistors to every cell, increasing area and power significantly. This is why register file design is a critical constraint in wide superscalar CPUs.

Key Concept
Register Renaming Connection

Modern out-of-order CPUs use more physical registers than the ISA defines. The physical register file might have 192 entries for an ISA with 32 architectural registers. The rename stage maps architectural register names to physical registers, eliminating false dependencies (WAR and WAW hazards) while preserving true data flow.

Content-Addressable Memory (CAM)

While a register file is addressed by register number, some structures need content-addressable memory - memory that is searched by value rather than address. CAMs are essential in processor design:

  • TLB (Translation Lookaside Buffer): Searched by virtual page number, returns physical frame number
  • Branch Target Buffer: Searched by instruction address, returns predicted target
  • Instruction queue tags: Searched by producer tag to wake dependent instructions

A CAM cell extends the SRAM cell with comparison logic. On a lookup, the search key is broadcast to all entries simultaneously, and each entry compares the key against its stored value. Matching entries assert their match line. This parallel comparison makes CAMs fast (single-cycle lookup) but expensive in area and power.

From Memory Elements to Processor State

Every piece of state in a processor is built from these memory elements:

  • Architectural registers (general purpose, flags, PC): a register file of multi-ported SRAM-style cells
  • Pipeline registers (between stages): flip-flop banks
  • Reorder buffer entries: SRAM + CAM for tag matching
  • Cache tags and data: SRAM arrays with CAM-like tag comparison
  • TLB entries: fully associative CAM

Understanding how bits are physically stored connects the abstract register model (from ISA design) to the actual transistor-level hardware, and explains the area and power costs that constrain processor design choices.