Hardware
The physical machine: the CPU and Von Neumann architecture, the fetch-decode-execute cycle, what makes a processor fast, embedded systems, input and output devices, sensors, storage types, virtual memory and the cloud. Topic 3 of the 0478 / 2210 syllabus in full.
Hardware is the physical part of a computer, the parts you can touch. At the centre of it all is the CPU, which processes every instruction. This chapter takes you inside the processor, then out to the devices that feed it data and the storage that keeps that data safe.
CPU and Von Neumann Architecture
The CPU (Central Processing Unit) processes all the instructions and data in a computer so that a result can be produced. A microprocessor is simply a CPU built onto a single integrated circuit chip.
Most computers follow the Von Neumann architecture. Its key idea is that both program instructions and the data they work on are stored together in the same memory. This is why a single computer can run any program: the program is just data loaded into memory.
The two units inside the CPU
| Component | Short | Role |
|---|---|---|
| Arithmetic Logic Unit | ALU | Performs arithmetic (add, subtract, multiply, divide) and logical (AND, OR, NOT) operations |
| Control Unit | CU | Directs all operations: it fetches, decodes and coordinates the execution of instructions |
Registers and Buses
A register is a very small, very fast store inside the CPU that holds one piece of data at a time. You must know the role of each of these five.
| Register | Short | What it holds |
|---|---|---|
| Program Counter | PC | The memory address of the next instruction to be fetched |
| Memory Address Register | MAR | The address currently being read from or written to |
| Memory Data Register | MDR | The data or instruction just fetched from, or about to be written to, memory |
| Current Instruction Register | CIR | The instruction currently being decoded and executed |
| Accumulator | ACC | The result of the most recent ALU calculation |
Buses
A bus is a set of parallel wires that carries data between components. There are three.
| Bus | Direction | What it carries |
|---|---|---|
| Address bus | One-way (CPU to memory) | Memory addresses |
| Data bus | Two-way | Data and instructions |
| Control bus | Two-way | Control signals such as read, write and clock |
The Fetch-Decode-Execute Cycle
This is the cycle the CPU repeats for every single instruction, billions of times a second. It has three stages, and you need to know the role of each register at each stage.
Fetch
- The address in the PC is copied to the MAR along the address bus
- The instruction at that address is fetched from RAM into the MDR along the data bus
- The PC is incremented so it points to the next instruction
Decode
- The instruction is copied from the MDR to the CIR
- The Control Unit decodes it, working out which operation and operand are needed
Execute
- The Control Unit sends signals to carry out the instruction
- If a calculation is needed, the ALU performs it and the result is stored in the ACC
What Affects CPU Performance
Three factors change how fast a CPU works. Exam questions often ask you to explain the effect of changing one.
| Factor | Effect on performance |
|---|---|
| Clock speed | A higher clock speed means more FDE cycles per second, so faster processing. Measured in gigahertz (GHz) |
| Number of cores | Each core can process instructions independently. More cores means more instructions handled at the same time. A quad-core can handle four streams at once |
| Cache size | Cache is very fast memory inside the CPU. A larger cache stores more frequently used data close by, reducing slow trips to RAM |
Instruction Sets
An instruction set is the complete list of machine-code commands that a particular CPU can carry out. Every CPU has its own instruction set, which is why a program must be compiled for the specific type of processor it will run on. A program built for one instruction set will not run on a CPU with a different one.
Embedded Systems
An embedded system is a dedicated computer built into a larger device to perform one specific task. It uses a microprocessor running a fixed program stored in ROM.
| Embedded system | General purpose computer |
|---|---|
| Performs one dedicated function | Performs many different functions |
| Program stored in ROM, cannot be changed by the user | Programs loaded from storage, can be changed |
| Examples: washing machine, microwave, car ABS, pacemaker, traffic lights | Examples: laptop, desktop PC, smartphone |
| Low power, reliable and fast for its task | Higher power, flexible and upgradeable |
Input and Output Devices
An input device converts real-world data into a digital form the computer can process. An output device converts digital data back into a form humans can use. The exam expects you to describe not just what each device is, but how it works, so each one is explained below.
How input devices work
When a key is pressed it completes a circuit on a circuit board underneath the keys. The keyboard has a chip that detects which circuit was completed and looks up the matching character code in a character map. That code is sent to the computer, which converts it to the correct character.
An LED shines light onto the surface beneath the mouse. A tiny camera takes thousands of photos of the surface every second. A processor compares each photo with the previous one to work out the direction and distance the mouse has moved, and sends those movement values to the computer.
Sound waves cause a thin diaphragm inside the microphone to vibrate. These vibrations are converted into a varying electrical (analogue) signal. An analogue-to-digital converter then samples this signal and turns it into the binary numbers the computer stores.
Light enters through the lens and falls on an image sensor made of millions of tiny light-sensitive cells. Each cell measures the amount of light hitting it and converts it into an electrical signal, which is turned into binary. Together these values form the pixels of the digital image.
A bright light shines onto the document as a scan head moves slowly across it. The light reflected off the document is captured by sensors and converted into electrical signals. These are turned into binary to build up a digital image of the page. Optical character recognition (OCR) software can then convert a scanned image of text into editable text.
A 3D scanner measures the shape of a solid object, often using lasers or infra-red to record the distance to many points on its surface. These measurements build up a digital 3D model of the object, which can then be edited or sent to a 3D printer.
A barcode is a pattern of light and dark vertical lines of varying width. The scanner shines a light (often a laser) across the barcode. Dark lines reflect little light and light gaps reflect a lot. A sensor detects this pattern of reflection and converts it into a number that identifies the product.
A QR code is a 2D pattern of black and white squares that can store much more data than a barcode. A camera captures an image of the code, and software reads the pattern of squares, decoding it into the data it represents, such as a web address.
A touch screen is both an input and output device. There are three types in the syllabus. Resistive screens have two flexible layers that touch when pressed, completing a circuit at that point. Capacitive screens have a coating that holds a small electrical charge, and a finger touching the screen changes the charge at that point. Infra-red screens have a grid of infra-red beams across the surface, and a touch breaks the beams at the touched point. In each case the position of the touch is calculated and sent to the computer.
How output devices work
An LCD (liquid crystal display) is made of a grid of liquid crystal pixels in front of a backlight. An electric current passing through each crystal twists it to control how much light passes through, and colour filters give each pixel its colour. Older LCD screens use a fluorescent backlight.
An LED screen is an LCD screen that uses light-emitting diodes (LEDs) as the backlight instead of a fluorescent lamp. LEDs are brighter, more energy efficient, and allow a thinner screen, which is why most modern displays are LED-backlit.
An inkjet printer sprays tiny droplets of liquid ink onto the paper through nozzles in a print head that moves across the page. The paper feeds through a small amount at a time. It builds the image up line by line from thousands of tiny dots. Inkjets are cheap and good for photos but slower and use up ink quickly.
A laser printer uses a laser beam to draw the image as a pattern of electrical charge on a rotating drum. Powdered ink called toner sticks to the charged areas of the drum. The toner is then transferred onto the paper and fused on permanently using heat. Laser printers are fast and well suited to high-volume printing.
A 3D printer builds a solid object one thin layer at a time, working from a digital 3D model. The most common type melts plastic filament and lays it down layer by layer, with each layer setting before the next is added, gradually building up the finished object. This is known as additive manufacturing.
A projector enlarges an image onto a large screen or wall. An LCD projector shines a strong light through a small liquid crystal display, projecting the image through a lens. A DLP (digital light processing) projector reflects light off millions of tiny mirrors on a chip, each mirror tilting to control the light for one pixel.
The computer sends a digital sound signal to a digital-to-analogue converter, which turns it into a varying electrical signal. This signal passes through a coil in the speaker, creating a changing magnetic field that makes a cone vibrate. The vibrating cone moves the air, producing sound waves we can hear.
An actuator converts an electrical signal from the computer into physical movement. Common actuators are motors (rotation), valves (controlling flow), and solenoids (pushing or pulling). Actuators are how a computer affects the physical world, and they are essential in the automated systems covered in Chapter 6.
Sensors
A sensor is an input device that measures a physical property and converts it into an electrical signal, which is then turned into digital data for the computer. Sensors are the eyes and ears of automated systems.
| Sensor | Measures | Example use |
|---|---|---|
| Temperature | Heat level | Greenhouse climate control, server rooms |
| Humidity | Moisture in the air | Weather stations, data centres |
| Moisture | Water content in soil | Automated irrigation systems |
| Light | Light intensity | Automatic street lighting, camera exposure |
| Infra-red | Heat radiation or presence | Motion detectors, burglar alarms |
| Pressure | Force per unit area | Industrial machinery, weather forecasting |
| Proximity | Distance to a nearby object | Automatic doors, parking sensors |
| Acoustic | Sound level | Noise pollution monitoring |
| Accelerometer | Change of velocity or orientation | Phone screen rotation, fitness trackers |
| Gas / pH | Gas concentration or acidity | CO detectors, swimming pools, agriculture |
Primary and Secondary Storage
Primary storage
Directly accessed by the CPU. Fast but limited in size. Includes RAM and ROM.
Secondary storage
Not directly accessed by the CPU. Larger and non-volatile, used for long-term storage. Slower than RAM.
RAM and ROM
| RAM | ROM | |
|---|---|---|
| Volatile? | Yes, loses contents when power is off | No, keeps contents without power |
| Read / write | Read and write | Read only |
| Holds | Programs and data currently in use | Firmware and the bootloader |
Storage Technologies
Secondary storage comes in three technologies. You must be able to describe how each one works, not just name an example. The table gives a one-line summary, then each is explained in full below.
| Type | Stores data using | Examples |
|---|---|---|
| Magnetic | Magnetised regions on spinning platters | Hard disk drive (HDD), magnetic tape |
| Optical | Pits and lands read by a laser | CD, DVD, Blu-ray |
| Solid-state | Electrical charge trapped in flash memory cells | SSD, USB flash drive, SD card |
How magnetic storage works
A magnetic hard disk drive contains one or more circular metal platters coated with a magnetic material. The surface of each platter is divided into concentric circles called tracks, and each track is divided into sectors, which is how the drive knows where each piece of data is located.
The platters spin at high speed, thousands of times per minute. A read/write head on a moving arm floats just above the surface. To write data, the head acts as an electromagnet: it magnetises a tiny region of the surface in one direction to represent a 1 or the opposite direction to represent a 0. To read data, the head detects the direction of magnetism of each region as it passes underneath and converts it back into 1s and 0s.
Because the platters spin and the head physically moves to the right track, magnetic drives have moving parts. This makes them cheaper per gigabyte and good for large capacities, but slower and more easily damaged by knocks than solid-state drives.
How optical storage works
Optical discs such as CDs, DVDs and Blu-rays store data on a spiral track running outward from the centre. Along this track the surface is burned into a pattern of pits (small dips) and lands (the flat areas between them).
To read the disc, a laser is shone onto the spinning surface. A land reflects the laser light strongly back to a sensor, while a pit scatters the light so less is reflected. The drive detects this change in reflection and converts the pattern into the binary 1s and 0s of the stored data. Writable discs work by using a stronger laser to burn the pits into a dye layer.
Blu-ray discs hold the most data because they use a blue laser with a shorter wavelength than the red laser used for DVDs and CDs, allowing the pits to be packed more closely together.
How solid-state storage works
Solid-state storage such as an SSD or USB flash drive uses flash memory and has no moving parts. Data is stored using special transistors arranged as control gates and floating gates. A floating gate can trap an electrical charge and hold it even when the power is switched off, which is what makes the storage non-volatile.
Whether a cell is holding a trapped charge or not represents a 1 or a 0. Because data is accessed electronically with no spinning disc or moving head, solid-state storage is much faster to read and write, uses less power, and is far more durable when knocked or dropped.
Virtual Memory
Virtual memory is a section of secondary storage (the HDD or SSD) used as an extension of RAM when the physical RAM becomes full. Pages of data are swapped between RAM and virtual memory as needed.
- RAM becomes full, with no space for a new program or process
- The operating system identifies pages of data in RAM that have not been used recently
- Those pages are swapped out to the virtual memory space on the disk
- The new data is loaded into the freed RAM space
- If the swapped-out pages are needed again, they are swapped back into RAM
Cloud Storage
Cloud storage keeps data on remote servers accessed over the internet, rather than on local hardware. The data physically lives on servers in data centres run by a provider.
| Cloud storage | Local storage | |
|---|---|---|
| Access | From any device, anywhere with internet | Only from the device it is connected to |
| Capacity | Scalable, pay for more when needed | Fixed, must buy new hardware to expand |
| Cost | Ongoing subscription or pay per use | One-time hardware cost |
| Security risk | Data held by a third party, risk of breaches | Device can be lost, damaged or stolen |
| Dependence | Needs a reliable internet connection | Works offline |
| Maintenance | Provider handles hardware maintenance | User responsible for backups and repairs |
Exam Practice
The PC holds the address of the next instruction to be fetched. The MAR holds the address currently being read from or written to. The ACC holds the result of the most recent calculation performed by the ALU.
The address held in the program counter is copied to the MAR along the address bus. The instruction at that address is fetched from RAM into the MDR along the data bus. The program counter is then incremented so it points to the next instruction.
More cores allow more instructions to be processed at the same time, since each core can handle its own stream of instructions independently. A larger cache stores more frequently used data and instructions close to the CPU, reducing the number of slower accesses to RAM, so the CPU spends less time waiting for data.
An embedded system performs one dedicated function and runs a fixed program stored in ROM that the user cannot change, for example a washing machine. A general purpose computer performs many different functions and runs programs loaded from storage that can be changed or added to, for example a laptop.
When RAM is full, the operating system identifies pages of data in RAM that have not been used recently and swaps them out to a reserved area of secondary storage called virtual memory. The freed space in RAM is then used for the new data. If the swapped-out pages are needed again, they are swapped back into RAM.
A solid-state drive uses NAND or NOR flash memory, where transistors act as control gates and floating gates to hold data, with no moving parts. One advantage over a magnetic hard disk is that it is faster to access data, or alternatively that it is more durable because it has no moving parts to be damaged.
