Note AcademyNote Academy

Computer Science 2210 · Chapter 3

Hardware

The CPU and the fetch-decode-execute cycle, input and output devices and sensors, primary and secondary storage, virtual and cloud storage, and network hardware.

Written for the 2023–2025 syllabus · 28 min read

3.1 Computer architecture

Central Processing Unit (CPU)

A microprocessor is a single-chip integrated circuit (IC) that contains the central processing unit (CPU) of a computer. It is capable of performing arithmetic, logic, control, and input/output operations. Microprocessors are the brains of a computer system but do not include memory, storage, or I/O interfaces on the same chip.

The Role of the CPU

Processing instructions and data: The CPU executes instructions from programs. These instructions tell the CPU what operations to perform. Data is processed by the CPU as it carries out these instructions, enabling the computer to perform tasks and solve problems.

The fetch-decode-execute cycle

  • Fetch: The CPU retrieves an instruction from the computer's memory.
  • Decode: The CPU decodes the instruction to understand what action is required.
  • Execute: The CPU executes the instruction. This could involve performing calculations, moving data, or interacting with other hardware components.

Control Unit and Arithmetic Logic Unit

  • Control Unit (CU): Directs the operations of the CPU by fetching instructions from memory, decoding them, and managing the execution cycle.
  • Arithmetic Logic Unit (ALU): Performs calculations and logical operations. It also holds temporary values during calculations in a register called the Accumulator.

Key Components of the CPU

  1. Register: Stores data being used by the CPU temporarily.

  2. Buses: Electrical pathways that transport data and instructions between the CPU, memory, and other hardware components. The main types of buses are:

    • Data bus: The data bus transfers actual data between the CPU and components. It is bidirectional, allowing data to flow both to and from the CPU.
    • Address bus: The address bus carries the memory addresses of data that the processor needs to access. It is a unidirectional bus, meaning that data flows in only one direction: from the CPU to the components.
    • Control bus: The control bus carries control signals sent by the CPU to components of the computer and vice versa. This is also bidirectional. It is used to synchronize the fetch-execute cycle.
  3. Core:

    • A core is an individual processing unit within a CPU.
    • More cores allow a CPU to perform multiple tasks simultaneously.
    • Multiple cores can divide the workload, making the CPU more efficient and reducing the time it takes to complete tasks.
  4. Cache:

    • It is a small amount of high-speed memory located within the CPU. It stores frequently accessed data and instructions, allowing the CPU to retrieve this information quickly.
    • A larger cache size means more data can be stored close to the CPU, reducing the need to access slower main memory (RAM). This results in faster data retrieval and improved performance.
    • With more cache, the CPU can handle more instructions quickly, reducing the time spent waiting for data from the main memory.
  5. Clock speed:

    • The clock speed indicates the number of cycles a CPU can perform per second. It is measured in hertz (Hz).
    • Higher clock speeds mean the CPU can execute more instructions per second, leading to faster performance.
    • For example, a CPU with a clock speed of 3.5 GHz can perform 3.5 billion cycles per second.
    • A higher clock speed improves the responsiveness of the CPU, allowing it to perform tasks more quickly and efficiently.

Von Neumann Architecture

Program Counter (PC): The PC holds the address of the next instruction to be executed. It increments after each instruction execution, ensuring that the CPU processes instructions sequentially.

Memory Address Register (MAR): The MAR holds the memory location of data that needs to be accessed. It acts as a pointer to the memory address from which data is to be fetched or to which data is to be sent.

Memory Data Register (MDR): The MDR holds the data that is being transferred to or from memory. It serves as a buffer between the CPU and the memory, ensuring that data is correctly read from or written to the memory locations specified by the MAR.

Current Instruction Register (CIR): The CIR holds the instruction that is currently being executed. It ensures that the CPU has immediate access to the current instruction, enabling quick execution.

Accumulator (ACC): The ACC holds intermediate results of arithmetic and logical operations. It is used to store the results of operations performed by the ALU, acting as a temporary storage space for calculations.

The CPU with its registers, control unit, ALU and accumulator, joined to RAM by the address bus, data bus and control bus

The CPU with its registers, control unit, ALU and accumulator, joined to RAM by the address bus, data bus and control bus

Fetch-Decode-Execute Cycle

