Karnaugh Maps for Combinatorial Logic - GitHub Pages

35
Karnaugh Maps for Combinatorial Logic CS 64: Computer Organization and Design Logic Lecture #12 Ziad Matni Dept. of Computer Science, UCSB

Transcript of Karnaugh Maps for Combinatorial Logic - GitHub Pages

Page 1: Karnaugh Maps for Combinatorial Logic - GitHub Pages

KarnaughMapsforCombinatorialLogic

CS64:ComputerOrganizationandDesignLogicLecture#12

ZiadMatni

Dept.ofComputerScience,UCSB

Page 2: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Administrative

•  Re:MidtermExam#2– OnThursday!– Everythingfromlectures7thru12

5/15/18 Matni,CS64,Sp18 2

Page 3: Karnaugh Maps for Combinatorial Logic - GitHub Pages

LectureOutline

•  LogicFunctionsandtheirSimplifications:

TruthTableUsevs.KarnaughMaps

5/15/18 Matni,CS64,Wi18 3

Page 4: Karnaugh Maps for Combinatorial Logic - GitHub Pages

ScalingUpSimplification

•  Whenwegettomorethan3variables,itbecomeschallengingtousetruthtables

•  WecaninsteaduseKarnaughMapstomakeitimmediatelyapparentastowhatcanbesimplified

5/15/18 Matni,CS64,Wi18 4

Page 5: Karnaugh Maps for Combinatorial Logic - GitHub Pages

ExampleofaK-MapA B f(A,B)0 0 a0 1 b1 0 c1 1 d

5/15/18 Matni,CS64,Wi18 5

A B f(A,B)0 0 00 1 11 0 11 1 1

0123

Page 6: Karnaugh Maps for Combinatorial Logic - GitHub Pages

K-Mapswith3or4Variables

5/15/18 Matni,CS64,Wi18 6

Notetheadjacentplacementof:00011110

It’sNOT:

00011011

Page 7: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

1.  Grouptogetheradjacentcellscontaining“1”2.  Groupsshouldnotincludeanythingcontaining“0”

3.  Groupsmaybehorizontalorvertical,butnotdiagonal

5/15/18 Matni,CS64,Wi18 7

Page 8: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

4.   Groupsmustcontain1,2,4,8,oringeneral2ncells.

5/15/18 Matni,CS64,Wi18 8

Page 9: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

5.   Eachgroupmustbeaslargeaspossible(Otherwisewe’renotbeingasminimalaswecanbe, eventhoughwe’renotbreakinganyBooleanrules)

5/15/18 Matni,CS64,Wi18 9

Page 10: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

6.   Eachcellcontaininga“1”mustbeatleastinonegroup

5/15/18 Matni,CS64,Wi18 10

Page 11: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

7.   Groupsmayoverlapesp.tomaximizegroupsize

5/15/18 Matni,CS64,Wi18 11

Page 12: Karnaugh Maps for Combinatorial Logic - GitHub Pages

RulesforUsingK-MapsforSimplification

8.   Groupsmaywraparoundthetable.Theleftmostcellinarowmaybegroupedwiththerightmostcellandthetopcellinacolumnmaybegroupedwiththebottomcell.

5/15/18 Matni,CS64,Wi18 12

Page 13: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example12vars

F(X,Y)=XY+Y=Y(X+1)=Y

5/15/18 Matni,CS64,Wi18 13

0 1

0

1

YX

1

1

F(X,Y)=Y

Y=1column

Verifyingresults!

Page 14: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example23vars

F(X,Y,Z)=XZ+Z(X'+XY)=XZ+ZX’+ZXY=Z(X+X’+XY)=Z(1+XY)=Z

5/15/18 Matni,CS64,Wi18 14

00 01 11 10

0

1

XYZ

1111

F(X,Y,Z)=Z

Y=1 X=1

Verifyingresults!

Page 15: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example33vars

!A!B!C+!A!BC+!ABC+!AB!C+A!B!C+AB!C

5/15/18 Matni,CS64,Wi18 15

00 01 11 10

0

1

ABC

1111

F(X,Y,Z)=!C+!A

1 1

Page 16: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example44vars

F(A,X,Y,Z)=AX+Z(X+A’+Y)=AX+ZX+ZA’+ZY

5/15/18 Matni,CS64,Wi18 16

00 01 11 10

00

01

11

10

XYAZ

1 1F(A,X,Y,Z)=ZA’+AX+ZY

11

1 1Z=1

A=1

Y=1 X=1

11

1

Page 17: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example44vars

F(A,B,C,D)=ABCD’+ABC’D+CD+A’B’+C’D

5/15/18 Matni,CS64,Wi18 17

00 01 11 10

00

01

11

10

ABCD

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

D=1

C=1

B=1 A=1

1

1

1 1 1 1

1

1

1

1 1

Page 18: Karnaugh Maps for Combinatorial Logic - GitHub Pages

K-MapRulesSummary1.  Groupscancontainonly1s2.  Only1sinadjacentgroupsareallowed3.  GroupsmayONLYbehorizontalorvertical(nodiagonals)4.  Thenumberof1sinagroupmustbeapoweroftwo(1,2,4,8...)5.  GroupsmustbeaslargeANDasfewinno.sas“legally”possible6.  All1smustbelongtoagroup,evenifit’sagroupofoneelement7.  Overlappinggroupsarepermitted8.  Wrappingaroundthemapispermitted

5/15/18 Matni,CS64,Wi18 18

Page 19: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exploiting“Don’tCares”

•  Anoutputvariablethat’sdesignated“don’tcare”(symbol=X)meansthatitcouldbea0ora1(i.e.we“don’tcare”which)– Thatis,itisunspecified,

usuallybecauseofinvalidinputs

5/15/18 Matni,CS64,Wi18 19

Page 20: Karnaugh Maps for Combinatorial Logic - GitHub Pages

ExampleofaDon’tCareSituation

•  Considercodingalldecimaldigits(say,foradigitalclockapp):– 0thru9---requireshowmanybits?•  4bits

– But!4bitsconveymorenumbersthanthat!•  Don’tforgetAthruF!

•  Notallbinaryvaluesmaptodecimal

5/15/18 Matni,CS64,Wi18 20

Page 21: Karnaugh Maps for Combinatorial Logic - GitHub Pages

ExampleContinued…

5/15/18 Matni,CS64,Wi18 21

Page 22: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Don’tCare:SoWhat?

•  RecallthatinaK-map,wecanonlygroup1s

•  Becausethevalueofadon’tcareisirrelevant,wecantreatitasa1ifitisconvenienttodoso(ora0ifthatwouldbemoreconvenient)

5/15/18 Matni,CS64,Wi18 22

Page 23: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Example

•  Acircuitthatcalculatesifthe4-bitbinarycodedsingledigitdecimalinput%2==0

•  So,although4-bitswillgivemenumbersfrom0to15,Idon’tcareabouttheonesthatyield10to15.

5/15/18 Matni,CS64,Wi18 23

I3 I2 I1 I0 R

0 0 0 0 1

0 0 0 1 0

0 0 1 0 1

0 0 1 1 0

0 1 0 0 1

0 1 0 1 0

0 1 1 0 1

0 1 1 1 0

1 0 0 0 1

1 0 0 1 0

1 0 1 0 X

1 0 1 1 X

1 1 0 0 X

1 1 0 1 X

1 1 1 0 X

1 1 1 1 X

Page 24: Karnaugh Maps for Combinatorial Logic - GitHub Pages

ExampleasaK-Map

5/15/18 Matni,CS64,Wi18 24

Page 25: Karnaugh Maps for Combinatorial Logic - GitHub Pages

IfWeDon’tExploit“Don’tCares”

5/15/18 Matni,CS64,Wi18 25

R=!I1!I0!I3+I1I0!I3+!I0!I1!I2

Page 26: Karnaugh Maps for Combinatorial Logic - GitHub Pages

IfWeDOExploit“Don’tCares”

5/15/18 Matni,CS64,Wi18 26

R=!I1!I0+I1I0

Page 27: Karnaugh Maps for Combinatorial Logic - GitHub Pages

CombinatorialLogicDesigns

•  Whenyoucombinemultiplelogicblockstogethertoformamorecomplexlogicfunction/circuit

5/15/18 Matni,CS64,Sp18 27

Whatistheoutput?A.B+C

Whatisitstruthtable?A B C F0 0 0 10 0 1 00 1 0 10 1 1 01 0 0 11 0 1 01 1 0 11 1 1 1

WhatisitsK-Map?00 01 11 10

01

ABC

1 1 111

Page 28: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise1

•  Giventhefollowingtruthtable,drawtheresultinglogiccircuit

– STEP1:DrawtheK-Mapandsimplifythefunction

– STEP2:Constructthecircuitfromthenowsimplifiedfunction

5/15/18 Matni,CS64,Sp18 28

A B C D F0 0 0 0 00 0 0 1 00 0 1 0 00 0 1 1 00 1 0 0 10 1 0 1 00 1 1 0 00 1 1 1 01 0 0 0 01 0 0 1 01 0 1 0 11 0 1 1 11 1 0 0 11 1 0 1 01 1 1 0 11 1 1 1 1

Page 29: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise1–Step1Getthesimplifiedfunction

5/15/18 Matni,CS64,Sp18 29

A B C D F0 0 0 0 00 0 0 1 00 0 1 0 00 0 1 1 00 1 0 0 10 1 0 1 00 1 1 0 00 1 1 1 01 0 0 0 01 0 0 1 01 0 1 0 11 0 1 1 11 1 0 0 11 1 0 1 01 1 1 0 11 1 1 1 1

00 01 11 10

00

01

11

10

ABCD

1 1

11

B=1 A=1

D=1

C=1

F(A,B,C)=B.C’.D’+A.C1 1

Page 30: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise1–Step2Drawthelogiccircuitdiagram

5/15/18 Matni,CS64,Sp18 30

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

AC

CBD

F

Page 31: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise2

•  Giventhefollowingtruthtable,drawtheresultinglogiccircuit

5/15/18 Matni,CS64,Sp18 31

A B C F0 0 0 10 0 1 10 1 0 10 1 1 01 0 0 11 0 1 11 1 0 01 1 1 0

00 01 11 10

0

1

ABC

111

F(A,B,C)=B’+A’.C’

1 1

B

AC

F

Page 32: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise3

•  Giventhefollowingschematicofacircuit,(a)writethefunctionand(b)filloutthetruthtable:

X=A.B+(A.C)’(notethatalsomeans:X=A.B+A’+C’)

5/15/18 Matni,CS64,Sp18 32

ABAC

X

A.B

(A.C)’

A B C X0 0 0 10 0 1 10 1 0 10 1 1 11 0 0 11 0 1 01 1 0 11 1 1 1

X

Page 33: Karnaugh Maps for Combinatorial Logic - GitHub Pages

Exercise3

•  Giventhefollowingschematicofacircuit,(a)writethefunctionand(b)filloutthetruthtable:

X=A.B+(A.C)’(notethatalsomeans:X=A.B+A’+C’)

5/15/18 Matni,CS64,Sp18 33

ABAC

X

A.B

(A.C)’

A B C X0 0 0 10 0 1 10 1 0 10 1 1 11 0 0 11 0 1 01 1 0 11 1 1 1

Page 34: Karnaugh Maps for Combinatorial Logic - GitHub Pages

YOURTO-DOs

•  StudyfortheMidtermonThursday!

•  FinishLab#6byFriday!

•  NextTime:SequentialLogic

5/15/18 Matni,CS64,Sp18 34

Page 35: Karnaugh Maps for Combinatorial Logic - GitHub Pages

5/15/18 Matni,CS64,Sp18 35