MGU Computer Science Series — Computer Science Foundations
Part IV: Computer Systems
CPU · Memory · Storage · I/O · Buses · Fetch-Decode-Execute · Embedded Systems
Chapter 15 of 28
MGU Computer Science Series  ·  Computer Science Foundations  ·  Library Textbook Edition

Chapter 15:
Hardware and Computer
Architecture

The physical machines that run every program — CPU, memory, storage, buses, graphics, the fetch-decode-execute cycle, embedded systems, and the tradeoffs that shape every device

■ Part IV: Computer Systems ■

■ 10 Sections  •  Chapter 15 of 28 ■

Follows Chapter 14: Files, Tables, and Data Processing  ·  Prepares students for Chapter 16: Operating Systems

Purpose and Overview

Every program you have written, studied, or used runs on physical hardware — real components made of metal, silicon, and circuits that carry electrical signals at extraordinary speed. Understanding that hardware is not optional background knowledge for a computer scientist; it is the foundation that explains why software behaves the way it does. When a program runs slowly, crashes, or consumes too much battery, the explanation usually begins inside the machine.

This chapter introduces the physical layer of computing. You will learn what the major hardware components are, what each one does, and how they work together to execute programs. The central idea is simple: a computer is a machine that fetches instructions from memory, decodes what each instruction means, and executes the required operation — one instruction at a time, billions of times per second. Every other hardware concept in this chapter connects to that cycle.

By the end of this chapter, you will be able to identify the major components of a computing system, explain the role each plays, trace the fetch-decode-execute cycle conceptually, and reason about how hardware choices affect performance, cost, energy use, and software behavior. These ideas prepare you directly for Chapter 16, which covers the operating system — the software layer that sits between hardware and everything else.

Opening Question

When you open a web browser and type a web address, what physically happens inside the machine? Instructions stored in memory are loaded into the CPU, decoded, executed, and the results are written back — in a chain so fast it appears instantaneous. Every click, keystroke, and video frame passes through the same hardware described in this chapter. By the end, that chain will make complete sense.

10Sections
11Objectives
20+Key Terms
8+Worked Examples

Learning Objectives

  1. 1Define hardware and distinguish it from software and data.
  2. 2Describe the role and structure of the CPU, including cores, clock speed, and cache.
  3. 3Explain the difference between RAM, cache memory, and persistent storage.
  4. 4Distinguish between storage types including HDDs, SSDs, and optical media.
  5. 5Identify common input and output devices and explain their roles.
  6. 6Describe how the motherboard, buses, and expansion slots connect components.
  7. 7Explain the role of graphics processing and why it differs from general CPU computation.
  8. 8Trace the fetch-decode-execute cycle at a conceptual level.
  9. 9Define embedded systems and give examples across multiple domains.
  10. 10Identify key performance metrics including clock speed, cores, RAM capacity, and storage speed.
  11. 11Analyze hardware tradeoffs among performance, power consumption, cost, and reliability.

Sections at a Glance

Sections 15.1 – 15.3
The Core of the Machine: Hardware, CPU, and Memory
What Hardware Is · The Central Processing Unit · The Memory Hierarchy

What Hardware Is

The word hardware refers to the physical components of a computing system — everything you can touch, see, and measure in grams and centimeters. A processor chip, a memory module, a hard drive, a keyboard, a screen, and the circuit board they are all connected to: these are hardware. Hardware is distinct from software, which refers to the programs and data that run on the hardware, and from data, which is the information being processed and stored.

The relationship between hardware and software is one of the most important ideas in computer science. Hardware provides the physical capacity to compute — the circuits, the storage cells, the electrical pathways. Software gives those circuits meaning and direction — it tells the hardware what to do and in what order. Neither is useful without the other. A processor with no software is like a factory with no instructions; software with no processor is like a recipe with no kitchen.

Hardware can be divided into several broad categories that will structure this entire chapter. The processor performs the actual computations. Memory holds the instructions and data the processor is actively working with. Storage preserves information even when power is off. Input devices bring information into the system. Output devices send results out of the system. The motherboard connects all of these components and allows them to communicate. Understanding what each category does — and why it must be designed carefully — is the foundation of computer architecture.

The Hardware-Software Boundary

Hardware is physical; software is logical. Hardware executes instructions in binary at the level of electrical signals. Software is a set of instructions written in code, translated by compilers or interpreters into those binary signals. The operating system sits at the boundary, managing hardware resources on behalf of software applications.

Hardware CategoryPrimary FunctionExamples
Processor (CPU)Executes instructions; performs arithmetic and logicIntel Core, AMD Ryzen, Apple M-series
Memory (RAM)Holds active programs and data for fast CPU accessDDR5 DIMM modules, LPDDR5 in phones
StoragePersists data when power is offSSD, HDD, USB flash drive
Input DevicesBring user or environmental data into the systemKeyboard, mouse, camera, microphone
Output DevicesSend processed results out to users or systemsMonitor, speakers, printer
MotherboardConnects all components; carries data between themATX motherboard, laptop main board
Graphics ProcessingHandles visual rendering and parallel computationNVIDIA GPU, AMD Radeon, Intel Iris Xe
Power SupplyConverts and delivers electrical power to componentsATX PSU, laptop battery and adapter
Why Hardware Knowledge Matters for Software

Every performance decision in software — whether to cache a value, use a simpler algorithm, or process data in smaller chunks — is rooted in hardware realities. Programmers who understand hardware write faster, more efficient software. System designers who understand hardware make better choices about which components to combine.

The CPU

The Central Processing Unit, or CPU, is the component that actually executes instructions. It is sometimes called the "brain" of the computer, though the analogy is limited — the CPU does not think or decide; it executes a sequence of precisely defined operations at enormous speed. What makes the CPU remarkable is not intelligence but relentless, high-speed execution of simple operations: add these two numbers, compare these values, move this data from one location to another, jump to a different instruction if a condition is true.

Inside the CPU, two functional units do most of the work. The Arithmetic Logic Unit, or ALU, performs mathematical operations (addition, subtraction, multiplication, division) and logical operations (AND, OR, NOT, comparison). Every computation your program performs — calculating a score, sorting a list, encrypting a message — passes through the ALU. The Control Unit manages the flow: it fetches the next instruction, decodes what it means, directs the ALU or other units to carry it out, and moves to the next instruction. The control unit is the coordinator; the ALU is the worker.

