The CPU and von Neumann architecture
Every program, from a game to a calculator, is a long list of simple instructions. The CPU processes instructions and data by repeating the fetch–decode–execute cycle. In the von Neumann model, instructions and data are stored together in the same main memory. Registers are small, very fast stores inside the CPU.
Everything inside the large box is the CPU. Main memory sits outside it, joined by the address, data and control buses.
Inside the CPU
Name each part and state its purpose.
| Component | Purpose |
|---|---|
| ALU · arithmetic logic unit | Does the arithmetic (e.g. adding) and the logic (e.g. comparing two values). |
| CU · control unit | Decodes each instruction and sends control signals that coordinate the other components. |
| PC · program counter | Points to the next instruction: it stores that instruction’s address in memory. |
| MAR · memory address register | Stores the address in RAM that is about to be read or written. |
| MDR · memory data register | Stores whatever has just come from RAM, or is about to go to RAM: data or an instruction. |
| CIR · current instruction register | Part of the CU: holds the instruction currently being decoded and executed. |
| ACC · accumulator | Built into the ALU: holds the interim results of its calculations. |
Three buses
What each one carries, and which way.
| Bus | Carries | Direction |
|---|---|---|
| Address bus | memory addresses | one way: CPU → memory |
| Data bus | data and instructions | both ways |
| Control bus | control signals, e.g. a read or write signal | both ways |
A microprocessor is a CPU built as an integrated circuit on a single chip.
1 Which register holds the address of the next instruction?
2 What does the ALU do?
3 Which bus carries memory addresses, and in which direction?
- 1The PC (program counter).
- 2It does the arithmetic (e.g. adding) and the logic (e.g. comparing two values).
- 3The address bus, one way: from the CPU to memory.
Fetch: from memory to the CIR
To run an instruction, the CPU must first fetch it: location 200 holds ADD 202, and the PC holds 200.
An instruction cannot run while it sits in memory: the CPU must first fetch a copy of it. Here location 200 holds ADD 202, and the PC holds 200.
Follow the numbered marks 1 to 5. Each one is a step in the list under the drawing.
Who does what?
- The control unit coordinates every transfer using control signals.
- The system clock supplies pulses that coordinate the CPU’s operations.
- Buses carry the address, the instruction and the signals.
Register contents after each step
Each row shows only the value that step writes. A blank cell keeps its value from the row above.
| PC | MAR | MDR | CIR | What happened | |
|---|---|---|---|---|---|
| start | 200 | the PC holds the address of the next instruction | |||
| the PC holds the address of the next instruction | |||||
| step 1 | 200 | PC copied to the MAR | |||
| PC copied to the MAR | |||||
| step 2 | 201 | the PC is incremented | |||
| the PC is incremented | |||||
| step 3 | 200 sent on the address bus, with a read signal | ||||
| 200 sent on the address bus, with a read signal | |||||
| step 4 | ADD 202 | the instruction arrives on the data bus | |||
| the instruction arrives on the data bus | |||||
| step 5 | ADD 202 | MDR copied to the CIR | |||
| MDR copied to the CIR | |||||
1 The PC holds 350. What does it hold after the fetch is finished?
2 Which register receives the instruction from RAM first?
3 Which bus carries the address from the MAR to RAM?
- 1The PC is incremented during fetch, so it holds 351.
- 2The MDR.
- 3The address bus.
Decode and execute
ADD 202 is now in the CIR. The CPU decodes it to find out what to do, executes it, and the cycle repeats.
Fetching only brings a copy of the instruction into the CPU; nothing has been done yet. ADD 202 is now in the CIR. The CPU decodes it to find out what to do, executes it, and the cycle repeats.
Marks 6 and 7 carry on from the fetch: the CU splits ADD 202 into its parts, then the value at 202 comes in and the ALU adds it.
6 · Decode
- The fetched instruction is already in the CIR, inside the CU.
- The control unit decodes it, using the instruction set.
- It is split into the opcode (the operation to carry out) and the operand (the data, or where the data is stored).
7 · Execute
- The CU sends signals from the CIR to the ALU and the other parts that carry out the instruction.
- The CU signals RAM to fetch any data the instruction needs.
- The ALU performs the operation.
- The ACC, built into the ALU, holds the data being worked on and stores the result.
- Not every instruction needs the ALU: some do no calculation.
The words to use
Use these when you describe decode and execute, or trace one instruction.
Instruction set
Every command that a given CPU can carry out. The commands are machine code, so each type of CPU understands its own instruction set.
Example: ADD 202
Opcode ADD · operand 202 (an address). Execute:
- 1202 → MAR
- 2the value stored at 202 (7) → MDR
- 3the ALU adds it to the 5 in the ACC
- 4the result, 12, stays in the ACC
202 → MAR; the value stored at 202 (7) → MDR; the ALU adds it to the 5 in the ACC; the result, 12, stays in the ACC.
The cycle repeats
The PC already points to the next instruction, because it was incremented during fetch.
1 Split the instruction SUB 150 into its opcode and its operand.
2 The ACC holds 9. The instruction is ADD 150, and address 150 holds 4. What does the ACC hold afterwards?
3 Which unit decodes the instruction?
- 1Opcode
SUB, operand150. - 29 + 4 = 13, stored in the ACC.
- 3The control unit (CU).
CPU performance and embedded systems
Two phones can run the same app at very different speeds. Much of the difference is in the CPU: a higher clock speed, more cores and more cache all make it work faster. Not every CPU is in a phone or laptop, though: an embedded system is a small computer built into a device to do one job.
How the CPU’s design affects performance
Each factor speeds the CPU up in a different way. Read across a row to link it to instructions.
| Factor | What it is | Increase it and… | |
|---|---|---|---|
| Clock speed | Clock cycles per second, e.g. 2.5 GHz = 2.5 billion cycles per second. | more instructions per second can be processed. | |
| Number of cores | A core fetches, decodes and executes instructions. | more instructions can be processed at the same time (if the software uses them). | |
| Cache size | Small, very fast memory near the CPU. It stores frequently used data and instructions. | more are kept close to the CPU, so they are fetched faster than from RAM. |
Clock speed
2.5 GHz means 2.5 billion clock cycles per second. A higher clock speed means more instructions per second.
Number of cores
A core fetches, decodes and executes instructions. With more cores, several instructions run together, if the software uses them.
Cache size
Cache holds frequently used data and instructions near the CPU. More cache means more of them are fetched faster than from RAM.
Weigh up two changes to a processor
A new processor often changes two things at once, and they can pull in opposite directions.
| Processor change | Consequence |
|---|---|
| 2.0 GHz → 2.8 GHz | More instructions may be processed per second by each core. |
| 4 cores → 2 cores | Fewer instructions can be processed simultaneously. |
- Neither change alone proves better performance.
- A program that uses several cores may slow down; one that uses a single core may speed up.
Neither change alone proves better performance. A program that uses several cores may slow down; one that uses a single core may speed up.
Embedded systems
Say what makes a system embedded, and give a device that contains one.
Embedded system
A computer system built into a larger device to perform a dedicated function.
- Contains a microprocessor (or microcontroller)
- Dedicated hardware with its program stored as firmware
- Not easily reprogrammed by the user
- Part of a larger device, not a general-purpose computer: it cannot normally run other apps
| Device | Dedicated function |
|---|---|
| Washing machine | controls the wash cycle |
| Car | controls braking (ABS) or the engine |
| Security system | monitors sensors and sounds an alarm |
| Lighting system | switches lights on when it is dark |
| Vending machine | takes payment and releases the item |
1 A CPU runs at 3.2 GHz. How many clock cycles is that per second?
2 Why can a CPU with 4 cores sometimes do more than one with 2 cores?
3 Is a washing machine controller an embedded system? Give a reason.
- 13.2 billion: 3,200,000,000 cycles per second.
- 2Each core can process an instruction at the same time, so more instructions are processed at once (if the software uses them).
- 3Yes: it is built into the machine and does one dedicated job, the wash cycle.
Input devices
A computer can only work on what it is given. An input device allows data or instructions to be entered into a computer so that they can be processed.
Name the input device a task needs, and say in a few words how it works.
Barcode scanner
Shines light on the bars; the reflected pattern is read as a number that identifies the item’s database record.
QR code scanner
Captures a two-dimensional QR code and reads the data stored in it, e.g. a web address or ticket.
Digital camera
Captures still images or video and stores them as digital data.
Keyboard
Enters characters, numbers and commands by pressing keys; a keypad enters a PIN.
Microphone
Converts sound into an electrical signal: records voice or music, or gives voice commands.
Optical mouse
Detects its movement using reflected light to move the pointer; buttons select and scroll.
2D scanner
Scans a flat document or photograph into a digital image.
3D scanner
Scans the shape of a solid object to create a three-dimensional digital model.
Touch screen: touch is the input, the display is the output
Describe how each type finds the touch point.
Resistive
Two flexible layers are pressed together at the touch point; the point of contact is calculated.
Capacitive
A finger changes the electrical charge on the screen at the touch point; the change is detected.
Infra-red
A grid of infra-red beams crosses the screen; the touch point is where beams are broken.
1 Which input device reads the bars on a product at a till?
2 Which input device makes a three-dimensional model of a solid object?
3 On a smartphone, which hardware is the input device: the touch screen or the on-screen keyboard?
- 1A barcode scanner.
- 2A 3D scanner.
- 3The touch screen. The on-screen keyboard is software.
Output devices
Processing is wasted if the result stays inside the computer. An output device shows or produces the result of processing: information for a person, or a physical action.
Name the output device a task needs, and say in a few words how it works.
LCD screen
A backlight shines through a layer of liquid crystals; the crystals in each pixel pass or block the light to form the image.
LED screen
Light-emitting diodes (LEDs) provide the light that forms the image; bright and energy efficient.
LCD projector
Shines light through liquid-crystal panels to project a large image onto a screen or wall.
DLP projector
Digital light processing: millions of tiny mirrors on a chip direct light to project an image.
Inkjet printer
Sprays tiny droplets of liquid ink onto paper to produce a hard copy.
Laser printer
Uses a laser and a charged drum to attract toner, which is fused onto paper by heat.
Speaker
Converts electrical signals into sound: speech, music or an alert.
3D printer
Builds a solid object layer by layer from a digital design.
Actuator
A motor, valve or other component that produces movement or a physical action when it receives a signal, e.g. opens a valve, applies a brake, moves a robot arm.
1 Which output device moves a robot arm when it receives a signal?
2 A firm prints 500 copies of a newsletter. Which printer suits it, and why?
3 What does a speaker turn electrical signals into?
- 1An actuator.
- 2A laser printer: fast, high-quality printing of many pages.
- 3Sound.
Choosing input and output devices
A lift panel, a smart speaker and a greenhouse need different devices, because their users and tasks differ. To choose one, ask who the user is and what the task needs. Then name the hardware and give a reason.
Every device either brings data in to the processor or carries a result out.
decides
Built-in devices of a phone, tablet or watch
Name the input and output devices inside a handheld, and what each does there.
| In a handheld | Devices it can contain | What they do there |
|---|---|---|
| Input devices | touch screen · microphone · camera · buttons · sensors, e.g. an accelerometer or a light sensor | take in touches, voice, pictures, presses and readings of the surroundings |
| Output devices | screen (the display part of the touch screen) · speaker · light (LED) · vibration motor (an actuator) | show images, play sound, flash a light, buzz for a silent alert |
Choose the device for the scenario
Give the hardware and a reason that fits the user and the task.
| Scenario | Device | Why it fits |
|---|---|---|
| A lift control panel for passengers with sight loss | input: microphone; output: speaker | they say the floor they want and hear each floor announced, without reading the panel |
| A smart speaker that plays music on request | microphone | takes voice commands as input |
| A family printing a few colour photos at home | inkjet printer | a low-cost printer that gives good colour for a small number of copies |
| Supermarket self-checkout | barcode scanner | reads the product code quickly and accurately, so no typing is needed |
| Make a copy of a broken plastic part | 3D scanner, then 3D printer | captures the shape as a 3D model, then builds the part |
| Presentation to a large audience in a hall | DLP or LCD projector | projects a very large image that everyone can see |
| Printing 500 copies of a newsletter | laser printer | fast, high-quality printing of many pages |
| Opening a window in a smart greenhouse | actuator (motor) | turns the computer’s signal into movement |
1 A supermarket self-checkout must read product codes with no typing. Which input device suits it?
2 A doorbell must alert a person who cannot hear. Which output device suits it?
3 A print shop needs 1000 leaflets quickly. Which printer, and why?
- 1A barcode scanner: it reads the code quickly and accurately.
- 2A flashing light (LED): it gives a signal that needs no hearing.
- 3A laser printer: fast, high-quality printing of many pages.
Sensors: choose the right one
Some input comes from no person at all: a freezer has to know when it is getting warm, even at night. A sensor is an input device that measures a physical property of its surroundings and sends the reading to a computer or microprocessor.
Name the sensor that captures the data a task needs: the specific name, not “sound sensor”.
| Sensor | Data it captures | A use |
|---|---|---|
| Accelerometer | movement and tilt: change of speed or direction | count steps on a fitness band |
| Acoustic | sound level | warn when noise from a building site is too loud |
| Flow | rate of flow of a liquid or gas | measure the fuel a pump delivers |
| Gas | which gas is present and how much (concentration), e.g. methane | warn miners of methane underground |
| Humidity | amount of water vapour in the air | switch on a bathroom fan to stop mould |
| Infra-red | infra-red radiation (heat or a broken beam) | start a tap when a hand is under it |
| Level | height of a liquid or solid in a container | stop a water tank overflowing |
| Light | light intensity | brighten a phone screen in strong sunlight |
| Magnetic field | changes in a magnetic field | know a garden gate is shut (a magnet in the gate) |
| Moisture | amount of water in the soil or a material | check timber is dry enough to build with |
| pH | acidity or alkalinity | keep a swimming pool safe to swim in |
| Pressure | applied pressure or weight | weigh luggage at a check-in desk |
| Proximity | how close an object is | turn a phone’s screen off when it is held to the ear |
| Temperature | temperature | warn when a shop freezer gets too warm |
Why use sensors?
- No one needs to be there: readings are taken automatically.
- Readings go on day and night (continuously).
- Readings are accurate and consistent.
- A sensor can sit where it is dangerous for a person, e.g. inside a furnace.
Do not confuse
Humidity = water vapour in the air.
Moisture = water in the soil or a material.
Infra-red detects heat or a broken beam; proximity measures distance to an object.
1 Which sensor starts a tap when a hand is under it?
2 Which sensor warns a shop when its freezer gets too warm?
3 What is the difference between a humidity sensor and a moisture sensor?
- 1An infra-red sensor (a hand breaks the beam or gives off heat).
- 2A temperature sensor.
- 3Humidity measures water vapour in the air; moisture measures water in the soil or a material.
Primary storage and virtual memory
A computer needs somewhere fast for the work it is doing now, and somewhere safe for everything else. Primary storage is what the CPU reaches directly: RAM and ROM. Secondary storage keeps your files when the power is off.
Primary storage
Directly accessed by the CPU. RAM and ROM (cache too).
Secondary storage
Not directly accessed by the CPU. Non-volatile: it keeps files and software permanently, so they need not be installed again each time the computer is used.
RAM and ROM
Both are primary storage, so compare what each lets the CPU do and what is left when the power goes off.
| RAM · random access memory | ROM · read only memory | |
|---|---|---|
| Access | read and write | read only (normally) |
| Volatile? | volatile: contents lost when power is off | non-volatile: contents kept without power |
| Stores | programs and data currently in use | start-up instructions (BIOS / bootstrap), firmware |
Why a computer needs both
- RAM holds the programs and data in use, so the CPU can access them quickly and change them.
- ROM keeps the start-up instructions safe when the power is off, so they are there at power-on and cannot be changed by accident.
Virtual memory: when RAM is full
Follow the orange arrows: an idle tab’s page is copied out of RAM, and copied back when that tab is clicked.
How it is created and used
- The operating system partitions part of secondary storage to create virtual memory.
- When RAM fills up, pages the CPU is not using at the moment are copied out to virtual memory.
- This frees RAM for the data the CPU needs; pages are moved back to RAM when needed.
Why it is necessary
- Programs still run when there is not enough RAM for them all: idle pages wait in virtual memory.
- Lets more programs be open at once.
- But it is slower than RAM, because the pages sit on secondary storage.
1 Which loses its contents when the power is off, RAM or ROM?
2 Which holds the start-up instructions?
3 RAM is full. Where do idle pages go, and what is the cost?
- 1RAM is volatile.
- 2ROM.
- 3They are copied to virtual memory, space set aside on secondary storage. It is slower than RAM.
Secondary storage
A hard disk, a DVD and a USB flash drive all keep your files when the power is off, but each holds its bits in a different way: magnetic, optical or solid-state. How each one works explains when it is the right choice.
Secondary storage technologies
Describe how each type stores its bits, and name an example of each.
Magnetic
- Circular platters spin; the surface is split into tracks and sectors.
- A read/write head on a moving arm uses an electromagnet.
- It reads or changes magnetised dots, which stand for 1 and 0.
Example: hard disk drive (HDD)
Optical
- The disc spins.
- A laser burns pits into a spiral track; unburnt areas are lands.
- To read, a laser detects the difference in reflection as 1s and 0s.
Examples: CD, DVD, Blu-ray. DVDs use a red laser; Blu-ray uses a blue laser, so it holds more data
Solid-state (flash)
- A grid of memory cells built from transistors, wired as NAND or NOR.
- In each cell a control gate sits over a floating gate, which traps electrons: that charge stores the data.
- No moving parts.
Examples: SSD, SD card, USB flash drive
Magnetic
Circular platters spin, their surface split into tracks and sectors. A read/write head on a moving arm uses an electromagnet to read or change magnetised dots, which stand for 1 and 0.
Example: hard disk drive (HDD)
Optical
The disc spins. A laser burns pits into a spiral track; unburnt areas are lands. When reading, a laser detects the difference in reflection as 1s and 0s.
Examples: CD, DVD, Blu-ray. DVDs use a red laser; Blu-ray uses a blue laser, so it holds more data
Solid-state (flash)
A grid of memory cells built from transistors, wired as NAND or NOR. In each cell a control gate sits over a floating gate, which traps electrons: that charge stores the data. No moving parts.
Examples: SSD, SD card, USB flash drive
Which type of storage?
Cover the Type column, then name the type each statement describes.
| Statement | Type |
|---|---|
| A head on an arm moves just above a spinning surface | magnetic |
| Electrons are trapped to store data, and nothing moves | solid-state |
| Light reflects differently from burnt and unburnt areas | optical |
| Each bit is a tiny area magnetised one way or the other | magnetic |
| Data sits as pits and lands along one spiral | optical |
| Memory cells built from transistors form a grid on a chip | solid-state |
Why choose solid-state?
Each difference, and what it means for the user.
| Solid-state compared with optical | So… |
|---|---|
| No moving parts: no disc to spin | it survives knocks (more durable), is quiet and uses less power |
| Faster access to data | files open and save sooner |
| Larger capacity | one drive holds what would fill many discs |
| More expensive per GB | the drawback: optical discs are cheaper for each GB stored |
1 Which type of storage reads pits and lands with a laser?
2 Which type has no moving parts? Name one example.
3 Give one drawback of solid-state compared with optical.
- 1Optical storage.
- 2Solid-state (flash), e.g. an SSD or a USB flash drive.
- 3It is more expensive per GB.
Cloud storage
Cloud storage keeps files on remote servers run by a third party (the provider), reached over the internet. The files still sit on physical disks: the servers are in the provider’s buildings, looked after by its staff.
Take a photo on a phone and a minute later it opens on a laptop, with no cable between them. Cloud storage keeps files on remote servers run by a third party (the provider), reached over the internet. The files still sit on physical disks, in the provider’s buildings and looked after by its staff.
Cloud or local storage
Give an advantage of the cloud, and a disadvantage compared with storing files locally.
| Advantage of the cloud | Disadvantage compared with local storage | |
|---|---|---|
| Access | open files from any device, anywhere, and share them with others | no internet connection, no access; a weak one slows every open and save |
| Hardware and space | no storage hardware to buy or look after; more space can be added when needed | large files take time to upload and download |
| Control | the provider maintains and backs up its servers | less direct control over the provider’s backup and security arrangements |
| If something fails | files survive if your own device breaks or is lost | if the provider fails or is hacked, files may become unavailable or lost: you rely on a third party |
Fit the advantage to the scenario
Choose the points that fit this user: the same feature can count for one user and against another.
A wildlife trail camera uploads its photos to the cloud
- If the camera is stolen or damaged, the photos already uploaded are still available.
- Nobody has to visit the forest to look after storage hardware: the provider maintains it.
- With little memory of its own, the camera can be small and cheap.
A dental clinic keeps patient records on its own server
- The clinic sets its own backup and decides who may see the records.
- It controls server maintenance and does not depend on a third party to store its records.
- Records still open when the internet is down.
1 What is cloud storage?
2 Your laptop is stolen. Why are files in the cloud still safe?
3 Give one disadvantage of cloud storage when the internet is down.
- 1Files kept on remote servers run by a third party, reached over the internet.
- 2The files are on the provider’s servers, not on your device.
- 3With no internet connection you cannot reach your files.
Network hardware and addresses
For data to reach your phone, the network has to know where your phone is, just as a letter needs an address. A NIC joins a device to a network and has a MAC address. The network gives the device an IP address. A router forwards each packet to its destination IP address.
Network hardware
Say what a NIC and a router do, and tell a static IP address from a dynamic one.
NIC · network interface card
The hardware (wired or wireless) a device needs to connect to a network and send and receive data. The manufacturer sets the NIC’s MAC address, unique to that card.
Router
Reads each packet’s destination IP address (in the packet header) and forwards the packet towards it, deciding its route. It connects a local network to the internet and can assign IP addresses to devices.
Static or dynamic IP
Static: the same address on every connection (e.g. a web server).
Dynamic: the network can give a different address at each connection.
NIC · network interface card
- The hardware (wired or wireless) a device needs to connect to a network and send and receive data.
- The manufacturer sets the NIC’s MAC address, unique to that card.
Router
- Reads each packet’s destination IP address (in the packet header).
- Forwards the packet towards it, deciding its route.
- Connects a local network to the internet and can assign IP addresses to devices.
Static or dynamic IP
- Static: the same address on every connection (e.g. a web server).
- Dynamic: the network can give a different address at each connection.
Each device at home has its own local address. The router reaches the internet for all of them through one public IP.
MAC address · media access control
The first half names the maker of the card; the second half is that card’s own number.
- Purpose: uniquely identifies a device’s network interface on a network.
- Structure: 48 bits, written as six pairs of hexadecimal digits separated by colons or hyphens.
- Set by the manufacturer and normally fixed.
Purpose: uniquely identifies a device’s network interface on a network.
Structure: 48 bits, written as six pairs of hexadecimal digits separated by colons or hyphens. Set by the manufacturer and normally fixed.
IP address · internet protocol
- Purpose: uniquely identifies a device on a network or the internet, so that data can be sent to the right place.
- The network gives it to the device, often through the router; the manufacturer does not.
Purpose: uniquely identifies a device on a network or the internet, so that data can be sent to the right place. The network gives it to the device, often through the router; the manufacturer does not.
| IPv4 | IPv6 | |
|---|---|---|
| Size | 32 bits | 128 bits |
| Written as | 4 denary numbers, each 0–255, separated by dots | 8 groups of 4 hexadecimal digits, separated by colons |
| Example | 192.168.0.25 | 2001:0db8:0000:0000: |
| Notes | about 4.3 billion addresses: not enough for every device | about 3.4 × 10³⁸ addresses. One run of all-zero groups can be written as ::, once only: 2001:0db8::0001 |
Is it a valid IPv4 address?
Check there are four denary groups, each from 0 to 255.
| IPv4 candidate | Decision |
|---|---|
| 172.16.8.20 | Valid: four denary groups, each from 0 to 255. |
| 172.16.8.260 | Invalid: 260 is greater than 255. |
1 Is 192.168.1.300 a valid IPv4 address?
2 How many bits are in an IPv4 address, and in an IPv6 address?
3 Who sets a device’s MAC address, and who gives it its IP address?
- 1No: 300 is greater than 255.
- 2IPv4 has 32 bits; IPv6 has 128 bits.
- 3The manufacturer sets the MAC address; the network (often through the router) gives the IP address.