ece2030 introduction to computer engineering lecture 7: simplification using k-map prof. hsien-hsin...

32
ECE2030 Introduction to Computer Engineering Lecture 7: Simplification using K-map Prof. Hsien-Hsin Sean Lee Prof. Hsien-Hsin Sean Lee School of Electrical and Computer School of Electrical and Computer Engineering Engineering Georgia Tech Georgia Tech

Upload: brian-george

Post on 13-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

ECE2030 Introduction to Computer Engineering

Lecture 7: Simplification using K-map

Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee

School of Electrical and Computer EngineeringSchool of Electrical and Computer Engineering

Georgia TechGeorgia Tech

2

Hamming Distance

• The count of bits different in two binary patterns

• Examples:– Dh(1001, 0101) = 2

– Dh(0xADF4, 0x9FE3) = ??

• Unit-Distance Codes– Reduce errors during transmission such as

rotary positional sensor– E.g. Gray Code

3

Gray Code Construction

01

01

10

00

11

0001111010110100

00001111

000001011010110111101100

100101111110010011001000

00000000

11111111

4

Gray CodeBinary Encoding Gray Code Encoding

Decimal b3 b2 b1 b0 g3 g2 G1 g0

0 0 0 0 0 0 0 0 0

1 0 0 0 1 0 0 0 1

2 0 0 1 0 0 0 1 1

3 0 0 1 1 0 0 1 0

4 0 1 0 0 0 1 1 0

5 0 1 0 1 0 1 1 1

6 0 1 1 0 0 1 0 1

7 0 1 1 1 0 1 0 0

8 1 0 0 0 1 1 0 0

9 1 0 0 1 1 1 0 1

10 1 0 1 0 1 1 1 1

11 1 0 1 1 1 1 1 0

12 1 1 0 0 1 0 1 0

13 1 1 0 1 1 0 1 1

14 1 1 1 0 1 0 0 1

15 1 1 1 1 1 0 0 0

0b e wherbbg 41iii

5

Rotary Position Sensor

6

Karnaugh Map (K-Map)• A graphical map method to simplify

Boolean function up to 6 variables• A diagram made up of squares• Each square represents one minterm

(or maxterm) of a given Boolean function

7

Karnaugh Map Examples

Note that the Hamming DistanceHamming Distance between adjacent columnsadjacent columns or adjacent rows adjacent rows (including cyclic ones) (including cyclic ones) must be 1 for simplification purposes

8

Karnaugh Map

Adjacent columns or rows allow grouping of minterms (maxterms) for simplification

9

Implicant• Definition

– A product term is an ImplicantImplicant of a Boolean function if the function has an output 1 for all minterms of the product term.

• In K-map, an ImplicantImplicant is – bubble covers only 1

(bubble size must be a power of 2)

00 01 11 10

00 1 1 0 0

01 0 0 1 0

11 0 1 1 1

10 1 1 0 0

ABCD

10

Prime Implicant

• Definition– If the removal of any literal from an

implicant II results in a product term that is not an implicant of the Boolean function, then II is an Prime Prime ImplicantImplicant.

– Examples• BCDBCD is an implicant, but CDCD or BDBD or

BCBC do not imply a 1 in this function; BCDBCD is a PIPI

• B’C’DB’C’D is an implicant, but B’C’B’C’ is not an implicant, thus B’C’DB’C’D is not a PI

• In K-map, a Prime Implicant Prime Implicant (PI)(PI) is – bubble that is expanded as big as

possible (bubble size must be a power of 2)

00 01 11 10

00 1 1 0 0

01 0 0 1 0

11 0 1 1 1

10 1 1 0 0

ABCD

11

Essential Prime Implicant• Definition

– If a minterm of a Boolean function is included in only one PI, then this PI is an Essential Prime Essential Prime ImplicantImplicant.

• In K-map, an Essential Essential Prime ImplicantPrime Implicant is – Bubble that contains a 1

covered only by itself and no other PI bubbles

00 01 11 10

00 1 1 0 0

01 0 0 1 0

11 0 1 1 1

10 1 1 0 0

ABCD

12

Non-Essential Prime Implicant• Definition

– A Non-Essential Prime Non-Essential Prime ImplicantImplicant is a PI that is not an Essential PI.

• In K-map, an Non-Non-Essential Prime Essential Prime ImplicantImplicant is – A 1 covered by more than

one PI bubble

00 01 11 10

00 1 1 0 0

01 0 0 1 0

11 0 1 1 1

10 1 1 0 0

ABCD

13

Simplification for SOP• Form K-Map for the given Boolean function

• Identify all Essential Prime Implicants for 1’s in the K-map

• Identify non-Essential Prime Implicants in the K-map for the 1’s which are not covered by the Essential Prime Implicants

• Form a sum-of-products (SOP) with all Essential Prime Implicants and the necessary non-Essential Prime Implicants to cover all 1’s

14

Example for SOP• Identify all the

essential PIs for 1’s• Identify the non-

essential PIs to cover 1’s

• Form an SOP based on the selected PIs

7) 6, 4, 1, m(0,F

00 01 11 10

0 1 1 0 0

1 1 0 1 1

ABC

CAABBAF

or

CBABBAF

15

Example for SOP• Identify all the

essential PIs for 1’s• Identify the non-

essential PIs to cover 1’s

• Form an SOP based on the selected PIs

15) 14, 13, 9, 8, 7, 1, m(0,F

00 01 11 10

00 1 1 0 0

01 0 0 1 0

11 0 1 1 1

10 1 1 0 0

ABCD

ABDBCDABCCBF

or

DCABCDABCCBF

16

Example for SOP• Identify all the

essential PIs for 1’s• Identify the non-

essential PIs to cover 1’s

• Form an SOP based on the selected PIs

12) 11, 6, 4, 3, M(1,F

00 01 11 10

00 1 0 0 1

01 0 1 1 0

11 0 1 1 1

10 1 1 0 1

ABCD

CBAABCBDDBF

or

DCAABCBDDBF

17

Prime Implicants• All the prior definitions apply to ‘0’ (or

maxterm) as well• Consider these implicants imply a ‘0’

output

18

Simplification for POS• Form K-Map for the given Boolean function

• Identify all Essential Prime Implicants for 0’s in the K-map

• Identify non-Essential Prime Implicants in the K-map for the 0’s which are not covered by the Essential Prime Implicants

• Form a product-of-sums (POS) with all Essential Prime Implicants and the necessary non-Essential Prime Implicants to cover all 0’s

19

Example for POS• Identify all the

essential PIs for 0’s• Identify the non-

essential PIs to cover 0’s

• Form an POS based on the selected PIs

)CBA)(B(AF

00 01 11 10

0 1 1 0 0

1 1 0 1 1

ABC

5) 3, M(2,F

20

Example for POS• Identify all the

essential PIs for 0’s• Identify the non-

essential PIs to cover 0’s

• Form an POS based on the selected PIs

D)B)(ADC)(BDBD)(ACB(F

00 01 11 10

00 1 0 0 1

01 0 1 1 0

11 0 1 1 1

10 1 1 0 1

ABCD

12) 11, 6, 4, 3, M(1,F

21

Don’t Care Condition X

• Don’t care (X)– Those input combinations which are

irrelevant to the target function (i.e. If the input combination signals can be guaranteed never occur)

– Can be used to simplify Boolean equations, thus simply logic design

• In K-map– Use XX to express Don’t Care in the map– Don’t care can be bubbled as 11 or 00

depending on SOP or POS simplification to result into bigger bubble

22

Don’t Care Example BCD to Gray Code

BCD-coded input Gray Code Output

Decimal b3 b2 b1 b0 g3 g2 g1 g0

0 0 0 0 0 0 0 0 0

1 0 0 0 1 0 0 0 1

2 0 0 1 0 0 0 1 1

3 0 0 1 1 0 0 1 0

4 0 1 0 0 0 1 1 0

5 0 1 0 1 0 1 1 1

6 0 1 1 0 0 1 0 1

7 0 1 1 1 0 1 0 0

8 1 0 0 0 1 1 0 0

9 1 0 0 1 1 1 0 1

10 1 0 1 0 XX XX XX XX

11 1 0 1 1 XX XX XX XX

12 1 1 0 0 XX XX XX XX

13 1 1 0 1 XX XX XX XX

14 1 1 1 0 XX XX XX XX

15 1 1 1 1 XX XX XX XX

• BCD stands for Binary Coded Binary Coded DecimalDecimal

• Each digit of a decimal number is represented by one codecode

• BCD only encodes from 0 to 9– Require 4 bits– Only use 10 out of

16 encoding space

23

BCD to Gray Code (Do not use Don’ Care)

BCD-coded input Gray Code Output

Decimal b3 b2 b1 b0 g3 g2 g1 g0

0 0 0 0 0 0 0 0 0

1 0 0 0 1 0 0 0 1

2 0 0 1 0 0 0 1 1

3 0 0 1 1 0 0 1 0

4 0 1 0 0 0 1 1 0

5 0 1 0 1 0 1 1 1

6 0 1 1 0 0 1 0 1

7 0 1 1 1 0 1 0 0

8 1 0 0 0 1 1 0 0

9 1 0 0 1 1 1 0 1

10 1 0 1 0 11 11 11 11

11 1 0 1 1 11 11 11 00

12 1 1 0 0 11 00 11 00

13 1 1 0 1 11 00 11 11

14 1 1 1 0 11 00 00 11

15 1 1 1 1 11 00 00 00

• BCD stands for Binary Coded Binary Coded DecimalDecimal

• Each digit of a decimal number is represented by one codecode

• BCD only encodes from 0 to 9– Require 4 bits– Only use 10 out of

16 encoding space

24

What g2 is?• g2 = F(b3, b2, b1, b0)

25

Example: g2 of BCD-to-Gray

3223320 bbbbbbg

00 01 11 10

00 0 0 0 0

01 1 1 1 1

11 X X X X

10 1 1 X X

b3b2

b1b000 01 11 10

00 0 0 0 0

01 1 1 1 1

11 0 0 0 0

10 1 1 1 1

b3b2

b1b0

Without using Don’t Care Take Don’t Care into account

230 bbg

26

Another Example of Don’t Care (SOPSOP)

14) 13, d(10,12) 11, 6, 4, 3, m(2,D) C, B, F(A,

00 01 11 10

00 0 0 1 1

01 1 0 0 1

11 1 X 0 X

10 0 0 1 X

ABCD

CBDBF

27

Another Example of Don’t Care (POSPOS)

14) 13, d(10,12) 11, 6, 4, 3, m(2,D) C, B, F(A,

00 01 11 10

00 0 0 1 1

01 1 0 0 1

11 1 X 0 X

10 0 0 1 X

ABCD

C))(BDB(F

28

Use Karnaugh Map in BB5 5 or BB66

• In BB55

– 2 K-maps are to be constructed (2 submaps)– Consider one submap is on top of the other – Cells that occupy the same relative position in 2

maps are considered adjacent– Bubble can be constructed in vertical dimension

when stacking up 2 maps

• In BB66

– 4 K-maps are to be constructed (4 submaps)

– Similar to BB55 , yet another dimension needs to be considered

29

Karnaugh Map Example in BB55

27) 24, 20, 19, 18, 16, 11, 8, 7, 6, 4, 3, 2, m(0,D)C,B,A, F(E,

00 01 11 10

00 1 0 1 1

01 1 0 1 1

11 0 0 0 0

10 1 0 1 0

ABCD

00 01 11 10

00 1 0 1 1

01 1 0 0 0

11 0 0 0 0

10 1 0 1 0

ABCD

E = 0 E = 1

CDBDCBDCACBAECAF

30

Karnaugh Map Example in BB66

)45(61) 53, 37, 31, 29, 23, 21, 13, 9, 5, m(1,Z)Y,X,W,V,F(U, d

00 01 11 10

00 1

01 1

11 1 1

10 1

WXYZ

U,V=0,0

00 01 11 10

00

01 1

11 X

10

WXYZ

U,V=1,0

00 01 11 10

00

01 1 1

11 1 1

10

WXYZ

U,V=0,1

00 01 11 10

00

01 1

11 1

10

WXYZ

U,V=1,1

VXZUZYVUWXZUZYXF

31

Minimal SOP and POS w/ Don’t care

• Could lead to different function if the same x is treated as 1 in SOP but as 0 in POS.

• Even though the final Boolean functions could be different, but for those ones with non-don’t care square, correct functionality was maintained.

0 1

0 x 11 0 x

A B

F = F = Ā (SOP)Ā (SOP)F = F = B (POS)B (POS)

F = F = Ā (POS)Ā (POS)

32

Use Karnaugh Map in BB5 5 or BB66

• It is getting hard and complicated • Eye-ball simplification on several

submaps is error-prone, leading to sub-optimal results

• Do we have a better algorithm?– Quine-McCluskey Method