Computer Fundamentals
CPU — Central Processing Unit; Memory Hierarchy
C-CAT
CPU — Central Processing Unit
What is CPU?
The CPU (Central Processing Unit) is the "brain" of the computer — it processes all instructions and data.
Also called: Processor, Microprocessor
Components of CPU
+-------------------------------------------+
| CPU |
| +------------------+ +---------------+ |
| | ALU | | CU | |
| | Arithmetic Logic | | (Control Unit)| |
| | Unit | | | |
| | + - × ÷ AND OR | | Fetch-Decode | |
| | NOT XOR CMP | | -Execute | |
| +------------------+ +---------------+ |
| +---------------------------------------+ |
| | Registers | |
| | PC, IR, MAR, MDR, Accumulator, Flags | |
| +---------------------------------------+ |
+-------------------------------------------+
| Component | Full Form | Function |
|---|---|---|
| ALU | Arithmetic Logic Unit | Performs arithmetic (+,-,×,÷) and logical (AND OR, NOT, XOR, compare) operations |
| CU | Control Unit | Directs flow of data; fetches, decodes, executes instructions |
| Registers | — | Fast, small storage within CPU for temporary values |
CPU Registers
| Register | Purpose |
|---|---|
| PC (Program Counter) | Holds address of next instruction to execute |
| IR (Instruction Register) | Holds currently executing instruction |
| MAR (Memory Address Register) | Holds address for memory access |
| MDR (Memory Data Register) | Holds data read from/written to memory |
| Accumulator | Holds results of ALU operations |
| Flags/Status Register | Holds condition codes (zero, overflow, carry, etc.) |
CPU Fetch-Decode-Execute Cycle
1. FETCH: PC → MAR → Memory → MDR → IR (load instruction)
2. DECODE: CU decodes instruction in IR
3. EXECUTE: ALU performs operation
4. WRITEBACK: Store result → register/memory
5. INCREMENT: PC++ (point to next instruction)
Repeat forever
CPU Performance Metrics
| Metric | Description | Formula |
|---|---|---|
| Clock Speed | How many cycles per second | Hz (GHz for modern CPUs) |
| CPI | Clock cycles per instruction | CPI = Cycles / Instructions |
| IPC | Instructions per clock | Higher = better |
| CPU Time | Time for a program | Instructions × CPI / Clock Speed |
| MIPS | Million instructions per second | Clock Speed / (CPI × 10^6) |
CPU Cache
Cache is small, fast memory inside/near CPU that stores frequently used data.
| Level | Size | Speed | Location |
|---|---|---|---|
| L1 Cache | 32-128 KB | Very fast (1-4 cycles) | Inside CPU core |
| L2 Cache | 256 KB - 4 MB | Fast (4-12 cycles) | Inside CPU package |
| L3 Cache | 4-64 MB | Moderate (30-50 cycles) | Shared between cores |
| RAM | 4-128 GB | Slow (100-300 cycles) | On motherboard |
Memory Hierarchy
Memory Hierarchy Pyramid
/\
/ \ CPU Registers (fastest, smallest)
/ \
/ \ L1 Cache
/--------\
/ \ L2 Cache
/------------\
/ \ L3 Cache
/----------------\
/ \ RAM (Main Memory) ← Primary Storage
/--------------------\
SSD/HDD ← Secondary Storage
NAS/SAN ← Tertiary Storage
Tape/Cloud ← Off-line Storage
As you go down the pyramid:
- Capacity increases (Bytes → GB → TB → PB)
- Speed decreases (nanoseconds → milliseconds → seconds)
- Cost per byte decreases
Memory Types
| Memory | Volatile? | Speed | Description |
|---|---|---|---|
| CPU Registers | Yes | Fastest | Inside CPU; accessed in <1 ns |
| Cache (L1/L2/L3) | Yes | Very Fast | SRAM; stores frequently used data |
| RAM | Yes | Fast | Main memory; program execution |
| SSD | No | Medium | Solid-state disk; fast permanent storage |
| HDD | No | Slow | Hard disk; spinning magnetic disk |
| Flash Drive | No | Medium | USB storage; portable |
| CD/DVD | No | Slow | Optical storage; read-only or writable |
Primary vs Secondary Storage
| Feature | Primary (RAM) | Secondary (HDD/SSD) |
|---|---|---|
| Speed | Very fast | Slower |
| Volatile | Yes (lost on power off) | No (permanent) |
| Capacity | 4-128 GB | 256 GB - 20 TB |
| Cost | Higher per GB | Lower per GB |
| Purpose | Running programs | Storing programs/data |
RAM Types
| Type | Full Form | Description |
|---|---|---|
| DRAM | Dynamic RAM | Must be refreshed; slow but cheap; used for main RAM |
| SRAM | Static RAM | No refresh needed; fast; expensive; used for cache |
| DDR4 | Double Data Rate 4 | Modern RAM standard; 2133-3200 MHz |
| DDR5 | Double Data Rate 5 | Latest RAM standard; up to 8400 MHz |
| GDDR6 | Graphics DDR6 | Used in GPUs for graphics memory |
Continue learning
Related notes
Definition of AI; Need of AI
Artificial Intelligence
Introduction to Data Engineering; Big Data — The 5 V's; Types of Data
Big Data and Data Engineering
Introduction to C Programming; C Program Structure; Data Types and Variables
C Programming
What Is a Computer?; Machine Cycle: Fetch–Decode–Execute; CPU Organization
Computer Architecture
Put this topic into timed practice
Open mock tests when you want full-exam pacing, or keep drilling in practice mode.