Memory characteristics, access methods, SRAM vs DRAM, the complete ROM family โ mask ROM, PROM, EPROM, EEPROM, Flash โ and the memory hierarchy from registers to magnetic disk. How cache fits into the picture and why it exists.
A computer’s memory system is not a single uniform thing โ it is a carefully engineered hierarchy of different storage technologies, each making different trade-offs between speed, capacity, cost, and persistence. Understanding these trade-offs is fundamental to understanding why computers are designed the way they are.
Every memory system can be characterised along six dimensions:
| Characteristic | Options |
|---|---|
| Location | CPU internal (registers), internal/main (RAM, ROM, cache), external/secondary (disk, tape, optical) |
| Capacity | Word size (natural unit of the CPU), number of addressable words or bytes |
| Unit of Transfer | Word (for main memory), block (for secondary storage โ e.g. 512-byte disk sector or 64-byte cache line) |
| Access Method | Sequential, direct, random, associative โ see Section S3 |
| Performance | Access time, cycle time, transfer rate |
| Physical Type | Semiconductor (SRAM, DRAM, Flash), magnetic surface (HDD, tape), optical (CD, DVD, Blu-ray) |
| Physical Characteristics | Volatile/non-volatile, erasable/non-erasable |
Given: A CPU has a 24-bit address bus and 8-bit (byte) addressable memory.
Addressable locations: 2ยฒโด = 16,777,216 = 16 MB
Given: A 16 Mbit DRAM chip, organised as 1M ร 16-bit words.
Chip capacity: 1,048,576 locations ร 16 bits = 16,777,216 bits = 16 Mbits โ
Address pins needed: logโ(1,048,576) = 20 address pins. DRAM uses row/column multiplexing โ 10 multiplexed pins select row, same 10 pins reused to select column: 2ยนโฐ ร 2ยนโฐ = 1M locations.
The most fundamental distinction between memory types is how data is accessed โ how the hardware reaches a specific stored value:
Four memory access methods. Sequential (tape) and direct (disk) have variable access times. Random access (DRAM, SRAM) achieves constant access time โ any address is reached in the same time. Associative access (CAM) compares a tag against all stored values simultaneously โ used in cache tag arrays and TLBs.
| Parameter | Definition | Applies to | Typical values |
|---|---|---|---|
| Access Time | Time from address presented to data available (RAM) โ or time to position read/write head (non-RAM) | All memory types | Registers: <1 ns ยท L1 cache: 1โ4 ns ยท DRAM: 50โ100 ns ยท SSD: 50โ100 ยตs ยท HDD: 5โ15 ms |
| Cycle Time | Access time + recovery time before next access can begin. For DRAM: includes precharge and refresh overhead. | Primarily random-access memory | DRAM cycle time โ 2ร access time due to destructive read + restore |
| Transfer Rate | Rate at which data moves in or out. For RAM: 1/Cycle Time. For non-RAM: TN = TA + N/R where N=bits, R=bit rate | All memory types | DDR5-6400: ~51 GB/s ยท SATA SSD: ~500 MB/s ยท HDD: ~200 MB/s |
| Property | Volatile | Non-Volatile |
|---|---|---|
| Definition | Information is lost when power is removed | Information persists without power |
| Semiconductor examples | SRAM, DRAM | ROM, PROM, EPROM, EEPROM, Flash, FeRAM |
| Other technology examples | โ | Magnetic tape, HDD, optical disc |
| Typical use | Working memory (programs, data during execution) | Storage (firmware, OS, files, configuration) |
| Property | Erasable | Non-Erasable |
|---|---|---|
| Definition | Contents can be modified after manufacture | Contents are fixed at manufacture โ cannot be changed |
| Examples | SRAM, DRAM, EEPROM, Flash | Mask ROM (traditional) |
| Implication | Software can be updated, bugs fixed in field | Any change requires replacing the chip |
Despite the name, RAM (Random Access Memory) is used specifically to mean read-write, volatile semiconductor memory. Two types exist:
SRAM cell (left): 6 transistors forming two cross-coupled inverters. Bistable โ holds state indefinitely without refresh. BL and BLฬ are complementary bit lines; Word Line (WL) activates the access transistors for read/write. DRAM cell (right): 1 transistor + 1 capacitor. Charge on the capacitor represents the bit. Leakage requires periodic refresh. Read is destructive โ charge must be restored after sensing.
| Feature | SRAM | DRAM |
|---|---|---|
| Storage element | Flip-flop (cross-coupled inverters) | Capacitor + access transistor |
| Transistors per bit | 6 | 1 (+ 1 capacitor) |
| Refresh required? | No | Yes โ every ~64 ms |
| Read destructive? | No | Yes โ capacitor partially drained |
| Access time | 1โ10 ns (faster) | 50โ100 ns (slower) |
| Density | Low (large cell) | High (small cell) |
| Cost per bit | High | Low |
| Power | Low (static dissipation) | Higher (refresh + switching) |
| Primary use | Cache (L1/L2/L3), register files | Main memory (GB-scale) |
ROM (Read-Only Memory) is non-volatile semiconductor memory. The term covers a family of technologies ranging from mask-programmed (at manufacture) to electrically rewritable:
ROM family tree. All four types are non-volatile. Mask ROM is cheapest for high-volume but cannot be changed. PROM can be programmed once by the user. EPROM can be erased by UV light and reprogrammed. EEPROM/Flash can be erased and reprogrammed electrically, in-system โ enabling firmware updates without removing the chip.
| Type | Category | Programmed by | Erase method | Volatile? |
|---|---|---|---|---|
| RAM | Read-write | CPU (byte-level, in-system) | Electrically (byte-level) | Yes |
| Mask ROM | Read-only | Photolithography masks at fab | Not possible | No |
| PROM | Read-only after programming | PROM programmer (one time) | Not possible (fuse) | No |
| EPROM | Read-mostly | PROM programmer, multiple times | UV light (~20 min, whole chip) | No |
| Flash | Read-mostly | CPU / programmer (block-level) | Electrically (block/sector) | No |
| EEPROM | Read-mostly | CPU / programmer (byte-level) | Electrically (byte-level) | No |
Basic DRAM is asynchronous. Modern systems use Synchronous DRAM (SDRAM), which synchronises all operations to the system clock, enabling predictable timing and burst transfers:
| DRAM type | Key advancement | Transfer rate |
|---|---|---|
| Basic DRAM | Asynchronous; CPU stalls waiting for data; no burst mode | ~100 MB/s |
| SDRAM | Synchronised to system clock; CPU knows when data arrives; burst mode | ~800 MB/s (PC100) |
| DDR SDRAM | Double Data Rate โ transfers on both rising and falling clock edges | ~1.6 GB/s (DDR-200) |
| DDR4 | Lower voltage (1.2V), higher density, higher frequency | ~17โ25 GB/s |
| DDR5 | 64-bit channel split into two 32-bit sub-channels; on-die ECC; 1.1V | ~25โ51 GB/s |
No single memory technology satisfies all requirements simultaneously. The solution is a memory hierarchy โ multiple levels of storage, each faster but smaller and more expensive than the level below:
Memory hierarchy pyramid. Speed decreases and capacity increases from top to bottom. The cache hierarchy bridges the gap โ SRAM caches hold recently used data, so most accesses hit cache (fast) rather than going to DRAM (slow). A typical L1 cache hit rate is 90โ99%.
Cache line fetches exploit spatial locality by fetching 64 bytes at once even though only 4 bytes were requested โ the adjacent bytes will likely be needed next.
Memory errors occur in two forms:
Principle: Hamming distance = number of bit positions where two codewords differ. To detect d errors, need Hamming distance โฅ d+1. To correct d errors, need distance โฅ 2d+1.
For SECDED (Single-Error Correction, Double-Error Detection): Need Hamming distance = 4. For 64 data bits, SECDED requires 8 check bits (72 bits total stored). DDR5 uses this exact scheme.
Check bit positions: Check bits occupy positions that are powers of 2 (1, 2, 4, 8, 16, 32, 64โฆ). On a mismatch, the syndrome (XOR of failing check bits) gives the exact position of the erroneous bit, enabling correction.
Every SoC contains dozens to hundreds of SRAM macros โ register files, L1 instruction and data caches, L2 caches, shared L3 cache, TLB arrays, FIFO buffers, scratchpad memories. SRAM macros are generated by memory compilers (ARM SRAM Compiler, Faraday Memory, TSMC SRAM) that take capacity, word width, and read/write ports as inputs and produce verified GDS2, LEF, timing characterisation (.lib), and simulation models. During physical design, SRAM macros are hard IP blocks โ their internal layout is fixed, and your job is to place them, manage power straps, and close timing on their input/output ports.
Embedded microcontrollers (ARM Cortex-M series) integrate NOR Flash directly on-die for program storage. NOR Flash allows random-access reads at byte granularity โ the CPU can execute code directly from NOR Flash (XIP โ execute-in-place) without copying to RAM first. NAND Flash (the technology in SSDs and USB drives) only supports page-level random access reads and must be copied to RAM before execution, but achieves 10โ100ร higher density than NOR. When you do SoC integration on a Cortex-M design, you will connect the embedded NOR Flash macro to the instruction bus and the DRAM or SRAM to the data bus โ a modified Harvard architecture in hardware.
Every SRAM macro in a safety-critical SoC (automotive ASIL-D, avionics DO-254 Level A) must have ECC. The synthesised ECC logic (Hamming encoder on write, decoder + corrector on read) adds area โ typically 12.5% overhead (8 ECC bits per 64 data bits). Automotive SoC designs for ASIL-D go further: SRAM is either implemented with ECC or with lockstep redundancy (two copies of the compute hardware running in parallel, outputs compared every cycle). ISO 26262 mandates ECC or lockstep for safety integrity.