You are on page 1of 9

Error Correcting Codes

Syed M Mahmud, Ph.D


Electrical and Computer Engineering Department
Parity Bit
• Even Parity: Total number of 1’s in the data and parity bits together is
Even.
• Odd Parity: Total number of 1’s in the data and parity bits together is
Odd.
Example: Assume that we are using Even Parity, and the data bits are
1101010. We need to add a parity bit to make total number of 1’s equal
to even.
Since the data bits have four 1’s, which is even, the parity bit (P) will be
zero. Therefore, the entire Code including the parity bit (P) is
P D1 D2 D3 D4 D5 D6 D7
Even Parity: 0 1 1 0 1 0 1 0
Parity Bit
For the same set of data bits, the parity bit (P) will be 1 for an Odd
Parity system. Therefore, the entire Code including the parity bit (P) is
P D1 D2 D3 D4 D5 D6 D7
Odd Parity: 1 1 1 0 1 0 1 0
Hamming Code
Hamming Code uses multiple parity bits. It can detect and correct error
bits.
A Hamming Code with n parity bits can have up to 2n – n - 1 data bits,
making a maximum code length of 2n - 1 bits.
Parity Bits Data Bits Total Bits
n 2n – n - 1 2n - 1
------------- ------------- -------------
3 4 7
4 11 15
5 26 31
A Hamming Code with 4 Parity Bits
Four parity bits can check up to 11 data bits, making a 15-bit code.
The parity bits P1, P2, P4 and P8 are placed at bit positions 1, 2, 4 and
8, respectively, as shown below. The other bits are data bits.

Number of Parity Bits = n = 4


Number of Data Bits = 2n – n - 1 = 16 – 4 – 1 = 11

Parity Bits  P1, P2, P4 and P8


Data Bits  D1, D2, D3, D4, D5, D6, D7, D8, D9, D10 and D11

Bit Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Code  P1 P2 D1 P4 D2 D3 D4 P8 D5 D6 D7 D8 D9 D10 D11
A Hamming Code with 4 Parity Bits: P1, P2, P4 and P8
Bit # P8 P4 P2 P1
1 0 0 0 1 Parity bit Pi checks all the bit positions,
2 0 0 1 0 whose (Bit #) binary representation has 1’s in
3 0 0 1 1 position i.
4 0 1 0 0
5 0 1 0 1 Examples:
6 0 1 1 0 P1 checks the bits 1,3,5,7,9,11,13 and 15
7 0 1 1 1
8 1 0 0 0 P2 checks the bits 2,3,6,7,10,11,14 and 15
9 1 0 0 1
10 1 0 1 0 P4 checks the bits 4,5,6,7,12,13,14 and 15
11 1 0 1 1
12 1 1 0 0 P8 checks the bits 8,9,10,11,12,13,14 and 15
13 1 1 0 1
14 1 1 1 0
A Hamming Code with 4 Parity Bits: P1, P2, P4 and P8
Bit # P8 P4 P2 P1
For Even Parity, the values of P1, P2, P4
1 0 0 0 1
2 0 0 1 0
and P8 are generated as follows:
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
A Hamming Code with 3 Parity Bits
Three parity bits can check up to 4 data bits, making a 7-bit code.

Number of Parity Bits = n = 3


Number of Data Bits = 2n – n - 1 = 8 – 3 – 1 = 4

Parity Bits  P1, P2 and P4


Data Bits  D1, D2, D3, D4

Bit Position: 1 2 3 4 5 6 7
Code  P1 P2 D1 P4 D2 D3 D4
A Hamming Code with 3 Parity Bits: P1, P2 and P4
Bit # P8 P4 P2 P1 For Even Parity, the values of P1, P2,
1 0 0 0 1 and P4 are generated as follows:
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
Bit Position: 1 2 3 4 5 6 7
14 1 1 1 0
Code  P1 P2 D1 P4 D2 D3 D4

You might also like