Fetch stage

  1. Program Counter (PC): Holds the address of the next instruction to be executed.
  2. Memory Address Register (MAR): The address from the PC is loaded into the MAR.
  3. Address bus: The MAR uses the address bus to send the address to the RAM.
  4. Random Access Memory (RAM): The RAM sends the instruction stored at the address back to the CPU.
  5. Memory Data Register (MDR): The fetched instruction is placed into the MDR.
  6. Current Instruction Register (CIR): The instruction from the MDR is transferred to the CIR for decoding.
  7. Update the Program Counter: The PC is incremented to point to the next instruction in the sequence, preparing for the next fetch cycle.

Decode stage

Control Unit (CU): The CU reads the instruction in the CIR and interprets it. This involves breaking down the instruction into its opcode (operation code) and operand (data or address). The CU determines the type of operation to be performed and the resources needed (such as ALU operations or data fetch).

Execute stage

Arithmetic Logic Unit (ALU): If the instruction involves arithmetic or logic operations, the CU sends the appropriate signals to the ALU, which performs the required operation using data from the registers.

Registers: Intermediate data or results are stored in registers like the Accumulator (ACC).

The fetch, decode and execute stages of the cycle, with the seven fetch steps, repeating for each instruction

The fetch, decode and execute stages of the cycle, with the seven fetch steps, repeating for each instruction

Instruction Set

An instruction set is a collection of all the commands that a CPU can execute. These commands are written in machine code, which is a set of binary instructions that the CPU understands directly.

Purpose of an instruction set

  1. The instruction set allows software to communicate directly with the hardware.
  2. An instruction set standardizes the way operations are performed on a particular CPU.
  3. By having a defined set of instructions, the CPU can optimize the execution of these commands, leading to efficient processing and faster performance.

Embedded System

  • An embedded system is designed to perform a specific, dedicated function within a larger system.
  • Unlike general-purpose computers, which can execute a variety of tasks, embedded systems are specialized for one or a few specific functions.
  • These systems often require human intervention, such as microwaves, washing machines, etc.

3.2 Input and output devices

Input Devices

An input device is any hardware component that allows users to enter data and control signals into a computer system.

Barcode scanner

  1. A barcode scanner shines a light at the barcode and the light is reflected back.
  2. The black bars in the barcode reflect less light than the white bars.
  3. Sensors are used to capture the amount of reflected light and the different reflections are converted to different binary values.
  4. These values are checked by a microprocessor against a database of values and their corresponding prices and then the price is returned.

Digital camera

  1. When the button of the camera is pressed, an aperture opens at the front of the camera to allow light to stream in through the lens.
  2. This is captured by a sensor called a charge-coupled device.
  3. The analogue-to-digital converter then converts each pixel into a digital value.

Keyboard

  1. Circuit board present at base of keys.
  2. A key is pressed that presses a switch.
  3. When a key is pressed it completes a circuit.
  4. The location of the keypress is calculated.
  5. An index of characters is searched to find the corresponding keypress.
  6. Each character has an ASCII / Unicode value.
  7. The ASCII / Unicode value has a binary value.
  8. Keypress generates an interrupt.
  9. Each character / keypress is added to a buffer to wait to be processed.
  10. The binary can then be processed by the CPU to action the key press.

Microphone

  1. When sound waves reach the microphone, it causes the diaphragm, which is a thin membrane inside the microphone, to vibrate.
  2. The analogue-to-digital converter converts the analogue signals into binary values and sends them to the microprocessor.

Optical mouse

  1. An optical mouse shines an LED from the bottom of the mouse onto a surface.
  2. Light bounces straight back from the surface into a photoelectric cell. This has a lens that magnifies the reflected light to allow detection of smaller movements.
  3. When a button on the mouse is clicked, a microswitch is pressed.
  4. A USB connection is used to carry the data to the computer.

QR code scanner

  1. A QR code is scanned using a camera on a mobile device and decoded using an application.
  2. When an illuminator is shone on the code, squares reflect light differently.
  3. Corners of the code are used for orientation.
  4. It then decodes it and redirects the person to the website/opens the document.
  5. QR codes can be saved for future use.

Touch screens: resistive, capacitive and infra-red

  • Resistive touch screen:

    • Made of two flexible layers separated by a small gap. One layer has conductive stripes on the top, and the other has conductive stripes on the bottom.
    • When pressure is applied to the screen, the two layers come into contact at the touch point. This creates a change in electrical resistance, and then a calculation is made to determine the coordinates of the touch.
    • Cheaper to manufacture.

    A resistive touch panel: a finger presses the flexible film down onto the lower electrode film, which are held apart by spacer dots

    A resistive touch panel: a finger presses the flexible film down onto the lower electrode film, which are held apart by spacer dots
  • Capacitive touch screen:

    • Composed of a glass panel coated with a transparent conductor (such as indium tin oxide).
    • When a finger (which conducts electricity) touches the screen, it changes the local electrostatic field. The device detects this change and calculates the touch point coordinates using the grid of conductive material.
    • More commonly used in smartphones.
    • More responsive to a touch.
  • Infra-red touch screen:

    • Uses an array of infrared light-emitting diodes (LEDs) and sensors around the edges of the screen.
    • When an object touches the screen, it interrupts the infrared light beams. The system detects the coordinates of the interruption.

Scanners: 2D and 3D

  • 2D scanner:
    • The document or image to be scanned is placed on the scanner's glass surface.
    • A light source illuminates the document.
    • A scanning mechanism moves beneath the glass, capturing light reflected from the document.
    • It captures the light as an array of pixels, converting the light intensity into electrical signals. These signals represent the different shades of light and dark areas of the document.
    • The electrical signals are then processed by an analogue-to-digital converter (ADC) to create a digital image of the document.
  • 3D scanner:
    • The object to be scanned is placed on a stable surface, and the scanner is positioned correctly.
    • A laser beam is projected onto the object's surface.
    • Sensors or cameras capture the reflection of the laser.
    • Multiple images are taken from different angles to cover the entire surface.
    • The captured images are processed to calculate the exact 3D coordinates (x, y, z) of points on the object's surface.
    • This data is then used to create a detailed 3D representation of the object.

Output Devices

Output devices are essential hardware components in a computer system, responsible for conveying information from the computer to the user or another device. They play a crucial role in making the data processed by the computer perceivable to humans.

Actuator

  • An actuator is a device that converts electrical signals into physical movement.
  • It operates by receiving control signals and converting them into mechanical motion.
  • Common types include electric motors, solenoids, and hydraulic actuators.

Digital Light Processing (DLP) projector

  1. It uses a lot of tiny mirrors that are laid out in a grid.
  2. Each mirror creates a pixel in the image.
  3. The mirrors can tilt towards or away from the light source.
  4. The mirrors reflect the light towards a lens.
  5. The colour is produced using a colour wheel.
  6. It then displays the image on a wall or screen.

Liquid Crystal Display (LCD) projector

  1. It uses a LED or CCFL backlight.
  2. Utilizes liquid crystal panels (one each for red, green, and blue colours) to modulate light and create images.
  3. Light passes through the LCD panels where individual pixels can be turned on or off to create the image.
  4. The light is then passed through a lens to focus and magnify it.
LCD projectorDLP projector
Has higher brightnessMore compact
Has higher colour accuracyMore reliable
Is typically less expensive

Inkjet printer

  1. The printer receives data from a computer detailing the text or image to be printed.
  2. The print head moves to the starting position, controlled by stepper motors.
  3. Tiny droplets of ink are formed using either thermal or piezoelectric technology.
    • Thermal: Heat creates bubbles that force ink out of nozzles.
    • Piezoelectric: Crystals change shape to push ink out of nozzles.
  4. Ink droplets are precisely placed on the paper to form characters or images.
  5. Different colour inks are mixed to produce various colours.
  6. The paper feed mechanism moves the paper incrementally for the next pass of the print head.
  7. Ink droplets dry quickly upon contact with the paper.

Laser printer

  1. A photosensitive drum is cleaned and then positively charged by a primary corona wire or roller.
  2. A laser beam scans the drum, discharging certain areas to form an electrostatic image of the print on the drum.
  3. The drum then passes through a toner hopper. The negatively charged toner particles stick to the positively charged areas of the drum.
  4. Paper is fed from the tray and positively charged by a roller.
  5. The drum rolls over the paper, and the toner particles are transferred from the drum to the paper due to the opposing charges.
  6. The paper passes through fuser rollers where heat and pressure melt the toner particles, fusing them permanently to the paper.
  7. Any residual toner is cleaned off the drum, and it is ready for the next printing cycle.

3D printer

  • Additive:
    • The printer is loaded with the material with which to make the model, such as resins or plastics.
    • The printer then builds the model layer by layer by depositing the material on top of the previous layer and hardening it.
    • The model is then left to cool.
  • Subtractive:
    • A solid block is cut using different tools such as lasers or blades.

Liquid Crystal Display (LCD) screen

  1. The backlight emits light that passes through the first polarizing filter.
  2. When an electric current is applied, the liquid crystals twist or align to allow varying amounts of light to pass through.
  3. The light passes through colour filters (red, green, blue) to create the desired colour for each pixel.
  4. The modulated light then passes through the second polarizer and forms the visible image on the screen.

