220 PracticeProblems 8 MultiCycleDP Sol
220 PracticeProblems 8 MultiCycleDP Sol
Spring 2015
Practice Problems #8 Solutions
Problem 1: Assuming the following timings for the components of the datapath. All other components have no
delay.
Data/Instruction Memory Read: 200ps
Adders: 80ps
Data Memory Write: 100ps
ALUs: 200ps
Register File Read: 100ps
Logical Shifter/Sign Extension: 30ps
Register File Write: 50ps
Multiplexors and other gates: 10ps
a. Calculate the delay for each clock cycle of the multicycle datapath finite state machine (each stage of each
instruction, i.e. each bubble). See attached pages
b. What is the minimum clock cycle period at which the multicycle datapath can operate properly? 270ps
What is the length of each instruction type in ps (Rtype, lw, sw, beq, j)?
lw 270*5 = 1350ps
sw/rtype 270*4 = 1080 ps
beq/j 270*3 = 810 ps
Problem 2: MIPS Execution
Examine the following MIPS program P.
add $t0, $s4, $s3
and $t2, $t0, $s1
add $t1, $t1, $t1
add $t2, $t2, $t2
lw
$t3, OPTION
beq $s0, $t3, PARSE_WRITE_SP_LE
and $t0, $t1, 0xff
and $t1, $t1, 0xff00
or
$t1, $t1, $t0
and $t0, $t2, 0xff
and $t2, $t2, 0xff00
or
$t2, $t2, $t0
PARSE_WRITE_SP_LE:
sw $t1, 0($a1)
lw $v0, WRITE_FILE
sw $t2, 0($a1)
a. In the multicycle datapath, in which clock cycle is the lw $t3, OPTION instruction fetched? 17th cycle
b. In the multicycle datapath, how many cycles does it take Program P to execute, assuming the branch is not
taken? 61 clock cycles
c. Which values (eg. MEM[$s0], branch address, Instruction[15:0], etc) are stored in the A, B, ALUOut, and MDR
registers during the execution cycle of the following instruction: sw $t1, 0($a1)
A: Reg[rs] = Reg[$a1]
B: Reg[rt] = Reg[$t1]
ALUOut: Reg[rs] + Instr[15:0] = Reg[$a1] + 0
MDR: Value read from memory (since Mem Rd = 0, it is the value last time read from the memory), which is the
sw instruction itself.
Problem 4: Show how the jump register instruction 'jr' can be implemented to the multicycle datapath by simply
making changes to the finite state machine. (Hint: $0 = $zero = 0)
rt field of the instruction should be register $0, which always holds the value 0.
Problem 5: Calculate the delay in the datapath after the addition of ALL instructions in Problem 3. Assume the
same delays. What is the minimum clock cycle period at which this design can operate properly?
The answer will depend on how you implemented each instruction
Problem 6: Consider changes to the original multicycle datapath that alters the register file so that it has only one
read port. Describe any changes that will need to be made to the datapath in order to support this modification.
Use the datapath diagram to illustrate the changes. Modify the finite state machine to indicate how the instructions
will work given your new datapath.
You will need to add control lines to Write registers A and B and a multiplexer (with a control line) to select
between the Rs and Rt fields of the instruction.
State 1 is modified with select Rs and WriteA asserted. A new state has to be added before states 6 and 8 to select
Rt and WriteB. After the new state control branches to either state 6 or state 8 based upon the opcode. Other
states are not affected as on RFormat and branch instruction use input from two registers. Additionally, State 2
must be modified to additionally read the Rt register and store the contents in B. While, lw does not require to read
Rt, the store word does. By making the modification to State 2, where the Register file is not being used, we do not
increase the number of clock cycles required for a sw instruction. Control signals to select Rt and WriteB must be
specified.
Problem 7: Consider eliminating the two shift left by 2 units in the multicycle datapath. Instead of these units, the
ALU will be used for shifting the values instead. What impact does this have on the original 5 instructions (lw, sw,
Rtype, beq, j)?
If the shift left by 2 is eliminated, then any time this happens will require that the ALU is used.
First, since the Decode stage adds the immediate value shifted left by 2 to calculate the branch address, now a stage
in between the Fetch and Decode stages would need to be added to do the shifting of the sign extended value. The
value would be in ALUOut and the input 3 of ALUSrcB would need to modified to be the valued from the ALUOut
register.
The second Shift left unit is used in stage 9 for the Jump instruction. If this was removed, the datapath would need
to go through the ALU and the PCSource mux could eliminate input 2, and use the value out of the ALU instead.
Problem 8: In the single cycle datapath control unit for the original 5 instructions (lw, sw, Rtype, beq, j), the
MemtoReg control signal can be eliminated and the MemRead or ALUSrc control signals can be used to control the
multiplexor instead. This reduces the number of control signals required (less logic gates to implement).
a. Which other signals in the single cycle datapath can be eliminated and replaced by another existing control
signal, or the inverse (NOT) of the signal.
RegDst and ALUOp1
RegDst & MemRead
Branch & AluOp0
b. Are there any signals in the multicycle datapath (basic 5 instructions only) which can be eliminated and
replaced?
Yes, MemtoReg is only used in Stage 4 &7. It can be replaced with RegDst (which is also only used in Stage
4 & 7)