Top Banner
Lecture 3 (b) Page 1 CS031 CS31 Pascal Van Hentenryck Karnaugh Maps
25

Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Apr 30, 2019

Download

Documents

buithien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) Page 1CS031

CS31Pascal Van Hentenryck

Karnaugh Maps

Page 2: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 2CS031

Overview

Karnaugh Maps• Simplifying Boolean functions

Page 3: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 3CS031

The Big Picture

Page 4: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 4CS031

Abstraction Hierarchy

Programming Language

Assembly Language

Machine Language

Sequential Circuit

Combinational Circuit

Binary Value

Voltage

Programming Language

Assembly Language

Machine Language

Sequential Circuit

Combinational Circuit

Binary Value

Voltage

Page 5: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 5CS031

Minimizing BooleanFunctions

The problem• Given a truth table, find a small circuit

to compute it• The problem is very hard in general

(no really efficient algorithm exists)Possible solutions

• Put the function as a sum of productsand build the corresponding circuit

• Put the function as product of sumsand build the corresponding circuit

Limitation• The size of the circuit may be far from

the minimal sizeKarnaugh Maps

• A manual and heuristic method tominimize the size of the circuit

Page 6: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 6CS031

Karnaugh Map

Another Presentation of a Truth Table

The Karnaugh map looks like this

Page 7: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 7CS031

Karnaugh Map

3 variables

4 variables

Page 8: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 8CS031

Karnaugh Maps

Property• Adjacent entries differ by at most one

variable

• The whole table is wrapping up onitself. The end of a row is adjacent tothe beginning of the row and so on.

Page 9: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 9CS031

BoxesBoxes of sizes 1,2,4,8 or 16

Page 10: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 10CS031

Minimization

The basic strategy1. Draw the Karnaugh map2. Fill it with the truth table3. Cover all the 1s with boxes of size 1, 2, 4, 8,

16. ... (an entry can be covered by severalboxes if needed)

4. Generate a product for each box; eachelement of the product corresponds to avariable which stays constant over the box. Itis the variable if the variable stays at 1 andthe negation of the variable otherwise.

5. The result is the sum of all these products

The main goal• As few boxes as possible• The biggest possible boxes

Page 11: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 11CS031

A simplification

Another Presentation of a Truth Table

The Karnaugh map looks like this

What is the boolean function?

Page 12: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 12CS031

A simplification

Another Presentation of a Truth Table

The Karnaugh map looks like this

What is the boolean function?f(a,b)=a’

Page 13: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 13CS031

Another Simplification Problem

Sum of Products gives us:

Page 14: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 14CS031

Another Simplification Problem

Sum of Products gives us:f(x,y,z) = x’yz + xy’z’ + xyz’ + xyz

Karnaugh map:

Page 15: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 15CS031

Another Simplification Problem

Sum of Products gives us:f(x,y,z) = x’yz + xy’z’ + xyz’ + xyz

Karnaugh map:

f(x,y,z) = yz + xz’

Page 16: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 16CS031

A Really Big One

Page 17: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 17CS031

Don’t CaresSometimes, it doesn’t matter exactlywhich output is generated in a certainsituation.A don’t care value is represented by ax and we can choose any value thatis convenient to us.

What do we choose?By setting the left and right x’s to 1 wecan make a 2x2 square, reducing thefunction to: f(x,y,z)=z’

Page 18: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 18CS031

Don’t CaresSometimes, it doesn’t matter exactlywhich output is generated in a certainsituation.A don’t care value is represented by ax and we can choose any value thatis convenient to us.

What do we choose?By setting the left and right x’s to 1 wecan make a 2x2 square, reducing thefunction to: f(x,y,z)=z’

1

1

Page 19: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 19CS031

We Still Don’t Care!

What if the x’s were 0’s?

f(w,x,y,z)=(w’x’y) + (w’xz) + (xyz)

Page 20: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 20CS031

We Still Don’t Care!

What if the x’s were 0’s?f(w,x,y,z)=(w’x’y) + (w’xz) + (xyz)

What if they’re don’t cares?

Page 21: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 21CS031

We Still Don’t Care!

What if the x’s were 0’s?f(w,x,y,z)=(w’x’y) + (w’xz) + (xyz)

What if they’re don’t cares?f(w,x,y,z)=(x’y) + (xz)

How many operations do we save?Including negations, 11-4=7

Page 22: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 22CS031

Half Adder Given two inputs, generate the sum and carry.

Page 23: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 23CS031

Full Adder

Add three inputs, generating the sum and carry.

Page 24: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 24CS031

Simplification for FA

Karnaugh map for S

Karnaugh map for C

Page 25: Karnaugh Maps - s3.amazonaws.com · CS031 Lecture 3 (b) 10 Minimization The basic strategy 1. Draw the Karnaugh map 2. Fill it with the truth table 3. Cover all the 1s with boxes

Lecture 3 (b) 25CS031

Chaining AddersWe can add two 4-bit numbers

by chaining full adders.FAFAFAFA0x0y0y2x2y2x2y1x1S0S1S2S3C

FA

FA

FA

FA

0x0y0

x1

x2

x3

y1

y2

y3

S0

S1

S2

S3

C