Hamming Code Project
Hamming Code Project
3
1
5
2
6
3
7
4
9
5
10
6
11
7
12
8
13
9
14
10
15
11
Using the four parity (error correction bits) positions we can represent 15 values (1- 15).
These values and their corresponding binary representation are shown in the table below.
Pos 20 =1 21 =2 22 =4 23 =8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
Using the format given, data is represented by the 11 non-parity bits. Say for example we
have the following data item to be encoded:
10101101011
1
3
1
5
0
6
1
7
0
9
1
10
1
11
0
12
1
13
0
14
1
15
1
After placing the data in the table we find that in positions 3, 6, 9, 10, 12, 14 and 15 we
have a 1. Using our previous conversion table we obtain the binary representation for
each of these values. We then exclusive OR the resulting values (essentially setting the
parity bit to 1 if an odd # of 1s else setting it to 0). The results of this activity are shown
below:
XOR
1
0
1
0
0
0
1
1
1
1
0
1
0
1
1
1
0
1
0
0
1
1
1
0
0
0
1
1
1
1
1
1
3
6
9
10
12
14
15
(11)
The parity bits are then put in the proper locations in the table providing the following
end result:
1
1
2
1
3
1
4
0
5
0
6
1
7
0
8
1
9
1
10
1
11
0
12
1
13
0
14
1
15
1
This is the encoded code word that would be sent. The receiving side would re-compute
the parity bits and compare them to the ones received. If they were the same no error
occurred if they were different the location of the flipped bit is determined.
For example, lets say that the bit in position 14 was flipped during transmission. The
receiving end would see the following encoded sequence:
1
1
2
1
3
1
4
0
5
0
6
1
7
0
8
1
9
1
10
1
11
0
12
1
13
0
14
0
15
1
Below is the re-calculation done at the receiving end (notice the information for position
14 has been left out as it was flipped from 1 to 0).
XOR
1
0
1
0
0
1
1
1
1
0
1
0
1
0
0
1
0
0
1
1
1
0
0
1
1
1
1
0
3
6
9
10
12
15
XOR
1
1
0
1
0
1
0
1
1
1
0
1
sent/received
new calculated
this bit was flipped (14)
Your task is to write a program that will perform two basic functions:
a) Request an 8 bit word generate and display its 11 bit Hamming encoded code
word sequence.
b) Request an 11 bit properly encoded Hamming code word and indicate if an error
has occurred (in which case you give the position of the bad bit) or if it is properly
encoded.