Light-Emitting Diode (LED) screen

  1. LED screens are made up of tiny pixels arranged in a matrix.
  2. Each pixel has 3 LEDs of red, green and blue colour.
  3. Different amounts of current are given to each LED to produce different colours.

Speaker

  1. An electrical signal is sent to a coil in the speaker.
  2. The current causes the coil to move back and forth.
  3. This coil is connected to a diaphragm which also moves back and forth, creating compressions and rarefactions, hence producing sound.

Sensors

  • Acoustic sensor: Detects sound levels in the environment. Used in noise monitoring systems and voice recognition applications.
  • Accelerometer: Measures acceleration forces. Used in smartphones for screen orientation and in vehicles for airbag deployment systems.
  • Flow sensor: Measures the rate of fluid flow. Used in water treatment plants and fuel consumption monitoring systems.
  • Gas sensor: Detects the presence of gases in the environment. Used in air quality monitoring and industrial safety systems.
  • Humidity sensor: Measures the moisture content in the air. Used in climate control systems and weather monitoring stations.
  • Infra-red sensor: Detects infrared radiation. Used in remote controls and motion detection systems.
  • Level sensor: Measures the level of liquids or solids. Used in tank level monitoring and industrial process control.
  • Light sensor: Measures ambient light intensity. Used in automatic lighting systems and screen brightness adjustment.
  • Magnetic field sensor: Detects magnetic fields. Used in compasses and industrial magnet detection.
  • Moisture sensor: Measures the moisture level in materials. Used in soil moisture monitoring for agriculture and material moisture testing.
  • pH sensor: Measures the acidity or alkalinity of a solution. Used in water quality monitoring and chemical processing.
  • Pressure sensor: Measures pressure of gases or liquids. Used in weather stations and hydraulic systems.
  • Proximity sensor: Detects the presence of objects nearby. Used in smartphones for screen auto-turn off and in industrial automation for object detection.
  • Temperature sensor: Measures temperature. Used in weather monitoring devices.

3.3 Data storage

Primary Storage

Primary storage refers to the memory that is directly accessed by the CPU to store and retrieve data.

RAM (Random Access Memory)

RAM is a type of memory used for temporary storage of data that is actively being used or processed by the CPU.

  • It is volatile, which means that it loses its data when the power is turned off.
  • It allows quick read and write access.
  • It is used to store running applications and the operating system. It also provides the workspace for the CPU to manipulate data.

ROM (Read Only Memory)

ROM is a type of non-volatile memory that stores critical boot and firmware instructions.

  • It is non-volatile, which means that it retains data even when the power is off.
  • Data cannot be written to a ROM.
  • Data is pre-written.
  • It stores the BIOS (Basic Input/Output System) or firmware, which initializes hardware and loads the operating system on startup.

Secondary Storage

Secondary storage refers to storage devices and media that are not directly accessed by the CPU.

  • Retains data without a continuous power supply.
  • Used to store data and programs permanently or for extended periods.
  • Typically offers much larger storage capacities compared to primary storage.
  • Generally slower than primary storage in terms of data access speeds.

Magnetic storage

  • Magnetic storage devices use magnetic platters, which are divided into concentric circles called tracks, and further subdivided into sectors.
  • Data is read and written using read/write heads that move across the platters. These heads contain electromagnets that create or detect magnetic fields on the surface of the platters.
  • When writing data, the electromagnet polarizes tiny regions of the platter to represent binary data (0s and 1s). When reading data, the head detects the magnetic polarity to retrieve the stored information.
  • Example: Hard Disk Drive (HDD)

Optical storage

  • Optical storage devices use lasers to read and write data on a disc's surface. The disc is divided into tracks and sectors.
  • During the writing process, a laser creates pits and lands on the surface of the disc.
  • When reading data, a laser beam scans the surface of the disc. The reflection of the laser changes between pits and lands, which is detected by a sensor and interpreted as binary data.
  • CD:
    • Read using red laser
    • Data is stored in a single layer
    • Smallest storage capacity
  • DVD:
    • Uses a laser with a shorter wavelength than CDs
    • Can have single or dual layers, providing higher capacity compared to CDs
  • Blu-ray:
    • Uses a blue-violet laser with a shorter wavelength than DVDs, allowing for a higher density of data storage
    • Can store significantly more data due to the higher density and multiple layers, hence has highest storage capacity

