a b with register $s2.

advertisement

1. Convert the following MIPS assembly fragment into C code. Assume integer a is

associated with register $s0, integer b is associated with $s1, and integer result is associated

with register $s2. slt $t0, $s1, $s0 beq $t0, $zero, L1 sub $s0, $s0, $s1 j L3

L1: slt $t0 $s0, $s1 beq sub j

$t0, $zero, L2

$s1, $s1, $s0

L3

L2: add $s2, $zero, $s0

L3:

2.

a. What is the logic equation represented by the hardware logic above?

b. Fill in the truth table according to the logic equation you provided in part a.

A B C D

0

0

0

0

0

1

0

1

0

0

1

1

1

1

0

0

1

1

0

1

0

1 1 1

c. Express the logic equation in the canonical sum-of-products form and redraw the

hardware to directly implement the sum-of-products form of the equation.

d. What if we added another output E, describe by the following truth table. How can we

modify our hardware to perform E as well?

A B C E

0

0

0

0

0

1

0

1

0

1

0

1

0

1

1

1

1

0

0

1

1

0

1

0

0

0

0

0

1 1 1 1

3. a. Fill in the single-cycle datapath below so that it implements the store word

instruction. An example store word instruction is sw $s0, 4($s1). Furthermore, indicate the

bit size of each of the input and output lines being used in the datapath using the notation

we’ve seen in class. For the following control lines, indicate whether each one needs to be

set or unset for the store word instruction. Note that you may not need all of the state

elements depicted.

Control Line

RegWrite

MemWrite

MemRead

Set or Unset?

b. Assume we want to add a new instruction to our instruction set. This instruction is

called load add register, or lar. An example load add register instruction is lar $s0, $s1, $s2.

This instruction retrieves the contents of a memory address stored in $s1 and adds the

contents to the value stored in $s2. The results are stored in register $s0. In other words, this

instruction is equivalent to the following sequence of instructions: lw $t0, 0($s1) add $s0, $s2, $t0

Create a datapath for this instruction. Label each of the input and output lines with their

width in bits. In the table below, indicate which control lines need to be set for this

instruction to be executed. Note that you may not need all of the state elements depicted.

Control Line

RegWrite

MemWrite

MemRead

Set or Unset?

Download