Any function requires three stages to complete Fetch Decode
     Any function requires three stages to complete: Fetch, Decode and Execute. For the purpose of this question we will assume that each of these stages take t ms to complete. Assume a Function Turbo runs 3 times in a loop.  How long will it take for the loop to complete assuming that there is no pipeline and only one stage (Fetch, Decode, or Execute) can run at a given time on your microprocessor?  How long will it take for the loop to complete assuming that there is a three stage pipeline?  Was there an advantage of using a pipeline? Give your answer in terms of percentage improvement. Give your answers in terms of t for each of the question above. You must clearly state any assumption necessary for your solution.    
 
  
  Solution
Fetch takes = t ms
Decode takes = t ms
Execute takes = t ms
a.
No pipeline
one function run takes = t ms + tms + t ms = 3 t ms.
If function executes 3 times in the loop total time taken = 3*(3 t ms) = 9 t ms.
b.
using 3 stage Pipeline
t ms t ms tms t ms t ms
Time taken for the loop = t ms + t ms + t ms + t ms + t ms = 5t ms
c.
So there is advantage of using pipeline(5t ms) as compared to no pipeline(9t ms)
% improvement = (9-5)/9 *100 = 44.4 %
| Fetch | Decode | Execute | ||
| Fetch | Decode | Execute | ||
| Fetch | Decode | Execute | 

