Question

In: Computer Science

Problem Description: Given Machine Instruction 1. LD R1, 50(R2) 2. ADD R3, R1, R4 3. LD...

Problem Description:

Given Machine Instruction

1. LD R1, 50(R2)

2. ADD R3, R1, R4

3. LD R5, 100(R3)

4. MUL R6, R5, R7

5. ADD R1, R1, #100

6. SUB R2, R2, #8

Font type: Times New Roman and Size 12

Task to do:

a) Draw the four-stage pipeline for the above Instruction.

b) Calculate the total clock cycles for all the above-mentioned instructions need to be completed.

c) Explain how to handle structural hazards the pipeline instruction.

d) Explain the classification of data hazards

e) Draw the flow chart for four stage pipeline and explain.

Solutions

Expert Solution

in four stage piple-line each and every instruction must execute in foure stages. lae us assum the four stages are: Fetch(F),Decode(D), Execute(E), Write(W). during the execution every stage able to process only one instruction. in the above progem the first four instructions are dependent instructions i.e the result obtained in the one instruction is used as input in the next instruction. the next instruction need to wait for the previous instruction completion. for example the the first instruction is loading the value into register R1. In second instruction R1 is the input operand. in second instruction R3 is destination or result in third instruction it is used as input operand . between these instruction deta dependency is there. In second stage (Decode) the instruction is decoded and the required operands are feteched, if operands are not available it will wait untill operands are avaialable called data hazard ( pipeline stalled). the following chart will show the instrution execution with data hazard

Instruction/clock cycle T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T13 T14 T15
1.LD R1, 50(R2) F D E W
2.ADD R3, R1, R4 F F F D E W
3.LD R5, 100(R3) F F F D E W
4. MUL R6, R5, R7 F F F D E W
5.ADD R1, R1, #100 F D E W
6.SUB R2, R2, #8 F D E W

it is clear that second instruction is waiting for first instruction, third instruction is waiting for secong instruction and fourt instruction is waiting for third instruction. last two instructions are independent instructions.

total number of clock cycles for the completion= 15

Structural hazard means resource conflict, when more than one instruction is trying to access the same resource in the same clock cycle structural hazard will occur.

for example : STR 50(R2),R1

INSTR2

INSTR3

  SUB R2, R2, #8

INstruction/Clock T1 T2 T3 T4 T5 T6
STR 50(R2),R1 F D E W
   INSTR2 F D E W
INSTR3 F D E W
SUB R2, R2, #8 F

in the above sequence of execution at clock cyle T4, instruction 1 is writing data into memory and instruction 4 is feacting the instruction from memory both are accessing the memory.

to handle the structural hazard we may include stalls in pile lien execution means delays.

INstruction/Clock T1 T2 T3 T4 T5 T6
STR 50(R2),R1 F D E W
   INSTR2 F D E W
INSTR3 F D E W
SUB R2, R2, #8 STALL F

another way of solving these hazards is to add additional hardwares. one is for featching the data another is for writing.

Classification of data hazard:

there are three types of data hazards

  1. Read After Write (RAW)
  2. Write After Write (WAW)
  3. Write After Rerad (WAR)

1. RAW hazard will occure when one instruction need to read the data after written by another instructions. in the above sequence of instructions instructions (1,2), (2,3), (3,4) are best examples.

2.this hazard is occured when the write operation of any instruction will take more than one clock cycle .

for example,

LD R1, 50(R2)

ADD R1, R3, R4

T1 T2 T3 T4 T5 T6
LD R1, 50(R2) F D MEM MEM E W
ADD R1, R3, R4 F D E W

at the end of this instruction sequence execution we will expect the r1 value which is written by second instruction but the memory operation involved in first instrution took more clock cyles. this type of hazard will ocuure when instruction involved in memory operation which are possibly take more than one clock cylcles.

3. this hazard occure if one instruction write the value after read operation of another instrtion.

in instruction decoding phase the processor will identify the operation and operand sinvolver in the instruction. if it is a branch instruction it will save the current progrma counter value as return address and discard hte instrructions which are currently in pipeline and fetch the instructions from branch target. after every instruction execution completion it will check for pending interrupts. if any interrupts is there again save the current Program counte rvalue as return address and fetch the instruction from interrupt service routine.


Related Solutions

Show and classify all potential data hazards. Instructions 1. add R2, R5, R4 2. add R4,...
Show and classify all potential data hazards. Instructions 1. add R2, R5, R4 2. add R4, R2, R5 3. sw R5, 100(R2) 4 . add R5, R2, R4
You have estimated spot rates as follows: r1= 5.60%, r2= 6.00%, r3= 6.30%, r4= 6.50%, r5=...
You have estimated spot rates as follows: r1= 5.60%, r2= 6.00%, r3= 6.30%, r4= 6.50%, r5= 6.60%. a. What are the discount factors for each date (that is, the present value of $1 paid in year t)? b. Calculate the PV of the following $1,000 bonds assuming an annual coupon and maturity of : (i) 5.6%, two-year bond; (ii) 5.6%, five-year bond; and (iii) 10.6%, five-year bond. c. What should be the yield to maturity on a five-year zero-coupon bond?...
You have estimated spot rates as follows: r1= 6.40%, r2= 6.80%, r3= 7.10%, r4= 7.30%, r5=...
You have estimated spot rates as follows: r1= 6.40%, r2= 6.80%, r3= 7.10%, r4= 7.30%, r5= 7.40%. a. What are the discount factors for each date (that is, the present value of $1 paid in year t)? (Do not round intermediate calculations. Round your answers to 3 decimal places.) year Discount Factor 1 2 3 4 5 b. Calculate the PV of the following $1,000 bonds assuming an annual coupon and maturity of : (i) 6.4%, two-year bond; (ii) 6.4%,...
Suppose that the following risk-free spot rates prevail in the market: r1=4%, r2=5%, r3=6%, r4=6.5%, where...
Suppose that the following risk-free spot rates prevail in the market: r1=4%, r2=5%, r3=6%, r4=6.5%, where rT denotes the spot rate per annum on an investment with T years to maturity, quoted with annual compounding. You can borrow and lend at these rates. Let f(T1,T2) denote the annual forward rate, quoted with annual compounding, applicable to a forward rate agreement to borrow or lend money in T1 years from today until T2 years from today. Questions: Compute the forward rate...
Problem 2 Statement: Let r1 = 1 + cos θ and r2 = 3 cos θ....
Problem 2 Statement: Let r1 = 1 + cos θ and r2 = 3 cos θ. (a) Graph each function in the rθ-plane. (b) Find all intersection points (both collision and non-collision). (c) Find the area common to the two graphs.
You have estimated spot rates as follows: r1= 1.5%,  r2= 1.8%,  r3= 2.1%,  r4= 2.3%,  r5= 3.5%, r6= 4.5%. Calculate...
You have estimated spot rates as follows: r1= 1.5%,  r2= 1.8%,  r3= 2.1%,  r4= 2.3%,  r5= 3.5%, r6= 4.5%. Calculate the price of bond with an annual coupon rate of 4.5% and six years to maturity. Face value of the bond is $1000. $1011.5 $1050.5 $1000 $1032.5 $1025.5
3. Suppose the demand for labor is given by LD = 12 – 1/5 W (or...
3. Suppose the demand for labor is given by LD = 12 – 1/5 W (or W = 60 – 5L), and the domestic supply of labor is given by LS = W – 6 (or W = L + 6) a) Calculate the market-clearing quantity of labor and the wage and graph (and label) everything: L* = ____________ W* = ___________ b) Suppose that newly arriving immigrants have LS = 2W – 12 and are as productive as domestic...
Problem 6-06 Given: E(R1) = 0.13 E(R2) = 0.18 E(σ1) = 0.04 E(σ2) = 0.06 Calculate...
Problem 6-06 Given: E(R1) = 0.13 E(R2) = 0.18 E(σ1) = 0.04 E(σ2) = 0.06 Calculate the expected returns and expected standard deviations of a two-stock portfolio having a correlation coefficient of 0.75 under the conditions given below. Do not round intermediate calculations. Round your answers to four decimal places. w1 = 1.00 Expected return of a two-stock portfolio: Expected standard deviation of a two-stock portfolio: w1 = 0.80 Expected return of a two-stock portfolio: Expected standard deviation of a...
eBook Problem 6-06 Given: E(R1) = 0.12 E(R2) = 0.16 E(σ1) = 0.05 E(σ2) = 0.06...
eBook Problem 6-06 Given: E(R1) = 0.12 E(R2) = 0.16 E(σ1) = 0.05 E(σ2) = 0.06 Calculate the expected returns and expected standard deviations of a two-stock portfolio having a correlation coefficient of 0.75 under the conditions given below. Do not round intermediate calculations. Round your answers to four decimal places. w1 = 1.00 Expected return of a two-stock portfolio: Expected standard deviation of a two-stock portfolio: w1 = 0.70 Expected return of a two-stock portfolio: Expected standard deviation of...
Two spacecraft are following paths in space given by r1=〈sin(t),t,t2〉r1=〈sin⁡(t),t,t2〉 and r2=〈cos(t),1−t,t3〉.r2=〈cos⁡(t),1−t,t3〉. If the temperature for...
Two spacecraft are following paths in space given by r1=〈sin(t),t,t2〉r1=〈sin⁡(t),t,t2〉 and r2=〈cos(t),1−t,t3〉.r2=〈cos⁡(t),1−t,t3〉. If the temperature for the points is given by T(x,y,z)=x2y(6−z),T(x,y,z)=x2y(6−z), use the Chain Rule to determine the rate of change of the difference DD in the temperatures the two spacecraft experience at time t=2.t=2. (Use decimal notation. Give your answer to two decimal places.) dDdt=dDdt=
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT