Turning a Single-Cycle Datapath into a Pipelined One

Overlapping instruction execution requires more than just running the same single-cycle hardware faster; it requires physically separating each pipeline stage with storage elements and duplicating control logic across stages. This article explains how pipeline registers preserve instruction state between stages and how control signals travel alongside data through the pipeline.

Pipeline RegistersPipelined DatapathPipeline Control Signals

~3 دقیقه مطالعه · آخرین به‌روزرسانی ۱۵ شهریور ۱۴۰۵

Why the Single-Cycle Datapath Cannot Simply Run Faster

Pipelining does not mean reusing the exact same single-cycle datapath and clocking it more quickly. Since five different instructions occupy five different stages simultaneously, the hardware for each stage must be physically separated, and the partial results of an instruction still in progress must be preserved as it moves from one stage to the next.

Pipeline Registers: Preserving State Between Stages

Between every pair of adjacent pipeline stages, a Pipeline Register stores all the values an instruction needs to carry forward into the next stage.

IF/ID register: holds the fetched instruction and incremented PC
ID/EX register: holds decoded register values, immediate, and control signals
EX/MEM register: holds ALU result, register value for stores, and control signals
MEM/WB register: holds the value to be written back and control signals

Each of these registers updates once per clock cycle, allowing one instruction's partial results to sit safely in a register while the next instruction's results are simultaneously being computed one stage earlier.

Control Signals Must Travel With the Instruction

In the single-cycle design covered earlier in this series, control signals were generated and used within the same cycle. In a pipelined design, a control signal generated during decode might not be needed until several cycles later, once the instruction reaches the memory or write-back stage. To handle this, control signals are carried forward through the same pipeline registers alongside the data they apply to, ensuring each signal arrives at the correct stage at the correct time for its own specific instruction.

An Example: Following a Load Instruction Through the Pipeline

Consider a load instruction moving through all five stages over five clock cycles.

Cycle 1 (IF): fetch the load instruction
Cycle 2 (ID): decode it, read base register, generate control signals
Cycle 3 (EX): ALU adds base register and offset to form the address
Cycle 4 (MEM): read the value from data memory at that address
Cycle 5 (WB): write the retrieved value into the destination register

At every one of these cycles, other instructions are simultaneously occupying the other four pipeline stages, each carrying their own data and control signals through their own pipeline registers without interfering with the load instruction's progress.

Why This Structural Change Matters

This separation of stages using pipeline registers is what makes overlapped execution physically possible. Without it, the hardware for a later stage would have no reliable way of knowing which instruction's data it is currently supposed to be working on, since multiple instructions occupy the datapath's different regions at the same instant.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Common Misconceptions About Parallel Computing and the Book's Final Lessons

After covering everything from thread-level parallelism to warehouse-scale computing, it is worth correcting persistent misconceptions about parallel systems that even experienced engineers sometimes hold. This article addresses common fallacies about scaling and parallel hardware, then closes out the parallel processing chapter by tying together the full journey from a single instruction to a building full of cooperating machines.

ادامه

Real Stuff: Benchmarking CPUs Against GPUs and Multiprocessor Matrix Multiply

Comparing a CPU and a GPU fairly requires a model that accounts for both computational throughput and memory bandwidth limits together. This article introduces the roofline model used to compare real hardware like the Intel Core i7 and NVIDIA Tesla GPU, then shows how matrix multiplication is accelerated across multiple processors as the final practical application of this chapter's parallel concepts.

ادامه

Benchmarking Multiprocessors and Modeling Parallel Performance

Measuring the performance of a parallel system requires different tools and metrics than measuring a single-core processor. This article covers the specialized benchmarks used to evaluate multiprocessor systems, explains how to model scaling behavior as more processors are added, and revisits Amdahl's Law in the context of real-world performance measurement.

ادامه

Cluster Networking: Connecting to the World Outside

A cluster of machines is only useful if it can communicate efficiently both internally and with the outside world. This article covers the networking layers involved in cluster communication, the tradeoffs between latency and bandwidth at scale, and how clusters connect to external networks and users.

ادامه

Clusters, Warehouse-Scale Computers, and Network Topologies

Beyond a single chip, parallelism extends to entire buildings full of independent computers working together. This article explains the shift from shared memory multiprocessing to clusters of separate machines, introduces the concept of warehouse-scale computing, and covers the network topologies that connect these independent machines efficiently.

ادامه

An Introduction to GPUs: Massive Parallelism for Data-Heavy Workloads

A GPU takes the SIMD idea covered earlier in this series to an extreme scale, running thousands of lightweight threads simultaneously to process massive amounts of independent data. This article explains why GPUs are architecturally so different from CPUs, how their thread execution model works, and what kinds of workloads benefit most from this design.

ادامه