📑 Contents

Chapter 4.1: Central Processing Unit (CPU) Architecture

9618 AS Computer Science

📚 Learning Objectives
🌟 Did You Know?

Early computers were fed data while machines were running - it was not possible to store programs or data. John Von Neumann introduced the revolutionary idea of the stored program computer, realizing that data and programs are of the same type and can use the same memory!

CPU ALU CU Registers Memory I/O Bus Bus

1. The Von Neumann Model

John von Neumann was the first person to describe the basic principles of a computer system and its architecture in a publication. The model has the following basic features:

📖 Key Features of Von Neumann Architecture

1.1 The Stored Program Concept

A Stored-Program digital computer keeps its programmed instructions, as well as its data, in read-write, random-access memory (RAM). This was revolutionary because:

MEMORY (RAM/IAS) Data + Programs CPU ALU CU REGISTERS (PC, MAR, MDR...) INPUT OUTPUT Address Bus Data Bus Control Bus
💡 Exam Tip

The Von Neumann architecture introduces two key concepts: ADDRESSES (indicate where data is stored) and REGISTERS (needed so data can be manipulated within the computer). Remember: the stored program concept means instructions and data share the same memory!

2. CPU Components

The CPU is the electronic circuit responsible for executing instructions of a computer program. It processes data, performs calculations, and makes decisions.

2.1 Arithmetic and Logic Unit (ALU)

📖 What is the ALU?
🌟 ALU and Accumulator

The Accumulator is a temporary register used when carrying out ALU calculations. It receives the results of any calculations that have taken place in the ALU.

2.2 Control Unit (CU)

📖 What is the Control Unit?
CONTROL UNIT Instruction Decoder Control Signal Gen ALU Arithmetic: + − × ÷ Logic: AND OR NOT XOR ACCUMULATOR (ACC) Stores results Control Result

2.3 System Clock

📝 System Clock Functions

3. Registers

Registers are extremely small, extremely fast memory located in the CPU. They hold small amounts of data needed as part of the fetch-execute cycle. Registers can be General Purpose or Special Purpose.

3.1 General Purpose vs Special Purpose

Type Description Example
General Purpose Can store any data the CPU is currently working on; flexible and can be used for various operations Accumulator (ACC)
Special Purpose Has a dedicated role within the operation of the CPU; controls or tracks data PC, MAR, MDR, CIR, IX, SR

3.2 Special Purpose Registers

📖 Program Counter (PC)
📖 Memory Address Register (MAR)
📖 Memory Data Register (MDR)
📖 Current Instruction Register (CIR)

3.3 Accumulator (ACC)

📖 Accumulator

3.4 Index Register (IX)

📖 Index Register

3.5 Status Register (SR)

📖 Status Register (Flag Register)
Flag Symbol When Set ( = 1)
Carry Flag C There is a CARRY following an addition operation
Negative Flag N Result of calculation yields a NEGATIVE value
Overflow Flag V Arithmetic operation results in an OVERFLOW
Zero Flag Z Result of arithmetic or logic operation is ZERO

3.6 Immediate Access Store (IAS)

📝 IAS (Primary Memory/RAM)
MEMORY MAR MDR PC CIR ACC ALU STATUS REG C N V Z

4. System Buses

Components within the CPU and wider computer system are connected by buses. A bus is a set of parallel wires through which data/signals are transmitted from one component to another.

4.1 Address Bus

📖 Address Bus Characteristics
Example: A 16-bit address bus can address 216 = 65,536 memory locations. A 32-bit address bus allows 4,294,967,296 memory locations to be simultaneously addressed.

4.2 Data Bus

📖 Data Bus Characteristics

4.3 Control Bus

📖 Control Bus Characteristics
CPU MEMORY ADDRESS BUS (Unidirectional →) DATA BUS (Bidirectional ↔) CONTROL BUS 16/32/64 bits 32/64 bits 8 bits
💡 Exam Tip

Remember: Address Bus = Unidirectional (CPU to memory only), Data Bus = Bidirectional (both directions). Wider buses = better performance because more data can be transferred in a single operation!

5. CPU Performance Factors

CPU performance is affected by several key characteristics. Understanding these factors helps explain why some computers perform better than others.

5.1 Clock Speed

📖 Clock Speed Explained
⚠️ Important

Higher clock speed doesn't always mean better overall performance! Using a clock speed higher than the computer was designed for can lead to unsynchronized operations and the computer may crash.

5.2 Number of Cores

📖 What is a Core?
Example:
• 4.2 GHz Dual Core = 4.2 × 2 = 8.4 GHz
• 2.2 GHz Quad Core = 2.2 × 4 = 8.8 GHz
The quad-core has higher effective speed despite lower base speed!
❌ Common Mistake

Dual-core is NOT always twice as fast as single-core. Some time is used for organizing tasks between cores, and not all tasks can be split across cores. Some tasks are sequential and must be done step-by-step.

5.3 Cache Memory

📖 What is Cache Memory?
Cache Level Location Speed Size
Level 1 (L1) Inside each CPU core Fastest Smallest
Level 2 (L2) Inside or near each core Fast Medium
Level 3 (L3) Shared by all cores Slower than L1/L2 Largest
CPU CORE L1 CACHE Fastest, Smallest L2 CACHE L3 CACHE (Shared) RAM Slowest, Largest FAST SLOW

5.4 Bus Width and Word Length

📖 Bus Width
Historical Examples:
• 8088 processor: 4.77 MHz, 8-bit word length
• 80486 processor: 50-80 MHz, 32-bit word length
• Pentium 4: 1.5-3.2 GHz, 64-bit word length

6. Computer Ports

Input and output devices are connected to a computer via ports. The interaction of ports with connected devices is controlled by the control unit.

6.1 Universal Serial Bus (USB)

📖 USB Characteristics
USB Version Speed Use Case
USB 1.1 12 Mbps Very slow, legacy devices
USB 2.0 480 Mbps Common, keyboards, mice
USB 3.0/3.1/3.2 5-20 Gbps External HDDs, gaming devices
USB4/USB4 2.0 Up to 80 Gbps High-speed data transfer

USB Connector Types

📝 USB Connector Types
Advantages of USB Disadvantages of USB
Devices automatically detected and drivers loaded Maximum cable length ~5 metres
Connectors fit only one way - prevents incorrect connections Older versions have limited transmission rates
Industry standard - considerable support available Old standards may not be supported in future
Multiple data transmission rates supported
Newer standards backward compatible

6.2 High Definition Multimedia Interface (HDMI)

📖 HDMI Characteristics
🌟 HDMI Authentication

HDMI uses authentication protocol: devices check for authentication key before sending data. If key is authenticated, "handshaking" occurs and data transmission begins. This helps prevent unauthorized copying of protected content.

6.3 Video Graphics Array (VGA)

📖 VGA Characteristics
Feature HDMI VGA
Signal Type Digital Analogue
Max Resolution 4K/10K 640 × 480
Audio Support Yes (video + audio) No (video only)
Security HDCP protection None
Cable Length Good signal over distance Signal loss over long cables
Status Current standard Being phased out
USB Serial, Bidirectional HDMI Digital, 19 pins VGA Analogue, 15 pins

7. Fetch-Execute Cycle

The fetch-execute cycle (also called fetch-decode-execute cycle) is the process that the CPU goes through repeatedly to process instructions.

7.1 The Three Stages

📝 Three Stages of F-E Cycle
  1. Fetch: Retrieve an instruction from memory - supply the address and receive the instruction
  2. Decode: Translate the retrieved instruction into a series of computer commands - interpret the instruction
  3. Execute: Execute the computer commands - carry out the required action

7.2 Detailed Steps

📖 Fetch Stage (Steps 1-4)
  1. Load the address from PC into MAR
  2. Increment the PC by 1
  3. Load the instruction from memory address (in MAR) into MDR
  4. Load the instruction from MDR into CIR
📖 Decode Stage (Step 5)
  1. Decode the instruction in the CIR - CU interprets what to do
📖 Execute Stage (Steps 6-7)
  1. If jump instruction: load address part into PC and reset to step 1
  2. Execute the instruction
  3. Reset and go back to step 1
🌟 Pipelining

Processors use pipelining - a micro-processing technique that handles multiple stages of different computer instructions at once. This allows the processor to begin fetching a second instruction before completing the cycle for another instruction!

7.3 Fetch-Execute Cycle Flowchart

START FETCH MAR ← [PC] PC ← [PC] + 1 MDR ← [[MAR]] CIR ← [MDR] DECODE Decode [CIR] Jump? EXECUTE Execute instruction No Yes
💡 Exam Tip

Remember the order: PC → MAR → MDR → CIR. The PC holds the address, MAR receives it, MDR gets the instruction from that address, and CIR stores the current instruction for decoding. Double brackets [[MAR]] mean "data at the address stored in MAR"!

8. Register Transfer Notation (RTN)

Register Transfer Notation (RTN) is a way of describing how data moves between registers in a CPU during the fetch-execute cycle. It uses symbols to represent registers and arrows to show data transfer.

8.1 Common RTN Symbols

Symbol Meaning
Data is transferred INTO a register
PC Program Counter
MAR Memory Address Register
MDR Memory Data Register
CIR Current Instruction Register
ACC Accumulator
RAM[ ] Memory location at address
[[ ]] Data at address (double brackets = indirect)

8.2 RTN Examples

📝 Fetch Stage in RTN
📝 Execute Examples in RTN

LDA X (Load value from memory location X into ACC):

STA X (Store ACC value into memory location X):

ADD X (Add value from memory location X to ACC):

BRZ X (Branch to X if ACC = 0):

🧠 Memory Trick

The arrow always points LEFT to where data is being saved (just like variable assignment in Python!). Double brackets [[ ]] mean "go to address, then get data at that address" - like a treasure map!

9. Interrupts

An interrupt is a signal sent from a device or software to the processor that causes it to temporarily stop what it is doing and service the interrupt.

9.1 Purpose and Role of Interrupts

📖 Why Interrupts are Used

9.2 Types of Interrupts

Type Definition Examples
Hardware Interrupts Generated by external devices Keyboard input, mouse movements, disk I/O
Software Interrupts Triggered by software or OS File requests, division by zero
Trap Interrupts Intentionally triggered by a program Debugging, handling unexpected errors

9.3 Interrupt Service Routine (ISR)

📖 What is an ISR?
📝 How Interrupts are Handled
  1. At end of each F-E cycle, processor checks for interrupt(s)
  2. Check if interrupt flag is set in interrupt register
  3. Identify source of interrupt and check priority
  4. If priority is high enough, save register contents to stack (PCB)
  5. Call Interrupt Service Routine (ISR)
  6. Address of ISR loaded into PC
  7. ISR code is executed
  8. When complete, restore registers from stack
  9. Re-enable lower priority interrupts
  10. Continue with next F-E cycle

9.4 Interrupt Priority and Nesting

📖 Priority Handling
HIGH PRIORITY Hardware Failure, Power Failure MEDIUM PRIORITY I/O Devices (Keyboard, Disk, Network) LOW PRIORITY Software Interrupts, User Applications Priority
⚠️ Important

If priority of interrupt is lower than current process, current process continues. Only higher priority interrupts will cause the processor to switch tasks. Proper management of nested interrupts avoids conflicts and ensures system stability.

Example: Keyboard Interrupt Handling
1. Interrupt flag raised in interrupt register
2. System finishes current F-E cycle
3. Check for higher priority interrupt
4. If none, save register contents to stack
5. Execute appropriate ISR
6. Restore registers from stack
7. Return to original process

10. Glossary

📖 Key Terms

ALU (Arithmetic Logic Unit) → Component that performs arithmetic and logic operations

Accumulator (ACC) → Register that stores results of ALU calculations

Address Bus → Unidirectional bus that carries memory addresses

Cache → Fast memory storing frequently used data close to CPU

Clock Speed → Number of cycles per second, measured in Hz

Control Bus → Bidirectional bus carrying control signals

Control Unit (CU) → Component that manages instruction execution and data flow

Core → Mini CPU with own CU, ALU, and registers

CIR (Current Instruction Register) → Stores instruction being decoded/executed

Data Bus → Bidirectional bus that carries data

Fetch-Execute Cycle → Process of fetching, decoding, and executing instructions

HDMI → Digital port for video and audio output

IAS (Immediate Access Store) → Another name for primary/RAM memory

Interrupt → Signal causing processor to stop and handle an event

ISR (Interrupt Service Routine) → Code that handles specific interrupt type

Index Register (IX) → Register used for indexed addressing

MAR (Memory Address Register) → Holds memory address for data access

MDR (Memory Data Register) → Stores data fetched from or to be written to memory

PC (Program Counter) → Holds address of next instruction to execute

Pipelining → Technique handling multiple instruction stages simultaneously

Register → Fast, small memory location inside CPU

RTN (Register Transfer Notation) → Notation describing data movement between registers

Status Register → Register containing flags showing processor state

USB → Universal Serial Bus - standard for device connection

VGA → Legacy analogue video port

Von Neumann Architecture → Computer design with stored program concept

Word Length → Number of bits CPU can process simultaneously

11. Exam-Style Questions

1. Describe the purpose of the Program Counter (PC) and explain how it is used during the fetch-execute cycle. [4 marks]

Answer:

  • PC holds the memory address of the next instruction to be executed
  • At start of fetch, PC value is copied to MAR
  • PC is incremented by 1 after address is copied
  • After instruction execution, PC contains address of next instruction
  • If jump instruction, PC is updated with new address from operand
  • Additional: PC ensures sequential execution of program instructions
2. Explain the differences between the address bus, data bus, and control bus. Include direction of data flow for each. [6 marks]

Answer:

  • Address Bus: Carries memory addresses; unidirectional (CPU to memory only)
  • Width determines maximum addressable memory locations
  • Data Bus: Carries data/instructions; bidirectional (both directions)
  • Wider data bus allows larger word lengths to be transferred
  • Control Bus: Carries control signals; bidirectional
  • Transmits timing signals and read/write commands
  • Additional: Control bus is typically 8 bits wide; carries synchronization signals
3. Describe how cache memory improves CPU performance. Include the different levels of cache. [5 marks]

Answer:

  • Cache stores frequently used data and instructions
  • Located closer to CPU than RAM, so faster access
  • Uses SRAM (faster) while main memory uses DRAM
  • L1 cache: Inside each core, fastest, smallest
  • L2 cache: Near each core, fast, medium size
  • L3 cache: Shared by all cores, slower, largest
  • Additional: More cache = less time waiting for data from RAM
4. Explain what happens when an interrupt is received by the CPU. [6 marks]

Answer:

  • At end of F-E cycle, CPU checks for interrupts
  • Interrupt flag is checked in interrupt register
  • CPU identifies source and priority of interrupt
  • If priority high enough, register contents saved to stack
  • CPU calls Interrupt Service Routine (ISR)
  • ISR address loaded into PC, ISR code executed
  • After ISR completes, registers restored from stack
  • Additional: Lower priority interrupts may be disabled during high-priority ISR
5. Compare HDMI and VGA ports, giving advantages and disadvantages of each. [5 marks]

Answer:

  • HDMI: Digital signal; carries video AND audio; higher resolution (4K/10K)
  • HDMI uses HDCP for content protection; modern standard
  • VGA: Analogue signal; video only; max 640×480 resolution
  • VGA prone to signal loss over long cables; being phased out
  • HDMI is current standard; VGA is legacy technology
  • Additional: HDMI supports faster refresh rates and more colors

11. Exam-Style Questions (Continued)

6. Describe the role of the ALU and the Control Unit within the CPU. [6 marks]

Answer:

  • ALU (Arithmetic Logic Unit):
  • Performs arithmetic operations (add, subtract, multiply, divide)
  • Performs logic operations (AND, OR, NOT, XOR)
  • Carries out operations while program is running
  • Control Unit (CU):
  • Reads and decodes instructions from memory
  • Generates control signals along control bus
  • Ensures synchronization of data flow
  • Additional: ALU results stored in Accumulator; CU controls all CPU operations
7. Write the fetch stage of the fetch-execute cycle using Register Transfer Notation (RTN). [4 marks]

Answer:

  • MAR ← [PC] : Copy address from PC to MAR
  • MDR ← RAM[MAR] or MDR ← [[MAR]] : Read instruction from memory
  • PC ← [PC] + 1 : Increment PC for next instruction
  • CIR ← [MDR] : Copy instruction to CIR
  • Additional: Double brackets [[MAR]] mean "data at address stored in MAR"
8. Explain how increasing the number of cores affects CPU performance. Give one reason why performance doesn't double with dual-core. [5 marks]

Answer:

  • Each core acts like a mini CPU with own CU, ALU, registers
  • More cores allow parallel processing - multiple instructions simultaneously
  • Theoretical speed = number of cores × clock speed
  • Dual-core can process two instruction streams at once
  • Performance doesn't double because:
  • Time needed to organize tasks between cores (overhead)
  • Not all tasks can be split across cores (sequential tasks)
  • Operating system must support multi-threading
  • Additional: Quad-core at 2.2 GHz = 8.8 GHz theoretical; dual-core at 4.2 GHz = 8.4 GHz
9. Describe the stored program concept and explain why it was revolutionary. [4 marks]

Answer:

  • A stored-program computer keeps programmed instructions in RAM along with data
  • Previously, data and programs were stored in separate memories
  • Von Neumann realized data and programs are same type - can use same memory
  • Instructions can be executed in sequential order
  • Revolutionary because programs could be changed without hardware modification
  • Additional: This is the foundation of modern general-purpose computers
10. Explain four factors that affect CPU performance. Describe how each factor influences performance. [8 marks]

Answer:

  • 1. Clock Speed: Higher speed = more instructions per second; measured in GHz
  • Each instruction executed on clock pulse; faster clock = more F-E cycles per second
  • 2. Number of Cores: More cores = parallel processing of multiple instructions
  • Each core has own CU, ALU, registers; enables multitasking
  • 3. Cache Size: Larger cache = more frequently used data stored nearby
  • Reduces time CPU waits for data from RAM; L1 fastest, L3 largest
  • 4. Bus Width: Wider bus = more bits transferred per operation
  • Wider data bus = larger word length; wider address bus = more addressable memory
  • Additional: All factors work together; improving one doesn't guarantee better overall performance

12. Exam Success Tips (Part 1)

💡 Register Names - Must Know
💡 Buses - Direction Matters!
💡 Cache Levels - Speed vs Size
💡 F-E Cycle Order

12. Exam Success Tips (Part 2)

⚠️ Common Mistakes to Avoid
🧠 Memory Tricks
💡 Ports Quick Reference
💡 Interrupt Handling Steps
  1. Check for interrupt at end of F-E cycle
  2. Identify source and priority
  3. Save registers to stack
  4. Execute ISR
  5. Restore registers
  6. Continue normal operation

12. Exam Success Tips (Part 3)

💡 Answer Structure Tips
🌟 Quick Reference Table
Topic Key Point
Von Neumann Stored program - data + instructions in same memory
ALU Arithmetic + Logic operations
CU Controls and synchronizes all operations
Clock Speed More cycles = more instructions per second
Cores Parallel processing, not always double speed
Cache L1 fastest/smallest, L3 slowest/largest
F-E Cycle Fetch → Decode → Execute
Interrupts Priority-based, handled by ISR
📌 Final Exam Reminders