Professional Documents
Culture Documents
Arithmetic-Logic Units: CPSC 321 Computer Architecture Andreas Klappenecker
Arithmetic-Logic Units: CPSC 321 Computer Architecture Andreas Klappenecker
OR gate
NOT gate
Logic Gates
NOR gate
NAND gate
XOR gate
Half Adder
a s
b
a b c s c
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
Full Adder
cin a b cout s
0 0 0 0 0
0 0 1 0 1
s=cin xor a xor b 0 1 0 0 1
0 1 1 1 0
cout=ab+cin(a xor b) 1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Full Adder
cin
s
a
b
cout
Subtraction a
0
AND 1
Result
OR
b 0 2
CarryOut
What is missing?
Tailoring the ALU to the MIPS
Calculate b-a a
0
If MSB equals
1, then a<b 1
Result
0, then a>=b
b 0 2
Changes? 1
Operation less than
Output of subtraction CarryOut
Overflow
a. CarryOut
SLT
Binvert Operation
CarryIn
4 ops
subtraction a
0
output available
Connect 1
output b 0 2
1
w/ LSB less
Less 3
Set
Overflow
Overflow
detection
b.
Binvert CarryIn Operation
whether a<b
b0 ALU0 Result0
Less
CarryOut
0 if false a1 CarryIn
b1 ALU1 Result1
0 Less
1 if true CarryOut
a2 CarryIn
b2 ALU2 Result2
0 Less
CarryOut
CarryIn
001 = or
a2 CarryIn Result2
010 = add b2
0
ALU2
Less
110 = subtract CarryOut
111 = slt