Q1

a

IterationMultiplicand (M)Product (P)Action
00011 01010000 0000 1100 1010Initial state
10011 01010000 0000 1100 1010No operation
0000 0000 0110 0101Shift right
20011 01010011 0101 0110 0101Addition
0001 1010 1011 0010Shift right
30011 01010001 1010 1011 0010
No operation
0000 1101 0101 1001Shift right
40011 01010100 0010 0101 1001Addition
0010 0001 0010 1100Shift right
50011 01010010 0001 0010 1100No operation
0001 0000 1001 0110Shift right
60011 01010001 0000 1001 0110No operation
0000 1000 0100 1011Shift right
70011 01010011 1101 0100 1011Addition
0001 1110 1010 0101Shift right
80011 01010101 0011 1010 0101Addition
0010 1001 1101 0010Shift right

b

Overflow, because the higher 8 bits are not all 0

Q2

a

IterationDivisor (D)Remainder (R)Action
00001 10010000 0000 0110 1000Initial state
0000 0000 1101 0000Shift left
10001 10011110 0111 1101 0000Subtraction
0000 0000 1101 0000Undo
0000 0001 1010 0000Shift left, set LSb 0
20001 10011110 1000 1010 0000Subtraction
0000 0001 1010 0000
Undo
0000 0011 0100 0000Shift left, set Lsb 0
30001 10011110 1010 0100 0000Subtraction
0000 0011 0100 0000Undo
0000 0110 1000 0000Shift left, set Lsb 0
40001 10011110 1101 1000 0000Subtraction
0000 0110 1000 0000Undo
0000 1101 0000 0000Shift left, set Lsb 0
50001 10011111 0100 0000 0000Subtraction
0000 1101 0000 0000Undo
0001 1010 0000 0000
Shift left, set Lsb 0
60001 10010000 0001 0000 0000Subtraction
0000 0010 0000 0001Shift left, set Lsb 1
70001 10011110 1001 0000 0001Subtraction
0000 0010 0000 0001Undo
0000 0100 0000 0010Shift left, set Lsb 0
80001 10011110 1011 0000 0010Subtraction
0000 0100 0000 0010Undo
0000 1000 0000 0100Shift left, set Lsb 0
90001 10010000 0100 0000 0100Adjust remainder

The quotient is 0000 0100
The remainder is 0000 0100

b

Since dividend is negative and divisor is positive, quotient and remainder will be both negative

negate quotient: 0000 0101 1111 1010 1111 1011
negate remainder: 0000 1011 1111 0100 1111 0101

The quotient is 1111 1011
The remainder is 1111 0101

Q3

a

Little endian: 0x 04 00 A9 AE
Big endian: 0x AE A9 00 04
Binary: 1010 1110 1010 1001 0000 0000 0000 0100

b

101011 10101 01001 0000000000000100

opcode: 101011 0x2B sw (I type instruction)
rs: 10101 0x15 0d21 t1
immediate: 0000000000000100 0x04 0d4

sw $t1, 4($s5)

c

A: 10101
B: 01001
C: Undetermined
D: 0001 0000 0000 0001 0000 0000 0100 0000 (0x10010040)
E: 0000 0000 0000 0000 0001 0000 0000 0001 (0x00001001)
F: 0000 0000 0000 0000 0000 0000 0000 0100

d

D: 0b 0001 0000 0000 0001 0000 0000 0100 0000
F: 0b 0000 0000 0000 0000 0000 0000 0000 0100
+
G: 0b 0001 0000 0000 0001 0000 0000 0100 0100

G = D + F
G: 0001 0000 0000 0001 0000 0000 0100 0100 (0x10010044)

e

Address
Content
0x100100400x20
0x100100410x24
0x100100420x04
0x10010043
0x01
0x10010044
0x01
0x10010045
0x10
0x10010046
0x00
0x10010047
0x00

Q4

a

  • For the outputs of ALU
    • ALUresults[31] is asserted if subtraction result is negative
    • Zero is asserted if subtraction results in zero
  • If either one of the above output is asserted, the input is less than or equal to zero, this is checked by the added OR gate
  • If the above condition is true, we check if blez is asserted with the added AND gate, and it would output the result to the final OR gate
  • Depending on the result of the previous AND gate, the MUX will receive an asserted input if blez is asserted and the input is actually less than or equal zero, and the branching target will be obtained from the sum of the sign extended lower 16 bits multiplied by 4 and PC + 4, which will finally be updated/stored to PC

b

InstrRegDstALUSrcMem
toReg
Reg
Write
Mem
Read
Mem
Write
BranchblezALU control
blezx0x000010110