Purposes of different primary memory types
In one sentence: RAM, ROM, cache, and registers provide the CPU with different kinds of immediate storage so it can access instructions and data efficiently.
What you will learn
By the end, you should be able to explain the purposes of RAM, ROM, L1/L2/L3 cache, and registers; describe how the CPU uses them; and explain cache hits, misses, and their performance effects.
Before you begin
This lesson builds on the CPU registers from Function and interaction of the main central processing unit components. Primary memory is memory used directly by the CPU; it is distinct from secondary storage such as an SSD or hard drive.
Key words
| Term | Simple meaning |
|---|---|
| RAM | Volatile read/write memory holding programs and data currently in use. |
| ROM | Non-volatile memory that stores instructions such as firmware used to start or control a device. |
| Cache | Small, fast memory holding copies of data or instructions likely to be needed soon. |
| Register | Very small, very fast storage inside the CPU for values and instructions being used immediately. |
| Cache hit | The requested information is found in the cache being checked. |
| Cache miss | The requested information is not found there and must be obtained from another level of memory. |
| Volatile | Loses its contents when power is switched off. |
The idea, step by step
Different purposes
| Type | Purpose | Typical characteristics |
|---|---|---|
| Registers | Hold an instruction, address, data item, or intermediate result that the CPU is using immediately. | Inside the CPU; extremely small and fast; volatile. |
| L1 cache | Keep frequently or recently needed instructions/data very close to a core. | Usually the smallest and fastest cache. |
| L2 cache | Provide additional cache capacity for a core or group of cores. | Usually larger and slower than L1, but faster than RAM. |
| L3 cache | Provide a larger cache that may be shared among cores. | Usually larger and slower than L1/L2, but faster than RAM. |
| RAM | Hold programs and data currently needed by the system. | Read/write and volatile; much larger than cache, but slower to access. |
| ROM | Retain essential instructions, such as firmware, when power is off. | Non-volatile; not used as the general working area for running programs. |
Exact sizes, locations, and sharing arrangements vary between devices. The general pattern is that registers and cache are close to the CPU and fast but limited in capacity; RAM provides a larger working area; ROM retains selected instructions without power.
Analogy: a nearby workspace
Imagine working at a desk with a few values in your hands, frequently used notes on a small tray, and a larger cabinet of working materials nearby. The values in your hands are like registers: very few items the CPU is using immediately. The tray is like cache: a small, fast place for copies of information that may be needed again. The cabinet is like RAM: a larger working area that takes longer to access than the closest items. This helps explain the trade-off between speed and capacity, but real memory is electronic, not physically arranged around the CPU; registers, cache, and RAM also have distinct technical roles.
How the CPU uses memory
The CPU uses registers during processing. When an instruction needs data that is not already in a register, the processor's memory system can check the cache hierarchy before requesting the data from RAM. Frequently used information may be kept in cache so later access is faster. RAM holds the broader set of active program instructions and data; ROM provides persistent startup or device instructions.
This is a simplified model: actual processors use different cache organizations and may check multiple cache levels. ROM, RAM, cache, and registers have different purposes, so none replaces all the others.
Cache hit and cache miss
- A cache hit occurs when the requested item is found in the cache being checked. The CPU can get it without waiting for a slower level.
- A cache miss occurs when it is not found there. The system must obtain it from a lower cache level or RAM and may place a copy in cache for later use.
A hit usually reduces the time the CPU waits for the information. A miss adds a delay because data must be fetched from farther away. A higher proportion of hits can improve performance, especially when a program reuses data; a miss does not mean the data is lost.
Worked example
Imagine a program repeatedly adds values from a small table.
- The CPU uses registers to hold the current instruction, the values for the calculation, and an intermediate result.
- On the first request for a table value, the value may not be in cache. This is a cache miss, so it is fetched from RAM (or another cache level).
- A later request for the same value may find it in cache. This is a cache hit, so it can be supplied more quickly.
- If the program uses many new values that are not in cache, more misses occur and the CPU spends more time waiting.
The cache improves access to reused information; it does not replace RAM as the larger working area.
Check your understanding
- Which of RAM and ROM is volatile, and what is each used for?
- How do L1 and L3 cache generally differ in size and speed?
- What happens when a requested value causes a cache miss?
- Why are registers useful even though they hold much less data than RAM?
Common mix-up
It is easy to think: A cache miss means the information does not exist.
Instead, remember: It means the information was not found in that cache. The system obtains it from another memory level, typically a lower cache or RAM.
Quick recap
- RAM is the volatile working area; ROM retains selected instructions such as firmware.
- Registers hold the CPU's immediate working values; L1/L2/L3 cache keep copies of useful information close to processing.
- A cache hit avoids a slower access; a miss requires a fetch from a lower level and can delay processing.
- The CPU uses these types together because they trade capacity, speed, and persistence differently.
Textbook reading
Read Computer Science (Baumgarten, Ganea, Turland, 2025), A1 Computer fundamentals > A1.1 Computer hardware and operation > A1.1.4 Purposes of different primary memory types, Book pp. 8–10 (PDF pp. 18–20). The syllabus outcome is A1.1.4: “Explain the purposes of different types of primary memory” (Guide p. 28; PDF p. 34).
Sources and further learning
This lesson addresses the complete listed scope of IB Computer Science Guide 2027 outcome A1.1.4. Its explanations and worked example are original.