Admin Panel AccessUser ManagementSystem SettingsExport DatabaseDownload BackupUser Credentials ListAPI Keys ManagementAccess TokensEnvironment ConfigConfiguration FileWordPress AdminWordPress LoginphpMyAdminJoomla AdminEnvironment FileGit ConfigDatabase BackupDebug InterfaceTest EndpointInternal API
LearnlyAILibraryPodcasts
DashboardMy ShelfAll NotesAI ChatCreate AI NoteEssay AssistantAI PresentationTo-DoCalendar
Courses

Log in to view your courses

Referral & Rewards
Revision Notes
AS-Level
OCR
Computer Science
1. The Characteristics of Contemporary Processors, Input, Output & Storage Devices
Pipelining
AI Assistant

Pipelining

Summary

Pipelining is a fundamental processor architecture technique that increases instruction throughput by overlapping the execution of multiple instructions. By dividing the instruction cycle into discrete stages, the CPU can process different parts of several instructions simultaneously, significantly improving performance without necessarily reducing the time taken for a single instruction to complete.

1. Definition & Core Concepts

  • Pipelining is an implementation technique where multiple instructions are overlapped in execution, similar to an industrial assembly line.

  • The standard instruction cycle is divided into discrete stages, typically including Fetch (retrieving the instruction), Decode (interpreting the opcode), and Execute (performing the operation).

  • In a pipelined system, as soon as the first instruction moves from the Fetch stage to the Decode stage, the next instruction can enter the Fetch stage.

  • This concurrency ensures that different hardware resources within the CPU are utilized at every clock cycle, rather than sitting idle while a single instruction completes its entire cycle.

Instruction Pipeline OverlapFetch 1Decode 1Execute 1Fetch 2Decode 2Execute 2Fetch 3Decode 3Execute 3Cycle 1Cycle 2Cycle 3

Diagram showing three instructions overlapping in a 3-stage pipeline across multiple clock cycles.

2. Underlying Principles

3. Pipeline Hazards

  • Structural Hazards: These occur when the hardware cannot support all possible combinations of instructions in the same clock cycle, such as two instructions needing to access memory simultaneously.

  • Data Hazards: These arise when an instruction depends on the result of a previous instruction that is still moving through the pipeline. A common type is Read After Write (RAW), where an instruction tries to read a register before a previous instruction has written to it.

  • Control Hazards: Also known as branch hazards, these occur when the pipeline makes the wrong decision on a conditional branch, fetching instructions that should not be executed.

  • Pipeline Flush: When a branch is taken, the instructions already in the pipeline (which were fetched sequentially) must be discarded, causing a performance penalty.

4. Methods & Techniques

5. Key Distinctions

6. Exam Strategy & Tips

  • Throughput vs. Latency: Pipelining aims to increase throughput (the number of instructions completed per unit of time) rather than decreasing latency (the time it takes for a single instruction to finish).

  • Clock Cycle Time: The clock period of a pipelined processor is determined by the duration of the slowest stage plus the overhead of the pipeline registers (latches) that store data between stages.

  • Ideal Speedup: In an ideal scenario with kkk stages and nnn instructions, the speedup over a non-pipelined processor is approximately kkk. The formula for the time taken to execute nnn instructions in a kkk-stage pipeline is: Tpipe=[k+(n−1)]×Clock CycleT_{pipe} = [k + (n - 1)] \times \text{Clock Cycle}Tpipe​=[k+(n−1)]×Clock Cycle

  • Balanced Stages: Maximum efficiency is achieved when all stages take exactly the same amount of time; otherwise, faster stages must wait for the slowest one, creating idle time.

  • Stalling (Bubbles): The simplest way to resolve hazards is to pause the pipeline for one or more cycles, effectively inserting a 'no-operation' (NOP) instruction until the dependency is resolved.

  • Forwarding (Bypassing): This technique routes the result of an operation directly from the output of the execution unit to the input of a subsequent instruction, bypassing the need to wait for a write-back to a register.

  • Branch Prediction: Processors use logic to guess whether a branch will be taken or not. If the guess is correct, the pipeline continues without interruption; if incorrect, the pipeline is flushed.

  • Delayed Branching: A compiler-level technique where the instruction immediately following a branch is always executed, regardless of the branch outcome, to keep the pipeline full.

Feature Non-Pipelined Pipelined
Execution One instruction at a time Multiple instructions overlapped
Throughput Lower (1 instruction per kkk cycles) Higher (Ideally 1 instruction per cycle)
Complexity Simpler hardware design Complex control logic and hazard detection
Resource Usage Low (most units idle most of the time) High (most units active every cycle)
  • Latency Impact: While pipelining increases throughput, the latency of an individual instruction often increases slightly due to the overhead of pipeline registers and the need to synchronize stages to the slowest unit.
  • Calculate Speedup: Always check if the question provides the number of instructions (nnn) and stages (kkk). Use the formula Speedup=n×kk+n−1\text{Speedup} = \frac{n \times k}{k + n - 1}Speedup=k+n−1n×k​ for finite instructions, or simply kkk for a very large nnn.

  • Identify Hazards: Look for instructions where the destination register of one is the source register of the next; this is a classic data hazard that requires stalling or forwarding.

  • Branch Penalties: If a branch occurs at stage 3 of a 5-stage pipeline, remember that 2 instructions (already in stages 1 and 2) will likely need to be flushed if the branch is taken.

  • Sanity Check: A pipelined processor should never be slower than a non-pipelined one in terms of throughput, but it will never achieve a speedup greater than the number of stages.