karnaugh maps and other topic on combinatorial logic · k-map rules summary 1. groups can contain...
TRANSCRIPT
KarnaughMapsandOtherTopiconCombinatorialLogic
CS64:ComputerOrganizationandDesignLogicLecture#12Fall2018
ZiadMatni,Ph.D.
Dept.ofComputerScience,UCSB
Administrative
• Lab#7onTuesday• DuebySundayatmidnight– NotFriday…HappyThanksgiving!
• NoclassthisWednesday!JJJ
11/18/18 Matni,CS64,Fa18 2
LectureOutline
• LogicFunctionsandtheirSimplifications:
TruthTableUsevs.KarnaughMaps
11/18/18 Matni,CS64,Fa18 3
ScalingUpSimplification
• Whenwegettomorethan3variables,itbecomeschallengingtousetruthtables
• WecaninsteaduseKarnaughMapstomakeitimmediatelyapparentastowhatcanbesimplified
11/18/18 Matni,CS64,Fa18 4
ExampleofaK-MapA B f(A,B)0 0 a0 1 b1 0 c1 1 d
11/18/18 Matni,CS64,Fa18 5
A B f(A,B)0 0 00 1 11 0 11 1 1
0123
K-Mapswith3or4Variables
11/18/18 Matni,CS64,Fa18 6
Notetheadjacentplacementof:00011110
It’sNOT:
00011011
RulesforUsingK-MapsforSimplification
1. Grouptogetheradjacentcellscontaining“1”2. Groupsshouldnotincludeanythingcontaining“0”
3. Groupsmaybehorizontalorvertical,butnotdiagonal
11/18/18 Matni,CS64,Fa18 7
RulesforUsingK-MapsforSimplification
4. Groupsmustcontain1,2,4,8,oringeneral2ncells.
11/18/18 Matni,CS64,Fa18 8
RulesforUsingK-MapsforSimplification
5. Eachgroupmustbeaslargeaspossible(Otherwisewe’renotbeingasminimalaswecanbe, eventhoughwe’renotbreakinganyBooleanrules)
11/18/18 Matni,CS64,Fa18 9
RulesforUsingK-MapsforSimplification
6. Eachcellcontaininga“1”mustbeatleastinonegroup
11/18/18 Matni,CS64,Fa18 10
RulesforUsingK-MapsforSimplification
7. Groupsmayoverlapesp.tomaximizegroupsize
11/18/18 Matni,CS64,Fa18 11
RulesforUsingK-MapsforSimplification
8. Groupsmaywraparoundthetable.Theleftmostcellinarowmaybegroupedwiththerightmostcellandthetopcellinacolumnmaybegroupedwiththebottomcell.
11/18/18 Matni,CS64,Fa18 12
Example12vars
F(X,Y)=XY+Y=Y(X+1)=Y
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 18
Exploiting“Don’tCares”
• Anoutputvariablethat’sdesignated“don’tcare”(symbol=X)meansthatitcouldbea0ora1(i.e.we“don’tcare”which)– Thatis,itisunspecified,
usuallybecauseofinvalidinputs
11/18/18 Matni,CS64,Fa18 19
ExampleofaDon’tCareSituation
• Considercodingalldecimaldigits(say,foradigitalclockapp):– 0thru9---requireshowmanybits?
• 4bits– But!4bitsconveymorenumbersthanthat!
• Don’tforgetAthruF!
• Notallbinaryvaluesmaptodecimal
11/18/18 Matni,CS64,Fa18 20
ExampleContinued…
11/18/18 Matni,CS64,Fa18 21
Don’tCare:SoWhat?
• RecallthatinaK-map,wecanonlygroup1s
• Becausethevalueofadon’tcareisirrelevant,wecantreatitasa1ifitisconvenienttodoso(ora0ifthatwouldbemoreconvenient)
11/18/18 Matni,CS64,Fa18 22
Example
• Acircuitthatcalculatesifthe4-bitbinarycodedsingledigitdecimalinput%2==0
• So,although4-bitswillgivemenumbersfrom0to15,Idon’tcareabouttheonesthatyield10to15.
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 24
0 1 0 1
IfWeDon’tExploit“Don’tCares”
11/19/18 Matni,CS64,Fa18 25
0 1 0 1
R=I1I0I3+I1I0I3+I0I1I2I3
IfWeDOExploit“Don’tCares”
11/19/18 Matni,CS64,Fa18 26
0 1 0 1
R=I0
CombinatorialLogicDesigns
• Whenyoucombinemultiplelogicblockstogethertoformamorecomplexlogicfunction/circuit
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 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
11/18/18 Matni,CS64,Fa18 30
F(A,B,C)=B.C’.D’+A.C
AC
CBD
F
Exercise2
• Giventhefollowingtruthtable,drawtheresultinglogiccircuit
11/18/18 Matni,CS64,Fa18 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’)
11/18/18 Matni,CS64,Fa18 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’)
11/18/18 Matni,CS64,Fa18 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
Multiplexer• Alogicalselector:– SelecteitherinputAorinputBtobetheoutput
//ifs=0,outputisa//ifs=1,outputisbintmux(inta,intb,ints){if(!s)returna;elsereturnb;
}11/18/18 Matni,CS64,Fa18 34
Multiplexer(Muxforshort)
• Typicallyhas3groupsofinputsand1output– IN:2data,1select– OUT:1data
• 1oftheinputdatalinesgetsselectedtobecometheoutput,basedonthe3rd(select)input– If“Sel”=0,thenI0getstobetheoutput– If“Sel”=1,thenI1getstobetheoutput
• TheoppositeofaMuxiscalledaDemulitplexer(orDemux)
11/18/18 Matni,CS64,Fa18 35
MuxConfigurations
11/18/18 Matni,CS64,Fa18 36
MuxescanhaveI/Othataremultiplebits
Ortheycanhavemorethantwodatainputs
2:1
A0A1B0B1SEL
O0O1
Thisiscalleda2-bit,2-to-1mux
6:1
ABCDEFSEL
O
Thisiscalleda1-bit,6-to-1mux
TheUseofMultiplexers
• Makesitpossibleforseveralsignals(variables)toshareoneresource– Verycommonlyusedindatacommunicationlines
11/18/18 Matni,CS64,Fa18 37Mux De
mux
… …DataLines
DataLines
Select
Shareddataline(“trunk”)
Select
MuxTruthTableandLogicCircuit1-bitMux
I0 I1 S O0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
11/18/18 Matni,CS64,Fa18 38
00 01 11 10
0
1
I0I1S
1
11
1
O=S.I1+S’.I0
I0I1
S
O
=linesarephysicallyconnected
00011011
YOURTO-DOs
• Lab#7onTuesday–DuebySundayatmidnight
• NoclassonWednesday!JJJ
11/18/18 Matni,CS64,Fa18 39
11/18/18 Matni,CS64,Fa18 40