Sheet 8
Sheet 8
Consider extending the MIPS architecture with the instruction below, which adds three registers
together and stores the result in a register.
This will use the same format as R-type instructions where the shamt field is used to hold ru.
The multicycle datapath from lecture appears below. Show what changes are needed to support add3.
You should only add wires and muxes to the datapath.
Draw the finite state machine diagram for the add3 instruction. Make sure to include any control
signals that you added. Your diagram should also support R-type, lw, sw, and beq instructions.
Show how can the add3 instruction be used in place of two dependent add instruction. What is the
percentage increase/decrease in the performance due to the use of add3 instead of 2 add instructions?
Add any necessary datapaths and control signals to the multicycle datapath. . Find a solution that
minimizes the number of clock cycles required for the new instruction without modifying the register
file.
Draw the finite state machine diagram for the swap instruction. Make sure to include any control
signals that you added. Your diagram should also support R-type, lw, sw, and beq instructions.
Cycle 3 : Cycle 4:
A→ rt B → rs
Regwrite=1 RegWrite = 1
MemtoReg=2 MemtoReg = 3
RegDst=0 RegDst = 2
1. Using the multicycle datapath from the lecture implement a register-memory addition
instruction addm as follows.
addm rd, rs, rt # rd = rs + Mem[rt]
In other words, register rt contains a memory address which is read to produce the ALU's operand.
The instruction should use the same format as R-type instructions. On the figure show the changes
needed to support addm.
Draw the finite state machine diagram for the addm instruction. Make sure to include any control
signals that you added. Your diagram should also support R-type, lw, sw, and beq instructions.
Sub → cycle 3 (execution)
For the following code segment, complete the Table 2 indicating the values for the control signals at
the following cycles when executed on a multi-cycle processor?
addi $s0, $zero, 800 4 s0 = 800
sub $s1, $zero, $zero 4 s1 = 0
L1: lw $t0, 0($a0) 5 t0 = content of add a0
add $s1, $s1, $t0 4 s1 = s1 + t0
add $a0, $a0, 4 4 a0 = a0 +4
addi $s0, $s0,-1 4 s0 = s0 -1
bnẹ $s0, $zero, L1 3 if s0 != 0 go to L1
add $s1, $s1, $s1 4
Mem Mem ALUSrc ALUSrc
PCWrite IorD IRWrite RegDst MemToReg RegWrite ALUOp PCSrc
Read Write A B
7th cycle
sub 0 X 0 0 0 X X 0 1 0 sub X
execution
26th cycle
Instr. 1 0 1 0 1 X X 0 0 1 add 0
fetch
33'rd
cycle
0 X 0 0 0 0 1 1 X X X X
Lw write
back
Assume that the operating time for major functional units is as follows:
Memory Units: 200 ps, ALU and Adders: 180 ps, Register File (R or W): 100 ps
Complete the table to compare between the single cycle and a muti-cycle implementations of the
above code in terms of number of clock cycles and total execution time
Instr. Reg file read Execution Data memory Reg file write time
Memory 100 (ALU) 180 200 100
200
R-type ✔ ✔ ✔ -------------------- ✔ 580
Sw ✔ ✔ ✔ ✔ ------------------- 680
Lw ✔ ✔ ✔ ✔ ✔ 780
Beq ✔ ✔ ✔ ------------------- ------------------- 480
Jump ✔ ------------------ -------------------- -------------------- ------------------- 200
For the following code segment, complete the table below indicating the values for the control signals
at the specified cycles when executed on a multi-cycle processor?
14'th
cycle
1 0 1 0 1 X X 0 0 1 add 0
Instr.
fetch
36’th
cycle
0 X 0 0 0 X X 0 0 2 add X
Lw
execution