Upload
lamtu
View
215
Download
0
Embed Size (px)
Citation preview
IntroductiontoDigitalLogic
CS64:ComputerOrganizationandDesignLogicLecture#11
ZiadMatni
Dept.ofComputerScience,UCSB
Administrative
• Re:MidtermExam#1
• Re:MidtermExam#2– NextThursday!– Everythingfromlectures7thru12
5/15/18 Matni,CS64,Sp18 2
Administrative
• Lab#6(nextweek)areexercisesthatdonotrequireacomputer– Youare*excused*fromgoingtoMondaylabnextweek,butT.Aswillbetheretohelp,ifyouneedit
– MaterialwecovertodayandonTuesdaywillbenecessarytofinishLab#6
• Lab#6willstillbedueendofdayFriday
• Lab#7willbedifferent…!
5/15/18 Matni,CS64,Sp18 3
Administrative
• Mid-quarterevaluationsforT.AsandforProf.– LinksonPiazza– Optionaltodo,butveryappreciatedbyusall!– DeadlineisMonday
5/15/18 Matni,CS64,Sp18 4
LectureOutline
• IntrotoBinary(Digital)LogicGates
• TruthTableConstruction
• LogicFunctionsandtheirSimplifications
• TheLawsofBinaryLogic
5/15/18 Matni,CS64,Sp18 5
Digitali.e.BinaryLogic
• Electroniccircuitswhenusedincomputersareaseriesofswitches
• 2possiblestates:eitherON(1)andOFF(0)
• Perfectforbinarylogicrepresentation!
5/15/18 Matni,CS64,Sp18 6
BasicBuildingBlocksofDigitalLogic
• Sameasthebitwiseoperators:ANDORXORNOTetc...
• Weoftenrefertotheseas“logicgates”indigitaldesign
5/15/18 Matni,CS64,Sp18 7
GraphicalSymbolsandTruthTablesANDandNAND
A B A.B0 0 00 1 01 0 01 1 1
5/15/18 Matni,CS64,Sp18 10
A B A.Bor!(A.B)
0 0 10 1 11 0 11 1 0
≡
GraphicalSymbolsandTruthTablesORandNOR
A B A+B0 0 00 1 11 0 11 1 1
5/15/18 Matni,CS64,Sp18 11
A B A+Bor!(A+B)
0 0 10 1 01 0 01 1 0
≡
ConstructingTruthTables
• T.TscanbeappliedtoANYdigitalcircuit
• TheyshowALLpossibleinputswithALLpossibleoutputs
• NumberofentriesintheT.T.
=2N,whereNisthenumberofinputs
5/15/18 Matni,CS64,Sp18 13
Example:ConstructingtheT.Tofa1-bitAdder
• Recallthe1-bitadder:
• 3inputs:I1andI2andCI– Input1,Input2,andCarry-In– HowmanyentriesintheT.T.isthat?
• 2outputs:RandCO– Result,andCarry-Out– Youcanhavemultipleoutputs:eachwillstilldependonsomecombinationoftheinputs
5/15/18 Matni,CS64,Sp18 14
EXAMPLE:
1 1
0
0
1
Example:ConstructingtheT.Tofa1-bitAdder
# I1 I2 CI CO R0 0 0 0 0 01 0 0 1 0 12 0 1 0 0 13 0 1 1 1 04 1 0 0 0 15 1 0 1 1 06 1 1 0 1 07 1 1 1 1 1
5/15/18 Matni,CS64,Sp18 16
INPUTS OUTPUTS
LogicFunctions• AnoutputfunctionFcanbeseenasacombinationof1or
moreinputs• Example:
F=A.B+C (allsinglebits)EquivalentinC/C++:
booleanf(booleana,booleanb,booleanc) { return((a&b)|c) }
5/15/18 Matni,CS64,Sp18 17
ORandANDasSumandProduct• Logicfunctionsareoftenexpressedwithbasiclogicbuilding
blocks,likeORsandANDsandNOTs,etc…
• ORissometimesreferredtoas“logicalsum”or“logicalunion”– Partlywhyit’ssymbolizedas“+”– BUTIT’SNOTTHESAMEASNUMERICALADDITION!!!!!!
• ANDas“logicalproduct”or“logicaldisjunction”– Partlywhyit’ssymbolizedas“.”– BUTIT’SNOTTHESAMEASNUMERICALMULTIPLICATION!!!!!!
5/15/18 Matni,CS64,Sp18 18
Example
• AXORBtakesthevalue“1”(i.e.isTRUE)ifandonlyif– A=0,B=1 i.e.!A.BisTRUE,or– A=1,B=0 i.e.A.!BisTRUE
• Inotherwords, AXORB isTRUEiff(ifandonlyif) A!B+!ABisTRUE
A+B=!A.B+A.!BWhichcanalsobewrittenas:A.B+A.B
5/15/18 Matni,CS64,Sp18 19
A B A+B0 0 00 1 11 0 11 1 0
RepresentingtheCircuitGraphically
A+B=!A.B+A.!B
Matni,CS64,Sp18
A B A+B0 0 00 1 11 0 11 1 0
Q:Doesittakeanytimeforaelectronicsignaltogothru3“layers”oflogicgates?
A:Ideally,NO,itallhappenssimultaneously.Inreality,OFCOURSEittakestime(it’scalledlatency)
A
A
B
B
A+B
WhatisTheLogicalFunctionforTheHalfAdder?
# I1 I2 CO R0 0 0 0 01 0 1 0 12 1 0 0 13 1 1 1 0
5/15/18 Matni,CS64,Sp18 21
INPUTS OUTPUTS
CO=I1.I2R=I1+I2
HalfAdder1-bitadderthatdoesnothaveaCarry-In(Ci)bit.Thislogicblockhasonly21-bitinputsand21-bitoutputs
Ourattempttodescribetheoutputsasfunctions
oftheinputs:
WhatisTheLogicalFunctionforAFull1-bitadder?
# I1 I2 CI CO R0 0 0 0 0 01 0 0 1 0 12 0 1 0 0 13 0 1 1 1 04 1 0 0 0 15 1 0 1 1 06 1 1 0 1 07 1 1 1 1 1
5/15/18 Matni,CS64,Sp18 22
INPUTS OUTPUTS
Ans.: CO=!I1.I2.CI+I1.!I2.CI+I1.I2.!CI+I1.I2.CI R=!I1.!I2.CI+!I1.I2.!CI+I1.!I2.!CI+I1.I2.CI
MinimizationofBinaryLogic• Why?
– It’sMUCHeasiertoreadandunderstand…– Savesmemory(software)and/orphysicalspace(hardware)– Runsfaster/performsbetter
• Why?...rememberlatency?
• Forexample,whenwedotheT.T.for(seedemoonboard): X=A.B+A.!B+B.!A,wefindthatitisthesameas
(savedourselvesabunchoflogicgates!)
5/15/18 Matni,CS64,Sp18 23
A+B
UsingT.Tsvs.UsingLogicRules• Inanefforttosimplifyalogicfunction,wedon’talways
havetouseT.Ts–wecanuselogicrulesinstead
Example:Whatarethefollowinglogicoutcomes?A.AA+A
A.1A+1
A.0A+0
5/15/18 Matni,CS64,Sp18 24
AAA10A
UsingT.Tsvs.UsingLogicRules• BinaryLogicworksinAssociativeways– (A.B).C isthesameas A.(B.C)– (A+B)+C isthesameas A+(B+C)
• ItalsoworksinDistributiveways– (A+B).C isthesameas:A.C+B.C– (A+B).(A+C) isthesameas:
A.A+A.C+B.A+B.C=A+A.C+A.B+B.C=A+B.C
5/15/18 Matni,CS64,Sp18 25
MoreExamplesofMinimizationa.k.aSimplification
• Simplify: R =A.B+!A.B =(A+!A).B =B
• Simplify: R =!ABCD+ABCD+!AB!CD+AB!CD
=BCD(A+!A)+!AB!CD+AB!CD =BCD+B!CD(!A+A) =BCD+B!CD =BD(C+!C) =BD
5/15/18 Matni,CS64,Sp18 26
Let’sverifyitwithatruth-table
Let’sverifyitwithatruth-table
Note:often,theANDdotsymbol(.)isomitted,butunderstoodtobethere(likewithmultiplicationdotsymbol)
MoreSimplificationExercises
• Simplify: R =!A!BC+!A!B!C+!ABC+!AB!C+A!BC =!A(C+!C)+!AB(C+!C)+A!BC =!A+!AB+A!BC =!A+A!BC
• ReformulateusingonlyANDandNOTlogic:
R =!AC+!BC =C(!A+!B) =C.!(A.B) ßDeMorgan’sLaw
5/15/18 Matni,CS64,Sp18 27
Let’sverifyitwithatruth-table
MoreSimplificationExamplesSimplifytheBooleanexpression:• (A+B+C)(D+E)'+(A+B+C)(D+E)SimplifytheBooleanexpressionandwriteitoutonatruthtableasproof• XZ+Z(X'+XY)
UseDeMorgan’sTheormtore-writetheexpressionbelowusingatleastoneORoperation• NOT(X+YZ)
5/15/18 Matni,CS64,Wi18 30
ScalingUpSimplification
• Whenwegettomorethan3variables,itbecomeschallengingtousetruthtables
• WecaninsteaduseKarnaughMapstomakeitimmediatelyapparentastowhatcanbesimplified
5/15/18 Matni,CS64,Wi18 31
ExampleofaK-MapA B f(A,B)0 0 a0 1 b1 0 c1 1 d
5/15/18 Matni,CS64,Wi18 32
A B f(A,B)0 0 00 1 11 0 11 1 1
0123
MoreonK-MapsNextWeek!
YOURTO-DOs
• FinishLab#5bytomorrow!
• Optional:Dotheonlinemid-termevaluations– SeeannouncementonPiazzaforlinks
• NextTime:MoreK-MapsandCombinatorialLogic
5/15/18 Matni,CS64,Sp18 33