Solid-state storage (flash memory)

  • Non-volatile
  • Has no moving parts
  • Uses transistors and cells that are laid out in a grid
  • Uses control gates and floating gates
  • Can be NAND/NOR (technology)
  • Uses EEPROM technology
  • Stores data by flashing it onto the chips
  • Data stored by controlling the flow of electrons through transistors
  • Reads and writes sequentially
  • When data is stored the transistor is converted from 1 to 0
  • Example: M.2 SSD, USB

HDD vs. SSD

  1. HDD has moving parts but SSD does not
  2. HDD uses magnetic storage whereas SSD uses flash memory
  3. HDD is slower to access data than SSD
  4. HDD will create noise/heat, whereas SSD runs quieter/cooler
  5. HDD has higher power consumption than SSD
  6. HDD has greater longevity/more read-write cycles whereas SSD has lower longevity/limited number of read-write cycles
  7. HDD is larger in physical size/heavier than SSD
  8. HDD is normally cheaper for the same capacity of storage as SSD
  9. HDD is available in a larger storage capacity than SSD

Virtual Memory

  • Virtual memory is created by partitioning HDD or SSD and setting aside that space just for the virtual memory.
  • When the RAM is fully utilized, the OS moves pages of data that are not actively being used from the RAM to the swap file on the hard drive or SSD.
  • This process frees up RAM for other active processes.
  • When the data in the swap file is needed again, it is transferred back to the RAM, potentially replacing other data that is moved to the swap file.

Cloud Storage

  • Data is stored on remote servers, which are accessed via the internet.
  • The data is stored in large data centres that contain thousands of servers and storage devices.
  • Users access cloud storage via the internet using web interfaces, desktop applications, or mobile apps provided by the cloud storage service.
  • Authentication mechanisms ensure that only authorized users can access the stored data.
  • Cloud storage provides scalable storage solutions.

Cloud storage vs. local storage

  • Cloud storage is accessible from anywhere with an internet connection, whereas local storage is limited to the physical location.
  • Cloud storage is easily scalable based on user needs, while local storage requires purchasing additional hardware.
  • Cloud storage reduces hardware and maintenance costs, in contrast to local storage which involves a high initial investment.
  • Cloud storage offers backup and recovery solutions, whereas local storage is vulnerable to hardware failures and physical damage.
  • Cloud storage is vulnerable to cyber-attacks, while local storage provides full control and customisable security measures.
  • Cloud storage requires a stable internet connection, while local storage is accessible without internet.

3.4 Network hardware

Network Interface Card (NIC)

A network interface card is a hardware component that allows a computer to connect to a network. The NIC provides the physical interface and necessary software to enable network communication, allowing data to be transmitted and received over the network.

MAC (Media Access Control) Address

  • A MAC address is a unique hardware identifier assigned to each network interface card by the manufacturer.
  • A MAC address is typically a 48-bit number (12 hex digits) usually represented in hexadecimal format. It is divided into two main parts:
    • The first 6 digits identify the manufacturer of the NIC.
    • The other 6 digits serve as a serial number or unique identifier for the device.
  • It cannot be changed.

IP (Internet Protocol) Address

  • An IP address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
  • Uniquely identifies devices on a network, ensuring data is sent to the correct destination.
  • Informs about the device's location within a network, facilitating routing and delivery of data packets.
  • IPv4:
    • Consists of 32 bits.
    • Usually represented as four decimal numbers separated by dots (dotted decimal format), e.g., 192.168.1.1.
    • Supports approximately 4 billion unique addresses.
  • IPv6:
    • Consists of 128 bits.
    • Represented as eight groups of four hexadecimal digits, separated by colons, e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
    • It can also be shortened, e.g. ::192:168:1:1.
    • Supports a virtually unlimited number of unique addresses, addressing the limitations of IPv4.

Router

  • A router directs data packets between different networks, ensuring they reach the correct destination.
  • It uses a routing table to determine the best path for data transmission based on IP addresses.
  • Routers assign unique IP addresses to each device on a local network. This process is essential for managing multiple devices and avoiding IP conflicts.
  • Routers connect local area networks (LANs) to wide area networks (WANs), such as the internet. They manage the data traffic between these networks, ensuring efficient communication and data flow.
  • When a packet reaches the router, it checks the packet header for the IP address of its destination. It then sends the packet along the fastest route.
Test yourself41 flashcards on this chapter.Flashcards →

Practise this chapter

Every past-paper question on these topics, with the mark scheme.