Вы находитесь на странице: 1из 9

Error Detection & Error Correction

ERROR DETECTING CODES


Parity System
- Simplest method for error detection - One parity bit attached to the information - Even Parity y and Odd Parity y

Even Parity
- One bit is attached to the information so that the total number of 1 bits is an even number. 1011001 0 1010010 1

Odd Parity
- One O bit i is attached tt h d t to th the i information f ti so that th t the th total t t l number b of f 1 bits bit is i an odd dd number 1011001 1 1010010 0

PARITY BIT GENERATION


For b6b5... b0 (7-bit information, e.g. an ASCII character code) code), Even parity bit beven is given by: beven = b6 b5 ... b0 Odd p parity y bit bodd is g given by: y bodd = beven 1 = (beven)
___

PARITY GENERATOR AND PARITY CHECKER

The same circuit as the parity checker can also be used for parity generation if we connect the beven point to 0. Then we will get the value of beven at the output. If we replace the last XOR gate with an XNOR gate, we get the parity checker and parity generator circuits for Odd Parity.

Hamming Distance
Definition: The number of elements that need t be to b changed h d (corrupted) ( t d) t to t turn one codeword into another. The hamming distance from:
[0101] to [0110] is 2 bits [1011101] to [1001001] is 2 bits butter to ladder is 4 characters roses to toned is 3 characters

Hamming Distance Error Detection and Correction


If the minimum Hamming distance between any two t code d words d i in a code d i is d, then: th
At most Floor(d 1) number of bit errors can be detected. E.g., a parity code (minimum distance = 2) can detect 1bit errors but not 2bit errors. At most Floor[(d 1)/2] number of bit errors can be corrected. E.g., a parity code cannot correct any errors because Floor[(21)/2] = 0.

Hamming Codes
In the late 1940s Richard Hamming recognized i d th that t th the f further th evolution l ti of f computers required greater reliability, in particular the ability to not only detect errors, but correct them. His search for error correcting codes led to the Hamming Codes, perfect 1error correcting codes, and the extended Hamming Codes, 1error correcting and 2error detecting codes.

Uses
Hamming Codes are still widely used in computing, ti t telecommunication, l i ti and d other th applications. Hamming Codes also applied in
Data compression Some solutions to the popular puzzle The Hat Game Block Turbo Codes

A [7,4] binary Hamming Code


Let our codeword be (x1 x2 x7) F27 x3, x5, x6, x7 are chosen according to the message (perhaps the message itself is (x3 x5 x6 x7 )). x4 := x5 + x6 + x7 (mod 2) x2 := x3 + x6 + x7 x1 := x3 + x5 + x7

[7,4] binary Hamming codewords

A [7,4] binary Hamming Code


Let a = x4 + x5 + x6 + x7 (=1 iff one of these bits i i is in error) ) Let b = x2 + x3 + x6 + x7 Let c = x1 + x3 + x5 + x7 If there is an error (assuming at most one) then abc will be binary representation of the subscript of the offending bit.

A [7,4] binary Hamming Code


If (y1 y2 y7) is received and abc 000, then we assume the th bit abc b i is i in error and d switch it h it it. If abc=000, we assume there were no errors (so if there are three or more errors we may recover the wrong codeword).

Definition: Generator and Check Matrices


For an [n, k] linear code, the generator matrix i ak is kn matrix t i Mf for which hi h th the row space i is the given code. For an [n, k] linear code, the generator matrix is a (nk)n matrix L, such that for any code word x, Lx is 0.

Example Matrices
A generator matrix for [7, 4] binary Hamming C d Code:

A check matrix for a [7,4] binary Hamming Code:

Syndrome Decoding
Let y = (y1 y2 yn) be a received codeword. The syndrome of y is S:=LryT. If S=0 then there was no error. If S 0 then S is the binary representation of some integer t such that: 1 t n=2r1 and the intended codeword is x = (y1 yt+1 yn). )

Example
Code generation Using G
Suppose the data to be sent is (1 0 1 0), the code d word d would ld b be:

Example
Error correction using L3
Suppose (1 0 1 0 0 1 0) is received instead of (1 0 1 1 0 1 0), 0) due d to t a 1bit error. The syndrome may be calculated as: S = L3 x =

100 is 4 in binary, so the intended codeword was (1 0 1 1 0 1 0).