Between the ALU and main memory sit the registers. Registers are tiny, extremely fast storage locations built directly into the CPU chip. A modern CPU might have a few dozen registers. They hold the values the CPU is working with right now: the two numbers about to be added, the result of the last comparison, the address of the next instruction. Registers are faster than any other form of storage by a large margin, but they are also very small. A program cannot keep all of its data in registers, which is why the CPU must constantly exchange information with memory.

The clock controls how fast the CPU operates. A clock is an electronic oscillator that produces a regular signal — a beat — at a fixed frequency measured in gigahertz (GHz). One gigahertz means one billion cycles per second. The CPU performs one or more operations per clock cycle. A CPU running at 3.5 GHz executes up to 3.5 billion operations every second. Clock speed is one measure of CPU performance, but it is not the only one. Modern CPUs also use pipelining — overlapping the stages of successive instructions — and execute multiple instructions simultaneously using a technique called superscalar execution.

Most modern CPUs contain multiple cores. Each core is an independent processing unit capable of executing its own stream of instructions. A quad-core CPU contains four such units on a single chip. Programs designed to use multiple cores simultaneously — through a technique called parallel or concurrent programming — can run significantly faster than on a single-core CPU. Operating systems distribute tasks across cores automatically, which is why a modern computer can play music, download a file, and run a text editor all at the same time without any of them grinding to a halt.

Between the CPU and main memory sits the cache. Cache is a small, very fast memory built directly into or very close to the CPU chip. Modern CPUs typically have multiple cache levels: L1 cache (the fastest and smallest, often 32–128 kilobytes per core), L2 cache (larger and slightly slower, often 256 kilobytes to 1 megabyte per core), and L3 cache (shared among cores, often 8–64 megabytes). When the CPU needs data, it checks L1 first. If the data is not there, it checks L2, then L3, then main RAM, then storage. Each level is larger but slower. Keeping frequently used data in cache dramatically reduces the time the CPU spends waiting.

Figure 15.2 — CPU Internal Structure (Conceptual)
CENTRAL PROCESSING UNIT (CPU) CONTROL UNIT Fetches & decodes instructions ALU Arithmetic & logic operations REGISTERS Fastest storage ~32 locations L1 CACHE 32–128 KB ~4 cycles L2 CACHE 256 KB–1 MB ~12 cycles L3 CACHE 8–64 MB ~40 cycles CLOCK 2–6 GHz Times all ops INTERNAL BUS — connects CPU to RAM and other components
Example 15.2.1
Reading a CPU specification
  • ScenarioA laptop is advertised with a processor described as: "4-core, 8-thread CPU, 3.2 GHz base clock, 4.5 GHz boost clock, 8 MB L3 cache." Interpret each specification.
  • 4-coreThe chip contains four independent processing units. Programs can run on multiple cores simultaneously, improving multitasking and parallel performance.
  • 8-threadEach physical core can handle two instruction streams simultaneously using a technique called hyperthreading. From the operating system's perspective, this appears as 8 logical processors.
  • 3.2 GHz baseThe guaranteed minimum speed under normal operating conditions: 3.2 billion clock cycles per second.
  • 4.5 GHz boostWhen the CPU detects demanding workloads and thermal conditions allow it, individual cores can temporarily run at up to 4.5 GHz.
  • 8 MB L3Eight megabytes of shared last-level cache. Frequently accessed data stored here avoids the much slower trip to main RAM.
Reading hardware specs is a core skill: each number tells you something specific about speed, capacity, or capability — not marketing.
Common Misconception — Clock Speed Alone Determines Performance

A higher clock speed does not always mean faster performance. A 4-core CPU at 3.0 GHz will often outperform a single-core CPU at 4.0 GHz for most modern workloads because modern software uses multiple threads. Core count, cache size, memory bandwidth, and instruction-level parallelism all matter. Always consider the full specification, not just the clock speed.

Memory

Memory is where the CPU finds the instructions and data it needs to work with right now. The word "memory" in computer science refers specifically to Random Access Memory, or RAM — the fast, temporary storage that holds the operating system, open applications, and data currently in use. RAM is volatile: when power is removed, everything stored in it disappears. This is why your work is lost if the computer loses power before you save, and why the computer must reload the operating system every time it starts.

RAM is measured in gigabytes. A modern desktop might have 16 to 64 GB of RAM; a smartphone typically has 6 to 16 GB. More RAM allows more programs to run simultaneously without the system slowing down. When RAM fills up, the operating system uses storage as an overflow area called virtual memory or a swap file — but storage is dramatically slower than RAM, so this causes noticeable performance drops.

The relationship between RAM and the CPU is governed by memory bandwidth — how much data can move between them per second. Even if a CPU can compute very quickly, it can only go as fast as memory can feed it. This is sometimes called the memory bottleneck. CPU designers address it with cache, which stores copies of recently used data close to the processor so the CPU does not need to wait for the slower RAM on every operation.

It is critical to understand the difference between RAM and storage. Students frequently confuse the two because both hold data. The key distinction is persistence and speed. RAM is fast (measured in nanoseconds) but temporary. Storage is slow (measured in microseconds or milliseconds) but permanent. When you save a file, you are moving data from RAM into storage. When you open a file, you are moving data from storage into RAM. The CPU only works directly with data that is in RAM or in cache — never directly from storage.

Figure 15.3 — Memory Hierarchy: Speed, Size, and Cost
L1 CACHE 32–128 KB · <4 ns L2 CACHE 256 KB – 1 MB · ~12 ns L3 CACHE (shared) 8–64 MB · ~40 ns MAIN RAM 8–128 GB · ~100 ns · volatile Fastest Largest & smallest & slowest
Memory TypeVolatile?SpeedTypical SizePurpose
L1 CacheYes~1–4 ns32–128 KB/coreImmediate CPU working storage
L2 CacheYes~5–15 ns256 KB–1 MB/coreSecondary fast buffer for L1 misses
L3 CacheYes~30–50 ns8–64 MB sharedShared last-level cache across all cores
RAM (DDR5)Yes~80–120 ns8–128 GBWorking memory for OS and apps
SSD StorageNo~50–200 µs256 GB–4 TBPersistent program and file storage
HDD StorageNo~3–10 ms500 GB–20 TBHigh-capacity persistent storage
Study Note — The ns, µs, ms Scale

