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 21–25 of 53
Consider the sequence of machine instructions given below:
MUL R5, R0, R1
DIV R6, R2, R3
ADD R7, R5, R6
SUB R8, R7, R4
In the above sequence, R0 to R8 are general purpose registers. In the instructions shown, the first register stores the result of the operation performed on the second and the third registers. This sequence of instructions is to be executed in a pipelined instruction processor with the following 4 stages: (1) Instruction Fetch and Decode (IF), (2) Operand Fetch (OF), (3) Perform Operation (PO) and (4) Write back the result (WB). The IF, OF and WB stages take 1 clock cycle each for any instruction. The PO stage takes 1 clock cycle for ADD or SUB instruction, 3 clock cycles for MUL instruction and 5 clock cycles for DIV instruction. The pipelined processor uses operand forwarding from the PO stage to the OF stage.
The number of clock cycles taken for the execution of the above sequence of instructions is ___________.
MUL R5, R0, R1
DIV R6, R2, R3
ADD R7, R5, R6
SUB R8, R7, R4
In the above sequence, R0 to R8 are general purpose registers. In the instructions shown, the first register stores the result of the operation performed on the second and the third registers. This sequence of instructions is to be executed in a pipelined instruction processor with the following 4 stages: (1) Instruction Fetch and Decode (IF), (2) Operand Fetch (OF), (3) Perform Operation (PO) and (4) Write back the result (WB). The IF, OF and WB stages take 1 clock cycle each for any instruction. The PO stage takes 1 clock cycle for ADD or SUB instruction, 3 clock cycles for MUL instruction and 5 clock cycles for DIV instruction. The pipelined processor uses operand forwarding from the PO stage to the OF stage.
The number of clock cycles taken for the execution of the above sequence of instructions is ___________.
Answer: 13
Cycle by cycle (PO handles one instruction at a time, and results are forwarded from PO):
- MUL: IF in 1, OF in 2, PO in 3-5, WB in 6
- DIV: IF in 2, OF in 3, PO in 6-10, WB in 11
- ADD: IF in 3, OF in 4, waits for R6, PO in 11, WB in 12
- SUB: IF in 4, OF in 5, waits for R7, PO in 12, WB in 13
Answer: 13
- MUL: IF in 1, OF in 2, PO in 3-5, WB in 6
- DIV: IF in 2, OF in 3, PO in 6-10, WB in 11
- ADD: IF in 3, OF in 4, waits for R6, PO in 11, WB in 12
- SUB: IF in 4, OF in 5, waits for R7, PO in 12, WB in 13
Answer: 13
Consider the following reservation table for a pipeline having three stages S1,S2 and S3.
The minimum average latency (MAL) is ________.
The minimum average latency (MAL) is ________.
Answer: 3
From the table, S1 is used at times 1 and 5 (gap 4), S2 at times 2 and 4 (gap 2), and S3 only once. So the forbidden latencies are {2, 4}.
The collision vector has one bit for each latency 4, 3, 2, 1, with 1 meaning forbidden: . Any latency of 5 or more is always allowed.
For each allowed latency, shift the state right by that many places and OR with 1010:
- From 1010, latency 1: 0101 OR 1010 = 1111
- From 1010, latency 3: 0001 OR 1010 = 1011
- From 1111, only latency 5 or more is allowed, which gives 1010
- From 1011, latency 3: 0001 OR 1010 = 1011 again; latency 5 or more gives 1010
Cycles: (3) has average 3. (1, 5) has average . Others such as (3, 5) give 4 and (5) gives 5.
No cycle can average less than 3. A cycle without latency 1 uses only latencies of 3 or more. A latency 1 is always followed by one of 5 or more, so each such pair adds up to at least 6 over 2 latencies.
MAL = 3
Answer: 3
The collision vector has one bit for each latency 4, 3, 2, 1, with 1 meaning forbidden: . Any latency of 5 or more is always allowed.
For each allowed latency, shift the state right by that many places and OR with 1010:
- From 1010, latency 1: 0101 OR 1010 = 1111
- From 1010, latency 3: 0001 OR 1010 = 1011
- From 1111, only latency 5 or more is allowed, which gives 1010
- From 1011, latency 3: 0001 OR 1010 = 1011 again; latency 5 or more gives 1010
Cycles: (3) has average 3. (1, 5) has average . Others such as (3, 5) give 4 and (5) gives 5.
No cycle can average less than 3. A cycle without latency 1 uses only latencies of 3 or more. A latency 1 is always followed by one of 5 or more, so each such pair adds up to at least 6 over 2 latencies.
MAL = 3
Answer: 3
Consider the following code sequence having five instructions I1 to I5. Each of these instructions has the following format.
OP Ri, Rj, Rk
where operation OP is performed on contents of registers Rj and Rk and the result is stored in register Ri.
I1: ADD R1, R2, R3
I2: MUL R7, R1, R3
I3: SUB R4, R1, R5
I4: ADD R3, R2, R4
I5: MUL R7, R8, R9
Consider the following three statements.
S1: There is an anti-dependence between instructions l2 and l5
S2: There is an anti-dependence between instructions l2 and l4
S3: Within an instruction pipeline an anti-dependence always creates one or more stalls
Which one of above statements is/are correct?
OP Ri, Rj, Rk
where operation OP is performed on contents of registers Rj and Rk and the result is stored in register Ri.
I1: ADD R1, R2, R3
I2: MUL R7, R1, R3
I3: SUB R4, R1, R5
I4: ADD R3, R2, R4
I5: MUL R7, R8, R9
Consider the following three statements.
S1: There is an anti-dependence between instructions l2 and l5
S2: There is an anti-dependence between instructions l2 and l4
S3: Within an instruction pipeline an anti-dependence always creates one or more stalls
Which one of above statements is/are correct?
Answer: (B)
Anti-dependence (WAR) means a later instruction writes to a register that an earlier instruction reads.
- S1: I2 and I5 both write R7. This is output dependence, not anti-dependence False
- S2: I2 reads R3 and I4 writes R3 This is anti-dependence True
- S3: In an in-order pipeline, WAR does not cause a stall False
Answer: Only S2 is true
- S1: I2 and I5 both write R7. This is output dependence, not anti-dependence False
- S2: I2 reads R3 and I4 writes R3 This is anti-dependence True
- S3: In an in-order pipeline, WAR does not cause a stall False
Answer: Only S2 is true
Consider a 6-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is executing on this 6-stage pipeline, the speedup achieved with respect to non-pipelined execution if 25% of the instructions incur 2 pipeline stall cycles is _________.
Answer: 4
The CPI of the pipeline = 1 + 0.25 2 = 1.5. With all 6 stages balanced, the ideal speedup is 6.
Speedup = 6 / 1.5 = 4
Answer: 4
Speedup = 6 / 1.5 = 4
Answer: 4
Consider two processors P1 and P2 executing the same instruction set. Assume that under identical conditions, for the same input, a program running on P2 takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to the program running on P1. If the clock frequency of P1 is 1GHz, then the clock frequency of P2 (in GHz) is _________.
Answer: 1.6
Execution time is IC CPI / f. Use these two relations:
and
Frequency of P2:
GHz
Answer: 1.6
and
Frequency of P2:
GHz
Answer: 1.6
Keep practising