karnaugh maps - s3.amazonaws.com · cs031 lecture 3 (b) 10 minimization the basic strategy 1. draw...

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

Upload: buithien

Post on 30-Apr-2019

219 views

Category:

Documents


0 download

TRANSCRIPT

Lecture 3 (b) Page 1CS031

CS31Pascal Van Hentenryck

Karnaugh Maps

Lecture 3 (b) 2CS031

Overview

Karnaugh Maps• Simplifying Boolean functions

Lecture 3 (b) 3CS031

The Big Picture

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

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

Lecture 3 (b) 6CS031

Karnaugh Map

Another Presentation of a Truth Table

The Karnaugh map looks like this

Lecture 3 (b) 7CS031

Karnaugh Map

3 variables

4 variables

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.

Lecture 3 (b) 9CS031

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

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

Lecture 3 (b) 11CS031

A simplification

Another Presentation of a Truth Table

The Karnaugh map looks like this

What is the boolean function?

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’

Lecture 3 (b) 13CS031

Another Simplification Problem

Sum of Products gives us:

Lecture 3 (b) 14CS031

Another Simplification Problem

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

Karnaugh map:

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’

Lecture 3 (b) 16CS031

A Really Big One

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’

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

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)

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?

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

Lecture 3 (b) 22CS031

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

Lecture 3 (b) 23CS031

Full Adder

Add three inputs, generating the sum and carry.

Lecture 3 (b) 24CS031

Simplification for FA

Karnaugh map for S

Karnaugh map for C

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