One nanosecond (ns) = one billionth of a second. One microsecond (µs) = one millionth of a second. One millisecond (ms) = one thousandth of a second. An SSD at 100 µs is roughly 1,000 times slower than RAM at 100 ns. An HDD at 5 ms is roughly 50,000 times slower than RAM. These differences explain why loading data from storage into RAM before processing it is not optional — it is essential for any reasonable performance.

Practice 15.1–15.3Concept Check
  1. In your own words, explain the difference between hardware and software. Give two examples of each.
  2. What is the difference between the ALU and the Control Unit inside a CPU? What does each one do?
  3. Why are registers faster than RAM? Why can't programs keep all their data in registers?
  4. A student says: "My computer has 512 GB of memory." Is this statement likely accurate or likely a confusion? Explain the difference between RAM and storage.
  5. What does it mean for memory to be volatile? Give a real-world consequence of volatility that students have experienced.
  6. If L1 cache is the fastest, why do CPUs also have L2 and L3 caches rather than just using a very large L1?
Sections 15.4 – 15.6
Persistence and Connection: Storage, I/O, and the Motherboard
Storage Types · Input and Output Devices · Motherboards, Buses, and Connections

Storage

Storage refers to the hardware that retains data even when the system is powered off. While RAM forgets everything when you shut down, storage keeps files, programs, databases, photographs, videos, and the operating system itself safely preserved for days, years, or decades. This persistence makes storage the foundation of practically everything users care about in a computer.

The two dominant storage technologies in modern computing are hard disk drives (HDDs) and solid-state drives (SSDs). A hard disk drive is a mechanical device: it contains one or more rigid magnetic platters that spin at high speed (typically 5,400 or 7,200 revolutions per minute), and a read/write head that moves across the platters to access data. Because data retrieval depends on physical motion — waiting for the right sector of the disk to spin under the head — HDDs are significantly slower than SSDs. However, HDDs offer very high capacity at low cost, which is why they remain common for large-scale backup and archival storage.

A solid-state drive uses flash memory — the same type of storage found in USB drives and smartphone storage — with no moving parts. Flash memory stores data as electrical charges trapped in memory cells. Because there is no mechanical motion, SSDs can access any location at nearly uniform speed, dramatically faster than HDDs. SSDs are also smaller, lighter, quieter, and more shock-resistant. Their primary disadvantage is cost per gigabyte, though SSD prices have dropped significantly in recent years. Most modern laptops and many desktop computers use SSDs as their primary drive.

Storage capacity is measured in standard units. One kilobyte (KB) is 1,024 bytes. One megabyte (MB) is approximately one million bytes. One gigabyte (GB) is approximately one billion bytes. One terabyte (TB) is approximately one trillion bytes. A typical SSD in a laptop today might hold 512 GB to 1 TB. An enterprise server might use multiple drives totaling dozens or hundreds of terabytes.

Beyond HDDs and SSDs, other storage media are worth understanding. USB flash drives use flash memory in a portable, removable form. Optical discs (CDs, DVDs, Blu-ray) store data as patterns of pits and lands read by a laser; they were once common for software distribution and backups but have largely been replaced by downloads and cloud storage. Cloud storage refers to storage provided by remote servers accessed over the internet — the data exists on SSDs and HDDs in data centers somewhere else, and the user accesses it through a network connection.

Storage TypeTechnologySpeedTypical CapacityBest Use
HDDMagnetic platters + moving head~100–200 MB/s500 GB – 20 TBMass storage, backups, archives
SSD (SATA)Flash memory (SATA interface)~500–600 MB/s256 GB – 4 TBOS and application drives, laptops
SSD (NVMe)Flash memory (PCIe interface)3,000–7,000 MB/s256 GB – 4 TBHigh-performance workstations, gaming
USB FlashFlash memory (removable)~30–400 MB/s8 GB – 2 TBPortable transfer, temporary storage
Cloud StorageRemote SSD/HDD over networkNetwork speedEffectively unlimitedBackup, sharing, remote access
Example 15.4.1
Choosing storage for a task
  • ScenarioA video production studio needs to store 50 TB of archived raw footage rarely accessed, a 2 TB working drive for active projects, and easy off-site backup.
  • Archive50 TB of rarely accessed footage → HDDs in a NAS (network-attached storage) array. High capacity, low cost per GB. Speed is acceptable since these files are rarely loaded.
  • Working DriveActive project files → NVMe SSD. Video editing demands fast sequential read speeds to play and render high-resolution footage without stuttering.
  • BackupOff-site backup → cloud storage or external HDDs kept at a separate location. Protects against fire, theft, or hardware failure at the studio.
Answer: Different storage types serve different purposes. No single technology is optimal for every use case.

Input and Output Devices

A computer that could not receive information from the outside world or send results back to users would be useless. Input devices bring data into the computing system. Output devices send processed results out of it. Together, they form the interface between the computing system and the humans — or other systems — that interact with it.

The most familiar input devices are the keyboard and the mouse. A keyboard converts physical key presses into electrical signals that the computer interprets as characters, commands, or shortcuts. A mouse tracks physical movement and translates it into cursor position on screen, sending click events when buttons are pressed. Touchscreens combine input and output on a single surface: a display that also detects the position and pressure of finger touches. Most smartphones, tablets, and many laptop screens use capacitive touchscreens that sense the electrical properties of a fingertip.

Other input devices capture different types of information from the physical world. A camera converts light into digital image data — a grid of pixels with color values. A microphone converts sound pressure waves into electrical signals that are then digitized. A scanner converts printed or physical images into digital files. Sensors in embedded systems capture temperature, pressure, acceleration, location (GPS), and dozens of other environmental measurements. Every sensor is ultimately an input device: it samples something from the physical world and converts it into numbers the computer can process.

The primary output device is the monitor or display. A display presents visual information by controlling the color and brightness of millions of tiny pixels arranged in a grid. Resolution describes how many pixels the display contains: a 1920×1080 display has 1,920 columns and 1,080 rows of pixels, totaling about 2 million pixels. Higher resolution displays show more detail. Refresh rate, measured in hertz (Hz), describes how many times per second the display updates its image — 60 Hz means 60 full images per second, which appears smooth to human eyes. Speakers convert digital audio signals back into sound waves. Printers convert digital documents into physical marks on paper or other materials.

Some devices serve as both input and output. A network interface card both sends and receives data over a network. A hard drive or SSD reads data (input to the CPU) and writes data (output from the CPU). A touchscreen displays information and receives touch input simultaneously. In computer architecture, these are called I/O devices collectively — the acronym I/O standing for input/output.

CategoryDeviceWhat It Captures or Produces
InputKeyboardKeypress characters and commands
Mouse / TouchpadPointer position and click events
CameraStill images and video (pixel arrays)
MicrophoneAudio (digitized sound waves)
Sensors (temp, GPS, accelerometer)Physical measurements as numeric data
OutputMonitor / DisplayVisual pixel arrays (images, text, video)
Speakers / HeadphonesAudio (sound waves from digital signal)
PrinterPhysical marks on paper or other media
ProjectorProjected visual image
Both (I/O)TouchscreenDisplays image; captures touch position
Network InterfaceSends and receives data packets

Motherboards, Buses, and Connections

The individual components described so far — CPU, RAM, storage, and I/O devices — are all separate pieces of hardware. Something must connect them into a functioning system. That something is the motherboard, a large printed circuit board that physically and electronically connects every major component of the computer.

The motherboard contains sockets and slots where components attach. The CPU installs into the CPU socket, which holds it securely and makes electrical contact with hundreds or thousands of tiny pins. RAM modules plug into memory slots, usually two or four slots on a desktop motherboard. The motherboard also contains slots for expansion cards — graphics cards, network cards, and other peripherals — and connectors for storage drives, fans, power, and front-panel controls.

Data travels between components through buses. A bus is a set of electrical conductors — wires or traces on a circuit board — that carry signals between components. The data bus carries the actual data being transferred. The address bus carries information about where in memory to read from or write to. The control bus carries command signals that coordinate operations. The width of a bus (how many bits it can carry simultaneously) and its speed (how fast signals travel) determine bandwidth — how much data can move per second.

Modern computers use several important bus standards. PCIe (Peripheral Component Interconnect Express) is the high-speed bus used to connect graphics cards, NVMe SSDs, and other high-bandwidth expansion cards directly to the CPU. USB (Universal Serial Bus) is the standard for external device connections — keyboards, mice, flash drives, phones, cameras, and hundreds of other devices all connect via USB in its various versions (USB 2.0, USB 3.x, USB-C). SATA (Serial ATA) was the standard interface for connecting hard drives and SSDs to the motherboard, though NVMe over PCIe is now preferred for high-performance drives.

The motherboard also contains the chipset — additional silicon that manages communication between the CPU and other components including storage controllers, USB hubs, and audio systems. Older systems divided this into a northbridge (handling fast connections to RAM and GPU) and a southbridge (handling slower connections to storage and USB), though modern CPUs integrate much of this functionality directly onto the processor die.

Figure 15.6 — Simplified Motherboard Block Diagram
MOTHERBOARD CPU Socket LGA / AM5 RAM DDR5 Slots GPU / PCIe x16 Slot Graphics card or NVMe SSD CHIPSET I/O Controller STORAGE SATA / NVMe M.2 USB PORTS Keyboard, mouse, drives AUDIO Integrated sound chip NETWORK Ethernet / Wi-Fi POWER PSU connector Solid lines = PCIe / high-speed buses · Dashed = other connections
Ports vs. Slots

A port is an external connector on the outside of the computer for attaching peripherals: USB ports, headphone jacks, Ethernet ports, HDMI outputs, and SD card readers are all ports. A slot is an internal connector inside the case for adding expansion cards directly to the motherboard: PCIe slots for graphics cards and M.2 slots for NVMe SSDs are slots. Both serve as connection points, but ports face outward and slots face inward.

Practice 15.4–15.6Component Identification and Analysis
  1. A student is choosing between two laptops: one with a 1 TB HDD and one with a 512 GB SSD. The HDD model is cheaper. What tradeoffs should the student consider? Which would you recommend for someone who primarily uses the laptop for web browsing and word processing?
  2. Classify each of the following as an input device, output device, or both, and explain your reasoning: (a) webcam, (b) touchscreen, (c) printer, (d) USB flash drive, (e) barcode scanner at a grocery store.
  3. In the motherboard diagram, which bus connection would carry the most data per second — the CPU-to-RAM connection or the chipset-to-USB connection? Explain why.
  4. What is the difference between a SATA SSD and an NVMe SSD? Why would someone pay more for an NVMe drive?
  5. A laptop has four USB-A ports and one USB-C port. A student needs to connect a keyboard, a mouse, a webcam, and an external SSD simultaneously. Is this possible? What hardware solution would help if more ports are needed?
Sections 15.7 – 15.10
Architecture and Systems: GPU, Fetch-Decode-Execute, Embedded, and Tradeoffs
Graphics Processing · The Fetch-Decode-Execute Cycle · Embedded Systems · Performance and Tradeoffs

Graphics Processing

The CPU is a general-purpose processor: it is designed to handle any type of computation, but it does so with a relatively small number of highly capable cores optimized for sequential, complex tasks. The Graphics Processing Unit, or GPU, is fundamentally different in design philosophy. A GPU contains thousands of smaller, simpler cores all designed to execute the same simple operation on many pieces of data simultaneously. This architecture is called Single Instruction, Multiple Data (SIMD), and it is ideally suited to the work of rendering graphics.

Rendering a 3D scene for a video game requires computing the color and brightness of millions of pixels every frame — 60 times per second or more in modern games. Each pixel's calculation is largely independent of the others and follows the same pipeline of operations: transform 3D geometry, apply lighting equations, sample textures, blend colors. Because all these pixel calculations are the same type of operation on different data, a GPU's massively parallel architecture handles them far more efficiently than a CPU ever could. The GPU renders frames and outputs them to the display through a video port (HDMI, DisplayPort, or similar).

GPUs have their own dedicated memory called VRAM (Video RAM), distinct from the system's main RAM. VRAM is optimized for the high-bandwidth access patterns of graphics rendering — a GPU might need to read or write to every pixel in a 4K frame in milliseconds. High-end gaming GPUs contain 8 to 24 GB of VRAM.

Beyond graphics, GPUs have become essential for two other domains: scientific simulation and machine learning. Training a neural network requires performing billions of matrix multiplications — exactly the type of massively parallel operation GPUs excel at. This is why data centers training large AI models use thousands of GPUs rather than CPUs. Researchers have coined the term GPGPU (General-Purpose computing on Graphics Processing Units) for this use of GPU hardware for non-graphics tasks.

