Page 1
• Binary AdditionHalf/Full Adder Review
• Ripple Carry• Carry-select adder• Carry lookahead adder• Binary Number Representation
– Sign & Magnitude– Ones Complement– Twos Complement
• Multiplications– Shift-Accumulate – Array
Adders and Multipliers
Page 2
Binary Addition: Half Adder
Ai 0 0 1 1
Bi 0 1 0 1
Sum 0 1 1 0
Carry 0 0 0 1
AiBi
0 1
0
1
0 1
1 0
Sum = Ai Bi + Ai Bi
= Ai + Bi
AiBi
0 1
0
1
0 0
10
Carry = Ai Bi
Carry
Sum A i
B i
Page 3
Full-Adder
A 0 0 0 0 1 1 1 1
B 0 0 1 1 0 0 1 1
CI 0 1 0 1 0 1 0 1
S 0 1 1 0 1 0 0 1
CO 0 0 0 1 0 1 1 1
A BCI
0
1
00 01 11 10
0
1
1
0
1
0
0
1
A BCI
0
1
00 01 11 10
0
0
0
1
0
1
1
1
S
CO
S = CI xor A xor B
CO = B CI + A CI + A B = CI (A + B) + A B
0 0 1 1
+ 0 0 1 0
0 1 0 1
1
A
B
S
CinCo
Page 4
Ripple Carry Adder
+
A3 B3
S3
+
A2 B2
S2
+
A1 B1
S1
+
A0 B0
S0C1C2C3
For simplicity of analysis, let’s assume each logic gate takes 1 unit of time to process input signals and generate resulting outputs
Page 5
Delay in Ripple Carry AdderObserve the propagation of carry signal from LSB input to the MSB output
A
A
B
B
CI CO
@0@0
@0@0
@N
@1
@1
@N+1
@N+2
���������������
In each F/A unit,two gate delaysto compute CO
������ ��
�������� ��� �����
A 0
B 0
C 0
S 0 @2
A 1
B 1
C 1 @2
S 1 @3
A 2
B 2
C 2 @4
S 2 @5
A 3
B 3
C 3 @6
S 3 @7
C 4 @8
0
1
2
3
Page 6
Ripple Carry Timing��������� ���������������������������������� ���� ���������� ������
������������ �������� �����
� ����������������� �����������
� ���� ���������������� ��!
� ���� ���������������� ��!
� "��� ���������������� �#!
� $��� ����#����������� ��!
�� ����������� �������
%�������������������� �������"� ����������
T0 T2 T4 T6 T8
S0, C1 Valid S1, C2 Valid S2, C3 Valid S3, C4 Valid
Page 7
Adders (cont.)
Ripple Adder
Ripple adder is inherently slow because, in generals7 must wait for c7 which must wait for c6 …etc.
T α n, Cost α n
How can we make it faster?Directly generate carry from all inputs
CLA Carry Look-Ahead AdderTreat Carry signal like a binary situation
CSA Carry Select Adder
FA
c0a0b0
s0c1
c2c3c4c5c6c7
s7 s6
Page 8
Carry Select Adder
T = Tripple_adder / 2 + TMUX
COST = 1.5 * COSTripple_adder+ (n+1) * COSTMUX
0
1c8
FA
0a4a5a6a7b7 b6 b5 b4c0
a0b0
s0
a1a2a3b3 b2 b1
s1s2s3
FA
1a4a5a6a7b7 b6 b5 b4
1 0 1 01 0 1 0
s4s5s6s7
Page 9
Extended Carry Select Adder
• What is the optimal # of blocks and # of bits/block?– If # blocks too large delay dominated by total mux delay– If # blocks too small delay dominated by adder delay per block
10
1 0 1 0 1 0 1 0
4-bit Adder
4-bitAdder
10
1 0 1 0 1 0 1 0
4-bit Adder
4-bitAdder
10
1 0 1 0 1 0 1 0
4-bit Adder
4-bitAdder
4-bit Adder
a3-a0b3-b0
cincout
a11-a8b11-b8a15-a12b15-b12 b7-b4 a7-a4
Page 10
What really happens with the carries
FA
c0a0b0
s0c1
c2c3c4c5c6c7
s7 s6
A B Cout S
0 0 0 Cin
0 1 Cin ~Cin
1 0 Cin ~Cin
1 1 1 Cin
Carry action
kill
Propagate
propagate
generate
������& ���������� ��� ��� � � ������������������ ����'�(�)�(��
������*�������������� ��� � � ���������� �����+������������������
Ai
BiGi
Ai
BiPi
Page 11
Carry Look Ahead Logic
������& ��������& �(�'��)����������������� ������������������ ����'�(�)�(��
������*��������*��(�'��,�� )������������������ �����+������������������
� � (�'��,�� )��,�� ��(����� � �
� � � (�'��)����'������)����
(�'��)������ '����)�!
(�'��)������ '��,�� )�!
(��� �� � ��
� �� ��� �����������%�����,���� ������� �����������-���������
Gi
Ci
Pi
Ci
PiSi
Ci+1
Page 12
All Carries in Parallel
.��,��� �������������������������������%���
���(�& ����*����
���(�& ����*�����(�& ����*��& ����*��*����
�#�(�& ����*�����(�& ����*��& ����*��*��& ����*��*��*����
���(�& #���*#��#�(�& #���*#�& ����*#�*��& ����*#�*��*��& ����*#�*��*� *����
/������������������+�����������%���� ���� ���� �������� �0�������������� ��1
2����%������������ ����������� ������������������3
Page 13
CLA Implementation
' ���� ����*���������� �& ��������4 �����
�������������� ���,�����
Pi @ 1 gate delay
Ci Si @ 2 gate delays
BiAi
Gi @ 1 gate delay
C0C0
C0
C0P0P0
P0
P0
G0G0
G0
G0
C1
P1
P1
P1
P1
P1
P1 G1
G1
G1
C2P2
P2
P2
P2
P2
P2
G2
G2
C3
P3
P3
P3
P3
G3
C4
Page 14
How do we extend this to larger adders?
• Faster carry propagation– 4 bits at a time
• But still linear• Can we get to log?• Compute propagate and generate for each adder BLOCK
44
4
A3-0 B3-0
S3-0
44
4
A7-4 B7-4
S7-4
44
4
A11-8 B11-8
S11-8
44
4
A15-12 B15-12
S15-12
Page 15
Cascaded Carry Lookahead
��%���� ���� ����������������������1����
���� ����������������1���� ����5��,��� ����1���� ����"�%��
4 ���� �������������"��%��
4-bit Adder
4 4
4
A [15-12] B [15-12] C 12 C 16
S [15-12]
P G 4-bit Adder
4 4
4
A [1 1-8] B [1 1-8] C 8
S [1 1-8]
P G 4-bit Adder
4 4
4
A [7-4] B [7-4] C 4
S [7-4]
P G 4-bit Adder
4 4
4
A [3-0] B [3-0] C 0
S [3-0]
P G
Lookahead Carry Unit C 0
P 0 G 0 P 1 G 1 P 2 G 2 P 3 G 3 C 3 C 2 C 1
C 0
P 3-0 G 3-0 C 4
@3 @2
@0
@4
@4 @3 @2 @5
@7
@3 @2 @5
@8 @8
@3 @2
@5
@5 @3
@0
C 16
Page 16
Trade-offs in combinational logic design
6 � �� ���7�� ������ �� �0���
8 ���������������+������ ����������� ������ ��������
/,�� ��������������1���� �����
6 � �� ����� ���������������� ��� ���,�� ������� ��
6��'����� �����9����: ���
������������ ������������������ �������
�����0� ���;����;����� ������ ����������������
Page 17
So what about subtraction?
• Develop subtraction circuit using the same process
– Truth table for each bit slice– Borrow in from slice of lesser
significance– Borrow out to slice of greater
significance– Very much like carry chain
• Homework exercise
0000
0111
0011
1011
1111
1110
1101
1100
1010
1001
1000
0110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7+8
+9
+10
+11
+12
+13
+14
+15
-
Page 18
Finite representation?
• What happens whenA + B > 2N - 1 ?
– Overflow– Detect?
» Carry out
• What happens when A - B < 0 ?
– Negative numbers?– Borrow out?
0000
0111
0011
1011
1111
1110
1101
1100
1010
1001
1000
0110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7+8
+9
+10
+11
+12
+13
+14
+15
-
Page 19
Number Systems• Desirable properties:
– Efficient encoding (2n bit patterns. How many numbers?)– Positive and negative
» Closure (almost) under addition and subtraction• Except when overflow
» Representation of positive numbers same in most systems» Major differences are in how negative numbers are represented
– Efficient operations» Comparison: =, <, >» Addition, Subtraction» Detection of overflow
– Algebraic properties?» Closure under negation?» A == B iff A – B == 0
• Three Major schemes:– sign and magnitude– ones complement– twos complement– (excess notation)
Page 20
Sign and Magnitude
0000
0111
0011
1011
11111110
1101
1100
1010
1001
10000110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7-0-1
-2
-3
-4
-5
-6-7
0 100 = + 4 1 100 = - 4
+
-
< ����� ���%�����������(��������� ���=���!5���(��������
.�� ��������� ��� ���%���������� ����� ����� ���!������>� ���!
?�� %��������������%���(��-0 ��0� 0 �
.������������������@
4 �����������(5�A5�B5��5�0 @@@��
Example: N = 4
Page 21
Ones Complement (algebraically)
���������������� ��������������������������������� ���� ���
���� !� " �#�" �
$��� ���%������� ���� ����&�'
!���������((((
"��������((((�
����
"'���������(���
�(((
"'���������� �)
� ���� ����������%
��� ��*��� ���� ���������&���������
(����"+��(((
,
Page 22
Ones Complement on the number wheel
� �%����������� ���� ���� �%��� ������C ��D���� ���� ���
� ������������ ����� ���
��������� ����������7�����'�����%����������� 5�������0'
� ������� ��������������������3�
���'�(�)��������'�E )�((���@
' ����������� �� ����1� ���� �����5���1�������
0000
0111
0011
1011
11111110
1101
1100
1010
1001
10000110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7-7-6
-5
-4
-3
-2
-1-0
0 100 = + 4 1 011 = - 4
+
-
Page 23
Twos Complement number wheel
0000
0111
0011
1011
11111110
1101
1100
1010
1001
10000110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7-8-7
-6
-5
-4
-3
-2-1
0 100 = + 4 1 100 = - 4
+
-
/������ ����� ������� �@!
4 ���������������������������
' �������� ��%���������F������������� ����
� �� ������� ��������'�A�)���� '�E )�A��
4 ���� ��������������� %������������������� %��
0 ������� %���������� ������������
like 1's compexcept shiftedone positionclockwise
Page 24
Twos Complement (algebraically)
?G�(���� 0 ?
/,�� ������ � ����� ���� �������>
����(�������
>���(��������
������(�����7����0>
/,�� ������ � ����� ���� �������0>
�
����(�������
0>��(��������
������(�����7����>
�
�%
�%
)���� ������������
- . ���� ���� ���%���/�����. ������ ���� ������0��00���
�����0B����������0B������ �����������������0>!
�����0B����������0B������ �����������������>!
Page 25
How is addition performed in each number system?
• Operands may be positive or negative
Page 26
Sign Magnitude Addition
�
��#
>
����
����
����
0�
�� 0#!
0>
����
����
����
���������%���������� �������������� D��
�
0 #
�
����
����
����
0�
��#
0�
����
����
����
Operand have same sign: unsigned addition of magnitudes
Operands have different signs:
subtract smaller from larger and keep sign of the larger
Page 27
Ones complement addition
�
��#
>
����
����
����
0�
�� 0#!
0>
����
����
�����
�
����
�
0 #
�
����
����
�����
�
����
0�
��#
0�
����
����
����
/� ������ ������
/� ������ ������
Perform unsigned addition, then add in the end-around carry
Page 28
When carry occurs
0000
0111
0011
1011
11111110
1101
1100
1010
1001
10000110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7-7-6
-5
-4
-3
-2
-1-0
0 100 = + 4 1 011 = - 4
+
-
M – N where M > N
-M - N
Page 29
Why does end-around carry work?
$�0"���0���*�. /�����1����������������������!�� ��0��00�����
H �0 ?��(��H ���?��(��H ��� ����0 ��0 ?!��(�� H �0 ?!�������0 �� �
� ����H �B�?!
0H ��� 0?!��(��H ���?��(�� ����0 H �0 �!��� ����0 ?�0 �!
(�������I����0 ��0 H ���?!J�0 �
� �
� �H ���?�A��
�0�
�������� ������ �������
(������0 ��0 H ���?!�
���������������������� ����������������0 H ���?!�����D���� �3
���� !� " �#�" �Recall:
Page 30
Twos Complement Addition
�
��#
>
����
����
����
0�
�� 0#!
0>
����
����
�����
�
0 #
�
����
����
�����
0�
��#
0�
����
����
����
� �� ������ ���������� ��� �1���� ����� ���� ��������� ������ � ����������������������� %������� �� ������ ����������
Perform unsigned addition and
Discard the carry out.
Overflow?
Page 31
Twos Complement number wheel
0000
0111
0011
1011
11111110
1101
1100
1010
1001
10000110
0101
0100
0010
0001
+0+1
+2
+3
+4
+5
+6
+7-8-7
-6
-5
-4
-3
-2-1
0 100 = + 4 1 100 = - 4
+
-
-M + -N where N + M � 2n-1
-M + N when N > M
Page 32
2s Comp: ignore the carry out
0H ���?�� ����?�B�H �
H G�����?��(�� �����0 H !�����?��(���������� ?�0 H !� �
������������0������F�����1���%����������
0H ���0?�� �����?���H �K ��0�
0H ��� 0?!�(�H G���?G�(� ����0 H !��� ����0 ?!
(�����0 H ���?!������� �
'���������������������5�������F�������������� ����� ��7������������������0 H ���?!3
� �
Page 33
2s Complement Overflow
' ��� ������������� %���������������������� %��
����� ������������� %���������������������� %��
5 + 3 = -8! -7 - 2 = +7!
0000
0001
0010
0011
1000
0101
0110
0100
1001
1010
1011
1100
1101
0111
11101111
+0
+1
+2
+3
+4
+5
+6
+7-8
-7
-6
-5
-4
-3
-2
-1
0000
0001
0010
0011
1000
0101
0110
0100
1001
1010
1011
1100
1101
0111
11101111
+0
+1
+2
+3
+4
+5
+6
+7-8
-7
-6
-5
-4
-3
-2
-1
How can you tell an overflow occurred?
Page 34
2s comp. Overflow Detection
L
#
0$
��������������
�������
�������
0>
0�
>
��������������
�������
���������
L
�
>
��������������
�������
�������
0#
0L
0$
��������������
�������
���������
4 ������� 4 �������
?���������� ?����������
2 ��&�. ������. ������*�����������0�������1������*���
Page 35
2s Complement Adder/Subtractor
'�0 )�(�'��� 0)!�(�'���)����
A B
CO
S
+ CI
A B
CO
S
+ CI
A B
CO
S
+ CI
A B
CO
S
+ CI
0 1
Add/Subtract
A 3 B 3 B 3
0 1
A 2 B 2 B 2
0 1
A 1 B 1 B 1
0 1
A 0 B 0 B 0
Sel Sel Sel Sel
S 3 S 2 S 1 S 0
Overflow
Page 36
c0
a0b0s0
a1b1s1
c1
a2b2s2
a3b3s3
c3
c2
c0
c0
a4b4s4
a5b5s5
c5
a6b6s6
a7b7s7
c7
c6
c0
c4
c0
c8
p,g
P,G
P,G
cin
cout
P,GPa,Ga
Pb,Gb
P = PaPbG = Gb + GaPb
Cout = G + cinP
aibisi
p,g
ci
ci+1
p = a ⊕ bg = ab
s = p ⊕ ci
ci+1 = g + cip
8-bit Carry Look-ahead Adder
Page 37
MULTIPLICATION
• Unsigned multiplication
– Array
– Add(shift) accumulate
Page 38
Basic concept of multiplication
� ����������
� ���������
������� �#!
������� ��!
����
����
����
����
G
�������� ��#!
*���������� ���
• product of 2 n-bit numbers is an 2n-bit number– sum of n n-bit partial products
• unsigned
Page 39
Combinational Multiplier:accumulation of partial products
'�
)�
'��)�
'�
)�
'��)�
'��)�
'�
)�
'��)�
'��)�
'��)�
'#
)#
'��)�
'��)�
'��)�
'��)#
'#�)�
'��)�
'��)#
'#�)�
'��)#'#�)#
� " � L � � � # � � � � � �� >
Page 40
Array Multiplier
b3 0 b2 0 b1 0 b0 0
P7 P6 P5 P4
a0
0
a1
0
a2
0
a3
0
P0
P1
P2
P3
FA
bj sum in
sum out
carryout
ai
carryin
Each row: n-bit adder with AND gates
What is the critical path?
Generates all n partial products simultaneously.
Page 41
“Shift and Add” Multiplier• Sums each partial
product, one at a time.
• In binary, each partial product is shifted versions of A or 0.
Control Algorithm:1. P ←←←← 0, A ←←←← multiplicand,
B ←←←← multiplier2. If LSB of B==1 then add A to P
else add 03. Shift [P][B] right 14. Repeat steps 2 and 3 n-1 times.5. [P][B] has product.
Bn-bit shift registers
P
An-bit register
+01
0 n-bit adder
• Cost αααα n, ΤΤΤΤ = n clock cycles.• What is the critical path for
determining the min clock period?
Page 42
Carry-save Addition• Speeding up multiplication is
a matter of speeding up the summing of the partial products.
• “Carry-save” addition can help.
• Carry-save addition passes (saves) the carries to the output, rather than propagating them.
• Example: sum three numbers,310 = 0011, 210 = 0010, 310 = 0011
310 0011+ 210 0010
c 0100 = 410
s 0001 = 110
310 0011c 0010 = 210
s 0110 = 610
1000 = 810
carry-save add
carry-save add
carry-propagate add
• In general, carry-save addition takes in 3 numbers and produces 2.• Whereas, carry-propagate takes 2 and produces 1.• With this technique, we can avoid carry propagation until final addition
Page 43
Carry-save Circuits
• When adding sets of numbers, carry-save can be used on all but the final sum.
• Standard adder (carry propagate) is used for final sum.
FA FA FA FA FA FA FA FA 0
CSA
s cs cs cs cs cs cs cs cc
CSA
CPA
CSA
CSA
x0
x1
x2
Page 44
Array Mult. using Carry-save Additionb3 0 b2 0 b1 0 b0 0
P7 P6 P5 P4
a0
0
a1
a2
a3
P0
P1
P2
P3
1
0
0
0
0
0
0
0
000
FA
bj sum in
sum out
carryout
ai
carryin
Fast carry-propagate adder
Page 45
Another Representation (from book)
A3 B0
SC
A2 B0
SC
A1 B0
SC
A0 B0
SC
A3 B1
SC
A2 B1
SC
A1 B1
SC
A0 B1
SC
A3 B2
SC
A2 B2
SC
A1 B2
SC
A0 B2
SC
A3 B3
SC
A2 B3
S
A1 B3
S
A0 B3
S
B0
B1
B2
B3
P7 P6 P5 P4 P3 P2 P1 P0
A3 A2 A1 A0
)��� ���%���1�������� �������
��,������������%��� ���%���1
F A
X
Y
A B
S CI CO
Cin Sum In
Sum Out Cout
Add
CPA
Page 46
Carry-save Addition
CSA is associative and communitive. For example:(((X0 + X1) + X2 ) + X3 ) = ((X0 + X1) +( X2 + X3 ))
• A balanced tree can be used to reduce the logic delay.
• This structure is the basis of the Wallace Tree Multiplier.
• Partial products are summed with the CSA tree. Fast CPA (ex: CLA) is used for final sum.
• Multiplier delay α log3/2N + log2NCSA
CPA
CSA
CSA
x0x1x2
CSA
CSACSA
x3x4x5x6x7
log3/2N
log2N
Page 47
“Shift and Add” Signed Multiplier
Bn-bit shift registers
P
An-bit register
+01
0 n-bit adder
• Signed extend partial product at each stage
• Final step is a subtract
Page 48
Summary
• 2 complement number systems– Algebraic and corresponding bit manipulations– Overflow detection– Signficance of “sign bit” -2n-1
• Carry look ahead is form a parallel prefix• Time / Space tradeoffs
– Bit serial adder
• Binary Multiplication algorithm– Array multiplier– Serial multiply (with bit parallel adder)
• Signed multiplication– Sign extend multipicand– Sign bit of multiplier treated as subtract