CCEE 213 - 2006 - 2007 - II - Final
CCEE 213 - 2006 - 2007 - II - Final
Faculty of Engineering
Electrical And Computer engineering Department
CCEE 213 Computer Architecture
Final
ID _________________________
Duration: 120 minutes.
Instructions:
9 Check to insure that you have a
complete copy of the examination.
There are 4 Questions, and a total
of 10 pages. There should be no
blank pages in your set.
Question 1
30 9 This examination is open book and
open notes.
Question 2 9 Questions are NOT allowed
30 during the exam.
Question 3 9 No use of scratch paper is
30 allowed. You should work your
Questions directly on the Question
Question 4 statement sheet in the appropriate
30 space only. You may use the
backside of the exam sheets as
Total Grade appropriate.
120
9 It is recommended that you read
the whole exam before attempting
any one Question.
9 Include all steps and calculations
as appropriate for maximum
credit. Be clear, brief, and
specific in your answers.
Good Luck!
Question 1: (30 points)
Given the following MIPS assembly program, write, next to each line, what kind of
hazard (structural, data, control) do you expect if the code was run on the 5 stage
pipeline of the book. Also indicate what solution would you use for each hazard and
whether you will need stall cycles and how many.
Number of
Instruction Hazard Solution
Stall cycles
add $t0,$a0,$0
add $t1,$0,$0
L1: lb $t2,0($t0)
beq $t2,$0,L2
addi $t1,$t1,1
addi $t0, $t0, 1
j L1
L2: beq $t1,$0,END0
add $t0,$a1,$0
add $t3,$0,$0
L3: lb $t2,0($t0)
beq $t2,$0,L4
addi $t3,$t3,1
addi $t0, $t0, 1
j L3
L4: beq $t3,$0,END0
slt $t0,$t3,$t1
bne $t0,$0,END0
sub $t0,$t3,$t1
add $v0,$a1,$t0
L5: addi $t0,$v0,$0
addi $t1,$a0,$0
L6: lb $t2,0($t0)
lb $t3,0($t1)
beq $t3, $0, END
bne $t2,$t3,L7
addi $t0,$t0,1
addi $t1,$t1,1
j L6
L7: addi $v0,$v0,-1
slt $t0,$v0,$a1
j L5
END0: add $v0,$0,$0
END: jr $ra
Question 2: (30 points)
A. The following MIPS instruction sequence can be used to implement
a MIPS pseudo instruction. Give the instruction a name and
describe what it does. The register $11 is the input register and $10
is the output register.
addu $10,$0,$11
bge $11,$0, next
sub $10,$0,$11
next: . . .
op
Memory
word or byte operand
Read Addr 1
Read
Register
Read Addr 2 Data 1
File
Write Addr
Read
Data 2
Write Data
C. Show how the bit string for +2010 would be stored in memory if
represented in a format similar to the MIPS floating point format
except with only 3 bits of exponent (and a bias of 3) and only 4 bits
of fraction.
1. Normalize F3
2. Insert a 1 as the most significant bit of F1 and F2
3. Add F2 to F1 to form F3
4. Strip off the most significant bit of F3
5. Round F3
6. Align F2 with F1
D. Give the setting for the control signals to execute the modified
instruction. Use an X to indicate a don’t care signal and a – to
indicate a control signal that has been eliminated. For ALUOp, just
indicate the arithmetic operation that needs to be performed (e.g.,
add, and, …). Use the blank space to give the setting for any control
signals that you had to add to the datapath.
Spring 2006-2007
Write Addr Read
1 0
Instr[15-11] Write Data Data 2 Write Data 0
1
3-May-2007
Instr[15-0] Sign ALU
16 Extend 32 control
Instr[5-0]
6
E. What is the CPI of the unmodified machine?
I1 I2 ID EX M WB
I1 I2 ID EX M WB
I1 I2 ID EX M WB
I1 I2 ID EX M WB
I1 I2 ID EX M WB
I1 I2 ID EX M WB
C. How can hazards like the ones above be handled (give all options)?
D. How many delay slots (stall cycles) are incurred in this six stage
pipeline if the branch decision hardware is implemented as in the
five stage MIPS pipeline shown on the next page?
0 ID/EX
EX/MEM
IF/ID Control
Add MEM/WB
Branch
4 Shift Add
PC
Address File
Write Addr ALU Address 1
Read Data
1
Data 2 Write Data 0
Write Data
0
Spring 2006-2007
ALU
16 Sign 32 cntrl
Extend
3-May-2007
1
Forward
Unit
9
E. What is the minimum number of delay slots that could be achieved
by moving the branch decision hardware as early in the pipeline as
possible?
lw $2, 400($3)
sw $2, 800($4)
H. Consider the loop code shown below running on the five stage
MIPS pipeline discussed in class.
loop: lw $2,50($3)
addi $1,$1,1
addi $3,$3,4
add $4,$2,$4
bne $1,$5,loop