cs64 lecture12 kmaps

36
Karnaugh Maps for Simplification of Digital Logic Functions CS 64: Computer Organization and Design Logic Lecture #12 Winter 2019 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB

Upload: others

Post on 20-Jan-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

KarnaughMapsforSimplificationofDigitalLogicFunctions

CS64:ComputerOrganizationandDesignLogicLecture#12Winter2019

ZiadMatni,Ph.D.

Dept.ofComputerScience,UCSB

Administrative

•  Lab#6onThursday– Youdon’thavetogotolab

(sothistime,wewon’ttakeattendance)– ButtheTAswillbethereifyouneedhelp!– DuebyMonday

2/19/19 Matni,CS64,Wi19 2

DigitalCircuitDesignProcess

2/19/19 Matni,CS64,Wi19 3

CANTHISPROCESSBEREVERSED?

MoreSimplificationExamplesSimplifytheBooleanexpression:•  (A+B+C).(D+E)'+(A+B+C).(D+E)SimplifytheBooleanexpressionandwriteitoutonatruthtableasproof•  X.Z+Z.(X'+X.Y)

UseDeMorgan’sTheormtore-writetheexpressionbelowusingatleastoneORoperation•  NOT(X+Y.Z)

2/19/19 Matni,CS64,Wi19 4

ScalingUpSimplification

•  Whenwegettomorethan3variables,itbecomeschallengingtousetruthtables

•  WecaninsteaduseKarnaughMapstomakeitimmediatelyapparentastowhatcanbesimplified

2/19/19 Matni,CS64,Wi19 5

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

2/19/19 Matni,CS64,Wi19 6

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

0123

K-Mapswith3or4Variables

2/19/19 Matni,CS64,Wi19 7

Notetheadjacentplacementof:00011110

It’sNOT:

00011011

RulesforUsingK-MapsforSimplification

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

3.  Groupsmaybehorizontalorvertical,butnotdiagonal

2/19/19 Matni,CS64,Wi19 8

RulesforUsingK-MapsforSimplification

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

2/19/19 Matni,CS64,Wi19 9

RulesforUsingK-MapsforSimplification

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

2/19/19 Matni,CS64,Wi19 10

RulesforUsingK-MapsforSimplification

6.   Eachcellcontaininga“1”mustbeatleastinonegroup

2/19/19 Matni,CS64,Wi19 11

RulesforUsingK-MapsforSimplification

7.   Groupsmayoverlapesp.tomaximizegroupsize

2/19/19 Matni,CS64,Wi19 12

RulesforUsingK-MapsforSimplification

8.   Groupsmaywraparoundthetable.Theleftmostcellinarowmaybegroupedwiththerightmostcellandthetopcellinacolumnmaybegroupedwiththebottomcell.

2/19/19 Matni,CS64,Wi19 13

Example12vars

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

2/19/19 Matni,CS64,Wi19 14

0 1

0

1

YX

1

1

F(X,Y)=Y

Y=1column

Verifyingresults!

Example23vars

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

2/19/19 Matni,CS64,Wi19 15

00 01 11 10

0

1

XYZ

1111

F(X,Y,Z)=Z

Y=1 X=1

Verifyingresults!

Example33vars

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

2/19/19 Matni,CS64,Wi19 16

00 01 11 10

0

1

ABC

1111

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

1 1

Example44vars

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

2/19/19 Matni,CS64,Wi19 17

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

Example44vars

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

2/19/19 Matni,CS64,Wi19 18

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

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

2/19/19 Matni,CS64,Wi19 19

Exploiting“Don’tCares”

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

usuallybecauseofinvalidinputs

2/19/19 Matni,CS64,Wi19 20

ExampleofaDon’tCareSituation

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

•  4bits– But!4bitsconveymorenumbersthanthat!

•  Don’tforgetAthruF!

•  Notallbinaryvaluesmaptodecimal

2/19/19 Matni,CS64,Wi19 21

ExampleContinued…

2/19/19 Matni,CS64,Wi19 22

Don’tCare:SoWhat?

•  RecallthatinaK-map,wecanonlygroup1s

•  Becausethevalueofadon’tcareisirrelevant,wecantreatitasa1ifitisconvenienttodoso(ora0ifthatwouldbemoreconvenient)

2/19/19 Matni,CS64,Wi19 23

Example

•  Acircuitthatcalculatesifthe4-bitbinarycodedsingledigitdecimalinput%2==0

•  So,although4-bitswillgivemenumbersfrom0to15,Idon’tcareabouttheonesthatyield10to15.

2/19/19 Matni,CS64,Wi19 24

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

ExampleasaK-Map

2/19/19 Matni,CS64,Wi19 25

0 1 0 1

IfWeDon’tExploit“Don’tCares”

2/19/19 Matni,CS64,Wi19 26

0 1 0 1

R=I1I0I3+I1I0I3+I0I1I2I3

IfWeDOExploit“Don’tCares”

2/19/19 Matni,CS64,Wi19 27

0 1 0 1

R=I0

CombinatorialLogicDesigns

•  Whenyoucombinemultiplelogicblockstogethertoformamorecomplexlogicfunction/circuit

2/19/19 Matni,CS64,Wi19 28

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

Exercise1

•  Giventhefollowingtruthtable,drawtheresultinglogiccircuit

– STEP1:DrawtheK-Mapandsimplifythefunction

– STEP2:Constructthecircuitfromthenowsimplifiedfunction

2/19/19 Matni,CS64,Wi19 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

Exercise1–Step1Getthesimplifiedfunction

2/19/19 Matni,CS64,Wi19 30

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

Exercise1–Step2Drawthelogiccircuitdiagram

2/19/19 Matni,CS64,Wi19 31

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

AC

CBD

F

Exercise2

•  Giventhefollowingtruthtable,drawtheresultinglogiccircuit

2/19/19 Matni,CS64,Wi19 32

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

Exercise3

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

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

2/19/19 Matni,CS64,Wi19 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

X

Exercise3

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

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

2/19/19 Matni,CS64,Wi19 34

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

YOURTO-DOs

•  Lab6!

2/19/19 Matni,CS64,Wi19 35

2/19/19 Matni,CS64,Wi19 36