5 missions. Guess, learn, then check. Your place is saved.
Mission 1ENIAC took days to reprogram. Your phone swaps apps instantly. Why?
Mission 2Double the cores. Why isn't the computer twice as fast?
Mission 3Pull the plug and unsaved work is gone. So how does it boot?
Mission 4One storage firm runs 300,000+ spinning hard disks. Why not SSDs?
Mission 5How does your data find one computer among billions online?
The specification points and sources are listed under the lesson: see Sources.
Mission 1
ENIAC took days to reprogram. Your phone swaps apps instantly. Why?
Make a guess: ENIAC took days to reprogram. Your phone swaps apps instantly. Why?
Hardware · the CPU
Programs live in memory
A program is a list of instructions in binary (machine code), processed by the CPU.
A running program's instructions and data are both held in main memory (RAM). This is the Von Neumann architecture.
New program? Load new instructions into memory. Nothing is rewired.
Input devices send data in; output devices present results; secondary storage keeps programs when they are not running.
Hardware · the CPU
Inside the CPU
Component
What it does
Control unit (CU)
Decodes instructions and sends control signals to coordinate the other parts
Arithmetic logic unit (ALU)
Carries out calculations and logical operations, such as comparisons
Program counter (PC)
Holds the address of the next instruction
Memory address register (MAR)
Holds the address in memory to be read from or written to
Memory data register (MDR)
Holds the data or instruction just read from memory, or about to be written
Accumulator (ACC)
Holds the result of calculations done by the ALU
The current instruction register (CIR) holds the instruction being decoded and executed.
An address says where something is; data is what is stored there.
A microprocessor is a CPU on a single integrated circuit (chip).
Hardware · the CPU
Buses
A bus is a set of parallel wires carrying signals between the CPU, main memory and other components.
The address bus carries memory addresses from the CPU to memory. It only goes one way.
The data bus carries data and instructions between the CPU and memory, in both directions.
The control bus carries control signals, such as "read" or "write" and clock pulses, to coordinate components.
Hardware · the CPU
The cycle that never stops
Kept in step by the clock, the CPU repeats the fetch–decode–execute (FDE) cycle billions of times a second.
Stage
What happens
Fetch
The address in the PC is copied to the MAR and sent along the address bus to RAM. The CU sends a read signal on the control bus. The instruction returns on the data bus to the MDR and is copied to the CIR. The PC goes up by 1
Decode
The CU decodes the instruction in the CIR
Execute
The instruction is carried out: the ALU may do a calculation, with the result stored in the ACC, or data may be read from or written to RAM using the MAR and MDR
The instruction set is the list of all the machine code commands a CPU can process.
Quick check
?An instruction says "add the number stored at address 12 to the total". In which stage is the number at address 12 read from memory?
Your answer
?At the start of the fetch stage, the address in the program counter is copied into which register?
Hardware · the CPU
Embedded systems
An embedded system is a computer built into a larger device to do one dedicated job.
Usually small, cheap, low power and reliable. Its program is stored permanently, often in ROM.
A general-purpose computer, such as a PC or laptop, runs many different programs.
Quick check
?Which of these is not an embedded system?
Mission check
?ENIAC took days to reprogram. Why can your phone swap apps instantly?
ENIAC's program was set by its wiring, so a new job meant rewiring. In your phone, programs are stored in memory as instructions, just like data. The CPU fetches, decodes and executes whatever instructions are there, so switching apps just means running different instructions.
Mission 2
Double the cores. Why isn't the computer twice as fast?
Make a guess: Double the cores. Why isn't the computer twice as fast?
Hardware · CPU performance
Clock speed
The clock sends out regular electrical pulses that keep the CPU's parts in step.
Clock speed is the number of clock cycles per second, measured in hertz (Hz).
1 GHz = 1,000,000,000 cycles per second, so 3.5 GHz is 3.5 billion.
Higher clock speed: more fetch–decode–execute cycles each second, so more instructions are processed.
Calculate
?A CPU has a clock speed of 2.8 GHz. How many clock cycles does it complete each second?
cycles per second
Hardware · CPU performance
Cores
A core is a complete processing unit. Each core can fetch, decode and execute instructions on its own.
A dual-core CPU can process two instructions at the same time; a quad-core CPU, four.
Doubling the cores rarely doubles the speed: some tasks cannot be split, and one core may wait for another's result.
Software must be written to use several cores.
Hardware · CPU performance
Cache
Cache is a small amount of very fast memory on or very near the CPU.
It holds frequently used instructions and data, saving slower trips to RAM.
A larger cache holds more, so the CPU waits less. But cache is expensive, so it stays small.
Quick check
?Sam's CPU often waits for data from RAM. The same small set of instructions is used again and again. Which upgrade is most likely to help?
Quick check
?A game only ever uses one core. Which CPU will run it fastest, if everything else is the same?
Mission check
?Double the cores. Why isn't the computer twice as fast?
Each core can run instructions at the same time as the others, but only if the work can be split between them. Tasks that can't be split, or where one core must wait for another's result, gain little, so doubling the cores rarely doubles the speed.
Mission 3
Pull the plug and unsaved work is gone. So how does it boot?
Make a guess: Pull the plug and unsaved work is gone. So how does it boot?
Hardware · primary memory
Primary storage
Primary storage (main memory) is memory the CPU can access directly.
It holds the instructions and data the CPU is using now. Secondary storage is too slow for the CPU to work from directly.
Main memory is made up of RAM and ROM.
Hardware · primary memory
RAM
RAM (random access memory) holds the operating system, the programs that are open and the data they are using.
The CPU can read and write RAM, so its contents change all the time.
RAM is volatile: its contents are lost when the power is switched off. That is why unsaved work disappears.
More RAM lets more programs and data be open at once without slowing down.
Hardware · primary memory
ROM
ROM (read-only memory) is non-volatile: it keeps its contents with the power off.
It can only be read. Its contents cannot normally be changed.
ROM holds the start-up instructions (the BIOS or boot program). They load the operating system from secondary storage into RAM.
RAM
ROM
Keeps data with power off?
No (volatile)
Yes (non-volatile)
Can be changed?
Read and write
Read only
Holds
Operating system, open programs and data in use
Start-up instructions
Size
Gigabytes
Small
Quick check
?A washing machine's wash programs must never be lost and must not be changed by the user. Where should they be stored?
Hardware · primary memory
Virtual memory
When RAM is full, the operating system uses part of secondary storage as virtual memory.
Data and programs not needed right now are moved out of RAM to virtual memory in blocks called pages, freeing space.
When they are needed again, pages are swapped back into RAM.
Secondary storage is much slower than RAM, so heavy swapping slows the computer down. Adding more RAM is the fix.
Quick check
?A computer has many apps open and becomes very slow when switching between them. What is the most likely cause?
Your answer
?What word describes memory that loses its contents when the power is switched off?
Mission check
?Pull the plug and unsaved work is gone. So how does it boot?
Your essay was in RAM, which is volatile, so it vanished. The start-up instructions are in ROM, which is non-volatile, so they are still there. They load the operating system from secondary storage into RAM, and the computer is ready again.
Mission 4
One storage firm runs 300,000+ spinning hard disks. Why not SSDs?
Make a guess: One storage firm runs 300,000+ spinning hard disks. Why not SSDs?
Hardware · secondary storage
Why secondary storage?
Secondary storage is non-volatile: it keeps the operating system, programs and files with the power off.
It holds far more than RAM, for much less money per gigabyte.
The CPU does not access it directly. Programs and data are copied into RAM (main memory) first.
To choose a device, compare its capacity, speed, portability, durability, reliability and cost.
Hardware · secondary storage
Magnetic storage
A hard disk drive (HDD) stores data on spinning magnetic platters.
Platters are divided into circular tracks, split into sectors.
A moving read/write head uses an electromagnet to magnetise tiny areas (one way for 1, the other for 0) and to read them.
Moving parts: slower, and easily damaged if dropped. But huge and cheap per gigabyte.
Hardware · secondary storage
Solid-state storage
Solid-state storage uses flash memory: electrical circuits that keep data with the power off. No moving parts.
Flash uses NAND or NOR technology. Transistors act as control gates and floating gates; trapped electrons store the bits.
Examples: SSD (solid-state drive), SD card, USB flash drive.
Fast, light, low power and robust. But it costs more per gigabyte, and cells wear out after many rewrites.
Hardware · secondary storage
Optical storage
A laser reads the surface of a spinning disc. Pits and lands reflect the light differently, giving 1s and 0s.
To write, a laser changes the surface of a recordable disc.
Examples: CD (about 700 MB), DVD (4.7 GB), Blu-ray (25 GB per layer).
Cheap and light to post, but low capacity, slow and easily scratched. Downloads and flash drives have largely replaced it.
Calculate
?A 4,000 GB hard disk costs £80. A 2,000 GB SSD costs £120. How many times more does the SSD cost per gigabyte?
Hardware · secondary storage
Cloud storage
Cloud storage keeps your files on servers at a remote location, reached over the internet. The servers use magnetic and/or solid-state storage.
Advantages: access from any device, anywhere; easy sharing; the provider handles backups and maintenance; buy more space when needed.
Disadvantages: no internet, no access; slow connections mean slow transfers; ongoing fees; you rely on the provider to keep data secure and private.
Quick check
?A school is choosing between cloud storage and its own local file server. Which is a disadvantage of the cloud?
Quick check
?A travel photographer copies 60 GB of photos a day to a small device kept loose in a rucksack. Which is the best choice?
Mission check
?One storage firm runs 300,000+ spinning hard disks. Why not SSDs?
When you store vast amounts of data, cost per gigabyte matters most. Hard disks give far more capacity for the money. SSDs are faster and tougher, so they are used where speed matters, such as in laptops.
Mission 5
How does your data find one computer among billions online?
Make a guess: How does your data find one computer among billions online?
Networks · hardware and addresses
IP addresses
An IP address identifies a device on a network, so data can be sent to it. Every packet carries a destination IP address.
An IPv4 address is 32 bits, written as four denary numbers from 0 to 255 separated by dots, e.g. 192.168.0.12. Each number is one byte (8 bits).
The network allocates IP addresses. A static one never changes; a dynamic one may change at each connection.
Quick check
?Which of these is a valid IPv4 address?
Networks · hardware and addresses
Routers
A router connects networks together, for example a home or school LAN to the internet.
The internet is a vast number of networks joined by routers.
A router reads each packet's destination IP address and sends it to the next router on a route towards it. Hop by hop, the packet reaches the right network.
A router can also assign IP addresses to devices on its network.
Quick check
?A packet arrives at a router in the middle of the internet. What does the router use to decide where to send it next?
Your answer
?A computer stores an IPv4 address in binary: 11000000.10101000.00000001.00001010. Write it in the usual dotted denary form.
Networks · hardware and addresses
IPv6
IPv4 gives about 4.3 billion addresses (2³²): too few for every phone, laptop and smart device.
IPv6 was created to give far more. It is 128 bits, written as eight groups of four hexadecimal digits separated by colons, e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
IPv4
IPv6
Size
32 bits
128 bits
Written as
4 denary numbers, 0–255, with dots
8 groups of 4 hex digits, with colons
Number of addresses
About 4.3 billion
About 3.4 × 10³⁸
Networks · hardware and addresses
MAC addresses
A device needs a NIC (network interface card) to join a network.
Each NIC is given a MAC address at manufacture: 48 bits, written as 12 hex digits in six pairs, e.g. 00:1A:2B:3C:4D:5E.
The first half is the manufacturer code; the second half is the serial code.
MAC addresses identify devices within a LAN. A MAC address stays the same; an IP address can change.
Quick check
?A technician sees the address 3C:52:82:1F:A0:6B on a laptop. What kind of address is it?
Mission check
?How does your data find one computer among billions online?
Every device online has an IP address, and every packet carries its destination IP address. The internet is many networks joined by routers; each router reads that address and forwards the packet one hop closer, until it reaches the right network and the right device.
Recap
Big ideas
Instructions and data are both stored in main memory; the CPU fetches, decodes and executes them, one after another, kept in step by the clock.
Registers do specific jobs: the PC and MAR hold addresses; the MDR, CIR and ACC hold data or instructions.
The address bus carries addresses, the data bus carries data and instructions, the control bus carries control signals.
An embedded system is a computer inside a larger device that does one dedicated job.
Higher clock speed means more cycles, and so more instructions, every second.
More cores help only when the work can be split; a larger cache means fewer slow trips to RAM.
RAM is volatile and holds what is in use now; ROM is non-volatile and holds the start-up instructions.
When RAM is full, virtual memory on secondary storage takes the overflow, but swapping is slow.
Secondary storage is non-volatile and keeps data for the long term; choose it by capacity, speed, portability, durability, reliability and cost.
Magnetic: huge and cheap per gigabyte, but moving parts. Solid state: fast and robust, but dearer per gigabyte.
Optical discs are read by a laser (pits and lands): cheap but low capacity.
Cloud storage is on remote servers: access anywhere, but only with an internet connection.
An IP address identifies a device on a network. Routers read each packet's destination IP address and forward it hop by hop.
IPv4 is 32 bits (four numbers, 0–255); IPv6 is 128 bits in hex, giving far more addresses.
A MAC address is a 48-bit hex address fixed in a NIC when it is made, used to find devices within a LAN.
🏆
Mini-lesson complete!
⭐⭐⭐
You've worked through Hardware for Cambridge IGCSE Computer Science (0478/0984). 🎉
Mission 1ENIAC took days to reprogram. Your phone swaps apps instantly. Why?
Mission 2Double the cores. Why isn't the computer twice as fast?
Mission 3Pull the plug and unsaved work is gone. So how does it boot?
Mission 4One storage firm runs 300,000+ spinning hard disks. Why not SSDs?
Mission 5How does your data find one computer among billions online?