Computer Science Homework Worksheet
Computer Science Homework Worksheet
Semester 1 2019/2020
Week of 16th September 2019
Tutorial 4: MIPS Encoding & Datapath
1. [Instruction Encoding] You accidentally spilled coffee on your best friend’s MIPS assembly
code printout. Fortunately, there are enough hints for you to reconstruct the code. Fill in the
missing lines (shaded cells) below to save your friendship.
Instruction
MIPS Code
Encoding
# $s1 is the result, $t0 stores a non-negative number
0x11000002
0x22310001
j loop
exit:
b. Give a simple mathematic expression for the relationship between $s1 and $t0 as
calculated in the code.
1 | P a g e
2. [Datapth ‐ AY1314S2 Term Test] Mr. De Blunder made a huge mistake while making his own
non‐pipelined MIPS processor. He accidentally swapped the two input ports for the RegDst
multiplexer:
Correct Wrong!
Unfortunately, the control unit still generate the signal using the original design! For each of
the following instructions, give:
i. One actual instance where the incorrect processor still gives the right execution
result.
ii. One actual instance where the incorrect processor gives the wrong execution result.
If there is no suitable answer, you can just indicate “No Answer”.
(a) add (Addition)
(b) lw (Load Word)
(c) beq (branch‐if‐equal), provide the branch offset as immediate value.
2 | P a g e
Questions 3 and 4 refer to the complete datapath and control design covered in lectures #10. For
your convenience, the complete diagram from Lecture #10 is also included at the end of this
tutorial.
3. Let us perform a complete trace to understand the working of the complete datapath and
control implementation. Given the following three hexadecimal representations of MIPS
instructions:
i. 0x8df80000: lw $24, 0($15)
[Wr = Write; Rd = Read; M = Mem; R = Reg]
b. Indicate the value of the PC after the instruction is executed.
3 | P a g e
4. With the complete datapath and control design, it is now possible to estimate the latency
(time needed for a task) for the various type of instructions. Given below are the resource
latencies of the various hardware components (ps = picoseconds = 10‐12 second):
Left‐shift/
Inst‐ Data‐ Control/
Adder MUX ALU Reg‐File Sign‐Extend/
Mem Mem ALUControl
AND
4 | P a g e
5 | P a g e