Professional Documents
Culture Documents
ESC201T L32 Digital Circuits 2
ESC201T L32 Digital Circuits 2
Electronics
B. Mazhari
Dept. of EE, IIT Kanpur
Numbers Every number system is associated with a base or radix
(2007)8 2 83 0 82 0 81 7 80
What decimal number does it represent?
Number Symbol
0 0
1 1
2 2
3 3
(2 BC 9)10 2 163 B 162 C 161 9 160
4 4
5 5
6 6 How do we convert it into decimal number?
7 7
8 8 (2 BC 9)10 2 4096 11 256 12 161 9 160 11209
9 9
10 A
11 B
12 C
13 D
14 E
15 F
A Binary system has a base 2 and uses only two symbols 0, 1 to represent all the
numbers
20 1
21 2
(1101) 2 1 2 1 2 0 2 1 2
3 2 1 0
22 4
23 8
Which decimal number does this correspond to ?
24 16
25 32
(1101) 2 1 8 1 4 0 2 1 2 13
1 0
26 64
27 128
1101.1001 28 256
2-4 29 512
23 22 20
21 2-1 2 2-3
-2
210 1024(K)
220 1048576(M)
11001 = ? 25
1100001 = ? 64+32+1=97
0.101 = ? 0.5+0.125=0.625
11.001 = ? 3+0.125=3.125
Converting decimal to binary number
45 bn 2n bn 1 2n 1.......b1 21 b0
45
22.5 bn 2n 1 bn 1 2n 2.......b1 20 b0 0.5
2
b0 1
22 0.5 bn 2n 1 bn 1 2n 2....... b1 20 b0 0.5 b0 1
22 bn 2n 1 bn 1 2n 2.......b2 21 b1 20
22 b1 0
11 bn 2n 2 bn 1 2n 3.......b2 20 b1 0.5
2
11 bn 2n 2 bn 1 2 n 3...... b3 21 b2 20
5 bn 2n 3 bn 1 2n 4......b4 21 b3 20
5 bn 2n 3 bn 1 2n 4......b4 21 b3 20
2 bn 2n 4 bn 1 2n 5......b5 21 b4 20
1 bn 2n 5 bn 1 2n 6......b5 20 0.5b4 b4 0
b5 1
45 remainder
22 1
11 0
5 1
2 1 45 = 101101
1 0
0 1
Convert (153)10 to octal number system
(153)10 bn 8n bn 1 8n 1.......b1 81 b0
8 8 8
153 remainder
19 1
2 3
153 = (231)8
0 2
Converting decimal to binary number
b2 1
Note that ½+1/4+1/8+……1
0.125 = ?
0 . 125
x2
0. 25
x2
0. 5
x2
0.125 = (.001)2
1. 0
0 . 8125
0.8125 = ?
x2
1. 625
x2
1. 25
x2
0.8125 = (.1101)2 0. 5
x2
1. 0
Binary numbers
Least significant bit or LSB
Most significant bit or MSB
1011000111 This is a 10 bit number
h1 10(1010) A
h0
11(1011) B
1
0 1 0 1 1
0 0 1 1 1
0 1 1 1 0 1 1
101
1101
110 + 1110
1011 11011
Complement of a number
9’s complement
Decimal system:
10’s complement
1’s complement
Binary system:
2’s complement
0110010
2's complement of 1010 = 1's complement of 1010+1 0110
001110
1011 0101
101101100 010010100
Subtraction using 10’s complement
5
5
1
0
3
10-3=7
This way of subtraction would make sense only if subtracting a number x2 from 10N
is much simpler than directly subtracting it directly from x1
Subtraction using 10’s complement
6
4
0
1
7
10-7=3
This way of subtraction would make sense only if subtracting a number x2 from 10N
is much simpler than directly subtracting it directly from x1
Advantages of using 2’s complement
x1 S
Adder
x2 CY
2 N x2 (CY , S ) x1 2 N x2
Note that carry will be there only if x1 – x2 is positive as 2N is N+1 bits (1 followed by N
zeros)
Advantages of using 2’s complement
2 N x2 (CY , S ) x1 2 N x2
Note that carry will be there only if x1 – x2 is positive as 2N is N+1 bits (1 followed by N
zeros)
A zero carry implies a negative number whose magnitude (x2 – x1) can be found as
follows:
S x1 2 N x2
2'scomplement of S 2 N ( x1 2 N x2 ) x2 x1
Example
10 0100
0100
1 0
6
1010
1010
+1010
10100
Example
6 1100
0100
0 1
10
0110
0110
+0110
1100
It makes sense to use adder as a subtractor as well provided additional circuit required
for carrying out 2’s complement is simple
Representing positive and negative binary numbers
One extra bit is required to carry sign information. Sign bit = 0 represents positive
number and Sign bit = 1 represents negative number
decimal Signed decimal Signed 1’s decimal Signed 2’s
Magnitude complement complement
0 0000 0 0000 0 0000
1 0001 1 0001 1 0001
2 0010 2 0010 2 0010
3 0011 3 0011 3 0011
4 0100 4 0100 4 0100
5 0101 5 0101 5 0101
6 0110 6 0110 6 0110
7 0111 7 0111 7 0111
-0 1000 -0 1111 -1 1111
-1 1001 -1 1110 -2 1110
-2 1010 -2 1101 -3 1101
-3 1011 -3 1100 -4 1100
-4 1100 -4 1011 -5 1011
-5 1101 -5 1010 -6 1010
-6 1110 -6 1001 -7 1001
-7 1111 -7 1000
If we represent numbers in 2’s complement form carrying out subtraction is same as
addition
Adder
x2 CY
0101 0101
+5 +0010 +5 +1110
+2 -2
+7 0111 +3 0011
1011 1011
-5 +0010 -5 +1110
+2 -2
-3 1101 -7 1001
Basic operations:
True
AND: y = x1. x 2 1
Yes
High voltage
Y is 1 if and only if both x1 and x2 are 1, otherwise zero
x1 x2 y
0 0 0
Truth Table 0 1 0
1 0 0
1 1 1
Basic operations:
OR: y = x1 + x 2
x1 x2 y
0 0 0
0 1 1
1 0 1
1 1 1
x y
NOT: y = x
0 1
1 0
Boolean Algebra
Basic Postulates
P1: x + 0 = x P1: x . 1 = x
P2: x + y = y + x P2: x . y = y . x
P3: x.(y+z) = x.y+x.z P3: x+y.z = (x+y).(x+z)
P4: x + x = 1 P4: x . x = 0
Basic Theorems
T1: x + x = x
T2: x + 1 = 1 T1: x . x = x
T2: x . 0 = 0
T3: ( x ) = x
T4: x . (y.z) = (x.y).z
T4: x + (y+z) = (x+y)+z
T5 (x.y) = x + y (DeMorgan's theorem)
T5 (x+y) = x . y (DeMorgan's theorem)
T6: x.( x+y) = x
T6: x+ x.y = x
Proving theorems P1: x + 0 = x P1: x . 1 = x
P2: x + y = y + x P2: x . y = y . x
P3: x.(y+z) = x.y+x.z P3: x+y.z = (x+y).(x+z)
P4: x + x = 1 P4: x . x = 0
=x (P1) = x (P1)
Proving theorems P1: x + 0 = x P1: x . 1 = x
P2: x + y = y + x P2: x . y = y . x
P3: x.(y+z) = x.y+x.z P3: x+y.z = (x+y).(x+z)
P4: x + x = 1 P4: x . x = 0
Prove : x + 1 = 1
x + x .y = x
x + x .y = x+y
x + 1 = x+(x+ x) = x . 1 + x. y
= x. (1+ y) = (x + x ). (x+ y)
= (x+x)+ x
=x.1 = 1. (x+ y)
=x+x =x =x+y
=1
DeMorgan’s theorem
(x1 x 2 x 3 ....) x1 . x 2 . x 3 .
(x1 x 2 x 3 ....) x1 . x 2 .x 3 .
(x1.x 2 x 2 .x 3 ) ?
(x1. x 2 . x 3 .....) ( x1 + x 2 x 3 +.....)
(x1 x 2 ) . (x 2 + x 3 )
x1 . x 2 x1 . x 3 x 2 . x 3
Function of Boolean variables
x1
y
x2
x1 x2 y
y
0 0 0
0 1 1
1 0 0
x 1 1 0
Y = 1 when x1 is 0 and x2 is 1
y = x2
y = x1 . x2
Boolean expression
Obtaining Boolean expressions from truth Table
x1 x2 y x1 x2 y
0 0 1 y = x1 . x2 0 0 0 y = x1 . x2
0 1 0 0 1 0
1 0 0 1 0 1
1 1 0 1 1 0
x1 x2 y x1 . x2
0 0 1
0 1 0 y = x1 . x2 x1. x2
1 0 0
1 1 1 x1 . x2
Obtaining Boolean expressions from truth Table
x1 x2 y
0 0 0 y = x1 . x2 x1. x2
0 1 1
1 0 1
1 1 0
Instead of writing expressions as sum of terms that make y equal to 1, we can also
write expressions using terms that make y equal to 0
x1 x2 y y = x1 . x2 x1 . x2 x1. x2
0 0 1
0 1 1
1 0 1
1 1 0 y = x1 x2
x1 x2 y x1 x2 y
0 0 1 0 0 0 y =x1 x2
0 1 0 y =x1 x2 0 1 1
1 0 1 1 0 1
1 1 1 1 1 1
x1 x2 y
x1 x2
0 0 0 y = (x1 x2 ).( x1 x2 )
0 1 1
1 0 1
1 1 0 x1 x2
Obtaining Boolean expressions from truth Table