15-2 The Hamming Code: Check Bits
15-2 The Hamming Code: Check Bits
u
p
s
152
(1)
This is known as the Hamming rule. It applies to any single error correcting (SEC)
binary FEC block code in which all of the transmitted bits must be checked. The
check bits will be interspersed among the information bits in a manner described
below.
Because p indexes the bit (if any) that is in error, the least significant bit of p
must be 1 if the erroneous bit is in an odd position, and 0 if it is in an even position
or if there is no error. A simple way to achieve this is to let the least significant bit
of p, p0, be an even parity check on the odd positions of the block, and to put p0 in
an odd position. The receiver then checks the parity of the odd positions (including that of p0). If the result is 1, an error has occurred in an odd position, and if the
result is 0, either no error occurred or an error occurred in an even position. This
satisfies the condition that p should be the index of the erroneous bit, or be 0 if no
error occurred.
Similarly, let the next from least significant bit of p, p1, be an even parity
check of positions 2, 3, 6, 7, 10, 11, (in binary, 10, 11, 110, 111, 1010, 1011,
), and put p1 in one of these positions. Those positions have a 1 in their second
from least significant binary position number. The receiver checks the parity of
these positions (including the position of p1). If the result is 1, an error occurred in
one of those positions, and if the result is 0, either no error occurred or an error
occurred in some other position.
Continuing, the third from least significant check bit, p2, is made an even parity check on those positions that have a 1 in their third from least significant position number, namely positions 4, 5, 6, 7, 12, 13, 14, 15, 20, , and p2 is put in one
of those positions.
152
p0 p1 u3 p2 u2 u1 u0
1 2
Table 151 shows the entire code. The 16 rows show all 16 possible information bit configurations and the check bits calculated by Hammings method.
TABLE 151. THE (7,4) HAMMING CODE
1
p0
2
p1
3
u3
4
p2
5
u2
6
u1
7
u0
0
1
0
1
0
1
1
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
1
1
0
1
0
1
4
5
6
7
1
0
1
0
0
1
1
0
0
0
0
0
1
0
0
1
1
1
1
1
0
0
1
1
0
1
0
1
8
9
10
11
1
0
1
0
1
0
0
1
1
1
1
1
0
1
1
0
0
0
0
0
0
0
1
1
0
1
0
1
12
13
14
15
0
1
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
1
1
1
0
0
1
1
0
1
0
1
Information
0
1
2
3
1. A perfect code exists for k = 2 m m 1, m an integerthat is, k = 1, 4, 11, 26, 57, 120,
.
152
To illustrate how the receiver corrects a single-bit error, suppose the code
word
1001110
is received. This is row 4 in Table 151 with bit 6 flipped. The receiver calculates
the exclusive or of the bits in odd positions and gets 0. It calculates the exclusive
or of bits 2, 3, 6, and 7 and gets 1. Lastly it calculates the exclusive or of bits 4, 5,
6, and 7 and gets 1. Thus the error indicator, which is called the syndrome, is
binary 110, or 6. The receiver flips the bit at position 6 to correct the block.
A SEC-DED Code
For many applications a single error correcting code would be considered unsatisfactory, because it accepts all blocks received. A SEC-DED code seems safer,
and it is the level of correction and detection most often used in computer memories.
The Hamming code can be converted to a SEC-DED code by adding one
check bit, which is a parity bit (let us assume even parity) on all the bits in the SEC
code word. This code is called an extended Hamming code [Hill, MS]. It is not
obvious that it is SEC-DED. To see that it is, consider Table 152. It is assumed a
TABLE 152. ADDING A PARITY BIT TO MAKE A SEC-DED CODE
Possibilities
Errors
Overall
Parity
Syndrome
even
No error
odd
0
0
even
Receiver Conclusion