Digital Systems Lecture 17-20
Digital Systems Lecture 17-20
Arithmetic Circuits
1
Unsigned Arithmetic
• Numbers that are positive only are called unsigned, and numbers that can
also be negative are called signed.
• We will deal with binary arithmetic in this course.
• Unsigned Binary Addition and Subtraction
Binary addition is performed in the same way as decimal addition
except that the values of individual digits can be only 0 or 1.
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Addition
• Single Digit Addition, all possible combinations
Can we get a
truth table for one
bit unsigned
addition ??
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Half Adder
This circuit, which implements the addition of only two bits, is called a half-adder.
Logic Circuit
Truth Table
s = xy’ +
x’y
c = xy
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Multi bit
By Hand
Method
5
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Multi bit
• For bit position 0, there is no carry-in, and hence the addition is the same
as Half Adder.
• For each other bit position i the addition involves bits X i and Yi, and a
carry-in Ci.
• This is a three variable function, for which truth table can be derived.
6
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Full Adder
This circuit, which implements the addition of only three bits, is called
a Full-adder.
Truth Table K-map simplification
si = Ʃ m(1,2,4,7)
ci+1 = Ʃ m(3,5,6,7)
7
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Full Adder
Logic Circuit
Using NAND Gates only
8
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Decomposed Full Adder
2 Half
Adder = 1
Full Adder
9
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE)
Unsigned Arithmetic - Ripple Carry Adder
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 0
Unsigned Arithmetic - Ripple Carry Adder
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 1
Unsigned Arithmetic - Ripple Carry Adder
• When the operands X and Y are applied as inputs to the adder, it takes
some time before the output sum, S, is valid.
• Each full-adder introduces a certain delay before its S i and Ci+1 outputs are
valid Let this delay be denoted as △t
• Thus the carry-out from the first stage, C 1 arrives at the second stage △t
after the application of the x0 and y0 inputs. The carry-out from the
second stage, C2, arrives at the third stage with a 2△t delay, and so on
• The signal Cn-1 is valid after a delay of (n - 1)△t, which means that the
complete sum is available after a delay of n△t.
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 2
Unsigned Arithmetic - Design Example
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 3
Unsigned Arithmetic - Design Example
Normal approach
Cin = 0
Cin = 0
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 4
Unsigned Arithmetic - Design Example
• Design a multiplier that multiplies an eight bit unsigned number by 3.
P = 3A where A is 8-bit unsigned number.
A = a7a6…a0 2 = 10
P = p7p6 …p0 4 = 100
3A = 2A + A 8 = 1000
A = a7a6…a0 8-bits In Binary number system
2A = a7a6…a0 0 9-bits left shift by 1-bit is equal +
A = 0a7a6…a0 9-bits to multiplied by 2
P = p9p8p7…….p0 10-bits
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 5
Unsigned Arithmetic - Design Example
Efficient Approach
Cin = 0
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 6
Fast Adders
• The performance of a large digital system is dependent on the speed of
circuits that form its various functional units.
• Obviously, better performance can be achieved using faster circuits.
• This can be accomplished by using superior (usually newer) technology in
which the delays in basic gates are reduced.
• But it can also be accomplished by changing the overall structure of a
functional unit, which may lead to even more impressive improvement.
• To reduce the delay caused by the effect of carry propagation through the
ripple-carry adder, we can attempt to evaluate quickly for each stage
whether the carry-in from the previous stage will have a value 0 or 1.
• If a correct evaluation can be made in a relatively short time, then the
performance of the complete adder will be improved.
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 7
Fast Adders - Carry Look Ahead Adder
• Based on Full adder circuit the carry-out function for stage i can be realized as-
Generate function
Propagate function
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 8
Fast Adders - Carry Look Ahead Adder
ci+1 = gi + pici
Substituting i = 0,1,2,3…..
c1 = g0 +p0c0
c2 = g1 + p1c1 = g1 + p1(g0 +p0c0) = g1 + p1g0 + p1p0c0
c3 = g2 + p2c2 = g2 + p2(g1 + p1g0 + p1p0c0)
= g2 + p2g1 + p2p1g0 + p2p1p0c0
c4 = g3 + p3c3 = g3 + p3(g2 + p2g1 + p2p1g0 + p2p1p0c0)
= g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0
1
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 9
Fast Adders - Carry Look Ahead Adder
• Expanding in term of i-1 gives
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 0
Fast Adders - Carry Look Ahead Adder
c1 = g0 +p0c0
c2 = g1 + p1c1
Where g0 = x0y0 and p0 = x0 + y0
g1 = x1y1 and p1 = x1 + y1
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 1
Fast Adders - Carry Look Ahead Adder
c1 = g0 +p0c0
c2 = g1 + p1g0 + p1p0c0
2
𝟒∆ 2 1 Where g0 = x0y0 and p0 = x0 + y0
g1 = x1y1 and p1 = x1 + y1
𝟑∆ 𝟑∆
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 3
Unsigned Arithmetic - Full Subtractor
• The full subtractor is a combinational circuit which is used to perform
subtraction of three input bits: the minuend X, subtrahend Y and borrow
in Bin.
• The full subtractor generates two output bits: the difference D and borrow
out Bout.
Truth Table
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 4
Signed Number Representation
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 5
Signed Number Representation- Sign Magnitude Representation
Example: Drawbacks
+5 = 0101 • Range
-5 = 1101 • Circuit complexity
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 6
Signed Number Representation - 1’s Complement
• In a complementary number system, the negative numbers are defined
according to a subtraction operation involving positive numbers.
• In the 1's complement scheme. an n-bit negative number, K, is obtained
by subtracting its equivalent positive number, P, from 2 n-1
• K = (2 -1)-P
Example:
n
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 7
Signed Number Representation - 2’s Complement
• In the 2's complement scheme, a negative number, K, is obtained by
subtracting its equivalent positive number, P, from 2 n
• K = 2n-P
Example:
-5 = 24-0101 = 10000-0101 =
1011 Simply it is 1’s
-3 = 24-0011 = 10000-0011 = complement plus one
1101
• To get 2’s complement of any negative binary number, add 1 to the 1’s
complement.
(+11)10 => sign-magnitude = (0 1011)2 2’s complement = (0 1011)2
(-11)10 => sign-magnitude = (1 1011)2 1’s complement = (1 0100)2
2’s complement = (1 0101)2
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 8
Signed Number Representation
2
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 9
Signed Number Representation
• Represent (+23) in 8-bit 1’s complement format.
(+23) --> S-M = 0 0010111
1’s comp = 0 0010111
• Represent (-23) in 8-bit 1’s complement format.
(-23) --> S-M = 1 0010111
1’s comp = 1 1101000
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 0
Signed Arithmetic - Sign Magnitude
• If both operands have the same sign, then the addition of sign-and-
magnitude numbers is simple. The magnitudes are added, and the
resulting sum is given the sign of the operands.
• However, if the operands have opposite signs, the task becomes more
complicated. Then it is necessary to subtract the smaller number from the
larger one.
• This means that logic circuits that compare and subtract numbers are also
needed.
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 1
Signed Arithmetic - 1’s Complement Addition
• An obvious advantage of the 1's complement representation is that a
negative number is generated simply by complementing all bits of the
corresponding positive number..
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 2
Signed Arithmetic - 1’s Complement Addition
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 3
Signed Arithmetic - 2’s Complement Addition
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 4
Signed Arithmetic - 2’s Complement Subtraction
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 6
Adder and Subtractor Unit for Unsigned Numbers
• Assume two unsigned 4 bit numbers A and B where
A = 1011
B = 0110
To perform A + B we use 4-bit Ripple carry adder where the carry in to
the full adder, which will add LSB, is 0.
For subtraction A – B in form of addition A is added with 2’s complement
of B i.e. A + (-B)
A = 1011 A = 1011
B = 0110 (-B) = 1001 1’s comp of
+ 0c0 1 1’s comp + 1 = 2’s comp
10001 10101
Discard
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 7
Adder and Subtractor Unit for Unsigned Numbers
• To perform both the operation A + B and A – B with the same circuit, for
addition we need B as normal b but for subtraction we need 1’s
complement of B.
• This can be achieved if we will apply each bit of B to 2-input XOR gate
where the second input for XOR gate will be a control signal which will
be 0 for addition and 1 for subtraction.
⊕⊕⊕⊕ ⊕⊕⊕⊕
B=0 1 1 0 B=0 1 1 0
0 0 0 0 1 1
1 1
0 1 1 0 B 1 0 0
1 1’s comp of B
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 8
Adder and Subtractor Unit for Unsigned Numbers
= 0 for addition
1 for subtraction
3
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 9
Adder and Subtractor Unit
Design minimum cost circuits to perform following operation on two 3-bit
unsigned numbers A and B-
a) A + 2B
b) A – 2B using 2’s complement
c) A ± 2B
Solution-
A = a2a1a0 -- 3 bits
B = b2 b 1 b 0 -- 3 bits
2B = b2b1b00 -- 4 bits
A = 0 a2a1a0 -- 4 bits
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 0
Adder and Subtractor Unit
a) A + 2B
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 1
Adder and Subtractor Unit
b) A – 2B using 2’s complement
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 2
Adder and Subtractor Unit
b) A ± 2B
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 3
Arithmetic Overflow
• The result of addition or subtraction is supposed to fit within the
significant bits used to represent the numbers.
• If n bits are used to represent signed numbers, then the result must be in
the range -2n- 1 to 2n- 1 - 1.
• If the result does not fit in this range, then we say that arithmetic
overflow has occurred.
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 4
Arithmetic Overflow
=0⊕1=1
So arithmetic overflow exists here. To solve this we will represent (+7) and (+2)
with 5 bits.
(+7) 0 0111
+ (+2) + 0 0010
(+9) 0 1001
Now c3 = 0 and c4 = 0
Overflow = 0 ⊕ 0 = 0
4
19ECE204/Digital Electronics & Systems, III Semester, B. Tech. (ECE and CSE) 6