(2) Hardware Architecture and the Fetch-Execute Cycle
Hardware Architecture Overview
Hardware architecture refers to the physical components that constitute a computer system and how they interact to process information.
The fundamental goal of understanding hardware architecture is to define the specific roles of the Central Processing Unit (CPU), memory hierarchies, and input/output systems.
Computers have evolved through three distinct generations of hardware:
The 1960s and 1970s Era: Large-scale systems that could occupy an entire room (comparable to the size of refrigerators). These systems were made of modular components, including discrete resistors, transistors, and capacitors mounted on Printed Circuit Boards (PCBs).
The 1990s and Early 2000s Era: Desktop computers characterized by mechanical noises during startup and larger, discrete components like motherboards and physical hard drives.
Modern Era: Highly integrated hardware exemplified by the Raspberry Pi and the specialized components found inside mobile cell phones.
The Central Processing Unit (CPU)
The CPU is considered the functional equivalent of the computer's "brain," though it is more accurately described as an extremely fast hand calculator with massive storage access rather than a truly intelligent entity.
Physical Composition:
The CPU is a highly sophisticated circuit containing millions of photo-imprinted transistors on a small square of material, often compared to a jewel in appearance.
Transistors serve as the fundamental building blocks, capable of making simple "yes/no" decisions and storing tiny amounts of information when interconnected correctly.
Performance Metrics:
A modern CPU typically executes approximately instructions per second.
Instructions are processed as sets of electrical pulses transmitted through integrated wires, often in widths of or bits.
Operational Requirements:
The high volume of electrical activity ( operations per second) generates significant heat.
If the cooling components (heat sinks or fans) are removed while the CPU is under load, the processor can sustain damage or fail due to the intense thermal energy produced by the transistors.
Memory Hierarchies and Storage
Main Memory:
Known as the primary location where programs reside while they are actively executing.
It is designed for extreme speed to keep pace with the CPU's fetch requests.
Volatility: Main memory is volatile, meaning all data and programs currently loaded are erased instantly when the power is turned off.
Secondary Memory:
This provides permanent, non-volatile storage for files such as Python scripts (), Word documents, and PowerPoints.
Older Technology: Physical hard disk drives (HDDs) utilize spinning platters of magnetic media and a mechanical head that moves in and out to read or write data magnetically.
Modern Technology: Solid-state storage, such as USB flash drives and SSDs, are replacing mechanical disks, offering faster access without moving parts.
The Motherboard:
Referred to as the "mother of all boards," it acts as the central hub connecting the CPU, main memory, and secondary storage.
Calculated paths and wires on the motherboard facilitate the transport of program data between hardware components.
The Fetch-Execute Cycle
The Fetch-Execute cycle is the core process of computer operation involving the CPU and Main Memory.
Step 1 (Fetch): The CPU asks "What's next?" and pulls a set of electrical pulses (an instruction) from the main memory via the motherboard's circuitry.
Step 2 (Execute): The CPU performs the specific command defined by those electrical pulses.
Repetition: This cycle repeats billions of times per second. The CPU is programmed to continually request the next instruction in sequence from the program loaded in the main memory.
Input and Output (I/O) Devices
I/O devices are the interface through which the computer interacts with the external world and human users.
Input Devices: Tools used to feed data into the computer, such as keyboards and mice.
Output Devices: Mediums used to display or convey data from the computer to the user, such as screens.
From Python to Machine Language
Machine Language:
The internal language of the CPU consists entirely of sequences of zeros () and ones ().
Every instruction the CPU executes must eventually be expressed in this binary format.
Translation Process:
Programmers write code in high-level languages like Python (e.g., if\,x < 3:\,print()).
This high-level code is stored in secondary memory as a file.
When the program is run, software known as a compiler or an interpreter translates the Python instructions into machine language.
The translated machine language is then loaded into the main memory, where the CPU can access it through the Fetch-Execute cycle.
In this context, the program acts as a "creative version" of the programmer's intent, living in the main memory during execution to answer the CPU's constant queries of "What to do next?"