Computers use either integrated graphics — a GPU built directly into the CPU chip or the same package, sharing system RAM — or a discrete GPU — a separate card with its own processor, VRAM, and cooling. Integrated graphics consume less power and are suitable for everyday computing, video playback, and light creative work. Discrete GPUs are necessary for 3D gaming, video editing, and machine learning workloads.

Example 15.7.1
Why GPUs outperform CPUs for certain workloads
  • TaskAdd 1 to every element in an array of 8 million numbers — a simple operation found in image processing, scientific simulation, and neural network inference.
  • CPU approachA CPU with 16 cores, each handling one operation at a time, processes 16 elements simultaneously. It would take roughly 500,000 iterations to process 8 million elements (8,000,000 ÷ 16).
  • GPU approachA GPU with 8,000 shader cores can process 8,000 elements simultaneously — completing the same task in roughly 1,000 iterations (8,000,000 ÷ 8,000).
  • ResultFor this type of uniform, parallel computation, the GPU is approximately 500 times faster. For complex sequential tasks with branching logic, the CPU may be faster per core. The right tool depends on the nature of the computation.
Lesson: Parallel data-parallel problems favor GPUs. Complex sequential logic favors CPUs. Modern systems use both, routing work to whichever is appropriate.

The Fetch-Decode-Execute Cycle

Every program a computer runs — from the simplest script to a complex operating system — consists of a sequence of instructions stored in memory. The CPU executes these instructions one by one (or several at a time using pipelining) by following a simple three-phase cycle repeated continuously: fetch, decode, and execute. This cycle is the heartbeat of every computing device, and understanding it gives you a precise mental model of what "running a program" actually means at the hardware level.

Before the cycle begins, the CPU uses a special register called the Program Counter (PC) — sometimes called the Instruction Pointer — to track which instruction to execute next. The program counter holds the memory address of the current instruction. After each instruction is processed, the program counter is incremented to point to the next instruction, unless a jump or branch instruction changes it deliberately.

In the fetch phase, the CPU sends the address stored in the program counter to main memory (or cache, if available) and retrieves the instruction stored at that address. The instruction is loaded into a special register called the Instruction Register (IR). The program counter is then incremented to point to the next instruction, ready for the next cycle.

In the decode phase, the control unit examines the instruction now held in the instruction register and determines what operation it represents. Instructions are stored in binary as machine code — patterns of bits that the CPU's circuitry is designed to recognize. Decoding means identifying which operation this instruction requests (add, subtract, load, store, jump, compare, etc.) and which operands — registers, memory addresses, or immediate values — it involves.

In the execute phase, the control unit routes the instruction to the appropriate functional unit. If it is an arithmetic operation, the ALU performs the calculation. If it is a memory operation, data is loaded from or stored to the specified address. If it is a jump instruction, the program counter is set to a new address, redirecting execution. After execution, results may be written back to a register or to memory — sometimes called the write-back phase.

Modern CPUs accelerate this cycle through pipelining — processing different stages of consecutive instructions simultaneously. While one instruction is in the execute phase, the next instruction is already in the decode phase, and the one after that is being fetched. This overlapping means a new instruction can complete on every clock cycle in ideal conditions, greatly improving throughput over strictly sequential processing.

Figure 15.8 — The Fetch-Decode-Execute Cycle
FETCH PC → Memory address Load instruction → IR Increment PC DECODE Read instruction bits Identify operation Identify operands EXECUTE ALU performs op Memory read/write Update PC if jump Repeat for next instruction PROGRAM COUNTER
Example 15.8.1
Tracing the fetch-decode-execute cycle for a simple addition
  • SetupA program wants to compute 5 + 3 and store the result. The instruction to add the value in Register A and Register B, storing the result in Register C, is stored at memory address 100. The program counter holds 100.
  • FetchThe CPU reads memory address 100 and loads the ADD instruction into the Instruction Register. The program counter is incremented to 101 (the next instruction).
  • DecodeThe control unit reads the instruction bits and determines: operation = ADD; source operands = Register A (holds 5) and Register B (holds 3); destination = Register C.
  • ExecuteThe ALU receives the values 5 and 3 from Registers A and B, performs the addition, and produces the result 8. The result 8 is written into Register C.
  • NextThe CPU's program counter now holds 101. The cycle begins again immediately: the next instruction at address 101 is fetched. This entire cycle took one or a few clock cycles — happening billions of times per second.
Every program instruction — however complex it appears in Python or another language — ultimately reduces to a sequence of these simple fetch-decode-execute steps at the hardware level.
Common Misconception — Programs Run "All at Once"

Programs do not execute all at once. Every line of code, every function call, every loop iteration is broken down into dozens or hundreds of machine instructions, each of which is executed one step at a time by the fetch-decode-execute cycle. What makes computers feel instant is not simultaneous execution of all instructions, but rather the extraordinary speed of that cycle — billions of iterations per second.

Embedded Systems

The computers most people think of — desktops, laptops, smartphones, tablets — are general-purpose computers: they can run any software you install and perform an enormous variety of tasks. But these represent only a fraction of the computing devices in the world. The vast majority of processors in existence are embedded systems: computing devices designed for a specific, dedicated purpose, integrated into a larger machine or product.

An embedded system is a computer built into another device to perform a fixed set of functions. It typically consists of a microcontroller — a small chip that integrates a processor, memory, and I/O peripherals on a single piece of silicon — along with sensors, actuators, and specialized software called firmware. Unlike a general-purpose computer, an embedded system usually runs a single program continuously and is not intended to be reprogrammed by end users.

Embedded systems are everywhere. The anti-lock braking system (ABS) in a car uses an embedded processor to monitor wheel speed sensors and modulate brake pressure hundreds of times per second — too fast for a human driver and with real-time reliability requirements no general-purpose OS could guarantee. A medical pacemaker uses an embedded system to monitor heart rhythm and deliver precisely timed electrical pulses; its software must never crash or delay. A microwave oven uses an embedded system to read keypad input, control magnetron power levels, operate the turntable motor, and manage the timer — all from a processor that costs a fraction of a dollar.

Other examples of embedded systems span nearly every domain of modern life. Traffic light controllers manage signal timing and respond to sensor inputs. Washing machines monitor water levels and motor speeds while executing programmed wash cycles. Airplane fly-by-wire systems translate pilot inputs into hydraulic and motor commands through embedded processors with multiple redundant systems for safety. Implantable glucose monitors measure blood sugar continuously and wirelessly transmit data to smartphones. Industrial robots execute precisely timed sequences of motor commands coordinated by embedded controllers.

