Fetch-Decode-Execute Simulator

The Central Processing Unit (CPU) is the brain of the computer that continuously runs programs by repeating the Fetch-Decode-Execute cycle. Internal registers and system buses coordinate to retrieve instructions from RAM, decode opcodes, and execute operations.

Programme:
RAM View:
Speed:
Cycle 1 • Standby Instr: Ready [LOAD 05]
1. FETCH ➔ 2. DECODE ➔ 3. EXECUTE
FETCH STAGE

Fetch 1: Copy PC Address to MAR

How the CPU Actually Works (Key Registers & Theory)

The Central Processing Unit (CPU) is the computer's engine. Every second, it repeats the Fetch-Decode-Execute cycle billions of times: fetching an instruction from memory, decoding what it means, and executing it.

The Desk Analogy (Registers vs RAM): RAM is like a massive library down the street—it holds everything, but fetching from it takes time. Registers are like sticky notes right on your desk. Ultra-fast, but each only holds one tiny piece of data.
Key Registers to Remember:
• PC (Program Counter): Address of the NEXT instruction.
• MAR: Address in RAM we are reading/writing.
• MDR: Holds data/instruction fetched from or sent to RAM.
• CIR: Holds instruction currently being decoded and executed.
• ACC (Accumulator): Holds temporary calculation results.
Under The Hood: Live Register State & Full 32-Cell RAM Inspector
Live Register State Watch AQA Core 4
Reg Full Name Denary Hex Role
PC Program Counter 00 0x00 Holds address of NEXT instruction
MAR Mem Address Reg 00 0x00 Holds RAM address to read/write
MDR Mem Data Reg --- --- Holds data/instruction fetched from RAM
CIR Current Instr Reg --- --- Holds active instruction while decoded & executed
ACC Accumulator 0 0x00 Stores temporary calculation results
Full 32-Cell RAM Inspector 32 Addressable Words
Addr Contents Type
Exam Mark Scheme Phrasing Reference:

"The contents of the Program Counter (PC) are copied to the Memory Address Register (MAR) via the address bus."

CPU Performance Factors

A CPU's processing speed is determined by clock speed (F-D-E cycles per second), cache size (ultra-fast onboard memory), and number of processor cores (independent execution units). Doubling cores does not always double performance due to software limits and inter-core communication.

Select Software Scenario:
Single-Threaded Task
Hardware Settings:
1
Clock Speed
F-D-E cycles / second
3.0 GHz
1.0 GHz (Cool) 4.5 GHz (High Heat)
2
CPU Cores
Independent ALUs & CUs
2 Cores
3
Cache Size
High-speed SRAM capacity
4 MB
4
Placement
Silicon physical proximity
On-Die
Visualizing instruction pulses, cache hit/miss latency, and core state
Found in Cache (<1ns) — Instant retrieval from fast on-chip SRAM, core never pauses
Not in Cache (Trip to RAM ~70ns) — Core freezes while packet fetches from slow off-chip DRAM
Clock Pulse — Heartbeat frequency driving F-D-E cycles
Interconnect Highway — On-chip copper bus tracks

Overall CPU Execution Speedometer

How fast your CPU configuration crunches tasks compared to a standard 1.0 GHz single-core computer (1.0× baseline).

5.4×
Faster Than Baseline PC
Throughput: 5,400 MIPS
Fast
1× (Base) 4× 8× 12× (Max)
NOTE Hardware Performance Note
Adjust hardware settings to see how clock speed, cores, and cache interact.
Overall Speed High Speed
5.2× Baseline
vs 1.0 GHz Single-Core PC (~5,200 MIPS)
Execution Rate Smooth
60 FPS
Task execution rate
Found in Fast Cache On-Chip Cache
92% Found
Grabbed in <1ns (Only 8% slow RAM trips)
Core Efficiency Low Stall
88% Working
12% cycles lost waiting for RAM
Specification Core

The Three Major CPU Performance Factors — Exam Essentials

1
Clock Speed — The CPU Heartbeat

Clock speed is measured in Hertz (Hz or GHz) and represents the frequency of electrical pulses generated by the system clock. 1 GHz equals one billion Fetch-Decode-Execute cycles every single second. A higher clock frequency allows the CPU to process more instructions per second, leading to faster program execution.

Exam Warning: Higher clock speeds consume substantially more electrical power and generate intense heat. If cooling systems cannot dissipate this heat fast enough, the CPU automatically throttles down (slows its frequency) to prevent permanent hardware damage.
2
Cache Memory — On-Chip Desk vs Off-Chip Library

