3.1 Computer architecture

Test yourself on Computer architecture 12 questions — drag-to-order, code completion, matching and multiple choice.
Start the quiz

The CPU and Architecture

Watch this lesson Video 3.1.1 · 8:53 · The stored program idea, what sits inside the processor and what does not, and the instruction set

1. The Evolution of Computing

Before the mid-1940s, computers were fixed-program machines. If you wanted a computer to switch from doing math to processing text, you had to physically rewire it.

The Challenge: Early computers like ENIAC required engineers to manually flip switches and move patch cables to "program" the machine. This took days or weeks for a single task. There was no "software" as we know it today.

2. The Stored Program Concept

In 1945, mathematician John von Neumann proposed a revolutionary idea: the Stored Program Concept.

The Core Idea

Both Data and the Instructions (the program) are stored together in the same Memory Unit (RAM).

This allowed a computer to be reprogrammed simply by loading a different set of instructions into memory, rather than changing the hardware.

3. Components of the Von Neumann Model

The model has a processor and a memory unit, joined by buses. Look carefully at where the boundary falls in the diagram: the Control Unit, the ALU and the registers are all inside the CPU, while memory sits outside it.

Control Unit (CU)

The "Manager" of the CPU. It directs the flow of data between the CPU and other devices. It manages the execution of instructions by sending control signals to the other components.

Arithmetic Logic Unit (ALU)

The "Calculator." It performs all Arithmetic calculations (addition, subtraction, etc.) and Logical operations (comparing values using AND, OR, NOT).

Registers

Inside the CPU. A handful of very small, very fast stores, each holding a single value the CPU is working with right now — an address, an instruction, or a result. Covered in detail in the next lesson.

Memory Unit (Main Memory)

Outside the CPU. This is RAM, also called the immediate access store. It holds the program's instructions and its data together, and the CPU fetches from it across the buses. It is much larger than the registers, and much slower.

Do not confuse registers with the memory unit. Registers are inside the processor and hold one value each; the memory unit is outside it and holds the whole running program. The stored program concept is a statement about the memory unit — that instructions and data live together in it — and it only makes sense once you keep the two apart.

4. The Instruction Set

A CPU cannot execute just any instruction. Every processor is built to recognise a fixed, finite list of machine-code operations, and that list is called its instruction set.

Each instruction in the set has two parts:

  • Opcodewhat to do: add, subtract, load a value, store a value, jump to another instruction.
  • Operandwhat to do it to: usually a value, or the address in memory where a value can be found.

This is why a program written in a high-level language has to be translated before it will run. The translator's job is to turn each high-level statement into a sequence of instructions drawn from that particular CPU's instruction set.

Why this matters: different processor designs have different instruction sets. Machine code compiled for one design will not run on a processor with a different set, because the second processor simply has no circuitry for those opcodes. That is why software is published for specific architectures rather than for computers in general.

5. Why the Von Neumann Architecture?

  • Flexibility: The same hardware can perform any task as long as the instructions are provided in memory.
  • Efficiency: It uses a single set of buses to access memory, simplifying the design of the computer.
  • Universal Design: Almost every modern computer, from your smartphone to your laptop, is based on this foundational model.

6. Embedded Systems

Not every computer looks like a computer. An embedded system is a computer system built into a larger device, dedicated to carrying out one specific task — rather than a general-purpose machine that runs whatever software you install on it.

It contains the same ingredients as any other computer: a microprocessor or microcontroller, memory holding a program that does not change, inputs (often from sensors), and outputs (often to actuators or a small display).

DeviceWhat the embedded system does
Washing machineRuns the selected wash programme: controls water valves, drum motor and heater from timer and temperature sensors.
Microwave ovenTimes the cooking, controls the magnetron, stops when the door opens.
Traffic lightsSequences the lights, responds to vehicle and pedestrian sensors.
Car engine managementAdjusts fuel and ignition continuously from engine sensor readings.
Central heating controllerCompares a temperature sensor with the set point and switches the boiler.
AdvantagesDisadvantages
Small and cheap to mass-produce, because the hardware only has to do one job Difficult or impossible for a user to upgrade or reprogram
Low power consumption Hard to troubleshoot — there is usually no screen or keyboard to diagnose it with
Dedicated to one task, so it is fast and reliable at that task A fault often means replacing the whole unit rather than repairing it
⚠️ Exam Alerts:
  • In a Von Neumann machine, instructions and data share the same memory and the same buses. This is often a 1-mark question.
  • The memory unit is not the registers. Registers are inside the CPU; the memory unit is RAM, outside it.
  • An instruction set is the complete list of machine-code operations one CPU can execute — not the program, and not the software.
  • Define an embedded system by what it is for — a computer dedicated to one specific function within a larger device — rather than by saying it is "a small computer".

Registers and the FDE Cycle

Watch this lesson Video 3.1.2 · 8:25 · What each register holds, which bus carries what, and why the program counter is incremented

1. CPU Registers

Registers are high-speed storage locations inside the CPU. Each one holds a single value the processor is working with at this instant.

Program Counter (PC)

Holds the address of the next instruction to be fetched.

Memory Address Register (MAR)

Holds the address of the current instruction or data being read from/written to memory.

Memory Data Register (MDR)

Holds the actual data or instruction fetched from memory (or waiting to be written).

Current Instruction Register (CIR)

Holds the instruction that is currently being decoded and executed.

Accumulator (ACC)

Holds the results of calculations performed by the ALU.

The pairing to remember: MAR and MDR always work together. The MAR holds where in memory, the MDR holds what was found there. One is an address, the other is contents.

2. System Buses

Buses are the physical connections (wires) that move data between the CPU and memory. They are not used for movement between two registers — registers are all inside the CPU already.

  • Address Bus: Carries addresses from the MAR to memory. (One-way / unidirectional).
  • Data Bus: Carries actual data/instructions between memory and the MDR. (Two-way / bidirectional).
  • Control Bus: Carries signals such as Read and Write from the Control Unit. (Two-way).

3. The Fetch-Decode-Execute (FDE) Cycle

This is the process the CPU repeats continuously, for as long as it is switched on, to run programs.

Step 1: Fetch
  • The PC contains the address of the next instruction.
  • That address is copied from the PC to the MAR. This happens inside the CPU — no system bus is involved.
  • The MAR places the address onto the Address Bus, which carries it out to memory, while the Control Unit sends a read signal along the Control Bus.
  • The contents of that memory location travel back along the Data Bus into the MDR.
  • The instruction is copied from the MDR to the CIR.
  • The PC is incremented by 1, so it now points at the following instruction.
Step 2: Decode

The Control Unit (CU) decodes the instruction held in the CIR, splitting it into its opcode (what to do) and operand (what to do it to), and works out which components need to act.

Step 3: Execute

The CPU carries out the instruction. If a calculation is required, the ALU performs it and the result is stored in the Accumulator (ACC).

Step 4: Repeat. Control returns to Fetch, and the whole cycle runs again using the address now in the PC. This is why the PC is incremented during fetch — so that the next pass picks up the next instruction rather than repeating the current one. A CPU performs this cycle billions of times per second, and its clock speed is simply how many times per second it can do so.

Worked example: two passes

Suppose memory holds an instruction LOAD 200 at address 100, and ADD 201 at address 101. Following the registers through:

StagePCMARMDRCIRACC
Start100
PC → MAR100100
Memory → MDR100100LOAD 200
MDR → CIR100100LOAD 200LOAD 200
PC incremented101100LOAD 200LOAD 200
Decode + Execute10120025LOAD 20025
— cycle repeats —101101ADD 201ADD 20125

Notice two things in that trace. The PC changed from 100 to 101 during the first fetch, which is what makes the second pass collect a different instruction. And on the last row the MAR and MDR are reused — they are not dedicated to instructions, they are used again whenever memory is accessed for anything.

⚠️ Exam Warnings:
  • A common mistake is saying the "Data Bus carries addresses." Addresses go on the Address Bus; data goes on the Data Bus. Only the Address Bus is unidirectional (CPU → Memory).
  • PC to MAR does not use a bus. Both are registers inside the CPU. The buses only carry things between the CPU and memory.
  • Say that the cycle repeats, and link the PC increment to it. "The PC is incremented" earns more credit when you add "so the next instruction is fetched on the following cycle".

Buses

Watch this lesson Video 3.1.3 · 8:11 · What each bus carries, why only one is one-way, and what bus width decides

1. Overview of System Buses

A Bus is a set of parallel wires connecting two or more components of a computer. In the Von Neumann architecture, the CPU uses three specific buses to communicate with Main Memory (RAM).

Address Bus Unidirectional

Carries the address (location) of where data needs to be found or stored in memory.

Flow: CPU → Memory / I/O

Data Bus Bi-directional

Carries the actual data or instructions between the CPU and other components.

Flow: CPU ↔ Memory / I/O

Control Bus Bi-directional

Carries control signals (commands) from the Control Unit (CU) to coordinate all activities.

Flow: CPU ↔ All Components

2. Key Operations & Bus Width

The "width" of a bus refers to the number of parallel wires it has. This is a common exam point:

  • Address Bus Width: Determines the maximum memory capacity the CPU can address. For example, a 32-bit address bus can access $2^{32}$ addresses (4 GiB).
  • Data Bus Width: Determines how much data can be moved at once. A 64-bit data bus is faster than a 32-bit one because it can move twice as much data per clock cycle.

3. The Control Bus Signals

The Control Bus isn't just one signal; it carries many different "commands" to prevent data collisions. Common signals include:

  • Memory Read: Fetch from RAM.
  • Memory Write: Save to RAM.
  • Bus Request: Device wants to use a bus.
  • Bus Grant: CPU allows bus use.
  • Clock Signal: Synchronizes operations.
  • Interrupt Request: Device needs attention.

4. Exam-Style "How it Works"

If the CPU needs to Read data from memory:

  1. The CPU places the memory address on the Address Bus.
  2. The CPU sends a "Read" signal via the Control Bus.
  3. The Memory Unit locates the data and sends it back via the Data Bus.
⚠️ Critical Fact: The Address Bus is the ONLY one that is strictly Unidirectional. It only goes from the CPU to Memory. The CPU tells Memory where to look; Memory never tells the CPU where to look!

Cores, Cache and Clock Speed

Watch this lesson Video 3.1.4 · 8:31 · The three things that make a CPU faster — and why each one stops helping

1. CPU Cores

A Core is a complete copy of a CPU. A "Dual-core" processor has two CPUs, while a "Quad-core" has four.

Impact of Multiple Cores

Allows Parallel Processing. The computer can execute multiple instructions at the exact same time.

  • Pro: Better multitasking (e.g., gaming while streaming).
  • Con: Some software is not designed to use multiple cores, so it won't run any faster.

2. Clock Speed

The Clock Speed is the number of FDE cycles a CPU can perform per second. It is measured in Hertz (Hz).

The "Heartbeat"

Most modern CPUs run at 3 GHz to 5 GHz. A 3 GHz CPU performs 3 billion cycles every second.

  • Impact: Higher clock speed = instructions are executed faster.
  • Limit: High clock speeds generate heat, which can damage the CPU if not cooled.

3. The Cache Memory

Cache is a tiny amount of high-speed memory located inside the CPU chip. It stores frequently used data so the CPU doesn't have to wait for the slower RAM.

Typical Sizes: Usually measured in KB or MB (e.g., 8 MB L3 Cache). While small, it is thousands of times faster than RAM.
Use: It holds the "loops" and "most used variables" of a running program.

4. The Memory Hierarchy: Distinguishing the Three

It is vital to distinguish between these three storage areas for the exam:

Feature Registers Cache RAM (Main Memory)
Location Inside the CPU Inside the CPU chip On the Motherboard
Size Few bytes (e.g., 64-bit) 2 MB – 32 MB 8 GB – 32 GB+
Speed Fastest Extremely Fast Fast (but slow for CPU)
Purpose Current instruction data Frequently used data Programs currently open

5. Summary: Performance Bottlenecks

Think of it like a kitchen:

  • Cores are the number of Chefs working.
  • Clock Speed is how Fast the chefs move.
  • Cache is the Countertop (right in front of the chef).
  • RAM is the Pantry (requires walking across the kitchen).
⚠️ Exam Note: Doubling the number of cores does not always double the speed. If the software is "single-threaded," only one core will do the work while the others sit idle!