Digital Logic Design - University of Hong Kong

Preview:

Citation preview

Digital Logic Design

ENGG1015

1st Semester, 2011

Dr. Kenneth Wong

Department of Electrical and Electronic Engineering

Representing Logic Operationsp g g p• Each function can be represented

equivalently in 3 ways:equivalently in 3 ways:– Truth table– Boolean logic expressiong p– Schematics

Truth Table

Boolean ExpressionSchematics

5

Determining output level from a diagramg p g

6

Implementing Circuits From Boolean Expressions• When the operation of a circuit is defined by a Boolean expression, we

can draw a logic-circuit diagram directly from that expression.• Example: draw the circuit for y = AC + BC + ABC• Example: draw the circuit for

– Done in two stepsy = AC + BC + ABC

7

Truth Table to Boolean Expression • List all combinations that give 1 at output

S

p

• Sum up all terms• Sum of products (SOP) – more later

CBACBA

?=xCBA

ABCABCCBACBAx ++= 8

Laws of Boolean Algebra • Commutative Laws

A + B = B + A

A A •• B = B B = B •• AA

• Associative Laws

A + (B + C) = (A + B) + C

A • (B • C) = (A • B) • C

9

• Distributive Law

A • (B + C) = A • B + A • CA (B + C) = A B + A CA (B + C) = A B + A C

Rules of Boolean Algebra

10

• Rule 1

OR Truth Table• Rule 2

• Rule 3

AND Truth Table

11

AND Truth Table

• Rule 4

• Rule 5

OR Truth Table• Rule 6

• Rule 7

AND Truth Table

12• Rule 8

• Rule 9

• Rule 10: A + AB = A– Proof: A+AB = A(1+B) by distributive law

= A·1 by rule 2= A by rule 4= A by rule 4

– Or prove by truth table

13

• Rule 11: BABAA +=+• This rule can only be proved by constructing the truth table (?)

BABAA ++

• Rule 12: (A + B)(A + C) = A + BC• This rule can only be proved by constructing the truth table (?)This rule can only be proved by constructing the truth table (?)

14

• Examples: – Simplify DBADBAy += ( ) by distributive law

1 by rule 6

b l 4

y AB D D

AB

AB

= +

= ⋅

Si lif ( )( )BABA

by rule 4AB=

– Simplify by distributive law

0 by rule 8 and rule 7

by rule 1

z AA AB BA BB

AB BA B

AB BA B

= + + +

= + + +

= + +

( )( )BABAz ++=

AB by rule 1

( 1) by distributive law

AB BA B

B A AB

= + +

= + += ⋅1 by rule 6 and rule 2

A

AB

– Simplify

by rule 4B=

BCDAACDx += ( ) by distributive lawx CD A AB= +

B

p y ( ) by distributive law( ) by rule 11

by distributive law

x CD A ABCD A BACD BCD

= += += +

15

Review QuestionsReview Questions• Simplify CABCAy +=

CAy =

CABCAy +=

• Simplify DCBADCBAy +=y CCy

DBAy =

• Simplify ABDDAy +=p y ABDDAy +

BDDAy +=

16

DeMorgan’s Theoremsg• Theorem 1

R bR b+

• Theorem 2

Remember: Remember:

“Break the bar, “Break the bar, change the operator”change the operator”

x y x y+ = ⋅

change the operatorchange the operator

D M ' th i f l i di it l i it d i

x y x y⋅ = +

– DeMorgan's theorem is very useful in digital circuit design– It allows ANDs to be exchanged with ORs by using invertors– DeMorgan's Theorem can be extended to any number ofDeMorgan s Theorem can be extended to any number of

variables. E.g, for three variables x, y and z

x y x y+ +x y z x y z

x y z x y z

+ + = ⋅ ⋅

⋅ ⋅ = + +

17

Quick Quiz (1)

Simplify•

( )AB C+

AC BC+•

•AC BC+

AC BC+

•AC BC+

AC BC+

Simplify ( ) ( )A C B D+ ⋅ +

• AC BD+

AC BD+

•AC BD+

AC BD+AC BD+

18

Quick Quiz (2)

Simplify•

AB CD EF⋅ ⋅

AB CD EF+ +•

AB CD EF+ +

AB CD EF+ +

AB CD EF+ +

ABCDEF

Determine the output expression for the below circuit and simplify it using DeMorgan’s Theoremcircuit and simplify it using DeMorgan s Theorem• ABC

• A B C+ +

ABC

• A B C+ + 19

Examples (Summary): ) ( ) ( )a AB C AB C A B C AC BC+ = ⋅ = + ⋅ = +

) ( ) ( ) ( ) ( )b A C B D A C B D A C B D AC BD+ ⋅ + = + + + = ⋅ + ⋅ = +

) ( ) ( ) ( )c A B C A B C A B C A B C+ ⋅ = ⋅ ⋅ = ⋅ + = +

) ( ) ( ) ( ) ( )d A BC D EF A BC D EF+ ⋅ + = + + +

( ) ( )( ) ( )

A BC D EFA B C D E F

= ⋅ + ⋅

= ⋅ + + ⋅ +

AB AC DE DF= + + +

) e AB CD EF AB CD EF AB CD EF⋅ ⋅ = + + = + +)e C C C

f ) Determine the output expression for the below circuit and simplify it using DeMorgan’s Theoremg g

20

Review QuestionsReview Questions• Using DeMorgan’s Theorems to convert the

expressions to one that has only single-variableexpressions to one that has only single-variable inversions.

QTSRy += QTSRy )( ++=

CBAz +=( ) CBAz ⋅+=

Qy Qy )(

( )

DCBAy ++= )( DCBAy +=

21

Implications of DeMorgan’s Theorems

x y x y+ = ⋅

• i.e., The AND gate with INVERTERs on each of its inputs is equivalent to a

Usually redrawn in this way

NOR gate

x y x y⋅ = +

• i e The OR gate with INVERTERs on

y y

Usually redrawn in this way• i.e., The OR gate with INVERTERs on

each of its inputs is equivalent to a NAND gate

y

22

Universality of NAND gatesy g• Any expression can be implemented using combinations of OR gates, AND gates and INVERTERs• However, it is also possible to implement any logic expression using only NANDHowever, it is also possible to implement any logic expression using only NAND gates and no other type of gate• This is because NAND gates, in proper combination, can perform Boolean operations OR, AND, and INVERTER, ,

23

• Example: Suppose we want to implement x=AB+CD. -- If we directly implement the expression, we need 2 AND gates and 1 OR we d ect y p e e t t e e p ess o , we eed N gates a d O

gate => we need two ICs -- If we transform the circuit into one having only NAND gates, we need

only one IConly one IC

IC in Dual-in-line package (DIP)package (DIP)

Pin diagrams for the ICs containing NAND,AND, and OR gates

24

Universality of NOR gateUniversality of NOR gate• In a similar manner, it can be shown that NOR gates can be arranged to implement any of the Boolean operationsany of the Boolean operations

25

Alternate Logic-Gate RepresentationsAlternate Logic Gate Representations• Apart from standard logic gate

symbols we have seen so far, theresymbols we have seen so far, there are alternate symbols for the commonly used gates

• The alternate symbols are obtained yby performing the following two steps:

1. Invert each input and output of the p pstandard symbol. This is done by adding bubbles (small circles) on input and output lines that do not have bubbles and by removing bubbles that are already there.

2. Change the operation symbol from AND to OR, or from OR to AND. (In the special case of the INVERTER, the operation symbol i t h d )

26

is not changed.)

Several points to notep• The equivalences can be extended to gates with

any number of inputs.y p• None of the standard symbols have bubbles on

their inputs, and all the alternate symbols do.• The standard and alternate symbols for each gate

represent the same physical circuit; there is no difference in the circuits represented by the two symbols.NAND d NOR t i ti t d• NAND and NOR gates are inverting gates, and so both the standard and the alternate symbols for each will have a bubble on either the input or theeach will have a bubble on either the input or the output, AND and OR gates are non-inverting gates, and so the alternate symbols for each will

27have bubbles on both inputs and output.

Why we need alternate representation?• Proper use of the alternate gate symbols in the circuit diagram can make the circuit operation much more easy to understand

• E.g., the two circuits on the right are equivalent• However circuit (a) does not• However, circuit (a) does not facilitate an understanding of how the circuit function • Circuit (b) is easy to understand: Z will go HIGH whenever either A=B=1 or C=D=1 (or both)

28

Canonical FormCanonical Form• Boolean expression can be expressed in

many different ways(A + D)(B + C) ≡ AB + AC + BD+ CD

• Two standard ways:Sum of Product– Sum of Product

– Product of Sum• Canonical SOP• Canonical POS

29

Canonical SOPCanonical SOP• Boolean expression expressed as a sum of

d t f b i i tproduct of basic inputs– Basic input may optionally negated

AB C + BD + AD

P d t– NOT canonical:

Product SumA + B(C + D)

– No parenthesis• Most natural for human

30

Canonical POSCanonical POS• Boolean expression expressed as a product

of sum of basic inputsof sum of basic inputs– Basic input my optionally negated

(A + B + C)(B + D )(A + D)

Product Sum– NOT canonical: – Many parenthesis A + B(C + D)

• Not too natural for human, but equally good for computers.

31

Example: This example illustrate the complete procedure for designing a logic circuit Suppose the logic circuit having 3 inputs A B C will have itslogic circuit. Suppose the logic circuit having 3 inputs, A, B, C will have its output HIGH only when a majority of the inputs are HIGH.

Step 1 Set up the truth table A B C xp p

Step 2 Write the AND term for

each case where the output

0 0 0 0

0 0 1 0

0 1 0 0each case where the output

is a 1.

Step 3 Write the SOP form the output

0 1 1 1

1 0 0 0

1 0 1 1

BCA→

CBA→Step 3 Write the SOP form the output

St 4 Si lif th t t i

1 0 1 1

1 1 0 1

1 1 1 1

CBA→CAB→

ABC→x ABC ABC ABC ABC= + + +

Step 4 Simplify the output expression

x ABC ABC ABC ABC ABC ABC= + + + + +

( ) ( ) ( )BC A A AC B B AB C CBC AC AB

= + + + + += + +

32Step 5 Implement the circuit

Example: Conversion through the opposite direction: Truth Table

BooleanS h tiy

A B C y

Boolean ExpressionSchematics

y

Step 1 Start from the circuit

A B C y

0 0 0 0

0 0 1 0

CBAS p S

Step 2 Obtain Boolean expression

from the circuit (in SOP form)

0 1 0 1

0 1 1 1

1 0 0 0

BCA→←CBA

from the circuit (in SOP form)1 0 1 1

1 1 0 1

1 1 1 1

CBA→←CAB

ABC→BCACBACy ++=

33Step 3 Write the truth table

1 1 1 1 ABC→

Forms of Boolean ExpressionsForms of Boolean Expressions• There are two general forms of logic expression: SOP, POS• Sum-of-products form (SOP)Sum of products form (SOP)

– first the product (AND) terms are formed then these are summed (OR)

– eg: ABC + DEF + GHI• Product-of-sum form (POS)

– first the sum (OR) terms are formed then the products are taken– first the sum (OR) terms are formed then the products are taken (AND)

– eg: (A+B+C)(D+E+F)(G+H+I)• It is possible to convert between these two forms using

Boolean algebra

34

Simplifying Logic Circuits• Once the expression for a logic circuit is obtained, we may try to simplify

it, so that the implementation requires fewer gates• Example: below two circuits are the same, but the second one is much p ,

more simpler

• Two methods for simplifyingAlgebraic method (use Boolean algebra theorems)– Algebraic method (use Boolean algebra theorems)

– Karnaugh mapping method (next lesson)

35

Minimization by Boolean Algebra• Make use of relationships and theorems of Boolean algebra to simplify

the expressions– this method relies on your algebraic skilly g

• Mainly consists of two steps:– The original expression is put into SOP form by repeated application of

DeMorgan’s theorems and multiplication of termsDeMorgan s theorems and multiplication of terms– Once the original expression is in SOP form, the product terms are

checked for common factors, and factoring is performed wherever possiblepossible

• Example: Simplify ( )z ABC AB AC= + ⋅( ) [by DeMorgan thm]z ABC AB A C= + ⋅ +( ) [ y g ]( ) [cancel double inverions]

[multiply out]ABC AB A CABC ABA ABC

= + ⋅ +

= + +

[ ]( )

ABC AB ABC A A AAC B B ABAC AB

= + + ⋅ =

= + +

[ 1]B B36

AC AB= + [ 1]( )

B BA C B

+ =

= +

• Example: Simplify Th i i l d i SOP f

z ABC ABC ABC= + +– The expression is already in SOP form

( )(1)

z AB C C ABCAB ABC

= + +

= +(1)

( )

AB ABCAB ABCA B BC

= +

= +

= +

Example: Simplify

( )( ) [by rule 11 in previous chapter]

A B BCA B C

= +

= +

( )( )x A B A B D D= + + +• Example: Simplify ( )( )x A B A B D D= + + +

[multiply out][ 0 d 0]

x AAD ABD ADD BAD BBD BDDABD BAD BD AA DD

= + + + + +

[ 0 and 0]( 1) [factoring]

ABD BAD BD AA DDBD A A

= + + = =

= + +

BD= [ 1 and 1+1=1]A A+ =

37

• Example: SimplifyFi t d it i t SOP f

( )z AC ABD ABCD ABC= + +– First expand it into SOP form

( ) [DeMorgan thm] [multiply out]

z AC A B D ABCD ABCACA ACB ACD ABCD ABC

= + + + +

= + + + +

– Then look for the largest common factor between any two or more product terms: first and last terms have , while the second and thirdBC

[ 0]ACB ACD ABCD ABC AA= + + + =

product terms: first and last terms have , while the second and third terms share

– Grouping the terms gives( ) ( )z BC A A AD C BC= + + +

BCAD

• We might think that the above expression is the simplest since it

( ) ( )( ) [by 1, ]

z BC A A AD C BCBC AD C B A A C BC C B

= + + +

= + + + = + = +

cannot be simplified further• However, in fact, the simplest form of this equation is• It turns out that we missed an operation earlier that could have led to

z ABD BC= +p

the simpler form• Question: How could we have known that we missed a step??• Ans: There is no way we can know This illustrate the frustration often

38

Ans: There is no way we can know. This illustrate the frustration often encountered in Boolean simplification

In conclusionIn conclusion…• All logic functions can be represented as

(1) truth table (2) schematics (3) Boolean expressions, interchangeably

• Laws of Boolean algebra helps to simplify the Boolean expressionp

• DeMorgan’s theorems• NAND/NOR gates are universal gates• NAND/NOR gates are universal gates• Non-standard representation is equivalent

t D M ’ thto DeMorgan’s theorems• Canonical SOP/POS

39

Recommended