You are on page 1of 50

ESc201 : Introduction to Electronics

ESc201:IntroductiontoElectronics

Digital Circuits 1
DigitalCircuits1

Dr. K
D
K. V
V. S
Srivastava
i
t
Dept. of Electrical Engineering
IIT Kanpur
1

Numbers
Every number system is associated with a base or radix
Ap
positional notation is commonly
y used to express
p
numbers

(a5 a4 a3 a2 a1a0 ) r = a5 r + a4 r + a3 r + a2 r + a1r + a0 r


5

The decimal system has a base of 10 and uses symbols


(0 1 2 3 4 5 6 7 8 9) to represent numbers
(0,1,2,3,4,5,6,7,8,9)

(2009)10 = 2 10 + 0 10 + 0 10 + 9 10
3

(
(123.24)
)10 = 1 10 + 2 10 + 3 10 + 2 10 + 4 10
2

Numbers
An octal number system has a base 8 and uses symbols
(0,1,2,3,4,5,6,7)

(2007)8 = 2 8 + 0 8 + 0 8 + 7 8
3

What decimal number does it represent?

(2007)8 = 2 512 + 0 64 + 0 8 + 7 8 = 1033


1

(2007)8 = (1033)10
3

Number

Symbol

How do we convert it into decimal number?

(2 BC 9)16 = 2 4096 + 11 256 + 12 16

10

11

12

13

14

15

Numbers
A hexadecimal
h
d i l system
t
h a base
has
b
off 16

(2 BC 9)16 = 2 163 + B 162 + C 161 + 9 160

+ 9 160 = 11209

(2 BC 9)16 = (11209 )10

A Binary system has a base 2 and uses only two symbols 0, 1


to represent all the numbers
20
1

(1101) 2 = 1 23 + 1 22 + 0 21 + 1 20

21

22

Which decimal number does this


correspond to ?

23

24

16

25

32

26

64

27

128

28

256

29

512

210

1024(K)

220

1048576(M)

(1101) 2 = 1 8 + 1 4 + 0 2 + 1 2 = 13
1

1101.1001
23
22

21

20

3
-2
2 2-3
2
2-1

2-4

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

Developing Fluency with Binary Numbers

11001 = ?

25

1100001 = ?

64+32+1=97
64
32 1 97

0.101 = ?

0.5+0.125=0.625

11.001 = ?

3+0.125=3.125
6

Converting decimal to binary number


Convert 45 to binary number

(45)10 = bnbn 1.......b0


n 1

45 = bn 2 + bn 1 2 ....... + b1 2 + b0
n

Divide both sides by 2

45
n 1
n2
0
= 22.5 = bn 2 + bn 1 2 ....... + b1 2 + b0 0.5
2

22 + 0.5 = bn 2

n 1

n2

+ bn 1 2 ....... + b1 2 + b0 0.5

b0 = 1

22 + 0.5 = bn 2

22 = bn 2

n 1

+ bn 1 2 ....... + b1 2 + b0 0.5 b0 = 1

n 1

n2

n2

+ bn 1 2 ....... + b2 2 + b1 2
1

Divide both sides by 2

22
n2
n 3
0
= 11 = bn 2 + bn 1 2 ....... + b2 2 + b1 0.5
2

11 = bn 2

n2

n 3

+ bn 1 2 ...... + b3 2 + b2 2
1

b1 = 0

5.5 = bn 2n 3 + bn 1 2n 4...... + b3 20 + 0.5b2 b2 = 1

5 = bn 2

n 3

n4

+ bn 1 2 ...... + b4 2 + b3 2
1

0
8

5 = bn 2

n 3

+ bn 1 2 ...... + b4 2 + b3 2

n4

+ bn 1 2 ...... + b4 2 + 0.5b3 b3 = 1

2.5 = bn 2

2 = bn 2

n4

1 = bn 2

n 5

n4

n 5

n 5

+ bn 1 2 ...... + b5 2 + b4 2
n6

+ bn 1 2 ...... + b5 2 + 0.5b4 b4 = 0
0

b5 = 1

(45)10 = b5b4b3b2b1b0 = 101101


9

Converting decimal to binary number


M th d off successive
Method
i di
division
i i b
by 2

45

remainder

22

11

45

44

101101

101100
10

Convert (153)10 to octal number system

(153)10 = (bnbn 1.......b0 )8


n 1

(153)10 = bn 8 + bn 1 8 .......b1 8 + b0
n

Divide both sides by 8

b0
b
153
= 19.125 = bn 8n 1 + bn 1 8n 2.......b1 80 + 0 8 = 0.125
8
8

153
19

remainder
1

b0 = 1

153

(231)8
11

Converting decimal to binary number


Convert (0
(0.35)
35)10 to binary number

((0.35))10 = 0.b1b2b3 .......b n


1

0.35 = 0 + b1 2 + b2 2 + .......b n 2

How do we find the b-1 b-2 coefficients?


Multiply both sides by 2

0 7 = b1 + b2 2 + .......b n 2
0.7
1

n +1

0.7 = b2 2 + b3 2 + .......b n 2

b1 = 0

n +1
12

0.7 = b2 2 + b3 2 + .......b n 2

n +1

Multiply both sides by 2


1

1 4 = b2 + b3 2 + .......b n 2
1.4

b2 = 1

n+2

N t that
Note
th t
+1/4+1/8+1
1/4 1/8
1
1

0 4 = b3 2 + b4 2 .......b n 2
0.4
1

0.8 = b3 + b4 2 .......b n 2

n+2

n +3

b3 = 0
13

Converting decimal to binary number


0 125 = ?
0.125

0 125
0.125

0 .

((.001)
001)2

0.

25

0.
1.

5
0

0 .

0.8125 = ?

1.
0 8125
0.8125

((.1101)
1101)2

125

1.
0
0.
1.

x2
x2
x2

8125
x2
625
x2
25
x2
5
x2
0

14

decimal

2bit 3bit

4bit

5bit

00

000

0000

00000

01

001

0001

00001

10

010

0010

00010

Least significant
g
bit or LSB 3

11

011

0011

00011

100

0100

00100

101

0101

00101

110

0110

00110

111

0111

00111

1000

01000

1001

01001

10

1010

01010

11

1011

01011

12

1100

01100

13

1101

01101

14

1110

01110

15

1111

15
01111

Binary numbers
Most significant bit or MSB

1011000111

Binary digit = bit


This is a 10 bit number
N-bit binary number
can represent numbers
from 0 to 2N -1

Converting Binary to Hex and Hex to Binary Number

(b7b6b5b4b3b2b1b0 )b = (h1 , h0 ) Hex


H
b7 2 + b6 2 + b5 2 + b4 2 + b3 2 + b2 2 b1 2 + b0
7

= h1161 + h0

0(0000)

1(0001)

2(0010)

3(0011)

4(0100)

5(0101)

(b7 23 + b6 22 + b5 21 + b4 )24 + (b3 23 + b2 22 b1 21 + b0 ) = h1161 + h0 6(0110)

h1

h0

(10110011)b = (1011)(0011) = ( B3) Hex


H

(110011)b = (11)(0011) = (33) Hex


( EC ) Hex = (1110)(1100) = (11101100)b

Symbol

7(0111)

8(1000)

9(1001)

10(1010)

11(1011)

12(1100)

13(1101)

14(1110)

15(1111)

16

Binary Addition/Subtraction
0

1 0

101

1101

110

+ 1110

1011

11011

1
1
1
1 1

17

Complement of a number
9s complement
p
Decimal 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
2

99 85 = 14

9' complement
9's
l
t off 123 = 999 123 = 876
10'ss complement of 123 = 99'ss complement of 123+1 = 877
10
18

Complement of a binary number


1s
1
s complement
Binary system:
2s complement
p
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 ? 2

1 1011 1111 1011 = 0100

1s complement
p
is simply
p y obtained by
y flipping
pp g a bit
(changing 1 to 0 and 0 to 1)

1's complement
p
of 1001101 = ?
0110010

19

2's complement of 1010 = 1's complement of 1010+1


= 0101 + 1 = 0110

22'ss complement of 110010 =


Leave all least significant 0s as they are, leave first 1 unchanged
and then flip all subsequent bits

001110

1011 0101
101101100 010010100
20

Advantages of using 2s complement


x1
x2

10 6 = ?

Adder

1010 (1010 )2

CY

610 ( 0110 )2

22'ss complement of 0110


0110=1010
1010

1010
+1010
10100

If Carry is 1; then number you get is


positive

( 0100 )2 410
Answer is +4

21

Advantages of using 2s complement


x1
x2

6 10 = ?

Adder

610 ( 0110 )2

S
CY

1010 (1010 )2

2' complement
2's
l
off 1010
1010=0110
0110
If Carry is 0; then number you get is negative

0110
+0110
01100

Take the 2s complement of number

22'ss complement of 1100=0100

( 0100 )2 410
Answer is -4

22

Example
10

0100
S

x1=1010

0100

Y = S if Sign = 0
Y = 2's Complement of S if Sign = 1

Adder
x2=0110

2's Complement

CY

Sign
Sign = 0 for psotive numbers
= 1 for negative numbers

1010
1010
+1010
10100

23

Example
1100

6
S

x1=0110

0100

Y = S if Sign = 0
Y = 2's Complement of S if Sign = 1

Adder
x2=1010

2's Complement

10

CY

Sign
Sign = 0 for psotive numbers
= 1 for negative numbers

0110
0110
+0110
1100

It makes sense to use adder as a subtractor as well p


provided additional circuit required
q
for carrying out 2s complement is simple
24

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
Magnitude

decimal

Signed1s
complement

decimal

Signed2s
complement

0000

1110

1111

0001

1101

1110

0010

1100

1101

0011

1011

1100

0100

1010

1011

0101

1001

1010

0110

1000

1001

0111

1000

1001

2
2

1010

1011

1100

5
5

1101

1110

1111

25

Example

+5
+2
+7

-5
+2
-3

0101
+0010
0111

1011
+0010
1101

2 complement
2s
l
t iis 011 = 3

+5
-2
+3

-5
-2
-7

0101
+1110
0011

1011
+1110
1001

2 complement
2s
l
t iis 111 = 7
26

Example

2s complement
p
is 11111001:
00000111= 7
27

Boolean Algebra
Algebra on Binary numbers
A variable x can take two values {0,1} 0

False
No
Low voltage

Basic operations:

AND: y = x1. x 2

True
Yes

High voltage
y is 1 if and only if both x1 and x2 are 1, otherwise zero

x1 x2 y
Truth Table

0
0
1
1

0
1
0
1

0
0
0
1

28

Basic operations:

OR: y = x1 + x 2
y is 1 if either x1 or x2 is 1. y= 0 if and only if both variables are
zero

x1 x2 y
0
0
1
1

NOT: y = x

0
1
0
1

0
1
1
1
x

0 1
1 0

29

Boolean Algebra
Basic Postulates

P1
P1.a:
x+0=x

P1.b:
P1
b x.1=x
P2.b: x . y = y . x

Identity element

P2.a: x + y = y + x
Commutative
P3.a: x.(y+z) = x.y+x.z P3.b: x+y.z = (x+y).(x+z)Distributive
P4.b: x . x = 0

P4.a: x + x = 1

Complement

Basic Theorems

T1.a: x + x = x
T2.a: x + 1 = 1
T3.a: ( x ) = x
T4.a: x + (y+z) = (x+y)+z

T1.b: x . x = x
T2.b: x . 0 = 0
T4.b: x . (y.z) = (x.y).z
T5 b
T5.b:

((x.y)) = x + y (D
(DeMorgan
M

T5.a: (x+y) = x . y (DeMorgan's theorem)


T6.b: x.( x+y) = x
T6.a: x+ x.y = x

30

Proving Theorems P1.a: x + 0 = x

P1.b: x . 1 = x

P2.a: x + y = y + x P2.b:
P3
P3.a:
x.(y+z)
( + ) = x.y+x.z
+
P3 b
P3.b:
P4.a: x + x = 1

Prove T1.a: x + x = x
x + x = (x+x).
(
) 1 (P1
(P1.b)
b)
= ((x+x).
) (x+x)
(
)

= x + x.x

=x+0
=x

((P4.a))

(P3.b)

(P4.b)

((P1.a))

x .y = y.x
x+y.z = ((x+y).(x+z)
)(
)

P4.b: x . x = 0

Prove T1.b: x . x = x
x . x = xx.x+
x+ 0 (P1.a)
(P1 a)
= x.x + x.x

((P4.b))

= x . (x+x ) (P3.a)

=x.1
=x

(P4.a)

((P1.b))
31

Proving Theorems P1.a: x + 0 = x

P1.b: x . 1 = x

P2.a: x + y = y + x
P2.b:
P3
P3.a:
x.(y+z)
( + ) = x.y+x.z
+
P3 b
P3.b:
P4.a: x + x = 1

Prove : x + 1 = 1
x + 1 = xx+(x+
(x x)
= (x+x)+ x

=x+x

x .y = y.x
x+y.z = ((x+y).(x+z)
)(
)

P4.b: x . x = 0

x + x .y = x

x + x .y = x+y

= x . 1 + x. y
= x. (1+ y)
=x.1

= (x
( + x ).
) (x+
( + y))
= 1. (x+ y)

=x

=x+y

=1
DeMorgans Theorem

(x1 + x 2 + x 3 + ....) = x1 . x 2 .x 3 .
(x1. x 2 . x 3 .....) = ( x1 + x 2 + x 3 +.....)
32

Simplification of Boolean expressions

((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 2 . x 3 )
= (x1 +x 2 ) . (x 2 + x 3 )
= (x1 + x 2 ) . (x 2 + x 3 )

= x1. x 2 + x 2 .x 2 +x1 . x 3 + x 2 . x 3

= x1 . x 2 + x1 . x 3 + x 2 . x 3
33

Function of Boolean variables


x1
y
x2

x1 x2 y
0
0
1
1

0
1
0
1

0
1
0
0

y = 1 when x1 is 0 and x2 is 1

y = x1 . x2
Boolean expression
34

Obtaining Boolean expressions from truth Table


x1 x2 y
0
0
1
1

0
1
0
1

x1 x2 y

y = x1 . x2

1
0
0
0

x1 x2 y
0
0
1
1

0
1
0
1

1
0
0
1

0
0
1
1

0
1
0
1

0
0
1
0

y = x1 . x2

x1 . x2

y = x1 . x2 + x1. x2
x1 . x2
35

Obtaining Boolean expressions from truth Table


x1 x2 y
0
0
1
1

0
1
0
1

0
1
1
0

y = x1 . x2 + x1. x2

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
0
0
1
1

0
1
0
1

1
1
1
0

y = x1 . x2 + x1 . x2 + x1. x2

y =x1 + x2
36

x1 x2 y

x1 x2 y

0
0
1
1

0
0
1
1

0
1
0
1

1
0
1
1

y =x1 + x2

0
1
0
1

0
1
1
1

y =x1 + x2

x1 + x2
x1 x2 y
0
0
1
1

0
1
0
1

0
1
1
0

y = (x1 + x2 ).( x1 + x2 )

x1 + x2
37

Obtaining Boolean expressions from truth Table


x1 x2 x3 y
0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

0
1
0
1
0
1
0
1

y = x1 . x2 . x3 + x1. x2 . x3 + x1. x2 . x3 + x1. x2 . x3

S
Sum
off Products (SOP)
(SO ) form
f

y = ( x1 + x2 + x3 ).( x1 + x2 + x3 ).( x1 + x2 + x3 ).( x1 + x2 + x3 )


Product of Sum (POS) form

38

Implementing Boolean expressions


Elementary Gates

AND: y = x1. x 2

x1

AND

x2

Why call it a gate?


x1
0

AND

y=0
G t is
Gate
i closed
l
d

x1

AND

OR y = x1 + x 2
OR:

x1

NOT: y = x

x2

y = x1
G t is
Gate
i open

OR

y
39

NAND: y = x1. x 2

x1x2

x1
x2
x1
x2

x1

NOR: y = x1 + x 2

x1x2

AND

x2
x1
x2

NAND

x1+x2
x1+x2

OR

NOR

y
40

XOR: y = x1 x 2 =xx1. x2 + x1 . x2

x1 x2 y
0
0
1
1

0
1
0
1

0
1
1
0

y is 1 if only one variable is 1 and the other is zero


x1

x1x2

x1

x2
y
x1
x2

x2

XOR

x1x2

41

Gates with more than 2 inputs

AND y = x1. x 2 . x3 ...


AND:

x1
x2
x3

OR y = x1 + x 2 + x3 + ....
OR:

x1
x2
x3

AND

XOR: y =x1 x 2 x 3 = x1. x2 x3 + x1 . x2 .x3 + x1 . x2 .x3 + x1.x2 .x3


y = 1 only if odd number of inputs is 1

42

Implementing Boolean expressions using gates


x

S = x. y.z + x. y.z + x. y.z + x. y.z

y
C
z

x
y

C = x. y + x.z + y.z

x
x y z

y
z

z
S

x
y

x y z

y
z

x y z

x
z

x
y
z

x y z
43

Representation of Boolean Expressions


x

y f1

y min
i tterm

0
0
1
1

0
1
0
1

0
0
1
1

0
1
0
1

0
1
1
0

f1 = x . y + x. y

f1 = m1 + m2

f 2 = (0,
(0 2,3)
2 3) = ?

x.y
x.y
x.y
x.y

m0
m1
m2
m3

f1 = ((1,, 2))

f 2 = x . y + x. y + x . y

A minterm is a product that contains all the variables used in


a function
44

Three variable functions


x

y z min terms

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

f 2 = (1,
(1 4,
4 7) = ?

x.y.z
x.y.z
x.y.z
x.y.z
x.y.z
x.y.z
x.y.z
x.y.z

m0
m1
1
m2
m3
m4
m5
m6
m7

f 2 = x . y. z + x. y. z + x . y . z

45

Product of Sum Terms Representation


x

y f1

0
0
1
1

0
1
0
1

0
0
1
1

0
1
1
0

y Max term
0
1
0
1

x+y
x+y
x+y
x+y

M0
M1
M2
M3

f1 = ( x + y ) ( x + y )
f1 = M 0 M 3
f1 = (M 0 , M 3 )
46

x
0
0
0
0
1
1
1
1

y z Max. terms
0
0
1
1
0
0
1
1

0 x + y + z M0
1 x + y + z M1
0 x + y + z M2
1 x + y + z M3
0 x + y + z M4
1 x + y + z M5
0 x + y + z M6
1 x + y + z M7

f1 = (1,5,
(1 5 7) = ?
f 2 = (x
( + y + z ).(
) ( x + y + z ).(
) ( x + y + z)
47

Simplification
x1 x2 x3 y
0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

0
1
0
1
0
1
0
1

y= (1,3,5,
(1 3 5 7)
y = x1 . x2 . x3 + x1. x2 . x3 + x1. x2 . x3 + x1. x2 . x3
x1
x2
x3
x1
x2
x3
x1

x2
x3
x1
x2
x3

Simplification of Boolean expression yields : y = x3 !! which does


48
not require any gates at all !

Goal of Simplification

y = x1 . x2 . x3 + x1. x2 . x3 + x1. x2 . x3 + x1. x2 . x3


x1
x2
x3
x1
x2
x3
x1

x2
x3
x1
x2
x3

Goal of simplification is to reduce the complexity of gate circuit.


Thi requires
This
i
th t we minimize
that
i i i the
th number
b off gates.
t
49

y = x1 . x2 . x3 + x1. x2 . x3 + x1. x2 . x3 + x1. x2 . x3


x1
x2
x3
x1

y = x1 . x3 + x1. x2 . x3 + x1. x2 . x3

x2
x3
x1

x1
y

x3

x2
x3
x1
x2
x3

x1
x2
x3
x1
x2
x3

This circuit is simpler not just because it uses 4 gates instead of


5 but also because circuit-2
circuit 2 uses one 2
2-input
input and three 3
3-input
input
gates as compared to five 3-input gates used in circuit-1
50

You might also like