Professional Documents
Culture Documents
Chapter 4 – Arithmetic
Functions
Arithmetic functions
• Operate on binary vectors
• Use the same subfunction in each bit position
Can design functional block for subfunction
and repeat to obtain functional block for overall
function
Cell - subfunction block
Iterative array - a array of interconnected cells
An iterative array can be in a single dimension
(1D) or multiple dimensions
Block Diagram of a 1D Iterative Array
A n-1 B n-1 A1 B0
X n-1 X2 X1
Xn X0
Cell n-1 Y n-1 Y2 Cell 1 Y1 Cell 0
Yn Y0
C n-1 C1 C0
Example: n = 32
• Number of inputs = ?
• Truth table rows = ?
• Equations with up to ? input variables
• Equations with huge number of terms
• Design impractical!
Iterative array takes advantage of the regularity to make
design feasible
Functional Blocks: Addition
X 12 3 X 2 13
S XY XY X Y
S ( X Y) ( X Y)
and
C XY
C ( ( X Y ) )
These equations lead to several implementations.
Five Implementations: Half-Adder
(a) S X Y X Y (d ) S ( X Y ) C
C XY C ( X Y)
( b) S ( X Y ) ( X Y ) (e ) S X Y
C XY C XY
( c ) S ( C X Y)
(a),C and
(b), XY(e) are SOP, POS, and XOR implementations
for S.
In (c), the C function is used as a term in the AND-NOR
implementation of S, and in (d), the function is used in a
POS term for S. C
Implementations: Half-Adder
The most common half
adder implementation is: X S (e)
Y
S XY C
C XY
A NAND only implementation is:
C
X
S (X Y) C
C ( ( X Y ) ) S
Y
Functional Block: Full-Adder
S Y C Y
0
11 3
12 0 1
13 2
X 14 17 X 15 17 16
5 6 4
Z Z
Equations: Full-Adder
C3 C2 C1
FA FA FA C0
C4 S3 S2 S1 S0
Signed Integers
Positive numbers and zero can be represented by unsigned
n-digit, radix r numbers. We need a representation for
negative numbers.
To represent a sign (+ or –) we need exactly one more bit of
information (1 binary digit gives 21 = 2 elements which is
exactly what is needed).
Since computers use binary numbers, by convention, the
most significant bit is interpreted as a sign bit:
s an–2 a2a1a0
where:
s = 0 for Positive numbers
s = 1 for Negative numbers
and ai = 0 or 1 represent the magnitude in some form.
Complements
Two complements:
• Diminished Radix Complement of N
(r 1)’s complement for radix r
1’s complement for radix 2
Defined as (rn
• Radix Complement
r’s complement for radix r
2’s complement in binary
Defined as rn N
Subtraction is done by adding the complement of
the subtrahend
If the result is negative, takes its 2’s complement
Signed-2’s Complement Arithmetic
Addition:
1. Add the numbers including the sign bits,
discarding a carry out of the sign bits.
2. If the sign bits were the same for both
numbers and the sign of the result is different, an
overflow has occurred.
3. The sign of the result is computed in step 1.
Subtraction:
Form the complement of the number you are
subtracting and follow the rules for addition.
Signed 2’s Complement Examples
Example 1: 1101
+ 0011
Example 2: 1101
0011
2’s Complement Adder/Subtractor
Subtraction can be done by addition of the 2's Complement.
1. Complement each bit (1's Complement.)
2. Add 1 to the result.
The circuit shown computes A + B and A – B:
For S = 1, subtract,
the 2’s complement B
3 A B3 A 2 B A B
2 1 1 0 A0
of B is formed by using
XORs to form the 1’s S
unchanged
C4 S3 S2 S1 S0
Overflow Detection
ai
Pi
bi Si
Gi
Ci+1
Ci
4FA 8XOR
Faster Adders
The carry propagation technique is a limiting factor in
the speed with which two numbers are added.
Two alternatives
• use faster gates with reduced delays
• Increase the circuit complexity (i.e. put more
gates) in such a way that the carry delay time is
reduced.
An example for the latter type of solution is carry
lookahead adders
Carry Lookahead Adders
Sum and carry can be expressed in terms of Pi and Gi:
• Si = Pi Ci
• Ci+1 = Gi + PiCi
Why the names (carry propagate and generate)?
• If Gi = 1 (both ai = bi = 1), then a “new” carry is
generated
• If Pi = 1 (either ai = 1 or bi = 1), then a carry
coming from the previous lower bit position is
propagated to the next higher bit position
4-bit Carry Lookahead Adder
We can use the carry propagate and carry generate signals to compute
carry bits used in addition operation
• C0 = input
• C1 = G0 + P0C0
• C2 = G1 + P1C1
= G1 + P1(G0 + P0C0) = G1 + P1G0 + P1P0C0
• C3 = G2 + P2C2 = G2 + P2(G1 + P1G0 + P1P0C0)
= G2 + P2G1 + P2P1G0 + P2P1P0C0
• P0 = a0 b0 and G0 = a0b0
• P1 = a1 b1 and G1 = a1b1
• P2 = a2 b2 and G2 = a2b2
• P3 = a3 b3 and G3 = a3b3
4-bit Carry Lookahead Circuit 1/3
C1 = G0 + P0C0
C2 = G1 + P1G0 + P1P0C0
C3 = G2 + P2G1 + P2P1G0 + P2P1P0C0
C3
P2
G2
P1 C2
G1
P0 C1
G0
C0
4-bit Carry Lookahead Circuit 2/3
G3
P3
a2 S3
C3
b2 P2
G2 P2
Carry C2
S2
a1
P1 Lookahead
b1
P1
G2 circuit S1
C1
a0
b0 P0
G0 P0
S0
C0
C0 C0
Hybrid Approach for 16-bit Adder
c16 c12 c8 c4
4-bit CLA 4-bit CLA 4-bit CLA 4-bit CLA
… … … …
s15 s12 s11 s8 s7 s4 s3 s0
Binary Multipliers
Two-bit multiplier y1 y0 Y
× x1 x0 X
x0 y1 x0 y0
+ x1 y1 x1 y0
z3 z2 z1 z0 Z
y1 y0
x0
y1 y0
x1
HA HA
z3 z2 z1 z0
(3x4)-bit Multiplier: Method
y3 y2 y1 y0 Y
× x2 x1 x0 X
x0 y3 x0 y2 x0 y1 x0 y0
x1 y3 x1 y2 x1 y1 x1 y0
+ x2 y3 x2 y2 x2 y1 x2 y0
z6 z5 z4 z3 z2 z1 z0
4-bit Multiplier: Circuit
x0 y3 y2 y1 y0
y3 y2 y1 y0
x1
0
Sout
4-bit Adder
y3 y2 y1 y0
x2
Cout
Cout
z6 z5 z4 z3 z2 z1 z0
mxn-bit Multipliers
Generalization:
multiplier: m-bit integer
multiplicand: n-bit integer
mn AND gates
(m-1) adders
• each adder is n-bit
Multiplication/Division by 2n
(a) Multiplication B3 B2 B1 B0
by 100 0 0
• Shift left by 2 C5 C4 C3 C2 C1 C0
(a)
(b) Division
by 100 B3 B2 B1 B0
• Shift right by 2
0 0
• Remainder C3 C2 C1 C0 C-1 C-2
preserved (b)
Magnitude Comparator
x = (A>B) = a3b3+t3a2b2+t3t2a1b1+t3t2t1a0b0
z = (A<B) = a3b3+t3a2b2+t3t2a1b1+t3t2t1a0b0
y = (A=B) = t3t2t1t0
4-bit Magnitude Comparator:
Circuit