Docsity

Computer Architecture: Datapath, Memory Hierarchy and Pipelining, Study notes of Computer Science

Toggle sidebar
bg1
Computer Architecture: Datapath, Memory Hierarchy and Pipeli Page 1 of 3
Computer Architecture: Datapath, Memory Hierarchy and
Pipelining
From instruction set to cycles, caches and parallelism
Computer Science | Undergraduate (Level 5) | December 2026
WHAT IS INSIDE
1. Instruction sets and the programmer's model
2. Datapath, control and pipelining
3. Memory hierarchy and caches
4. Instruction-level and thread-level parallelism
Exam question patterns
Glossary of exam-ready definitions
1. Instruction sets and the programmer's model
An instruction set architecture is the contract between hardware and compiler: registers, addressing
modes, data types and the instruction formats. RISC designs favour fixed-length instructions, load-store
addressing and many registers so that pipelining stays simple; CISC designs allow memory operands and
richer instructions, trading decode complexity for code density. The exam distinction is not which is faster
but which makes which optimisation cheap.
Calling conventions, the stack frame and the role of the program counter and link register define how
procedures work, and they explain most assembly questions. Addressing modes - immediate, register, base
plus offset, PC-relative - decide whether code is position independent and how many instructions a loop
costs. Counting instructions and cycles for a short loop is the standard calculation, and the answer must
separate instruction count from cycles per instruction.
•RISC vs CISC - the trade is decode complexity against instruction count.
•CPI and clock - time = instruction count x CPI x clock period; name all three.
•Position independence - PC-relative addressing makes code relocatable.
•Stack discipline - saves and restores must balance or the return address is lost.
2. Datapath, control and pipelining
The single-cycle datapath executes one instruction per clock, so the clock period is set by the slowest
instruction - usually a load. Multicycle designs break execution into steps and reuse hardware, which
shortens the clock but adds registers and control states. The control unit is either hardwired or
microprogrammed, and the choice trades flexibility against speed.
A five-stage pipeline (fetch, decode, execute, memory, write back) overlaps instructions, so ideal throughput
is one instruction per cycle, but structural, data and control hazards stall it. Data hazards are handled by
forwarding, with a one-cycle load-use stall when forwarding cannot help; control hazards by branch
prediction, delay slots or flushing. Speedup is limited by the unpipelined fraction and by pipeline depth, and
a deeper pipeline raises both throughput and the penalty of a misprediction.
•Load-use hazard - forwarding cannot cover it; insert one stall or reorder.
•Branch penalty - misprediction cost grows with pipeline depth.
•Superscalar - issue width is limited by dependencies and by functional units.
•Amdahl's law - speedup is capped by the part that does not improve.
pf3

Partial preview of the text

Download Computer Architecture: Datapath, Memory Hierarchy and Pipelining and more Study notes Computer Science in PDF only on Docsity!

Computer Architecture: Datapath, Memory Hierarchy and

Pipelining

From instruction set to cycles, caches and parallelism Computer Science | Undergraduate (Level 5) | December 2026

WHAT IS INSIDE

  1. Instruction sets and the programmer's model
  2. Datapath, control and pipelining
  3. Memory hierarchy and caches
  4. Instruction-level and thread-level parallelism Exam question patterns Glossary of exam-ready definitions

1. Instruction sets and the programmer's model

An instruction set architecture is the contract between hardware and compiler: registers, addressing modes, data types and the instruction formats. RISC designs favour fixed-length instructions, load-store addressing and many registers so that pipelining stays simple; CISC designs allow memory operands and richer instructions, trading decode complexity for code density. The exam distinction is not which is faster but which makes which optimisation cheap.

Calling conventions , the stack frame and the role of the program counter and link register define how procedures work, and they explain most assembly questions. Addressing modes - immediate, register, base plus offset, PC-relative - decide whether code is position independent and how many instructions a loop costs. Counting instructions and cycles for a short loop is the standard calculation, and the answer must separate instruction count from cycles per instruction.

  • RISC vs CISC - the trade is decode complexity against instruction count.
  • CPI and clock - time = instruction count x CPI x clock period; name all three.
  • Position independence - PC-relative addressing makes code relocatable.
  • Stack discipline - saves and restores must balance or the return address is lost.

2. Datapath, control and pipelining

The single-cycle datapath executes one instruction per clock, so the clock period is set by the slowest instruction - usually a load. Multicycle designs break execution into steps and reuse hardware, which shortens the clock but adds registers and control states. The control unit is either hardwired or microprogrammed, and the choice trades flexibility against speed.

A five-stage pipeline (fetch, decode, execute, memory, write back) overlaps instructions, so ideal throughput is one instruction per cycle, but structural , data and control hazards stall it. Data hazards are handled by forwarding , with a one-cycle load-use stall when forwarding cannot help; control hazards by branch prediction, delay slots or flushing. Speedup is limited by the unpipelined fraction and by pipeline depth, and a deeper pipeline raises both throughput and the penalty of a misprediction.

  • Load-use hazard - forwarding cannot cover it; insert one stall or reorder.
  • Branch penalty - misprediction cost grows with pipeline depth.
  • Superscalar - issue width is limited by dependencies and by functional units.
  • Amdahl's law - speedup is capped by the part that does not improve.

Computer Architecture: Datapath, Memory Hierarchy and Pipelining

3. Memory hierarchy and caches

Locality - temporal and spatial - is why a hierarchy works: registers, L1, L2, L3, main memory and disk, each an order of magnitude slower and larger. A cache is described by capacity, block size, associativity, replacement policy and write policy. Direct mapped caches have one candidate block and simple indexing but suffer conflict misses; fully associative caches have no conflict misses but need comparators on every access; set-associative designs are the compromise.

The three C s - compulsory, capacity and conflict misses - organise any answer about miss rates, and block size trades compulsory misses against capacity misses. Write-through keeps memory coherent at the cost of traffic; write-back reduces traffic but needs dirty bits and coherence handling. Virtual memory extends the same logic with page tables and a TLB, and its costs are page faults rather than cache misses, which is why the two must not be confused in an exam answer.

  • AMAT - hit time + miss rate x miss penalty; quote all three terms.
  • Associativity - more ways reduce conflict misses and raise hit time.
  • Block size - larger blocks exploit spatial locality and can lower hit rate on small working sets.
  • TLB miss vs page fault - a TLB miss may cost only a page-table walk.

4. Instruction-level and thread-level parallelism

Instruction-level parallelism is extracted by pipelining, multiple issue, out-of-order execution and speculation. Scoreboarding and Tomasulo track dependencies and rename registers to remove false ones, while reorder buffers keep precise exceptions. The limits are true data dependencies and branch misprediction, so the returns to wider issue diminish quickly.

Multicore and SIMD move parallelism up a level, but shared memory introduces cache coherence and consistency questions. Snooping and directory protocols keep caches coherent, and the memory consistency model decides what a program may assume about the order of writes. Performance questions about multicore therefore have to name contention, false sharing and synchronisation cost, not just core count.

  • Register renaming - removes write-after-write and write-after-read hazards.
  • Precise exceptions - the reorder buffer retires in order even when execution is out of order.
  • False sharing - independent variables in one cache line serialise cores.
  • Consistency model - defines the ordering a programmer may rely on. Level Typical latency Managed by Miss cost Register 1 cycle Compiler Spill to memory L1 cache 2-4 cycles Hardware L2 access L2 / L3 cache 10-40 cycles Hardware Main memory access Main memory 100-300 cycles OS plus hardware Page fault if absent Solid-state disk 10k-100k cycles OS Long stall Magnetic disk Millions of cycles OS Seek plus transfer

Exam question patterns

Three shapes dominate. Trace the algorithm : show the state after each step in a table, then state the final result and the complexity - a trace without a complexity statement is half an answer. Prove or justify : state the invariant, show it holds at initialisation, during each iteration and at termination. Design and compare : give the data structure, the operations with their costs, the trade-off, and one case where the alternative would be worse.