CSE230-Quiz2-Ans

CSE230-Quiz2-Ans - bubbles as possible. ( Do NOT use any...

This preview shows pages 1–2. Sign up to view the full content.

Student Name:________________________________________ CSE230/EEE230 Quiz #2 Note: 1. The quiz is open book and open notes. No laptop usage allowed. 2 . There is only one problem, which is worth 75 points total. 3 . Your answers must be legible and organized. Given the following sequence of instructions to be executed using a pipelined implementation. Assume that the pipeline stalls due to any of the 3 classes of hazards (structural hazards, data hazards, and control/branch hazards). 1 lw \$s0, 0(\$s1) 2 add \$s3, \$s0, \$s2 3 sub \$s4, \$s5, \$s6 4 beq \$s3, \$s4, Label 5 sub \$s1 \$s3, \$s4 6 Label: add \$s5, \$s3, \$s6 1) Specify all the hazards that may occur in this piece of code. Solution: Cycles Instructions 1 2 3 4 5 6 7 8 9 1 IF ID EX Mem WB 2 IF ID EX Mem WB 3 IF ID EX Mem WB 4 IF ID EX Mem WB 5 or 6 IF ID EX Mem WB Between 1 and 2, 2 and 4, 3 and 4, 3 and 5: Data Hazard 4: Control Hazard Between 1 and 4: Structure Hazard 2) Show how to avoid those hazards by adding as few

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bubbles as possible. ( Do NOT use any other techniques such as forwarding .) After adding the necessary bubbles, how many clock cycles are required to complete the execution of this piece of code? Solution: (Shorthand: I=IF, D=ID, X=Ex, M=Mem,W=WB) 1 I D X M W 2 I D X M W 3 I D X M W Student Name:________________________________________ 4 I D X M W 5 or 6 I D X M W 6 * I D X M W Note: Instruction 2 cannot start 1 cycle earlier since it would result in a structural hazard (i.e., the M of instruction 1 would overlap with the I of instruction 2). 17 or 18 cycles depending on if the branch is taken. * If the previous instruction is 6 (the branch is taken), then this row is empty....
View Full Document

This note was uploaded on 05/11/2010 for the course CSE/EEE CSE/EEE230 taught by Professor Baoxinli during the Fall '08 term at ASU.

Page1 / 2

CSE230-Quiz2-Ans - bubbles as possible. ( Do NOT use any...

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

View Full Document
Ask a homework question - tutors are online