1 / 34
Computer Architecture · Grade 10 · Chapter 2

What is a Computer? Architecture & Logic

From silicon transistors and logic gates to the Von Neumann architecture and the Fetch-Decode-Execute cycle.

Von Neumann F-D-E Cycle CPU Registers Memory Hierarchy Binary & Logic Gates
Chapter Roadmap

Learning Objectives

1. System Architecture

Deconstruct the Von Neumann model: CPU, Main Memory, System Buses (Address, Data, Control), and I/O.

2. CPU Execution Engine

Trace the Fetch-Decode-Execute cycle through hardware registers (PC, MAR, MDR, CIR, ACC).

3. Memory & Storage Hierarchy

Compare access latencies across Registers, L1/L2/L3 Cache, RAM, NVMe Flash, and Secondary Storage.

4. Digital Logic & Operating Systems

Build half-adders from logic gates (AND, OR, NOT, XOR) and explore the OS kernel layer.

Historical Evolution

From Jacquard Looms to Billions of Transistors

In 1804, Joseph Marie Jacquard created a weaving loom controlled by punched cards. In 1945, John von Neumann realized program instructions and data could both be stored electronically in the exact same memory.

The Stored-Program Breakthrough

Before stored-program computers, reprogramming ENIAC meant physically rewiring patch cables and switchboards for days. Today, a modern Apple M3 or Intel Core chip packs over 25 billion transistors into a silicon wafer the size of a postage stamp!

Theoretical Foundations

What Formally Defines a Computer?

A computer is a programmable electronic device that accepts raw data (input), performs high-speed logical/arithmetic operations, and generates output according to stored instructions.

Turing Completeness

If a system can simulate any single-taped Turing machine (perform any computable algorithm given time and memory), it is Turing Complete.

Programmability

Unlike a mechanical clock or fixed microwave timer, a computer's behavior is defined entirely by software loaded into memory.

State & Memory

Computers maintain mutable state across cycles, allowing loops, conditional branches, and persistent file modification.

Universal Flow

Input → Process → Storage → Output (IPOS)

Every computational system operates around this fundamental pipeline:

IN

Input

Keyboard, mouse, camera, microphone, temperature sensor, network packets.

CPU

Processing

ALU performs arithmetic and boolean logic; CU coordinates instruction flow.

MEM

Storage

Primary (RAM/Cache) holds active instructions; Secondary (SSD) stores long-term state.

OUT

Output

Display monitor (OLED/LCD), speakers, motor actuators, network responses.

Anatomy of Modern Systems

Core Hardware Subsystems

Central Processing Unit (CPU)

The primary execution engine. Reads bytecode, performs calculations, and directs data traffic.

Random Access Memory (RAM)

Volatile, high-speed primary memory holding currently executing programs and datasets.

Graphics Processing Unit (GPU)

Massively parallel processor with thousands of cores optimized for vector/matrix math and 3D graphics.

Solid State Drive (NVMe SSD)

Non-volatile NAND flash memory storing the OS, files, and installed software when powered off.

Motherboard & Chipset

Printed circuit board (PCB) providing high-speed copper traces (PCIe, SATA) connecting all components.

Power Supply Unit (PSU)

Converts AC wall current into regulated DC voltages (+12V, +5V, +3.3V) for delicate microcircuits.

Architecture Blueprint

The Von Neumann Model

Proposed in 1945, this architectural model remains the foundation of 99% of general-purpose computers today.

Shared Memory Principle

Both program instructions (code) and data (variables) reside in the same physical addressable memory space. The CPU fetches instructions and data over shared system buses.

The 3 System Buses

  • Address Bus (Unidirectional): Carries memory addresses from CPU to RAM.
  • Data Bus (Bidirectional): Transports actual instruction words and variable values.
  • Control Bus (Bidirectional): Carries read/write signals, clock pulses, and interrupts.
Inside the Processor

The CPU Core Architecture

A single CPU core is comprised of four cooperative functional units:

Control Unit (CU)

Directs the operations of the processor. It fetches instructions, decodes opcodes into micro-operations, and generates electrical control pulses.

Arithmetic Logic Unit (ALU)

The mathematical calculator. Performs integer arithmetic (+, -, *, /) and bitwise boolean logic (AND, OR, XOR, NOT).

CPU Registers

Extremely small, ultra-fast internal SRAM storage cells that hold data being operated on in the current clock cycle.

Internal CPU Cache

On-chip L1/L2 cache SRAM that buffers recently accessed instructions and data to avoid waiting for slow main RAM.

Hardware Registers

The 5 Essential Special-Purpose Registers

Program Counter (PC)

Holds the memory address of the next instruction to be fetched from RAM. Automatically increments after each fetch.

Memory Address Register (MAR)

Holds the physical RAM address currently being read from or written to via the Address Bus.

Memory Data Register (MDR)

Holds the actual data word or instruction recently fetched from RAM, or waiting to be written to RAM.

Current Instruction Register (CIR)

Holds the instruction opcode and operand currently being decoded by the Control Unit.

Accumulator (ACC)

Stores the intermediate output and computational results of the most recent ALU operation.

Instruction Execution Engine

The F-D-E Cycle — Phase 1: FETCH

How the CPU retrieves the next instruction from memory:

1

PC → MAR

Address in Program Counter is copied into the Memory Address Register.

2

Address Bus

MAR asserts address across Address Bus; CU sends a Memory Read signal.

3

RAM → MDR

RAM copies instruction word over Data Bus into the Memory Data Register.

4

MDR → CIR & PC++

Instruction copied to CIR. Program Counter increments by 1 word size.

Instruction Execution Engine

The F-D-E Cycle — Phase 2: DECODE

The Control Unit decodes the raw binary instruction in the CIR into hardware control signals:

Instruction Word Structure: Opcode + Operand

Instruction: 10110001 00001111 10110001 (Opcode) --> "ADD value at address into Accumulator" 00001111 (Operand) --> "RAM Address 0x0F (15)"

The Control Unit's internal instruction decoder looks up the Opcode in the CPU's Instruction Set Architecture (ISA) table and routes power lines to the ALU and register gates.

Instruction Execution Engine

The F-D-E Cycle — Phase 3: EXECUTE

The CPU executes the operation requested by the instruction:

ALU Operation

Data from address 0x0F is fetched into MDR and added to the Accumulator: ACC = ACC + MDR.

Branch / Jump

If the instruction is a conditional jump (e.g. JMP 0x20), the Program Counter is updated directly to change execution flow.

Write-Back

Results stored back into destination register or written to RAM via MAR/MDR write cycle.

Cycle Repeats: The CPU executes this exact 3-phase cycle billions of times every single second!
Processor Performance

Clock Frequency, GHz & Pipelining

The CPU master clock quartz oscillator synchronizes all transistor switching events.

Clock Speed (GHz)

A 4.0 GHz CPU pulses 4,000,000,000 times per second. 1 clock cycle takes just 0.25 nanoseconds!

Instruction Pipelining

Modern CPUs overlap execution stages like an assembly line: while Instruction 3 is being executed, Instruction 2 is being decoded, and Instruction 1 is being fetched simultaneously.

Storage Architecture

The Memory Hierarchy: Speed vs Capacity

Computers cannot have memory that is simultaneously infinite, instantaneous, and cheap. We use a hierarchy:

L0

Registers

Size: ~1 KB
Latency: 0.5 ns
On-chip flip-flops

L1-3

CPU Cache

Size: 32 KB - 64 MB
Latency: 1 - 10 ns
SRAM on silicon

RAM

Main Memory

Size: 16 - 64 GB
Latency: 60 - 80 ns
DRAM modules

SSD

NVMe Flash

Size: 1 - 4 TB
Latency: 25,000 ns
Non-volatile NAND

Memory Technologies

Volatile vs Non-Volatile Memory

Primary Memory (RAM) — Volatile

  • Requires constant electrical power to maintain bit state (DRAM capacitors must be refreshed thousands of times/sec).
  • Loses all data immediately when power is shut off.
  • Extremely high bandwidth (> 50 GB/s) directly accessible by CPU address bus.

Secondary Storage (SSD / HDD) — Non-Volatile

  • Retains trapped electrons (floating gate NAND flash) or magnetic orientation without power.
  • Preserves OS, games, photos, and files permanently.
  • Much slower than RAM; CPU cannot execute code directly from SSD without loading to RAM first.
Digital Foundations

Binary: Why Everything is 0 and 1

Silicon transistors act as microscopic electronic switches with two stable states: Voltage High (1) or Voltage Low (0).

Bit (b)

A single binary digit (0 or 1). Represents 2 states ($2^1$).

Byte (B)

8 bits. Represents $2^8 = 256$ distinct values (ASCII characters, RGB color channels: 0-255).

64-Bit Word Size

