Question: 1) How many clock periods does the following code segment take given a) single cycle b) multicycle c) a 5 stage pipeline assuming one clock

1) How many clock periods does the following code segment take given

a) single cycle 
b) multicycle 
c) a 5 stage pipeline assuming one clock period per instruction, but no data forwarding 
d) a 5 stage pipeline with data forwarding as described in P&H, Chapter 4, section 7. for the following code: 
or $t1,$0,$a2 
or $t3,$0,$a0 
or $t4,$0,$a1 
lw $t5,0($t7) 
lw $t6,0($t8) 
mul $t2,$t5,$t6 
addi $t1,-1 
add $t3,$a3,$t3 
add $t4,$a3,$t4 

2) Find the data hazards in the following code segment, and show the hazards on a

pipeline diagram, as in P&H, Fig. 4.52:

 lw $t1,0($t1) 
 addi $t1,$t1,100 
 or $t2,$t3,$t1 
 add $a0,$a1,$t2 
 ori $a0,$a0,42 
 add $t5,$a0,$t2 

3)Find the control hazards in the following code segment, and show the hazards on a pipeline diagram:

 la $t0, ar2 
 lw $t1, size 
 lw $t2, nrows 
 lw $t3, ncols 
 addi $t4, $t2, -1 # nrmax 
 addi $t5, $t3, -1 # ncmax 
 ori $t6, $0, 0 # initialize row index to 0 
 lwc1 $f0, val 
 mfc1 $s4, $0 
rloop: mul $t9, $t6, $t3 # multiply rindex by ncols 
 mul $t9, $t9, $t1 # multiply by size of one array element to get roffset 
 ori $t7, $0, 0 # initialize column index to 0 
cloop: mul $s0, $t7, $t1 # multiply cindex by size to get coffset 
 add $s1, $s0, $t9 # offset of ar2[rindex][cindex] = roffset + coffset 
 add $t8, $s1, $t0 # address of ar2[rindex][cindex] = offset + base 
 sw $s4, 0($t8) # store val in ar2[rindex][cindex] 
 addi $t7, $t7, 1 # increment the column index 
 sub $s2, $t5, $t7 # nc = ncmax - cindex 
 bgez $s2, cloop # branch back to cloop if nc >= 0 
 addi $t6, $t6, 1 # increment the row index 
 sub $s3, $t4, $t6 # nr = nrmax - rindex 
 bgez $s3, rloop # branch back to rloop if nr >= 0 
 ori $v0, $0, 10 # reach here if row loop is done 
 syscall # end of program! 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!