Hamming Code (7, 4)
Hamming Code (7, 4)
A copy of a 4-bit dataword is fed into the generator that creates three parity checks r0, r1, and r2, as shown below:
r0 = a2 + a1 + a0 modulo-2
r1 = a3 + a2 + a1 modulo-2
r2 = a1 + a0 + a3 modulo-2
In other words, each of the parity-check bits handles 3 out of the 4 bits of the dataword. The total number of 1s in
each 4-bit combination (3 dataword bits and 1 parity bit) must be even. We are not saying that these three
equations are unique; any three equations that involve 3 of the 4 bits in the dataword and create independent
equations (a combination of two cannot create the third) are valid.
The checker in the decoder creates a 3-bit syndrome (s2s1s0) in which each bit is the parity check for 4 out of the
7 bits in the received codeword:
s0 = b2 + b1 + b0 + q0 modulo-2
s1 = b3 + b2 + b1 + q1 modulo-2
s2 = b1 + b0 + b3 + q2 modulo-2
The equations used by the checker are the same as those used by the generator with the parity-check bits added to
the right-hand side of the equation. The 3-bit syndrome creates eight different bit patterns (000 to 111) that can
represent eight different conditions. These conditions define a lack of error or an error in 1 of the 7 bits of the
received codeword, as shown in Table 10.5.
Note that the generator is not concerned with the four cases shaded in Table 10.5 because there is either no error
or an error in the parity bit. In the other four cases, 1 of the bits must be flipped (changed from 0 to 1 or 1 to 0) to
find the correct dataword. The syndrome values in Table 10.5 are based on the syndrome bit calculations. For
example, if q0 is in error, s0 is the only bit affected; the syndrome, therefore, is 001. If b2 is in error, s0 and s1 are
the bits affected; the syndrome, therefore is 011. Similarly, if b1 is in error, all 3 syndrome bits are affected and
the syndrome is 111.
There are two points we need to emphasize here. First, if two errors occur during transmission, the created
dataword might not be the right one. Second, if we want to use the above code for error detection, we need a
different design.