Modern CPUs process 64 bits (8 bytes) in a single clock cycle, addressing up to $2^{64} \approx 18$ Exabytes of RAM.

Boolean Logic in Silicon

Fundamental Logic Gates: NOT, AND, OR

By wiring CMOS transistors together, we build fundamental logic circuits:

NOT Gate (Inverter)

In: 0 → Out: 1
In: 1 → Out: 0

Inverts the input voltage signal.

AND Gate

0 & 0 → 0 | 0 & 1 → 0
1 & 0 → 0 | 1 & 1 → 1

Outputs 1 only if both inputs are 1.

OR Gate

0 | 0 → 0 | 0 | 1 → 1
1 | 0 → 1 | 1 | 1 → 1

Outputs 1 if at least one input is 1.

Advanced Logic Circuits

XOR & The Universal NAND Gate

XOR Gate (Exclusive OR)

Outputs 1 if inputs are different; outputs 0 if inputs are identical.

A: 0, B: 0 → Out: 0
A: 0, B: 1 → Out: 1
A: 1, B: 0 → Out: 1
A: 1, B: 1 → Out: 0 (Essential for addition!)

NAND as a Universal Gate

A NAND gate (NOT AND) is functionally complete. Any digital circuit, ALU, or supercomputer CPU in existence can be constructed entirely using only interconnected NAND gates!

From Logic to Math

How Gates Add Binary Numbers: The Half-Adder

How does a CPU calculate $1 + 1 = 2$ in binary ($1 + 1 = 10_2$)?

The Half-Adder Circuit Blueprint

  • Sum Bit ($S$): Calculated via A XOR B (Outputs 0 when $1+1$, outputs 1 when $1+0$).
  • Carry Bit ($C$): Calculated via A AND B (Outputs 1 when $1+1$, representing the carry over).
By chaining a Half-Adder with an incoming Carry input ($C_{in}$), engineers build a Full-Adder. Chaining 64 full-adders together creates a 64-bit CPU ALU!
Parallel Compute

CPU vs GPU: Serial vs Massively Parallel

Central Processing Unit (CPU)

  • 4 to 32 powerful, complex cores.
  • Optimized for low-latency, serial execution, deep branching, and OS multitasking.
  • Huge L3 caches and complex branch predictors.

Graphics Processing Unit (GPU)

  • Thousands (e.g. 16,384) of smaller arithmetic cores (SIMD - Single Instruction, Multiple Data).
  • Optimized for high-throughput parallel math: matrix multiplications for 3D shaders and AI neural networks.
Instruction Set Architectures

x86-64 (CISC) vs ARM (RISC)

Different processors understand different native machine language vocabularies (ISAs):

x86-64 (Intel / AMD) — CISC

Complex Instruction Set Computer: Instructions can perform multi-step memory operations directly. Dominates desktop PCs, gaming rigs, and enterprise cloud servers.

ARM (Apple Silicon / Qualcomm) — RISC

Reduced Instruction Set Computer: Simple, fixed-length instructions that execute in single cycles. High energy efficiency; powers all smartphones, tablets, and modern MacBooks.

Systems Software

The Complete Computing Stack

1

Hardware

Silicon transistors, buses, RAM, registers.

2

Firmware

UEFI / BIOS initializes hardware on power-on.

3

OS Kernel

Privileged scheduler managing RAM and CPU time.

4

Applications

Python scripts, web browsers, Discord, games.

Core System Software

What the OS Kernel Actually Does

1. Process Scheduler

Time-slices CPU cores across hundreds of background threads using preemptive multitasking.

2. Virtual Memory

Gives every app an isolated virtual address space, paging unused memory pages to SSD swap when RAM fills.

3. Device Drivers

Translates generic OS requests (e.g. write(data)) into specific hardware commands for graphics cards or Wi-Fi chips.

Debunking Hardware Myths

Misconception: "More Cores & Higher GHz Always Means Faster"

The Myth

"A 64-core CPU at 5.0 GHz will always run every game and Python script 8 times faster than an 8-core CPU."

The Computer Science Reality

Amdahl's Law: Performance gain from parallel computing is strictly limited by the portion of the program that is serial. If a game physics engine or Python script runs on 1 thread, 63 extra cores sit completely idle!

Interactive Smartboard Activity

Classify the System Subsystems

SMARTBOARD SORTING

Match each component to its primary Von Neumann / IPOS role:

1. NVMe M.2 Flash Drive  →  [Secondary Storage (Non-Volatile)]
2. Control Unit (CU)  →  [CPU Instruction Coordination]
3. OLED 144Hz Screen  →  [Output Subsystem]
4. L1 Cache SRAM  →  [High-Speed Primary Memory]
5. ALU  →  [Arithmetic & Logic Processing]

Class Discussion

Think-Pair-Share: The Von Neumann Bottleneck

A modern CPU can calculate instructions in 0.25 nanoseconds. But fetching data from main RAM across the motherboard bus takes 70 nanoseconds.

The Problem

The CPU spends over 95% of its potential cycles sitting stalled (idle), waiting for data to arrive from memory.

Discussion Prompt (2 Mins)

How do modern chip designers (Intel, AMD, Apple) combat this bottleneck? (Hint: Think about cache hierarchies, branch prediction, and prefetching!)

Guided Calculation

Understanding Latency at Human Scale

If 1 CPU clock cycle (0.3 ns) were scaled up to equal 1 second in human time:

L1

L1 Cache

1 ns = 3 seconds
(Reaching into your pocket)

RAM

Main RAM

70 ns = 4 minutes
(Walking down the hall)

SSD

NVMe SSD

25,000 ns = 1 day
(Waiting for next-day delivery)

NET

Internet Request

50 ms = 5.2 years
(Attending high school + college)

Systems Engineering Challenge

Spot the Flaw in this PC Build

PC Specification Sheet:

CPU: Intel Core i9-14900K (24 cores, 6.0 GHz)
GPU: NVIDIA RTX 4090 (24GB VRAM)
RAM: 4GB DDR4 Single Channel (2133 MHz)
Primary Drive: 5400 RPM Mechanical Magnetic HDD (SATA)
PSU: 450W Generic Power Supply

Question: Why will this $3,000 system stutter, crash, and perform worse than a budget laptop?
Knowledge Check 1 / 4

What is the core defining principle of the Von Neumann Architecture?

ACPUs must contain at least 8 independent cores
BProgram instructions and data are stored together in the same addressable memory
CGraphics processing must be handled on a separate dedicated expansion card
DRAM never loses data when power is disconnected
Click to reveal answer
Explanation: Von Neumann architecture stores both code (instructions) and variable data in unified addressable RAM, fetched over shared buses.
Knowledge Check 2 / 4

Which CPU register holds the memory address of the NEXT instruction to be fetched?

AProgram Counter (PC)
BMemory Data Register (MDR)
CCurrent Instruction Register (CIR)
DAccumulator (ACC)
Click to reveal answer
Explanation: The Program Counter (PC) stores the pointer to the next instruction in RAM and increments automatically after each fetch phase.
Knowledge Check 3 / 4

Which memory type offers the FASTEST access speed but lowest capacity?

ANVMe Solid State Drive
BDDR5 Main RAM
CCPU Internal Registers
DL3 Shared Cache
Click to reveal answer
Explanation: CPU registers sit directly inside the execution pipeline and operate at sub-nanosecond speeds (single cycle latency).
Knowledge Check 4 / 4

Which boolean logic gate produces output 1 if and only if its inputs are DIFFERENT?

AAND Gate
BOR Gate
CXOR Gate (Exclusive OR)
DNAND Gate
Click to reveal answer
Explanation: An XOR (Exclusive OR) gate outputs 1 when inputs are distinct (0,1 or 1,0) and outputs 0 when inputs match (0,0 or 1,1).
Chapter 2 Review

Computer Architecture Summary

1. Von Neumann Model

Unified memory for code and data connected to CPU via Address, Data, and Control buses.

2. The F-D-E Engine

Continuous cycle: Fetch via PC/MAR/MDR → Decode in CIR/CU → Execute via ALU & Registers.

3. Memory Hierarchy

Tradeoff between speed and cost: Registers → SRAM Cache → DRAM RAM → Flash SSD.

4. Digital Abstraction

Transistors → Logic Gates → Adders/ALU → CPU Cores → OS Kernel → High-Level Software.

Wrap-Up & Next Session

Exit Ticket: Trace a Single Keystroke

In 3 sentences, describe what happens from the moment you press the 'A' key on your keyboard to the moment 'A' appears on your monitor:

1. Hardware interrupt signal sent via USB controller to OS kernel.
2. OS context-switches CPU to text editor process; updates memory buffer in RAM.
3. GPU renders font glyph from RAM buffer into frame buffer; sends HDMI signal to OLED pixels!

Next Up in Chapter 3: What is Artificial Intelligence? Foundations, History, and Learning Paradigms!