Upload
syed-muhammad-zaidi
View
219
Download
0
Embed Size (px)
Citation preview
8/2/2019 Haming Code
http://slidepdf.com/reader/full/haming-code 1/4
HammlngCodeOneofthemostcommonerror-correctingcodesusedinRAMSwasdevisedbyR.W.Hamming,IntheHammingcode,kparitybitsareaddedtoann-bitdawwordforminganewwordofn+kbits,Thebitpositionsarenumberedinsequencefrom1ton+k.Thosepositionsnumberedasapowerof2arereservedfortheparitybits,Theremainingbitsarethedatabits.Theccdecanbeusedwithwordsofanylength.Beforegivingthegeneralchamzkdicsofthecode,wewillillustrateitsoperationwithadatawordofeightbits.Consider,forexample,the%bitdataword11000100.Weinclude4paritybitswiththe8-bitwordandarrangethe12bitsasfollows:Bitposition:123456789101112P~P,1P41O0p8O100Sectfon7,4ErrorDetectionandCofrectibnThe4paritybits,PI,Pa,Pband6.areinpositions1,2,4,and8,respectively.The8bitsofthedatawordamintheremainingpsitiom.Bacbparitybitiscalculatedasfollows:6=XORofbits(3,5,7,9,11)=1a1$0@080=0Reme*thattheexcIusiveORo@onperfonnstbeoddfunction:Itiseqdto1foran
oddnumberof1'sinthevariab1aandto0foranevennumberof1's.Thus,eachparitybitissetsothatthetotalnumberof1'sinthecheckedpositions,includingtheparitybit,isalwayseven.The&bitdatawordisstoredinmemorytogetherwiththa4paritybitsasa12-bitcompwiteword.Substitutingthe4Pbitsintheirproperpositions,weobtainthe12-bitcorn@&wordstoredinmemory:001110010100Bitposition:12345678910I112Whenthe12bitsmreadfromme~,theyare*@nkm.%@tyiscbecked
overthesamcombinationofbits,includingtheparitybit.The4checkbinareevaluatedasfollows:C1=XORofbits(1,3,5,7,9,11)C2=XORofbits(2,3,6,7,10,11)C4=XORofbits(4,5,6,7,12)c8=XORofbits(8,9,10,11,12)A0checkbithignawevenparityoverthecheckedbitsanda1dc&pWsoddparity.Sincethebitswmst&withevenparity,theresult,C=C$4CtCl=0000,indicaksthatnoerrorhasoccurred.However,ifC#0,thenthe&bitbinarynumberformedbythecheckbitsgives
thepositionoftheerronebusbit.Forexample,considerthefollowingthnecases:Bitpsition:123456789101112001110010100No-1011100101OOEmwinbitl001loo010100Errorinbit5Inthefirstcase,thereisnoerrorinthe12-bitwd,Inthesecondcase,thereisanerrorinbitpositionnumber1becameitchangedhm0to1.Thethirdcaseshowsanerrorinbitpositim
8/2/2019 Haming Code
http://slidepdf.com/reader/full/haming-code 2/4
5,withachangefrom1to0.EvaluatingtheXORofthecorrespondingbits,wedeterminethe4checkbitstobeasfollows:C8c4c2ClFornomr:0000Witherrorinbit1:0001Witherrorinbit5:0101298Chapter7MemoryandProgrammabkLogicThus,fornoem,wehaveC=0000,withanerrorinbit1,weobtainC=0001;andwithanerrorinbit5,wegetC=0101.WhenthebinatynumbCisnotequalto0000.itgivesthepositionofthebitinerror,Theerrorcanbecorrectedbycomplementingthecorrespondingbit.Notethatanerrorcanoccurinthedatawordorinweoftheparitybits.TheHammingcodecanbeusedfordatawordsofanylength.Ingeneral,theHammingcadeconsistsofkcheckbitsandndatabits,foratotalofn+kbits.ThesyndromevalueCconsistsofkbitsandhasarangeofzkvaluesbetween0andzk-1.Oneofthesevalues,usuallyzero,isusedtoindicatethatnoerrorwasdetected,leaving2k-1vah~estoindicatewhichofthen+kbitswasinerror.Eachofthese2k-1valuescanlxusedtouniquelydes
cribeabitinerror.Therefore,therangeofkmustbeequaltoorgreaterthann+k.givingtherelarionshipSolvingfornintermsofk,weobtainThisrelationshipgivesaformuIaforestablishingthenumberofdatabitsthatcanbeusedinconjunctionwithkcheckbits.Forexample,whenk=3,thenumberofdatabitsthatcanbeusedisn5(23-1-3)=4.Fork=4,weha~e2-~f-4=11,givingnI11.Thedat~wordmaybeIessthan11bits,butmusthaveatleast5bits;otherwise,ody3checkbitswillbeneeded.Thisjustifiestheuseof4checkbitsforthe8databitsinthepreviousexampIe.
RangesofnfordousvaluesofkarelistedinTable7.2,Thepupingofbitsforparitygenerationandcheckingcanbedekmhedfromalistofthebinarynumbersfrom0through2k-1.Theleastsignificantbitisa1inthebinarynumbers1,3,5,7,andsoon.Thesecondsignificantbitisa1inthebinarynumh2,3,6,7a,ndsoon.Comparingthesenumberswiththebitpositionsusedingeneratingandcheckjngp&ybitsintheHammingcode,wenotetherelationshipbetweenthebitgroupingsinthecodeandthepositionofthe1-bitsinthebinarycountsequence.Notethateachgroupofbitsstartswithanumberthatisa
powerof21,2,4,8,16,etc.Thesenumbersarealsothepositionnumbersfortheparitybits,Single-EmrCorrection,Double-ErmrDetectionTheHammingcodecandetectandcmectonlyasingleerror.Byaddinganotherparitybittothecodedword,tbeHammingcodecanbeusedtocorrectasinglemranddetectdoubleerrors.Ifweincludethisadditionalparitybit,thentheprevious12-bitcodedwordkames001110010100fi3,wherefi3isevaluatedfromtheexclusive-ORoftheother12
8/2/2019 Haming Code
http://slidepdf.com/reader/full/haming-code 3/4
bits.Thistabla7.2RangedhtaBIErIbrkChdEltsNumberofCheckBlts,kRangeofDataBitr,n32445-11512-26627-57758-120Section7.5Read-onlyMemory299producesthe13-bitword0011100101M31(evenparity).Whenthe13-bitwordisreadfrommemory,thecheckbitsareevaluated,asistheparityPovertheentire13bits.IfP=0,theparityiscorrect(evenparity),butifP=1,thentheparityoverthe13bitsisincorrect(oddparity].Thefollowingfourcasescanarise:IfC=0andP=0,noerroroccurred.IfC#0andP=1,asingleerroroccurredthatcanbecorrected.IfC#0andP=0,adoubleerroroccurredthatisdetected,butthatcannotbecomted.IfC=0andP=1,merroroccurredintheP13bit.Thisschememaydetectmorethantwoerrors,butisnotguaranteedtodetectallsucherrors.
IntegratedcircuitsuseamodifiedHammingcodetogenerateandcheckparitybitsforsingle-errorcorrectionanddouble-errordetection.ThemodifiedHammingcodeusesamoreefficientparityconfigurationthatbalancesthenumberofbitsusedtocalculatetheXORoperation.Atypicalintegratedcircuitthatusesan8-bitdatawordanda5-bitcheckwordisICtype74637.Otherintegratedcircuitsareavailablefordatawordsof16and32bits.ThesecircuitscanbeusedinconjunctionwithamemoryunittocorrectasingIeerrorordetectdoubleerrorsduringwriteandreadoperations.
7.5READ-ONLYMEMORYAROMisessentiallyamemorydeviceinwhichpermanentbinaryinformationisstored.Thebinaryinformationmustbespecifiedbythedesignerandisthenembeddedintheunittoformtherequiredinterconnectionpattern.Oncethepatternisestablished,itstayswithintheunitevenwhenpoweristurnedoffandonagain.AblockdiagramofaROMconsistingofkinputsandnoutputsisshowninFig,7.9.Theinputsprovidetheaddressformemory,andtheoutputsgivethedatabitsofthestoredwordthatisselectedbytheaddress.ThenumberofwordsinaROMisdemminedfromthefact
thatkaddressinputhesareneededtospecify2kwords.NotethatROMdoesnothavedatainputs,becauseitdoesnothaveawriteoperation.InregratedcircuitROMchipshaveoneormoreenableinputsandsometimescomewiththree-stateoutputstofacilitatetheconstructionoflargearraysofROM,Consider,forexample,a32X8ROM.Theunitconsistsof32wordsof8bitseach.Therearefiveinputlinesthatformthebinarynumbersfrom0through31fortheaddr
8/2/2019 Haming Code
http://slidepdf.com/reader/full/haming-code 4/4
ess.Figure7.10showstheinternallogicconstructionofthisROM.Thefiveinputsaredecodedinto32distinctoutputsbymeansofa5X32decoder.Eachoutputofthedecoderrepresentsamemoryaddress.kinputs(address)noutputs(data)FK;URE7.9ROMblockdlagrsm