Course contentsShow
← Computer Science
Lesson 1127 of 2,87226. Memory Hierarchy and CachingFree lesson

Cache Address Breakdown

Understand how memory addresses are divided into tag, index, and offset fields for cache operations.

Cache Address Breakdown

What you'll learn: How a memory address gets split into tag, index, and offset fields so a cache can quickly locate data.


The Core Idea

When your CPU needs to access memory, it doesn't send a single blob address to the cache. Instead, the address is cleverly divided into three distinct fields: the tag, index, and offset. Each field has a specific job in helping the cache find (or confirm) the right data block.

Think of it like finding a book in a library:

  • Index = which aisle to go to
  • Tag = which specific shelf in that aisle
  • Offset = which page within the book

The Three Fields

Offset

The offset (rightmost bits) tells you where inside a cache line the specific byte lives. If your cache line is 64 bytes, you need 6 bits for the offset (since 2^6 = 64).

Index

The index (middle bits) selects which cache line (row) to check. In a direct-mapped cache with 256 lines, you need 8 bits for the index.

Tag

The tag (leftmost remaining bits) is the unique identifier stored alongside the cached data. After the index picks a line, the cache compares the tag in the address with the stored tag to confirm it's the right block (a hit) or a different one (a miss).

Why This Matters

Breaking addresses into fields lets the cache hardware work in parallel: it uses the index to jump straight to one location while simultaneously comparing the tag. This is far faster than searching every cache entry.

Key Takeaway: A memory address is split into tag (unique ID), index (which cache line), and offset (position within the line) to enable fast, direct cache lookups.