Cache is high-speed Static RAM (SRAM) constructed directly on the CPU silicon die, providing sub-nanosecond access latency. Frequently used instructions and data are kept here. When data is found in cache (a Cache Hit), the processor retrieves it immediately without pausing. Main memory (RAM) is located across the motherboard bus and takes roughly 70ns. When data is missing from cache (a Cache Miss), the CPU must stall and wait for bus transfer.

Exam Tip: A computer cannot simply replace all RAM with 64 GB of cache because SRAM requires multiple transistors per bit, making it physically too large for a silicon die and far too expensive to manufacture at scale.
3
Number of Cores — Parallel Processing

Each CPU core contains its own independent Arithmetic Logic Unit (ALU), Control Unit (CU), and internal registers. A quad-core processor can execute four distinct instructions simultaneously.

Key Exam Trap — Why doubling cores does not simply double speed:
  • Software must be written for multithreading; single-threaded programs can only run on one core while remaining cores stay completely idle.
  • Thread coordination and core-to-core communication introduce management overhead.
  • All cores contend for the same shared memory bus, shared cache levels, and RAM bandwidth.
Advanced Extension

Beyond GCSE — How Modern CPUs Eliminate Idle Stalls

In a classic Fetch-Decode-Execute design, functional sub-units (such as the ALU or instruction decoder) frequently sit completely idle while waiting for high-latency memory or conditional outcomes. Modern high-performance processors use advanced hardware engineering to keep execution units continuously busy:

Branch Prediction and Speculative Execution

When a program reaches an IF / ELSE condition or loop, the CPU encounters a branch. Rather than sitting idle waiting for the condition to be calculated, modern CPUs predict which path the code will take (often with over 95% accuracy) and execute instructions ahead of time along the predicted path. If the prediction is verified correct, execution proceeds without delay. If incorrect, the speculative work is discarded and the pipeline restarts on the correct path.

Instruction Pipelining

Operating like an industrial assembly line, the CPU divides instruction processing into overlapping stages. While instruction 1 is in the Execute stage, instruction 2 is simultaneously being Decoded, and instruction 3 is already being Fetched from cache. This overlap ensures every internal functional unit performs work on every single clock cycle.

Out-of-Order Execution (OoO)

When an instruction stalls awaiting data from slow system RAM, modern processors do not freeze the entire core. Hardware schedulers scan forward in the instruction queue, identify later instructions that do not depend on the missing data, and execute them out of original program order to prevent wasted clock cycles.

Storage & Memory — Primary vs Secondary

Computers need primary memory (RAM) for fast, volatile working memory while programs run, and non-volatile secondary storage (SSD, HDD, optical) to retain data permanently when powered down. Virtual memory uses secondary storage as temporary overflow when RAM fills up.

Primary Storage: RAM vs ROM Interactive Comparator

System Power:

Primary storage consists of memory chips directly connected to the CPU via high-speed memory buses. Use the power switch above to test volatility, and try writing to both chips below.

RAM (Random Access Memory)

Direct working workspace for active CPU execution
Active • Power Supplied
Volatile (Needs Power) Read & Write Typical: 8 GB – 32 GB
Addressable Memory Slots 4/4 Slots Active

ROM (Read-Only Memory)

Permanent factory-burned firmware for system startup
Firmware Preserved
Non-Volatile (Permanent) Read-Only Typical: 4 MB – 16 MB
Factory Burned ROM Firmware Immutable
Status: Power supplied. RAM actively holding OS, Chrome, Spotify, and current document. ROM firmware standing by.
Feature RAM (Random Access Memory) ROM (Read-Only Memory)
Volatility Volatile — loses all contents instantly if power is cut. Non-volatile — data is permanently retained with zero power.
Read / Write Read and Write — CPU continuously writes, edits, and reads data at nanosecond speeds. Read-Only — Burned into semiconductor circuits at the factory. CPU can only read.
What It Stores The active Operating System, running applications, and currently open files/documents. The BIOS / UEFI firmware and the Bootstrap Loader needed to start the computer.
Capacity Large: Typically 8 GB to 64 GB in modern laptops/desktops. Small: Typically 4 MB to 16 MB (just enough for firmware).

Why Secondary Storage is Essential

The CPU can only directly fetch instructions from Primary Storage (RAM & Cache). However, a computer with only RAM and ROM would be practically useless for two critical reasons:

1. RAM is Volatile (Data Retention)

