Learning Objectives

By the end of this chapter, you will be able to:

  • Define the computer memory hierarchy.
  • Describe the different levels of the memory hierarchy (registers, cache, RAM, storage).
  • Explain the trade-off between speed, cost, and capacity at each level.
  • Differentiate between volatile and non-volatile memory.

The Memory Hierarchy

Computers use a variety of different types of memory, each with its own characteristics. The memory hierarchy is a way of organizing these different types of memory based on their speed, capacity, and cost. The general principle is that the faster the memory, the more expensive it is per byte, and therefore the smaller its capacity.

The hierarchy is typically visualized as a pyramid:

  • Top of the Pyramid: Fastest, most expensive, smallest capacity.
  • Bottom of the Pyramid: Slowest, cheapest, largest capacity.

Levels of the Memory Hierarchy

  1. Registers
    • Location: Inside the CPU.
    • Description: The fastest and smallest form of memory. Registers are used by the CPU to hold the data it is currently processing.
  2. Cache Memory
    • Location: On or very close to the CPU.
    • Description: A small, very fast type of memory that is used to store frequently accessed data and instructions from the main memory. By keeping this data close to the CPU, cache memory reduces the time the CPU has to wait for data from the slower RAM.
  3. Primary Memory (RAM)
    • Location: On the motherboard.
    • Description: Random Access Memory (RAM) is the computer’s main working memory. It is where the operating system, applications, and the data currently in use are kept so they can be quickly reached by the CPU. RAM is volatile, meaning its contents are lost when the computer is powered off.
  4. Secondary Storage
    • Location: Separate devices.
    • Description: Secondary storage is used for long-term, persistent storage of data and programs. It is much slower than RAM but has a much larger capacity and is non-volatile, meaning it retains its data even when the power is off.
    • Examples: Hard Disk Drives (HDDs), Solid-State Drives (SSDs), and external USB drives.

Summary

The computer memory hierarchy organizes memory types based on a trade-off between speed, cost, and capacity. At the top are the fastest, smallest, and most expensive types of memory—CPU registers and cache—which hold the data the CPU is actively using. In the middle is primary memory (RAM), the computer’s main workspace, which is volatile. At the bottom is secondary storage (HDDs, SSDs), which is the slowest, cheapest, and largest, providing non-volatile, long-term storage for all of the computer’s files and applications.

Key Takeaways

  • The memory hierarchy is a trade-off between speed, cost, and capacity.
  • The levels are: Registers > Cache > RAM > Secondary Storage.
  • RAM is volatile (loses data when powered off), while secondary storage is non-volatile.
  • Cache memory is used to bridge the speed gap between the very fast CPU and the slower RAM.

Discussion Questions

  1. Why don’t we just build computers with a very large amount of the fastest type of memory (registers)?
  2. What is the purpose of cache memory?
  3. What is the difference between primary memory (RAM) and secondary storage?