Substractor: Combinational Logic Design
Substractor: Combinational Logic Design
Substractor: Combinational Logic Design
Substractor
Overview
• Binary Subtraction
– 2’’s complement
– Extension to r’s complement
– Subtraction with complements
• Binary Adders/Subtractors
– Signed numbers
– Signed Addition/Subtraction
– Overflow problem
• Binary Multipliers
Nov-01-10 Chapter 3-v: Combinational Logic 2
Design (3.9-3.11)
Binary Subtraction
n
• In general, if N > M, Dif = M-N+2 , where
n = # bits.
• In Case II of the previous example, Dif=
5
19-30+2 = 21.
• To correct the magnitude of Dif, which
n n
should be N-M, calculate 2 -(M-N+2 ).
• This is known as the 2’’s complement of
Dif.
B 1 0011 1100
M 0110 0100 100
N -1 0 0 1 0 1 1 0 -50
Dif 11001 110 206
n
210000 0000 256
Dif - 1 1 0 0 1 1 1 0 -206
0001 10010 50
M0M1M2M3 N0N1N2N3
B
4-bit Subtractor
Selective
2’s Complementer
Selective
2’s Complementer
Sub/Add
Quadruple 2-to-1 MUX
– 2C(N2) =
{ 2n-N2 ,
0 ,
if n > 0
if n = 0
• Example: N2 =1010
– 2C(N2) = 24-N2 = 100002 – 10102 = 01102
• Example: N2 =11111
– 2C(N2) = 25-N2 = 1000002 – 111112 = 00001 2
Nov-01-10 Chapter 3-v: Combinational Logic 10
Design (3.9-3.11)
2’s Complement (cont.)
– 1C(N2) = (2n-1) - N2
• Example: N2 =011
– 1C(N2) = (23-1)-N2 = 1112 – 0112 = 1002
• Example: N2 =1010
– 1C(N2) = (24-1) - N2 = 11112 – 10102 = 0101 2
• Observation: 1’s complement can be derived by
just complementing all the bits in the number.
A-B = A + 2C(B)
= A + 1C(B) + 1
= A + B’ + 1
S=0
B3 B2 B1 B0
0
S=1
When C4 = 0 and S=1 it means that A < B and we must correct the
result R3…R0 (see slide 15).
Thus, we must compute 2’s complement of R3…R0:
Use a specialized 2’s complement circuit or
Use the 4-bit Adder/Subtractor again, with A3…A0=0000,
B3…B0=R3…R0, and S=1.
• For example:
– -1010 is
• -10102 in unsigned (- sign is implicit)
• 110102 in singed (- sing is indicated in MSB=1)
• Another example:
– 10112 is
• 1110 in unsigned
• -310 in signed
V
Cn+1
Cn
C n-bit Adder/Subtractor
• Example:
– Multiplier A=A1A0 and multiplicand B=B1B0
– Find C = AxB:
B1 B0
x A1 A0
-----------------
A0B1 A0B0
+ A1B1 A1B0
-------------------------------
C3 C2 C2 C0