henry hexmoor1 chapter 5 arithmetic functions arithmetic functions –operate on binary vectors...
Post on 19-Dec-2015
221 views
TRANSCRIPT
![Page 1: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/1.jpg)
Henry Hexmoor 1
Chapter 5Arithmetic 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
![Page 2: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/2.jpg)
Henry Hexmoor 2
Adders
![Page 3: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/3.jpg)
Henry Hexmoor 3
Cell n-1Xn-1
Y n-1
A n-1Bn-1
Cn-1
Xn
Y nCell 1
X1
Y 1
A 1
C1
Cell 0X0
Y 0
B0
C0
X2
Y 2
Block Diagram of a 1D Iterative Array
• 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
Figure 5-1
![Page 4: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/4.jpg)
Henry Hexmoor 4
Half-Adder 5-2
• A 2-input, 1-bit width binary adder that performs the following computations:
• A half adder adds two bits to produce a two-bit sum• The sum is expressed as a
sum bit , S and a carry bit, C• The half adder can be specified
as a truth table for S and C
X 0 0 1 1
+ Y + 0 + 1 + 0 + 1
C S 0 0 0 1 0 1 1 0
X Y C S
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
![Page 5: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/5.jpg)
Henry Hexmoor 5
Half Adder5-2
XX
YY
SS
CC
YXCYXS
Figure 5-2
![Page 6: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/6.jpg)
Henry Hexmoor 6
Full-Adder
• A full adder is similar to a half adder, but includes a carry-in bit from lower stages. Like the half-adder, it computes a sum bit, S and a carry bit, C.
– For a carry-in (Z) of 0, it is the same as the half-adder:
– For a carry- in(Z) of 1:
Z 0 0 0 0
X 0 0 1 1
+ Y + 0 + 1 + 0 + 1
C S 0 0 0 1 0 1 1 0
Z 1 1 1 1
X 0 0 1 1
+ Y + 0 + 1 + 0 + 1
C S 0 1 1 0 1 0 1 1
![Page 7: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/7.jpg)
Henry Hexmoor 7
Full Adder Table
A B Cin
nS C
0 0 0 0 00 0 1 1 00 1 0 1 00 1 1 0 11 0 0 1 01 0 1 0 11 1 0 0 11 1 1 1 1
![Page 8: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/8.jpg)
Henry Hexmoor 8
Logic Optimization: Full-Adder
• Full-Adder Truth Table:
• Full-Adder K-Maps:
X Y Z C S0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 01 1 0 1 01 1 1 1 1
X
Y
Z
0 1 3 2
4 5 7 61
1
1
1
S
X
Y
Z
0 1 3 2
4 5 7 61 11
1
C
![Page 9: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/9.jpg)
Henry Hexmoor 9
Equations: Full-Adder
• From the K-Map, we get:
• The S function is the three-bit XOR function:
• 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:
• The term X·Y is carry generate.
• The term XY is carry propagate.
ZYZXYXCZYXZYXZYXZYXS
ZYXS
Z)YX(YXC
![Page 10: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/10.jpg)
Henry Hexmoor 10
Full Adder
![Page 11: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/11.jpg)
Henry Hexmoor 11
4 bit Full Adder
![Page 12: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/12.jpg)
Henry Hexmoor 12
4-bit Ripple-Carry Binary Adder• A four-bit Ripple Carry Adder made from four 1-bit Full Adders.• A carry 1 may propagate through many FAs to the most
significant bit just as a wave ripples outward…
B3 A 3
FA
B2 A 2
FA
B1
S3C4
C0
C3 C2 C1
S2 S1 S0
A 1
FA
B0 A
Figure 5-5
![Page 13: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/13.jpg)
Henry Hexmoor 13
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:
• Note: The "long path" is from A0 or B0 though the circuit to S3.
A3B3
S3
B2
S2
B1
S1 S0
B0
A2 A1 A0
C4
C3 C2 C1 C0
![Page 14: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/14.jpg)
Henry Hexmoor 14
Carry Lookahead
• Given Stage i from a Full Adder, we know that there will be a carry generated when Ai = Bi = "1", whether or not there is a carry-in.
• Alternately, there will be a carry propagated if the “half-sum” is "1" and acarry-in, Ci occurs.
• These two signal conditions are called generate, denoted as Gi, and propagate, denoted as Pi respectively and are identified in the circuit:
AiBi
Ci
Ci+1
Gi
Pi
Si
![Page 15: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/15.jpg)
Henry Hexmoor 15
Carry Lookahead (continued)
• In the ripple carry adder:– Gi, Pi, and Si are local to each cell of the adder– Ci is also local each cell
• In the carry lookahead adder, in order to reduce the length of the carry chain, Ci is changed to a more global function spanning multiple cells
• Defining the equations for the Full Adder in term of the Pi and Gi:
iiiiii BAGBAP
iii1iiii CPGCCPS
![Page 16: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/16.jpg)
Henry Hexmoor 16
Group Carry Lookahead Logic
• Figure 5-6 in the text shows shows the implementation of these equations for four bits. This could be extended to more than four bits; in practice, due to limited gate fan-in, such extension is not feasible.
• Instead, the concept is extended another level by considering group generate (G0-3) and group propagate (P0-3) functions:
• Using these two equations:
• It is possible to have four 4-bit adders use one of the same carry lookahead circuit to speed up 16-bit addition
012330
0012312323330
PPPPP
GPPPPGPPGPGG
030304 CPGC
![Page 17: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/17.jpg)
Henry Hexmoor 17
Subtraction table
bin x y bout D
0 0 0 0 0
0 0 1 1 1
0 1 0 0 1
0 1 1 0 0
1 0 0 1 1
1 0 1 1 0
1 1 0 0 0
1 1 1 1 1
![Page 18: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/18.jpg)
Henry Hexmoor 18
Half subtractor
HalfSubtractor
X
Y
D
B-OUT
X
Y
Difference D
B-out
![Page 19: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/19.jpg)
Henry Hexmoor 19
Full Subtraction circuit for A - BD = (A B) BIBO = A’(B + BI )+ A B BI
![Page 20: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/20.jpg)
Henry Hexmoor 20
Binary Subtraction5-3
A
Subtraction of two n-digit numbers, M – N
1. Subtract the subtrahend N from the minuend M.2. if no end borrow occurs, then M>= N,and the result is nonnegative and correct.3. If an end borrow occurs, then N > M, and the difference, M – N + 2n, is subtracted from 2n, and a minus sign is appended to the result.
See Example 5-1 and Figure 5-7 0 1 1001 0100 0111 0111 0010 1101 10000 1101 () 0011
![Page 21: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/21.jpg)
Henry Hexmoor 21
A B
Binary adder Binary subtractor
Selective2's complementer
Quadruple 2-to-1multiplexer
Result
Borrow
Complement
S0 1Subtract/Add
Figure 5-7
Adder-subtractor
![Page 22: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/22.jpg)
Henry Hexmoor 22
Complements5-3
1’s complement of a binary n digit number N is obtained by changing all 1’s to 0 and all 0’s to 1.2’s complement of a binary n digit number N is obtained by adding 1 to its 1’s complement. e.g., 1’s complement:1011001 01001100001111 1110000
2’s complement:10110 010011 + 1 = 010100
![Page 23: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/23.jpg)
Henry Hexmoor 23
Alternate 2’s Complement Method
• Given: an n-bit binary number, beginning at the least significant bit and proceeding upward:– Copy all least significant 0’s– Copy the first 1– Complement all bits thereafter.
• 2’s Complement Example:10010100
– Copy underlined bits: 100
– and complement bits to the left:
01101100
![Page 24: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/24.jpg)
Henry Hexmoor 24
Subtraction with complements
5-3
OR GateA
1. Add the 2’s complement of the subtrahend N to the minuend M.2. If M>= N, the sum produces an end carry, 2n. Discard the end carry, leaving result M – N.1. If M < N, the sum does not produce an end carrysince it is equal to 2n – (N – M), the 2’s complement of N –M. Perform a correction, taking the 2’s complement of the sum and placing a minus sign in front to obtain the result – (N – M).
![Page 25: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/25.jpg)
Henry Hexmoor 25
Unsigned 2’s Complement Subtraction Example 1
• Find 010101002 – 010000112
01010100 01010100
– 01000011 + 10111101
00010001• The carry of 1 indicates that no correction of the
result is required.
1
2’s comp
![Page 26: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/26.jpg)
Henry Hexmoor 26
Binary Adder-Subtractors5-4
OR GateA
Figure 5-8
FA FA FA FA
S
B3
C3
S2 S1 S0S3C4
C2 C1 C0
A 3 B2 A 2 B1 A 1 B0 A 0
S = 0, adderS = 1, subtractor
![Page 27: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/27.jpg)
Henry Hexmoor 27
Overflow Detection
• Overflow occurs if n + 1 bits are required to contain the result from an n-bit addition or subtraction
• Overflow can occur for:– Addition of two operands with the same sign– Subtraction of operands with different signs
• Detection can be performed by examining the result signs which should match the signs of the top operand
![Page 28: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/28.jpg)
Henry Hexmoor 28
Two bit Multiplication
a b ab
0 0 0
0 1 0
1 0 0
1 1 1
a b ab
0 0 0
0 1 0
1 0 0
1 1 1
![Page 29: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/29.jpg)
Henry Hexmoor 29
Three bit Multiplication
• Partial products are: 101 × 1, 101 × 1, and 101 × 0
• Note that the partial productsummation for n digit, base 2numbers requires adding upto n digits (with carries) ina column.
• Note also n × m digit multiply generates up to an m + n digit result (same as decimal).
1 0 1
× 0 1 1
1 0 1
1 0 1
0 0 0
0 0 1 1 1 1
![Page 30: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/30.jpg)
Henry Hexmoor 30
Multiplier Boolean Equations
• We can also make an n × m “block” multiplier and use that to form partial products.
• Example: 2 × 2 – The logic equations for each partial-product binary digit are shown below:
• We need to "add" the columns to getthe product bits P0, P1, P2, and P3.
• Note that some columns may generate carries.
b1 b0
a1 a0
(a0b1) (a0
b0)+ (a1
b1) (a1 b0)
P3 P2 P1 P0
![Page 31: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/31.jpg)
Henry Hexmoor 31
A 2x2 binary multiplier• The AND gates produce the
partial products.
• For a 2-bit by 2-bit multiplier, we can just use two half adders to sum the partial products. In general, though, we’ll need full adders.
• Here C3-C0 are the product, not carries!
B1 B0
x A1 A0
A0B1 A0B0
+ A1B1 A1B0
C3 C2 C1 C0
HAHA
![Page 32: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/32.jpg)
Henry Hexmoor 32
Multiplication: a special case
• In decimal, an easy way to multiply by 10 is to shift all the digits to the left, and tack a 0 to the right end.
128 x 10 = 1280
• We can do the same thing in binary. Shifting left is equivalent to multiplying by 2:
11 x 10 = 110 (in decimal, 3 x 2 = 6)
• Shifting left twice is equivalent to multiplying by 4:
11 x 100 = 1100 (in decimal, 3 x 4 = 12)
• As an aside, shifting to the right is equivalent to dividing by 2.
110 ÷ 10 = 11 (in decimal, 6 ÷ 2 = 3)
![Page 33: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/33.jpg)
Henry Hexmoor 33
Other Arithmetic Functions5-7
• 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
![Page 34: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/34.jpg)
Henry Hexmoor 34
HW 5
1. Perform the indicated subtraction with the following unsigned binary numbers by taking the 2’s complement of the subtrahend:
(a) 1111 – 10000, (b) 10110 – 1111, (c) 101111 – 1011110, (d) 101 – 101000
(Q 5-4)
2. Design a circuit that multiplies two 4-bit unsigned numbers. Use AND gates and binary adders. (Q 5-18)
![Page 35: Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design](https://reader036.vdocument.in/reader036/viewer/2022081519/56649d365503460f94a0ebe8/html5/thumbnails/35.jpg)
Henry Hexmoor 35