Embedded systems face constraints that general-purpose computers do not. They often have very limited memory and processing power, because the chip must be inexpensive and energy-efficient for production at scale. They may need to operate on battery power for years — a tire pressure sensor must last the life of the tire without a battery change. Many embedded systems have real-time requirements: they must respond to events within a guaranteed time window. An airbag controller must detect a crash and trigger the bag within milliseconds; a delay of even a few extra milliseconds could be fatal. Meeting these constraints requires careful hardware selection, efficient firmware, and often a real-time operating system (RTOS) designed for predictable, bounded response times.

DomainExample Embedded SystemKey FunctionCritical Constraint
AutomotiveABS controllerMonitor wheel speed; modulate brakesReal-time response, reliability
MedicalCardiac pacemakerMonitor heart rate; deliver pacing pulsesNever crash; extreme reliability
ConsumerMicrowave oven controllerManage keypad, power, timer, motorCost (must be very cheap)
IndustrialCNC machine controllerCoordinate motor movements for precision cuttingPositional accuracy, timing
AerospaceFly-by-wire flight controllerTranslate pilot inputs to control surfacesSafety, redundancy, real-time
InfrastructureTraffic light controllerManage signal timing; respond to sensorsReliability, long-term operation
IoT / SensorSmart thermostatRead temperature; control HVAC; connect to cloudPower efficiency, connectivity
Why Embedded Systems Matter for Computer Scientists

Understanding embedded systems is increasingly important as computing expands into physical devices — wearables, smart home devices, autonomous vehicles, medical equipment, and industrial automation. The programming, architecture, and reliability challenges of embedded systems differ significantly from desktop or server software. Many computing careers now involve this intersection of hardware and software.

Performance, Power, and Tradeoffs

Designing or choosing a computer system always involves tradeoffs. No single configuration is best for every situation. Performance, power consumption, cost, size, reliability, and thermal management all pull in different directions, and real engineering decisions require balancing them deliberately based on the intended use case. Understanding these tradeoffs is one of the most practically important ideas in computer architecture.

Clock speed and core count are the most visible CPU performance metrics. Increasing clock speed — making the CPU tick faster — increases performance for single-threaded workloads (tasks that cannot be parallelized). But faster clocks require more power and generate more heat. There is a physical limit to how fast silicon circuits can switch at a given voltage, which is why clock speeds have largely plateaued around 4–6 GHz in recent years despite continued performance improvements through other means. Increasing core count helps with multi-threaded workloads, but only if the software is written to use multiple threads — a single-threaded program runs no faster on 16 cores than on 4.

Thermal design power (TDP) is the maximum sustained heat a CPU or GPU generates under full load, measured in watts. A processor with a 65W TDP requires cooling capable of dissipating 65 watts of heat. High-performance desktop CPUs may have TDPs of 125–250 watts, requiring large heatsinks and fans or liquid cooling systems. Laptop processors use mobile variants with lower TDPs — often 15–45 watts — to remain cool and preserve battery life, at the cost of some peak performance. Understanding TDP helps explain why high-performance laptops are thicker and heavier, why data centers require enormous cooling infrastructure, and why battery life and performance are often in tension in mobile devices.

Memory bandwidth determines how fast data can flow between RAM and the CPU. A CPU that can compute very quickly but must wait for slow memory is said to be memory-bound — the memory is the bottleneck. This is why cache exists: by keeping frequently used data close to the processor, cache reduces the frequency of slow trips to main RAM. Adding more RAM increases capacity but not necessarily bandwidth; faster RAM (higher frequency or wider bus) increases bandwidth.

Storage speed is frequently the bottleneck for loading applications, opening large files, and running databases. Replacing an HDD with an SSD in an older computer often produces a dramatic improvement in perceived performance because the system spends less time waiting for storage. NVMe SSDs offer further improvements for workloads that involve large sequential reads or frequent random reads, though the gains are less noticeable for simple web browsing or document editing.

Cost is always a factor. More RAM, faster SSDs, higher-core-count CPUs, and discrete GPUs all increase price. Budget systems make deliberate compromises — less RAM, slower storage, integrated graphics — that are perfectly adequate for many users. Workstation and server configurations spend significantly more for the performance that demanding tasks require. A well-informed buyer or system designer understands which components are the actual bottleneck for the intended workload and invests accordingly.

The tension between performance and power is most visible in mobile devices. A smartphone must run for a full day on a battery the size of a credit card while also handling communications, navigation, photography, and streaming. Mobile chips achieve this through aggressive power management: cores that can be clock-gated (switched off when idle), dynamic voltage and frequency scaling (running slower and at lower voltage when full speed is not needed), and heterogeneous architectures that combine high-performance cores for demanding tasks with efficiency cores that handle background work with minimal power drain.

Tradeoff PairHigher Value MeansLower Value MeansWho Cares Most
Clock speed ↔ PowerFaster single-thread performance, more heatLess heat, lower energy useGaming, laptops on battery
Core count ↔ CostBetter parallel performance, higher priceLower cost, adequate for single tasksVideo rendering, servers, AI
RAM capacity ↔ CostMore apps open, less swap usageLower cost, more swap if overloadedHeavy multitasking, virtual machines
SSD vs. HDDMuch faster access, less capacity per dollarMore capacity per dollar, much slowerBoot speed, video archive
Discrete GPU ↔ IntegratedMuch faster graphics, higher power and costLower power, cheaper, adequate for 2DGaming, ML, creative work
Performance ↔ Battery lifeFaster task completion, shorter runtimeLonger battery life, slower under loadMobile devices, laptops
Example 15.10.1
Analyzing tradeoffs for a specific use case
  • ScenarioA university research team needs a computer for training machine learning models on large datasets — millions of images. Budget is limited but performance matters significantly.
  • CPUA high core-count CPU (16–32 cores) helps with data preprocessing and multi-threaded workloads, but the CPU is not the primary bottleneck for ML training.
  • GPUA discrete GPU with 16+ GB VRAM is the highest priority. ML training is massively parallel; the GPU does 90%+ of the compute work. This is worth investing in even on a tight budget.
  • RAM64 GB of RAM allows large datasets to be loaded into memory without constant disk access. Less RAM would create a storage bottleneck.
  • StorageAn NVMe SSD for the OS and active project data; a large HDD for the full dataset archive. This gives fast access to current data without paying SSD prices for 10 TB of training data.
  • PowerHigh TDP is acceptable for a workstation that stays plugged in. Battery life is irrelevant. Adequate cooling (case airflow or liquid cooling) is required.
