hw3_sol - EE108B Winter 2003-2004 Handout #34 Homework #3...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
EE108B Winter 2003-2004 Handout #34 Homework #3 (Total 140 points) Due Tues Feb 17, 5 PM in Gates 408 1. (4 points) one point for each correct bullet. List two advantages and two disadvantages of fixed size instructions. Answer: Advantages: Next PC calculation is simple for non-branch instructions No instruction alignment issues for branch instructions Decode logic is simple, as the start and end of an instruction is known Easy to pipeline Disadvantages: Larger code size, as some bits are wasted for the instructions that could have been encoded in fewer bits (as a consequence, use of the instruction cache is not as efficient) Limit the number of instructions in the ISA Limit the size of the memory addressable by one instruction 2. (Total 9 points) Identify all of the data dependencies in the following code (accompanied by a diagram). Which dependencies are data hazards that will be resolved via forwarding? add $2, $5, $4 add $4, $2, $5 sw $5, 100($2) add $3, $2, $4 Answer: There are three dependencies in the code (1 point) . The second instruction is dependent on $2 in the first instruction (1 point) . The third instruction is also dependent on $2 from the first instruction (1 point) . And finally, the fourth instruction is dependent on both the $2 of the first instruction (1 point) and the $4 of the second instruction (1 point) . Below is a graphical representation showing the dependencies of each of the instructions in the pipeline: 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE108B Winter 2003-2004 Handout #34 (1 point) The read-after-write (RAW) hazard of the fourth instruction accessing $2 is solved by performing the WB step to the register file during the first half of the cycle and reading from it during the second half (1 point) . All of the other RAW hazards can be solved using forwarding (1 point) . A diagram illustrating the forwarding and register file access is shown below: (1 point) 2
Background image of page 2
EE108B Winter 2003-2004 Handout #34 3. (5 points) Consider executing the following code on the pipelined datapath of Figure 6.46 on page 492: add $5, $6, $7 lw $6, 100($7) sub $7, $6, $8 How many cycles will it take to execute this code? Draw a diagram like that of Figure 6.44 on page 489 that illustrates the dependencies that need to be resolved, and provide another diagram like that of Figure 6.45 on page 491 that illustrates how the code will actually be executed (incorporating any stalls or forwarding) so as to resolve the identified problems. Answer: There is one dependency in the code. The third instruction is dependent on $6 which is written by the load instruction. Below is a graphical representation showing the dependencies of each of the instructions in the pipeline: Unfortunately the value from the lw instruction is not available to be forwarded until after the MEM stage. Therefore, a single bubble must be added to the pipeline. A diagram illustrating the bubble and the forward is shown below: 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE108B Winter 2003-2004 Handout #34 Therefore with a single stall, the code will take a total of eight cycles to execute. 4.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

hw3_sol - EE108B Winter 2003-2004 Handout #34 Homework #3...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online