PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3...

47
PHY 201 (Blum) 1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

Transcript of PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3...

Page 1: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 1

Karnaugh Maps

References:Chapters 4 and 5 in Digital Principles (Tokheim)Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

Page 2: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 2

Review: Expressing truth tables Every truth table can be expressed in terms

of the basic Boolean operators AND, OR and NOT operators. E.g. using sum of products or product of sums.

The circuits corresponding to those truth tables can be build using AND, OR and NOT gates, which can be made out of transistors.

In the sum of products approach, the input in each line of a truth table can be expressed in terms of AND’s and NOT’s (though we will only need the rows that have 1 as an output).

Page 3: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 3

Algebra Gate A’ means NOT A

high

low

high input

low output

Red probe indicator

Page 4: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 4

Algebra Gates AB means A AND B

Page 5: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 5

Algebra Gates A+B means A OR B

Page 6: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 6

Review: Line by Line

InputsExpression

A B

0 0 (Not A) AND (NOT B) A´B´ A´B´ is true for the first

line and false for the rest

0 1 (Not A) AND B A´B A´B is true for the second

line and false for the rest

1 0 A AND (NOT B) AB´ AB´ is true for the third

line and false for the rest

1 1 A AND B AB A´B´ is true for the fourth line and false for the rest

This is not yet a truth table. It has no outputs.

Page 7: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 7

Writing the expression To express a truth table as a sum of

products (minterm expression), take the input lines that correspond to true (high, 1) outputs.

Write the expressions for each of those input lines (as shown on the previous slide). This step will involve NOTs and ANDs

Then feed all of those expressions into an OR gate.

Page 8: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 8

Example 1

A B C Out

0 0 0 1

0 0 1 0

0 1 0 1

0 1 1 0

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

Page 9: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 9

Example 1 (Cont.) A’B’C’ + A’BC’ + AB’C + ABC The expression one arrives at in this

way is known as the sum of products. You take the product (the AND operation)

first to represent a given line. Then you sum (the OR operation) together

those expressions. It’s also called the minterm

expression.

Page 10: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 10

Simplifying Boolean algebra expressions Recall that (A’B’C + A’BC’ + A’BC + AB’C’ +

AB’C + ABC’ + ABC) and (A+B+C) correspond to the same truth table.

Before building a circuit that realizes a Boolean expression, we would like to simplify that expression as much as possible.

Fewer gates means Fewer transistors Less space required Less power required (less heat generated) More money made

Page 11: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 11

A few fundamental theorems A + 1 = 1 A + 0 = A A·1 = A A·0= 0

A + A = A A·A = A A + A’ = 1 A·A’ = 0

Page 12: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 12

A Trivial Simplification Example A B C Out Expressions

0 0 0 0

0 0 1 0

0 1 0 1 A’ B C’

0 1 1 1 A’ B C

1 0 0 0

1 0 1 0

1 1 0 1 A B C’

1 1 1 1 A B C

Page 13: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 13

Simplifying a trivial example A´BC´ + A´BC + ABC´ + ABC A´B (C´ + C) + AB (C´ + C) A´B + AB (A´ + A) B B

C+C’ means C OR (NOT C)

In other words, we don’t care about C

Page 14: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 14

How simplification occurs Note that simplification occurs when two

terms differ by only one factor. For example, the terms A´BC´ and A´BC have

A’B in common and differ only in the C factor. A’BC’ + A’BC A’B(C’+C) A’B

If the two terms differ by more than one factor, there is no simplification For example, the terms A’BC’ and A’B’C have

A’ in common and differ in the B and C factors A’BC’ + A’B’C A’(BC’ + B’C) no

simplification

Page 15: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 15

Majority Rules Example

A B C Majority

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 1

1 1 1 1

Page 16: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 16

Row Expressions

A B C Row expressions

0 0 0 A’B’C’

0 0 1 A’B’C

0 1 0 A’BC’

0 1 1 A’BC

1 0 0 AB’C’

1 0 1 AB’C

1 1 0 ABC’

1 1 1 ABC

Page 17: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 17

Majority rules (sum of products) without simplification

A´BC + AB´C + ABC´ + ABCNOTs

ANDs

OR

Page 18: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 18

Majority Rules: Boolean Algebra Simplification

A´BC + AB´C + ABC´ + ABC The term A’BC can be combined with ABC

since they differ by one and only one term Same for AB’C and ABC Same for ABC’ and ABC In logic, ABC = ABC + ABC + ABC

A´BC+AB´C+ABC´+ABC+ABC+ABC A´BC+ABC + AB´C+ABC + ABC´+ABC (A´+A)BC + A(B´+B)C + AB(C´+C) BC + AC + AB

Page 19: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 19

Majority rules after simplification

Page 20: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 20

Majority Rules Comparison

Gates: 3 NOTs, 4 3-input ANDs, 1 4-input OR

Gates: 0 NOTs, 3 2-input ANDs, 1 3-input OR

Page 21: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 21

Simplifying made easy Simplifying Boolean expressions is

not always easy. So we introduce next a method (a

Karnaugh or K map) that is supposed to make simplification more visual.

The first step is to rearrange the inputs into what is called “Gray code” order. Here, Gray is a guy not a color.

Page 22: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 22

Frank Gray in Wikipedia

Page 23: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 23

Page 24: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 24

Gray code In addition to binary numbers, there is

another way of representing numbers using 1’s and 0’s. Put another way, there is another useful

ordering of the combinations of 1’s and 0’s. It is not useful for doing arithmetic, but

has other purposes. In gray code the numbers are ordered

such that consecutive numbers differ by one bit only.

Page 25: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 25

Gray code (Cont.)

0 0 0

0 0 1

0 1 1

0 1 0

1 1 0

1 1 1

1 0 1

1 0 0

Each row different by one bit only

Page 26: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 26

Constructing Gray code (a.k.a. reflected binary code)

0

1

Page 27: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 27

Reflect lower bits and add 0’s in front of the original rows and 1’s in front of the new

rows

0 0

0 1

1 1

1 0

Lower bits

Reflect lower bits through red line

Add 0’s

Add 1’s

Page 28: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 28

Reflect lower bits and 0’s then 1’s in front (again)

0 0 0

0 0 1

0 1 1

0 1 0

1 1 0

1 1 1

1 0 1

1 0 0

Reflect lower bits through red line

Add 0’s

Add 1’s

Page 29: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 29

An important property In gray-code order, two consecutive

rows of a truth table differ by one bit only.

Thus if a truth table is put in gray code order and if two consecutive rows contain a 1, then a simplification of the Boolean expression is possible. A term like X + X’ can be factored out.

Page 30: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 30

Trivial Example in Gray code

A B C Out

0 0 0 0

0 0 1 0

0 1 1 1

0 1 0 1

1 1 0 1

1 1 1 1

1 0 1 0

1 0 0 0

Note: Gray code ordered inputs

Page 31: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 31

Improving Some combinations that differ

only by a single bit are not in consecutive rows.

Thus there may be a simplification associated with such a combination and we might miss it.

So we put some of the inputs in as columns.

Page 32: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 32

Two rows that differ by one bit but are not consecutive

A B C Out

0 0 0 0

0 0 1 0

0 1 1 1

0 1 0 1

1 1 0 1

1 1 1 1

1 0 1 0

1 0 0 0

Page 33: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 33

A row-column version

A B\C 0 1

0 0 0 0

0 1 1 1

1 1 1 1

1 0 0 0

Place the C inputs across the top.

All inputs are filled in with light blue.

In this version, more inputs differing by one bit only are in adjacent positions.

This output corresponds to the input A=0, B=1 and C=0

Page 34: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 34

Karnaugh-map This way of arranging truth tables

combined with the rules for simplifying Boolean expressions goes by the name Karnaugh map or K map. Named for Maurice Karnaugh.

Page 35: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 35

Maurice Karnaugh

Page 36: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 36

The rules Put the truth table into a form with inputs in

Gray code order. Then one identifies output “blocks” (as large

as possible). A block must be a rectangle containing

1’s and only 1’s. The simplification rules require that the

number of 1’s in a block should be a power of 2 (1, 2, 4, 8, …).

However, a given output 1 can belong to more than one block.

Page 37: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 37

Wrapping There are still cases in which

inputs differing by only one bit are not adjacent (e.g. the first and last row).

Imagine that the rows wrap around, so for instance, a block can include the top and bottom rows (without intermediate rows).

Similarly for columns.

Page 38: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 38

W X Y Z Output

0 0 0 0 1

0 0 0 1 0

0 0 1 0 0

0 0 1 1 0

0 1 0 0 1

0 1 0 1 1

0 1 1 0 1

0 1 1 1 0

1 0 0 0 1

1 0 0 1 0

1 0 1 0 0

1 0 1 1 0

1 1 0 0 1

1 1 0 1 1

1 1 1 0 1

1 1 1 1 0

Karnaugh Example

Page 39: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 39

Karnaugh Example (Unsimplified Boolean algebra expression)

WXY’Z + W’XY’Z + WX’Y’Z’ + W’X’Y’Z’ + WXYZ’ + WXY’Z’ + W’XY’Z’ + W’XYZ’

Page 40: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 40

Example in Karnaugh (identifying block in gray code truth table)

Z 0 1 1 0

W X\Y 0 0 1 1

0 0 1W’X’Y’Z’

0 0 0

0 1 1W’XY’Z’

1W’XY’Z

0 1W’XYZ’

1 1 1WXY’Z’

1WXY’Z

0 1WXYZ’

1 0 1WX’Y’Z’

0 0 0

Page 41: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 41

For Yellow Group: W and X inputs change; Y and Z inputs don’t change from zeros. Group represented by

Y’Z’ Z 0 1 1 0

W X\Y 0 0 1 1

0 0 1W’X’Y’Z’

0 0 0

0 1 1W’XY’Z’

1W’XY’Z

0 1W’XYZ’

1 1 1WXY’Z’

1WXY’Z

0 1WXYZ’

1 0 1WX’Y’Z’

0 0 0

Page 42: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 42

For Red Group: W and Z inputs change; X input does not change from 1; Y input does not change from 0. Group

represented by XY’ Z 0 1 1 0

W X\Y 0 0 1 1

0 0 1W’X’Y’Z’

0 0 0

0 1 1W’XY’Z’

1W’XY’Z

0 1W’XYZ’

1 1 1WXY’Z’

1WXY’Z

0 1WXYZ’

1 0 1WX’Y’Z’

0 0 0

Page 43: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 43

For Green group: W and Y inputs change; X input does not change from 1; Z input does not change from 0. Group represented by XZ’

Z 0 1 1 0

W X\Y 0 0 1 1

0 0 1W’X’Y’Z’

0 0 0

0 1 1W’XY’Z’

1W’XY’Z

0 1W’XYZ’

1 1 1WXY’Z’

1WXY’Z

0 1WXYZ’

1 0 1WX’Y’Z’

0 0 0

Page 44: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 44

Result Y’Z’ + XY’ + X Z’ A block of size two eliminates one Boolean

variable; a block of four eliminates two Boolean variables; and so on.

To find the expression for a block, identify the inputs for that block that don’t change, AND them together, that’s your expression for the block.

Obtain an expression for each block and OR them together. Every 1 must belong to at least one block (even if it is a block onto itself).

Page 45: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 45

From Binary order to Gray code order

Page 46: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 46

From Binary order to Gray code order

Page 47: PHY 201 (Blum)1 Karnaugh Maps References: Chapters 4 and 5 in Digital Principles (Tokheim) Chapter 3 in Introduction to Digital Systems (Palmer and Perlman)

PHY 201 (Blum) 47

Online References http://www.facstaff.bucknell.edu/

mastascu/eLessonsHTML/Logic/Logic3.html

http://www.cs.usm.maine.edu/~welty/karnaugh.htm

http://en.wikipedia.org/wiki/Frank_Gray_(researcher)

http://en.wikipedia.org/wiki/Maurice_Karnaugh