Lesson: Matching hardware to the actual workload — not buying "the most expensive" or "the cheapest" — is what good system design means. The bottleneck for ML training is the GPU; that is where to spend the budget.
Practice 15.7–15.10Architecture and Tradeoffs
  1. Explain in your own words why a GPU with 4,000 simple cores can outperform a CPU with 16 powerful cores for image processing tasks. What type of computation gives this advantage?
  2. Trace the fetch-decode-execute cycle for this scenario: a program wants to compare two values and jump to a different instruction if the first is greater. Describe what happens during each phase of the cycle.
  3. A car's anti-lock braking system must respond to wheel-slip events within 10 milliseconds. Explain why this is an example of a real-time constraint and why a general-purpose operating system might not be suitable for this application.
  4. Identify five embedded systems in a typical modern home. For each one, identify at least one critical constraint (power, cost, reliability, real-time response, etc.).
  5. A student claims: "More cores always means a faster computer." Explain why this is not always true, using a specific example.
  6. A content creator needs a laptop primarily for video editing. Which hardware specification would give the greatest performance improvement for this use case: doubling the RAM from 16 GB to 32 GB, replacing the SATA SSD with an NVMe SSD, or upgrading from integrated graphics to a discrete GPU with 8 GB VRAM? Justify your answer.

Chapter Summary

Key Terms Review

hardware
The physical components of a computing system — everything that can be touched, measured, and replaced.
CPU
Central Processing Unit — the chip that executes program instructions. Contains the ALU, control unit, registers, and cache.
ALU
Arithmetic Logic Unit — the part of the CPU that performs mathematical and logical operations on data.
control unit
The part of the CPU that fetches instructions from memory, decodes them, and directs other units to execute them.
register
An extremely fast, tiny storage location inside the CPU used to hold values the processor is actively working with.
clock speed
The rate at which a CPU executes cycles, measured in gigahertz (GHz). Higher clock speed means more cycles per second.
core
An independent processing unit within a CPU chip. A quad-core CPU contains four cores, each capable of executing its own instruction stream.
cache
Fast memory built into or near the CPU that stores copies of recently accessed data, reducing wait time for main RAM.
RAM
Random Access Memory — fast, volatile memory that holds the operating system, active programs, and data in use. Lost when power is removed.
volatile memory
Memory that loses its contents when power is removed. RAM is volatile; SSDs and HDDs are not.
HDD
Hard Disk Drive — a mechanical storage device using spinning magnetic platters. High capacity, low cost, but slower than SSDs.
SSD
Solid-State Drive — a storage device using flash memory with no moving parts. Faster, more durable, and more power-efficient than HDDs.
flash memory
Non-volatile memory that stores data as electrical charges in cells. Used in SSDs, USB drives, and smartphones.
motherboard
The main circuit board that physically and electronically connects the CPU, RAM, storage, GPU, and all other components.
bus
A set of electrical conductors that carry signals between components. Data buses carry data; address buses carry memory addresses; control buses carry command signals.
PCIe
Peripheral Component Interconnect Express — the high-speed internal bus standard used for GPUs, NVMe SSDs, and high-performance expansion cards.
GPU
Graphics Processing Unit — a processor with thousands of simpler cores optimized for massively parallel computation, used for rendering and machine learning.
VRAM
Video RAM — dedicated memory on a GPU used to store textures, frame buffers, and data for graphical rendering.
fetch-decode-execute
The three-phase cycle by which a CPU processes instructions: fetch from memory, decode the operation, execute the result.
program counter
A CPU register that holds the memory address of the next instruction to be fetched and executed.
pipelining
A CPU technique that overlaps the fetch, decode, and execute stages of consecutive instructions to increase throughput.
embedded system
A computing device built into another product for a specific, dedicated purpose. Uses a microcontroller and firmware rather than a general-purpose OS.
microcontroller
A compact chip that integrates a CPU, memory, and I/O peripherals on a single piece of silicon, used in embedded systems.
real-time constraint
A requirement that a computing system respond to events within a guaranteed, bounded time window. Critical in safety-critical embedded systems.
thermal design power (TDP)
The maximum sustained heat output of a processor under full load, measured in watts. Determines cooling requirements.

Hardware Diagram Practice

Use the system block diagram below to answer the questions that follow.

Practice Diagram — Simplified Computer System Block Diagram
[A] CPU 4-core, 3.8 GHz, 16 MB L3 [B] RAM 32 GB DDR5 [C] GPU Discrete, 8 GB VRAM [D] MOTHERBOARD / CHIPSET PCIe · SATA · USB · Audio · Network [E] STORAGE 1 TB NVMe SSD 4 TB HDD [F] I/O DEVICES Monitor · Keyboard · Mouse Webcam · Speakers
  1. Identify which component in the diagram (A through F) performs the fetch-decode-execute cycle. Explain its role.
  2. Which component(s) in the diagram are volatile? Which are non-volatile? Explain the difference in practical terms.
  3. Trace the path data takes when you open a file from storage and the CPU processes it. Which components does the data pass through, and in what order?
  4. The system has both an NVMe SSD and an HDD. What would you recommend storing on each, and why?
  5. Component [C] is a discrete GPU. What advantage does it provide over integrated graphics? For what types of tasks would it make a significant difference?
  6. If the system's RAM were doubled from 32 GB to 64 GB, which workload would benefit most: writing a short document, training a machine learning model, or browsing simple web pages? Justify your reasoning.

Component Function Questions

Answer each question with a complete explanation, not just a term.

  1. A student opens a large image file in a photo editor. Describe exactly what happens in terms of hardware: where is the file read from, what receives it first, where does the CPU get it from, and where does the edited result go when saved?
  2. Why does a computer run noticeably slower when RAM is nearly full? What hardware mechanism causes this, and why is it slower?
  3. Explain why the program counter must be incremented (or redirected) at every step of the fetch-decode-execute cycle. What would happen if the program counter never changed?
  4. A friend says: "My old laptop has a 5400 RPM hard drive and the new one has an SSD. Why does the new one feel so much faster even though they have similar CPU speeds?" Explain, referencing the specific hardware mechanisms involved.
  5. What makes a microcontroller different from the CPU in a laptop? List at least three differences in design goals or specifications.
  6. A GPU is described as having 6,144 CUDA cores running at 1.8 GHz, with 12 GB GDDR6X VRAM. Interpret each specification in plain language suitable for a computer science student who has not studied GPUs before.

