Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the following code fragment: LW R1, 0(R2) R1 = MEM[R2+0] ADDWI R1, R1, #1 32 bit add; R1=R1+1 SW 0(R2), R1 MEM[R2+0] = R1

For the following code fragment:

LW R1, 0(R2) R1 = MEM[R2+0]

ADDWI R1, R1, #1 32 bit add; R1=R1+1

SW 0(R2), R1 MEM[R2+0] = R1

ADDWI R2, R2, #4 32 bit add; R2=R2+4

SUBW R4, R3, R2 32 bit sub; R4=R3R2

BNE R4, Zero, Loop Goto Loop if R4==0

Assume that the initial value of R3 is R2 + 12. Throughout this exercise assume the simple 5 stage pipeline (IF, ID, EX, MEM, WB) discussed in class. For this problem assume that branches are resolved during the MEM stage of the pipeline.

a) Show the timing of this instruction sequence without any forwarding hardware. Use a timing chart like:

Cycle 1 2 3 4 5 ...
LW R1, 0(R2) IF ID EX MEM WB
ADDI, R1, R1, #1 IF ...
...

Assume that a branch is handled by stalling until the branch target is known. If all memory references are cache hits, how many cycles does this loop take to execute?

b) Show the timing of this instruction sequence with normal forwarding hardware. Assume that the branch is handled by predicting it as not taken. If the branch is taken then the pipeline is flushed and the branch target is fetched once the target is known. If all memory references hit in the cache, how many cycles does this loop take to execute?

c) Assume the pipeline uses a single-cycle delayed branch and forwarding. Schedule the instructions in the loop including the branch delay slot. You may reorder instructions and modify the individual instruction operands, but do not undertake other loop transformations that change the number or opcode of the instructions in the loop. Show the pipeline timing diagram and compute the number of cycles needed to execute the entire loop.

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions