特別好的格雷碼描述_第1頁
特別好的格雷碼描述_第2頁
特別好的格雷碼描述_第3頁
特別好的格雷碼描述_第4頁
特別好的格雷碼描述_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

格雷碼格雷碼(循環(huán)碉)是任意兩個(gè)相鄰數(shù)的代碼只有一位二進(jìn)制數(shù)不同的BCD碼,它與奇偶校驗(yàn)碼同屬可靠性編碼。格雷W(Graycode)是由皇里宴箜室的FrankGray在1940年提出,用於在PCM(PulseCodeModulation)方法傅送嘉孔虢畤防止出金昔,業(yè)於1953年三月十七日取得美閾暮利。格雷W是一彳固數(shù)列集合,相鄱麗敷冏只有一彳固位元改燮舄照罹敷W且格雷W的娘序不是唯一的以二逵制舄0值的格雷W舄第零I瓦第一項(xiàng)改燮最右遑的位元,第二項(xiàng)改燮右起第一固舄1的位元的左遑位元,第三、四I方法同第一、二I,如此反覆,即可排列出n固位元的格雷W。(假哉以二逵制舄0的值做舄格雷W的0)G:格雷碼B:二進(jìn)制碼G(N)=B(n+1)XORB(n)格雷碼的構(gòu)成:(B-GM怦二b3 異或“時(shí)運(yùn)算'jgi=bi?bi+l-(i<3) J不同為“1”[相同為P示意圖:G=g3g2glgoMio十六M16二法制碼bsb2bibo徊環(huán)碼g3g2giga00000000010010000000010011is3.00110100010101100111100010011010101111000010011001110101010011001101111111101010131415D'1101111011111011100110003位元格雷碼0004位元格雷碼00004位元2進(jìn)制原始碼00002位元格雷碼00011110001000100010110011001001000100011110011001001110111010110101010110

100010011001101111111101010101110011000011110001001101010111100110111101111二逵位血昏第n位二二逵位血昏第(n+1)位+格雷血昏第n位。因^二^位碉和格雷^皆有相同位敷,所以二逵位碉可彳聳最高位的左遑位元取0,以逵行盲十算。(言主:遇到1+1畤結(jié)果視舄0)例如:格雷^0111,舄4位數(shù),所以其所^舄之二逵位碉也必舄4位敷,因此可取^成之二^位碉第五位舄0,即0b3b2b1b0。0+0=0,所以b3=00+1=1,所以b2=11+1取0,所以b1=00+1取1,所以b0=1因此所^換舄之二^位血昏舄01012-bitGraycode00011110|-|3-bitGraycode000001011010110111101100|-|4-bitGraycode0000000100110010011001110101010011001101111111101010101110011000|}|}ThereflectedbinarycodealsoknownasGraycodeafterFrankGray(researcher)isabinarynumeralsystemwheretwosuccessivevaluesdifferinonlyonebit.Thereflectedbinarycodewasoriginallydesignedtopreventspuriousoutputfromelectromechanicalswitchs.Today,GraycodesarewidelyusedtofacilitateerrorcorrectionindigitalcommunicationssuchasdigitalterrestrialtelevisionandsomeDOCSISsystems.NameImage:ReflectedbinaryGray2632058.pngBelllabsresearcherFrankGray(researcher)introducedthetermreflectedbinarycodenhis1947patentapplication,remarkingthatthecodehad"asyetnorecognizedname".F.Gray.PulsecodecommunicationMarch171953(filedNov.1947).lt;/ref>Hederivedthenamefromthefact

thatit"maybebuiltupfromtheconventionalbinarycodebyasortofreflectionprocess".ThecodewaslaternamedafterGraybyotherswhousedit.Twodifferent1953patentapplicationsgive"Graycode"asanalternativenameforthe"reflectedbinarycode";J.Breckman. EncodingCircuitJan31,1956(filedDec.1953).lt;/ref>E.A.Raglandetal.Direction-SensitiveBinaryCodePositionControlSystemFeb.11,1958(filedOct.1953).lt;/ref>oneofthosealsolists"minimumerrorcode"and"cyclicpermutationcode"amongthenames.A1954patentapplicationrefersto"theBellTelephoneGraycode".S.Reineretal.AutomaticRectificationSystemJun24,1958(filedJan.1954).l±;/ref>HistoryandpracticalapplicationReflectedbinarycodeswereappliedtomathematicalpuzzlesbeforetheybecameknowntoengineers.TheFrenchengineerEmileBaudotusedGraycodesintelegraphyin1878.HereceivedtheFrenchLegiond'honneurmedalforhiswork.TheGraycodeissometimesattributed,incorrectly,Knuth,DonaldE."Generatingallntuples."TheArtofComputerProgramming,Volume4A:EnumerationandBacktrackingpre-fascicle2a,October152004/~knuth/fasc2a.ps.gz]toFlishaGray(inPrinciplesofPulseCodeModulation,K.W.Cattermole,K.W.Cattermole,PrinciplesofPulseCodeModulationAmericanElsevierPublishingCompany,Inc.,1969,NewYorkNY,ISBN0-444-19747-8.forexample).FrankGray(researcher)whobecamefamousforinventingthesignalingmethodthatcametobeusedforcompatiblecolortelevision,inventedamethodtoconvertanalogsignalstoreflectedbinarycodegroupsusingvacuumtubebasedapparatus.Themethodandapparatuswerepatentedin1953andthenameofGraystucktothecodes.The"PCMtube"apparatusthatGraypatentedwasmadebyRaymondW.SearsofBellLabs,workingwithGrayandWilliamM.Goodall,whocreditedGrayfortheideaofthereflectedbinarycode.W.M.Goodall,"TelevisionbyPulseCodeModulation,"BellSys.Tech.J.,Vol.30pp.3349,1951.TheuseofhiseponymouscodesthatGraywasmostinterestedinwastominimizetheeffectoferrorintheconversionofanalogsignalstodigital;hiscodesarestillusedtodayforthispurpose,andothers.Image:US02632058Gray.pngImage:EncoderDisc(3-Bit).svgforangle-measuringdevicesmarkedin3-bitbinary-reflectedGraycode(BRGC)]]Graycodesareusedinpositionencoders(linearencoderandrotaryencoder),inpreferencetostraightforwardbinaryencoding.Thisavoidsthepossibilitythat,whenseveralbitschangeinthebinaryrepresentationofanangle,amisreadcouldresultfromsomeofthebitschangingbeforeothers.RotaryencodersbenefitfromthecyclicnatureofGraycodes,becausethefirstandlastvaluesofthesequencedifferbyonlyonebit.Thebinary-reflectedGraycodecanalsobeusedtoserveasasolutionguidefortheTowerofHanoiItalsoformsaHamiltoniancycleonatesseractwhereeachbitisseenasonedimension.DuetotheHammingdistancepropertiesofGraycodes,theyaresometimesusedinGeneticAlgorithm.Theyareveryusefulinthisfield,sincemutationsinthecodeallowformostlyincrementalchanges,butoccasionallyasinglebit-changecancauseabigleapandleadtonewproperties.GraycodesarealsousedinlabellingtheaxesofKarnaughmap.WhenGraycodesareusedincomputerstoaddressprogrammemory,thecomputeruseslesspowerbecausefeweraddresslineschangeastheprogramcounteradvances.InmoderndigitalcommunicationsGraycodesplayanimportantroleinerrorcorrectionForexample,inadigitalmodulationschemesuchasquadratureamplitudemodulationwheredataistypicallytransmittedinsymbolrateof4bitsormore,thesignalsconstellationdiagramisarrangedsothatthebitpatternsconveyedbyadjacentconstellationpointsdifferbyonlyonebit.Bycombiningthiswithforwarderrorcorrectioncapableofcorrectingsingle-biterrors,itispossibleforareceivertocorrectanytransmissionerrorsthatcauseaconstellationpointtodeviateintotheareaofanadjacentpoint.ThismakesthetransmissionsystemlesssusceptibletonoiseDigitallogicdesignersusegraycodesextensivelyforpassingmulti-bitcountinformationbetweensynchronouslogicthatoperatesatdifferentclockfrequencies.Thelogicisconsideredoperatingindifferent"clockdomains".Itisfundamentaltothedesignoflargechipsthatoperatewithmanydifferentclockingfrequencies.Atypicaluseisbuildingafifo(first-in,first-outdatabuffer)thathasreadandwriteportsthatexistindifferentclockdomains.Theupdatedreadandwritepointersneedtobepassedbetweenclockdomainswhentheychange,tobeabletotrackfifoemptyandfullstatusineachdomain.Eachbitofthepointersissamplednon-deterministicallyforthisclockdomaintransfer.Soforeachbit,eithertheoldvalueorthenewvalueispropagated.Therefore,ifmorethanonebitinthemulti-bitpointerischangingatthesamplingpoint,a"wrong"binaryvalue(neithernewnorold)canbepropagated.Byguaranteeingonlyonebitcanbechanging,graycodesguaranteethattheonlypossiblesampledvaluesaretheneworoldmulti-bitvalue.Typicallygraycodesofpower-of-twolengthareused.Gray-codecountersandarithmeticSometimesdigitalbusesinelectronicsystemsareusedtoconveyquantitiesthatcanonlyincreaseordecreasebyoneatatime,forexampletheoutputofaneventcounterwhichisbeingpassedbetweenclockdomainsortoadigital-to-analogconverter.TheadvantageofGraycodeintheseapplicationsisthatdifferencesinthepropagationdelaysofthemanywiresthatrepresentthebitsofthecodecannotcausethereceivedvaluetogothroughstatesthatareoutoftheGraycodesequence.ThisissimilartotheadvantageofGraycodesintheconstructionofmechanicalencoders,howeverthesourceoftheGraycodeisanelectroniccounterinthiscase.ThecounteritselfmustcountinGraycode,orifthecounterrunsinbinarythentheoutputvaluefromthecountermustbereclockedafterithasbeenconvertedtoGraycode,becausewhenavalueisconvertedfrombinarytoGraycode,itispossiblethatdifferencesinthearrivaltimesofthebinarydatabitsintothebinary-to-Grayconversioncircuitwillmeanthatthecodecouldgobrieflythroughstatesthatarewildlyoutofsequence.AddingaclockedregisterafterthecircuitthatconvertsthecountvaluetoGraycodemayintroduceaclockcycleoflatency,socountingdirectlyinGraycodemaybeadvantageous.AGraycodecounterwaspatentedin1962andtherehavebeenmanyotherssince.InrecenttimesaGraycodecountercanbeimplementedasastatemachineinVerilog.Inordertoproducethenextcountvalue,itisnecessarytohavesomecombinationallogicthatwillincrementthecurrentcountvaluethatisstoredinGraycode.ProbablythemostobviouswaytoincrementaGraycodenumberistoconvertitintoordinarybinarycode,addonetoitwithastandardbinaryadder,andthenconverttheresultbacktoGraycode.Thisapproachwasdiscussedinapaperin1996Mehta,H.;Owens,R.M.&Irwin,M.J.(1996),Someissuesingraycodeaddressing,intheProceedingsofthe6thGreatLakesSymposiumonVLSI(GLSVLSI96),IEEEComputerSociety,pp.178/xpls/abs_all.jsp?tp&arnumber497616&isnumber10625Someissuesingraycodeaddressing]andthensubsequentlypatentedbysomeoneelsein1998Other,potentiallymuchfastermethodsofcountinginGraycodearediscussedinthereporthttp://www.cs.auckland.ac.nz/CDMTCS//researchreports/304bob.pdfTheGrayCodebyR.W.Doran],includingtakingtheoutputfromthefirstlatchesofthemaster-slaveflipflopsinabinaryripplecounter.MotivationManydevicesindicatepositionbyclosingandopeningswitches.Ifthatdeviceusesbinarynumeralsystemthesetwopositionswouldberightnexttoeachother:...011100...Theproblemwithbinarynumeralsystemisthat,withreal(mechanical)switches,itisveryunlikelythatswitcheswillchangestatesexactlyinsynchrony.Inthetransitionbetweenthetwostatesshownabove,allthreeswitcheschangestate.Inthebriefperiodwhileallarechanging,theswitcheswillreadsomespuriousposition.Evenwithoutkeybouncethetransitionmightlooklike011—001—101—100.Whentheswitchesappeartobeinposition001,theobservercannottellifthatisthe"real"position001,oratransitionalstatebetweentwootherpositions.Iftheoutputfeedsintoasequentiallogicsystem(possiblyviacombinatoriallogicthenthesequentialsystemmaystoreafalsevalue.Thereflectedbinarycodesolvesthisproblembychangingonlyoneswitchatatime,sothereisneveranyambiguityofposition,DecGrayBinary00000001001001201101030100114110100511110161011107100111Noticethatstate7canrollovertostate0withonlyoneswitchchange.Thisiscalledthe"cyclic"propertyofaGraycode.Agoodwaytoremembergraycodingisbybeingawarethattheleastsignificantbitfollowsarepetitivepatternof2.Thatis11,00,11etc.andtheseconddigitfollowsapatternoffours.Moreformally,aGraycodeisacodeassigningtoeachofacontiguoussetofinteger,ortoeachmemberofacircularlist,awordofsymbolssuchthateachtwoadjacentcodewordsdifferbyonesymbol.Thesecodesarealsoknownassingle-distancecodesreflectingtheHammingdistanceof1betweenadjacentcodes.TherecanbemorethanoneGraycodeforagivenwordlength,butthetermwasfirstappliedtoaparticularbinarynumeralsystemcodeforthenm-negativeintegers,thebinary-reflectedGraycodeorBRGCthethree-bitversionofwhichisshownabove.Constructingann-bitgraycodeThebinary-reflectedGraycodefornbitscanbegeneratedrecursionbyreflectingthebits(i.e.listingtheminreverseorderandconcatenatingthereverselistontotheoriginallist),prefixingtheoriginalbitswithabinary0andthenprefixingthereflectedbitswithabinary1.Thebasecase,forn=1bit,isthemostbasicGraycode,G={0,1}Thebasecasecanalsobethoughtofasasinglezero-bitGraycode(n=0G={""}whichismadeintotheone-bitcodebytherecursiveprocess.ThecodemayalsobeconstructediterationHerearethefirstfewstepsoftheabove-mentionedreflect-and-prefixmethod:Image:Graycodereflect.pngThesecharacteristicssuggestasimpleandfastmethodoftranslatingabinaryvalueintothecorrespondingGraycode.Eachbitisinvertedifthenexthigherbitoftheinputvalueissettoone.Thiscanbeperformedinparallelbyabit-shiftandexclusive-oroperationiftheyareavailable.Asimilarmethodcanbeusedtoperformthereversetranslation,butthecomputationofeachbitdependsonthecomputedvalueofthenexthigherbitsoitcannotbeperformedinSpecialtypesofGraycodesInpractice,a"Graycode"almostalwaysreferstoabinary-reflectedGraycode.However,mathematicianshavediscoveredotherkindsofGraycodes.LikeBRGCs,eachconsistsofalistsofwords,whereeachworddiffersfromthenextinonlyonedigit(eachwordhasaHammingdistanceof1fromthenextword).n-aryGraycode|border"0"cellpadding"10"align"right"|-||width"150"align"right"cellpadding"5"border"1"style"border-collapse:collapse;"|-|Ternarynumber->ternaryGraycodle;/small>0->0001->0012->00210->01211->01012->01120->02121->02222->020100->120101->121102->122110->102111->100112->101120->111121->112122->110200->210201->211202->212210->222211->220212->221220->201221->202222->200|}|}TherearemanyspecializedtypesofGraycodesotherthanthebinary-reflectedG&code.OnesuchtypeofGraycodeisthen-aryGraycodealsoknownasanon-BooleanGraycodeAsthenameimplies,thistypeofGraycodeusesnon-Booleanvaluesinitsencodings.Forexample,a3-ary(ternaryGraycodewouldusethevalues0,1,2}.The(n,k)-GraycodesthenaryGraycodewithkdigits.lt;/ref>Thesequenceofelementsinthe(3,2)Graycodeis:{00,01,02,12,10,11,21,22,20}The(n,k)Graycodemaybeconstructedrecursively,astheBRGC,ormaybeconstructediterationAnalgorithmtoiterativelygeneratethe(N,k)Graycodeispresented(inC(programminglanguage)://parameters:value,base,digits//Convertavaluetoagr叩codewiththegivenbaseanddigits.Iterating//throughasequenceofvalueswouldresultinasequenceofgraycodesin//whichonlyonedigitchangesatatime.intbaseNdigits];//Storestheordinarybase-Nnumber,onedigitperentryintgraydigits];//Storesthebase-Ngraycodenumber//PutthenormalbaseNnumberintothebaseNarray.Forbase10,109//wouldbestoredas9,0,1]for(i0;i<digits;i++)baseNi](value/(int)pow(base,i))%base;}//ConvertthenormalbaseNnumberintothegraycodeequivalent.Notethat//theloopstartsatthemostsignificantdigitandgoesdow.intshift0;for(idigits-1;i>0;i--)//Thegraydigitgetsshifteddownequaltothesumofthehigher//djits.grayi](baseNi]+base-shift)%base;//+basetopreentnegshift+grayi];}//EXAMPLES//input:value1899,base10,digits4//output:baseN]9,9,8,1],gray]0,1,7,1]//input:value1900,base10,digits4//output:baseN]0,0,9,1],gray]0,1,8,1]Thereareothergraycodealgorithmsfor(n,k)Graycodes.Itisimportanttonotethatthe(n,k)Graycodesproducedbytheabovealgorithmisalwayscyclical;somealgorithms,suchasthatbyGuan,lackthispropertywhenkisodd.Ontheotherhand,whileonlyonedigitatatimechangeswiththismethod,itcanchangebywrapping(loopingfromn-1to0).InGuansalgorithm,thecountalternatelyrisesandfalls,sothatthenumericdifferencebetweentwograycodedigitsisalwaysone.Graycodesarenotuniquelydefined,becauseapermutationofthecolumnsofsuchacodeisaGraycodetoo.Theaboveprocedureproducesacodeinwhichthelowerthesignificanceofadigit,themoreoftenitchanges,makingitsimilartonormalcountingmethods.BalancedGraycodeAbalancedGraycodeisoneinwhichthebitchangesaredistributedasequallyaspossibleamongthebitpositions.Strictlyspeaking,a(cyclic)Graycodeiscalledbalancedif|TC(i)-TC(j)|\leq2foranytwobitpositionsi,jwhereTC(i)isthenumberoftimesthebitichangesinthecode(transitioncounbfthebiti.Similarly,aGraycodeiscalledtotallybalancedfTC(i)TC(j)foranytwobitpositionsi,jBalancednbitGraycodesexistforanynwhiletotallybalancednbitGraycodesexistonlywhennisapowerof2.lt;/ref>BeckettGraycodeAnotherinterestingtypeofGraycodeistheBeckett-GraycodeTheBeckett-GraycodeisnamedafterSamuelBeckettanIrishplaywrightespeciallyinterestedinsymmetryOneofhispl叩s,"Quad(play),wasdividedintosixteentimeperiods.Attheendofeachtimeperiod,Beckettwishedtohaveoneofthefouractorseitherenteringorexitingthestage;hewishedtheplaytobeginandendwithanemptystage;andhewishedeachsubsetofactorstoappearonstageexactlyonce.lt;/ref>Clearly,thismeanttheactorsonstagecouldbere)resentedbya4-bitbinaryGraycode.Beckettplacedanadditionalrestrictiononthescripting,however:hewishedtheactorstoenterandexitsuchthattheactorwhohadbeenonstagethelongestwouldalwaysbetheonetoexit.TheactorscouldthenberepresentedbyaFIFOQueue(datastructure)datastructuresothatthefirstactortoexitwhenadequeueiscalledforisalwaysthefirstactorwhichwasenqueuedritothestructure.BeckettwasunabletofindaBeckett-Graycodeforhisplay,andindeed,anexhaustivelistingofallpossiblesequencesrevealsthatnosuchcodeexistsforn=4ComputerscientistsinterestedinthemathematicsbehindBeckett-Graycodeshavefoundthesecodesverydifficulttoworkwith.Itistodayknownthatcodesexistforn=(2,5,6,7,8}ndtheydonotexistforn=(3,4}Anexampleofan8-bitBeckett-Graycodecanbefoundin.AccordingtoJ.SawadaandD.Wong,"AFastAgorithmtogenerateBeckett-Graycodes"ElectronicnotesinDiscreteMathematics(EuroComb2007)Vol.29pp.571-577,2007.,thesearchspaceforn=6canbeexploredin15hours,andmorethan9,500solutionsforthecasen=7havebeenfound.Snake-in-the-boxcodesSnake-in-the-boxcodes,orsnakesarethesequencesofnodesofinducedpathinanndimensionalhypercubegraphandcoil-in-the-boxcodes,orcoilsarethesequencesofnodesofinducedcycle(graphtheory)inahypercube.ViewedasGraycodes,thesesequenceshavethepropertyofbeingabletodetectanysingle-bitcodingerror.CodesofthistypewerefirstdescribedbyW.H.Kautzinthelate1950s;lt;/ref>sincethen,therehasbeenmuchresearchonfindingthecodewiththelargestpossiblenumberofcodewordsforagivenhypercubedimension.Single-trackGraycodeYetanotherkindofGraycodeisthesingle-trackGraycode(STGC),originallydefinedbyHiltgen,PatersonandBrandestiniin"Single-trackGraycodes"(1996)lt;/ref>.TheSTGCisacyclicallistofPuniquebinaryencodingsoflengthnsuchthattwoconsecutivewordsdifferinexactlyoneposition,andwhenthelistisexaminedasaPxnMatrix(mathematics)eachcolumnisacyclicshiftofthefirstcolumn.lt;/ref>Thenamecomesfromtheirusewithrotaryencoder,whereanumberoftracksarebeingsensedbycontacts,resultingforeachinanoutputof0or1.Toreducenoiseduetodifferentcontactsnotswitchingattheexactsamemomentintime,onepreferablysetsupthetrackssothatthedataoutputbythecontactsareinGraycode.Togethighangularaccuracy,oneneedslotsofcontacts;inordertoachieveatleast1degreeaccuracy,oneneedsatleast360distinctpositionsperrevolution,whichrequiresaminimumof9bitsofdata,andthusthesamenumberofcontacts.Ifallcontactsareplacedatthesameangularposition,then9tracksareneededtogetastandardBRGCwithatleast1degreeaccuracy.However,ifthemanufacturermovesacontacttoadifferentangularposition(butatthesamedistancefromthecentershaft),thenthecorresponding"ringp

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論