Download presentation
Presentation is loading. Please wait.
1
Binary Subtraction Section 3-9 Mano & Kime
2
Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor in VHDL
3
Half Subtractor CABD 0001 0 0 0 1 1 1 1 0 1 1 0 0 A 0 B 0 D 0 C 1
4
Full Subtractor 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 C i A i B i D i C i+1 11 11 CiCi AiBiAiBi 00011110 0 1 DiDi D i = C i $ (A i $ B i ) Same as S i in full adder
5
Full Subtractor 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 C i A i B i D i C i+1 CiCi AiBiAiBi 00011110 0 1 1 111 C i+1 C i+1 = !A i & B i # C i !A i & !B i # C i & A i & B i
6
Full Subtractor C i+1 = !A i & B i # C i !A i & !B i # C i & A i & B i C i+1 = !A i & B i # C i & (!A i & !B i # A i & B i ) C i+1 = !A i & B i # C i & !(A i $ B i ) Recall: S i = C i $ (A i $ B i ) C i+1 = !A i & B i # C i & !(A i $ B i )
7
Full Subtractor S i = C i $ (A i $ B i ) C i+1 = !A i & B i # C i & !(A i $ B i ) half subtractor
8
Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor in VHDL
9
Negative Numbers Subtract by adding 73 -35 38 10’s complement 73 +65 138 Ignore carry
10
Negative Numbers 10’s complement : Subtract from 100 100 -35 65 Take 9’s complement and add 1 99 -35 64 +1 65
11
Negative Numbers 2’s complement: Subtract from 100000000 01001101 10110011 Take 1’s complement and add 1 11111111 -01001101 10110010 +1 10110011
12
Finding 2’s Complement 0 1 0 1 1 0 0 0 Copy all bits to first 1 2’s complement 0001 Complement remaining bits 0101
13
Negative Number Take 2’s Complement 75 10 = 4B 16 = 01001011 -75 10 = B5 16 = 10110101 FF -4B B4 +1 B5
14
Negative Number Take 2’s Complement 1 10 = 01 16 = 00000001 -1 10 = FF 16 = 11111111 128 10 = 80 16 = 10000000 -128 10 = 80 16 = 10000000
16
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
17
Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor in VHDL
18
Block Diagram of Binary Adder-Subtractor
19
Adder/Subtractor A 0 B 0 D 0 C 1 A 0 B 0 S 0 C 1 Half adder Half subtractor E = 0: Half adder E = 1: Half subtractor
20
Adder/Subtractor-1 i+1 E = 0: Full adder E = 1: Full subtractor
21
0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 C i A i B i S i C i+1 1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 C i A i B i S i C i+1 Full Adder Reordered Full Adder 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 C i A i B i D i C i+1 Full Subtractor NOT
22
Making a full adder from a full subtractor
23
Adder/Subtractor-2 E = 0: 4-bit adder E = 1: 4-bit subtractor
24
4-bit Subtractor: E = 1 +1 Add A to !B (one’s complement) plus 1 That is, add A to two’s complement of B D = A - B
25
Adder- Subtractor Circuit
26
Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor in VHDL
27
A 4-Bit Adder-Subtractor
30
addsub2 a(3:0) b(3:0) E CB SD(3:0) addsub2.vhd
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.