Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

RISC, CISC and pipelining

RISC vs CISC and pipelining: why designs differ, how pipelining improves throughput, hazards and their mitigation, with worked numerical examples a student can expect in exams.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers choose processor designs (instruction set and pipeline structure) to meet performance, power and implementation cost targets. Understanding RISC, CISC and pipelining helps you reason about CPI (cycles per instruction), clock rate, and real-world speedups, and to design or optimise compilers, instruction scheduling and processor control.

Key ideas

  • CISC (Complex Instruction Set Computer) — an ISA design philosophy that provides many complex instructions, often allowing memory operands in arithmetic instructions and variable-length encodings. Define: CISC = large, irregular instruction set with complex addressing and multi-step instructions.

  • Key practical differences (explain plainly): RISC tries to simplify hardware and pipeline by making every instruction similar; CISC packs more functionality per instruction which can reduce code size but complicates pipelines and decoding. Typical pros/cons often cited in exams: RISC—simpler control and pipelines, easier high clock rates, many registers, but larger code size; CISC—higher code density and fewer instructions executed, but more complex decode/microcode and harder to pipeline at very high frequencies.

  • Pipelining — a technique to improve instruction throughput by overlapping instruction execution. Define: pipeline stage = a processing step (e.g., Instruction Fetch, Decode, Execute, Memory, Writeback). In an ideal pipeline with p stages, after the pipeline is full, one instruction completes each cycle (throughput of one instruction per cycle), so latency for one instruction is p cycles but throughput is 1/cycle.

  • Formal pipeline performance model (assumptions stated): assume balanced stages (each stage takes approximately the same time), negligible pipeline overhead except where stated, and ignore hazards for the ideal model. Under these assumptions: ideal pipeline speedup ≤ p (number of stages). Real speedup is less because of pipeline register overhead and hazards.

  • Derivation of pipeline speedup (standard exam derivation):

    1. Unpipelined cycle time = sum of times of all stages = T_total.
    2. Pipelined cycle time = max(stage times) + T_overhead (pipeline register delay). For balanced stages approximate = T_total / p + T_overhead.
    3. Execution time for N instructions unpipelined = N · T_total.
    4. Execution time for N instructions pipelined ≈ (N + p - 1) · (T_total / p + T_overhead).
    5. For large N, speedup ≈ T_total / (T_total / p + T_overhead) = p / (1 + p·T_overhead/T_total).
    6. If T_overhead = 0 and stages balanced, speedup → p.
  • Hazards — conditions that prevent the next instruction in the pipeline from executing in its designated clock cycle.

    • Structural hazard: hardware resource conflict (e.g., single memory for instruction/data).
    • Data hazard: instruction depends on result of an earlier instruction not yet written back. Types: RAW (true), WAR (anti), WAW (output); in a simple in-order 5-stage pipeline only RAW occurs, while WAR/WAW arise with out-of-order execution or writeback reordering.
    • Control hazard: caused by branches and changes in control flow.
  • Typical ways to handle hazards: hardware forwarding (bypassing), inserting pipeline stalls (bubbles), pipeline interlocks, branch prediction, and compiler reordering (static scheduling).

  • Exact CPI accounting used in exams: CPI_actual = CPI_ideal + CPI_stalls, where CPI_ideal is 1 for a perfectly pipelined processor (one instruction per cycle after fill), and CPI_stalls sums stall cycles per instruction caused by structural, data and control hazards. Explain assumptions when CPI_ideal differs (e.g., multi-cycle functional units). For a multiple-issue machine of width w with ideal IPC = w, CPI_ideal = 1/w.

  • Relationship between throughput, latency and CPI:

    • Throughput = 1 / (CPI · clock_period) (instructions per second).
    • Latency = number of cycles to complete one instruction × clock_period.
  • Diagram you should draw for exams:

    • Draw a horizontal pipeline timing diagram table: rows = instructions (I1, I2, ...), columns = clock cycles (1, 2, 3...). Fill cells with stages: IF, ID, EX, MEM, WB. Show a bubble as an empty cell or label "stall". Label pipeline depth p and mark where forwarding eliminates a stall. Also draw a block diagram of a 5-stage pipeline showing IF, ID, EX, MEM, WB in sequence with pipeline registers between stages.

Formulas

ExecutionTime_unpipelined = IC × T_total where IC = instruction count (instructions), T_total = unpipelined cycle time (seconds)

ExecutionTime_pipelined ≈ (IC + p - 1) × (T_total/p + T_overhead) where p = number of pipeline stages, T_overhead = pipeline register overhead (s)

Speedup ≈ ExecutionTime_unpipelined / ExecutionTime_pipelined (dimensionless)

CPUTime = IC × CPI_actual × ClockPeriod (seconds)

CPI_actual = CPI_ideal + CPI_structural + CPI_data + CPI_control where each CPI_* is stall cycles per instruction (cycles/instruction)

Throughput = 1 / (CPI_actual × ClockPeriod) (instructions per second). Equivalent forms: IPC = 1 / CPI_actual and ClockRate = 1 / ClockPeriod, so Throughput = ClockRate × IPC.

