LCDF3 Chap 05
LCDF3 Chap 05
Chapter 5 – Arithmetic
Functions and Circuits
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
Chapter 5 3
Block Diagram of a 1D Iterative Array
A n-1B 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
Cn-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
Chapter 5 4
Functional Blocks: Addition
Chapter 5 6
Logic Simplification: Half-Adder
X 12 3 X 2 13
S XY XY X Y
S ( X Y )( X Y )
and
C XY
C ( ( XY ) )
These equations lead to several implementations.
Chapter 5 7
Five Implementations: Half-Adder
SX Y C
C XY
A NAND only implementation is:
C
X
S ( X Y )C
C ( ( XY ) ) S
Y
Chapter 5 9
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
Chapter 5 11
Equations: Full-Adder
From the K-Map, we get:
SX YZ X Y Z X YZ X YZ
C X Y X Z Y Z
The S function is the three-bit XOR function (Odd
Function):
SX Y Z
The Carry bit C is 1 if both X and Y are 1 (the sum is
2), or if the sum is 1 and a carry-in (Z) occurs. Thus C
can be re-written as:
C X Y (X Y) Z
The term X·Y is carry generate.
The term XY is carry propagate.
Chapter 5 12
Implementation: Full Adder
Full Adder Schematic Ai Bi
Here X, Y, and Z, and C
Gi
(from the previous pages)
are A, B, Ci and Co,
respectively. Also,
Pi
G = generate and Ci
P = propagate.
Note: This is really a combination
of a 3-bit odd function (for S)) and
Carry logic (for Co): Ci+1 Si
(G = Generate) OR (P =Propagate AND Ci = Carry In)
Co G + P · Ci
Chapter 5 13
Binary Adders
Chapter 5 14
4-bit Ripple-Carry Binary Adder
C3 C2 C1
FA FA FA C0
C4 S3 S2 S1 S0
Chapter 5 15
Carry Propagation & Delay
One problem with the addition of binary numbers is the
length of time to propagate the ripple carry from the least
significant bit to the most significant bit.
The gate-level propagation path for a 4-bit ripple carry
adder of the last example:
A3 A2 A1 A0
B3 B2 B1 B0
C3 C2 C1 C0
C4
S3
Note: The "long S2 S S
path" is from A0 or B01though the 0circuit to
S3.
Chapter 5 16
Carry Lookahead
Chapter 5 18
Carry Lookahead Development
Chapter 5 20
Carry Lookahead Example
Specifications:
3 3
• 16-bit CLA CLA CLA CLA CLA
• Delays: 2 2
CLA
NOT = 1 2
XOR = Isolated AND = 3
AND-OR = 2
Longest Delays:
• Ripple carry adder* = 3 + 15 2 + 3 = 36
• CLA = 3 + 3 2 + 3 = 12
*See slide 16
Chapter 5 21
Unsigned Subtraction
Algorithm:
• Subtract the subtrahend N from the minuend M
• If no end borrow occurs, then M N, and the result
is a non-negative number and correct.
• If an end borrow occurs, the N > M and the
difference M N + 2n is subtracted from 2n, and a
minus sign is appended to the result.
Examples: 0 1
1001 0100
0111 0111
0010 1101
10000
1101
() 0011 Chapter 5 22
Unsigned Subtraction (continued)
Introduce complements
as an approach Subtract/Add
S
0
Quadruple
1
2-to-1
multiplexer
Result
Chapter 5 23
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
Chapter 5 24
Binary 1's Complement
Chapter 5 25
Binary 2's Complement
Chapter 5 27
Subtraction with 2’s Complement
For n-digit, unsigned numbers M and N, find M
N in base 2:
• Add the 2's complement of the subtrahend N to
the minuend M:
M + (2n N) = M N + 2n
• If M N, the sum produces end carry rn which is
discarded; from above, M N remains.
• If M < N, the sum does not produce an end carry
and, from above, is equal to 2n ( N M ), the 2's
complement of ( N M ).
• To obtain the result (N – M) , take the 2's
complement of the sum and place a to its left.
Chapter 5 28
Unsigned 2’s Complement Subtraction Example 1
1
01010100 01010100
2’s comp
– 01000011 + 10111101
00010001
The carry of 1 indicates that no
correction of the result is required.
Chapter 5 29
Unsigned 2’s Complement Subtraction Example 2
Chapter 5 30
Subtraction with Diminished Radix Complement
Chapter 5 31
Unsigned 1’s Complement Subtraction - Example 1
Chapter 5 32
Unsigned 1’s Complement Subtraction Example 2
01000011 0 01000011
– 01010100 1’s comp
+ 10101011
1’s comp
11101110
00010001
The carry of 0 indicates that a correction
of the result is required.
Result = – (00010001)
Chapter 5 33
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 2 1 = 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.
Chapter 5 34
Signed Integer Representations
Chapter 5 35
Signed Integer Representation Example
r =2, n=3
Chapter 5 36
Signed-Magnitude Arithmetic
If the parity of the three signs is 0:
1. Add the magnitudes.
2. Check for overflow (a carry out of the MSB)
3. The sign of the result is the same as the sign of the
first operand.
If the parity of the three signs is 1:
1. Subtract the second magnitude from the first.
2. If a borrow occurs:
• take the two’s complement of result
• and make the result sign the complement of the
sign of the first operand.
3. Overflow will never occur.
Chapter 5 37
Sign-Magnitude Arithmetic Examples
Example 1: 0010
+ 0101
Example 2: 0010
+ 1101
Example 3: 1010
0101
Chapter 5 38
Signed-Complement Arithmetic
Addition:
1. Add the numbers including the sign bits,
discarding a carry out of the sign bits (2's
Complement), or using an end-around carry (1's
Complement).
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.
Chapter 5 39
Signed 2’s Complement Examples
Example 1: 1101
+ 0011
Example 2: 1101
0011
Chapter 5 40
Signed 1’s Complement Examples
Example 1: 1101
+ 0011
Example 2: 1101
0011
Chapter 5 41
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 3B A 3B A 2 B A 2 B A1 1 0 0
of B is formed by using
XORs to form the 1’s S
unchanged
C4 S3 S2 S1 S0
Chapter 5 42
Overflow Detection
0 0 1 1
Detection can be performed by examining the result
signs which should match the signs of the top operand
Chapter 5 43
Overflow Detection
Signed number cases with carries Cn and Cnshown for correct
result signs:
0 00 01 11 1
0 0 1 1
+ 0 1 0 + 1
0 0 1 1
Signed number cases with carries shown for erroneous result signs
(indicating overflow):
0 10 11 01 0
0 0 1 1
+ 0 1 0 + 1
1 1 0 0
Simplest way to implement overflow V = Cn + Cn
This works correctly only if 1’s complement and the addition of the
carry in of 1 is used to implement the complementation! Otherwise
fails for 10 ... 0
Chapter 5 44
Binary Multiplication
Chapter 5 45
Review - Decimal Example: (237 × 149)10
Chapter 5 48
Multiplier Boolean Equations
Chapter 5 49
Multiplier Arrays Using Adders
An implementation of the 2 × 2
A
multiplier array is
0
B1 B0
shown:
A1
B1 B0
HA HA
C3 C2 C1 C0
Chapter 5 50
Multiplier Using Wide Adders
Chapter 5 51
Cellular Multiplier Array
elements as shown:
pp [ j , k ]
Each element computes a
AB
single bit product equalCarry [ j , k ]Co
FA S
Ci
Carry [ j, (k - 1)]
to ai·bj, and implements
a single bit full adder Column Sum to below
Chapter 5 52
Other Arithmetic Functions
Convenient to design the functional
blocks by contraction - removal of
redundancy from circuit to which input
fixing has been applied
Functions
• Incrementing
• Decrementing
• Multiplication by Constant
• Division by Constant
• Zero Fill and Extension
Chapter 5 53
Design by Contraction
Contraction is a technique for simplifying
the logic in a functional block to
implement a different function
• The new function must be realizable from the
original function by applying rudimentary
functions to its inputs
• Contraction is treated here only for
application of 0s and 1s (not for X and X)
• After application of 0s and 1s, equations or
the logic diagram are simplified by using rules
given on pages 224 - 225 of the text.
Chapter 5 54
Design by Contraction Example
Contraction of a ripple carry adder to incrementer for n = 3
• Set B = 001
A2 A1 A0
X 0 0 1
0 4 1
X 5
2
C3 5 X C1 3
C0 5 0
S2 S1
A2 A1 A0
S2 S1 S0
(b)
• The middle cell can be repeated to make an incrementer with n > 3.
Chapter 5 55
Incrementing & Decrementing
Incrementing
• Adding a fixed value to an arithmetic variable
• Fixed value is often 1, called counting (up)
• Examples: A + 1, B + 4
• Functional block is called incrementer
Decrementing
• Subtracting a fixed value from an arithmetic variable
• Fixed value is often 1, called counting (down)
• Examples: A 1, B 4
• Functional block is called decrementer
Chapter 5 56
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 C21 C22
preserved (b)
Chapter 5 57
Multiplication by a Constant
Carry
4-bit Adder
output Sum
C6 C5 C4 C3 C2 C1 C0
Chapter 5 58
Zero Fill
Chapter 5 59
Extension
Chapter 5 60
Terms of Use
© 2004 by Pearson Education,Inc. All rights reserved.
The following terms of use apply in addition to the standard Pearson
Education Legal Notice.
Permission is given to incorporate these materials into classroom
presentations and handouts only to instructors adopting Logic and
Computer Design Fundamentals as the course text.
Permission is granted to the instructors adopting the book to post these
materials on a protected website or protected ftp site in original or
modified form. All other website or ftp postings, including those
offering the materials for a fee, are prohibited.
You may not remove or in any way alter this Terms of Use notice or
any trademark, copyright, or other proprietary notice, including the
copyright watermark on each slide.
Return to Title Page
Chapter 5 61