1,184 views
0 votes
0 votes

A CPU has five-stage pipeline where each stage takes 1ns, 2ns, 1.5ns, 3ns, 2.5ns. Instruction fetch happens in the first stage of the pipeline. Branch instructions are not overlapped. i.e., the instruction after the branch is not fetched till the branch instruction is completed. Assume that each stage requires one clock cycle. 30% of the instructions are conditional branches. Find the average execution time of the program for 1200 instructions is ________

2 Answers

Best answer
1 votes
1 votes

Number of instructions = $1200$
Each clock cycle takes $max(1ns, 2ns, 1.5ns, 3ns, 2.5ns) = 3ns$
Execution time of $1200$ instructions = $(5 + 1199)*3$ = 3612 ns
Number of branch instructions = $\frac{30}{100}*1200 = 360$

The instruction after the branch is not fetched till the branch instruction is completed.

So each branch instruction will stall pipeline for 4 clock cycles  = $360*4*3$ = 4320 ns
The average execution time of the program for 1200 instructions  = 3612 + 4320 = 7932 ns. 

selected by
0 votes
0 votes
For non branch instruction, it will take max(among all pipeline stages)=3ns

For branch it is non overlapping instruction, which will take 10 ns

Now there are 30% of 1200 instruction(360 instructions) are branch instruction and 70% of instruction are non branch(840 instructions)

$=360\times 10+840\times 3=6120ns$

Related questions

0 votes
0 votes
1 answer
1