Top Banner
CS1103-5 CS1104: Computer Organisation http://www.comp.nus.edu.sg/~cs110 4 Lecture 5: Karnaugh Maps
71

CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

Jan 03, 2016

Download

Documents

Rosanna Price
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: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1103-5

CS1104: Computer Organisation

http://www.comp.nus.edu.sg/~cs1104

Lecture 5: Karnaugh Maps

Page 2: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Lecture 5: Karnaugh Maps 2

Lecture 5: Karnaugh Maps

Function Simplification

Algebraic Simplification

Half Adder

Introduction to K-maps

Venn Diagrams

2-variable K-maps

3-variable K-maps

4-variable K-maps

5-variable and larger K-maps

Page 3: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Lecture 5: Karnaugh Maps 3

Lecture 5: Karnaugh Maps

Simplification using K-maps

Converting to Minterms Form

Simplest SOP Expressions

Getting POS Expressions

Don’t-care Conditions

Review

Examples

Page 4: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Function Simplification 4

Function Simplification (1/2) Why simplify?

Simpler expression uses less logic gates. Thus: cheaper, less power, faster (sometimes).

Simplification techniques: Algebraic Simplification.

simplify symbolically using theorems/postulates.

requires skill but extremely open-ended.

Karnaugh Maps. diagrammatic technique using ‘Venn-like diagram’. easy for humans (pattern-matching skills). simplified standard forms. limited to not more than 6 variables.

Page 5: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Function Simplification 5

Function Simplification (2/2) Simplification techniques:

Quine-McCluskey tabulation technique. tabulation technique based on certain ‘cancellation theorems’. simplified standard forms. tedious, repetitive step-by-step technique. boring to humans BUT suitable for computers. larger variables possible, but computationally intensive.

Page 6: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Algebraic Simplification 6

Algebraic Simplification (1/5)

Algebraic simplification aims to minimise

(i) number of literals, and

(ii) number of terms

But sometimes conflicting.

Let’s aim at reducing the number of literals.

Page 7: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Algebraic Simplification 7

Algebraic Simplification (2/5) Example:

