A digital code that helps in the process of error correction. The transmission line of a serial communications system can be susceptible to noise pulses that flip bits to incorrect values. There is a need for altered digital transmission data to be identified and perhaps corrected. Hamming code is one such mechanism. A message of four bits is embedded in a transmission of seven bits. The three extra redundant bits, known as check bits, provide enough information that a one-bit error anywhere in the seven bits can be corrected.
In the encoding process, the message bits may be designated M3M2M1M0 and the check bits C2C1C0. Three functions have to be identified relating to the Ms and equating to the Cs:
There are many Boolean functions f that could be chosen here, and Hamming chose the following: have each Ci be the bit that makes the parity – the sum of the bits, either even or odd – of the string {Ci,Mx,My,Mz} always the same. Then Ci becomes 0 or 1, whichever is needed to make the number of 1s in the set {Ci,Mx,My,Mz} even (assuming even parity). The table shows the Hamming code for four-bit data.
M3 | M2 | M1 | M0 | C2 | C1 | C0 |
---|
0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 0 | 1 | 1 |
0 | 0 | 1 | 0 | 1 | 0 | 1 |
0 | 0 | 1 | 1 | 1 | 1 | 0 |
0 | 1 | 0 | 0 | 1 | 1 | 0 |
0 | 1 | 0 | 1 | 1 | 0 | 1 |
0 | 1 | 1 | 0 | 0 | 1 | 1 |
0 | 1 | 1 | 1 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 1 | 1 | 1 |
1 | 0 | 0 | 1 | 1 | 0 | 0 |
1 | 0 | 1 | 0 | 0 | 1 | 0 |
1 | 0 | 1 | 1 | 0 | 0 | 1 |
1 | 1 | 0 | 0 | 0 | 0 | 1 |
1 | 1 | 0 | 1 | 0 | 1 | 0 |
1 | 1 | 1 | 0 | 1 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 |
Hamming code for 4-bit data