seacucumber: a syntheszing compiler

51
Karnaugh-Maps September 14, 2006 – Typeset by Foil T E X

Upload: others

Post on 12-May-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SeaCucumber: A Syntheszing Compiler

Karnaugh-Maps

September 14, 2006

– Typeset by FoilTEX –

Page 2: SeaCucumber: A Syntheszing Compiler

What are Karnaugh Maps?

A simpler way to handle most (but not all) jobs of manipulatinglogic functions.

– Typeset by FoilTEX – 1

Page 3: SeaCucumber: A Syntheszing Compiler

What are Karnaugh Maps?

A simpler way to handle most (but not all) jobs of manipulatinglogic functions.

Hooray!!

– Typeset by FoilTEX – 2

Page 4: SeaCucumber: A Syntheszing Compiler

Karnaugh Map Advantages

• Can be completed more systematically

• Much simpler to find minimum solutions

• Easier to see what is happening (graphical)

• Almost always use instead of boolean minimization...

– Typeset by FoilTEX – 3

Page 5: SeaCucumber: A Syntheszing Compiler

Truth Table Adjacencies

F = A’

A B F

0 0 1

0 1 1

1 0 0

1 1 0

��������9

These are adjacent in a gray code

sense – they differ by only one bit.

We can apply XY + XY’ = X

A’B’ + A’B = A’(B’+B) = A’(1)

= A’

F = B

A B F

0 0 0

0 1 1

1 0 0

1 1 1

XXXXXXXXy

��������9

Same idea:

A’B + AB = B

– Typeset by FoilTEX – 4

Page 6: SeaCucumber: A Syntheszing Compiler

Truth Table Adjacencies

Key Idea:

Gray code adjacency allows use of simplification theorem

(e.g., XY + XY’ = X).

Problem:

Physical adjacency in truth table is not equal to gray code adjacency.

– Typeset by FoilTEX – 5

Page 7: SeaCucumber: A Syntheszing Compiler

Two variable Karnaugh Map

0 1

0

1

BA

A=0,B=0

A=0,B=1

A=1,B=0

A=1,B=1

A different way to draw a truth table by folding it.

– Typeset by FoilTEX – 6

Page 8: SeaCucumber: A Syntheszing Compiler

K-Map

Physical adjacency does imply Gray code adjacency.

0 1

0

1

BA

1

1

0

0

F=A’B’+A’B=A’

1

0

0 1

0

1

BA

0

1

F = A’B + AB = B

– Typeset by FoilTEX – 7

Page 9: SeaCucumber: A Syntheszing Compiler

Two Variable Karnaugh Map

A B F

0 0 0

0 1 0

1 0 1

1 1 1

– Typeset by FoilTEX – 8

Page 10: SeaCucumber: A Syntheszing Compiler

Two Variable Karnaugh Map

A B F

0 0 1

0 1 1

1 0 0

1 1 0 1

0 1

0

1

BA

1

– Typeset by FoilTEX – 9

Page 11: SeaCucumber: A Syntheszing Compiler

Two Variable Karnaugh Map

A B F

0 0 1

0 1 1

1 0 0

1 1 0 1

0

0 1

0

1

BA

0

1

– Typeset by FoilTEX – 10

Page 12: SeaCucumber: A Syntheszing Compiler

Two Variable Karnaugh Map

A B F

0 0 1

0 1 1

1 0 0

1 1 0

1

0

0 1

0

1

BA

0

1

F = A’B’+A’B = A’

– Typeset by FoilTEX – 11

Page 13: SeaCucumber: A Syntheszing Compiler

Two Variable Karnaugh Map

A B F

0 0 1

0 1 1

1 0 0

1 1 0

0 1

0

1

BA

1

1

0

0A=0B=0 or 1

F = A’B’+A’B = A’

– Typeset by FoilTEX – 12

Page 14: SeaCucumber: A Syntheszing Compiler

Another Two Variable Karnaugh Map

A B F

0 0 0

0 1 1

1 0 1

1 1 1

1

0 1

0

1

BA

0

1

1

F = A’B + AB’+ AB = A+B

Each ’1’ must be covered at least once.

– Typeset by FoilTEX – 13

Page 15: SeaCucumber: A Syntheszing Compiler

Yet Another Two Variable Karnaugh Map

A B F

0 0 1

0 1 1

1 0 1

1 1 1

1

0 1

0

1

BA

1

1 1

F = A’B’ + A’B + AB’+ AB = 1

Groups of more than two 1’s can be combined as well.

– Typeset by FoilTEX – 14

Page 16: SeaCucumber: A Syntheszing Compiler

Three Variable Karnaugh MapShowing Minterm Locations

Note the order of the

B C Variables:

B C

0 0

0 1

1 1

1 0

0 1A

01

00

11

10

m0

m1

m3

m2

m4

m5

m7

m6

BC

ABC=010

ABC=101

– Typeset by FoilTEX – 15

Page 17: SeaCucumber: A Syntheszing Compiler

Adjacencies

Adjacent squares differ by exactly one variable.

0 1A

01

00

11

10

BC

A’B’C AB’C

ABC

AB’C’

There is wrap-around:

top and bottom rows are adjacent.

– Typeset by FoilTEX – 16

Page 18: SeaCucumber: A Syntheszing Compiler

Truth Table to Karnaugh Map

A B C F

0 0 0 0 0

0 0 1 0 1

0 1 0 1 2

0 1 1 1 3

1 0 0 0 4

1 0 1 1 5

1 1 0 0 6

1 1 1 1 7

-

0 1A

01

00

11

10

BC0

0

1

1 0

1

1

00

1

2

3

4

5

6

7

– Typeset by FoilTEX – 17

Page 19: SeaCucumber: A Syntheszing Compiler

Solution Example

A’BC+A’BC’ = A’B

0 1A

01

00

11

10

BC0

0

1

1 0

1

1

0

F = A’B + AC

AB’C+ABC = AC

– Typeset by FoilTEX – 18

Page 20: SeaCucumber: A Syntheszing Compiler

Another Example

A’B’C+A’BC=A’C AB’C’+ABC’=AC’

0 1A

01

00

11

10

BC0

1

1

0

0

0

1

1

F = A’C + AC’ = A ⊕ C

– Typeset by FoilTEX – 19

Page 21: SeaCucumber: A Syntheszing Compiler

Minterm Expansion to K-Map

F =∑

m(1, 3, 4, 6)

0 1A

01

00

11

10

m0

m1

m3

m2

m4

m5

m7

m6

BC

1

1

1

1

0

0

0

0

0 1A

01

00

11

10

BC

Minterms are the 1’s, everything else is 0.

– Typeset by FoilTEX – 20

Page 22: SeaCucumber: A Syntheszing Compiler

Maxterm Expansion to K-Map

F =∏

M(0, 2, 5, 7)

M0

M1

M3

M2

M4

M5

M7

0 1A

01

00

11

10

BC

M6

1

1

1

1

0

0

0

0

0 1A

01

00

11

10

BC

Maxterms are the 0’s, everything else is 1.

– Typeset by FoilTEX – 21

Page 23: SeaCucumber: A Syntheszing Compiler

Yet Another Example2n 1’s can be circled at a time. This includes 1,2,4,8 ... .

3,... not OK.

AB’C + ABC =AC

A’B’C’+AB’C’+A’B’C+AB’C =

B’

BC 0 1A

01

00

11

10

0 1

00

1 1

11

F=B’+AC

The larger the group of 1’s – the simpler the resulting product term.

– Typeset by FoilTEX – 22

Page 24: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

Plot:

0 1A

01

00

11

10

BC ab’c’ + bc + a’

– Typeset by FoilTEX – 23

Page 25: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

Plot:

0 1A

01

00

11

10

BC ab’c’ + bc + a’

1

– Typeset by FoilTEX – 24

Page 26: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

Plot:

0 1A

01

00

11

10

BC ab’c’ + bc + a’

1

1 1

– Typeset by FoilTEX – 25

Page 27: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

Plot:

0 1A

01

00

11

10

BC ab’c’ + bc + a’

1

1 1

1

1

1

– Typeset by FoilTEX – 26

Page 28: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

Plot:

Remaining spaces are ’0’.

0 1A

01

00

11

10

BC ab’c’ + bc + a’

1

1 1

1

1

1

0

0

– Typeset by FoilTEX – 27

Page 29: SeaCucumber: A Syntheszing Compiler

Boolean Algebra to Karnaugh Map

F = B’C’ + BC + A’

0 1A

01

00

11

10

BC ab’c’ + bc + a’

1

1 1

1

1

1

0

0

This is a simpler equation than we started with. How did we get

here?

– Typeset by FoilTEX – 28

Page 30: SeaCucumber: A Syntheszing Compiler

Mapping Sum of Product Terms

The three variable map has 12 possible groups of 2 spaces.

These become terms with 2 literals.

0 1A

01

00

11

10

BC 0 1A

01

00

11

10

BC 0 1A

01

00

11

10

BC

– Typeset by FoilTEX – 29

Page 31: SeaCucumber: A Syntheszing Compiler

Mapping Sum of Product Terms

The three variable map has 6 possible groups of 4 spaces.

These become terms with 1 literal.

0 1A

01

00

11

10

BC 0 1A

01

00

11

10

BC 0 1A

01

00

11

10

BC

– Typeset by FoilTEX – 30

Page 32: SeaCucumber: A Syntheszing Compiler

Four Variable Karnaugh Map

m12

m13

m15

m8

m9

m11

m10m14

01

00

11

10

m0

m1

m3

m4

m5

m7

ABCD 00 01 11 10

m6m2

D

A’BC

AB’C’

01

00

11

10

ABCD 00 01 11 10

0

1 1 1 1

1111

1

10 0

0 00

F = A’BC + AB’C + D

Note the row and column numbering. This is required for adjacency.

– Typeset by FoilTEX – 31

Page 33: SeaCucumber: A Syntheszing Compiler

Find a POS Solution

BC’

C’D

AB’CD’

01

00

11

10

ABCD 00 01 11 10

111

1

10

01

1

1

01

0 0 0 0

F’ = C’D + BC’ + AB’CD’

F = (C+D’)(B’+C)(A’+B+C’+D)

Find solutions to groups of 0’s to find F’. Invert to get F using DeMorgan’s.

– Typeset by FoilTEX – 32

Page 34: SeaCucumber: A Syntheszing Compiler

Dealing With Don’t Cares

F =∑

m(1, 3, 7) +∑

d(0, 5)

A’BC+AB’C+A’BC+ABC=

C

BC 0 1A

01

00

11

10

1

00

1

1

0

X

X

F = C

Circle the x’s that help get bigger groups of 1’s (or 0’s if POS).

Don’t circle the x’s that don’t help.

– Typeset by FoilTEX – 33

Page 35: SeaCucumber: A Syntheszing Compiler

Minimal K-Map Solutions

Some Terminology

and

An Algorithm to Find Them

– Typeset by FoilTEX – 34

Page 36: SeaCucumber: A Syntheszing Compiler

Prime Implicants

• A group of 1’s which are adjacent and can be combined on a

Karnaugh Map is called an implicant.

• The biggest group of 1’s which can be circled to cover a 1 is called

a prime implicant.

– They are the only implicants we care about.

– Typeset by FoilTEX – 35

Page 37: SeaCucumber: A Syntheszing Compiler

Prime Implicants

Prime Implicants Non−prime Implicants

01

00

11

10

ABCD 00 01 11 10

0

1 1

111

1

10 0

0

0 0

0

1 1

Are there any additional prime implicants in the map that are not

shown above?

– Typeset by FoilTEX – 36

Page 38: SeaCucumber: A Syntheszing Compiler

All the Prime Implicants

Prime Implicants

01

00

11

10

ABCD 00 01 11 10

0

1 1

111

1

10 0

0

0 0

0

1 1

When looking for a minimal solution – only circle prime implicants...

A minimal solution will never contain non-prime implicants

– Typeset by FoilTEX – 37

Page 39: SeaCucumber: A Syntheszing Compiler

Essential Prime Implicants

01

00

11

10

ABCD 00 01 11 10

0

1 1

111

1

10 0

0

0 0

0

1 1

Not all prime implicants are required ...

A prime implicant which is the only cover

of some 1’s is essential – a minimal

solution requires it.

Essential Prime Implicants Non−essential Prime Implicants

– Typeset by FoilTEX – 38

Page 40: SeaCucumber: A Syntheszing Compiler

A Minimal Solution Example

Minimum

F = AB’+BC+AD

Not required.01

00

11

10

ABCD 00 01 11 10

0

1 1

111

1

10 0

0

0 0

0

1 1

– Typeset by FoilTEX – 39

Page 41: SeaCucumber: A Syntheszing Compiler

Another Example

A’B’

F = A’D+BCD+B’D’Minimum

Not required.

01

00

11

10

ABCD 00 01 11 10

11

10 0

11 0

1

0

1

0

1

0

1

0

Every one one of F’s locations is covered by multiple implicants.

After choosing essentials, everything is covered...

– Typeset by FoilTEX – 40

Page 42: SeaCucumber: A Syntheszing Compiler

Finding the Minimum Sum of Products

1. Find each essential prime implicant and include it in the solution.

2. Determine if any minterms are not yet covered.

3. Find the minimal number of remaining prime implicants which

finish the cover.

– Typeset by FoilTEX – 41

Page 43: SeaCucumber: A Syntheszing Compiler

Yet Another Example

Using non-essential primes.

Essentials:

A’D’ and ADNon-essentials:

A’C and CDSolution:

A’D’+AD+A’Cor

A’D’+AD+CD

A’C

A’D’

AD

CD

01

00

11

10

ABCD 00 01 11 10

11

0

1 0

1

1

1

0 0

1

1

0

1

0

1

– Typeset by FoilTEX – 42

Page 44: SeaCucumber: A Syntheszing Compiler

K-Map Solution Summary

• Identify prime implicants.

• Add essentials to solution.

• Find minimum number non-essentials required to cover rest of map.

– Typeset by FoilTEX – 43

Page 45: SeaCucumber: A Syntheszing Compiler

Five and Six Variable K-Maps

– Typeset by FoilTEX – 44

Page 46: SeaCucumber: A Syntheszing Compiler

Five Variable Karnaugh Map

m12

m13

m15

m8

m9

m11

m10m14

m16

m17

m20

m21

m19 m23

m18 m22

m28

m29

m31

m30

m24

m25

m27

m26

This is the A=0 plane. This is the A=1 plane.

01

00

11

10

m0

m1

m3

m4

m5

m7

00 01 11 10

m6m2

01

00

11

10

00 01 11 10BC

DEBC

DE

The planes are adjacent to one another (one is above the other in

3D).

– Typeset by FoilTEX – 45

Page 47: SeaCucumber: A Syntheszing Compiler

Some Implicants in a Five Variable K-Map

ABCDEminimalnot

D’E’

B’C’E’AB’C’DA’BCD

A=1A=0

01

00

11

10

00 01 11 10

01

00

11

10

00 01 11 10BC

DEBC

DE

1

1 1 1 1

1

1

1 1 1 1

1

1

1

0 0

0 0

0

00

0

0

0 0

0

0 0 0

0

00

– Typeset by FoilTEX – 46

Page 48: SeaCucumber: A Syntheszing Compiler

Some Implicants in a Five Variable K-Map

Find the minimum sum-of-products for:

F =∑

m(0, 1, 4, 5, 11, 14, 15, 16, 17, 20, 21, 30, 31)

F = B’D’ + BCD + A’BDE

A=1A=0

01

00

11

10

00 01 11 10

01

00

11

10

00 01 11 10BC

DEBC

DE1 1

1

1

1 1

10 0

0

00

0

0

0 0

0

001 1

0 0

1

0 10

0

1 1

00

– Typeset by FoilTEX – 47

Page 49: SeaCucumber: A Syntheszing Compiler

Six Variable K-Map

m12

m13

m15

m8

m9

m11

m10m14

AB=00

AB=01

AB=10

AB=11

m16

m17

m20

m21

m19 m23

m18 m22

m28

m29

m31

m30

m24

m25

m27

m26

m32

m33

m35

m34

m36

m37

m39

m38

m44

m45

m47

m46

m40

m41

m42

m43

m48

m49

m51

m50

m52

m53

m55

m54

m60

m61

m63

m62

m56

m57

m59

m58

01

00

11

10

m0

m1

m3

m4

m5

m7

00 01 11 10

m6m2

EFCD

01

00

11

10

00 01 11 10CD

EF

01

00

11

10

00 01 11 10EFCD

01

00

11

10

00 01 11 10EFCD

– Typeset by FoilTEX – 48

Page 50: SeaCucumber: A Syntheszing Compiler

Six Variable K-Map

=CDEF

AC’D’=Solution= AC’D’+CDEF

AB=00

AB=01

AB=10

AB=11

1 1

11

1

1

1

1

1

1

1

1

0

0

0

0 0

0

0

0 0

0

0 0

0

0

0 0

0

0

0 0

0

0 0

0

0

0

000

0 0 0

0

000

0

0

0

0

00

0

00

0

0

00

0

0

0

01

00

11

10

00 01 11 10EFCD

01

00

11

10

00 01 11 10CD

EF

01

00

11

10

00 01 11 10EFCD

01

00

11

10

00 01 11 10EFCD

– Typeset by FoilTEX – 49

Page 51: SeaCucumber: A Syntheszing Compiler

K-Map Summary

• A K-Map is simply a folded truth table, where physical adjacency

implies logical adjacency.

• K-Maps are most commonly used hand method for logic

minimization.

• K-Maps have other uses for visualizing boolean equations.

– Typeset by FoilTEX – 50