How is an XOR with more than 2 inputs supposed to work?

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

You can find a XOR gate that have more than two inputs, but they are not actually a 3 input XOR. They XOR input A and B and the result of ... ElectricalEngineeringStackExchangeisaquestionandanswersiteforelectronicsandelectricalengineeringprofessionals,students,andenthusiasts.Itonlytakesaminutetosignup. Signuptojointhiscommunity Anybodycanaskaquestion Anybodycananswer Thebestanswersarevotedupandrisetothetop Home Public Questions Tags Users Unanswered Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore HowisanXORwithmorethan2inputssupposedtowork? AskQuestion Asked 8years,7monthsago Modified 6years,2monthsago Viewed 140ktimes 37 16 \$\begingroup\$ I'vejuststartedstudyingcomputerengineering,andI'mhavingsomedoubtsregardingthebehavioroftheXORgate. I'vebeenprojectingcircuitswithLogisim,whoseXORsbehavedifferentlyfromwhatI'velearnt.Tome,itshouldbehaveasaparitygate,givingahighoutputwhenevertheinputsreceivesanoddcombination.Itdoesn't,though,formorethantwoinputs.Howshoulditbehave? IalsoreadinabookthatXORgatesarenotproducedwithmorethantwoinputs.Isthatcorrect?Why? digital-logic Share Cite Follow editedDec14,2013at21:30 uniquenamehere 84011goldbadge99silverbadges1919bronzebadges askedDec14,2013at20:28 gabrieljcsgabrieljcs 59411goldbadge44silverbadges77bronzebadges \$\endgroup\$ 6 1 \$\begingroup\$ Whynot(oralmostnever)with>2inputs?TwotypicalusesofXORgatesare1)tocheckforequality,and2)tocontrol/manipulatethepolarityofasignal.Neithermakessenseformorethan2inputs. \$\endgroup\$ – WoutervanOoijen Dec14,2013at22:38 1 \$\begingroup\$ Wouldn'tthesuminafull-adderberepresentedasA^B^Cin? \$\endgroup\$ – gabrieljcs Dec14,2013at23:50 \$\begingroup\$ Youcanexpressitthatway,butthatdoesnotmeanthatitisagoodwaytoimplementit. \$\endgroup\$ – WoutervanOoijen Dec15,2013at8:49 1 \$\begingroup\$ JustcheckedmyversionofLogisim,andthe"1andonly1"appearstobethedefaultbehaviorbutthereistheoptiontochangeittoanodd-parityfunction. \$\endgroup\$ – JoeHass Dec15,2013at22:36 \$\begingroup\$ Indeed,Joe.Thislinkhasadiscussionregardingthat,answeredbyLogisim'sdeveloper,CarlBurch. \$\endgroup\$ – gabrieljcs Dec16,2013at16:58  |  Show1morecomment 7Answers 7 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 30 \$\begingroup\$ Therearedifferentpointsofviewregardinghowanexclusive-ORgatewithmorethantwoinputsshouldbehave.MostoftensuchanXORgatebehaveslikeacascadeof2-inputgatesandperformsanodd-parityfunction.However,somepeopleinterpretthemeaningofexclusive-ORmoreliterallyandsaythattheoutputshouldbea1ifandonlyifexactlyoneoftheinputsisa1.IdoseemtorecallthatLogisimusesthelatterinterpretation,andsomewhereinmyrustymemoryIhaveseenitinanASICcelllibrary.OneofthetheinternationalstandardsymbolsforanXORgateisarectanglelabelledwith=1whichseemstobemoreconsistentwiththe"1andonly1"definition. EDIT:Thedefinitionofexclusive-ORas"1andonly1"isuncommonbutitcanbefound.Forexample,IEEE-Std91a-1991givesthesymbolfortheexclusive-ORonp.62withthenote:"Theoutputstandsatits1-stateifoneandonlyoneofthetwoinputsstandsatits1-state."Formorethan2inputsthestandardrecommendsusingthe"oddparity"symbolinstead.WebsitesthatdiscussthisconfusingsituationincludeXOR:TheInterestingGateandgatedemosatTAMS.Agooglesearchwillalsoturnupsitesthatclaimthat,strictlyspeaking,thereisnosuchthingasanXORgatewithmorethantwoinputs. Share Cite Follow editedDec16,2013at0:55 answeredDec14,2013at21:15 JoeHassJoeHass 8,20911goldbadge2525silverbadges3838bronzebadges \$\endgroup\$ 6 5 \$\begingroup\$ AsfarasI'mconcerned,thesecondone(1andonly1)istheonlycorrectwaytodothis-anythingelseisn'treallyexclusive. \$\endgroup\$ – Polynomial Dec14,2013at23:37 3 \$\begingroup\$ Thereisnodifferentpointofview,bothpointsaretechnicallycorrect,however"1ifonlyifexactlyoneoftheinputsisa1"doesn'texpandasyoumightthink.Whenyoucascade2inputXORs,eachoutputfeedingintothepinsofathirdXORthisshowstheabovepoint.Multi-inputgatesarederivedfromtheir2inputprimitives.Thusthe4inputtruthtableis((A⊕B)⊕(C⊕D))whichresultsinafinal1outputifthereareanoddnumberoftrueinputs. \$\endgroup\$ – KrisBahnsen Dec15,2013at21:39 \$\begingroup\$ @KrisBahnsenAstheOPpointedout,thereareindeedtwopointsofview(trythedefaultXORinLogisimifyouneedevidence).Yourassertionthatmulti-inputgatesarederivedfrom2-inputprimitivesisgivenasthoughitisuniversaltruthbutwehavealreadygivenyouacounter-example. \$\endgroup\$ – JoeHass Dec15,2013at22:34 \$\begingroup\$ @JoeHass,I'veneverusedlogisim,IprimarilyuseLogicWorks;inwhich,amulti-inputXORbehavesasIdescribedabove,oddnumberoftrueinputsisatrueoutput.ThewikipageonXOR(en.wikipedia.org/wiki/XOR)agreesthatwhatIsaidistrueaswell.Ialsohaveneveractuallyseenamulti-inputXORIC,soIcannotturntodatasheetstotryanddisprovewhatIsaid.Logisimseemstobetheonlythingthatimplementsthemulti-inputXORschemewiththelogic"1ifandonly..."Ifyoucanfindanothersource,IwilladmitIamwrongandthattherearemultipledefinitionsofXOR. \$\endgroup\$ – KrisBahnsen Dec15,2013at23:30 \$\begingroup\$ Goodclarification,thankyouforputtingthetimeinonresearchingthestandardsfarmorethanIhad. \$\endgroup\$ – KrisBahnsen Dec16,2013at7:53  |  Show1morecomment 11 \$\begingroup\$ OnatwogateXORtheoutputishighwhentheinputsaredifferent.Iftheinputsarethesametheoutputislow. Hencethistruthtable: YoucanfindaXORgatethathavemorethantwoinputs,buttheyarenotactuallya3inputXOR.TheyXORinputAandBandtheresultofthem"R"isthenXORwithinputC.AndtheresultofRXORCisthenXORwithinput4andsoon. HereisatruthtableforthethreeinputXORshown: AsimpleparityalgorithmisXORingbitsinareceivedmessageoverforexampleEthernet.IfthesenderandthereceiverknowthatXORingthemessagebitsshouldbe0(onebitinthemessageisprovidedtobeabletoaddaonesothatamessageofanylengthcanbe0whenXORed)thenthereceivercanknowif1bithasbeenflipped.Thisisabadparitycheckasitcanonlyfindoddnumberofbitchanges,butshowstheconcept. Share Cite Follow editedDec14,2013at21:08 answeredDec14,2013at21:02 uniquenamehereuniquenamehere 84011goldbadge99silverbadges1919bronzebadges \$\endgroup\$ 1 3 \$\begingroup\$ I'mamathematician,thatanswerlookshorribletome.Iunderstandthatistheoutputgenerallyintendedbya3-inputXORbut01101000seemsfarmorelogicaltome.+Niceanswer. \$\endgroup\$ – BenCrossley Jun5,2019at20:30 Addacomment  |  1 \$\begingroup\$ Ifyoutake4inputsandfeedtwotooneXORandtwotoanotherthen,takethetwoXORoutputsandfeedthemtoathirdXOR,itsoutputdoeswhatyoubelieveitshould(Ithink). Share Cite Follow answeredDec14,2013at21:01 AndyakaAndyaka 385k2323goldbadges319319silverbadges672672bronzebadges \$\endgroup\$ 3 1 \$\begingroup\$ I'mmoreconcernedaboutthewhys,nothows.Thanksfortheanswer,though. \$\endgroup\$ – gabrieljcs Dec15,2013at19:22 \$\begingroup\$ @root,actually,youasked"Howshoulditbehave?"Youdidn'taskwhyanywhere.Thisisacorrectanswer,ityields((A⊕B)⊕(C⊕D))whichisthesameasa4inputXOR,whichisthesameasmultiple2inputXORscascadedtogether. \$\endgroup\$ – KrisBahnsen Dec15,2013at21:29 \$\begingroup\$ You'reright.Sorryforthemisunderstanding. \$\endgroup\$ – gabrieljcs Dec16,2013at16:46 Addacomment  |  1 \$\begingroup\$ XORisnotcompletlyaparitygate.IfyoudefinetheoutputofXORas1whenoneandonlyoneoftheinputsis1thenathreeinputXORwouldgiveyou0forall-1input.Thisisnotusedveryoftenandsotherearefew3-inputXOR-gates. WhatmostpeoplemeanwhentheysayXORismodulo2additionwhichisaparitycheckerexactly.Mostgateslabeledas3-inputXORsareinfactmodulo2additiongates.Fortwoinputs,modulo2additionisthesamethingasXORbutthe0fromtheXORdescribedaboveisinsteada1inmodulo2gates.Modulo2gateswithanarbitrarynumberofinputscanbeproducedfromsimpletwo-inputXORgates. Share Cite Follow answeredDec14,2013at21:16 DuggieDuggie 1122bronzebadges \$\endgroup\$ Addacomment  |  1 \$\begingroup\$ ididabitofsearchonseeingyourquestionandfoundanICwhichisa3inputXORgate.74LVC1G386fromnxp.thelinktothenxpsiteshowingsearchresultsforthispartnumberinnxpsiteishttp://www.nxp.com/search?q=74lvc1g386&type=keyword&rows=10 Share Cite Follow answeredDec31,2013at14:48 MaheshMohandasanMaheshMohandasan 1133bronzebadges \$\endgroup\$ 4 2 \$\begingroup\$ Thanksforcontributing,butyouranswerwillbeworthlessifNXPchangestheirsearchengine.Pleasesummarizewhatyoufoundheresoitwillbeoflastingvalue. \$\endgroup\$ – JoeHass Dec31,2013at14:53 \$\begingroup\$ ijustsearchedtoseeifthereisanymanufactureprovideXORwithmorethan3inputsandfoundthisone...sothoughtit'dhelpishareit...hereisalinktotheirdatasheetnxp.com/documents/data_sheet/74LVC1G386.pdf \$\endgroup\$ – MaheshMohandasan Dec31,2013at15:04 1 \$\begingroup\$ Pleasedon'tpostanotherlink!Tellushowthethingworks! \$\endgroup\$ – JoeHass Dec31,2013at15:11 \$\begingroup\$ itsa3inputXORgatewhichfunctionsjustlikewe'vestudied/know.ie.,itgivesahigho/pforoddnumberofhighinputs(asfromthedatasheet).thatswhysharedthelink.:) \$\endgroup\$ – MaheshMohandasan Dec31,2013at15:22 Addacomment  |  1 \$\begingroup\$ So,Iwentthereandtested!Iwroteasmallverilogfile,simulatedandlookedatthewaveform. Itturnsoutthecorrectinterpretationforverilogis:Thereisanoddamountof1'sintheinputAKAInterpretation2ofthisarticle moduletop(y1,y2); outputy1,y2; rega,b,c; wirex1,x2; wiret; xor(t,a,b); xor(x2,t,c); assigny2=x2; assigny1=x1; xor(x1,a,b,c); initial begin $dumpfile("test.vcd"); $dumpvars(y1,y2,a,b,c,x1,x2); #20 #10a=0;b=0;c=0; #10a=0;b=0;c=1; #10a=0;b=1;c=0; #10a=0;b=1;c=1; #10a=1;b=0;c=0; #10a=1;b=0;c=1; #10a=1;b=1;c=0; #10a=1;b=1;c=1; #10a=0;b=0;c=0; end endmodule Share Cite Follow editedSep15,2015at19:37 answeredSep15,2015at19:27 mentatkgsmentatkgs 11122bronzebadges \$\endgroup\$ Addacomment  |  0 \$\begingroup\$ AsperthelogicofsimplemultiinputORgate,itassumesthethehighestvalueamongstallinputshoweveritdoesnottakeadecision.AsregardsEXOR(beingmixedupwithhalfadderbeingjustacoincidence,asitdoesnothappeninmultivaluelogicEXOR)ittakesadecisionastowhichoneishighestamongsttheinputsbutifthehighest(including0+0..1+1)aresameitfailstoselectamonsttheinputsmeansitcannottakeadecisionwhichonetochoosefrom.Nodecsionmeansoutputiszero.Forexampleifsomeoneisaskedtobuymaximumnumberofsweetsofonebrandinonedollerandiftherearetwobrands(radix=2)thenhecanselecttheonehavinghighestsweetcountbutifbothbrandareavailableatfreeofcosthecannotselectany(means0,0)likewiseifboththebrandsoffersamenumber(1,1)ofsweetshecannottakeadecisionmeansoutputiszero.Samelogiccanbeextentedfor3,4ormorenumberofbrands(higherradix)ofsweets.Thisequallyapplicabletomultivaluelogic.(x+x+..+x=0wherexcanhaveanyvalue),InthreeinputEXORgate1+1+1=0(asagainstthenormalinterpretation1+1+1=1whichappearstobewrong,beingmixedupwithparity). V.T.Ingole,PhD Share Cite Follow answeredMar20,2015at3:16 vijayingolevijayingole 22011silverbadge44bronzebadges \$\endgroup\$ 1 \$\begingroup\$ Thisexplanationisunnecessarilycomplicated,anddoesn'tseemtodefinitivelyanswerthequestionanyway. \$\endgroup\$ – user39382 Sep16,2015at0:04 Addacomment  |  Highlyactivequestion.Earn10reputation(notcountingtheassociationbonus)inordertoanswerthisquestion.Thereputationrequirementhelpsprotectthisquestionfromspamandnon-answeractivity. Nottheansweryou'relookingfor?Browseotherquestionstaggeddigital-logicoraskyourownquestion. TheOverflowBlog AconversationwithStackOverflow’snewCTO,JodyBailey(Ep.461) StackExchangesitesaregettingprettierfaster:IntroducingThemes FeaturedonMeta Testingnewtrafficmanagementtool Duplicatedvotesarebeingcleanedup 2022ModeratorElectionQ&A–QuestionCollection 2022CommunityModeratorElection 2022CommunityModeratorElectionResults Linked 0 There'sConflictsintheDefinitionsofXNOR? 6 3inputXNORgateoperation 2 Nameforthislogicoperation 1 3-inputXORgatetruthtable 2 InLTSpice,fora3-inputlogicgatesystem,theXORgateisn'toutputtingwhatI'mexpectingitto 1 HowcanIcontrolaLEDwithtwoseparatecontrolcircuits? 0 DefinitionofXOR,andhowtorememberitsexpansionindisjunctivenormalformforNvariables 0 HowtochangeasumofprodutsusingANDandORgatestomakeitonlyuseXORgates? -4 Whatlogicgatematchesthetruthtablebelow? 0 Lookingforthenameofa3-inputlogicgate Seemorelinkedquestions Related 1 XORgatewithNAND 9 HowtobuildaninterestingXORcircuitwithmychild'selectronicskit 0 Howtoimplementaxorgatewithnandgates 0 IsXORequaltoXNORwhenoddnumberofinputsareconsidered? 0 DoIunderstandhowthisDigitalIntegratorcircuitissupposedtowork? 8 HowisthisCD4013applicationsupposedtowork? 1 Howtodo2variableXOR HotNetworkQuestions IsitpossibletousemultiplefilestodefineeampotentialinLAMMPS? Isitpossibletodeterminethemajor/minorkeyofasongbyjustlookingatthechords? Shouldapersonconsoleacoworkerifhe/shewasfired? Doinfraredheatershaveaspecialblackbodyradiationspecturm? Backronymiser឵឵ Isthereasimpleinstanceofintransitivityforimplicitdefinability? Whyarebanksprovidingmortages? '70's-eranovelaboutaplanet(futureEarth?)coveredbyanintelligent,continent-spanningtree,mileshigh Whatisthiswhitebaronmydoor? Whydoesn'tsudoalwaysspawnashellsub-process? Doeseveryonealwayseat,drinkandsleepforfreeeverywhereinMiddle-earth? Whyaretherepre-compiledpackagesinrepositories? HowmanymassshootingsdoesJapanhaveperyear? DSolveinV13.1hangsonmanyode'swhenusingIncludeSingularSolutions->True.Howtoworkaroundthis? HowarethepartsofcategorytheorywhichmakeexplicitreferencetoSetdifferentwhenformalizedinaproofassistantthatisbasedontypetheory DoPCboardsinACunitswearout? MySQL:HowtooptimizeacertainSELECTstatementwhichcausesveryhighload? Revolvingpendulumcontradictslaplacedeterminism Inversefunctionofy=x+(0.022-x)^1.414? HowdoImovearesearchgrouppost-tenure? InthisimagetakenbyVoyager1,whichiscloser:theearthorthemoon? Addanon-georeferencedimageatadefinedlocation-notageoreferencingquestion HowcanItestaprocmailrulewithoutsendingmyselfanemail? Whatであってisdoinghere? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?