CM Coding
CM Coding
Information Theory
Each parity bit calculates the parity for some of the bits in the code word. The position of
the parity bit determines the sequence of bits that it alternately checks and skips.
Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,...)
Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc.
(2,3,6,7,10,11,14,15,...)
Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc.
(4,5,6,7,12,13,14,15,20,21,22,23,...)
Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc.
(8-15,24-31,40-47,...)
Position 16: check 16 bits, skip 16 bits, check 16 bits, skip 16 bits, etc.
(16-31,48-63,80-95,...)
Position 32: check 32 bits, skip 32 bits, check 32 bits, skip 32 bits, etc.
(32-63,96-127,160-191,...) etc.
Set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a
parity bit to 0 if the total number of ones in the positions it checks is even.
Example: An 8 bit byte with binary value 10101111 is to be encoded using an even-parity
Hamming code. What is the binary value after encoding?
1 2 3 4 5 6 7 8 9 10 11 12
- - 1 - 0 1 0 - 1 1 1 1
P1 - 1 0 0 1 1
1 - 1 - 0 1 0 - 1 1 1 1
P2 - 1 1 0 1 1
1 0 1 - 0 1 0 - 1 1 1 1
P4 - 0 1 0 1
1 0 1 0 0 1 0 - 1 1 1 1
P8 - 1 1 1 1
1 0 1 0 0 1 0 0 1 1 1 1
The given 8 bit byte with a binary value of 10101111 yields a parity value of
101001001111.
Example: Correct in even parity, the following bits patterns (101001001111) were received?
Parity 1 2 3 4 5 6 7 8 9 10 11 12
Corr. IN Even
1 0 1 0 0 1 0 0 1 1 1 1
P1 = 0 1 1 0 0 1 1
P2 = 0 0 1 1 0 1 1
P4 = 0 0 0 1 0 1
P8 = 0 0 1 1 1 1
Algorithm 2:
Suppose the transmitter will send a code of 8 bits by using Hamming code methods which is
based on sending an extra bits called (helping bit or Parity bit) in the positions
(1,2,4,8,16,…etc). For example if the sender sends 4 bits that’s mean it will send 3 extra bits
(parity bit) in the position (1,2,4) the result code it will be of 7 bits. To know the value of
each extra bit we will change each position of bit has value "1" to the binary system and
apply the XOR gate with each other, then we put the result in the position of extra bit ( parity
bit) respectively.
Example: An 8 bit byte with binary value 10110101 is to be encoded using an even-parity
Hamming code. What is the binary value after encoding?
Position 1 2 3 4 5 6 7 8 9 10 11 12
Value - - 1 - 0 1 1 - 0 1 0 1
Table -1-
P3 0011
P6 0110
P7 0111
P10 1010
P12 1100
Apply XOR Gate __________
Results 0100 Parity Bits
P1 = 0 P2=0 P4=1 P8=0
Position 1 2 3 4 5 6 7 8 9 10 11 12
Value 0 0 1 1 0 1 1 0 0 1 0 1
Table -2-
According to the above example, assume that the recipient received the code without errors.
In general, the recipient will know and identify error by converting the positions their value
"1" in the code to the binary system and then apply the XOR gate between them. And then
apply the XOR gate again between results and the parity bits, as shown in Tables 5 and 6. If
the result is 0, this means that the code did not get any error during the transmission process.
P3 0011
P6 0110
P7 0111
P10 1010
P12 1100
Apply XOR Gate _______
Results 0100
Parity Bits 0100
Apply XOR gate again 0000 Correct Transmitting