Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: Given the following code: LOOP: lw $5, 100($1) lw $6, 800($1) add $5, $5, $6 sw $5, 100($1) addi $1, $1, -4 bne

Problem 2: Given the following code:

LOOP:

lw $5, 100($1)

lw $6, 800($1)

add $5, $5, $6

sw $5, 100($1)

addi $1, $1, -4

bne $1, $Zero, LOOP

Assume the initial value in $1 equals 400, such that the loop executes 100 iterations.

1. Execute the code on a pipelined computer based on the following assumptions:

i) Forwarding is not available;

ii) The branch decision is made during the EX phase, and if the branch is taken, the new PC is available by the end of the MEM phase (Fig. 4.51);

iii) Do not alter the code sequence.

a) Filling in the slots of the following table. Insert stalls where they are necessary. b) How many cycles does the whole loop take to execute? Show your calculation.

image text in transcribed

**This is the lw in the next iteration.

2. Do 1. again based on the following assumptions:

i) Forwarding is available;

ii) The branch decision is made during the ID phase, and if the branch is taken, the new PC is available by the end of the ID phase (Fig. 4.62 or 4.66);

iii) Do not alter the code sequence.

a) Filling in the slots of the table above. Insert stalls where they are necessary.

b) How many cycles does the whole loop take to execute? Show your calculation.

3. Do 1. again based on the following assumptions:

i) Forwarding is available;

ii) The branch decision is made during the ID phase, and if the branch is taken, the new PC is available by the end of the ID phase. Re-schedule the instructions in the loop so that the total number of clock cycles is minimized.

a) Filling in the slots of the table above. Insert stalls where they are necessary.

b) How many cycles does the whole loop take to execute? Show your calculation.

image text in transcribed

Instruction lw S5, 100($1) lw $6, 800(S1) add S5, $5, $6 sw $5, 100 ($1) addi $1, $1,-4 bne S1, SZero, LOOF **lw S5, 100(S1) 123 4 5678910 11 12 13 1415 16 Instruction lw S5, 100($1) lw $6, 800(S1) add S5, $5, $6 sw $5, 100 ($1) addi $1, $1,-4 bne S1, SZero, LOOF **lw S5, 100(S1) 123 4 5678910 11 12 13 1415 16

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

Students also viewed these Databases questions