XOR gate - Wikipedia

文章推薦指數: 80 %
投票人數:10人

XOR gate is a digital logic gate that gives a true (1 or HIGH) output when the number of ... An XOR gate circuit can be made from four NAND gates. XORgate FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch Logicgate ThisarticleisaboutXORdigitallogicgate(e.g.SN7486orCD4030B).ForXORlogicaloperation,seeExclusiveor.Forotheruses,seeXOR(disambiguation). Input Output A B AXORB 0 0 0 0 1 1 1 0 1 1 1 0 CMOSXORgate XORgate(sometimesEOR,orEXORandpronouncedasExclusiveOR)isadigitallogicgatethatgivesatrue(1orHIGH)outputwhenthenumberoftrueinputsisodd.AnXORgateimplementsanexclusiveor( ↮ {\displaystyle\nleftrightarrow} )frommathematicallogic;thatis,atrueoutputresultsifone,andonlyone,oftheinputstothegateistrue.Ifbothinputsarefalse(0/LOW)orbotharetrue,afalseoutputresults.XORrepresentstheinequalityfunction,i.e.,theoutputistrueiftheinputsarenotalikeotherwisetheoutputisfalse.AwaytorememberXORis"musthaveoneortheotherbutnotboth". XORcanalsobeviewedasadditionmodulo2.Asaresult,XORgatesareusedtoimplementbinaryadditionincomputers.AhalfadderconsistsofanXORgateandanANDgate.Otherusesincludesubtractors,comparators,andcontrolledinverters.[1] Thealgebraicexpressions A ⋅ B ¯ + A ¯ ⋅ B {\displaystyleA\cdot{\overline{B}}+{\overline{A}}\cdotB} or ( A + B ) ⋅ ( A ¯ + B ¯ ) {\displaystyle(A+B)\cdot({\overline{A}}+{\overline{B}})} or A ⊕ B {\displaystyleA\oplusB} allrepresenttheXORgatewithinputsAandB.ThebehaviorofXORissummarizedinthetruthtableshownontheright. Contents 1Symbols 2Pass-gate-logicwiring 2.1Analyticalrepresentation 3Alternatives 4Morethantwoinputs 5Applications 5.1Usesinaddition 5.2Pseudo-randomnumbergenerator 5.3Correlationandsequencedetection 5.4Phasedetectors 6Seealso 7References Symbols[edit] TherearethreeschematicsymbolsforXORgates:thetraditionalANSIandDINsymbolsandtheIECsymbol.Insomecases,theDINsymbolisusedwith⊕insteadof≢.FormoreinformationseeLogicGateSymbols. ANSIXORSchematicSymbol IECXORSchematicSymbol DINXORSchematicSymbol Thelogicsymbols⊕,Jpq,and⊻canbeusedtodenoteanXORoperationinalgebraicexpressions. C-likelanguagesusethecaretsymbol^todenotebitwiseXOR.(Notethatthecaretdoesnotdenotelogicalconjunction(AND)intheselanguages,despitethesimilarityofsymbol.) Pass-gate-logicwiring[edit] AnXORgatecanbeconstructedusingMOSFETs.HereisadiagramofapasstransistorlogicimplementationofanXORgate.[2][3][4][5][6] TransmissionGateLogicwiringofanXORgate Note:The"Rss"resistorpreventsshuntingcurrentdirectlyfrom"A"and"B"totheoutput.Withoutit,ifthecircuitthatprovidesinputsAandBdoesnothavetheproperdrivingcapability,theoutputmightnotswingrailtorailorbeseverelyslew-ratelimited.The"Rss"resistoralsolimitsthecurrentfromVddtogroundwhichprotectsthetransistorsandsavesenergywhenthetransistorsaretransitioningbetweenstates. Analyticalrepresentation[edit] f ( a , b ) = a + b − 2 a b {\displaystylef(a,b)=a+b-2ab} isananalyticalrepresentationofXORgate: f ( 0 , 0 ) = 0 + 0 − 2 ⋅ 0 ⋅ 0 = 0 {\displaystylef(0,0)=0+0-2\cdot0\cdot0=0} f ( 0 , 1 ) = 0 + 1 − 2 ⋅ 0 ⋅ 1 = 1 {\displaystylef(0,1)=0+1-2\cdot0\cdot1=1} f ( 1 , 0 ) = 1 + 0 − 2 ⋅ 1 ⋅ 0 = 1 {\displaystylef(1,0)=1+0-2\cdot1\cdot0=1} f ( 1 , 1 ) = 1 + 1 − 2 ⋅ 1 ⋅ 1 = 0 {\displaystylef(1,1)=1+1-2\cdot1\cdot1=0} f ( a , b ) = | a − b | {\displaystylef(a,b)=|a-b|} isanalternativeanalyticalrepresentation. Alternatives[edit] XORgatecircuitusingthreemixedgates Ifaspecifictypeofgateisnotavailable,acircuitthatimplementsthesamefunctioncanbeconstructedfromotheravailablegates.AcircuitimplementinganXORfunctioncanbetriviallyconstructedfromanXNORgatefollowedbyaNOTgate.Ifweconsidertheexpression ( A ⋅ B ¯ ) + ( A ¯ ⋅ B ) {\displaystyle(A\cdot{\overline{B}})+({\overline{A}}\cdotB)} ,wecanconstructanXORgatecircuitdirectlyusingAND,ORandNOTgates.However,thisapproachrequiresfivegatesofthreedifferentkinds. Asalternative,ifdifferentgatesareavailablewecanapplyBooleanalgebratotransform ( A ⋅ B ¯ ) + ( A ¯ ⋅ B ) ≡ ( A + B ) ⋅ ( A ¯ + B ¯ ) {\displaystyle(A\cdot{\overline{B}})+({\overline{A}}\cdotB)\equiv(A+B)\cdot({\overline{A}}+{\overline{B}})} asstatedabove,andapplydeMorgan'sLawtothelasttermtoget ( A + B ) ⋅ ( A ⋅ B ) ¯ {\displaystyle(A+B)\cdot{\overline{(A\cdotB)}}} whichcanbeimplementedusingonlythreegatesasshownontheright. AnXORgatecircuitcanbemadefromfourNANDgates.Infact,bothNANDandNORgatesareso-called"universalgates"andanylogicalfunctioncanbeconstructedfromeitherNANDlogicorNORlogicalone.IfthefourNANDgatesarereplacedbyNORgates,thisresultsinanXNORgate,whichcanbeconvertedtoanXORgatebyinvertingtheoutputoroneoftheinputs(e.g.withafifthNORgate). Desiredgate NANDconstruction NORconstruction AnalternativearrangementisoffiveNORgatesinatopologythatemphasizestheconstructionofthefunctionfrom ( A + B ) ⋅ ( A ¯ + B ¯ ) {\displaystyle(A+B)\cdot({\overline{A}}+{\overline{B}})} ,notingfromdeMorgan'sLawthataNORgateisaninverted-inputANDgate.AnotheralternativearrangementisoffiveNANDgatesinatopologythatemphasizestheconstructionofthefunctionfrom ( A ⋅ B ¯ ) + ( A ¯ ⋅ B ) {\displaystyle(A\cdot{\overline{B}})+({\overline{A}}\cdotB)} ,notingfromdeMorgan'sLawthataNANDgateisaninverted-inputORgate. Desiredgate NANDconstruction NORconstruction FortheNANDconstructions,theupperarrangementrequiresfewergates.FortheNORconstructions,thelowerarrangementofferstheadvantageofashorterpropagationdelay(thetimedelaybetweenaninputchangingandtheoutputchanging). Morethantwoinputs[edit] Literalinterpretationofthename"exclusiveor",orobservationoftheIECrectangularsymbol,raisesthequestionofcorrectbehaviourwithadditionalinputs.Ifalogicgateweretoacceptthreeormoreinputsandproduceatrueoutputifexactlyoneofthoseinputsweretrue,thenitwouldineffectbeaone-hotdetector(andindeedthisisthecaseforonlytwoinputs).However,itisrarelyimplementedthiswayinpractice. Itismostcommontoregardsubsequentinputsasbeingappliedthroughacascadeofbinaryexclusive-oroperations:thefirsttwosignalsarefedintoanXORgate,thentheoutputofthatgateisfedintoasecondXORgatetogetherwiththethirdsignal,andsoonforanyremainingsignals.Theresultisacircuitthatoutputsa1whenthenumberof1satitsinputsisodd,anda0whenthenumberofincoming1siseven.Thismakesitpracticallyusefulasaparitygeneratororamodulo-2adder. Forexample,the74LVC1G386microchipisadvertisedasathree-inputlogicgate,andimplementsaparitygenerator.[7] Applications[edit] ExamplehalfaddercircuitdiagramExamplefulladdercircuitdiagram XORgatesandANDgatesarethetwomost-usedstructuresinVLSIapplications.[8] Usesinaddition[edit] TheXORlogicgatecanbeusedasaone-bitadderthataddsanytwobitstogethertooutputonebit.Forexample,ifweadd1plus1inbinary,weexpectatwo-bitanswer,10(i.e.2indecimal).SincethetrailingsumbitinthisoutputisachievedwithXOR,theprecedingcarrybitiscalculatedwithanANDgate.ThisisthemainprincipleinHalfAdders.AslightlylargerFullAddercircuitmaybechainedtogetherinordertoaddlongerbinarynumbers. Pseudo-randomnumbergenerator[edit] Pseudo-randomnumber(PRN)generators,specificallylinear-feedbackshiftregisters(LFSR),aredefinedintermsoftheexclusive-oroperation.Hence,asuitablesetupofXORgatescanmodelalinear-feedbackshiftregister,inordertogeneraterandomnumbers. Correlationandsequencedetection[edit] XORgatesproducea0whenbothinputsmatch.WhensearchingforaspecificbitpatternorPRNsequenceinaverylongdatasequence,aseriesofXORgatescanbeusedtocompareastringofbitsfromthedatasequenceagainstthetargetsequenceinparallel.Thenumberof0outputscanthenbecountedtodeterminehowwellthedatasequencematchesthetargetsequence.CorrelatorsareusedinmanycommunicationsdevicessuchasCDMAreceiversanddecodersforerrorcorrectionandchannelcodes.InaCDMAreceiver,correlatorsareusedtoextractthepolarityofaspecificPRNsequenceoutofacombinedcollectionofPRNsequences. Acorrelatorlookingfor11010inthedatasequence1110100101wouldcomparetheincomingdatabitsagainstthetargetsequenceateverypossibleoffsetwhilecountingthenumberofmatches(zeros): 1110100101(data) 11010(target) 00111(XOR)2zerobits 1110100101 11010 000005zerobits 1110100101 11010 011102zerobits 1110100101 11010 100112zerobits 1110100101 11010 010004zerobits 1110100101 11010 111110zerobits Matchesbyoffset: .  : : : : : : : ----------- 012345 Inthisexample,thebestmatchoccurswhenthetargetsequenceisoffsetby1bitandallfivebitsmatch.Whenoffsetby5bits,thesequenceexactlymatchesitsinverse.BylookingatthedifferencebetweenthenumberofonesandzerosthatcomeoutofthebankofXORgates,itiseasytoseewherethesequenceoccursandwhetherornotitisinverted.Longersequencesareeasiertodetectthanshortsequences. Phasedetectors[edit] XORgatesmaybeusedinsimplestphasedetectors.[9]: 425  Seealso[edit] Exclusiveor ANDgate ORgate Inverter(NOTgate) NANDgate NORgate XNORgate IMPLYgate Booleanalgebra Logicgate WikimediaCommonshasmediarelatedtoXORgates. References[edit] ^Fletcher,William(1980).Anengineeringapproachtodigitaldesign.Prentice-Hall.p. 98.ISBN 0-13-277699-5. ^ "DesigningcombinationallogicgatesinCMOS".p.233 ^"TransmissionGateXOR"Archived2017-08-16attheWaybackMachine. ^ "transmission-gateXOR(tinyXOR)"(via[1]) ^ "Figure3,ExclusiveORandXNORgate". ^ "Pass-TransistorLogic:TransmissionGateXOR"(p.11) ^74LVC1G386Archived2009-12-29attheWaybackMachinedatasheet ^"ComparisonofdifferentdesigntechniquesofXOR&ANDgateusingEDAsimulationtool".XOR&ANDgatesaremostimportantbasicbuildingblocksofanyVLSIapplications. ^Rabaey,JanM.(1996).Digitalintegratedcircuits :adesignperspective.UpperSaddleRiver,N.J.:Prentice-Hall.ISBN 978-0-13-178609-7. vteLogicalconnectives Tautology/True  ⊤ {\displaystyle\top} Alternativedenial (NANDgate)  ↑ {\displaystyle\uparrow} Converseimplication  ← {\displaystyle\leftarrow} Implication (IMPLYgate)  → {\displaystyle\rightarrow} Disjunction (ORgate)  ∨ {\displaystyle\lor} Negation (NOTgate)  ¬ {\displaystyle\neg} Exclusiveor (XORgate)  ↮ {\displaystyle\not\leftrightarrow} Biconditional (XNORgate)  ↔ {\displaystyle\leftrightarrow} Statement (Digitalbuffer) Jointdenial (NORgate)  ↓ {\displaystyle\downarrow} Nonimplication (NIMPLYgate)  ↛ {\displaystyle\nrightarrow} Conversenonimplication  ↚ {\displaystyle\nleftarrow} Conjunction (ANDgate)  ∧ {\displaystyle\land} Contradiction/False  ⊥ {\displaystyle\bot}  Philosophyportal Thisarticleneedsadditionalormorespecificcategories.Pleasehelpoutbyaddingcategoriestoitsothatitcanbelistedwithsimilararticles.(May2021) Retrievedfrom"https://en.wikipedia.org/w/index.php?title=XOR_gate&oldid=1097355929" Categories:LogicgatesHiddencategories:WebarchivetemplatewaybacklinksArticleswithshortdescriptionShortdescriptionmatchesWikidataCommonscategorylinkisonWikidataArticlesneedingadditionalcategoriesfromMay2021Pagesthatuseadeprecatedformatofthemathtags Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk English Views ReadEditViewhistory More Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Inotherprojects WikimediaCommons Languages አማርኛالعربيةAzərbaycancaCatalàČeštinaDeutschEspañolEuskaraفارسی한국어ՀայերենLatinaLombardМакедонскиNederlands日本語RomânăSimpleEnglishSlovenčinaСрпски/srpskiSuomiSvenskaதமிழ்TürkçeУкраїнська粵語中文 Editlinks



請為這篇文章評分?