Edited
Edited
ARITHMETIC
INTRODUCTION
2. 1’s – complement
3. 2’s – complement
Example:
+5 = 0101
-5 = 1101
Example:
+3 = 0011
-3 = 1100
Example:
+3 = 0011
-3 = 1101
0 1 0 1
+ 0 + 0 + 1 + 1
0 1 1 10
Carry-out
Example:
X 7 0 1 1 1
+ Y + 6 + 0 0 1 1 1 1 0 0 0
Z 13 1 1 0 1
xi
Carry-out yi Carry-in
ci+1 si ci
xi yi ci si ci+1
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
si = xi yi ci + xi yi ci + xi yi ci + xi yi ci
ci+1 = yi ci + xi ci + xi yi
xi
yi
yi
ci
ci
xi
yi
ci xi
si ci+1
xi ci
yi
ci
xi
xi
yi yi
ci
xi yi
Adder
ci+1 ci
(A)
si
xn-1 yn-1 x1 y1 x0 y0
cn-1 c1
Adder Adder Adder
cn c0
(A) (A) (A)
sn-1 s1 s0
MS B Position LS B Position
A cascade of k n-adders:
si = xi yi ci + xi yi ci + xi yi ci + xi yi ci
ci+1 = xi yi + yi ci + xi ci
Let Gi = xi yi and Pi = xi + yi
ci+1 = Gi + Pi ci
ci+1 = Gi + Pi ci
PiPi-i…P1G0 + PiPi-1…P0c0
Example:
c1 = G0 + P0c0
c2 = G1 + P1G0 + P1P0c0
x7 y7 x6 y6 x5 y5 x4 y4 x3 y3 x2 y2 x1 y1 x0 y0
c8 c4 c0
4-bit Adder 4-bit Adder
s7 s6 s5 s4 s3 s2 s1 s0
Examples:
yn-1 y1 y0
. . . Add/S ub
Control
. . .
xn-1 x1 x0
. . .
c0
cn
n-bit adder
x0
. . .
sn-1 s1 s0
Multiplier Q
Add/Noadd
Control
n-bit
adder
Control
MPX
S equencer
0
0
mn-1 ... m0
Multiplicand M
1 1 0 1
Initial
0 0 0 0 0 1 0 1 1
C A Q
0 1 1 0 1 1 0 1 1 Add 1st
0 0 1 1 0 1 1 0 1 S hift Cycle
1 0 0 1 1 1 1 0 1 Add 2nd
0 1 0 0 1 1 1 1 0 S hift Cycle
0 1 0 0 1 1 1 1 0 No Add 3rd
0 0 1 0 0 1 1 1 1 S hift Cycle
1 0 0 0 1 1 1 1 1 Add 4th
0 1 0 0 0 1 1 1 1 S hift Cycle
Product
SIGNED-OPERAND MULTIPLICATION
Example:
1 0 0 1 1 (-13)
0 1 0 1 1 (+11)
1 1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 0 1 1
0 0 0 0 0 0 0 0
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 0 1 1 1 0 0 0 1 (-143)
Booth Algorithm
0100000 (32)
- 0000010 (2)
0011110 (30)
0 1 0 1 1 01
0 0 1 1 1 10
0 0 0 0 0 00
0 1 0 1 1 0 1
0 1 0 1 1 0 1
0 1 0 1 1 0 1
0 1 0 1 1 0 1
00 0 0 0 0 0
000 0 0 0 0
0001 0 1 0 1 000110
0101101
0+10 0 0 -10
0 0 0 0 0 0 0 0000000
1 1 1 1 1 1 1 010011
0 0 0 0 0 0 0 00000
0 0 0 0 0 0 0 0000
0 0 0 0 0 0 0 000
0 0 0 1 0 1 1 01
0 0 0 0 0 0 0 0
0 0 0 1 0 1 0 1000110
Multiplier Version of
multiplicand
Bit i Bit i – 1
selected by bit i
0 0 0xM
0 1 +1 x M
1 0 -1xM
1 1 0xM
Example:
0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0
0 +1-1 +1 0 -1 0 +1 0 0 -1 +1-1 +1 0 -1 0 0
01101 (+13)
x 11010 (-6)
01101
0-1+1-10
0 0 0 0 0 00000
1 1 1 1 1 0011
0 0 0 0 1 101
1 1 1 0 0 11
0 0 0 0 0 0
1 1 1 0 1 10010 (-78)
Examples:
Worst-case Multiplier:
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
+1-1 +1 -1+1 -1+1 -1+1-1 +1-1 +1 -1+1-1
Ordinary Multiplier:
1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0
0 -1 0 0+1 -1+1 0 -1+1 0 0 0 -1 0 0
Good Multiplier:
0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1
0 0 0 0+1 0 0 0 0 -1 0 0 0+1 0 -1
FAST MULTIPLICATION
Example:
0 0 -1 +1 -1 0
0 -1 -2
Examples:
0 1 1 0 1
+1 -1 +1
1 0 1 1 1
-1 +2 -1
Multiplication Examples:
01101 (+13)
x 11010 (- 6)
01101
0 -1 -2
1 1 1 1 100110
1 1 1 1 0011
0 0 0 0 00
1 1 1 0 110010 (- 78)
01010 (+10)
x 10111 (- 9)
01101
-1 +2 -1
1 1 1 1 110110
0 0 0 1 0100
1 1 0 1 10
1 1 1 0 100110 (- 90)
INTEGER DIVISION
21 10101
13 274 1101 100010010
26 1101
14 10000
13 1101
1 1110
1101
1
Register A
Shift Left
Dividend Q
Quotient
Setting
n+1-bit Add/Subtract
adder
Control
Sequencer
0 mn-1 ... m0
Divisor M
A restoring-division example:
10
11 1000
11
10
Initially 0 0 0 0 0 1 0 0 0
0 0 0 1 1
S hift 0 0 0 0 1 0 0 0 0
S ubtract 1 1 1 0 1 1st
Cycle
S et q0 1 1 1 1 0
Restore 1 1
0 0 0 0 1 0 0 0 0
S hift 0 0 0 1 0 0 0 0 0
S ubtract 1 1 1 0 1
2nd
S et q0 1 1 1 1 1 Cycle
Restore 1 1
0 0 0 1 0 0 0 0 0
S hift 0 0 1 0 0 0 0 0 0
S ubtract 1 1 1 0 1
3rd
S et q0 0 0 0 0 1 Cycle
0 0 0 1
S hift 0 0 0 1 0 0 0 1 0
S ubtract 1 1 1 0 1
4th
S et q0 1 1 1 1 1 Cycle
Restore 1 1
0 0 0 1 0 0 0 1 0
Remainder Quotient
A nonrestoring-division example:
Initially 0 0 0 0 0 1 0 0 0
0 0 0 1 1
S hift 0 0 0 0 1 0 0 0 0 1st
S ubtract 1 1 1 0 1 Cycle
S et q0 1 1 1 1 0 0 0 0 0
S hift 1 1 1 0 0 0 0 0 0
Add 0 0 0 1 1 2nd
Cycle
S et q0 1 1 1 1 1 0 0 0 0
S hift 1 1 1 1 0 0 0 0 0
Add 0 0 0 1 1 3rd
Cycle
S et q0 0 0 0 0 1 0 0 0 1
S hift 0 0 0 1 0 0 0 1 0
S ubtract 1 1 1 0 1 4th
Cycle
S et q0 1 1 1 1 1 0 0 1 0
Quotient
Add 1 1 1 1 1
0 0 0 1 1 Restore
Remainder
0 0 0 1 0
Remainder