Question

Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3,...

Given the following sequence of instructions:

lw $s2, 0($s1) //1

lw $s1, 40($s3) //2

sub $s3, $s1, $s2 //3

add $s3, $s2, $s2 //4

or $s4, $s3, $zero //5

sw $s3, 50($s1) //6

a.

List the read after write (current instruction is reading certain registers which haven’t been written back yet) data dependencies. As an example , 3 on 1 ($s2) shows instruction 3 has data dependency on instruction 1 since it is reading register $s2.

b.

Assume the 5 stage MIPS pipeline with no forwarding and each stage takes 1 cycle. No inserting of NOPs, you let the processor stall on hazards. How many times does the processor stall(notice the stall happens when the register you want to read hasnt been written back from previous instructions)?Where does the stall happen?i.e, specify the stall between instruction #x and instruction #y How long is each stall (in the unit of cycles)? What is the execution time (in cycles) for the whole program? Sketch a diagram(refer to Figure 4.30 on page 280 of the textbook ) to explain your answer.

c.

Assume the 5 stage MIPS pipeline with full forwarding Will all the stall you saw in Question b be eliminated? If not, insert NOPs instead of stall to eliminate the hazards. Sketch a diagram to illustrate

your answer

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a. Read-after-Write data dependencies:

  • 3 on 1 ($s2) - Instruction 3 has data dependency on instruction 1 since it is reading register $s2
  • 3 on 2 ($s1) - Instruction 3 has data dependency on instruction 2 since it is reading register $s1
  • 4 on 1 ($s2) - Instruction 4 has data dependency on instruction 1 since it is reading register $s2
  • 5 on 4 ($s3) - Instruction 5 has data dependency on instruction 4 since it is reading register $s3
  • 6 on 2 ($s1) - Instruction 6 has data dependency on instruction 2 since it is reading register $s1
  • 6 on 4 ($s3) - Instruction 6 has data dependency on instruction 4 since it is reading register $s3

b. Pipeline Diagram:

1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 IF ID EX MEM WB
2 IF ID EX MEM WB
3 IF nop nop ID EX MEM WB
4 IF ID EX MEM WB
5 IF nop nop ID EX MEM WB
6 IF ID EX MEM WB
  • We can see that the processor is having stalls for 2 times.
    • One is at instruction 3
    • Another one is at instruction 5
  • For every stall, it is taking 2 cycles.
  • The total execution time: 14 cycles

c. We can place a nop after instruction 2 so that the value of $s1 can be directly forwarded from the MEM stage of instruction 2 to the EX stage of instruction 3.

