Skip to content
Chethan Yadav_
Computer Architecture

COA/Lesson 3 of 6/7 min read

CPU Organization

Von Neumann architecture, CPU components, the instruction cycle, instruction formats, addressing modes, RISC vs CISC and CPU performance equations.


On this page

Von Neumann Architecture

The stored-program model behind almost every computer: instructions and data share the same memory and the same bus.

Components:

  • CPU: ALU, control unit, registers.
  • Memory: holds both program and data.
  • I/O: devices connected through the bus.
  • Bus: address bus, data bus, control bus.

Von Neumann bottleneck

The CPU can fetch either an instruction or data at a time over the shared bus, and the CPU is much faster than memory. The bus limits throughput. Mitigations: caches, separate instruction and data caches, prefetching, wider buses.

Harvard Architecture

Separate memories and buses for instructions and data, so both can be fetched in the same cycle. Used in microcontrollers and DSPs.

Modern CPUs are modified Harvard: unified main memory, but split L1 instruction and data caches.

CPU components

ALU

The Arithmetic Logic Unit performs arithmetic (add, subtract, multiply) and logic (AND, OR, XOR, shifts, compares). It sets status flags:

FlagMeaning
Z (zero)Result is zero
N (negative)Result's sign bit is 1
C (carry)Unsigned overflow
V (overflow)Signed overflow

Branches like "jump if equal" test these flags.

Control Unit

Decodes instructions and generates control signals that orchestrate the datapath: which registers to read, what the ALU should do, whether to access memory.

Registers

The fastest storage, inside the CPU.

RegisterRole
Program Counter (PC)Address of the next instruction
Instruction Register (IR)Instruction being executed
MAR (memory address register)Address to read or write
MDR (memory data register)Data read from or written to memory
AccumulatorHolds ALU results in simple CPUs
General purpose (R0 to Rn)Operands and results
Stack Pointer (SP)Top of the call stack
Status / flags registerALU flags, interrupt enable

Program Counter

Holds the address of the next instruction. Normally incremented by the instruction size after each fetch. Jumps, branches, calls and returns load a new value into it. A function call saves the return address (the PC) on the stack.

Instruction Cycle

Every instruction goes through the fetch-decode-execute cycle:

  1. Fetch: MAR = PC; read memory into MDR; IR = MDR; PC = PC + size.
  2. Decode: control unit interprets the opcode and identifies operands.
  3. Operand fetch: read registers or memory as needed.
  4. Execute: ALU computes, or memory is accessed, or a branch updates the PC.
  5. Write back: store the result in a register or memory.
  6. Check for pending device signals before the next fetch (see interrupts).

The clock drives each step; a single instruction may take multiple clock cycles.

Instruction Set Architecture

The ISA is the contract between hardware and software: instructions, registers, data types, addressing modes and memory model. Examples: x86-64, ARMv8, RISC-V, MIPS. The microarchitecture is how a specific chip implements the ISA (pipelines, caches, branch predictors).

Instruction formats

An instruction has an opcode and zero or more operands.

FormatExampleNotes
Three-addressADD R1, R2, R3R1 = R2 + R3; typical RISC
Two-addressADD R1, R2R1 = R1 + R2; x86 style
One-addressADD XACC = ACC + X; accumulator machines
Zero-addressADDPops two, pushes result; stack machines (JVM bytecode)

Instruction types

  • Data transfer: LOAD, STORE, MOV.
  • Arithmetic and logic: ADD, SUB, AND, SHL.
  • Control flow: JMP, BEQ, CALL, RET.
  • System: SYSCALL, HALT.

Addressing Mode

How an instruction specifies the location of its operand.

ModeExampleEffective operand
ImmediateADD R1, #5The constant 5
RegisterADD R1, R2Contents of R2
Direct (absolute)LOAD R1, 1000Mem[1000]
IndirectLOAD R1, (1000)Mem[Mem[1000]]
Register indirectLOAD R1, (R2)Mem[R2] (pointers)
Indexed / displacementLOAD R1, 8(R2)Mem[R2 + 8] (arrays, struct fields)
PC-relativeBEQ labelPC + offset (branches, position-independent code)
Auto-incrementLOAD R1, (R2)+Mem[R2], then R2 increments

Immediate is fastest (no memory access); indirect is slowest (two memory accesses).

RISC

Reduced Instruction Set Computer: small set of simple, fixed-length instructions, most completing in one cycle. Only LOAD and STORE touch memory (load-store architecture). Many registers. Easy to pipeline. Examples: ARM, RISC-V, MIPS.

CISC

Complex Instruction Set Computer: many instructions, variable length, some doing complex multi-step work (memory-to-memory operations, string instructions). Denser code, harder to pipeline. Example: x86.

RISCCISC
InstructionsFew, simpleMany, complex
LengthFixed (often 32 bits)Variable (1 to 15 bytes on x86)
Cycles per instructionAbout 1Several
Memory accessLoad and store onlyMost instructions
RegistersManyFewer
ControlHardwiredOften microprogrammed
PipeliningEasyHarder
Code sizeLargerSmaller

Modern x86 chips decode CISC instructions into RISC-like micro-ops internally, so the distinction is mostly at the ISA level today.

Microprogrammed Control

Two ways to build a control unit:

  • Hardwired: control signals generated by fixed logic circuits. Fast, but hard to modify. Typical for RISC.
  • Microprogrammed: each machine instruction is executed by a small program of microinstructions stored in a control memory. Flexible and easier to design for complex ISAs, but slower. Typical for CISC.

CPU performance

CPU time = Instruction count * CPI * Clock cycle time
         = Instruction count * CPI / Clock rate

CPI

Cycles Per Instruction: average clock cycles per instruction. Weighted by instruction mix:

Mix: 50% ALU (1 cycle), 30% load/store (2 cycles), 20% branch (3 cycles)
CPI = 0.5 * 1 + 0.3 * 2 + 0.2 * 3 = 1.7

Pipelined and superscalar CPUs aim for CPI near or below 1 (IPC, instructions per cycle, above 1).

MIPS (million instructions per second) = clock rate / (CPI * 10^6). It is a misleading metric across ISAs because instructions do different amounts of work.

Higher clock rate alone does not mean a faster CPU. Total time depends on instruction count, CPI and clock rate together, and on memory stalls that this equation hides inside CPI.

Quick revision

  • Von Neumann: shared memory for code and data, causing the bus bottleneck; Harvard splits them.
  • CPU = ALU + control unit + registers; the PC holds the next instruction address.
  • Instruction cycle: fetch, decode, operand fetch, execute, write back.
  • ISA is the hardware-software contract; microarchitecture is the implementation.
  • Know the addressing modes: immediate, register, direct, indirect, indexed, PC-relative.
  • RISC: simple, fixed-length, load-store, pipelines well. CISC: complex, variable length, dense code.
  • CPU time = instruction count * CPI / clock rate.