(x+y).(x+y').(x'+z) (6 literals)= (x.x+x.y'+x.y+y.y').(x'+z) (assoc.)= (x+x.(y'+y)+0).(x'+z) (idemp.,assoc., compl.)= (x+x.(1)+0).(x'+z) (complement)= (x+x+0).(x'+z) (identity 1)= (x).(x'+z) (idemp, identity 0)= (x.x'+x.z) (assoc.)= (0+x.z) (complement)= x.z (identity 0)

Number of literals reduced from 6 to 2.

Page 8: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Algebraic Simplification 8

Algebraic Simplification (3/5) Find minimal SOP and POS expressions of

f(x,y,z) = x'.y.(z + y'.x) + y'.z x'.y.(z+y'.x) + y'.z= x'.y.z + x'.y.y'.x + y'.z (distributivity)= x'.y.z + 0 + y'.z (complement, null element 0)= x'.y.z + y'.z (identity 0)= x'.z + y’.z (absorption)= (x' + y').z (distributivity)

Minimal SOP of f = x'.z + y'.z (2 2-input AND gates and 1 2-input OR gate)

Minimal POS of f = (x' + y').z (1 2-input OR gate and 1 2-input AND gate)

Page 9: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Algebraic Simplification 9

Algebraic Simplification (4/5) Find minimal SOP expression of

f(a,b,c,d) = a.b.c + a.b.d + a'.b.c' + c.d + b.d'a.b.c + a.b.d + a'.b.c' + c.d + b.d'= a.b.c + a.b + a'.b.c' + c.d + b.d' (absorption)= a.b.c + a.b + b.c' + c.d + b.d' (absorption)= a.b + b.c' + c.d + b.d' (absorption)= a.b + c.d + b.(c' + d') (distributivity)= a.b + c.d + b.(c.d)' (DeMorgan)= a.b + c.d + b (absorption)= b + c.d (absorption)

Number of literals reduced form 13 to 3.

Page 10: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Algebraic Simplification 10

Algebraic Simplification (5/5)

Difficulty – needs good algebraic manipulation skills.

Advantage – very open-ended (to your desired form!)

Page 11: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Half Adder 11

Half Adder (1/2)

Half-Adder is a circuit which adds two single bits (called X,Y) together, to produce a result of two bits (called C, S).

A black-box representation of this circuit is:

Truth table representation is:

X Y C S0 0 0 00 1 0 11 0 0 11 1 1 0

Half adder

X

Y(X+Y)

S

C

Page 12: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Half Adder 12

Half Adder (2/2)

In sum-of-minterms forms:

C = X.Y

S = X'.Y + X.Y'

Algebraic simplification could simplify S to:

S = X'.Y + X.Y'

= XY

Giving:

X Y C S0 0 0 00 1 0 11 0 0 11 1 1 0

XY

S

C

Page 13: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Introduction to K-maps 13

Introduction to K-maps

Systematic method to obtain simplified sum-of-products (SOPs) Boolean expressions.

Objective: Fewest possible terms/literals.

Diagrammatic technique based on a special form of Venn diagram.

Advantage: Easy with visual aid.

Disadvantage: Limited to 5 or 6 variables.

Page 14: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Venn Diagrams 14

Venn Diagrams (1/2)

Venn diagram to represent the space of minterms. Example of 2 variables (4 minterms):

a.b' a'.b

a'.b'

a.ba

b

Page 15: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Venn Diagrams 15

Venn Diagrams (2/2)

Each set of minterms represents a Boolean function. Examples:

{ a.b, a.b' } a.b + a.b' = a.(b+b') = a

{ a'.b, a.b } a'.b + a.b = (a'+a).b = b

{ a.b } a.b

{ a.b, a.b', a'.b } a.b + a.b' + a'.b = a + b

{ } 0

{ a'.b',a.b,a.b',a'.b } 1

a.b' a'.b

a'.b'

a.ba b

Page 16: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 2-variable K-maps 16

2-variable K-maps (1/4)

Karnaugh-map (K-map) is an abstract form of Venn diagram, organised as a matrix of squares, where each square represents a minterm

adjacent squares always differ by just one literal (so that the unifying theorem may apply: a + a' = 1)

For 2-variable case (e.g.: variables a,b), the map can be drawn as:

Page 17: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 2-variable K-maps 17

2-variable K-maps (2/4) Alternative layouts of a 2-variable (a, b) K-map

a'b'

ab'

a'b abb

a

m0 m2

m1 m3b

a

OR

Alternative 2:

a'b'

a'b

ab' aba

b

m0 m1

m2 m3a

b

Alternative 1:

OR

ab a'b

ab' a'b'

b

a

m3 m1

m2 m0

b

aOR

Alternative 3:

and others…

Page 18: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 2-variable K-maps 18

2-variable K-maps (3/4)

Equivalent labeling:

a

b

equivalent to:

ab

0 1

0 1

b

a

equivalent to:

ba

1 0

0 1

Page 19: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 2-variable K-maps 19

2-variable K-maps (4/4)

The K-map for a function is specified by putting a ‘1’ in the square corresponding to a minterm a ‘0’ otherwise

For example: Carry and Sum of a half adder.

0 0

0 1a

b

0 1

1 0a

b

C = a.b S = a.b' + a'.b

Page 20: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 3-variable K-maps 20

3-variable K-maps (1/2)

There are 8 minterms for 3 variables (a, b, c). Therefore, there are 8 cells in a 3-variable K-map.

ab'c' ab'ca

b

abc abc'

a'b'c'

a'b'c a'bc a'bc'0 1

00 01 11 10

c

abc

ORm4 m5a

b

m7 m6

m0 m1 m3 m20 1

00 01 11 10

c

abc

Note Gray code sequenceAbove arrangement ensures that minterms of adjacent cells differ by only ONE literal. (Other arrangements which satisfy this criterion may also be used.)

Page 21: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 3-variable K-maps 21

3-variable K-maps (2/2)

There is wrap-around in the K-map: a'.b'.c' (m0) is adjacent to a'.b.c' (m2) a.b'.c' (m4) is adjacent to a.b.c' (m6)

m4 m5 m7 m6

m0 m1 m3 m20 1

00 01 11 10abc

Each cell in a 3-variable K-map has 3 adjacent neighbours. In general, each cell in an n-variable K-map has n adjacent neighbours. For example, m0 has 3 adjacent neighbours: m1, m2 and m4.

Page 22: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Quick Review Questions (1) 22

Quick Review Questions (1)Textbook page 104. 5-1. The K-map of a 3-variable function F is shown below.

What is the sum-of-minterms expression of F?

5-2. Draw the K-map for this function A:A(x, y, z) = x.y + y.z' + x'.y'.z

0 1a

b

0 0

1 0 0 10 1

00 01 11 10

c

abc

Page 23: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 4-variable K-maps 23

4-variable K-maps (1/2)

There are 16 cells in a 4-variable (w, x, y, z) K-map.

m4 m5

w

y

m7 m6

m0 m1 m3 m200

01

11

10

00 01 11 10

z

wxyz

m12

m13

m15

m14

m8 m9 m11

m10

x

Page 24: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 4-variable K-maps 24

4-variable K-maps (2/2)

There are 2 wrap-arounds: a horizontal wrap-around and a vertical wrap-around.

Every cell thus has 4 neighbours. For example, the cell corresponding to minterm m0 has neighbours m1, m2, m4 and m8.

m4 m5

w

y

m7 m6

m0 m1 m3 m2

z

wxyz

m12

m13

m15

m14

m8 m9 m11

m10

x

Page 25: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 5-variable K-maps 25

5-variable K-maps (1/2)

Maps of more than 4 variables are more difficult to use because the geometry (hyper-cube configurations) for combining adjacent squares becomes more involved.

For 5 variables, e.g. vwxyz, need 25 = 32 squares.

Page 26: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 5-variable K-maps 26

5-variable K-maps (2/2)

Organised as two 4-variable K-maps:

Corresponding squares of each map are adjacent.Can visualise this as being one 4-variable map on TOP of the other 4-variable map.

m20

m21

w

y

m23

m22

m16

m17

m19

m18

00

01

11

10

00 01 11 10

z

wxyz

m28

m29

m31

m30

m24

m25

m27

m26

x

m4 m5

w

y

m7 m6

m0 m1 m3 m200

01

11

10

00 01 11 10

z

wxyz

m12

m13

m15

m14

m8 m9 m11

m10

x

v ' v

Page 27: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Larger K-maps 27

Larger K-maps (1/2)

6-variable K-map is pushing the limit of human “pattern-recognition” capability.

K-maps larger than 6 variables are practically unheard of!

Normally, a 6-variable K-map is organised as four 4-variable K-maps, which are mirrored along two axes.

Page 28: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Larger K-maps 28

Larger K-maps (2/2)

Try stretch your recognition capability by finding simplest sum-of-products expression for m(6,8,14,18,23,25,27,29,41,45,57,61).

a'.b'

m000

01

11

10

00 01 11 10cdef

m1 m3 m2

m4 m5 m7 m6

m12

m13

m15

m14

m8 m9 m11

m10

m40

10

11

01

0000 01 11 10cd

ef

m41

m43

m42

m44

m45

m47

m46

m36

m37

m39

m38

m32

m33

m35

m34

m18

00

01

11

10

10 11 01 00 cd

ef

m19

m17

m16

m22

m23

m21

m20

m30

m31

m29

m28

m26

m27

m25

m24

m58

10

11

01

0010 11 01 00 cd

ef

m59

m57

m56

m62

m63

m61

m60

m54

m55

m53

m52

m50

m51

m49

m48

a'.b

a.b' a.b

a

b

Page 29: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 29

Simplification Using K-maps (1/9)

Based on the Unifying Theorem:

A + A' = 1

In a K-map, each cell containing a ‘1’ corresponds to a minterm of a given function F.

Each group of adjacent cells containing ‘1’ (group must have size in powers of twos: 1, 2, 4, 8, …) then corresponds to a simpler product term of F. Grouping 2 adjacent squares eliminates 1 variable, grouping 4

squares eliminates 2 variables, grouping 8 squares eliminates 3 variables, and so on. In general, grouping 2n squares eliminates n variables.

Page 30: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 30

Simplification Using K-maps (2/9)

Group as many squares as possible. The larger the group is, the fewer the number of literals in the

resulting product term.

Select as few groups as possible to cover all the squares (minterms) of the function. The fewer the groups, the fewer the number of product terms in

the minimized function.

Page 31: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 31

Simplification Using K-maps (3/9)

Example:

F (w,x,y,z) = w’.x.y'.z' + w'.x.y'.z + w.x'.y.z' + w.x'.y.z + w.x.y.z' + w.x.y.z

= m(4, 5, 10, 11, 14, 15)

z

1 1

w

y

00

01

11

10

00 01 11 10wxyz

1 1

1 1

x (cells with ‘0’ are not shown for clarity)

Page 32: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 32

Simplification Using K-maps (4/9)

Each group of adjacent minterms (group size in powers of twos) corresponds to a possible product term of the given function.

1 1

w

00

01

11

10

00 01 11 10

z

wxyz

1 1

1 1

x

A

B

y

Page 33: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 33

Simplification Using K-maps (5/9)

There are 2 groups of minterms: A and B, where: A = w'.x.y'.z' + w‘.x.y'.z

= w'.x.y'.(z' + z)

= w'.x.y'

B = w.x'.y.z' + w.x'.y.z + w.x.y.z' + w.x.y.z

= w.x'.y.(z' + z) + w.x.y.(z' + z)

= w.x'.y + w.x.y

= w.(x'+x).y

= w.y 1 1

w

00

01

11

10

00 01 11 10

z

wx

yz

1 1

1 1

x

A

B

y

Page 34: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 34

Simplification Using K-maps (6/9)

Each product term of a group, w'.x.y' and w.y, represents the sum of minterms in that group.

Boolean function is therefore the sum of product terms (SOP) which represent all groups of the minterms of the function.

F(w,x,y,z) = A + B = w'.x.y' + w.y

Page 35: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 35

Simplification Using K-maps (7/9)

Larger groups correspond to product terms of fewer literals. In the case of a 4-variable K-map:

1 cell = 4 literals, e.g.: w.x.y.z, w'.x.y'.z

2 cells = 3 literals, e.g.: w.x.y, w.y'.z'

4 cells = 2 literals, e.g.: w.x, x'.y

8 cells = 1 literal, e.g.: w, y', z

16 cells = no literal, e.g.: 1

Page 36: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 36

Simplification Using K-maps (8/9)

Other possible valid groupings of a 4-variable K-map include:

1

11

1

1

1

1

1

1

11

1 1

111

1

11

1

Page 37: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplification Using K-maps 37

Simplification Using K-maps (9/9)

Groups of minterms must be (1) rectangular, and (2) have size in powers of 2’s.

Otherwise they are invalid groups. Some examples of invalid groups:

1

11

1 1

111

1

1

1

1

1

1

1

1

Page 38: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Converting to Minterms Form 38

Converting to Minterms Form (1/2)

The K-map of a function is easily drawn when the function is given in canonical sum-of-products, or sum-of-minterms form.

What if the function is not in sum-of-minterms?

Convert it to sum-of-products (SOP) form.

Expand the SOP expression into sum-of-minterms expression, or fill in the K-map directly based on the SOP expression.

Page 39: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Converting to Minterms Form 39

Converting to Minterms Form (2/2) Example:

f(A,B,C,D) = A.(C+D)'.(B'+D') + C.(B+C'+A'.D)

= A.(C'.D').(B'+D') + B.C + C.C' + A'.C.D

= A.B'.C'.D' + A.C'.D' + B.C + A'.C.D

11

C

A

00

01

11

10

00 01 11 10

B

CDAB

D1 1 1

1 1

A.B'.C'.D' + A.C'.D' + B.C + A'.C.D

= A.B'.C'.D' + A.C'.D'.(B+B') + B.C + A'.C.D

= A.B'.C'.D' + A.B.C'.D' + A.B'.C'.D' + B.C.(A+A') + A'.C.D

= A.B'.C'.D' + A.B.C'.D' + A.B.C + A'.B.C + A'.C.D

= A.B'.C'.D' + A.B.C'.D' + A.B.C.(D+D') + A'.B.C.(D+D') + A'.C.D.(B+B')

= A.B'.C'.D' + A.B.C'.D' + A.B.C.D + A.B.C.D' + A'.B.C.D + A'.B.C.D' + A'.B‘.C.D

Page 40: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 40

Simplest SOP Expressions (1/3) To find the simplest possible sum of products (SOP)

expression from a K-map, you need to obtain: minimum number of literals per product term; and minimum number of product terms

This is achieved in K-map using bigger groupings of minterms (prime implicants) where

possible; and no redundant groupings (look for essential prime implicants)

Implicant: a product term that could be used to cover minterms of the function.

Page 41: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 41

Simplest SOP Expressions (2/3)

A prime implicant is a product term obtained by combining the maximum possible number of minterms from adjacent squares in the map.

Use bigger groupings (prime implicants) where possible.

11 1

111

11 1

111

Page 42: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 42

Simplest SOP Expressions (3/3)

No redundant groups:

An essential prime implicant is a prime implicant that includes at least one minterm that is not covered by any other prime implicant.

1

1

1

11

1

1

1

1

1

1

11

1

1

1

Essential prime implicants

Page 43: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Quick Review Questions (2) 43

Quick Review Questions (2)

Textbook page 104.

5-3. Identify the prime implicants and the essential prime implicants of the two K-maps below.

0 1a

b

0 0

1 1 0 10 1

00 01 11 10

c

abc

11

C

A

00

01

11

10

00 01 11 10

B

CDAB

D1 1 1

1 1

1

1 1

1

Page 44: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 44

Simplest SOP Expressions (1/5) Algorithm 1 (non optimal):

1. Count the number of adjacencies for each minterm on the K-map.

2. Select an uncovered minterm with the fewest number of adjacencies. Make an arbitrary choice if more than one choice is possible.

3. Generate a prime implicant for this minterm and put it in the cover. If this minterm is covered by more than one prime implicant, select the one that covers the most uncovered minterms.

4. Repeat steps 2 and 3 until all the minterms have been covered.

Page 45: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 45

Simplest SOP Expressions (2/5)

Algorithm 2 (non optimal):

1. Circle all prime implicants on the K-map.

2. Identify and select all essential prime implicants for the cover.

3. Select a minimum subset of the remaining prime implicants to complete the cover, that is, to cover those minterms not covered by the essential prime implicants.

Page 46: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 46

Simplest SOP Expressions (3/5)

Example:

f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)

All prime implicants

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Page 47: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 47

Simplest SOP Expressions (4/5)

B

1

1

C

A

00

01

11

10

00 01 11 10CDAB

1

1

1

1

D

1

1

1

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Essential prime implicants

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Minimum cover

Page 48: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Simplest SOP Expressions 48

Simplest SOP Expressions (5/5)

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

B.D

AB'D'A'BC'

A'B'C

f(A,B,C,D) = B.D + A'.B'.C + A.B'.D' + A'.B.C'

Page 49: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Quick Review Questions (3) 49

Quick Review Questions (3)

Textbook page 104.

5-4. Find the simplified expression for G(A,B,C,D).

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

D1 1 1

1

1

1 1

5-5 to 5-7.

Page 50: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Getting POS Expressions 50

Getting POS Expressions (1/2) Simplified POS expression can be obtained by grouping

the maxterms (i.e. 0s) of given function.

Example:

Given F=m(0,1,2,3,5,7,8,9,10,11), we first draw the K-map, then group the maxterms together:

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

0

1

1

D

1

1

1 1

10

00

0 0

Page 51: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Getting POS Expressions 51

Getting POS Expressions (2/2)

This gives the SOP of F' to be:F' = B.D' + A.B

To get POS of F, we have:F = (B.D' + A.B)'

= (B.D')'.(A.B)' DeMorgan

= (B'+D).(A'+B') DeMorgan

0

0

C

A

00

01

11

10

00 01 11 10

B

CDAB

0

1

0

0

D

0

0

0 0

01

11

1 1

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

0

1

1

D

1

1

1 1

10

00

0 0K-map of F

K-map of F'

Page 52: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Don’t-care Conditions 52

Don’t-care Conditions (1/3) In certain problems, some

outputs are not specified.

These outputs can be either ‘1’ or ‘0’.

They are called don’t-care conditions, denoted by X (or sometimes, d).

Example: An odd parity generator for BCD code which has 6 unused combinations.

No. A B C D P0 0 0 0 0 11 0 0 0 1 02 0 0 1 0 03 0 0 1 1 14 0 1 0 0 05 0 1 0 1 16 0 1 1 0 17 0 1 1 1 08 1 0 0 0 09 1 0 0 1 1

10 1 0 1 0 X11 1 0 1 1 X12 1 1 0 0 X13 1 1 0 1 X14 1 1 1 0 X15 1 1 1 1 X

Page 53: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Don’t-care Conditions 53

Don’t-care Conditions (2/3)

Don’t-care conditions can be used to help simplify Boolean expression further in K-maps.

They could be chosen to be either ‘1’ or ‘0’, depending on which gives the simpler expression.

We usually use the notation d to denote the set of don’t-care minterms. For example, the function P in the odd-parity generator for BCD can be written as:

P = m(0, 3, 5, 6, 9) + d(10, 11, 12, 13, 14, 15)

Page 54: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Don’t-care Conditions 54

Don’t-care Conditions (3/3) For comparison:

WITHOUT don’t-cares:P = A'.B'.C'.D’ + A'.B'.C.D +

A'.B.C'.D + A'.B.C.D' + A.B'.C'.D

WITH don’t-cares:P = A'.B'.C'.D' + B'.C.D + B.C'.D + B.C.D' + A.D

1

A

C

00

01

11

10

00 01 11 10

D

ABCD

1

B

1

1

1

1

A

C

00

01

11

10

00 01 11 10

D

ABCD

1

B

1

1

1

X X

XXXX

Page 55: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Review 55

Review – The Techniques Algebraic Simplification.

requires skills but extremely open-ended.

Karnaugh Maps. can obtain simplified standard forms.

easy for humans (pattern-matching skills).

limited to not more than 6 variables.

Other computer-aided techniques such as Quine-McCluskey method (not covered in this course).

Page 56: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Review 56

Review – K-maps (1/4)

Characteristics of K-map layouts: (i) each minterm in one square/cell

(ii) adjacent/neighbouring minterms differ by only 1 literal

(iii) n-literal minterm has n neighbours/adjacent cells

Valid 2-, 3-, 4-variable K-maps

a'b'

a'b

ab' aba

b

m0 m1

m2 m3a

b

OR

Page 57: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Review 57

Review – K-maps (2/4)

ab'c' ab'ca

b

abc abc'

a'b'c'

a'b'c a'bc a'bc'0 1

00 01 11 10

c

abc

m4 m5a

b

m7 m6

m0 m1 m3 m20 1

00 01 11 10

c

abc

m4 m5

w

y

m7 m6

m0 m1 m3 m200

01

11

10

00 01 11 10

z

wxyz

m12

m13

m15

m14

m8 m9 m11

m10

x

Page 58: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Review 58

Review – K-maps (3/4)

Groupings to select product-terms must be: (i) rectangular in shape (ii) in powers of twos (1, 2, 4, 8, etc.) (iii) always select largest possible groupings of minterms

(i.e. prime implicants) (iv) eliminate redundant groupings

Sum-of-products (SOP) form obtained by selecting groupings of minterms (corresponding to product terms).

Page 59: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Review 59

Review – K-maps (4/4)

Product-of-sums (POS) form obtained by selecting groupings of maxterms (corresponding to sum terms) and by applying DeMorgan’s theorem.

Don’t cares, marked by X (or d), can denote either 1 or 0. They could therefore be selected as 1 or 0 to further simplify expressions.

Page 60: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 60

Examples (1/11)

Example #1:

f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)

Fill in the 1’s.

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Page 61: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 61

Examples (2/11)

Example #1:

f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)

These are all the prime implicants; but do we need them all?1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Page 62: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 62

Examples (3/11)

Example #1:

f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)

Essential prime implicants:

B.D

A'.B.C'

A.B'.D'

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

Page 63: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 63

Examples (4/11)

Example #1:

f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)

Minimum cover.

EPIs: B.D, A'.B.C', A.B'.D'

+

A'.B'.C

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

f(A,B,C,D) = B.D + A'.B.C' + A.B'.D' + A'.B'.C

Page 64: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 64

Examples (5/11)

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

1

1

C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1

1

D

1

1

1

B

1

1

C

A

00

01

11

10

00 01 11 10CDAB

1

1

1

1

D

1

1

1

Essential prime implicants

Minimum cover

SUMMARY

f(A,B,C,D) = B.D + A'.B'.C + A.B'.D' + A'.B.C'

Page 65: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 65

Examples (6/11)

Example #2:

f(A,B,C,D) = A.B.C + B'.C.D' + A.D + B'.C'.D'

Fill in the 1’s.1

1C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1D

1

1

11

Page 66: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 66

Examples (7/11)

Example #2:

f(A,B,C,D) = A.B.C + B'.C.D' + A.D + B'.C'.D'

Find all PIs:

A.D

A.C

B'.D'

A.B'

1

1C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

1D

1

1

11

A.D, A.C and B'.D' are EPIs, and they cover all the minterms.

So the answer is: f(A,B,C,D) = A.D + A.C + B'.D'

Page 67: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 67

Examples (8/11)

Example #3 (with don’t cares):

f(A,B,C,D) = m(2,8,10,15) + d(0,1,3,7)

Fill in the 1’s and X’s.1X

C

A

00

01

11

10

00 01 11 10

B

CDAB

X 1

XD

11

X

Page 68: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 68

Examples (9/11)

Example #3 (with don’t cares):f(A,B,C,D) = m(2,8,10,15) + d(0,1,3,7)

1X

C

A

00

01

11

10

00 01 11 10

B

CDAB

X 1

XD

11

X

f(A,B,C,D) = B'.D' + B.C.D

Do we need to have an additional term A'.B' to cover the 2 remaining x’s?

No, because all the 1’s (minterms) have been covered.

Page 69: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 69

Examples (10/11)

To find simplest POS expression for example #2:

f(A,B,C,D) = A.B.C + B'.C.D' + A.D + B'.C'.D' Draw the K-map of the complement of f, f '.

1

1C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

D

11

1

From K-map,

f ' = A'.B + A'.D + B.C'.D'

Using DeMorgan’s theorem,

f = (A'.B + A'.D + B.C'.D')'

= (A+B').(A+D').(B'+C+D)

Page 70: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1104-5 Examples 70

Examples (11/11) To find simplest POS expression for example #3:

f(A,B,C,D) = m(2,8,10,15) + d(0,1,3,7) Draw the K-map of the complement of f, f '.

f '(A,B,C,D) = m(4,5,6,9,11,12,13,14) + d(0,1,3,7)

From K-map,

f ' = B.C' + B.D' + B'.D

Using DeMorgan’s theorem,

f = (B.C' + B.D' + B'.D)'

= (B'+C).(B'+D).(B+D')

1

1C

A

00

01

11

10

00 01 11 10

B

CDAB

1

1

D

11

1

X

X

X

X

1

Page 71: CS1104: Computer Organisation cs1104 Lecture 5: Karnaugh Maps cs1104.

CS1103-5

End of file