hw2 Carch 2024 Sol
hw2 Carch 2024 Sol
COURSE NUMBER:
SOC2060
In MIPS, condition codes are set automatically when a general purpose register is written: T / F
The performance of a Multi-cycle MIPS is always better than a Single-cycle MIPS: T / F
In Multi-cycle MIPS, intermediate states are recorded in PC and memory : T / F
The behavior of the entire processor is specified fully by a finite state machine: T / F
In Multi-cycle MIPS, control signals for the next state are determined in current state: T / F
In Single-cycle MIPS, the most complex operation slows down everything: T / F
By adopting pipelining, more concurrency can be achieved: T / F
In Multi-cycle MIPS, most of the datapath is idle when a memory access is happening: T / F
The resource contention can be avoided by adopting pipelining: T / F
In Single-cycle MIPS, the memory contains both instructions and data: T / F
2
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
PCSrc1=Jump
Instruction [25– 0] Shift Jump address [31– 0]
left 2
26 28 0 1
4
Jump left 2 PCSrc2=Br Taken
Branch
MemRead
Instruction [31– 26]
Control MemtoReg
ALUOp
MemWrite
ALUSrc
RegWrite
Instruction [5– 0]
And ALUControl2:0 is doing the same job as F2:0 of following ALU Design.
(a)[10 points] A new R-type instruction “lw2” needs to be added to the instruction set. The semantics
of “lw2” is as follows:
lw2: Rd <- Memory[Rs + Rt]
PC <- PC + 4
3
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
And ALUControl2:0 is doing the same job as F2:0 in the following ALU Design.
4
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
(a)[10 points] List all the values of control signals at “write back” phase of LW (Load Word) instruction.
If a control signal doesn’t affect the “write back”, write X meaning “don’t care”.
Control Signal Value
IorD X
RegWrite 1
IRWrite 0
RegDst 0
MemtoReg 1
PCWrite 0
PCSrc1:0 XX
ALUControl2:0 XXX
ALUSrcB1:0 XX
ALUSrcA X
(b)[10 points] List all the values of control signals at “memory access” phase of LW (Load Word)
instruction. If a control signal doesn’t affect the “memory access”, write X meaning “don’t care”.
Control Signal Value
IorD 1
RegWrite 0
IRWrite 0
RegDst X
MemtoReg X
PCWrite 0
PCSrc1:0 XX
ALUControl2:0 XXX
ALUSrcB1:0 XX
ALUSrcA X
(c)[10 points] List all the values of control signals at “decode / register operand fetch” phase of
BRANCH instruction. If a control signal doesn’t affect the “decode and register operand fetch”, write X
meaning “don’t care”.
Control Signal Value
IorD X
RegWrite 0
IRWrite 0
RegDst X
MemtoReg X
PCWrite 0
PCSrc1:0 XX
ALUControl2:0 010
ALUSrcB1:0 11
ALUSrcA 0
5
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
(d)[10 points] List all the values of control signals at “execute / address generation” phase of BRANCH
instruction. If a control signal doesn’t affect the “execute and address generation”, write X meaning
“don’t care”.
Control Signal Value
IorD X
RegWrite 0
IRWrite 0
RegDst X
MemtoReg X
PCWrite 0
PCSrc1:0 01
ALUControl2:0 110
ALUSrcB1:0 00
ALUSrcA 1
(b)[5 points]
The address of the second byte to load is 16 and now the byte is loaded into a register. Specify how
many cycles are needed for the load and specify the starting address(es) of block(s) of L1 and L2 caches.
6
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
(c)[6 points]
The address of the third byte to load is 1025 and now the byte is loaded into a register. Specify how
many cycles are needed for the load and specify the starting address(es) of block(s) of L1 and L2 caches.
(d)[6 points]
The address of the fourth byte to load is 18 and now the byte is loaded into a register. Specify how many
cycles are needed for the load and specify the starting address(es) of block(s) of L1 and L2 caches.
(e)[6 points]
The address of the fifth byte to load is 15 and now the byte is loaded into a register. Specify how many
cycles are needed for the load and specify the starting address(es) of block(s) of L1 and L2 caches.
Processor A Processor B
Instruction CPI Frequecy Instruction CPI Frequecy
Class of Class of
Occurrece Occurrece
A 3 40% A 2 15%
B 2 25% B 2 15%
C 2 25% C 2 10%
D 8 10% D 3 10%
E 1 10%
F 2 20%
7
G 2 20%
STUDENT NAME:
STUDENT ID NUMBER: SECTION NUMBER IN THIS COURSE:
(a)[8points]. What is the CPI of each processor A and B? Show your work.
CPIA
CPIA = 0.4*3 + 0.25*2 + 0.25*2 + 0.1*8 = 3.0
CPIB
CPIB = 0.15*2 + 0.15*2 + 0.1*2 + 0.1*3 + 0.1*1 + 0.2*2 + 0.2*2 = 2.0
(b)[6points]. Which processor are you going to choose? Show your work in terms of total execution
time. On Processor A, the total number of instructions to perform your experiment is 1,000,000. If
the total time on processor A and B are the same, choose the one with more instructions for next
experiments.