CS152 Homework 2                                                          v1.2      updated 10/6/2003

 

Homework 2 is due Monday, 10/6, no later than 5:00pm in the HW boxes in 283 Soda. Please include the TIME and TA NAME of the DISCUSSION section that you attend as well as your NAME, STUDENT ID and LOGIN. Homeworks and labs will be handed back in discussion sections.

 

Homework Policy:

 

This homework is long. Please get started early. Questions or comments about the homework should be directed to Kurt (cs152-td@cory.eecs.berkeley.edu)

 

 

Homework #2:

 

Unless otherwise noted, all questions refer to the Beta version of COD. Dave will release Chapter 6 as soon as possible – until then, get started on the questions from Chapters 4 and 5.

 

Part I:

Update: You can find some online versions of the diagrams from the book for problems 5.17 and 5.20 here and here that are cleaner.

Part II:

 

Question 1:

 

The following code contains a "read after write" data hazard that is resolved by forwarding:

 

            add            $2 $3 $3

            add            $5 $2 $6

 

Consider the similar situation in which a memory read occurs after a memory write:

 

            sw             $7 100($2)

            lw            $8 100($2)

 

Write a paragraph describing how this situation differs from the one involving registers, and describe how the potential "read after write" problem is resolved.

 

Question 2:

 

Consider an instruction sequence used for a memory-to-memory copy:

 

            lw            $2, 100($5)

            sw             $2, 200($6)

 

The second Elaboration on page 484 of the text discusses this situation and states that additional forwarding hardware can improve its performance. Show the necessary additions to the datapath of Figure 6.31 to allow code like this to run without stalling. Include forwarding equations (like those on pages 479-482) for all of the control signals for any new of modified multiplexors in your datapath. Finally, rewrite the stall formula on page 488 so that this code sequence won't stall.

 

Part III: Updates

End of homework #2