Because RAM requires a continuous electrical charge to refresh its capacitors, all data is permanently lost when the computer powers off or sleeps. Secondary storage is non-volatile, keeping your operating system, installed software, games, photos, and saved work permanently preserved for decades.

2. Capacity & Cost Constraints

High-speed RAM is physically complex and expensive per gigabyte. A typical system has 16 GB of RAM, but a single modern game or video library can require hundreds of gigabytes. Secondary storage provides massive terabyte storage at a tiny fraction of the cost per gigabyte.

Secondary Storage Simulation: HDD vs SSD Workbench

Switch between magnetic and solid-state storage to see the difference between mechanical latency and semiconductor speeds. Test file fragmentation, defragmentation, and discover how deleted files really work!

Magnetic Hard Drive Platter 7,200 RPM
Move mouse over tracks, sectors, spindle, or actuator head to inspect hardware components.
File A (game_levels.pak)
File B (vacation_clip.mp4)
File C (notes.txt)
File D (save_data.dat)
Free Sectors
Arm Seek Time 0.0 ms
Rotational Delay 0.0 ms
Total Read Latency 0.0 ms
Head Track Jumps 0
File Allocation Table (FAT / Index) File Pointers
File Name Sector Chain Status
Hard Drive Latency: An HDD has moving parts. To read a fragmented file, the mechanical actuator arm must physically swing across concentric tracks (Seek Time), and the head must wait for sectors to spin underneath (Rotational Latency).
Live Speed Benchmark

File Read Speed: Fragmented HDD vs Defragged HDD vs Solid-State Drive (SSD)

Normalized Read Latency
1. Fragmented HDD (Mechanical Arm Jumping) 14.2 ms • Slow
Arm jumped 3 tracks physically; waited for 4 distinct rotational disc delays.
2. Defragmented HDD (Single Smooth Track) 2.4 ms • ~6× Faster
Head stays steady on Track 0; all sectors read contiguously in one 360° spin.
3. Solid-State Drive (SSD) (Multichannel Electrical Bus) 0.08 ms • 175× Faster!
Pure electronic voltage bus; zero moving parts, zero mechanical latency.

Comparing Secondary Storage: Magnetic vs Solid-State vs Optical

Exam questions frequently ask you to recommend a storage type for a specific real-world scenario (e.g. an action camera, a backup server, or distributing software). You must evaluate across these 6 key characteristics:

Characteristic Magnetic (HDD / Tape) Solid-State (SSD / USB Flash) Optical (CD / DVD / Blu-Ray)
1. Capacity Very High: 1 TB to 20+ TB. Massive storage for servers and backups. High: 256 GB to 8 TB. Plenty for OS, software, and games. Low: CD: 700 MB, DVD: 4.7 GB, Blu-ray: 25–50 GB.
2. Speed (Read/Write) Moderate: ~150 MB/s. Slower due to physical seek time and rotation. Very Fast: 500 MB/s to 7,000+ MB/s (NVMe). Instant access. Very Slow: ~10–30 MB/s. Mechanical laser tracking.
3. Portability Low: Bulky, heavy, requires delicate handling and SATA/USB cables. Excellent: Tiny, lightweight (M.2 sticks, USB flash thumb drives). High: Flat, lightweight discs, easily posted in envelopes.
4. Durability Poor: Dropping an HDD while running causes a catastrophic head crash. Very High: Shock-resistant. No moving parts to break if dropped. Moderate: Easily scratched or warped by sunlight and heat.
5. Reliability High: Excellent long-term retention if kept stationary and cool. High: Highly reliable, though cells have a finite write cycle limit. Low–Moderate: Discs can degrade or scratch after repeated handling.
6. Cost per GB Very Cheap: Around £0.015 per GB. Best for mass data archives. Moderate: Around £0.06 per GB. More expensive per gigabyte. Very Cheap per Unit: Pennies per blank disc, but low capacity.

CPU Architecture Revision & Exam Traps

Core definitions, architecture rules, and exam traps for Paper 2 (§3.4). Master the Von Neumann model, register roles, CPU performance factors, primary memory, and secondary storage technologies.

Key Exam Traps & Core Concepts

EXAM TRAP 1: REGISTERS

Never Confuse the MAR and the MDR

This is one of the most frequently lost marks on GCSE Computer Science papers. Remember their exact roles:

MAR (Memory Address Register):
• Holds the memory address (location) where data or an instruction is to be fetched from or written to.
• Connected to the Address Bus.
MDR (Memory Data Register):
• Holds the actual data value or instruction that has been read from RAM or is waiting to be written to RAM.
• Connected to the Data Bus.
Memory Hook: MAR = Address (where to look); MDR = Data (what was found).
EXAM TRAP 2: CPU PERFORMANCE

