Sie sind auf Seite 1von 6

K

h
a
b
a
r

8/10/2012

ERRORDETECTION
ERROR
DETECTION
&
ERRORCORRECTION

ERROR DETECTING CODE

M
T
U

To detect an errors in Communications &


processing an eighth bit known as parity bit is
added to the ASCII Chars to make the total no
of Bits to Even or Odd.
WithEvenWithOdd
ParityParity

ASCIIA= 10000010100000111000001
ASCIIT= 10101001101010001010100
ASCIIe= 11001010110010111100101
TheextrabitisaddedastheLeftMostBit,Evenparityismorecommon

8/10/2012

ERRORDETECTINGCODE

contd.

K
h
a
b
a
r

The parity Bit enables detecting errors of 1, 3, 5 bits


or any odd combination of bits in each Char that is
t
transmitted.
itt d
However, even number of errors go undetected and in
that case additional error deting techniques are
required to take care of that possibility.
ACK
NAK ((-ive
i ACK)
Malfunction Message to operator.

M
T
U

HAMMING CODE
Electrical Signals may affect the Memory path
causing errors while storing or retrieving Data.
Memory reliability can be enhanced by
employing Err Deting & Corrtion Codes
e.g. when parity Bit is employed for the
purpose, it is stored with the Data word in the
memory. As & when it is retrieved & if the
parity is not correct err is detected but can
cantt
be corrected.
contd

8/10/2012

HAMMING CODE

contd

K
h
a
b
a
r

An Err Corring Codes generates multiple


parities and stored along with the data
word

On retrieval, if the Parity Bits dont match,


they generate a unique pattern called a
S d
Syndrome
th t is
that
i usedd to
t identify
id tif the
th Bit
that is in error which can be corrected.

contd

Hamming Code

contd

M
T
U

k parity bits are added to an n bit data word new word of


n+k bits .
Bit positions are numbered from 1 to n+k
The bits that are numbered as power of 2 are parity bits, and
remaining bits are data bits.
Ex: 8 bit data word and 4 parity bits.
Bit Position 1 2 3 4 5 6 7 8 9 10 11 12
P1 P2 1 P4 1 0 0 P8 0 1 0 0
The parity Bits are calculated as follows:
P1= XOR of bits (3, 5,7, 9, 11)
=1 1 0 0 0=0
P2 = XOR of bits (3, 6, 7, 10, 11) = 1 0 0 1 0 =0
P4 = XOR of bits (5, 6, 7, 12)
= 1 0 0 0 =1
P8 = XOR of bits (9, 10, 11, 12) = 0 1 0 0 = 1

8/10/2012

Hamming Code

contd

K
h
a
b
a
r

Bit Position 1 2 3 4 5 6 7 8 9 10 11 12
0 0 1 1 1 0 0 1 0 1 0 0
On retrieval the parity is checked for the same set of
bits including parity bits (Even parity)
C1 = XOR of bits (1, 3, 5,7, 9, 11) = 0
C2 = XOR of bits (2, 3, 6, 7, 10, 11) = 0
=0
C4 = XOR of bits (4, 5, 6, 7, 12)
C8 = XOR of bits (8, 9, 10, 11, 12) = 0

Since C= C8 C4 C2 C1=0000 indicates no error has


occurred .
However if C 0 , the number formed by the parity bits
gives the position of the erroneous bit.

Hamming Code

1
0
1
0

2
0
0
0

3
1
1
1

M
T
U

Bit

Pos.n:

4
1
1
1

C8

For no error
0
For error in bit 1 0
For error in bit 5 0

5
1
1
0

6
0
0
0

7
0
0
0

8
1
1
1

contd

9 10 11 12
0 1 0 0 No Error
0 1 0 0 Error in bit 1
0 1 0 0 Error in
i bit
bi 5

C4

C2

C1

0
0
1

0
0
0

0
1
1

The error can be corrected by complementing the


respective bit based on C8C4C2C1 which gives the
position of the erroneous bit.

8/10/2012

Hamming Code

contd

K
h
a
b
a
r

The Hamming code can be used for data words of any


length.
In general HC consists of k check bits and n data bits .
The syndrome value consisting k bits has a range of 2K
values betn 1 & 2K-1. One of its value 0, is used to
indicate that no error was detected.
The values 1 to (2k-1) give the value indicating which of
the n+k bit was erroneous.
Range of kj must be 2k-1 n+k
i.e. 2k - 1- k n that gives the formula for
establishing the no of data bits used in conjunction
with k check bits.

Hamming
HammingCode
Code

contd
contd

M
T
U

Thegroupingofbitsforparitygenrtion and
checking can be determined from a list of
checkingcanbedeterminedfromalistof
binarynumbersfrom0to2k 1.
LSBis1inthebinarynos1,3,5,7,..
The2nd significantbitis1binarynos.2,3,6,7..
Eachgroupstartswithapowerof2::1,2,4
Thenumbersarealsothepositionnumberof
theparitybits.

8/10/2012

HammingCode

contd

K
h
a
b
a
r

SINGLEERRORCORR,DOUBLEERRORDetection
ByaddinganotherparityHCcancorrectsinglebitanddetect
doubleerrorbits.
Addinganotherbittotheprev12bitwordandevaluatingitwith
XORingallthe12bitsweget
001110010100P13
0011100101001(evenparity)
OnretrievingdatawordifP=0thenparityiscorrectelseitisincorrect.
If C=0 and P=0 no error has occurred
IfC=0andP=0,noerrorhasoccurred
IfC0andP=1,asingleerroroccurredthatcanbecorrected
IfC0andP=0,adoubleerroroccurredthatisdetectedbutcantbe
corrected
IfC=0andP=1,asingleerroroccurredinP13 bit

EX.IC74637uses5bitparity&8bitdataword

QUESTIONS:MorrisMano 4th Ed.

M
T
U

10.Given8bitDataword,01011011,Findthe13bitHCword
thatcorrectssingleerrorsanddetectsdoubleerrors.
11.Obtain15bitHammingcodewordfor11bitdataword
11001001010
12.Thefollowing12bithammingwordcontaining4paritybits
arereceived.Whatweretheoriginal8bitdatawordwritten
intomemory?
(a)000011101010
(b)101110000110
( ) 101111110100
(c)101111110100
13.Howmnay paritycheckbitsmustbeincludedtoachieve
singleerrorscotrection anddoubleerrordetectionforthe
followingdatawords:
(a)16bits,(b)32bits,(c)48bits.

Das könnte Ihnen auch gefallen