Memory, Storage & Peripherals
Memory and Storage Devices
Memory and storage form a hierarchy from CPU registers to tape. Speed and cost per bit rise as capacity falls, so cache and virtual memory keep active data close to the processor. SRAM and DRAM serve cache and main memory; ROM and flash hold firmware and files; magnetic, optical and solid-state media provide nonvolatile secondary storage. Peripherals connect through interfaces whose bandwidth must match the device.
Memory hierarchy
Levels closer to the CPU are faster, smaller and more expensive per bit. Levels farther away are slower, larger and cheaper per bit.
- Registers: fastest and smallest level, inside the CPU, holding operands and addresses.
- Cache (L1, L2, L3): SRAM buffer for recently used blocks, sized from kilobytes to megabytes.
- Main memory: DRAM holding active programs and data, typically 8-64 GB.
- SSD: nonvolatile NAND flash storage, typically 256 GB-4 TB.
- HDD: magnetic disks with terabyte capacity and millisecond access.
- Tape: lowest cost per byte, sequential access, used for archives and backups.
| Level | Typical size | Typical latency | Relative cost per bit | Volatile? |
|---|---|---|---|---|
| Registers | Under 1 KB | Under 1 ns | Highest | Yes |
| L1/L2/L3 cache | 32 KB-32 MB | 1-15 ns | Very high | Yes |
| Main memory (DRAM) | 8-64 GB | 60-100 ns | Moderate | Yes |
| SSD (NAND flash) | 256 GB-4 TB | 0.05-0.1 ms | Low | No |
| Hard disk | 1-20 TB | 5-10 ms | Very low | No |
| Magnetic tape | Many TB | Seconds-minutes | Lowest | No |
SRAM and DRAM
Both are volatile random-access memories, but they store a bit differently. SRAM uses flip-flops; DRAM uses capacitors.
- SRAM stores a bit in a flip-flop made from about six transistors.
- SRAM needs no refresh and is fast, but each cell is large and costly.
- SRAM is used for CPU cache, not for main memory.
- DRAM stores a bit as charge on a capacitor with one transistor.
- DRAM capacitors leak, so rows are refreshed every 64 ms in a typical chip.
- DRAM is denser and cheaper per bit than SRAM, but slower and refresh-dependent.
- Both SRAM and DRAM lose their contents when power is removed.
ROM family
ROM is nonvolatile and retains its contents without power. The family differs in how it is written and erased.
- Mask ROM is programmed during manufacture and cannot be changed.
- PROM is blank when sold and written once by blowing fuses in a programmer.
- EPROM is erased by ultraviolet light through a quartz window, typically for 15-30 minutes.
- EEPROM is erased and rewritten electrically, byte by byte.
- Flash is EEPROM-based and erases in blocks; it is used in SSDs, USB drives and phones.
- ROM commonly holds firmware such as the boot program.
| Property | RAM | ROM |
|---|---|---|
| Volatility | Volatile; loses data on power loss | Nonvolatile; keeps data without power |
| Writes | Read and written during normal operation | Written once or infrequently |
| Typical use | Main memory and cache | Firmware and boot code |
| Examples | SRAM, DRAM | Mask ROM, PROM, EPROM, EEPROM, flash |
Cache and virtual memory
Cache exploits locality by keeping recent blocks close to the CPU. Virtual memory maps each program to physical frames and can spill pages to storage.
- A cache line is typically 64 bytes; a tag identifies which memory block it holds.
- A cache hit returns data in a few cycles; a miss forwards the request to RAM.
- Temporal locality reuses recent data; spatial locality uses nearby addresses.
- L1 is smallest and fastest, L2 is larger, and L3 is largest and often shared.
- Virtual memory divides a logical address space into pages, commonly 4 KiB.
- The MMU translates pages to physical frames through a page table; the TLB caches recent translations.
- A page fault loads a missing page from storage; excessive paging is thrashing.
Average access time = h x t_hit + (1 - h) x t_miss
h = hit rate, t_hit = hit time, t_miss = miss penaltyMagnetic, optical and solid-state storage
Secondary storage is nonvolatile and much larger than main memory. Magnetic, optical and solid-state media use different recording mechanisms.
- Magnetic HDD: platters spin at 5,400 or 7,200 rpm and a read/write head seeks tracks.
- HDD average seek time is about 9 ms; sustained transfer is roughly 100-200 MB/s.
- Magnetic tape is sequential, cheap and dense, so it is used for backup and archives.
- Optical: a laser reads pits; CD holds about 700 MB, DVD 4.7 GB per layer and Blu-ray 25 GB per layer.
- Optical media are cheap and portable but slow to write and increasingly uncommon.
- NAND flash SSD has no moving parts; NVMe reads several GB/s with latency under 0.1 ms.
- Flash endurance is finite: cells wear out after a limited number of erase cycles.
| Property | Magnetic (HDD/tape) | Optical (CD/DVD/Blu-ray) | Solid-state (SSD) |
|---|---|---|---|
| Mechanism | Magnetised regions on platters or tape | Laser reads pits and lands | Charge stored in NAND flash cells |
| Typical capacity | 1-20 TB HDD; many TB tape | 700 MB CD; 4.7 GB DVD; 25 GB Blu-ray | 256 GB-4 TB |
| Latency | About 5-10 ms HDD; seconds for tape | Tens of milliseconds | Under 0.1 ms |
| Cost per TB | Low | Low | Highest |
| Best use | Bulk storage and backup | Media and archival copies | Operating systems and random I/O |
Peripherals and interfaces
Peripherals provide input, output or storage. The interface must supply enough bandwidth for the device.
- Input peripherals: keyboard, mouse, scanner, webcam, microphone and sensor.
- Output peripherals: monitor, printer, speaker and actuator; a touchscreen is both input and output.
- Storage peripherals: external HDD, SSD and tape drive.
- USB 2.0 carries up to 480 Mb/s; USB 3.2 exceeds 5 Gb/s, where Mb/s and Gb/s are megabits and gigabits per second.
- HDMI carries digital video and audio; SATA and NVMe connect storage devices.
- A slow interface bottlenecks a fast device, so match port bandwidth to device bandwidth.
Exam points
- Hierarchy order by speed is registers, cache, DRAM, SSD, HDD, tape; cost per bit falls in the same order.
- SRAM uses flip-flops, needs no refresh and serves as cache; DRAM uses capacitors, needs refresh and serves as main memory.
- SRAM and DRAM are volatile; ROM, flash, magnetic and optical storage are nonvolatile.
- PROM is one-time programmable, EPROM is UV-erasable, and EEPROM or flash is electrically erasable.
- Cache exploits locality; virtual memory maps pages to frames and uses a TLB, with page faults served from storage.
- HDDs are magnetic and mechanical, optical discs use a laser, and SSDs use NAND flash with latency under 0.1 ms.
Key terms
- Memory hierarchy
- The ordered levels of storage from registers and cache to RAM, SSD, disk and tape, arranged by speed, capacity and cost per bit.
- Virtual memory
- A scheme that gives each program a logical address space mapped to physical frames, allowing programs larger than available RAM.
- Cache hit
- A memory access whose requested block is already present in cache, avoiding an access to the next lower level.
Check yourself
Quick check
Which memory is volatile and needs periodic refresh?
A cache has a 0.9 hit rate, 1 ns hit time and 100 ns miss penalty. What is the average access time?