Why More Cores Does Not Guarantee Faster Performance

A common exam question asks why a quad-core CPU will not run four times faster than a single-core CPU:

• Software Parallelism: Many programs are written sequentially (Step 2 depends on Step 1). Extra cores remain idle if software cannot be split into concurrent threads.
• Overhead & Communication: The operating system must coordinate and synchronise threads across cores, consuming clock cycles.
• Resource Contention: All cores share the same memory bus and RAM. Accessing RAM creates a bottleneck.
SPECIFICATION §3.4.1

The Stored Program Concept (Von Neumann)

Key Definition: In the Von Neumann architecture, both program instructions and data are stored together in the same physical memory (RAM) and fetched across shared system buses. Instructions are executed sequentially unless an explicit branch occurs.
PRIMARY MEMORY TRAP

Never Confuse RAM and ROM

Both are primary storage chips directly wired to the CPU, but their physical characteristics are opposites:

RAM (Random Access Memory):
• Volatile: Needs constant electrical power; wipes completely on shutdown.
• Read & Write: CPU continuously loads and modifies active apps, OS code, and open files.
ROM (Read-Only Memory):
• Non-Volatile: Retains data permanently when powered off.
• Read-Only: Factory burned. Stores BIOS/UEFI firmware and the Bootstrap Loader.
SECONDARY STORAGE ESSENTIALS

Why Secondary Storage is Needed & 6 Assessment Factors

RAM is volatile (temporary) and small in capacity. Secondary storage is non-volatile and provides high-capacity, long-term file retention.

The 6 Factors for Comparing Media:
1. Capacity: HDD (Huge TBs) > SSD (High GBs/TBs) > Optical (CD 700MB, DVD 4.7GB, BD 25GB).
2. Speed: SSD (instant, 500–7000 MB/s) > HDD (150 MB/s, physical seek) > Optical (~15 MB/s).
3. Portability: SSD/USB flash (small, light) > Optical discs > HDD (heavy, bulky).
4. Durability: SSD (shockproof) > Optical (scratches easily) > HDD (fragile head crash if dropped).
5. Reliability: SSD & HDD (high when treated well) > Optical (laser dye degrades).
6. Cost per GB: Optical & HDD (pennies per GB) vs SSD (higher cost per GB).
UTILITY SOFTWARE & EXAM TRAP

Defragmentation (HDD) vs Why You NEVER Defrag an SSD

A frequent exam question explores how file fragmentation affects performance:

• On a Magnetic HDD: Files become scattered across non-contiguous sectors over time. The mechanical arm must swing back and forth (seek time) to read all blocks, slowing down the drive. Defragmentation reorganises sectors contiguously so the file can be read in a single smooth rotation.
• On an SSD: Access time to any flash cell is identical (instant electrical pulse, zero seek time). Non-contiguous blocks do not slow it down. Furthermore, flash cells have a finite number of write cycles (P/E wear). Defragmenting an SSD needlessly writes gigabytes of data, wearing out the flash cells prematurely!

Exam Style Questions with Mark Schemes

F-D-E Cycle • 4 Marks

Q1: Describe the role of the Program Counter (PC) and the Memory Address Register (MAR) during the fetch stage of the fetch-decode-execute cycle.

[1 mark] The Program Counter (PC) holds the address of the next instruction to be fetched from memory.
[1 mark] The address stored in the PC is copied into the Memory Address Register (MAR).
[1 mark] The PC is incremented by 1 (to point to the subsequent instruction).
[1 mark] The MAR places the memory address on the Address Bus to locate the instruction in RAM.
Performance • 3 Marks

Q2: A computer manufacturer claims that an 8-core CPU will execute programs four times faster than a dual-core (2-core) CPU with the same clock speed. Explain why this claim is not true in practice.

[1 mark] Software may not be optimised for multi-threading / tasks may be sequential where one step requires the result of a previous step.
[1 mark] Core management / coordination overhead from the operating system reduces efficiency.
[1 mark] Shared hardware bottlenecks: all cores must share access to memory bus and RAM, causing waiting/stalls.
Hardware • 3 Marks

Q3: Explain what cache memory is and why having more cache memory improves CPU performance.

[1 mark] Cache is very fast, small memory located on (or extremely close to) the CPU chip.
[1 mark] It stores frequently or recently used instructions and data.
[1 mark] Accessing cache is much faster than fetching from RAM, reducing CPU idle waiting time.