An instruction pipeline has five stages, namely, instruction fetch (IF),…

2014

An instruction pipeline has five stages, namely, instruction fetch (IF), instruction decode and register fetch (ID/RF), instruction execution (EX), memory access (MEM), and register writeback (WB) with stage latencies 1 ns, 2.2 ns, 2 ns, 1 ns, and 0.75 ns, respectively (ns stands for nanoseconds). To gain in terms of frequency, the designers have decided to split the ID/RF stage into three stages (ID, RF1, RF2) each of latency 2.2/3 ns. Also, the EX stage is split into two stages (EX1, EX2) each of latency 1 ns. The new design has a total of eight pipeline stages. A program has 20% branch instructions which execute in the EX stage and produce the next instruction pointer at the end of the EX stage in the old design and at the end of the EX2 stage in the new design. The IF stage stalls after fetching a branch instruction until the next instruction pointer is computed. All instructions other than the branch instruction have an average CPI of one in both the designs. The execution times of this program on the old and the new design are \(P\) and \(Q\) nanoseconds, respectively. The value of \(P/Q\) is __________.

Attempted by 19 students.

Show answer & explanation

Correct answer: 1.5

Key steps and calculations:

  • Clock period of the old design = maximum stage latency = 2.2 ns.

  • Clock period of the new design = maximum stage latency after splitting = 1 ns (many stages have latency ≤ 1 ns, the largest is 1 ns).

  • Branch resolution position in the old design: at the end of the EX stage (third stage). Since IF is stage 1, the IF stage must be stalled for the two intermediate cycles (ID/RF and EX) after fetching a branch. So branch penalty in cycles (old) = 2 cycles.

  • Branch resolution position in the new design: at the end of EX2 (sixth stage). Counting from IF (stage 1), the IF stage must be stalled for five cycles (ID, RF1, RF2, EX1, EX2) after fetching a branch. So branch penalty in cycles (new) = 5 cycles.

  • Average CPI (old) = 1 + branch_fraction × penalty_old = 1 + 0.2 × 2 = 1.4.

  • Average CPI (new) = 1 + 0.2 × 5 = 2.0.

  • Ratio of total execution times P/Q = (CPI_old × clock_old) / (CPI_new × clock_new) = (1.4 × 2.2) / (2.0 × 1) = 3.08 / 2 = 1.54 ≈ 1.5.

Final answer: P/Q ≈ 1.54, which rounds to 1.5.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir