Computer Architecture

Computer architecture is where the previous topic's gates finally get assembled into a working CPU, and understanding that assembly explains why programs run at the speed they do. An instruction is a single operation the CPU knows how to perform — add two numbers, load a value from memory, compare two registers — encoded as raw binary the way the data-representation topic described; assembly language is a thin, human-readable layer directly on top of that binary, one line per instruction, with mnemonics like `ADD` or `LOAD` standing in for the actual bit patterns, which is as close to the hardware as a programmer can get without writing 1s and 0s by hand. The CPU executes instructions through a repeating fetch-decode-execute cycle: fetch pulls the next instruction from memory using a register called the program counter, decode figures out which operation it specifies and which registers or memory addresses it touches, and execute actually performs it — addition and comparison run through an arithmetic logic unit built directly from the half-adders and full-adders of the previous topic, while a control unit (also just more logic gates) sequences the whole cycle and decides which hardware components get used on any given step. A register, already introduced as a handful of flip-flops, is the CPU's fastest possible storage — reading or writing one register costs a single clock cycle, with absolutely nothing faster available on the chip. A cache sits directly between the registers and main memory (DRAM, covered in this series' own memory-and-execution topic) as a small, fast layer that keeps a copy of recently used data, because DRAM access is dramatically slower than a register and most programs reuse the same small set of data and instructions repeatedly — a principle called locality — so a cache hit (the data is already there) is far cheaper than a cache miss (the CPU has to wait for DRAM). The memory hierarchy arranges every storage tier available to a computer — registers, then cache, then DRAM, then disk — from fastest-and-smallest at the top to slowest-and-largest at the bottom, and every tier below the top exists purely as a cost tradeoff: faster memory is dramatically more expensive per byte, so a real system layers cheap, large, slow storage underneath small amounts of expensive, fast storage and relies on locality to keep the common case fast. This entire chapter — instructions, the fetch-decode-execute cycle, and the memory hierarchy that feeds it — is the hardware picture the next topic, operating systems, has to manage and share safely across every program running on the machine at once.

Fetch
program counter points to the next instruction in memory
Decode
control unit figures out the operation and its operands
Execute
ALU performs the operation using the gates from digital logic
Store result, advance program counter
then the cycle repeats from fetch again
The Memory Hierarchy: Speed vs. Size vs. Cost Faster memory is always smaller and always more expensive per byte Registers 1 clock cycle — fastest on the chip Cache (L1 / L2 / L3) a few cycles — holds recent data DRAM (main memory) hundreds of cycles — a cache miss waits here Disk / SSD thousands of cycles — slowest, biggest, cheapest locality — programs reuse the same small set of data — is why caching works at all
Inside One CPU Cycle Built from nothing but the gates and registers from digital logic Program counter a register holding the next address Control unit decodes the instruction, sequences the hardware ALU adders and gates do the actual computation Reg- isters ADD mnemonic in assembly is one line, but underneath it is binary: an opcode plus register numbers, exactly matching the bit patterns the control unit decodes, every one of these boxes is only logic gates

Take computer architecture further

Ask the copilot about this term, or have our engineers assess it against your process.