Instruction pipelines and execution time
A pipeline overlaps different instructions; it does not necessarily reduce the latency of one instruction. Draw a cycle chart whenever register timing, forwarding, variable-latency stages or branches affect when an instruction can advance.
6.1 Clock period, latency and throughput
Past papers · CS 2014–2026 (23 papers): 14 questions, 26 marks
A pipeline with one-bit items at one accepted item per clock has steady bit rate bit/s even when latency is several clocks. For bits/item, multiply the item rate by . Do not divide throughput by stage count.
6.2 Dependencies and structural conflicts
Past papers · CS 2014–2026 (23 papers): 3 questions, 4 marks
Let and be the registers read and written by instruction , with earlier than . Include implicit operands and address-generation registers in the read set.
| Hazard | Cause | Usual remedies |
|---|---|---|
| Structural | Two operations need one unavailable resource | Stall, add ports/units, pipeline the resource |
| Data | Consumer/read/write order conflicts with readiness | Forward, stall, schedule; rename false dependencies where relevant |
| Control | Next fetch address unresolved or wrong | Stall, predict, resolve sooner, flush wrong path |
In the simple in-order five-stage pipeline with all reads in ID and writes in WB, WAR and WAW do not create hazards; reads and writes retain their required order. Variable completion order or out-of-order execution can change that. Register renaming removes WAR/WAW name conflicts, not true RAW flow. A shared single-ported instruction/data memory can conflict between IF and a load/store MEM stage even with no register dependence.
6.3 Forwarding and cycle charts
Past papers · CS 2014–2026 (23 papers): 3 questions, 5 marks
Forwarding routes a produced value directly from a pipeline register to a later instruction's operand input. It needs comparison/control logic and data multiplexers. The consuming stage and production time matter more than the instruction's name.
For the following table only, use five stages IF–ID–EX–MEM–WB, operands read in ID, ALU inputs consumed in EX, ALU results ready at EX end, load data ready at MEM end, and WB writes early enough for ID to read the same cycle.
| Back-to-back producer → consumer | No forwarding | Full EX-input forwarding |
|---|---|---|
| ALU result → ALU input | 2 stall cycles | 0 |
| Load result → ALU input | 2 stall cycles | 1 |
These counts change if register read is in EX, same-cycle read/write is forbidden, the branch compares in ID, or a load takes extra cycles. A store's address may be needed in EX while its data is needed in MEM; the stated store-data forwarding path determines its stall count.
A load followed by a dependent add needs one bubble with MEM-to-EX forwarding in the stated five-stage model.
A reliable chart procedure is to place instructions in program order, mark when each source value is available, check every destination resource, and advance only when both conditions hold. During an interlock, freeze the blocked earlier stages and insert a bubble downstream when needed. Do not add overlapping stall causes twice.
6.4 Control hazards and prediction
Past papers · CS 2014–2026 (23 papers): 2 questions, 4 marks
If a branch result becomes known at the end of stage after IF is stage 1, a fetch-stalling design cannot fetch the next correct instruction until the following cycle. Predicting fetch can keep the pipeline busy, but wrong-path work must be discarded.
Static prediction fixes a direction or simple rule. A one-bit predictor records the last outcome. A two-bit saturating counter uses states 0, 1, 2, 3: predict not-taken in 0/1, taken in 2/3; increment on taken and decrement on not-taken, saturating at the ends. Trace the specified initial state. Direction prediction and obtaining a branch target are separate requirements.
6.5 Multi-cycle execution and functional resources
Past papers · CS 2014–2026 (23 papers): 3 questions, 6 marks
A unit's latency is time from entry to result; its initiation interval is the minimum spacing of new starts. An unpipelined multiply unit may occupy EX for several cycles. A pipelined multiplier can have the same latency but accept one input each cycle. Use the stated resource design.
For replicated resources, schedule jobs to the earliest available unit. With identical independent units of service time , sustained capacity is at most jobs/s. A series of processing stages is limited by the smallest stage capacity, but finite completion time includes the initial traversal. This scheduling method also handles several independent arithmetic pipelines; do not replace every such problem by the single blocking-EX formula.
6.6 Reservation tables and initiation spacing
Past papers · CS 2014–2026 (23 papers): 1 question, 2 marks
A reservation table marks the relative cycles in which one operation occupies each resource. Two initiations collide if any marks on the same row overlap after shifting one table. Revisiting a resource makes the smallest safe spacing insufficient to determine the best long-run schedule.
The equivalent collision-vector method stores forbidden latency in bit ; shift the old vector right by the chosen spacing, then OR the initial vector. State the bit convention before using a drawing. Enumerate reachable states, then compare cycle means; a locally smallest allowed choice need not be globally optimal.
6.7 Partial improvement and parallel speedup
Past papers · CS 2014–2026 (23 papers): 1 question, 2 marks
Use this result to bound an execution-time improvement, including faster arithmetic or reduced memory stalls. A percentage must refer to the original execution time; a fraction of instruction count is not automatically a time fraction.
Last-minute recall
- CPU time is dynamic instruction count × CPI × clock period.
- The slowest stage plus overhead sets the pipeline clock.
- Count fill/drain for a finite instruction sequence.
- True RAW dependence survives register renaming.
- Forwarding helps only after a value has actually been produced.
- Load-use and branch stalls depend on the stated stage timing.
- Multiply a conditional hazard rate by its instruction-class fraction.
- A blocking multi-cycle stage differs from a pipelined long-latency unit.
- Reservation-table scheduling minimises a cycle mean, not just the smallest legal gap.
- Speeding up one part cannot remove time spent in the unchanged part.