You are on page 1of 2

LAB 1: HAMMING CODE

In this lab, we will utilize one error control code, known as the (7,4) Hamming block code. (7,4) means that 4 message bits, represented by the vector m, are converted into a 7-bit code, represented by the vector x = mG (modulo 2), where G is the "generator matrix" given by: 1 1 0 1 0 0 0 0 1 1 0 1 0 0 G= (1) 1 1 1 0 0 1 0 1 0 1 0 0 01 After the message bits pass through a noisy medium that introduces unknown errors, we can model the received vector y as follows:

y = x + e (modulo 2)

(2)

In modulo 2 addition we have 0 + 0 = 1 + 1 = 0; 0 + 1 = 1 + 0 = 1. Therefore we imagine the error vector e as a binary vector; where a component of e is 1, the received y vector diers from the originating x vector. The receiver then needs to decode the data in an attempt to recover the original message bits. This produces a "syndrome", s, which determines what the error vector was (if no errors or only a single bit error has occurred): s = yHT (modulo 2) where HT is the transpose of the "parity-check" matrix, H, given by: 1 0 0 1 0 1 1 H = 0 1 0 1 1 1 0 (4) 0 0 1 0 1 11 The 3-bit syndrome uniquely determines what the error pattern was, for single bit errors. So since we know what the error was, we can correct it and decrease the probability of a received bit error for the system! If the syndrome is perceived as a binary number, it can be converted to decimal and used as an index into the following error-pattern look-up matrix. The decimal value of the syndrome now points to the row of E that contains the corresponding error pattern.
E=

(3)

0 0 0 0 1 0 0 0

0 0 1 0 0 0 0 0

0 1 0 0 0 0 0 0

0 0 0 0 0 0 1 0

0 0 0 1 0 0 0 0

0 0 0 0 0 0 0 10

0 0 0 0 0 1 0

(5)

The (7,4) Hamming code is such that, when there is a single error in y, the row of E chosen with the syndrome matches the e used above to model the relationship between x and y. Therefore, given y, the decoding procedure is: y (corrected) = y + e (modulo 2) = x + e + e (modulo2) = x (6)

since addition modulo 2 of any binary vector to itself results in a vector of zeroes. 1

Assignment:
Write the following functions, using the Hamming code given above: A routine that takes a vector of four binary (0,1) symbols, and returns a vector of seven bits containing the corresponding valid codeword (encoding); A routine that takes a vector of seven bits, decodes them, and returns a vector of seven bits containing the decoded valid codeword (decoding). The routines should be properly commented, and example outputs should be given. Question: Why might some of the bits still be in error after coding and decoding with this (7,4) Hamming code? Explain.

You might also like