Computer Organisation and Architecture · Cache Basics
Tag Directory for Checking Cache Presence
Overview
The tag directory is the structure that determines whether a required element (data/block) is present in the cache. It plays the same role for the cache that the page table plays for paging, and it must be checked before the cache itself is accessed.
Key concepts
- Tag directory: the structure used to determine whether the required element (data/block) is present in the cache or not.
- Semantic parallel with the page table: the page table tells whether the required page is present in main memory; the tag directory tells whether the required element is present in the cache.
The purpose is the same, though there are differences. - Lookup order: just as paging accesses the page table before main memory, the CPU must access the tags before accessing the cache.
- Service on a miss: a miss in the cache triggers a service operation, analogous to page fault service time in paging; the data must be brought from the next lower level.
- Speed hierarchy: cache resides in high-speed memory (Level 1). On a cache miss the data should at least be in the next level (main memory); if it is missing there too, the program runs as slow as secondary memory.
- Purpose of cache memory: reduce the cost of the system (everything cannot be based directly on registers) and increase CPU speed beyond what main memory alone gives.

How it works
- Before accessing the cache, the CPU accesses the tags (tag directory) to check whether the element is present.
- Only once the tag lookup shows the element is present does the CPU go into the cache and take that element.
- On a miss in the cache, a service operation is performed: the data is brought from the next lower level and loaded into the cache.
- If the data is missing in the next level as well, the program runs as slow as secondary memory.
- The aim is to get the information into the highest-speed memory, store it there, and access it; if it is not present, go to the next level and fetch it.
Comparison
| Aspect | Paging | Cache |
|---|---|---|
| Checking structure | Page table | Tag directory |
| What it checks | Whether required page is in main memory | Whether required element is in cache |
| Outcome of check | Page hit / page fault | Hit / miss (presence in cache) |
| Action on failure | Page fault service time: fetch page from secondary memory and load it | Fetch the element from the next level and load it into cache |
| When the structure is accessed | Before accessing main memory | Before accessing the cache |
Revision summary
- Tag directory answers "is the required element in the cache?" — it is the cache's counterpart of the page table.
- Always check the tags first; only on a tag match do you read the element from the cache.
- Miss in cache → go to the next level; miss there too → speed drops to secondary-memory speed.
- Cache exists to reduce system cost (registers alone cannot serve as the basis) and to increase CPU speed over main memory.
- Introducing cache increases cost but also increases speed compared to a system without cache.
- Cache size is always smaller than main memory size.
Previous-year exam insights
- Average memory access time (single-level): AMAT = hit time + miss rate × miss penalty, where miss penalty is the extra time to fetch the block from the next level and load it into cache.
Asked inGATE 2021GATE 2024UGC NET 2022 - In a k-level hierarchy, AMAT = h1 + m1·h2 + m1·m2·h3 + … where hi is the hit time at level i and mi the local miss rate at level i.
Asked inGATE 2020ISRO 2019 - For a set-associative or direct-mapped cache, the physical address is split as Tag | Set/Line index | Block offset;
number of index bits = , offset bits = , tag bits = address bits − index bits − offset bits.
Asked inGATE 2019GATE 2022UGC NET 2021NIELIT 2020 - A TLB is a small cache of page-table entries; a TLB hit gives the frame number without touching the page table, a TLB miss requires a page-table walk.
With a physically-indexed, physically-tagged cache, address translation must complete before the cache tag comparison, so a TLB miss can still end in a cache hit only if the page is present in memory.
Asked inGATE 2026GATE 2021 - Write policies: write-through keeps memory consistent (higher traffic), write-back writes only on eviction using a dirty bit; write-allocate loads the block on a write miss, no-write-allocate does not.
These choices change the effective miss penalty and memory traffic.
Asked inGATE 2020BARC 2019 - Replacement policies (LRU, FIFO, random) apply only to associative/set-associative caches; direct-mapped caches need no replacement policy.
Locality of reference (temporal and spatial) is the reason caches work.
Asked inUGC NET 2021ISRO 2020