Welcome to the Hardware Section: Computer Architecture
Hello future Computer Scientists! This chapter, "Computer Architecture," is where we look under the hood of a computer system. We’ll explore the essential physical components (the hardware) and how they work together to bring your programs and apps to life.
Understanding hardware is crucial because it explains why your computer sometimes runs fast, sometimes slow, and exactly how it processes the billions of instructions you give it every day. Don't worry if the names seem complicated—we will break down the system into simple, understandable jobs!
3.1 The Central Processing Unit (CPU)
The Role of the CPU and Microprocessors (3.1.1)
The Central Processing Unit (CPU) is often called the "brain" of the computer. Its main job is to process instructions and data that are input into the computer so that a result (output) can be produced.
Think of the CPU as the Chief Executive Officer (CEO) of the computer system. It receives instructions, delegates tasks, and makes sure everything runs on time.
A microprocessor is simply a modern type of integrated circuit (IC) that performs the functions of a CPU, built entirely onto a single, small silicon chip. Most computers, phones, and embedded systems use microprocessors today.
The Von Neumann Architecture (3.1.2)
Most modern computers use the Von Neumann architecture, where instructions and data are stored together in the same memory unit (RAM). The CPU constantly communicates with this memory via internal components.
Key Components of the CPU (3.1.2a)
The CPU contains several vital components that handle processing and control:
- Arithmetic Logic Unit (ALU): Performs all arithmetic calculations (like addition and subtraction) and logical operations (like AND, OR, NOT). The calculator and decision-maker.
- Control Unit (CU): Manages and coordinates all other components of the computer. It controls the flow of data and instructions and issues timing signals. The manager of the CPU.
- Registers: Tiny, super-fast memory locations used to hold data or instructions temporarily during the Fetch-Decode-Execute cycle.
Essential Registers
- Program Counter (PC): Holds the address of the next instruction to be fetched.
- Memory Address Register (MAR): Holds the memory address of the data or instruction that the CPU wants to read or write to.
- Memory Data Register (MDR): Holds the data or instruction that has been fetched from or is about to be written to memory.
- Current Instruction Register (CIR): Holds the instruction currently being decoded and executed.
- Accumulator (ACC): Temporarily holds the results of calculations performed by the ALU.
💡 Memory Aid: MAR holds the Address, MDR holds the Data.
Buses
Buses are electrical pathways that transmit data, addresses, and signals between the CPU and other components (like RAM).
- Address Bus: Carries the address from the CPU (stored in the MAR) to memory. It is unidirectional (one-way).
- Data Bus: Carries actual data and instructions between the CPU and memory (via the MDR). It is bidirectional (two-way).
- Control Bus: Carries control signals (e.g., read/write signals, clock signals) that coordinate all activities. It is bidirectional.
The Fetch-Decode-Execute (FDE) Cycle (3.1.2b)
This is the core process the CPU repeats constantly to run a program. It happens millions of times per second!
Step-by-Step FDE Cycle:
- FETCH:
- The address of the next instruction is copied from the PC to the MAR.
- The PC is incremented to point to the instruction after next.
- The instruction/data is read from RAM (at the address held in MAR) and sent along the Data Bus to the MDR.
- The instruction is copied from the MDR to the CIR.
- DECODE:
- The Control Unit (CU) interprets the instruction stored in the CIR. It figures out what the instruction means (e.g., "Add these two numbers").
- The CU prepares the necessary components (like the ALU or specific registers) for the execution phase.
- EXECUTE:
- The instruction is carried out. This might involve the ALU performing a calculation, data being moved between registers, or writing data back to memory.
- If a calculation is done, the result is often stored in the Accumulator (ACC).
Don't worry if this seems tricky at first—practice labelling diagrams and remembering the register roles, especially how PC $\rightarrow$ MAR and MDR $\rightarrow$ CIR in the Fetch phase.
Factors Affecting CPU Performance (3.1.3)
Three main characteristics determine how fast a CPU can execute instructions:
- Clock Speed:
- Measured in Gigahertz (GHz). This is the number of cycles (FDE cycles) the CPU can perform per second.
- Effect: A faster clock means the CPU executes more instructions per second, leading to higher performance.
- Number of Cores:
- A core is essentially an independent processing unit within the CPU.
- Effect: More cores mean the CPU can run multiple instructions or tasks simultaneously (parallel processing). A quad-core CPU can handle four tasks concurrently better than a single-core CPU.
- Cache Size:
- Cache is small, fast memory located *inside* or very close to the CPU. It stores frequently used instructions and data.
- Effect: A larger cache means the CPU is less likely to have to wait for the slower main memory (RAM). Larger cache usually increases performance.
Instruction Set (3.1.4)
An instruction set is the complete list of all the commands (in machine code) that a specific CPU can understand and process. Every different type of CPU (e.g., Intel vs ARM) has its own unique instruction set.
Embedded Systems (3.1.5)
An embedded system is a computer system built into a larger device, designed to perform one or a few dedicated functions. They are often microprocessors optimized for real-time control.
They are different from a general-purpose computer (like a PC or laptop) which can perform many functions.
Examples of Embedded Systems:
- Domestic appliances (washing machines, microwaves)
- Cars (engine management, ABS braking systems)
- Security systems, lighting systems, and vending machines.
The CPU uses the FDE cycle to run programs. The speed is boosted by having more cores, a faster clock, and a larger cache. Small, specialized computers are called embedded systems.
3.2 Input and Output Devices
The CPU needs ways to receive information (Input) and display or act upon processed information (Output).
Input Devices (3.2.1)
An input device allows data or instructions to be entered into the computer system.
Examples include:
- Keyboard, Optical Mouse: Used for text entry and cursor control.
- Barcode Scanner, QR Code Scanner: Reads optical patterns for data entry (like product codes).
- Digital Camera, Microphone: Captures images and sound, converting them into digital data.
- Touch Screen: A device that combines input and output.
- Resistive: Responds to pressure (e.g., stylus or glove).
- Capacitive: Responds to electrical charge (e.g., bare finger).
- Infra-red: Uses an array of infrared beams/sensors to detect touch.
- 2D and 3D Scanners: Converts physical objects or documents into digital representations.
Output Devices (3.2.2)
An output device takes processed data from the computer and converts it into a human-readable or machine-actionable form.
Examples include:
- LED/LCD Screen: Displays visual output. (LED is usually brighter and more energy efficient than traditional LCD).
- Projectors (DLP, LCD): Projects visual output onto a large surface.
- Inkjet Printer, Laser Printer: Produces hard copy output.
- Speaker: Produces sound output.
- 3D Printer: Creates three-dimensional physical objects.
- Actuator: A mechanism that converts electrical signals into physical motion or force (e.g., opening a valve, moving a robot arm, turning a motor). Used heavily in automated systems.
Sensors and Control (3.2.3)
A sensor is an input device that detects and measures a physical property (like light, temperature, or pressure) and converts it into data (usually an electrical signal) that a computer can process.
Sensors are fundamental to creating automated systems (see Topic 6.1). The microprocessor monitors the sensor data and sends instructions to an actuator if an action is needed.
Types of Sensors and Data Captured
- Temperature Sensor: Measures heat/cold. (Used in central heating systems).
- Light Sensor: Measures ambient light intensity. (Used in automatic street lighting).
- Pressure Sensor: Measures force/weight. (Used in burglar alarms on floor mats).
- Acoustic Sensor: Measures sound levels/vibration. (Used in security systems to detect glass breaking).
- Accelerometer: Measures acceleration/tilt/vibration. (Used in phones to change screen orientation).
- Moisture/Humidity Sensor: Measures water content/dampness. (Used in agriculture for soil irrigation).
- Gas Sensor: Measures concentrations of specific gases. (Used in industrial safety/factories).
- Flow Sensor: Measures the speed or volume of liquid/gas passing a point. (Used in measuring fuel consumption).
- Proximity Sensor: Detects the presence of nearby objects without physical contact. (Used in parking sensors on cars).
- Level Sensor: Measures the height of a substance (e.g., water in a tank).
- Infra-red Sensor: Measures heat signature or is used in remote controls.
- Magnetic Field Sensor: Measures the presence or strength of a magnetic field (e.g., compass applications).
- pH Sensor: Measures acidity or alkalinity. (Used in environmental science or agriculture).
Selecting the most suitable sensor depends entirely on the context and the physical quantity you need to monitor. If you are checking the environment, you likely need a temperature, humidity, or light sensor.
Input devices capture data; output devices display results or actuate movement. Sensors are specialized input devices essential for automated systems.
3.3 Data Storage
Primary Storage (3.3.1)
Primary storage is the memory directly accessible by the CPU. It is essential for storing the data and instructions that the CPU is currently working on.
- Random Access Memory (RAM):
- Allows data to be read from and written to (read/write).
- It is volatile: data is lost when power is switched off.
- Used to store the Operating System and currently running applications/data.
- Read Only Memory (ROM):
- Allows data to be read, but not usually written to (read-only).
- It is non-volatile: data remains even when power is switched off.
- Used to store the computer's startup instructions (the bootloader or firmware).
Why are both needed? The computer needs ROM to start up (since ROM holds instructions without power) and needs RAM to run programs efficiently once it's on (since RAM is much faster for dynamic, temporary storage).
Secondary Storage (3.3.2)
Secondary storage is used for the long-term, permanent storage of data and programs. It is non-volatile. The CPU cannot access it directly; data must first be copied into RAM.
Types of Secondary Storage (3.3.3)
1. Magnetic Storage (e.g., Hard Disk Drive - HDD)
- Operation: Uses spinning platters coated in magnetic material. Data is stored by magnetizing tiny areas (bits) on the platters. Read/write heads move across the surface to read and write data using electromagnets.
- Structure: Platters are divided into concentric tracks, which are further divided into sectors.
- Examples: Hard Disk Drives (HDD).
2. Optical Storage (e.g., CD, DVD, Blu-ray)
- Operation: Data is stored as microscopic indents (pits) and flat areas (lands) on a spinning disc. A laser beam is shone onto the surface; the reflection pattern is read to interpret the binary data.
- Examples: CDs, DVDs, Blu-ray Discs.
3. Solid-State Storage (Flash Memory) (e.g., SSD, USB drive)
- Operation: Uses electronic circuits and NAND or NOR technology. Data is stored using electrical charges trapped in floating gates within transistors. Since there are no moving parts, it is very fast.
- Examples: Solid-State Drives (SSD), USB flash drives, SD cards.
Virtual Memory (3.3.4)
Sometimes, the RAM is full, but the computer needs to load more programs or data. This is where virtual memory comes in.
- What it is: Virtual memory is a section of the secondary storage (like the HDD or SSD) that the operating system treats as if it were RAM.
- How it works: When RAM is full, the OS moves inactive data and instructions (called pages) from RAM to virtual memory. When those pages are needed again, they are swapped back into RAM.
- Why it's necessary: It allows the computer to run more applications than the physical RAM size permits, preventing the system from crashing. However, swapping data to slow secondary storage significantly reduces performance.
Cloud Storage (3.3.5 & 3.3.6)
Cloud storage refers to storing data on remote physical servers (owned by a provider like Google or Amazon) rather than storing it locally on your own devices. The data is accessed over the internet.
Advantages vs. Local Storage:
- Advantages (Cloud):
- Data can be accessed remotely from any location with internet access.
- Automatic backups and disaster recovery provided by the vendor.
- Scalability (easily increase or decrease storage space needed).
- Disadvantages (Cloud):
- Requires a continuous internet connection to access data.
- Security and privacy risks (relying on a third-party vendor).
- Speed is dependent on internet bandwidth (can be slow for large files).
Primary (RAM/ROM) is fast, volatile/non-volatile, and used for active tasks. Secondary (HDD/SSD/Optical) is for permanent, non-volatile storage. Virtual memory uses secondary storage to temporarily extend RAM when needed.
3.4 Network Hardware
To connect devices and communicate across networks, specialized hardware is needed.
Network Interface Card (NIC) (3.4.1)
Every computer that needs to access a network must have a Network Interface Card (NIC). The NIC translates data between the computer and the network medium (like an Ethernet cable or Wi-Fi radio waves).
MAC Addresses (3.4.2)
The Media Access Control (MAC) address is a unique physical identifier assigned to the NIC at the point of manufacture.
- Structure: Usually written in hexadecimal (e.g., 00-1A-2B-3C-4D-5E).
- Parts: The first part identifies the manufacturer, and the second part is the unique serial number of the device.
- Purpose: Used primarily within local networks to ensure data packets reach the correct physical device.
IP Addresses (3.4.3)
The Internet Protocol (IP) address is a numerical label assigned to every device connected to a computer network.
- Purpose: Used for logical addressing and routing across large networks, including the Internet. It tells the network where the device is located.
- Allocation: IP addresses are allocated by the network; they can be static (permanently set) or dynamic (assigned temporarily, usually by a router).
IPv4 vs IPv6
The internet relies on IP addresses, and two versions exist:
- IPv4: Uses 32 bits (e.g., 192.168.1.1). Offers about 4.3 billion unique addresses.
- IPv6: Uses 128 bits (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Necessary because IPv4 addresses ran out. Offers vastly more addresses and better routing capabilities.
The Role of a Router (3.4.4)
A router is a network device that directs data (in the form of packets) between different computer networks (network A and network B).
- A router is essential for connecting a local network (LAN) to the Internet (WAN).
- It uses the IP address contained in the packet header to decide the most efficient route for the data to travel to its specific destination.
- Many routers also have the capability to assign dynamic IP addresses to devices on the local network (this is called DHCP, though you only need to know it assigns IP addresses).
The NIC is the interface. The MAC address is the permanent physical ID. The IP address is the logical network location used by the router to send data to the correct destination.
Conclusion
Well done! You have now grasped the foundational structure of computer systems. We've seen how the CPU processes information using its specialized components and the FDE cycle, how hardware captures and displays data, and where that data is stored permanently. You also know the key pieces of hardware needed to connect to the world.
Keep reviewing the register roles and the differences between storage types—these are vital for exam success!