COMPUTER ORGANIZATION & ARCHITECTURE/Student Engineering Notebook
Page 05·notes
MEMORY HIERARCHY, CACHE MAPPING & AMAT—~32 MIN READ

Cache Memory: Direct, Associative, Set-Associative & AMAT

“Tag/Index/Offset bit splitting, multi-level cache AMAT, and tag directory overhead.”

1.The Principle of Locality & The Three Cache Mapping Techniques

Caches exploit Temporal Locality (recently referenced memory locations are likely to be accessed again soon) and Spatial Locality (memory locations contiguous to recently accessed items are likely to be accessed soon).

Physical Address Partitioning Formulations:

1. Block (Byte) Offset bits (w):

w = \log_2(Block Size in bytes). Identifies the specific byte within a cache line.

2. Direct-Mapped Cache:

Each main memory block maps to exactly ONE cache line index: Line = (Block Address) \bmod (Total Cache Lines).

Address Split: [ Tag Bits \mid Line Index Bits (\log_2 N_{lines}) \mid Block Offset Bits (w) ].

3. Fully Associative Cache:

A memory block can be placed in ANY cache line. No index bits required. Requires parallel comparator hardware for all lines.

Address Split: [ Tag Bits \mid Block Offset Bits (w) ].

4. k-way Set-Associative Cache:

Cache lines are grouped into sets of k lines each. Block maps to: Set = (Block Address) \bmod (Total Sets).

Address Split: [ Tag Bits \mid Set Index Bits (\log_2 N_{sets}) \mid Block Offset Bits (w) ].

Total Sets = \frac{Total Cache Capacity}{Block Size × k} = \frac{N_{lines}}{k}.

notice this:— Tag Directory Overhead Formulation

Tag Directory Size = Total Lines × [Tag Bits + Valid Bit + Dirty Bit + Replacement Bits]. In a k-way set-associative cache with LRU, each set requires \lceil \log_2(k!) \rceil or an approximation \lceil \log_2 k \rceil bits per line for LRU tracking.

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION2 Marks

2. GATE Worked Numerical: Cache Bit Splitting & Tag Directory Size

⚠️ Pitfall Warning:

Always divide cache capacity by (Block Size * k) to get the number of sets in a set-associative cache. Do not use the line count directly for the index field!

Problem: A 32-bit byte-addressable system contains a 64 KB 4-way set-associative cache with 64-byte block size. Find:

1. Number of Tag, Set Index, and Block Offset bits.

2. Total cache memory overhead (tag directory capacity) assuming 1 valid bit and 1 dirty bit per line.

Step 1: Compute Block Offset bits:

w = \log_2(64 bytes) = 6 bits.

Step 2: Compute Total Lines:

N_{lines} = \frac{Cache Size}{Block Size} = \frac{64 KB}{64 B} = 1024 lines.

Step 3: Compute Total Sets for 4-way set-associative (k = 4):

N_{sets} = \frac{1024}{4} = 256 sets.

Step 4: Compute Set Index bits:

s = \log_2(256) = 8 bits.

Step 5: Compute Tag bits:

Tag = 32 - s - w = 32 - 8 - 6 = 18 bits.

Step 6: Compute Tag Directory Overhead:

Bits per line = Tag (18) + Valid (1) + Dirty (1) = 20 bits/line.

Total Tag Directory = 1024 lines × 20 bits = 20,480 bits = 2560 bytes = 2.5 KB.

3.Multi-Level Average Memory Access Time (AMAT)

AMAT models the effective latency seen by the CPU across the memory hierarchy:

1. Single-Level Cache:

AMAT = T_{hit} + (M_{rate} × T_{penalty}).

2. Two-Level Cache Hierarchy (L1 and L2):

AMAT = T_{L1} + M_{L1} × (T_{L2} + M_{L2,local} × T_{MM}).

Local vs Global Miss Rate Distinction:

- Local Miss Rate of L2 (M_{L2,local}): \frac{Misses in L2}{Accesses to L2 (Misses from L1)}.

- Global Miss Rate of L2 (M_{L2,global}): \frac{Misses in L2}{Total CPU References} = M_{L1} × M_{L2,local}.

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION2 Marks

4. GATE Worked Numerical: Multi-Level Cache AMAT

⚠️ Pitfall Warning:

Ensure you check whether L2 miss rate is specified as LOCAL or GLOBAL! If GLOBAL miss rate is given, the formula simplifies to: AMAT = T_L1 + M_L1 * T_L2 + M_L2,global * T_MM.

Problem: An L1 cache has hit time = 1 ns and miss rate = 8%. An L2 cache has hit time = 6 ns and local miss rate = 12%. Main memory access latency is 100 ns. Calculate overall AMAT.

Step 1: Multi-level AMAT formula:

AMAT = T_{L1} + M_{L1} × (T_{L2} + M_{L2,local} × T_{MM}).

Step 2: Evaluate L1 miss penalty:

Penalty_{L1} = 6 ns + (0.12 × 100 ns) = 6 + 12 = 18 ns.

Step 3: Compute final AMAT:

AMAT = 1 ns + (0.08 × 18 ns) = 1 + 1.44 = 2.44 ns.

SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Curated University Lecture Series
Computer Organization and Design: The Hardware/Software Interface (5th Edition) ·
LECTURE SERIES
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Gate Smashers · COA Full Course↗Instructor: Varun Singla · Covers: Instruction cycle, addressing modes, cache mapping, pipelining, I/O

Rapid GATE-focused conceptual coverage with numericals.

Open YouTube↗
Knowledge Gate · COA for GATE↗Instructor: Sanchit Jain · Covers: Cache bit-splitting, AMAT, pipeline CPI, IEEE 754, DMA

Past-paper-focused approach with clear COA numerical explanations.

Open YouTube↗
ETH Zürich · Digital Design & Computer Architecture↗Instructor: Prof. Onur Mutlu · Covers: Microarchitecture, pipelining, out-of-order execution, memory hierarchy

Graduate-level depth on how real modern processors are designed.

Open YouTube↗