This unit explains how data is stored, accessed, and transferred inside a computer — essential for understanding how modern CPUs achieve high speed.
⭐ 5.1 Memory Hierarchy
Memory is organized in layers based on speed, cost, and capacity.
From Fastest → Slowest
-
Registers
-
Main Memory (RAM)
-
Secondary Memory (HDD/SSD)
-
Tertiary (CD/DVD)
Key Idea:
-
Higher levels → faster, expensive, smaller
-
Lower levels → slower, cheap, larger
CPU always tries to read from the fastest possible level.
⭐ 5.2 Cache Memory
Cache = small, very fast memory between CPU & RAM.
Why cache is needed?
Because CPU is extremely fast but RAM is slower → cache avoids waiting.
Types of Cache
1. L1 Cache
Fastest, smallest, inside CPU core.
2. L2 Cache
Bigger, slower.
3. L3 Cache
Shared between multiple cores.
Cache Mapping Techniques
1️⃣ Direct Mapping
Each block of main memory maps to exactly one cache line.
Advantages: Simple
Disadvantages: Conflict misses
2️⃣ Associative Mapping
Any memory block → any cache line.
Advantages: Flexible
Disadvantages: Expensive hardware
3️⃣ Set-Associative Mapping
Memory block → a small set of cache lines.
Most commonly used.
⭐ 5.3 Main Memory (RAM + ROM)
RAM Types
ROM Types
⭐ 5.4 Memory Interleaving
Memory speed can be increased by storing data across multiple banks.
Types:
1️⃣ Lower-Order Interleaving
Low-order bits choose memory bank.
2️⃣ Higher-Order Interleaving
High-order bits choose memory bank.
Goal: Increase reading speed by accessing multiple banks simultaneously.
⭐ 5.5 Associative Memory (Content Addressable Memory)
Data is accessed by content, not by address.
Used in:
-
Cache tag matching
-
TLB (Translation Lookaside Buffer)
⭐ 5.6 I/O Organization
Two main categories:
1️⃣ Programmed I/O
CPU controls I/O directly.
Simple but slow.
2️⃣ Interrupt-Driven I/O
I/O device interrupts CPU when ready.
Faster than programmed I/O.
3️⃣ Direct Memory Access (DMA)
Fastest I/O method.
DMA Features:
-
Transfers data directly between memory & I/O
-
CPU is freed during transfer
-
Very efficient for large data (disk, graphics)
⭐ 5.7 Memory-Mapped vs I/O-Mapped I/O
| Feature | Memory-Mapped I/O | I/O-Mapped I/O |
|---|---|---|
| Address Space | Uses normal memory addresses | Separate I/O address space |
| Instructions | Normal memory instructions | Special I/O instructions (IN, OUT) |
| Speed | Faster | Moderate |
| Example | Modern CPUs | 8085 (IN/OUT) |
⭐ 5.8 Secondary Storage Concepts
HDD
-
Slower
-
Large capacity
SSD
-
No moving parts
-
Much faster
-
Expensive
CD/DVD
-
Used for distribution & backup