How to: Hamming (248,240) decoder in Python

56 views Asked by At

I need to implement a hamming 248,240 decoder. The syndromes used to calculate the parity bits are given here:

Syndromes

P0: 555555555555555555555555555555AAAAAAAAAAAAAAAB55555556AAAD5B

P1: 666666666666666666666666666666CCCCCCCCCCCCCCCD9999999B33366D

P2: 787878787878787878787878787878F0F0F0F0F0F0F0F1E1E1E1E3C3C78E

P3: 807F807F807F807F807F807F807F80FF00FF00FF00FF01FE01FE03FC07F0

P4: FF80007FFF80007FFF80007FFF8000FFFF0000FFFF0001FFFE0003FFF800

P5: FFFFFF800000007FFFFFFF80000000FFFFFFFF00000001FFFFFFFC000000

P6: FFFFFFFFFFFFFF8000000000000000FFFFFFFFFFFFFFFE00000000000000

P7: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000

The left most entries are for the MSBits of the input data

I have a binary file where I can extract the data and ECC bytes separately, the file does not have the parity bits encoded into the data. I have tried to implement everything but I cannot seem to be able to identify where in the data the bit flip occurred.

Here is what I have tried, I am able to correctly calculate the ECC byte for the first 30-bytes (its a Hamming 248,240 system), then I tried to flip single bits in the 30 bytes of data, I manage to get a different parity byte now, here is what I tried to locate the bit that was flipped:

  • Find the bit differences between the correct parity byte and the corrupted one, for example the correct ECC byte is 0x5B and the one from the flipped bits is 0xAA, when I do this I get 0xF1, these are all the parity bits that are different, can I then say the 241st bit is corrupt?
  • Based on the method above I tried to see which bits all of the syndromes 7,6,5,4,0 have in common, this did not help either because they have more than one in common

I will post here the hex array of the 1st 30-bytes also: b'f99b6ccc4ce8f588f84ba62a5120f5f54322f7dbe60b7373cfb2906d6b9a' The correct ECC byte for this would be 0x5B

Does anybody have any pointers on where I am going wrong with my methodology? Im trying to solve this in python

0

There are 0 answers