---
title: SRAM arrays and register files
heading: The 6T cell, bitlines and sense amplifiers, array organization and multiported files
eyebrow: S3 · Lesson 13 · SRAM arrays and register files
xp: 50
---

::: hook
Most of a modern chip's area is SRAM: caches, register files, buffers and FIFOs. RTL describes a memory in two lines, but the memory compiler that builds it makes real design choices: how many rows share a bitline, how far each bitline swings before a sense amplifier decides, how to split the array into banks, and how many ports each cell can afford. Those choices set a memory's speed, energy and area, and knowing them explains why caches are banked, why register files are small, and why a memory's access time is quoted the way it is.
:::

::: play
- The lines are a bitline's voltage during a read: the selected cell's current discharges the precharged bitline's capacitance, which grows with the number of rows sharing it.
- The dashed line is 100 mV below the precharge level, where a sense amplifier can decide.
- Double the rows and the bitline takes about twice as long to get there: long bitlines are slow, which is why big arrays are split into subarrays.
:::

```sim plot
view: graph
x: t = 0..1.5 ns
y: V = 0.8..1.0 V
slider: n = 64..1024 step 64 = 256
slider: I = 10..40 = 20 µA
plot: 1 - I*1e-6*t*1e-9/((n*0.2 + 30)*1e-15) | label: bitline
plot: 0.9 + 0*t | dashed | label: sense threshold
readout: time to 100 mV (ns) = (n*0.2 + 30)*1e-15*0.1/(I*1e-6)*1e9 | digits: 3
```

::: predict
## A column of 256 SRAM cells loads its bitline with 0.2 fF per cell plus 30 fF of wire, and a cell sinks 20 µA. How long does a read take to develop 100 mV for the sense amplifier?

- [x] About 0.41 ns
- [ ] About 4 ps
- [ ] About 4 ns
- [ ] It depends only on the supply voltage

::: reveal
The bitline holds $256 \times 0.2 + 30 = 81$ fF. The cell discharges it at $I/C$, so 100 mV takes $81\text{ fF} \times 0.1\text{ V}/20\text{ µA} = 0.41$ ns. A full swing to ground would take ten times as long, which is why SRAMs sense small differences instead.
:::
:::

::: nameit
## The 6T cell

Two cross-coupled inverters hold a bit; two access transistors connect it to a complementary pair of bitlines when the wordline rises. A cell takes about 120 to 150 $F^2$ for a feature size F: around 0.12 µm² at 28 nm.

## Reading

Both bitlines are precharged high. The wordline turns on, and the cell's side holding 0 pulls its bitline down slowly, since the cell transistors are tiny. A **sense amplifier** fires once the difference reaches about 50 to 100 mV:
$$t_\text{read} \approx \frac{C_\text{bl}\Delta V}{I_\text{cell}}, \qquad C_\text{bl} = nc_\text{cell} + C_\text{wire}$$
Each read costs about $mC_\text{bl}\Delta V\,V_{DD}$ for the m columns whose bitlines swing, while a write drives its columns rail to rail, $C_\text{bl}V_{DD}^2$ each.

## Organization

A memory of S bits is built from subarrays of R rows by C columns: shorter bitlines (fewer rows) are faster and cheaper per access, shorter wordlines (fewer columns) are faster to drive. A **column multiplexer** selects W of the C columns for each word, so the address splits into bank, row and column bits.

## Multiported register files

Each extra port adds a wordline and a pair of bitlines through every cell, so a cell's width and height each grow by about one track per port, and the area grows roughly as the square of the port count:
$$A \propto (a + p)(b + p)$$
That's why register files with many ports (a wide superscalar core's 12 or more) are small and are sometimes duplicated rather than given more ports.
:::

::: example
## A 32 KB array is built from 256 × 256-bit subarrays and read as 64-bit words. How many subarrays are there, and how are the 12 word-address bits used?

::: solution
1. **Subarrays.** 32 KB is 262 144 bits, and each subarray holds $256 \times 256 = 65\,536$:
   $$\frac{262\,144}{65\,536} = 4\ \text{subarrays}$$
2. **Words per row.** Each row holds 256 bits, four 64-bit words, so a 4-to-1 column multiplexer picks one.
3. **Address bits.** The 4096 words need 12 address bits: 2 to choose the subarray, 8 for the row and 2 for the column multiplexer.

**Answer:** 4 subarrays; the 12 bits split into 2 for the subarray, 8 for the row and 2 for the column.
:::
:::

::: example
## How much area do the cells of 1 Mb of SRAM take at 28 nm, at 150 F² per cell?

::: solution
1. **One cell.**
   $$\begin{aligned} A &= 150 \times (0.028\text{ µm})^2 \\ &= 0.118\ \text{µm}^2 \end{aligned}$$
2. **One megabit.** $2^{20}$ cells take 0.123 mm².
3. **The whole macro.** Decoders, sense amplifiers and redundancy add 20 to 40%, so real macros reach about 0.15 to 0.17 mm² per megabit at that node.

**Answer:** the cells take 0.123 mm², and a full macro about 0.15 to 0.17 mm².
:::
:::

::: example
## A register file cell with 2 read ports and 1 write port is replaced by one with 8 read and 4 write ports. If the area goes as the square of the port count, how much bigger is each cell?

::: solution
1. **Port counts.** From 2 + 1 = 3 ports to 8 + 4 = 12.
2. **Area ratio.**
   $$\left(\frac{12}{3}\right)^2 = 16$$
   times the area per bit, with slower bitlines too, since each is longer and more heavily loaded.
3. **What wide cores do.** They split the register file into clusters or duplicate it, each copy needing only some of the read ports.

**Answer:** each cell is 16 times bigger.
:::
:::

::: check
kind: parts
given: F = 7 | 16 | 28 | 65; a = 120 | 150 | 200; M = 1 | 8 | 64

## An SRAM cell takes {a} F² at a {F} nm feature size, and a block holds {M} Mb.

::: part
answer: a*(F/1000)^2
unit: µm²
tolerance: 0.5%

### How big is each cell?

::: misses
- [any] $aF^2$, with F in micrometers.
:::
:::

::: part
answer: a*(F/1000)^2*M*1048576/1e6
unit: mm²
tolerance: 0.5%

### How much area do the block's cells take?

::: misses
- [any] Cell area × $2^{20}$ × M.
:::
:::
:::

::: check
kind: parts
given: n = 128 | 256 | 512; c = 0.1 | 0.2; w = 20 | 50; I = 10 | 30; v = 50 | 100

## A bitline serves {n} cells of {c} fF each plus {w} fF of wire; a cell sinks {I} µA, and the sense amplifier needs {v} mV.

::: part
answer: n*c + w
unit: fF
tolerance: 0.5%

### What is the bitline's capacitance?

::: misses
- [any] $nc_\text{cell} + C_\text{wire}$.
:::
:::

::: part
answer: (n*c + w)*1e-15*v*1e-3/(I*1e-6)*1e9
unit: ns
tolerance: 0.5%

### How long does a read take to develop that difference?

::: misses
- [any] $C\Delta V/I$.
:::
:::
:::

::: check
kind: parts
given: S = 8 | 32 | 128; R = 128 | 256; C = 128 | 256; W = 32 | 64

## An {S} KB SRAM is built from {R} × {C}-bit subarrays and read in {W}-bit words.

::: part
answer: S*8192/(R*C)
tolerance: 0

### How many subarrays does it need?

::: misses
- [any] Total bits over bits per subarray.
:::
:::

::: part
answer: C/W
tolerance: 0

### How wide a column multiplexer does each row need?

::: misses
- [any] Columns per row over word width.
:::
:::

::: part
answer: round(log(S*8192/W)/log(2))
unit: bits
tolerance: 0

### How many word-address bits are there?

::: misses
- [round(log(S*1024)/log(2))] That's a byte address; count words.
- [any] $\log_2$ of the number of words.
:::
:::
:::

::: check
kind: parts
given: m = 64 | 256; C = 50 | 100; v = 0.05 | 0.1; V = 0.8 | 1

## A read swings {m} bitlines of {C} fF each by {v} V from a {V} V supply; a write drives 64 bitlines rail to rail.

::: part
answer: m*C*1e-15*v*V*1e12
unit: pJ
tolerance: 0.5%

### About how much energy does a read take?

::: misses
- [any] $mC\Delta V\,V_{DD}$.
:::
:::

::: part
answer: 64*C*1e-15*V^2*1e12
unit: pJ
tolerance: 0.5%

### And a write?

::: misses
- [any] $64CV_{DD}^2$.
:::
:::
:::

::: check
kind: choice

