Search code examples
hamming-code

Hamming Code Confusion


I am having difficulty answering this problem. Here is the original question:

A word is encoded with check bits 0111 (c8, c4, c2, and c1). The word is read back as 11101011 (data). What is the original data word?

I thought that since there are 4 check bits then this must be a 4-bit memory word, which there are only 16 possible words: 0000, 1000, 0100, 1100, 0010, 1010, 0110, 1110, 0001, 1001, 0101, 1101, 0011, 1011, 0111, 1111. Therefore, each codeword has 8 bits, and the check bits are in position 1, 2, 4, and 8.

  • bit 1 checks parity over bits: 1, 3, 5, 7, 9, 11
  • bit 2 checks parity over bits: 2, 3, 6, 7, 10, 11
  • bit 4 checks parity over bits: 4, 5, 6, 7, 12
  • bit 8 checks parity over bits: 8, 9, 10, 11, 12

I also know that to set the parity bit to 1 if total numbers of 1's checks to odd, and if all 1's check to even then set parity bit to 0.

I think that the word read back must have an error in it and that I have to correct it then this will allow me to find the original data word.

Is this what is happening in this question?


Solution

  • Message: 11000010

    Method A:

    CBA987654321  <-- Hexadecimal
    1100?001?0??
    
    C=1100
    B=1011
    5=0101
    ______
    X=0010
    

    Test vertically every single bit (XOR).

    Solution:

    1100?001?0??
        0   0 10
    
    110000010010
    

    Method B:

    CBA987654321  <-- Hexadecimal
    1100?001?0??