Number Arithmetic p2
Number Arithmetic p2
Elementary School
Arithmetic
COMP375 Computer Architecture and dO Organization i ti
17 +7 24
You add two numbers together. If the sum is greater than the number base, you add one to the next column. When you add two numbers, you may also have to add the carry from the column to the right.
1 Bit Adder
A one bit adder has three inputs, numbers A and B and Carry in. There are two outputs, t t the th Sum S and d Carry C out. t
A B
Cout
Cin
Sum
COMP375
Arithmetic Circuits
Addition Sum
~A ~B ~Cin Cin 0 1 ~A B 1 0 A B 0 1 A ~B 1 0 ~Cin Cin
Cout = AB + BC + AC
Cout
Sum
Sum
Sum
COMP375
Arithmetic Circuits
Subtraction
Instead of building a separate subtraction circuit, you can add the negative of the operand. To make a twos complement number negative, you must invert the bits and add one A NOT gate can be used to invert all the bits. Setting the Carry In on the rightmost bit will add one to the result. A+~B+1 = A + (~B+1) = A + (-B) = A - B
Propagation Delay
To make a 32 bit adder, you can use 32 one bit adders. dd The left most bit cannot be computed until all of the other bits are computed so that the Carry In value will be known. Each one bit adder requires the signal to go through two gates. Each gate takes a small amount of time to react. This limits the speed of the adder.
Carry Equations
We can express the carry as: Ci+1 = Gi + (Pi * Ci) Ci+2 = Gi+1 + (Pi+1 * Gi) + (Pi+1 * Pi * Ci) Ci+4 = Gi+3 +(Pi+3 * Gi+2) + (Pi+3 * Pi+2 * Gi+1) + (Pi+3 * Pi+2 * Pi+1 * Gi) + (Pi+3 * Pi+2 * Pi+1 * Pi * Ci)
COMP375
Arithmetic Circuits
Reduced Propagation
The simple n bit ripple adder took O(2n) ti time to t add dd n bits bit d due t to carry propagation. ti With carry look ahead, it takes O(3) time to propagate the carry. The look ahead requires more circuitry.
Further Simplification
Creating a big adder out of groups of adders can reduce propagation and circuitry
As Bs As Bs As Bs
Cout
Sums
Sums
Sums
Multiplication Tables
Decimal
1 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 2 2 4 6 8 10 12 14 16 18 20 3 3 6 9 12 15 18 21 24 27 30 4 4 8 12 16 20 24 28 32 36 40 5 5 10 15 20 25 30 35 40 45 50 6 6 12 18 24 30 36 42 48 54 60 7 7 14 21 28 35 42 49 56 63 70 8 8 16 24 32 40 48 56 64 72 80 9 9 18 27 36 45 54 63 72 81 90 10 10 20 30 40 50 60 70 80 90 100 0 1
Multiplication
543 *312 312 1086 543 1629 169416
decimal
Binary
0 0 0 1 0 1
COMP375
Arithmetic Circuits
00000
B0 is 1 so Add
A
00101
+
01010
+
00101
B P
00101
00101
00101
COMP375
Arithmetic Circuits
B1 is zero so do nothing
A
01010 00101
B
10100 00101
B
00101
00101
B2 is 1 so Add
A
10100
+
01000 00101
B
00101
B P
11001
11001
COMP375
Arithmetic Circuits
B3 is zero so do nothing
A
01000 00101
B
10000 00101
B
11001
11001
B4 is zero so do nothing
A
Done
A
10000 00101
B
10000 00101
B
11001
11001
COMP375
Arithmetic Circuits
Combinatorial Multiplier
Division
Division is difficult. (Every elementary school h l child hild k knows th that.) t) Some small computers do not have multiplication or division. Some have multiplication but not division.
COMP375