18116029
18116029
GURPREET SINGH-18116029
22 October 2019
1 Question
Consider the following assembly language program.
I1: MOV R3, R7
I2: LD R8, [R3]
I3: ADD R3, R3, 4
I4: LOAD R9, [R3]
I5: BNE R8, R9, I3
List all the dependencies in this code.
Answer
1
2 Question
We have a single stage, no pipelined machine, and a pipelined machine with 5-
stages. The cycle time for the former is 5 ns and the latter is 1 ns.
a. Assume no stalls, what is the speedup of the pipelined machine over the
single staged machine?
b. Given the pipeline stalls 1 cycle for 40 % of the instructions, what is the
speedup now?
Answer
a)
let number of instructions is n.
Speedup = 1 x n x 5/(5+n-1) = 5n/(4+n)
when number of instructions is very large , by taking limit n - > infinity
speedup = 5
b) Average CPI = 1 + 0.4 x 1 = 1.4
Speedup = 5n/1.4n = 3.58
2
3 Question
Use the following code fragment.
I1: Loop: LD R1, 0[R2]
I2: DADDI R1, R1, 1
I3: SD 0[R2], R1
I4: DADDI R2, R2, 4
I5: DSUB R4, R3, R2
I6: BNEZ R4, Loop
b. Show the timing of this instruction sequence for a 5-stage pipeline along
with the number of cycles required to execute one iteration of the loop with no
forwarding.
c. Show the timing of this instruction sequence for a 5-stage pipeline along
with the number of cycles required to execute one iteration of the loop with
forwarding.
Assume registers can be written and read in the same cycle, during write back.
(The number of cycles for the execution of one iteration of the loop ends after
the A (ALU) stage of BNEZ instruction.)
Answer :
b) 16 Cycles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
LD F D E M W
DADDI F S S D E M W
SD F S S D E M W
DADDI F D E M W
DSUB F S S D E M W
BNEZ F S S D E
outside F S
3
c) 9 Cycles
1 2 3 4 5 6 7 8 9
LD F D E M W
DADDI F S D E M W
SD F D E M W
DADDI F D E M W
DSUB F D E M
BNEZ F D E
outside F S
4
4 Question
Individual stages of a processor have the following latencies.
F D A M W
210 90 110 240 50
a. What is the clock cycle time if we implement this processor using single-
cycle approach (in ps)?
b. What is the clock cycle time if we implement this processor using a 5-stage
pipeline (in ps)?
Answer :
CPUA = 1 x 700 x N
5
d) 3 Stage pipeline :
Stage 1 : F - 210 ps