32
Digital Logic CS2052 Computer Architecture Computer Science & Engineering University of Moratuwa Dilum Bandara [email protected]

Digital Logic

Embed Size (px)

DESCRIPTION

Introduction to digital logic, fundamental logic gates, Boolean algebra & simplifications, 3-6 input Kanaugh Maps

Citation preview

Page 1: Digital Logic

Digital Logic

CS2052 Computer Architecture

Computer Science & Engineering

University of Moratuwa

Dilum [email protected]

Page 2: Digital Logic

Outline

Logic gates

Boolean Algebra

Kanaugh Maps

2

Page 3: Digital Logic

Logic Gates

Every digital device is based on a set of chips

designed to store & process information

Basic building blocks of these chips are logic

gates

Implementation of gates can be different

Different materials & fabrication technologies

Different operating voltages

e.g., 5v vs. 0v, 3+v vs. 0.5v

Today, they go as low as 1.9 - 2.1v

But their logical behavior is consistent across all

computers3

Page 4: Digital Logic

Common Logic Gates

NOT/inverter

AND

4

Truth table

Algebraic function

Page 5: Digital Logic

Common Logic Gates (Cont.)

OR

NAND

5

Page 6: Digital Logic

Common Logic Gates (Cont.)

NOR

XOR/EXOR (Exclusive OR)

6

Page 7: Digital Logic

Common Logic Gates (Cont.)

NXOR/EXNOR (Exclusive NOR)

7

Page 8: Digital Logic

Exercise

Implement 3-input AND using 2-inputs ANDs

Implement a NOT gate using a NAND

8

Page 9: Digital Logic

Fundamental Logic Gate

2-input NAND gate can be used to build any

other gate

9

Page 10: Digital Logic

Exercise

Implement AND using NANDs

Homework

Implement following gates using NANDs

OR

XOR

10

Page 11: Digital Logic

Boolean Algebra

Boolean variable

Takes only 2 values – either TRUE (1) or FALSE (0)

Boolean function

Mapping from Boolean variables to a Boolean value

Application

Can represent complex relationships in a digital circuit

Boolean algebra

Deals with binary variables & logic operations

operating on those variables

Application

Can simplify a relationship among multiple inputs in a digital

circuit 11

Page 12: Digital Logic

Basic Identities of Boolean Algebra

Basic operations

AND (.), OR (+), NOT (– or /)

0 – FALSE

1 – TRUE

x + 0 = x x + x = x

x · 0 = 0 x . x = x

x + 1 = 1 x + x/ = 1

x · 1 = x x · x / = 0

12

Page 13: Digital Logic

Basic Identities (Cont.)

Commutativity

x + y = y + x

xy = yx

Associativity

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

x (yz) = (xy) z

Distributivity

x ( y + z ) = xy + xz

x + yz = ( x + y )( x + z)

13

Textbook has a typo

Page 14: Digital Logic

Basic Identities (Cont.)

DeMorgan’s Theorem

( x + y )/ = x/ y/

( xy )/ = x/ + y/

Generalized DeMorgan's Theorem

(a + b + … z) / = a / b / … z /

(a.b … z) / = a / + b / + … z /

Involution

(x /) / = x

14

Page 15: Digital Logic

Exercise

Simplify following functions using Boolean Algebra

a + ab

a(a + b)

a(a / + b)

a + a/ b

(a + b.c) /

a + ab = a(1+b)=a

a(a + b) = a.a +ab=a+ab=a(1+b)=a

a + a'b = (a + a')(a + b)=1(a + b) =a+b

a(a' + b) = a.a' +ab=0+ab=ab

(a + b.c)' = a'.b' + a'.c' 15

Page 16: Digital Logic

Homework

Show steps for following simplifications

(a + b)(a + b') = a

ab + ab'c = ab + ac

(a + b)(a + b' + c) = a + bc

(a(b + z(x + a')))' = a' + b' (z' + x')

(a(b + c) + a'b)'=b'(a' + c')

(a + b)(a' + c)(b + c) = (a + b)(a' + c)

No need to submit answers

16

Page 17: Digital Logic

Minterms

Minterm

Each combination of variables in a truth table

As no of digital inputs (Boolean variables)

increase no of minterms increase

2n minterms for n inputs

As n increases

Large truth tables

Long Boolean functions

Easier to represent using decimal equivalent of

sum of minterms

F(a, b, c) = Σ (2, 4, 5, 7) 17

Page 18: Digital Logic

Exercise

Represent all odd numbers between 0 – 7 as a sum of

minterms

F(a, b, c) = Σ (1, 3, 5, 7)

Use Boolean Algebra to simplify above function

Σ (1, 3, 5, 7) = a‘b‘c + a‘bc + ab‘c + abc

= a‘c(b‘ + b) + ac (b‘ + b)

= a‘c + ac = c (a‘+ a) = c

18

Sum of Products

Page 19: Digital Logic

Karnaugh Map (K-Map)

Pictorial representation of a truth table

Map of squares – each square for each minterm

Adjacent squares change in minterm only by one

variable

19

bc

a

00 01 11 10

0 0 1 3 2

1 4 5 7 6

Decimal equivalent

of minterm

Page 20: Digital Logic

Example – 3 Variable K-Map

Simplify represent of all odd numbers between 0 – 7

F(a, b, c) = Σ (1, 3, 5, 7)

20

ab

c

00

01

11

10

0 1

1

1

1

1

0

0

0

0

= c

Page 21: Digital Logic

Exercise – 3 Variable K-Map

Simplify following expression using a K-map

21

ab

c

00

01

11

10

0 1

1

0

0

0

1

1

0

0

= a’c’ + a’b’

Page 22: Digital Logic

Kanaugh Map – Simplification

Squares containing 1’s are grouped to get sum-

of-product expression

Group size must be 2n

Group must be in rectangular shape

Each group represents an algebraic term

Its OK for groups to overlap

OR of all those terms is the final expression

Maximum group size better simplification

A don’t care (X) can be interpreted as either 0 or 1

when needed, only if it contributes to simplification

Don’t group Xs together!

22

Page 23: Digital Logic

4 Variable K-Map

23

Page 24: Digital Logic

Example – 4 Variable K-Map

24

Page 25: Digital Logic

Exercise – 4 Variable K-Map

What would be a Boolean expression of a circuit

that detects all even numbers between 0 – 15?

Present as a sum of minterms

25

Page 26: Digital Logic

5 Variable K-Map – Option 1

26

BC

DE

A1/0

00 01 11 10

00

01

11

10

0

5

3

1

8124

2

20

11

106

7

14

16

13 9

15

19

18

17

28 24

31

2921

23

3022 26

25

27

Page 27: Digital Logic

Example – 5 Variable K-Map

What would be a Boolean expression of a circuit

to detect all prime numbers between 0 & 31?

27

BC

DE

A1/0

00 01 11 10

00

01

11

10

0

5

3

1

8124

2

20

11

106

7

14

16

13 9

15

19

18

17

28 24

31

2921

23

3022 26

25

27

Page 28: Digital Logic

5 Variable K-Map – Option 2

28

Page 29: Digital Logic

Example – 5 Variable K-Map – Option 2

29

Page 30: Digital Logic

6 Variable K-Map

30

Page 31: Digital Logic

Simplification as Product of Sum

Some times it is useful to obtain the algebraic

expression as a product of sums

Can be obtained by finding sum of products for

F/ & converting it to F

To find F/ Group 0s in a K-map

F(a, b, c) = Σ (1, 3, 5, 7) = Π (1, 3, 5, 7)

31

Page 32: Digital Logic

Exercise – Product of Sum

Find sum-of-product & product-of-sum

representation of following K-map

32

ab

c

00

01

11

10

0 1

1

x

1

1

0

0

0

1

F(a, b, c) = ab’ + c

F/(a, b, c) = a’c’ + bc’

(F/(a, b, c)) / = (a + c)(b’ + c)

= F(a, b, c)