ClockPeriod_pipelined ≈ T_total/p + T_overhead (seconds)

Notes: IC unit = instructions, time units SI = seconds. Use these when computing execution time and speedup.

Worked examples

Example 1 — pipeline speedup with numbers

Given: IC = 1,000,000 instructions; unpipelined (single-cycle) clock period T_total = 10 ns; pipeline depth p = 5; assume perfectly balanced stage so stage time = T_total/p = 2 ns; pipeline register overhead T_overhead = 0.2 ns. Compute execution times and speedup.

  1. Unpipelined execution time = IC × T_total = 1,000,000 × 10×10^-9 s = 0.01 s = 10 ms.
  2. Pipelined clock period = T_total/p + T_overhead = 2 ns + 0.2 ns = 2.2 ns.
  3. Pipelined execution time ≈ (IC + p - 1) × clock_period = (1,000,000 + 4) × 2.2×10^-9 s = 1,000,004 × 2.2×10^-9 s = 0.0022000088 s = 2.2000088 ms.
  4. Speedup = 10 ms / 2.2000088 ms ≈ 4.5454.

Final answer: Execution time unpipelined = 10 ms; pipelined = 2.2000088 ms; speedup ≈ 4.545.

Example 2 — CPI with branch penalty

Given: branch frequency f_b = 0.20 (20% of instructions are branches); branch penalty P = 2 cycles (average cycles lost per branch); ideal CPI = 1; IC = 2,000,000; clock period = 2 ns. Compute CPI and execution time.

  1. CPI_actual = CPI_ideal + f_b × P = 1 + 0.20 × 2 = 1 + 0.4 = 1.4 cycles/instruction.
  2. Execution time = IC × CPI_actual × clock_period = 2,000,000 × 1.4 × 2×10^-9 s = 5.6×10^-3 s = 5.6 ms.

Final answer: CPI = 1.4; execution time = 5.6 ms.

Example 3 — short pipeline trace (5-stage, data hazard and stall)

Sequence (assembly-like):

  1. LW R1, 0(R2) ; load into R1
  2. ADD R3, R1, R4 ; uses R1 — load-use hazard
  3. SUB R5, R3, R6 ; uses R3
  4. BEQ R5, R0, L ; branch (control hazard)
  5. OR R7, R8, R9

How to trace: draw a table with rows I1..I5 and columns Cycle 1..Cycle 10. Fill IF, ID, EX, MEM, WB per instruction. For a typical load-use hazard insert 1 bubble: ADD's ID stage must be delayed one cycle because data from LW is available only after MEM then WB, but forwarding from MEM to EX may still leave one-cycle stall. Also show branch penalty: assume branch resolved in EX and incorrect-path instructions are fetched for 2 cycles (penalty = 2). Describe: after inserting one stall between I1 and I2, and a 1-cycle penalty at BEQ, fill timing diagram accordingly. The final instruction completion cycles can be read from table; total stall count = 3 cycles in this small trace.

Final step: show which cycles contain stalls and how forwarding could reduce stalls (explain conditions when forwarding removes the load-use stall — it cannot if data is available only in MEM stage for load).

Common mistakes

  • Mistaking CPI (cycles per instruction) and cycle time; both affect execution time multiplicatively.
  • Forgetting pipeline fill and drain when computing total cycles for small IC; using (IC × cycle_time) instead of (IC + p -1) for pipelined time.
  • Mixing up where forwarding can solve hazards: forwarding removes many ALU-ALU hazards but typically cannot remove the load-use hazard without an extra cycle.
  • Saying RISC always faster than CISC as a rule — real outcome depends on implementation, compiler and instruction mix.

For your exam

Question types you will see: definitions (define RISC, CISC, pipeline stages), short notes (advantages/disadvantages of RISC vs CISC, role of forwarding), derivations (pipeline speedup formula), numericals (compute CPI, execution time, speedup, branch penalties), diagrams (draw pipeline timing tables and block diagrams), and trace problems (insert stalls and show exact timing for a small instruction sequence).

What a full-marks answer includes:

  • Precise definitions with bold term names
  • Clear statement of assumptions (balanced stages, whether hazards/prediction included)
  • Correct derivation steps (for speedup use the (N+p-1) formula; show algebra)
  • A labelled diagram when asked (show stages, pipeline registers, and where hazards occur)
  • For numericals: show formulas used, substitute numbers with units, show intermediate arithmetic and final result with units

Quick check

  1. Define pipelining in one sentence.
  2. If pipeline depth p = 4, T_total = 12 ns, and T_overhead = 0.5 ns, what is the pipelined clock period (ns) approximately? (assume balanced stages)
  3. If branch frequency is 25% and average branch penalty is 3 cycles, by how much does CPI increase over ideal CPI=1?

Answers: 1. Overlapping instruction execution by dividing the processor into stages so multiple instructions are processed concurrently. 2. ClockPeriod ≈ (12/4) + 0.5 = 3 + 0.5 = 3.5 ns. 3. CPI increases by 0.25 × 3 = 0.75 (so CPI = 1.75).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?