System Comparison

Compare each pair and explain which would perform better for the given task and why.

TaskSystem ASystem BWhich Performs Better?
Web browsing and email4-core CPU, 8 GB RAM, SATA SSD, integrated GPU4-core CPU, 8 GB RAM, HDD, integrated GPUExplain your choice
Training a neural network16-core CPU, 64 GB RAM, no discrete GPU8-core CPU, 32 GB RAM, discrete GPU 16 GB VRAMExplain your choice
Archiving 20 TB of video files2 × 10 TB HDD array1 × 4 TB NVMe SSDExplain your choice
Editing 4K video8-core CPU, 32 GB RAM, HDD8-core CPU, 32 GB RAM, NVMe SSDExplain your choice
Embedded car sensor controllerFull desktop CPU, 8 GB RAMLow-power microcontroller, 256 KB flashExplain your choice

Error Analysis

Each statement contains a technical error or misconception. Identify the error and write a corrected explanation.

Misconception 1
"My computer has 8 GB of memory and 512 GB of storage, so the storage is the same as memory, just bigger."

What is the error? Explain the actual difference between RAM and storage.

Misconception 2
"A CPU with a higher clock speed is always faster than one with a lower clock speed."

Identify what this statement misses. Give a specific example where a lower-clock-speed CPU outperforms a higher one.

Misconception 3
"The GPU is just a better CPU. We should replace CPUs with GPUs entirely."

Explain what each processor type is optimized for and why both are needed in modern systems.

Misconception 4
"In the fetch-decode-execute cycle, the CPU executes all the instructions in a program at once when the program starts."

Describe how the fetch-decode-execute cycle actually works and what the program counter does.

Misconception 5
"Embedded systems are just small, cheap computers that run simple software. They're not really computer science."

Explain the real engineering challenges of embedded systems, using two specific examples of domains where those challenges are critical.

Performance Tradeoff Questions

  1. A laptop manufacturer offers two versions of the same model: one with a 45W TDP CPU and one with a 15W TDP CPU. The 15W version costs the same but has a lower clock speed. Who should buy each version? What are the tradeoffs?
  2. A software engineer is building a web server that handles thousands of short HTTP requests simultaneously. Should she prioritize clock speed or core count? Explain your reasoning in terms of how web servers handle concurrent connections.
  3. Explain why adding more RAM to a computer with 8 GB that frequently uses virtual memory would improve performance more dramatically than replacing a 4-core CPU with an 8-core CPU on the same machine.
  4. A space probe is sent on a 10-year mission. Its embedded computer must operate on solar power, survive extreme temperature swings, and never crash. Identify three hardware design priorities this mission would require, and explain why each matters.
  5. The memory hierarchy (L1 → L2 → L3 → RAM → storage) uses smaller, faster storage at each higher level. Why not simply build all memory with L1 cache characteristics and eliminate the other levels? What prevents this?

Chapter 15 Checkpoint

Chapter 15 Checkpoint
Complete without assistance — covers all major sections of Chapter 15
Part 1 — Vocabulary and Definitions
  1. Define hardware and explain how it differs from software. Give two examples of each.
  2. What are the three main functional components inside a CPU? Describe the role of each in one sentence.
  3. Explain the difference between L1 cache, RAM, and SSD storage in terms of speed, size, and volatility.
  4. Define embedded system and give two examples from different domains.
  5. What is thermal design power (TDP) and why does it matter for laptop design?
Part 2 — Concepts and Explanation
  1. Describe each phase of the fetch-decode-execute cycle in your own words. What is the role of the program counter?
  2. Why can a GPU outperform a CPU for training machine learning models, even though CPUs have higher clock speeds?
  3. A program that processes video frame by frame produces identical results on a 4-core and a 16-core CPU. A program that encodes 16 video streams simultaneously runs much faster on the 16-core CPU. Explain why.
  4. Explain what the memory bottleneck is and describe two hardware mechanisms that help reduce it.
Part 3 — Application and Analysis
  1. A hospital needs a computer to continuously monitor patient vital signs and trigger alerts within 200 milliseconds. Should they use a standard desktop computer running Windows or a specialized embedded system with an RTOS? Justify your answer with at least two technical reasons.
  2. Compare an HDD and an NVMe SSD across four criteria: speed, durability, power consumption, and cost per GB. For each criterion, state which is better and explain why.
  3. A user notices that their computer is much slower after they have been using it for several hours with many browser tabs open. Using hardware concepts from this chapter, explain what is likely happening and suggest a hardware solution.
  4. Draw a block diagram (or describe one clearly) showing how a CPU, RAM, SSD, GPU, keyboard, and monitor are connected on a motherboard. Label the types of connections where relevant (PCIe, SATA, USB, direct).
Part 4 — Error Identification
  1. A student writes: "I saved my work to RAM so it won't be lost." Identify the error and explain the correct concept.
  2. A tech review says: "This CPU has a 5.0 GHz clock, so it processes 5 billion instructions per second." Identify at least two reasons why this statement is an oversimplification.
Looking Ahead
Chapter 16: Operating Systems

Chapter 15 introduced the physical hardware layer — the components that actually execute instructions and store information. Chapter 16 will introduce the software layer that sits directly above that hardware: the operating system. The operating system is the program responsible for managing the CPU, RAM, storage, and I/O devices on behalf of all other programs. You will learn what processes are, how the OS manages memory, how filesystems organize data on storage devices, and how permissions and user accounts control who can access what. Everything you have learned about hardware in this chapter provides the foundation for understanding why operating systems make the design decisions they do.

MGU Library Connection
  • Computer Systems Reference — Appendix G of this textbook
  • Binary and Data Representation Reference — Appendix B (bits and bytes underpin all hardware quantities)
  • Computer Architecture Foundations (MGU CS Series) — covers CPU design, instruction sets, pipelines, and memory systems in depth
  • Operating Systems Foundations (MGU CS Series) — builds directly on the hardware concepts in this chapter
  • MGU Glossary entries: CPU, GPU, cache, RAM, SSD, HDD, motherboard, bus, embedded system, fetch-decode-execute, pipelining, TDP, VRAM