8/12/2019 L13 Kvs Digital Circuits 1 Full
1/50
:
r. . . r vas avaDept. of Electrical Engineering
IIT Kanpur
1
8/12/2019 L13 Kvs Digital Circuits 1 Full
2/50
Numbers
A ositional notation is commonl used to ex ress numbers
5 4 3 2 1 0( )a a a a a a a r a r a r a r a r a r = + + + + +
The decimal system has a base of 10 and uses symbols
, , , , , , , , ,
3 2 1 0=
10123.24 1 10 2 10 3 10 2 10 4 10
= + + + +
2
8/12/2019 L13 Kvs Digital Circuits 1 Full
3/50
Numbers
An octal number system has a base 8 and uses symbols
(0,1,2,3,4,5,6,7)
3 2 1 08(2007) 2 8 0 8 0 8 7 8= + + +
What decimal number does it represent?
1 0
8(2007) 2 512 0 64 0 8 7 8 1033= + + + =
3
810
=
8/12/2019 L13 Kvs Digital Circuits 1 Full
4/50
Number Symbol
0 0Numbers
exa ec ma sys em as a ase o2 2
3 3
3 2 1 0
16(2 9) 2 16 16 16 9 16BC B C= + + + 4 45 5
7 7
8 8
How do we convert it into decimal number?
1
9 9
10 A
16
09 16 11209+ =
12 C
13 D
14 E
15 F 4
16 10
8/12/2019 L13 Kvs Digital Circuits 1 Full
5/50
A Binary system has a base 2 and uses only two symbols 0, 1
to represent all the numbers 0
3 2 1 0
2(1101) 1 2 1 2 0 2 1 2= + + + 21 2
22 4
Which decimal number does thiscorrespond to ?
23
824 16
1 0
2(1101) 1 8 1 4 0 2 1 2 13= + + + = 26 6427 128 .
23-
2-428 256
29 512
22 21 20 2-1 - 210 1024(K)220 1048576(M)
13. 5625
2-1 2-2 2-3 2-4 2-5 2-6
0.5 0.25 0.125 0.0625 0.03125 0.015625 5
8/12/2019 L13 Kvs Digital Circuits 1 Full
6/50
Developing Fluency with Binary Numbers
1 1 0 0 1 = ? 25
= + + =
0.101 = ? 0.5+0.125=0.625
11.001 = ? 3+0.125=3.125
6
8/12/2019 L13 Kvs Digital Circuits 1 Full
7/50
Converting decimal to binary number
10 1 0(45) .......n nb b b=
1 11 1 045 2 2 ....... 2
n nn nb b b b
= + + +
Divide both sides by 2
1 1 022.5 2 2 ....... 2 0.5
2
n n
n nb b b b
= = + + +
1 2 01 1 022 0.5 2 2 ....... 2 0.5
n n
n nb b b b
+ = + + +
0 1b = 7
8/12/2019 L13 Kvs Digital Circuits 1 Full
8/50
1 2 0
1 1 022 0.5 2 2 ....... 2 0.5n n
n nb b b b
+ = + + + 0 1b =
1 2 1 0
1 2 122 2 2 ....... 2 2n n
n nb b b b
= + + +
Divide both sides by 2
2 3 0
1 2 111 2 2 ....... 2 0.5
2
n n
n nb b b b
= = + + +
1 0b =
2 3 1 0
1 3 211 2 2 ...... 2 2n n
n nb b b b
= + + +
3 4 0
1 3 25.5 2 2 ...... 2 0.5n n
n nb b b b
= + + + 2 1b =
3 4 1 0
1 4 35 2 2 ...... 2 2n n
n nb b b b
= + + + 8
8/12/2019 L13 Kvs Digital Circuits 1 Full
9/50
3 4 1 0
1 4 35 2 2 ...... 2 2n n
n nb b b b
= + + +
4 5 0
1 4 32.5 2 2 ...... 2 0.5n n
n nb b b b
= + + + 3 1b =
4 5 1 01 5 42 2 2 ...... 2 2
n nn n
b b b b
= + + +
5 6 0n n = 0b =n n
=
10 5 4 3 2 1 0
9
8/12/2019 L13 Kvs Digital Circuits 1 Full
10/50
Converting decimal to binary number
e o o success ve v s on y
22 1
11 0
2 1
45 = 1 0 1 1 0 1
1 0
0 1 1044 = 1 0 1 1 0 0
8/12/2019 L13 Kvs Digital Circuits 1 Full
11/50
Convert (153)10 to octal number system
10 1 0 8.......n n
1 1153 8 8 ....... 8n n= + +n n
Divide both sides by 8
1 2 0 01 119.125 8 8 ....... 8
8 8
n n
n nb b b
= = + +
0 0.1258
=
0153
19 1
remainder
2 3 153 = (231)8
11
8/12/2019 L13 Kvs Digital Circuits 1 Full
12/50
Converting decimal to binary number
. 10
(0.35) 0. .......b b b b
=
1 2
1 20.35 0 2 2 ....... 2 n
nb b b
= + + +
How do we find the b-1 b-2 coefficients?Multiply both sides by 2
1 2. ....... n
= + + 1 =
1 2 1
2 30.7 2 2 ....... 2
n
nb b b
+
= + +12
8/12/2019 L13 Kvs Digital Circuits 1 Full
13/50
1 2 1
2 30.7 2 2 ....... 2 n
nb b b
+
= + +
Multiply both sides by 2
2 3. ....... n
= + + 2 =
o e a + + +
1 2 2n +
3 4. ....... n =
1 33 40.8 2 ....... 2
nnb b b
+
= + 3 0b =
13
8/12/2019 L13 Kvs Digital Circuits 1 Full
14/50
Converting decimal to binary number
0 . 125
x2
.
.
5x2
0 .
1. 0. = . 2
0.8125 = ?0 .
1 . 625
8125x2
25x2
1 .x2
.
1. 0x2
. . 2
14
8/12/2019 L13 Kvs Digital Circuits 1 Full
15/50
Binary numbers decimal 2bit 3bit 4bit 5bit0 00 000 0000 00000
Least si nificant bit or LSB
Most significant bit or MSB2 10 010 0010 00010
3 11 011 0011 00011
4 100 0100 00100
5 101 0101 00101
7 111 0111 00111
8 1000 01000
Binary digit = bit 9 1001 01001
10 1010 01010
12 1100 01100
13 1101 01101
N-bit binary number
14 1110 01110
15 1111 01111
from 0 to 2N -115
8/12/2019 L13 Kvs Digital Circuits 1 Full
16/50
Converting Binary to Hex and Hex to Binary Number Symbol
0(0000) 0
= 1(0001) 12(0010) 2
ex
7 6 5 4 3 2 1
7 6 5 4 3 2 1 02 2 2 2 2 2 2b b b b b b b b+ + + + + +
4(0100) 4
5(0101) 5
11 016h h= +
6(0110) 6
7(0111) 7
7 6 5 4 3 2 1 0 1 02 2 2 2 2 2 2 16h h+ + + + + + = +
9(1001) 9
10(1010) A
h1h0
10110011 1011 0011 3B= =11(1011) B
12(1100) C
ex
(110011) (11)(0011) (33)b Hex= =
14(1110) E
15(1111) F( ) (1110)(1100) (11101100)Hex bEC = = 16
8/12/2019 L13 Kvs Digital Circuits 1 Full
17/50
Binary Addition/Subtraction
0
0
0
1
1
0
1
11
1
0 1 1 1 11 0
1 1 0
+ 1 1 1 0
1 0 1 1 1 1 0 1 1
17
8/12/2019 L13 Kvs Digital Circuits 1 Full
18/50
Complement of a number
9s com lementDecimal system:
10s complement
9s complement of n-digit number x is 10n -1 -x
10s complement of n-digit number x is 10n -x
9s complement of 85 ? 10 1 85 99 85 14 =
s comp emen o = =
' '
18
8/12/2019 L13 Kvs Digital Circuits 1 Full
19/50
Complement of a binary number
Binary system:
2s com lement
1s complement of n-bit number x is 2n -1 -x
2s complement of n-bit number x is 2n -x
1s complement of 1011 ? =
1s complement is simply obtained by flipping a bit
1's com lement of 1001101 = ?
(changing 1 to 0 and 0 to 1)
0110010 19
8/12/2019 L13 Kvs Digital Circuits 1 Full
20/50
2's complement of 1010 = 1's complement of 1010+1
0101 1 0110= + =
' =
Leave all least significant 0s as they are, leave first 1 unchanged
001110
and then flip all subsequent bits
1011 0101
20
8/12/2019 L13 Kvs Digital Circuits 1 Full
21/50
Advantages of using 2s complement
Adderx1
x2
S
CY
=10 2
10 2
' =
1010
If Carry is 1; then number you get is
+1010
( ) 1020100 4
21
10100 Answer is +4
8/12/2019 L13 Kvs Digital Circuits 1 Full
22/50
Advantages of using 2s complement
Adder1
x2 CY
( )10 210 10106 10 = ? ( )10 26 01102's comp ement o 1010=0110
If Carry is 0; then number you get is negative
+0110Take the 2s complement of number
'01100 0100 4
22
Answer is -4
8/12/2019 L13 Kvs Digital Circuits 1 Full
23/50
Example
0100Y = S if Sign = 0
Y = 2's Complement of S if Sign = 1
SYx1=1010
Adder
2's Complement Sign
=
CYx2=0110
= 1 for negative numbers6
1010
1 0
1 0 1 0+ 1 0 1 0
23
8/12/2019 L13 Kvs Digital Circuits 1 Full
24/50
Example
1100 0100Y = S if Sign = 0
Y = 2's Complement of S if Sign = 1
SYx1=0110
Adder
2's Complement Sign
=
CYx2=1010
= 1 for negative numbers10
0110
0 1
0 1 1 0+ 0 1 1 0
It makes sense to use adder as a subtractor as well provided additional circuit required
for carrying out 2s complement is simple
24
8/12/2019 L13 Kvs Digital Circuits 1 Full
25/50
Representing positive and negative binary numbers
One extra bit is required to carry sign information. Sign bit = 0 represents positive
=
decimal Signed
Magnitude
0 0000
decimal Signed1s
complement
1 1110
decimal Signed2s
complement
1 1111
1 0001
2 0010
3 0011
2 1101
3 1100
4 1011
2 1110
3 1101
4 1100
4 0100
5 0101
6 0110
5 1010
6 1001
7 1000
5 1011
6 1010
7 1001
7 0111
0 1000
1 1001
3 1011
4 1100
6 1110
7 1111 25
8/12/2019 L13 Kvs Digital Circuits 1 Full
26/50
Example
+ 0 0 1 0+ 5
+ 2
+ 5- 2
+ 1 1 1 0
0 1 1 1+7 +3
1 0 1 1 1 0 1 1- 5+ 2- 3
+
1 1 0 1
- 5- 2- 7
+
1 0 0 1
s comp emen s = s comp emen s =
26
8/12/2019 L13 Kvs Digital Circuits 1 Full
27/50
Example
2s com lement is 11111001:
27
00000111= 7
8/12/2019 L13 Kvs Digital Circuits 1 Full
28/50
Boolean Algebra
Al ebra on Binar numbers
A variable x can take two values {0,1} 0
False
No
Low voltage
Basic operations:
1Yes
Hi h volta e
1 2AND: y = x . x
y is 1 if and only if both x1 and x2 are 1, otherwise zero
x x
0 0 00 1 0Truth Table
1 0 0
1 1 1 28
8/12/2019 L13 Kvs Digital Circuits 1 Full
29/50
Basic operations:
OR: = x + xy is 1 if either x1 or x2 is 1. y= 0 if and only if both variables are
zero
x1 x2 y
0 1 1
1 0 11 1 1
NOT: y = xyx
1 0 29
8/12/2019 L13 Kvs Digital Circuits 1 Full
30/50
Boolean AlgebraBasic Postulates
.a: x = x
P2.a: x + y = y + x
. : x . = x
P2.b: x . y = y . x
Identity element
Commutative
P3.a: x.(y+z) = x.y+x.z
P4.a: x + x = 1
P3.b: x+y.z = (x+y).(x+z)
P4.b: x . x = 0 Complement
Distributive
Basic TheoremsT1.a: x + x = x
T2.a: x + 1 = 1T1.b: x . x = x
T2.b: x . 0 = 0
T3.a: ( x ) = x
T4.a: x + (y+z) = (x+y)+zT4.b: x . (y.z) = (x.y).z
T5.a: (x+y) = x . y (DeMorgan's theorem)
T6.a: x+ x.y = x
. : x.y = x y e orga
T6.b: x.( x+y) = x 30
P1 + 0 P1 b 1
8/12/2019 L13 Kvs Digital Circuits 1 Full
31/50
Proving TheoremsP1.a: x + 0 = x
P2.a: x + y = y + x
P1.b: x . 1 = x
P2.b: x . y = y . x
.a: x. y z = x.y x.z
P4.a: x + x = 1
P3. : x+y.z = (x+y .(x+z
P4.b: x . x = 0
Prove T1.a: x + x = x Prove T1.b: x . x = x
x + x = x+x . .
= x+x . x+x P4.a
. = . .
= x.x + x.x P4.b
= x + x.x (P3.b) = x . (x+x ) (P3.a
= x + 0 (P4.b)
= x P1.a
= x . 1 (P4.a)
= x P1.b
31
P1 a: + 0 P1 b 1
8/12/2019 L13 Kvs Digital Circuits 1 Full
32/50
Proving Theorems P1.a: x + 0 = x
P2.a: x + y = y + x
P1.b: x . 1 = x
P2.b: x . y = y . x
.a: x. y z = x.y x.z
P4.a: x + x = 1
P3. : x+y.z = (x+y .(x+z
P4.b: x . x = 0
Prove : x + 1 = 1+ = + +
x + x .y = x= x . 1 + x.
x + x .y = x+y
= (x+x)+ x= x. (1+ y)
= x . 1
= x x . x y
= 1. (x+ y)
= x + x
= 1
=x= x y
DeMorgans Theorem1 2 3 1 2 3(x x x ....) x . x .x .+ + + =
1 2 3 1 2 3(x . x . x .....) ( x + x x +.....)= + 32
Si lif i ti f B l i
8/12/2019 L13 Kvs Digital Circuits 1 Full
33/50
Simplification of Boolean expressions
x x x .... x . x .x .+ + + =
1 2 3 1 2 3(x . x . x .....) ( x + x x +.....)= +
1 2 2 3(x .x x .x ) ?+ =1 2 2 3
(x . x ) . (x . x )=
1 2 2 3
(x +x ) . (x + x )=
1 2 2 3(x x ) . (x + x )= +
1 2 2 2 1 3 2 3x . x x .x +x . x x . x= + +
1 2 1 3 2 3x . x x . x x . x= + +
33
F ti f B l i bl
8/12/2019 L13 Kvs Digital Circuits 1 Full
34/50
Function of Boolean variables
x1
x2
1 2
0 0 0
1 0 0
1 1 0
y = 1 when x1 is 0 and x2 is 1
1 2y = .x x
Boolean expression34
Obtaining Boolean expressions from truth Table
8/12/2019 L13 Kvs Digital Circuits 1 Full
35/50
Obtaining Boolean expressions from truth Table
x1 x2 y
0 0 1 1 2y = .x xx1 x2 y
0 0 01 2y = .x x
1 0 01 1 0
1 0 11 1 0
x1 x2 y
0 0 1
1 2.x x
=0 1 01 0 01 1 1 1 2.x x
. .
35
Obtaining Boolean expressions from truth Table
8/12/2019 L13 Kvs Digital Circuits 1 Full
36/50
Obtaining Boolean expressions from truth Table
x1 x2 y
0 0 01 2 1 2y = . .x x x x+
1 0 11 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 1 2 1 2 1 2y = . . .x x x x x x+ +
0 0 10 1 11 0 11 1 0 1 2y =x x+
36
8/12/2019 L13 Kvs Digital Circuits 1 Full
37/50
x x x x
0 0 10 1 0 y =x x+
0 0 00 1 1
1 2y =x x+
1 0 1
1 1 1
1 0 1
1 1 1
1 2x x+
x1 x2 y
0 0 0 1 2 1 2y = (x ).( )x x x+ +1 0 11 1 0
37
Obtaining Boolean expressions from truth Table
8/12/2019 L13 Kvs Digital Circuits 1 Full
38/50
= . . . . . . . .x x x x x x x x x x x x+ + +
Obtaining Boolean expressions from truth Table
yx1 x2 x3
0 0 0 00 0 1 1
0 1 0 00 1 1 11 0 0 01 0 1 1
Sum of Products (SOP) form
1 1 1 1
1 2 3 1 2 3 1 2 3 1 2 3y = ( ).( ).( ).( )x x x x x x x x x x x x+ + + + + + + +
Product of Sum (POS) form 38
Implementing Boolean expressions
8/12/2019 L13 Kvs Digital Circuits 1 Full
39/50
Implementing Boolean expressions
1 2AND: y = x . x
x1
x2yAND
Why call it a gate?
x1AND y = 0
0
x1AND
1
y = x1
a e s c ose a e s open
1 2: y = x + x 1x2yOR
NOT: y = x yx39
8/12/2019 L13 Kvs Digital Circuits 1 Full
40/50
x1x1x2
1 2 . x21 2
x1
xyNAND
NOR: y = x + x
x1
x2OR
1 2
x1+x2
x
x2y
40
8/12/2019 L13 Kvs Digital Circuits 1 Full
41/50
= =x1 x2 y
1 2 1 2 1 2 . . 0 0 00 1 11 0 1
1 1 0
y is 1 if only one variable is 1 and the other is zero
x2
y
x1
xyXOR
x1
x1x2x2
41
Gates with more than 2 inputs
8/12/2019 L13 Kvs Digital Circuits 1 Full
42/50
Gates with more than 2 inputs
x
1 2 3: y = x . x . ...x yANDx2x3
x1
1 2 3: y = x + x ....x+ + x2x3
y
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3XOR: y =x x x = x . . . . . . .x x x x x x x x x x x + + +
y = 1 only if odd number of inputs is 1
42
Implementing Boolean expressions using gates
8/12/2019 L13 Kvs Digital Circuits 1 Full
43/50
p g p g g
x
. . . . . . . .x y z x y z x y z x y z=
=
y
C
. . .
xx
x y zy
z
xy
z
x
zS
y
yC
yz
x
x y z
z
x
y
z
x y z43
Representation of Boolean Expressions
8/12/2019 L13 Kvs Digital Circuits 1 Full
44/50
Representation of Boolean Expressions
x y m n erm
0 0 x . y m00 0 0
x y 1
.
1 0 x . y m21 1 x . y m31 0 11 1 0
1f = . .x y x y+ 1 1 2f = m m+ f = 1, 2
2 , , 2 = . . .x y x y x y+ +
a function44
Three variable functions
8/12/2019 L13 Kvs Digital Circuits 1 Full
45/50
Three variable functions
0 0 0 x . y . z m0 . .
0 1 0 x . y . z0 1 1 x . y . z
m
m2m3
x . y . z1 0 1 x . y . z
1 1 0 x . y . z
m4m5
m6 1 1 1 x . y . z
m7
=2
, ,
2f = . . . . . .x y z x y z x y z+ +
45
Product of Sum Terms Representation
8/12/2019 L13 Kvs Digital Circuits 1 Full
46/50
p
x y f1 x y Max term
0 1 11 0 1 0 1 x + y M11 0 x + y M2
=1
301 =
= 301 ,
46
8/12/2019 L13 Kvs Digital Circuits 1 Full
47/50
y zx Max. terms
M0M1
0 0 0 x + y + z0 0 1 x + y + z
M2
M3
x + y + z
0 1 1 x + y + z1 0 0 x + + z
M5
M6
1 0 1 x + y + z1 1 0 x + y + z
1 , , =
2 = x . .y z x y z x y z
47
Simplification
8/12/2019 L13 Kvs Digital Circuits 1 Full
48/50
p
yx1 x2 x3
0 0 0 0=
, , ,
0 1 0 00 1 1 1
x1
x2
1 0 0 01 0 1 1
1 1 0 0
3
x2
x1
1 1 1 1
y
x2
x3
x1
3
x1
x2
x3
Simplification of Boolean expression yields : y = x3 !! which does
not require any gates at all ! 48
Goal of Simplification
8/12/2019 L13 Kvs Digital Circuits 1 Full
49/50
= 1 2 3 1 2 3 1 2 3 1 2 3. . . . . . . .x1
x2
x3
x2
x1
y
x2
x3
x1
x3
x1
x2
x3
Goal of simplification is to reduce the complexity of gate circuit.
s requ res a we m n m ze e num er o ga es.
49
1 2 3 1 2 3 1 2 3 1 2 3y = . . . . . . . .x x x x x x x x x x x x+ + +
8/12/2019 L13 Kvs Digital Circuits 1 Full
50/50
1 2 3 1 2 3 1 2 3 1 2 3yx1
x2
x3
x1 1 3 1 2 3 1 2 3y = . . . . .x x x x x x x x + +
y
x2
x1
x2
x3
x1
x3
x1
x2
x3y
x2
x3
x1
x3x1
x2
x3
This circuit is simpler not just because it uses 4 gates instead of
- - -
gates as compared to five 3-input gates used in circuit-1
50