Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5. The following instruction is to be executed: sw $t1, 4($t2). The instruction

ID: 3812154 • Letter: 5

Question

5. The following instruction is to be executed: sw $t1, 4($t2). The instruction is located at 0x00401000. Assume that $t1 holds a -1 and $t2 holds 0x10010010 Give the values of the following:

i. output of sign-extend

ii. output of shift left 2

iii. inputs to ALU control

iv. output from MUX before registers

v. output from MUX before ALU

vi. output from ALU vii. output from adder at top left

viii. output from adder at top right

Basically sw is used to store the word in particular memory location. 4($t2) means the offset to $t2 is 4. So you just have to add the address with 4 and then find the rest of values. In order to answer please list the address after each input from above

*this was commented as an improper question. Why? I need more detail.

Explanation / Answer

The instruction sw $t1, 4($t2) will store the value of the register $t1 at the address $t2 + 4(offset). The content of the $t1 is -1 and $t2 is 0x10010010. The target address can be computed as follows:

Target address = 0x10010010 + 00000100

                        = 0x10010110

The value of register $t1 will be stored at the address 0x10010110.

i.

The output of the sign-extension can be shown as follows:

The number of bits after the sign extension will be 8 + 8 = 16 bits.

Append the zeroes to store the 16 bit hexadecimal number, if the number of required bits are less than total number of bits.

Now, the required number will be of 16 bits which is shown as follows:

0x0000000010010110

ii.

The shift left 2 operation will multiply a number by 4. If a number is shifted to left by 2, then it means it will be multiplied by 2. The output of the shift left 2 can be shown as follows:

Multiply the number 0x10010110 by the number 4 (0x00000100):

0x10010110 * 0x00000100 = 0x1001011000

Hence, the output of shift left 2 is 0x1001011000.

iii.

The inputs to the ALU control can be shown as follows:

The input to ALU control are the values in the given instruction which can be shown as follows:

$t1, 4($t2), sw

Where, sw is a characteristic function which will perform store operation on the values of $t1 and $t2.

Hence, the inputs to the ALU control are $t1,$t2, sw.

iv.

The output generated from MUX before the registers are as follows:

·       The input data given to the register file.

·       The select signal to choose the output of the memory registers.

·       The output generated from the ALU.

v.

The output from MUX before ALU can be shown as follows:

MEMREAD

ALUMUX

MEMWRITE

ALUOP

REGMUX

t1, 4(t2)

1

0

t1 at t2 + 4

1

sw

1

0

0

0

The output from MUX before ALU will be ALUMUX.

vi.

The output from ALU will be REGMUX.

vii.

The output from adder at top left are shown as follows:

·       The adder at the top left is used to increment the value of program counter (PC).

·       PC will be added by 4 and gives the result as PC + 4.

·       The output of the adder will be PC + 4.

·       The PC has address of the instruction i.e., 0x00401000. When 4 is added to this address value, then the result will be 0x00401004.

·       The output of the adder at top left will be 0x00401004.

viii.

The output from adder at top right will be as follows:

·       This adder is placed at top right corner in the single cycle datapath diagram.

·       The input of this adder is the output of first adder i.e., PC + 4 and the left shifted output i.e., 0x1001011000.

·       Add the value of PC + 4 i.e., 0x00401004 with the value of left shifted value i.e., 0x1001011000 to get the output of the adder.

0x00401004 + 0x1001011000 = 0x1001412004

·       The output of the adder at the top right will be 0x1001412004.

MEMREAD

ALUMUX

MEMWRITE

ALUOP

REGMUX

t1, 4(t2)

1

0

t1 at t2 + 4

1

sw

1

0

0

0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote