Question

Suppose a MIPS processor uses the simple 5-stage pipeline described in the text, where the stages...

Suppose a MIPS processor uses the simple 5-stage pipeline described in the text, where the stages are instruction fetch, instruction decode and operand fetch, execute and calculate address, memory access, and register write. Suppose further that

• There is a single memory for both instruction and data, which can only support one read or write each cycle.

• There is no “forwarding” in the pipeline. Thus, if an instruction B relies on a value written into a register by an instruction A, then the execute stage for B cannot proceed until the register write stage for A has completed.

• In the absence of hazards, a new instruction can be fed to the pipeline every cycle.

Consider the following MIPS code.

            Lw $s1, 0($s2)

            Lw $s3, 12($s4)

            Add $s5,$s1,$s3

            Beq $s5,$s5, L1

            Sw $s5,0($s3)

      L1: Sw $s5,12($s4)

  1.   Show all hazards?
  1. Fill in the schedule below showing exactly where each step of all instructions is executed.

Homework Answers

Answer #1

Note: Assuming "Fill in the schedule below showing exactly where each step of all instructions is executed." means creating a pipeline diagram. Please let me know if you have questions.

Pipeline Diagram

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

lw $s1, 0($s2)

IF

ID

EX

M

RW

lw $s3, 12($s4)

IF

ID

EX

M

RW

add $s5,$s1,$s3

IF

ID

EX

M*

RW

Wait for RW of previous instr

beq $s5,$s5, L1

IF

ID

EX

M*

RW*

IF cannot occur in same cycle as M

sw $s5,0($s3)

Not Executed

L1: sw $s5,12($s4)

IF

ID

EX

M

RW*

Wait for EX of branch

* -> Stages do not use memory and registers

The code takes 15 cycles to complete

Know the answer?
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
Similar Questions
Assume a five-stage single-pipeline microarchitecture (fetch, decode, execute, memory, write- back) and the code given below....
Assume a five-stage single-pipeline microarchitecture (fetch, decode, execute, memory, write- back) and the code given below. All ops are one cycle except LW and SW, which are 1+2 cycles, and branches, which are 1+1 cycles. There is no forwarding. Show the phases of each instruction per clock cycle for one iteration of the loop. Loop: lw x1,0(x2)       addi x1,x1, 1       sw x1,0(x2)       addi x2,x2,4       sub x4,x3,x2       bnz x4,Loop How many clock cycles per loop iteration...
Consider the simple five-stage pipeline (Fetch, Decode, Execute, Memory, Write-back) ADD R1, R2, R3 SUB R4,...
Consider the simple five-stage pipeline (Fetch, Decode, Execute, Memory, Write-back) ADD R1, R2, R3 SUB R4, R1, R5 For the above pairs of instructions, determine how many cycles it would take to complete execution. (1) Without forwarding. (2) With forwarding.
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed by the destination register followed by one or two source registers: Instruction no Instructions 1 ADD R3, R1, R2 2 LOAD R6, [R3] 3 AND R7, R5, 3 4 ADD R1, R6, R0 5 SUB R2, R1, R6 6 AND R3, R7, 15 7 SUB R5, R3, R4 8 ADD R0, R1, R10 9 LOAD R6, [R5] 10 SRL R7, R0, 8 Assume the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT