eng241 digital design week #2 combinational logic circuits

96
ENG241 Digital Design Week #2 Combinational Logic Circuits

Upload: gladys-booth

Post on 13-Dec-2015

228 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: ENG241 Digital Design Week #2 Combinational Logic Circuits

ENG241 Digital Design

Week #2 Combinational Logic Circuits

Page 2: ENG241 Digital Design Week #2 Combinational Logic Circuits

Resources

Chapter #2, Mano Sections2.1 Logic Gates2.2 Boolean Algebra2.3 Min Terms & Max Terms2.4 Logic Optimization

2

Page 3: ENG241 Digital Design Week #2 Combinational Logic Circuits

Week #2 Topics

Binary Logic and Gates Boolean Functions Boolean Algebra (Truth Tables) Basic Identities Standard Forms (Minterms, Maxterms) Circuit Optimization (K-Maps) Map Manipulations (Prime Implicants)

3

Page 4: ENG241 Digital Design Week #2 Combinational Logic Circuits

Binary Logic

Binary variables Can be 0 or 1 (T or F, low or high) Variables named with single letters in

examples Really use words when designing circuits

Basic Functions AND OR NOT

4

Page 5: ENG241 Digital Design Week #2 Combinational Logic Circuits

5

Logic Signals

Binary ‘0’ is representedby a “low” voltage(range of voltages)

Binary ‘1’ is representedby a “high” voltage(range of voltages)

The “voltage ranges” guardagainst noise

of binary signalsExample

Page 6: ENG241 Digital Design Week #2 Combinational Logic Circuits

NOT Operator

Unary Operator Symbol is bar

Z = X Truth table -> Inversion

6

Page 7: ENG241 Digital Design Week #2 Combinational Logic Circuits

Inverter Gate

7

Page 8: ENG241 Digital Design Week #2 Combinational Logic Circuits

AND Gate

Symbol is dot Z = X.Y

Or no symbol Z = XY

Truth table -> Z is 1 only if

Both X and Y are 1

8

Switches in series => AND

Page 9: ENG241 Digital Design Week #2 Combinational Logic Circuits

9

Switching Circuits (AND Gate)

AND

AND Gate: Symbol

Page 10: ENG241 Digital Design Week #2 Combinational Logic Circuits

AND Gate: Timing

Timing Diagrams

10

Page 11: ENG241 Digital Design Week #2 Combinational Logic Circuits

OR Gate

Symbol is + Not addition Z = X + Y

Truth table -> Z is 1 if either 1

Switches in parallel => OR

11

Page 12: ENG241 Digital Design Week #2 Combinational Logic Circuits

12

Switching Circuits (OR Gate)

OR

OR Gate: Symbol

Page 13: ENG241 Digital Design Week #2 Combinational Logic Circuits

OR Gate: Timing

Timing Diagrams

13

Page 14: ENG241 Digital Design Week #2 Combinational Logic Circuits

14

Binary Logic

Truth Tables, Boolean Expressions, and Logic Gates

x y z

0 0 0

0 1 0

1 0 0

1 1 1

x y z

0 0 0

0 1 1

1 0 1

1 1 1

x z

0 1

1 0

AND OR NOT

xy z x

y z

z = x • y = x y z = x + y z = x = x’

x z

Page 15: ENG241 Digital Design Week #2 Combinational Logic Circuits

More Inputs

Work same way What’s output?

15

Page 16: ENG241 Digital Design Week #2 Combinational Logic Circuits

NAND Gates

Very common for discrete logic

16

Page 17: ENG241 Digital Design Week #2 Combinational Logic Circuits

NOR Gates

NOT OR Also common YX F

X Y Z

0 0

0 1

1 0

1 1

1

0

0

0

17

Page 18: ENG241 Digital Design Week #2 Combinational Logic Circuits

Logic Diagram Boolean Expression

Logic Diagram

18

ZY XF .

What is the Boolean expression?

Page 19: ENG241 Digital Design Week #2 Combinational Logic Circuits

Boolean Expression Logic Diagram

Consider function

XZZYX YZ X F

How many gates do we need to implement this function?

19

Page 20: ENG241 Digital Design Week #2 Combinational Logic Circuits

Boolean Operator Precedence

The order of evaluation in a Boolean expression is:

Consequence: Parentheses appear around OR expressions

Example: F = A(B + C)(C + D)

1. Parentheses 2. Not

3. And 4. Or

20

Page 21: ENG241 Digital Design Week #2 Combinational Logic Circuits

Mechanically Go From Truth Table to Function

Steps of design:1. Start with Problem Statement2. Obtain Truth Table3. Obtain a algebraic boolean function4. Draw the circuit diagram

Page 22: ENG241 Digital Design Week #2 Combinational Logic Circuits

Design Steps (Simple Example)

Specification: Design a circuit that has 3 inputs x, y, z

and a single output F. F is true when the three inputs are the same and false otherwise.

22

Page 23: ENG241 Digital Design Week #2 Combinational Logic Circuits

Design Steps (Simple Example)

Step #1, since we have three inputs then the Truth Table has to have 8 entries (23)

X Y Z F

0 0 0 1

0 0 1 0

0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 1

23

Page 24: ENG241 Digital Design Week #2 Combinational Logic Circuits

Design Steps (Simple Example)

Step #2, Pick the entries in the truth table where F is equal 1.

Give Expression:

X Y Z F

0 0 0 1

0 0 1 0

0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 1ZYXZYX F

24

Page 25: ENG241 Digital Design Week #2 Combinational Logic Circuits

Design Steps (Simple Example)

Step #3, Draw a logic diagram that represents the boolean functions.

X Y Z F

0 0 0 1

0 0 1 0

0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 1

ZYXZYX F

25

Page 26: ENG241 Digital Design Week #2 Combinational Logic Circuits

Representation: Truth Table

2n rowswhere n # ofvariables

ZYXZYXZYXZY XZ YX F

26

Give Boolean Expression?

Not Simplified!

Page 27: ENG241 Digital Design Week #2 Combinational Logic Circuits

Boolean Functions: Complexity

There can be different representations for a boolean function

Usually we want the simplest (Why?) Fewer gates (Less Area, Less Power

Consumption, Faster!)

We can use identities to reduce complexity of Boolean expressions.

27

Page 28: ENG241 Digital Design Week #2 Combinational Logic Circuits

Boolean Algebra & Identities

There is only one way that a Boolean function can be represented in a truth table.

However, when the function is in algebraic form, it can be expressed in a variety of ways.

Boolean algebra is a useful tool for simplifying digital circuits.

Use identities to manipulate functions

28

Page 29: ENG241 Digital Design Week #2 Combinational Logic Circuits

Table of Identities

29

Page 30: ENG241 Digital Design Week #2 Combinational Logic Circuits

Dual of an Expression

The dual of an expression is obtained by:

1. Changing AND to OR and OR to AND throughout

2. Changing 1’s to 0’s and 0’s to 1’s

For example The dual of X+0 is:

• X.1, The dual of X.0 is:

• X+130

Page 31: ENG241 Digital Design Week #2 Combinational Logic Circuits

Duals

Left and right columns are duals

31

Page 32: ENG241 Digital Design Week #2 Combinational Logic Circuits

Single Variable Identities

32

Page 33: ENG241 Digital Design Week #2 Combinational Logic Circuits

Commutative

Order independent

33

Page 34: ENG241 Digital Design Week #2 Combinational Logic Circuits

Associative

Independent of order in which we group

So can also be written asand ZYX

34

Page 35: ENG241 Digital Design Week #2 Combinational Logic Circuits

Distributive

Identity 15 is the dual of identity 14.

Identity 14 is well known from ordinary algebra!

35

Page 36: ENG241 Digital Design Week #2 Combinational Logic Circuits

DeMorgan’s Theorem

Used a lot NOR equals invert AND

NAND equals invert OR

36

Proof?

Page 37: ENG241 Digital Design Week #2 Combinational Logic Circuits

Truth Tables for DeMorgan’s

37

Page 38: ENG241 Digital Design Week #2 Combinational Logic Circuits

Useful Theorems

ninimizatioMyyyx =××

( ) tionSimplifica yxyxyxyx ×=+×+=×+

Absorption xyxxxyxx

Consensuszyxzyzyx ×+×=×+×+×( ) ( ) ( ) ( ) ( )zyxzyzyx +×+=+×+×+

+x

x x

x x

x x

38

Page 39: ENG241 Digital Design Week #2 Combinational Logic Circuits

Example 1: Boolean Algebraic Proof

A + A·B = A (Absorption Theorem)

Proof Steps Justification (identity or theorem)

A + A·B

= A · 1 + A · B X = X · 1 = A · ( 1 + B) X · Y + X · Z = X ·(Y + Z)

= A · 1 1 + X = 1

= A X · 1 = X

39

Page 40: ENG241 Digital Design Week #2 Combinational Logic Circuits

Cont .. Boolean Algebraic Proof

Our primary reason for doing proofs is to learn:

Careful and efficient use of the identities and theorems of Boolean algebra, and

How to choose the appropriate identity or theorem to apply to make forward progress, irrespective of the application.

40

Page 41: ENG241 Digital Design Week #2 Combinational Logic Circuits

Algebraic Manipulation

XZZYX YZ X F

When a Boolean equation is implemented with logic gates,

i. Each term requires a gate,

ii. Each variable designates an input to the gate.

We define a literal as a single variable within a term that may or may not be complemented.

The expression above has THREE terms and EIGHT literals.

41

Page 42: ENG241 Digital Design Week #2 Combinational Logic Circuits

Algebraic Manipulation

Consider function

XZZYX YZ X F

How many gates do we need to implement this function?

42

Page 43: ENG241 Digital Design Week #2 Combinational Logic Circuits

Simplify Function

XZZYX YZ X F

XZZ Z YX F )(

XZYX F 1

XZYX F

Apply

Apply

Apply

End Result?

43

Page 44: ENG241 Digital Design Week #2 Combinational Logic Circuits

Fewer Gates

XZYX F

1. Fewer Gates!

2. Fewer Inputs per gate!

44

Page 45: ENG241 Digital Design Week #2 Combinational Logic Circuits

The Duality Principle

YXYXX

• Recall how to obtain the dual of an expression!

• The duality principle states that a Boolean equation remains valid if we take the dual of the expression on both sides of the equal sign.

XYYXX )(

45

Page 46: ENG241 Digital Design Week #2 Combinational Logic Circuits

1. Complement of a Function

X Y Z F F0 0 0 0 1

0 0 1 1 0

0 1 0 1 0

0 1 1 0 1

1 0 0 0 1

1 0 1 0 1

1 1 0 0 1

1 1 1 0 1

ZYXZYXZYXZYXZYXZYXF

ZYXZYXF

The complement representation for a function F, (F’), is obtained from an interchange of 1’s to 0’s and 0’s to 1’s for the values of F in the truth table.

46

Page 47: ENG241 Digital Design Week #2 Combinational Logic Circuits

2. Cont ..Complement of a Function

The complement of a function can be derived algebraically by applying DeMorgan’s theorem.

ZYXZYXF ZYXZYXF )(.)( ZYXZYXF

))(( ZYXZYXF

47

Page 48: ENG241 Digital Design Week #2 Combinational Logic Circuits

3. Cont ..Complement of a Function

Yet another way of deriving the complement of a function is to: Take the dual of the function equation Complement each literal.

)()( ZYXZYXF ZYXZYXF )).(( ZYXZYXDual

)).(( ZYXZYXF

48

Page 49: ENG241 Digital Design Week #2 Combinational Logic Circuits

ENG241 Digital Design

Cont ..Week #2 Combinational Logic Circuits

Page 50: ENG241 Digital Design Week #2 Combinational Logic Circuits

Resources

Chapter #2, Mano Sections 2.3 Standard Forms 2.4 Circuit Optimization (K-Maps)

50

Page 51: ENG241 Digital Design Week #2 Combinational Logic Circuits

Week #2, #3 Topics

Standard Forms (Minterms, Maxterms) Circuit Optimization (K-Maps) Map Manipulations (Prime Implicants)

51

Page 52: ENG241 Digital Design Week #2 Combinational Logic Circuits

From Truth Table to Function

Consider a truth table Can implement F by

taking OR of all terms that are 1

ZYXZYXZYXZY XZ YX F

Z YX F

52

XZY optimizedF )(

MinTerm

Product Term

Page 53: ENG241 Digital Design Week #2 Combinational Logic Circuits

Standard Forms

Assume we have a circuit with 3 variables X, Y, Z

Definitions: Product Term – a subset of the variables

appear XY, XZ, XZ’, XYZ Min Term – is a product term in which all

variables appear once (XYZ, X’YZ, X’Y’Z’)

53

Page 54: ENG241 Digital Design Week #2 Combinational Logic Circuits

Number of Minterms

For n variables, there will be 2n minterms

Like binary numbers from 0 to 2n-1

54

Page 55: ENG241 Digital Design Week #2 Combinational Logic Circuits

Definition: Minterm

Is a Product Term in which ALL variables appear once (complemented or not)

55

Page 56: ENG241 Digital Design Week #2 Combinational Logic Circuits

Sum of Minterms (SOM)

OR all of the minterms of truth table row with a 1

ZXYZYXYZXZYXF

ZYXZYXZYXZYX F

In this case m1 + m3 + m4 + m6

In this case m0+m2+m5+m7

56

m0

m1

m2

m3m4

m5

m6

m7

Page 57: ENG241 Digital Design Week #2 Combinational Logic Circuits

Alternative Representation

ZYXZYXZYXZYXF ........

ZYXZYXZYXZYX F ........

In this case m1 + m3 + m4 + m6

In this case m0+m2+m5+m7

)7,5,2,0(),,( mZYXF

)6,4,3,1(),,( mZYX F

57

Page 58: ENG241 Digital Design Week #2 Combinational Logic Circuits

Summary of Properties of Minterms

There are 2n minterms for a Boolean function with n variables

Any Boolean function can be expressed as a logical sum of minterms

The complement of a function contains those minterms not included in the original function.

A function that includes all the 2n minterms is equal to logic 1.

58

Page 59: ENG241 Digital Design Week #2 Combinational Logic Circuits

Sum of Products (SOP)

The sum-of-minterms form is a standard algebraic expression that is obtained directly from a truth table.

The expression obtained contains the maximum number of literals in each term.

Simplification of the sum-of-minterms expression is called sum-of-products.

59

Page 60: ENG241 Digital Design Week #2 Combinational Logic Circuits

SOM vs. SOP

ZYXZYXZYXZYX F

Sum of minterms

After Simplification we get the Sum of products

ZXZX F ..

60

Page 61: ENG241 Digital Design Week #2 Combinational Logic Circuits

Sum of Products Implementation

Sum of products

XYZYXYF

We refer to this implementation as a two-level circuit

61

Page 62: ENG241 Digital Design Week #2 Combinational Logic Circuits

2-level Implementation

Sum of products has 2 levels of gates

Is there a 3-level rep of this circuit?

62

Page 63: ENG241 Digital Design Week #2 Combinational Logic Circuits

2-level vs. 3-level Implementation

AB + CD + CE can be

Also expressed as

AB + C(D+E)

What’s best? • Hard to answer!!• More gate delays?• But maybe we only have 2-input gates

63

Page 64: ENG241 Digital Design Week #2 Combinational Logic Circuits

Definition: Maxterm

Is a Sum Term in which all variables appear once (complemented or not)

64

Page 65: ENG241 Digital Design Week #2 Combinational Logic Circuits

Minterm related to Maxterm

Minterm and maxterm with same subscripts are complements

Example (Use Demorgans theory)

33 MZYXYZXm

Mjm j

65

YZXm 3

Page 66: ENG241 Digital Design Week #2 Combinational Logic Circuits

Product of Maxterms

6431 MMMMF

))(( ZYXZYXF

))(( ZYXZYX

We can also express F as AND of all rows that should evaluate to 0

)6,4,3,1(),,( MZYXF

66

M0

M1

M2

M3

M4

M5

M6

M7

Page 67: ENG241 Digital Design Week #2 Combinational Logic Circuits

Two-Level Circuit Optimization

The complexity of the digital logic gates that implement a Boolean function is directly related to the algebraic expression from which the function is implemented!!

Boolean expressions may be simplified by algebraic manipulation (i.e. identities) but it is awkward and not straight forward!

67

Page 68: ENG241 Digital Design Week #2 Combinational Logic Circuits

Karnaugh Maps

Graphical depiction of truth table A box for each minterm

So 2 variables, 4 boxes 3 variable, 8 boxes And so on

Useful for simplification By inspection Algebraic manipulation harder

68

Page 69: ENG241 Digital Design Week #2 Combinational Logic Circuits

Examples

YXXYYXYXF

69

There are implied 0s in other boxes Figure (b) F = m1 + m2 + m3

Page 70: ENG241 Digital Design Week #2 Combinational Logic Circuits

Simplification

)( YYXYX

XYYXYXF

)1(XYX

YX

70

Page 71: ENG241 Digital Design Week #2 Combinational Logic Circuits

Three-Variable Map

Eight minterms Look at encoding of columns and rows

71

Page 72: ENG241 Digital Design Week #2 Combinational Logic Circuits

Simplification

Adjacent squares (horizontally or vertically) are minterms that vary by single variable

Draw rectangles on map to simplify function

Illustration next

72

Page 73: ENG241 Digital Design Week #2 Combinational Logic Circuits

How to obtain a simplified expression?

Combine as many 1’s as possible from the map to form rectangle

Only adjacent 1’s can be combined vertically or horizontally but not diagonally.

The number of 1’s that can be combined is a power of 2, (20=1, 21=2, 22=4, 23=8), …

73

Page 74: ENG241 Digital Design Week #2 Combinational Logic Circuits

Example

ZYXZYXYZXZYXF

X Y Z F

0 0 0 0

0 0 1 0

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 1

1 1 0 0

1 1 1 0YXYXF

74

Page 75: ENG241 Digital Design Week #2 Combinational Logic Circuits

Example

ZYXZYXYXF

YXYXF

75

X

YZ00 1101 10

0

1

ZYXZYXZYXYZXF

11

1 1

Page 76: ENG241 Digital Design Week #2 Combinational Logic Circuits

Adjacency is Cylindrical

Note that wraps from left edge to right edge.

Z

76

Page 77: ENG241 Digital Design Week #2 Combinational Logic Circuits

Another Minimization Example

Each of the two adjacent pairs of entries can be simplified by eliminating the changing bit. x is eliminated in

column 2 y is eliminated in the

other pair. F = y’z + x’z’

77

Page 78: ENG241 Digital Design Week #2 Combinational Logic Circuits

Covering 4 Squares

is

ZYXZYXZYXZYXF

ZXZXF ZF

78

Page 79: ENG241 Digital Design Week #2 Combinational Logic Circuits

Another Example

In general, as more squares are combined, we obtain a product term with fewer literals.

Overlap is allowed.

79

Page 80: ENG241 Digital Design Week #2 Combinational Logic Circuits

4-variable map

At limit of K-map

80

Page 81: ENG241 Digital Design Week #2 Combinational Logic Circuits

Also Wraps (toroidal topology)

81

Page 82: ENG241 Digital Design Week #2 Combinational Logic Circuits

Simplifying a 4-Variable Function

)14,13,12,9,8,6,5,4,2,1,0(),,,( mZYXWF

1 1 1

1 1 1

1 1 1

1 1

WXYZ

00

01

11

10

00 01 11 10

Y

W Z

X Z

82

Page 83: ENG241 Digital Design Week #2 Combinational Logic Circuits

Don’t Care

So far we have dealt with functions that were always either 0 or 1

Sometimes we have some conditions where we don’t care what result is

Example: dealing with BCD Only care about first 10

83

Page 84: ENG241 Digital Design Week #2 Combinational Logic Circuits

Mark With an `X’

In a K-map, mark don’t care with an ‘X’

Simpler implementations Can select an X either as 1 or 0 Example:

84

)5,2,0(),15,11,7,3,1(),,,( dmDCBAF

Page 85: ENG241 Digital Design Week #2 Combinational Logic Circuits

Example

or

What would we have if Xs were 0?85

)5,2,0(),15,11,7,3,1(),,,( dmDCBAF

Page 86: ENG241 Digital Design Week #2 Combinational Logic Circuits

Prime Implicants

Each element in the K-Map is an implicant. A prime implicant is a product term obtained by

combining the maximum possible number of adjacent squares in the map. A single 1 on a map represents a prime implicant

if it is not adjacent to any other 1. Two adjacent 1’s form a prime implicant, provided

they are not within a group of four adjacent squares.

Four adjacent 1’s form a prime implicant if they are not within a group of eight adjacent squares, and so on.

If a minterm in a square is covered by only one prime implicant, that prime implicant is said to be essential. They are found by looking at each square marked

with a 1 and checking the number of prime implicants that cover it. Those with only one prime implicant are essential.

86

Page 87: ENG241 Digital Design Week #2 Combinational Logic Circuits

Implicant/Prime Implicant/EssentialConsider: { , , , , , }onf b d abc bd acd abc bcd

• Each Element of fon is an Implicant• Prime Implicants are:

{ , , , , }b d abc bd acd abc

• abc is a Prime Implicant but NOT anEssential Prime Implicant

• bcd is an Implicant but NOT aPrime Implicant

• bd is an Essential Prime Implicant

87

Page 88: ENG241 Digital Design Week #2 Combinational Logic Circuits

Finding Simplified Expressions

The procedure for finding simplified expressions is

1. Determine all essential prime implicants.2. The final expression is formed from the logical sum of:

I. The essential prime implicants, with II. Other prime implicants needed to cover the remaining

minterms

There may be more than one simplified expression.

88

Page 89: ENG241 Digital Design Week #2 Combinational Logic Circuits

Prime Implicants: Example

Two essential prime implicants (caused by m0 and m5) This gives us two terms: x’z’ and xz

Finding prime implicants for the remainders results in four expressions: F = xz + x’z’ + yz + wz F = xz + x’z’ + yz + wx’ F = xz + x’z’ + x’y + wz F = xz + x’z’ + x’y + wx’

89

Page 90: ENG241 Digital Design Week #2 Combinational Logic Circuits

H.-H. S. Lee

Essential Prime Implicants

0 2 4 6 7 8 10

11

12

13

14

16

18

19

29

30

(6,7) X X

(10,11) X X

(12,13) X X

(18,19) X X

(13,29) X X

(14,30) X X

(0,2,16,18) X X X X

(0,2,4,6,8,10,12,14)

X X X X X X X X

30) 29, 19, 18, 16, 14, 13, 12, 11, 10, 8, 7, 6, 4, 2, m(0,E)D,C,B,F(A,

Prime Implicants

Page 91: ENG241 Digital Design Week #2 Combinational Logic Circuits

91

Page 92: ENG241 Digital Design Week #2 Combinational Logic Circuits

Consensus Theorem

The third term is redundant Can just drop

What does it mean? For third term to be true, Y & Z both 1 Then one of the first two terms must be

1!

ZXXYYZZXXY

92

Page 93: ENG241 Digital Design Week #2 Combinational Logic Circuits

Proof of Consensus Theorem

)( XXYZZXXY

YZXXYZZXXY

YZXZXXYZXY

YZZXXY

)1()1( YZXZXY

ZXXY

93

Page 94: ENG241 Digital Design Week #2 Combinational Logic Circuits

Three Variable Maps

Three variable maps exhibit the following characteristics:

1. One box represents minterm with 3 literals

2. Rectangle of 2 boxes -> 2 literals3. Rectangle of 4 boxes -> 1 literal4. Rectangle of 8 boxes -> Logic 1 (on 3-

variable map)

94

Page 95: ENG241 Digital Design Week #2 Combinational Logic Circuits

Slight Variation

Overlap is OK. No need to use full m5-- waste of input

95

Page 96: ENG241 Digital Design Week #2 Combinational Logic Circuits

Another Example

Four adjacent corners can be combined to form the two literal term x’z’.

Four adjacent squares can be combined to form the two literal term x’y.

The remaining 1 is combined with a single adjacent 1 to obtain the three literal term w’y’z’.

F = x’z’ + x’y + w’y’z’96