Pipeline Processor · Computer Organization and Architecture
53 questions · asked in 25 of 27 years (2000–2026)
MCQ 29 · MSQ 2 · NAT 221-mark 23 · 2-mark 30
2000Questions per year2026
Questions 46–50 of 53
A 5 stage pipelined CPU has the following sequence of stages:
IF - Instruction fetch from instruction memory,
RD - Instruction decode and register read,
EX - Execute: ALU operation for data and address computation,
MA - Data memory access - for write access, the register read at RD stage is used,
WB - Register write back.
Consider the following sequence of instructions:
I1 : L R0, loc1; R0 <= M[loc1]
I2 : A R0, R0; R0 <= R0 + R0
I3 : S R2, R0; R2 <= R2 - R0
Let each stage take one clock cycle. What is the number of clock cycles taken to complete the above sequence of instructions starting from the fetch of I1 ?Answer: (A)
Stages: IF, RD, EX, MA, WB, one cycle each. I1 loads R0 from memory, I2 needs R0 from I1, I3 needs R0 from I2. I1 runs IF 1, RD 2, EX 3, MA 4, WB 5.
Without forwarding, a value can be used only after it is written back (WB) and then read (RD).
If WB and RD cannot share a cycle: I2 has RD 6, EX 7, MA 8, WB 9, and I3 has RD 10, EX 11, MA 12, WB 13. Total 13 cycles.
If WB writes in the first half of a cycle and RD reads in the second half (split-phase access), they can share a cycle: I2 has RD 5, EX 6, MA 7, WB 8, and I3 has RD 8, EX 9, MA 10, WB 11. Total 11 cycles.
Neither 13 nor 11 is among the options (8, 10, 12, 15), so the intended machine passes results between stages with operand forwarding.
With forwarding, a result goes straight to the EX stage of the next instruction without waiting for WB.
I1: the loaded value is ready only at the end of MA, cycle 4.
I2: IF 2, RD 3. Its EX needs R0, which is not ready until cycle 4 ends, so it waits one cycle (cycle 4). EX 5 (R0 forwarded from the MA of I1), MA 6, WB 7. The R0 read in RD is old, but that does no harm because EX uses the forwarded value.
I3: IF 3. It cannot move into RD in cycle 4 because I2 is still held there, so RD is 5. EX 6 (R0 forwarded from the EX of I2), MA 7, WB 8.
(The stage written MM in the figure is MA.) The last instruction finishes WB in cycle 8: 5 stages + 2 later instructions + 1 stall = 8 cycles.
Answer: (A)
Without forwarding, a value can be used only after it is written back (WB) and then read (RD).
If WB and RD cannot share a cycle: I2 has RD 6, EX 7, MA 8, WB 9, and I3 has RD 10, EX 11, MA 12, WB 13. Total 13 cycles.
If WB writes in the first half of a cycle and RD reads in the second half (split-phase access), they can share a cycle: I2 has RD 5, EX 6, MA 7, WB 8, and I3 has RD 8, EX 9, MA 10, WB 11. Total 11 cycles.
Neither 13 nor 11 is among the options (8, 10, 12, 15), so the intended machine passes results between stages with operand forwarding.
With forwarding, a result goes straight to the EX stage of the next instruction without waiting for WB.
I1: the loaded value is ready only at the end of MA, cycle 4.
I2: IF 2, RD 3. Its EX needs R0, which is not ready until cycle 4 ends, so it waits one cycle (cycle 4). EX 5 (R0 forwarded from the MA of I1), MA 6, WB 7. The R0 read in RD is old, but that does no harm because EX uses the forwarded value.
I3: IF 3. It cannot move into RD in cycle 4 because I2 is still held there, so RD is 5. EX 6 (R0 forwarded from the EX of I2), MA 7, WB 8.
(The stage written MM in the figure is MA.) The last instruction finishes WB in cycle 8: 5 stages + 2 later instructions + 1 stall = 8 cycles.
Answer: (A)
In an enhancement of a design of a CPU, the speed of a floating point unit has been increased by 20% and the speed of a fixed point unit has been increased by 10%. What is the overall speedup achieved if the ratio of the number of floating point operations to the number of fixed point operations is 2:3 and the floating point operation used to take twice the time taken by the fixed point operation in the original design?
Answer: (A)
Speedup
Take as the time of one fixed point operation.
Time before the change:
Time after the change:
Now the speedup
Correct Answer:
Take as the time of one fixed point operation.
Time before the change:
Time after the change:
Now the speedup
Correct Answer:
Consider a pipeline processor with 4 stages S1 to S4. We want to execute the following loop:
The output of I1 for i = 2 will be available after
for (i = 1; i < = 1000; i++)
{I1, I2, I3, I4}
where the time taken (in ns) by instructions I1 to I4 for stages S1 to S4 are given below:The output of I1 for i = 2 will be available after
Answer: (C)
Each cycle is 1 ns. A stage handles one instruction at a time, and an instruction stays in its stage (shown as --) until the next stage is free. The row I1 (i = 2) is the first instruction of the second loop pass, so it comes right after I4 of the first pass.
Some steps: I3 finishes S2 in t5 but S3 is busy with I2 until t6, so it waits in t6. I4 cannot enter S2 before I3 leaves it, and I1 (i = 2) in turn waits in S1 in t8. I1 (i = 2) does S2 in t9 to t10 (2 ns), S3 in t11, and S4 in t12 to t13 (2 ns).
The output of I1 for i = 2 is ready at the end of t13, which is 13 ns.
Answer: (C)
Some steps: I3 finishes S2 in t5 but S3 is busy with I2 until t6, so it waits in t6. I4 cannot enter S2 before I3 leaves it, and I1 (i = 2) in turn waits in S1 in t8. I1 (i = 2) does S2 in t9 to t10 (2 ns), S3 in t11, and S4 in t12 to t13 (2 ns).
The output of I1 for i = 2 is ready at the end of t13, which is 13 ns.
Answer: (C)
A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 nanoseconds respectively. Registers that are used between the stages have a delay of 5 nanoseconds each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will be
Answer: (C)
In a pipeline, all stages must work in step. So every stage is made as long as the slowest stage, which here is . The delay of the register between stages must be added too. Here it is . This gives a clock period of
The first instruction takes this time: ns.
After that, one instruction finishes in every ns. So,
The total time for instructions microseconds.
Correct Answer:
The first instruction takes this time: ns.
After that, one instruction finishes in every ns. So,
The total time for instructions microseconds.
Correct Answer:
Consider the following program segment for a hypothetical CPU having three user registers R1, R2 and R3.
Let the clock cycles required for various operations be as follows:
Register to/from memory transfer : 3 clock cycles
ADD with both operands in register : 1 clock cycle
Instruction fetch and decode : 2 clock cycles per word
The total number of clock cycles required to execute the program is
Let the clock cycles required for various operations be as follows:
Register to/from memory transfer : 3 clock cycles
ADD with both operands in register : 1 clock cycle
Instruction fetch and decode : 2 clock cycles per word
The total number of clock cycles required to execute the program is
Answer: (B)
Each instruction costs 2 cycles for each word to fetch and decode, plus its execute time: 3 cycles for a register to or from memory transfer, 1 cycle for an ADD on registers, and 0 for HALT. The sizes (in words) come from the table in the question.
So the program takes clock cycles.
Answer: (B)
So the program takes clock cycles.
Answer: (B)
Keep practising