COA Notes
CPU internal architecture, datapath design, register organization, and control flow mechanisms.
Introduction
The CPU (Central Processing Unit) is the most complex and fascinating component in a computer. It's a marvel of engineering — billions of transistors organized into functional units that work together to execute billions of instructions every second. Understanding CPU architecture means understanding how registers, the ALU, control unit, and internal buses are organized to form a complete processing engine.
CPU Internal Organization
The CPU has two main paths:
- Datapath: The hardware that performs operations on data (registers, ALU, internal buses)
- Control Path: The hardware that tells the datapath what to do and when (control unit, timing circuits)
Types of CPU Organization
Single Accumulator Organization
- All operations use a single register called the Accumulator (AC)
- Instructions have the form: OPERATION address
- The AC is always one implicit operand
- Example:
ADD Xmeans AC ← AC + M[X] - Simple but requires many memory accesses (load/store for every operation)
General Register Organization
- Multiple registers available for operands and results
- Instructions specify registers:
ADD R1, R2, R3means R1 ← R2 + R3 - Reduces memory accesses (operands stay in registers)
- Most modern processors use this approach
- Faster but instructions need more bits to specify registers
Stack Organization
- Operands are pushed onto and popped from a stack
- Operations implicitly use the top of stack
- Example: PUSH A, PUSH B, ADD → top of stack = A + B
- Compact instructions (no operand addresses needed)
- Used in some calculators and the Java Virtual Machine
Register File Design
The register file is a small, fast memory inside the CPU:
Structure
| Write Port: Data_in | [Decoder] → Selected Register |
| Read Port A: [MUX] | selects register → Data_out_A |
| Read Port B: [MUX] | selects register → Data_out_B |
Specifications
- Number of registers: 8 (x86), 16 (ARM), 32 (MIPS, RISC-V)
- Register width: 32 or 64 bits
- Read ports: Usually 2 (supply both ALU inputs simultaneously)
- Write ports: Usually 1 (write one result per cycle)
- Access time: Single cycle (fastest storage in the system)
Why Not More Registers?
- More registers = more bits needed in instructions to specify them
- More registers = larger, slower register file
- Diminishing returns: most programs don't need hundreds of registers simultaneously
The CPU Datapath
Single-Cycle Datapath
Every instruction completes in exactly one clock cycle:
- Simple control but slow (clock must accommodate the slowest instruction)
Multi-Cycle Datapath
Instructions broken into multiple shorter cycles:
- Each phase (fetch, decode, execute, memory, writeback) is one cycle
- Different instructions take different numbers of cycles
- Hardware is shared across phases (one ALU for both address calculation and arithmetic)
- Faster clock, but more cycles per instruction
Pipelined Datapath
Multiple instructions in different phases simultaneously:
- While instruction N is executing, N+1 is decoding, N+2 is fetching
- Maximum throughput: one instruction per cycle (ideally)
- This is the standard approach in all modern processors
Bus Architecture Within the CPU
Single Internal Bus
Only one transfer per cycle. Simple but slow (multi-cycle operations).
Dual Bus
| Register | Bus A → ALU input 1 |
| Register | Bus B → ALU input 2 |
| ALU output | Bus A or result bus → destination |
Read two operands simultaneously. Faster.
Triple Bus
| Register | Bus A → ALU input 1 |
| Register | Bus B → ALU input 2 |
| ALU output | Bus C → destination register |
Read two operands AND write result in same cycle. Fastest (used in most modern designs).
Instruction Execution Flow
For a register-register ADD (ADD R1, R2, R3):
- Fetch: IR ← M[PC]; PC ← PC+4
- Decode: Control unit determines ADD operation; Read R2 and R3 from register file
- Execute: ALU computes R2 + R3
- Write Back: Result stored in R1
For a memory LOAD (LOAD R1, offset(R2)):
- Fetch: IR ← M[PC]; PC ← PC+4
- Decode: Read R2 (base address)
- Execute: ALU computes R2 + offset (effective address)
- Memory: Read data from computed address
- Write Back: Store loaded data in R1
Key Takeaways
- CPU architecture encompasses the datapath (registers + ALU + buses) and control path (control unit)
- Three organizational styles: accumulator (simple), general register (fast), stack (compact)
- General register organization dominates modern processors due to reduced memory traffic
- The register file provides fast, multi-port access to operands
- Single-cycle, multi-cycle, and pipelined are the three main datapath implementation strategies
- Internal bus width and port count directly affect how many operations happen per cycle
- Modern CPUs use pipelined triple-bus designs for maximum throughput
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for CPU Architecture.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Organization & Architecture topic.
Search Terms
computer-organization, computer organization & architecture, computer, organization, cpu, architecture, cpu architecture
Related Computer Organization & Architecture Topics