1 2 3 4 5 6 7 8 9 10 11
1 IF ID EX MEM WB
2 IF ID EX MEM WB
nop
3 IF ID EX MEM WB
4 IF ID EX MEM WB
5 IF ID EX MEM WB
6 IF ID EX MEM WB
Add a comment
Know the answer?
Add Answer to:
Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Given the following instruction sequence for the MIPS processor with the standard 5 stage pipeline $10, S0. 4 addi lw S2.0(S10) add sw S2,4(510) $2, $2, $2 Show the data dependences between th...

    1. Given the following instruction sequence for the MIPS processor with the standard 5 stage pipeline $10, S0. 4 addi lw S2.0(S10) add sw S2,4(510) $2, $2, $2 Show the data dependences between the instructions above by drawing arrows between dependent instructions (only show true/data dependencies). a. Assuming forwarding support, in what cycle would the store instruction write back to memory? Show the cycle by cycle execution of the instructions as they execute in the pipeline. Also, show any stalls...

  • We have the following sequence of instructions in MIPS lw $t4, 4($s1) or $t1, $t2, $t3...

    We have the following sequence of instructions in MIPS lw $t4, 4($s1) or $t1, $t2, $t3 or $t2, $t1, $t4 or $t1, $t1, $t2 1) Indicate any hazards and what the hazard types are. 2) Assume there is no forwarding in this pipelined processor and each stage takes 1 cycle. Draw the pipeline chart and calculate how many cycles are consumed 3) Assume there is forwarding in this pipelined processor and each stage takes 1 cycle. Draw the pipeline chart...

  • Show how the following four instructions will be executed within the MIPS pipeline. Also, show the...

    Show how the following four instructions will be executed within the MIPS pipeline. Also, show the forwarding paths needed. Use the graphical notation showing all stages of MIPS pipeline. Indicate all data dependencies. Which dependencies are data hazards that will be resolved via forwarding? Which dependencies are data hazards that will cause a stall? add $s3, $s4, $s6 sub $s5, $s5, $s2 lw $s7, 100 ($s5) add $s8, $s7, $s2

  • Given the following sequence of instructions to be executed on a 5-stage pipelined datapath as decrypted...

    Given the following sequence of instructions to be executed on a 5-stage pipelined datapath as decrypted in our textbook: I1: add $8, $12,$10 12: SW $9,0 ($8) 13: lw $8,4($9) I4: and $12,$12,$8 15: SW $8,0($9) a. List true dependencies in the given sequence in the format of (register involved producer instruction, consumer instruction). Use labels to indicate instructions For example: ($0, I10, I11) means a true dependence between instruction I10 and I11: value of register $0 is generated by...

  • We execute the following instruction sequence (data hazards may exhibit in the sequence) on a MIPS...

    We execute the following instruction sequence (data hazards may exhibit in the sequence) on a MIPS 5-stage pipeline with forwarding and stall features implemented. Draw a graphical representation for the execution of the instruction sequence that clearly shows (1) forwarding path (if any); (2) stall cycles (if any); and (3) total cycles needed for the execution. lw R8, 0x0020(R10) add R9, R8, R10 sw R8, 0x0040(R10)

  • Question 1: Problems in this exercise refer to the following sequence of instructions : LW $5,...

    Question 1: Problems in this exercise refer to the following sequence of instructions : LW $5, -16($5) SW $5, -16($5) ADD $5, $5, $5 A) Indicate dependences and their type. (40 Points) B) Assume there is not forwarding in this pipeline processor, indicate hazards and add NOP instructions to eliminate them. C) Assume there is full forwarding, indicate hazards and add NOP instructions to eliminate unresolved cases. The remaining problem in this exercise assumes the following clock cycle times: Without...

  • Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6,...

    Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6, $s2, $s2 sw Ss6, 48(Ss1) a. Include stalls/nops in the code so it executes correctly in the cases of (i) No forwarding (ii) ALU-ALU for warding, (iii) Full forwarding b. In each case calculate the number of clock cycles required to execute the code c. Assume further that the clock cycle time is 110 ps with no forwarding, 120 ps with ALU-ALU forwarding and...

  • (60 points) The following instructions are executed on the 5-stage MIPS pipelined datapath. add r...

    Computer architecture help: (60 points) The following instructions are executed on the 5-stage MIPS pipelined datapath. add r5,r2, r1 lw r3, 4(r5) lw r2, 0(r2) or r3, r5, r3 sw r3, 0(r5) (a) (20 points) List the data hazards in the above code. For each data hazard identified, clearly mark the source and the destination. For example you can say, there is a data hazard from instruction X to instruction Y on register Z. (b) (20 points) Assume there is...

  • Q4. (20 points) Consider the following sequence of instructions being processed on the 5-stage RISC-V pipelined...

    Q4. (20 points) Consider the following sequence of instructions being processed on the 5-stage RISC-V pipelined processor: lw r4, 100 (r2) add r5, r2, r3 sub r6, r4, r5 and r7, r2, r5 I. Identify all the data dependencies in the above instruction sequence. For each dependency, indicate the two instructions and the register that causes the dependency. I Assume that the pipelined uses full forwarding. Draw a pipelined diagram that represents the flow of instructions through the pipeline during...

  • 1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0)...

    1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 . 2.Please use 5-stage pipeline to describe following MIPS assembly code in forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 sw         $s2,      4($t0)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT