The following will be discussed in this chapter: Addition and subtraction of binary data is fundamental, represent inputs and outputs, hardware features, same hardware can be used for addition and subtraction with minor changes, dealing with overflow.
Trang 1Lecture 14
Binary Adders and Subtractors
Trang 2w
° Addition and subtraction of binary data is fundamental
• Need to determine hardware implementation
° Represent inputs and outputs
• Inputs: single bit values, carry in
• Outputs: Sum, Carry
° Hardware features
• Create a single-bit adder and chain together
° Same hardware can be used for addition and
subtraction with minor changes
° Dealing with overflow
• What happens if numbers are too big?
Trang 3° Add two binary numbers
• A 0 , B 0 -> single bit inputs
• S 0 -> single bit sum
• C 1 -> carry out
Trang 41 1
1 1
Ai+Bi
Ci
Si
Ci+1
° Consider single-bit adder for each bit position.
Each bit position creates a sum and carry
Trang 5Si
° Full adder includes carry in C i
° Notice interesting pattern in Karnaugh map.
Trang 6° Full adder includes carry in C i
° Alternative to XOR implementation
Trang 7Full Adder
Si = Ci’ Ai’ Bi
+ Ci’ Ai Bi’
+ Ci Ai’ !Bi’ + Ci Ai Bi
Trang 8Full Adder (S in SOP)
Trang 9Ci+1
° Now consider implementation of carry out
° Two outputs per full adder bit (Ci+1, Si)
Note: 3 inputs
Trang 10° Now consider implementation of carry out
° Minimize circuit for carry out - C i+1
Trang 11Full Adder (C in SOP)
Trang 14° Hardware repetition simplifies hardware design
Trang 15° Putting it all together
• Single-bit full adder
• Common piece of computer hardware
Trang 16° Chain single-bit adders together.
° What does this do to delay?
Trang 17Negative Numbers – 2’s
Complement.
110 = 0116 = 00000001-110 = FF16 = 11111111
12810 = 8016 = 10000000-12810 = 8016 = 10000000
° Subtracting a number is the same as:
1 Perform 2’s complement
2 Perform addition
° If we can augment adder with 2’s complement
hardware?
Trang 19Adder- Subtractor Circuit
Trang 20Overflow in two’s complement
addition
° Definition: When two values of the same signs are
added:
• Result won’t fit in the number of bits provided
• Result has the opposite sign.
Trang 211101 1010
11
1110 1101
01
0011 0110
11
1110 0100
2
4
2
2 4 2
Trang 22Addition cases and overflow
Trang 23Binary Parallel Adder (Again)
° To add n-bit numbers:
• Use n Full-Adders in parallel
• The carries propagates as in addition by hand
°This adder is called ripple carry adder
°Src: Mano’s Book
Trang 24Ripple Adder Delay
°How to improve?
Trang 25Carry Look Ahead Adder
• How to reduce propagation delay of ripple carry adders?
• Carry look ahead adder: All carries are computed as a
function of C 0 (independent of n !)
• It works on the following standard principles:
• A carry bit is generated when both input bits Ai and Bi
are 1, or
• When one of input bits is 1, and a carry in bit exists
Trang 26Carry Look Ahead Adder
Trang 27Carry Look Ahead Adder
Trang 28Carry Look Ahead Adder
Trang 29Carry Look Ahead Generator
Trang 30Carry Look Ahead Adder
Conclusion: Each carry bit can be expressed in
terms of the input carry Co, and not based on its
preceding carry bit
Each carry bit can be expressed as a SOP, and can
be implemented using a two-level circuit, i.e a gate delay of 2T
Trang 31Carry Look Ahead Adder
Trang 32BCD Adder
° BCD digits are valid for decimal numbers 0-9
° Addition of two BCD numbers will generate an
output, that may be greater than 1001 (9).
° In such cases, the BCD number 0110 is added to
the result as a correction step
° When adding two BCD numbers, the maximum
result that can be obtained is:
9 + 9 = 18
If we include a carry in bit, then the maximum
result that can be obtained is: 19 (10011)
Both numbers 18 and 19 are invalid BCD digits Therefore, a 6 needs to be added to bring them
to correct BCD format.
Trang 33Derivation of BCD adder
Trang 34Derivation of BCD adder
°Combinations 1010 through 1111 need correction
°When K=1, it is necessary to add 0110 to the binary sum
Trang 36Binary Multiplication
Trang 37Binary Multiplication
° Therefore, for multiplying two 2-bit numbers, AND
gates and ADDERS will be sufficient
°Half
Adders
Trang 38° Addition and subtraction are fundamental to computer
systems
° Key – create a single bit adder/subtractor
• Chain the single-bit hardware together to create bigger designs
° The approach is call ripple-carry addition
• Can be slow for large designs
° Overflow is an important issue for computers
• Processors often have hardware to detect overflow
° Next time: encoders/decoder