Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s...
-
date post
19-Dec-2015 -
Category
Documents
-
view
219 -
download
0
Transcript of Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s...
![Page 1: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/1.jpg)
Binary Subtraction
Section 3-9 Mano & Kime
![Page 2: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/2.jpg)
Binary Subtraction
• Review from CSE 171
• Two’s Complement Negative Numbers
• Binary Adder-Subtractors
• 4-bit Adder/Subtractor in VHDL
![Page 3: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/3.jpg)
Half Subtractor
C A B D 0 0 0 1
0 0 0 00 1 1 11 0 1 01 1 0 0
A 0 B 0
D 0
C 1
![Page 4: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/4.jpg)
Full Subtractor
0 0 0 0 00 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 1
Ci Ai Bi Di Ci+1
1 1
1 1
Ci
AiBi00 01 11 10
0
1
Di
Di = Ci $ (Ai $ Bi)
Same as Si in full adder
![Page 5: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/5.jpg)
Full Subtractor
0 0 0 0 00 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 1
Ci Ai Bi Di Ci+1 Ci
AiBi00 01 11 10
0
1
1
1 11
Ci+1
Ci+1 = !Ai & Bi
# Ci !Ai & !Bi
# Ci & Ai & Bi
![Page 6: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/6.jpg)
Full SubtractorCi+1 = !Ai & Bi
# Ci !Ai & !Bi
# Ci & Ai & Bi
Ci+1 = !Ai & Bi
# Ci & (!Ai & !Bi # Ai & Bi)
Ci+1 = !Ai & Bi # Ci & !(Ai $ Bi)
Recall:Si = Ci $ (Ai $ Bi)
Ci+1 = !Ai & Bi # Ci & !(Ai $ Bi)
![Page 7: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/7.jpg)
Full Subtractor
A
B
D
C
C i+1
i
i
i
i
Si = Ci $ (Ai $ Bi)
Ci+1 = !Ai & Bi # Ci & !(Ai $ Bi)
half subtractorhalf subtractor
![Page 8: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/8.jpg)
Binary Subtraction
• Review from CSE 171
• Two’s Complement Negative Numbers
• Binary Adder-Subtractors
• 4-bit Adder/Subtractor in VHDL
![Page 9: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/9.jpg)
Negative Numbers
Subtract by adding
73-35 38
10’s complement 73+65138
Ignore carry
![Page 10: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/10.jpg)
Negative Numbers
10’s complement: Subtract from 100
100-35 65
Take 9’s complement and add 1
99-35 64 +1 65
![Page 11: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/11.jpg)
Negative Numbers
2’s complement:
Subtract from
100000000 01001101 10110011
Take 1’s complement and add 1
11111111-01001101 10110010 +1 10110011
![Page 12: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/12.jpg)
Finding 2’s Complement
0 1 0 1 1 0 0 0
Copy all bitsto first 1
2’s complement
0001
Complementremaining bits
0101
![Page 13: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/13.jpg)
Negative NumberTake 2’s Complement
7510 = 4B16 = 01001011-7510 = B516 = 10110101
FF-4B B4 +1 B5
![Page 14: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/14.jpg)
Negative NumberTake 2’s Complement
110 = 0116 = 00000001-110 = FF16 = 11111111
12810 = 8016 = 10000000-12810 = 8016 = 10000000
![Page 15: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/15.jpg)
Table 2.2Positive and Negative Binary Numbers
Signed decimal Hex Binary Unsigned decimal-128 80 10000000 128-127 81 10000001 129-126 82 10000010 130
… … … …… … … …… … … …-3 FD 11111101 253-2 FE 11111110 254-1 FF 11111111 2550 00 00000000 01 01 00000001 12 02 00000010 23 03 00000011 3
… … … …… … …
… … …125 7D 01111101 125126 7E 01111110 126127 7F 01111111 127
![Page 16: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/16.jpg)
Signed Numbers
4-bit: 8H = -8 to 7H = +7 1000 to 0111
8-bit: 80H = -128 to 7F = +127
16-bit: 8000H = -32,768 to 7FFFH = +32,767
32-bit: 80000000H = -2,147,483,648 to 7FFFFFFFH = +2,147,483,647
![Page 17: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/17.jpg)
Binary Subtraction
• Review from CSE 171
• Two’s Complement Negative Numbers
• Binary Adder-Subtractors
• 4-bit Adder/Subtractor in VHDL
![Page 18: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/18.jpg)
Block Diagram of Binary Adder-Subtractor
![Page 19: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/19.jpg)
Adder/SubtractorA 0 B 0
D 0
C 1
A 0 B 0
S 0
C 1
A 0
B 0 0
CB1 E
SD
Half adder Half subtractor
E = 0: Half adder
E = 1: Half subtractor
![Page 20: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/20.jpg)
Adder/Subtractor-1
i+1
A B
D
C
C
i i
i
i
E
E = 0: Full adderE = 1: Full subtractor
![Page 21: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/21.jpg)
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
Ci Ai Bi Si Ci+1
1 0 1 0 11 0 0 1 01 1 1 1 11 1 0 0 10 0 1 1 00 0 0 0 00 1 1 0 10 1 0 1 0
Ci Ai Bi Si Ci+1
Full AdderReorderedFull Adder
0 0 0 0 00 0 1 1 10 1 0 1 00 1 1 0 01 0 0 1 11 0 1 0 11 1 0 0 01 1 1 1 1
Ci Ai Bi Di Ci+1
FullSubtractor
NOT
![Page 22: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/22.jpg)
Making a full adderfrom a full subtractor
Full Adder
A B
C C
D
i i
i+1 i
i
![Page 23: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/23.jpg)
Adder/Subtractor-2
Full Adder
A B
C
0 0
1
0
Full Adder
A B
C
1 1
2
1
Full Adder
A B
C
2 2
3
2
Full Adder
A B
C SD
3 3
4 3 SD SD SD
E
E = 0: 4-bit adderE = 1: 4-bit subtractor
![Page 24: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/24.jpg)
4-bit Subtractor: E = 1
Full Adder
A B
C
0 0
1
0
Full Adder
A B
C
1 1
2
1
Full Adder
A B
C
2 2
3
2
Full Adder
A B
C SD
3 3
4 3 SD SD SD
E
+1
Add A to !B (one’s complement) plus 1That is, add A to two’s complement of BD = A - B
![Page 25: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/25.jpg)
Adder- Subtractor Circuit
![Page 26: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/26.jpg)
Binary Subtraction
• Review from CSE 171
• Two’s Complement Negative Numbers
• Binary Adder-Subtractors
• 4-bit Adder/Subtractor in VHDL
![Page 27: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/27.jpg)
2's Complementer
2-to-1 MUX
4-bit Adder
E
A(3:0) B(3:0)
B1(3:0)
B2(3:0)
SD(3:0)
0 1
CB
A 4-Bit Adder-Subtractor
![Page 28: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/28.jpg)
2's Complementer
2-to-1 MUX
4-bit Adder
E
A(3:0) B(3:0)
B1(3:0)
B2(3:0)
SD(3:0)
0 1
CB
![Page 29: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/29.jpg)
2's Complementer
2-to-1 MUX
4-bit Adder
E
A(3:0) B(3:0)
B1(3:0)
B2(3:0)
SD(3:0)
0 1
CB
![Page 30: Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.](https://reader030.fdocuments.us/reader030/viewer/2022032800/56649d3f5503460f94a188b1/html5/thumbnails/30.jpg)
addsub2
a(3:0)
b(3:0)
E
CB
SD(3:0)
addsub2.vhd