## Why are large SRAMs split into many small subarrays rather than built as one tall, wide array?

- [ ] Small arrays leak less per bit
- [x] Shorter bitlines and wordlines have less capacitance, so each access is faster and swings less charge; only the addressed subarray needs to be activated
- [ ] One big array can't be addressed in binary
- [ ] Subarrays don't need sense amplifiers

::: misses
- [1] Leakage per cell is the same; it's access time and energy that scale with line length.
- [3] Any size can be addressed; the problem is the lines' capacitance.
- [4] Every subarray needs its own sense amplifiers: that's the area cost of splitting.
:::
:::

::: check
kind: derivation
vars: a = 2..10, b = 2..10, p = 1..20, q = 1..20

## A register-file cell is a tracks wide and b tracks tall before ports are added, and each port adds one track in each direction.

::: step
answer: (a + p)*(b + p)

### What is the area, in square tracks, with p ports?
:::

::: step
answer: (a + q)*(b + q)/((a + p)*(b + p))

### By what factor does it grow going from p to q ports?
:::

::: right
Right. Once the ports dominate the cell, the area goes as the square of their number.
:::
:::

::: check
kind: python

## Write `read_time(rows, c_cell, c_wire, i_cell, dv)` (all in SI units) and `best_banks(total_rows, c_cell, c_wire, i_cell, dv, t_level)`: splitting the rows into B banks (B a power of two from 1 to 64) shortens each bitline to total_rows/B rows but adds $t_\text{level}\log_2B$ of bank multiplexing; return the B with the least total time.

```python starter
def read_time(rows, c_cell, c_wire, i_cell, dv):
    return 0.0

def best_banks(total_rows, c_cell, c_wire, i_cell, dv, t_level):
    return 1
```

```python solution
import math

def read_time(rows, c_cell, c_wire, i_cell, dv):
    return (rows * c_cell + c_wire) * dv / i_cell

def best_banks(total_rows, c_cell, c_wire, i_cell, dv, t_level):
    best, best_t = 1, None
    for k in range(7):
        b = 1 << k
        t = read_time(total_rows / b, c_cell, c_wire, i_cell, dv) + t_level * k
        if best_t is None or t < best_t:
            best, best_t = b, t
    return best
```

```python tests
assert abs(read_time(256, 0.2e-15, 30e-15, 20e-6, 0.1) - 0.406e-9) < 1e-12, "The predict: 0.41 ns."
assert best_banks(4096, 0.2e-15, 30e-15, 20e-6, 0.1, 200e-12) == 16, "4096 rows with 200 ps per mux level: 16 banks."
assert best_banks(256, 0.2e-15, 30e-15, 20e-6, 0.1, 200e-12) == 1, "Short bitlines and slow muxes: don't split."
```

::: right
Right. Banking trades bitline delay, which falls as 1/B, against multiplexing delay, which grows as $\log_2B$.
:::
:::

::: explain
## Why does an SRAM read sense a small bitline difference instead of waiting for a full logic swing?

::: model
The cell's transistors are made as small as possible to pack bits densely, so the current a cell can sink is tiny, while the bitline it discharges is long and connects to hundreds of cells, so its capacitance is large. Discharging it all the way would take many nanoseconds. A sense amplifier, a regenerative latch like a comparator's, can tell which of the two bitlines is lower once they differ by 50 to 100 mV, so the read finishes in a tenth of the time. It also saves energy, since the bitlines only swing a little before being precharged again.
:::
:::

::: practice
::: check
given: n = 200 | 400; c = 0.15 | 0.25; I = 15 | 25
answer: (n*c + 40)*1e-15*0.1/(I*1e-6)*1e9
unit: ns
tolerance: 0.5%

## Time to 100 mV: {n} cells of {c} fF plus 40 fF wire, {I} µA?

::: misses
- [any] $C\Delta V/I$.
:::
:::

::: check
given: F = 10 | 22; a = 130 | 180
answer: a*(F/1000)^2
unit: µm²
tolerance: 0.5%

## Cell area at {a} F², F = {F} nm?

::: misses
- [any] $aF^2$.
:::
:::

::: check
given: p = 3 | 6; q = 9 | 15
answer: (q/p)^2
tolerance: 0.5%

## Area ratio going from {p} to {q} ports, area ∝ ports²?

::: misses
- [any] $(q/p)^2$.
:::
:::
:::
