8. Memory Devices
Learning Objectives
- Distinguish volatile memory (RAM) from non-volatile memory (ROM and its variants)
- Explain the difference between SRAM and DRAM at a circuit level
- Describe how an address bus and data bus together access a specific memory location
- Explain the memory hierarchy and why it trades speed against capacity
- Identify ROM, PROM, EPROM, EEPROM, and flash memory and how they differ
- Apply memory concepts to explain why a computer needs both RAM and secondary storage
Quick Answer
A memory device is a digital circuit that stores binary data so it can be written and later read back. Memory splits into two broad families: volatile memory (like RAM), which loses its contents the instant power is removed, and non-volatile memory (like ROM and flash), which retains data without power. Memory devices matter because every computation needs somewhere to hold data and instructions — a CPU without memory has nothing to compute on, and the specific type of memory chosen (fast-but-volatile vs. slow-but-permanent) shapes the entire architecture of a computer system, known as the memory hierarchy.
How Memory Devices Work
Every memory device organizes storage into addressable locations: each location holds a fixed number of bits (commonly 8, called a byte), and each location has a unique binary address. To read or write, a circuit places an address on the address bus, and data flows across the data bus to or from that exact location — this addressing scheme is what lets random access memory jump straight to any location instead of having to scan through everything sequentially.
RAM (Random Access Memory) — Volatile
RAM is called "random access" because any memory location can be reached directly and in the same amount of time, regardless of its address — unlike, say, a tape drive that must wind through earlier data first.
SRAM (Static RAM): Stores each bit using a flip-flop-like circuit (typically six transistors). It holds data as long as power is supplied, with no need to refresh. SRAM is fast and simple to interface but takes more silicon area per bit, so it is expensive and used mainly for CPU cache, where speed matters more than capacity.
DRAM (Dynamic RAM): Stores each bit as a charge on a tiny capacitor (one transistor and one capacitor per bit). It is much denser and cheaper per bit than SRAM, but the capacitor's charge leaks away within milliseconds, so DRAM must be continuously "refreshed" (read and rewritten) thousands of times per second to retain data. DRAM is used for a computer's main system memory because its low cost per bit allows much larger capacities.
ROM (Read-Only Memory) — Non-Volatile
ROM retains its contents without power, making it ideal for storing data or code that must survive a power cycle, like a device's startup firmware.
| ROM Type | Can it be rewritten? | How |
|---|---|---|
| ROM (mask) | No | Data is fixed permanently during manufacturing |
| PROM | Once | Programmed once by the user, then permanently fixed |
| EPROM | Yes, but slowly | Erased with ultraviolet light, then reprogrammed electrically |
| EEPROM | Yes, electrically | Erased and rewritten in-circuit using electrical signals |
| Flash memory | Yes, electrically, in blocks | An evolution of EEPROM erased/written in larger blocks for speed and density |
Why it matters: Flash memory's block-based erase/write is exactly why USB drives, SSDs, and smartphone storage use it — it gives non-volatile storage with reasonably fast read/write speeds and no moving parts, at the cost of a limited number of erase cycles before a memory cell wears out.
Memory Hierarchy
No single memory technology is simultaneously fast, cheap, and large, so real systems layer several types together:
- Registers (inside the CPU) — fastest, smallest capacity, most expensive per bit
- Cache (SRAM) — very fast, small capacity
- Main memory (DRAM) — moderate speed, moderate capacity
- Secondary storage (SSD/HDD, flash) — slower, but very large capacity and non-volatile
Frequently used data is kept in the faster levels closer to the CPU, while bulk, less time-critical data lives in slower, cheaper, larger storage — this layering is what lets a computer feel fast while still affording large storage capacity.
Real-World Example
When you power on a computer, the CPU's very first instructions come from ROM or flash-based firmware (the BIOS/UEFI), because DRAM starts out empty and requires initialization code to even begin working. That firmware then sets up and tests the DRAM, loads the operating system from secondary storage into DRAM, and only then does normal execution using fast RAM begin — a sequence that only works because ROM is non-volatile and RAM is not.
Common Misunderstanding
Students often assume "ROM" literally means data can never be changed under any circumstances. While that's true of classic mask ROM, EEPROM and flash memory — both descendants of ROM technology — absolutely can be rewritten electrically, just more slowly and with more limitations (like block erasure and limited write cycles) than RAM.
Key Terms
| Term | Definition | Related Concept |
|---|---|---|
| Volatile memory | Memory that loses data when power is removed | RAM |
| Non-volatile memory | Memory that retains data without power | ROM, flash |
| SRAM | Static RAM; stores bits in flip-flop-like cells, fast, no refresh needed | CPU cache |
| DRAM | Dynamic RAM; stores bits as capacitor charge, needs periodic refresh | Main memory |
| Address bus | The set of wires that specifies which memory location to access | Random access |
| Data bus | The set of wires that carries the actual data being read or written | Memory transfer |
| Memory hierarchy | The layered arrangement of memory types by speed, cost, and capacity | Registers, cache, RAM, storage |
| Flash memory | Non-volatile, electrically rewritable memory erased in blocks | SSDs, USB drives |
Common Mistakes
Misconception: "RAM" and "memory" are the same as a computer's storage drive. Why it's wrong: RAM is volatile working memory that is cleared when powered off, while a storage drive (SSD/HDD) is non-volatile and keeps files permanently — confusing the two leads to the mistaken belief that turning off a computer deletes your saved files. Correct understanding: RAM temporarily holds data and running programs for fast CPU access; secondary storage permanently holds files and only loads what's needed into RAM while in use.
Misconception: DRAM must be slower than SRAM because it needs refreshing. Why it's wrong: Refreshing does add overhead, but DRAM's real disadvantage is latency per access, not raw throughput — its much lower cost per bit is precisely why it's chosen for large-capacity main memory, despite the refresh requirement. Correct understanding: SRAM is faster and used for small, latency-critical storage like CPU cache; DRAM trades some speed for dramatically higher density and lower cost, which is why it is used for bulk main memory.
Misconception: ROM can never be updated once manufactured, so all ROM-based storage is permanently fixed. Why it's wrong: Only classic mask ROM is truly fixed at manufacture; EPROM, EEPROM, and flash memory are all ROM-family technologies specifically designed to be erased and reprogrammed later. Correct understanding: Treat "ROM" as a family describing non-volatile, typically slower-to-write memory, not a guarantee of permanent unchangeable content — check the specific subtype to know if and how it can be rewritten.
Comparison and Connections
| Memory Type | Volatile? | Speed | Cost per Bit | Typical Use |
|---|---|---|---|---|
| SRAM | Yes | Very fast | High | CPU cache |
| DRAM | Yes | Fast | Moderate | Main system memory |
| Mask ROM | No | Fast read, unwritable | Low | Fixed firmware, mass production |
| EEPROM / Flash | No | Fast read, slower write | Low-moderate | Firmware updates, SSDs, USB drives |
Practice Questions
Recall
-
What is the key difference between volatile and non-volatile memory? Volatile memory loses its stored data when power is removed; non-volatile memory retains data without power.
-
Why does DRAM need to be refreshed periodically? Because each bit is stored as a charge on a tiny capacitor that leaks away over time, so the data must be read and rewritten regularly to prevent it from being lost.
Understanding
-
Explain why SRAM is used for CPU cache instead of DRAM, despite DRAM being cheaper. SRAM is significantly faster because it uses flip-flop-like transistor cells with no refresh delay, matching the CPU's high speed needs, while DRAM's refresh cycles and capacitor-based storage introduce latency that would slow down cache access — the small size of cache makes SRAM's higher cost per bit affordable.
-
Why does a computer need both RAM and a permanent storage device instead of just one type of memory? RAM offers the speed needed for active computation but loses data without power, while storage devices are non-volatile but too slow for direct CPU execution — using both lets the system combine fast temporary working memory with permanent, larger-capacity file storage.
Application
-
A microcontroller's firmware needs to be updated occasionally in the field without physically removing the chip. Which type of memory should store the firmware? EEPROM or flash memory, since both can be erased and rewritten electrically in-circuit, unlike mask ROM or EPROM (which requires UV light and removal from the circuit).
-
A CPU cache designer needs sub-nanosecond access time and can accept a small capacity. Which memory technology should be chosen, and why? SRAM, because its flip-flop-based cells respond faster than DRAM's capacitor-based cells and require no refresh cycles, at the acceptable cost of lower density for the relatively small cache size needed.
Analysis
-
A student argues that since flash memory is non-volatile like ROM, it must be exactly as slow to write as classic EEPROM. Evaluate this claim. The claim oversimplifies — flash memory is indeed a descendant of EEPROM, but it improves on EEPROM's per-byte erase/write process by erasing and writing in larger blocks, which increases both speed and storage density, even though writes are still slower than reads and slower than RAM.
-
Compare the trade-offs of placing frequently accessed data closer to the CPU (in cache/registers) versus in main memory, from the perspective of the memory hierarchy. Data closer to the CPU (registers, then cache) is accessed with much lower latency but at higher cost per bit and smaller total capacity, while main memory offers much larger capacity at greater latency and lower cost per bit — the memory hierarchy exploits the fact that most programs repeatedly access a small set of data, so keeping that "hot" data in fast, small memory improves overall system performance without needing all memory to be equally fast and expensive.
FAQ
Why is RAM called "random access" specifically? Because any address can be reached directly, in roughly the same access time, regardless of where it is physically located in the memory array — this contrasts with sequential-access media like magnetic tape, where reaching a distant location takes proportionally longer.
Is flash memory the same as RAM? No. Flash memory is non-volatile (it keeps data without power) and is used for storage like SSDs and USB drives. RAM is volatile working memory used while a program is actively running. They serve fundamentally different roles even though both are semiconductor memory.
Why does DRAM need more transistors than one might expect, yet still ends up denser than SRAM? Each DRAM bit actually needs only one transistor plus one capacitor, versus roughly six transistors for one SRAM bit, so DRAM cells are physically smaller and pack far more bits into the same silicon area, even though the capacitor requires periodic refreshing.
What replaced EPROM in most modern designs? EEPROM and flash memory largely replaced EPROM, because they can be erased and reprogrammed electrically, in-circuit, without needing to expose the chip to ultraviolet light or remove it from the board — a major convenience for field updates and manufacturing.
Why do computers still need secondary storage if RAM exists? Because RAM is volatile and relatively expensive per bit at large capacities — secondary storage (SSD/HDD/flash) provides the large, permanent capacity needed to keep files and programs available across power cycles, at a fraction of RAM's cost per gigabyte.
Quick Revision
- Volatile memory (RAM) loses data without power; non-volatile memory (ROM, flash) retains it
- SRAM: flip-flop-based, fast, no refresh, used for CPU cache
- DRAM: capacitor-based, denser and cheaper, needs periodic refresh, used for main memory
- ROM family: mask ROM (fixed), PROM (write once), EPROM (UV erase), EEPROM/flash (electrically erasable)
- Address bus selects the memory location; data bus carries the value read or written
- Memory hierarchy: registers > cache (SRAM) > main memory (DRAM) > secondary storage (flash/SSD/HDD)
- Faster memory levels are smaller and more expensive per bit; slower levels are larger and cheaper
- Flash memory erases/writes in blocks, balancing speed, density, and non-volatility
Related Topics
Prerequisites: Registers and flip-flops, binary addressing, sequential and combinational logic
Related Topics: Cache design, secondary storage technologies, CPU architecture
Next Topics: Digital-to-analog and analog-to-digital conversion (how digital memory interfaces with the analog world)