Electrical, Computer, and Systems Engineering
ECSE-4730 Computer Systems Architecture
Fall 1998
Problem Set 3/4 [SOLUTIONS]-- Due Friday, October 23, 1998
|
Your Name |
|
|
Circle Your Section |
8-9:50 am 10-11:50 am noon-1:50pm |
Notes:
----------------------------------Do not write below this line-----------------------------------------
|
1 |
2 |
3 |
4 |
Total |
|
20* |
40 |
20 |
40 |
100 |
* problem 1 is for extra credit.
TA Signature :___________________________________
1. (Extra credit: 20 points) [Reading assignments]
Operations:
IR = Memory[PC];
# Components: IR, Memory, PC
# Control signals: IorD = 0, MemRead = 1,IRWrite = 1
PC = PC + 4;
# Components: PC, ALU
#
Control signals: ALUSrcB = 01, ALUOp = 00,PCWrite= 1, PCSource = 00A = Reg[IR[25-21]];
# Components: A, Reg file, IR
# Control Signals: none
B = Reg[IR[20-16]];
# Components: B, Reg file, IR
# Control Signals: none
ALUOut = PC +(sign-extend(IR[15-0]) <<2);
# Components: PC, Sign-extend, Shift Left 2, IR, ALU
# Control Signals: ALUSrcA = 0, ALUSrcB =11, ALUOp = 00
# Components: A, sign extend, IR, ALU
# Control Signals: ALUSrcA = 1, ALUSrcB =10, ALUOp = 00
MDR = Memory[ALUOut];
# Control Signals: MemRead = 1, IorD = 1
Reg[IR[20-16]]= MDR;
# Control Signals: RegDst = 0, RegWrite = 1, MemtoReg = 1
Solution:
lw $3, 0($5)
add $7, $7, $3 ## Forced load-use hazard => stall
sw $6, 0($5)
lw $4, 4($5)
add $8, $8, $4 ## Forced load-use hazard => stall
add $10, $7, $8 # resolved by forwarding
beq $10, $11, Loop # resolved by forwarding
Solution:
The instruction is:
sw $6, 16 ($5)
We need look only at the EX stage and MEM stage to figure out what instruction this is, and what its operands are.
We know that the instruction is either an R-type, lw, sw or a beq. In the EX stage, I observe that the ALUSrc control signal is 1. This rules out R-type instructions and 'beq' (because they use the contents of 'rs' and 'rt' in the ALU, not the sign-extended offset). Now we can eliminate 'lw' by examining the set of control signals for MEM (which in this case is 001). Looking ahead in the MEM stage, we observe that 001 stands for: Branch = 0, MemRead = 0, MemWrite = 1. Now a 'lw' does not write to memory and cannot have MemWrite = 1, so it must be a 'sw' instruction.
Now what's left is the operands…
You can deduce the operands $6, $5 by looking at the 'rs' and 'rt' lines before the ALU. You can deduce the offset 16 by looking at the result of the sign-extend. This gives our full answer.