NBC 101 • Unit 216 min readVery High Exam Frequency

The 5-Tier Memory Hierarchy Pyramid & Cache Memory Principles

Unit 2: Computer Memory Hierarchy, Storage & I/O SystemsFundamentals of Computer

👨‍🏫 Professor's Mental Model: The Master Chef's Kitchen Workstation

Memory hierarchy ek busy restaurant ke 5-star chef ke kitchen jaisi hai: Chef ke haath me pakda hua chamach/knife CPU Registers hai (Instant speed, tiny). Counter par khula hua masala box Cache Memory hai (Super fast, few KB/MB). Kitchen ki main dining table RAM hai jahan active dishes banti hain (Fast, volatile). Store room me rakha deep-freezer Secondary Storage (SSD/HDD) hai (Huge capacity, permanent). Aur warehouse me rakha godown Archival Tape hai!

The 5-Tier Computer Memory Hierarchy Pyramid

Click any tier in the pyramid below to inspect access latencies, physical silicon hardware, capacity tiers, and cost trade-offs.

100% Guaranteed 10/15-Mark Exam Diagram
Going Up: Maximum Speed & Highest Cost / Bit
< 1 ns
Going Down: Maximum Capacity & Lowest Cost / Bit
Terabytes
Level 1 – 3

SRAM Cache Memory (L1, L2, L3)

⚡ Latency: 0.8 – 10 Nanoseconds (3 – 20 Clock Cycles)

Bridges the massive speed gap between the ultra-fast CPU core and slower main DRAM memory utilizing Temporal and Spatial Locality of Reference.

Silicon Hardware:On-Die 6-Transistor (6T) SRAM Cells
Typical Capacity:32 KB – 64 MB (L1: 32-64KB, L2: 512KB-1MB, L3: 16-64MB)
Volatility:Volatile
Managed By:Hardware Cache Controller (MMU)

1. Why Does Memory Hierarchy Exist?

In modern computer design, no single memory technology is simultaneously Ultra-Fast, Massive in Capacity, and Inexpensive. • The Trade-off: Faster memories (SRAM, Registers) require complex multi-transistor latch circuits costing more per bit and consuming more silicon area. Slower memories (DRAM, Flash SSD, Magnetic HDD) are dense and cheap per gigabyte but take hundreds of clock cycles to respond. • The Solution: A multi-level hierarchical storage system where frequently referenced data is cached close to the CPU, while massive inactive archives reside on secondary/tertiary storage.

2. Cache Memory Mechanics & Locality of Reference

Cache Memory is a small, ultra-fast semiconductor memory placed between the CPU core and Main RAM to bridge the processor-memory speed bottleneck. • Principle of Locality of Reference: 1. Temporal Locality (Locality in Time): If a memory location is referenced once, it will likely be referenced again soon (e.g., loop variables, function calls, counter indices). 2. Spatial Locality (Locality in Space): If a memory location is referenced, nearby contiguous addresses will likely be referenced soon (e.g., sequential array elements, adjacent program instructions). • Cache Hit vs Cache Miss: • Cache Hit: CPU finds the requested word directly in Cache. High speed, zero DRAM latency. • Cache Miss: CPU does not find word in Cache; it must fetch the entire block from slower Main Memory and update Cache. • Hit Ratio (H): Fraction of total memory accesses fulfilled by Cache: H = Hits / (Hits + Misses). • Average Memory Access Time (T_avg): T_avg = H * T_cache + (1 - H) * T_main.

3. Cache Organization & Mapping Architectures

1. Direct Mapping: Each block of main memory maps to exactly one specific line in Cache using line index bits (Formula: Cache Line = Main Memory Block Modulo Number of Cache Lines). Fast lookup, but high contention collision misses. 2. Fully Associative Mapping: Any main memory block can be loaded into ANY available line in Cache. Zero conflict misses, but requires expensive parallel comparator circuits. 3. Set Associative Mapping (Modern Industry Standard): Compromise between Direct and Associative. Cache is divided into sets of N lines (e.g., 2-way, 4-way, 8-way Set Associative). Block maps to a specific set, but can occupy any line within that set.
5-Tier Memory Hierarchy Technical Parameters Comparison
Memory TierSilicon TechTypical CapacityAccess LatencyCost / BitVolatile?
Level 0: CPU RegistersFlip-Flop Latches64 B – 1 KB0.2 – 0.5 nsHighestYes
Level 1 Cache (L1)6T SRAM (On-Die)32 KB – 64 KB0.8 – 1.5 nsVery HighYes
Level 2 Cache (L2)SRAM (Near Core)512 KB – 2 MB3 – 5 nsHighYes
Level 3 Cache (L3)Shared SRAM16 MB – 64 MB10 – 15 nsModerate-HighYes
Level 4: Main RAM1T-1C DRAM Array8 GB – 64 GB50 – 80 nsModerateYes
Level 5: Secondary SSD/HDDNAND Flash / Magnetic512 GB – 8 TB20 µs – 10 msLowNo (Permanent)

🎯 University Exam Scoring Blueprint

  • Draw the triangular Memory Hierarchy Pyramid with upward speed/cost and downward capacity arrows.
  • Write the definition and mathematical formula for Hit Ratio: H = Hits / (Hits + Misses).
  • Explain Temporal Locality vs Spatial Locality with code examples (Loops vs Arrays).

Top Viva Questions on The 5-Tier Memory Hierarchy Pyramid & Cache Memory Principles

1 Questions
1

What is the difference between Temporal Locality and Spatial Locality?