Karnaugh Maps for Combinatorial Logic - GitHub Pages
Transcript of Karnaugh Maps for Combinatorial Logic - GitHub Pages
KarnaughMapsforCombinatorialLogic
CS64:ComputerOrganizationandDesignLogicLecture#12
ZiadMatni
Dept.ofComputerScience,UCSB
Administrative
• Re:MidtermExam#2– OnThursday!– Everythingfromlectures7thru12
5/15/18 Matni,CS64,Sp18 2
LectureOutline
• LogicFunctionsandtheirSimplifications:
TruthTableUsevs.KarnaughMaps
5/15/18 Matni,CS64,Wi18 3
ScalingUpSimplification
• Whenwegettomorethan3variables,itbecomeschallengingtousetruthtables
• WecaninsteaduseKarnaughMapstomakeitimmediatelyapparentastowhatcanbesimplified
5/15/18 Matni,CS64,Wi18 4
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
K-Mapswith3or4Variables
5/15/18 Matni,CS64,Wi18 6
Notetheadjacentplacementof:00011110
It’sNOT:
00011011
RulesforUsingK-MapsforSimplification
1. Grouptogetheradjacentcellscontaining“1”2. Groupsshouldnotincludeanythingcontaining“0”
3. Groupsmaybehorizontalorvertical,butnotdiagonal
5/15/18 Matni,CS64,Wi18 7
RulesforUsingK-MapsforSimplification
4. Groupsmustcontain1,2,4,8,oringeneral2ncells.
5/15/18 Matni,CS64,Wi18 8
RulesforUsingK-MapsforSimplification
5. Eachgroupmustbeaslargeaspossible(Otherwisewe’renotbeingasminimalaswecanbe, eventhoughwe’renotbreakinganyBooleanrules)
5/15/18 Matni,CS64,Wi18 9
RulesforUsingK-MapsforSimplification
6. Eachcellcontaininga“1”mustbeatleastinonegroup
5/15/18 Matni,CS64,Wi18 10
RulesforUsingK-MapsforSimplification
7. Groupsmayoverlapesp.tomaximizegroupsize
5/15/18 Matni,CS64,Wi18 11
RulesforUsingK-MapsforSimplification
8. Groupsmaywraparoundthetable.Theleftmostcellinarowmaybegroupedwiththerightmostcellandthetopcellinacolumnmaybegroupedwiththebottomcell.
5/15/18 Matni,CS64,Wi18 12
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!
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!
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
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
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
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
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
ExampleofaDon’tCareSituation
• Considercodingalldecimaldigits(say,foradigitalclockapp):– 0thru9---requireshowmanybits?• 4bits
– But!4bitsconveymorenumbersthanthat!• Don’tforgetAthruF!
• Notallbinaryvaluesmaptodecimal
5/15/18 Matni,CS64,Wi18 20
ExampleContinued…
5/15/18 Matni,CS64,Wi18 21
Don’tCare:SoWhat?
• RecallthatinaK-map,wecanonlygroup1s
• Becausethevalueofadon’tcareisirrelevant,wecantreatitasa1ifitisconvenienttodoso(ora0ifthatwouldbemoreconvenient)
5/15/18 Matni,CS64,Wi18 22
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
ExampleasaK-Map
5/15/18 Matni,CS64,Wi18 24
IfWeDon’tExploit“Don’tCares”
5/15/18 Matni,CS64,Wi18 25
R=!I1!I0!I3+I1I0!I3+!I0!I1!I2
IfWeDOExploit“Don’tCares”
5/15/18 Matni,CS64,Wi18 26
R=!I1!I0+I1I0
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
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
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
Exercise1–Step2Drawthelogiccircuitdiagram
5/15/18 Matni,CS64,Sp18 30
F(A,B,C)=B.C’.D’+A.C
AC
CBD
F
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
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
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
YOURTO-DOs
• StudyfortheMidtermonThursday!
• FinishLab#6byFriday!
• NextTime:SequentialLogic
5/15/18 Matni,CS64,Sp18 34
5/15/18 Matni,CS64,Sp18 35