Title: Subtractors
1Subtractors
2Subtractors
- Half Subtractor
- Full Subtractor
- Adder/Subtractor - 1
- Adder/Subtractor - 2
3Half Subtractor
C
A
B
D
0
0
0
1
0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0
2
1
0 -1 1
4Full Subtractor
Ci Ai Bi Di Ci1
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
1
1
1
1
Di
5Full Subtractor
Ci Ai Bi Di Ci1
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
1
1
1
1
Ci1
Ci1 !Ai Bi Ci !Ai !Bi Ci
Ai Bi
6Full Subtractor
Ci1 !Ai Bi Ci !Ai !Bi Ci
Ai Bi
Ci1 !Ai Bi Ci (!Ai !Bi Ai
Bi) Ci1 !Ai Bi Ci !(Ai Bi)
Recall
Di Ci (Ai Bi)
Ci1 !Ai Bi Ci !(Ai Bi)
7Full Subtractor
Di Ci (Ai Bi)
Ci1 !Ai Bi Ci !(Ai Bi)
8subtract.abl
MODULE subtract TITLE 'Subtractor, A. Student,
7/12/02' DECLARATIONS " INPUT PINS " A3..A0 PIN
6, 7, 11, 5 " Switch 1..4 A A3..A0
" 4-bit operand B3..B0 PIN 72, 71,
66, 70 " Switch 5..8 B B3..B0
" 4-bit subtrahend " OUTPUT PINS " D3..D0
PIN 39, 37, 36, 35 ISTYPE 'com' " LED 5..8 D
D3..D0 " 4-bit difference BF PIN
40 ISTYPE 'com' " LED 4 borrow flag
9subtract.abl (contd)
" INTERMEDIATE NODES " C4..C0 NODE ISTYPE 'com'
" internal borrow vector Cin C3..C0 Cout
C4..C1 EQUATIONS C0 0 D C A B Cout
!A B Cin !(A B) BF C4 END subtract
Di Ci (Ai Bi)
Ci1 !Ai Bi Ci !(Ai Bi)
10Adder/Subtractor - 1
Half subtractor
Half adder
E 0 Half adder
E 1 Half subtractor
11Adder/Subtractor-1
i1
E 0 Full adder E 1 Full subtractor
12addsub1.abl
i1
C4..C0 NODE ISTYPE 'com' " internal borrow
vector Cin C3..C0 Cout C4..C1
EQUATIONS Cout Cin (E (A B)) (E A)
B
13Adder/Subtractor-2
14Reordered Full Adder
Full Adder
Ci Ai Bi Si Ci1
Ci Ai Bi Si Ci1
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
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
NOT
15Making a full subtractor from a full adder
16Adder/Subtractor-2
E 0 4-bit adder E 1 4-bit subtractor
174-bit Subtractor E 1
That is, add A to twos complement of B D A - B
18Question
Subtract the following 4-bit binary numbers
10110110 -74 11001011 -53 11101011
-21
What is the answer in binary and dec? Was there a
net borrow?
Yes