Code words are created according to the Hamming algorithm presented in the text.
This is an important piece of information, don't you think? :-)
Without the algorithm, we can't be sure of validity so I'll give you a general approach.
Each check bit will generally apply to some subset of bits. Let's say the seven bits are b6
through b0
. The four check bits are calculated to give even parity across the following subsets:
1 0 1 0 1 0 1
ca b6 b5 b3 b2 b1 b0 1+0+0+1+0+1 + (ca = 0)
cb b6 b4 b2 b0 1+1+1+1 + (cb = 0)
cc b6 b3 b0 1+0+1 + (cc = 0)
cd b5 b1 b0 0+0+1 + (cd = 1)
Now, if you didn't get a check bit sequence matching the data, you would ideally be able to work out which single data or check bit would need to change in order to repair it. This would only work if you could ensure that each check bit calculation was carefully crafted to add maximal extra information.
That probably a failing to my above calculation since I just pulled it out of thin air. But, since my intent was just to explain the concept in the absence of your algorithm, that shouldn't matter.
One way to ensure that an algorithm works is to brute force it:
- Get a list of all possible eleven-bit values. There's only 2048 of these so it's not onerous. For now, discard the ones that are already okay (we're only interested in invalid ones).
- In turn, toggle each bit (of the 11) and see if the item becomes valid.
- If no bit toggles made it valid, this is not a single-bit error so can safely be ignored.
- If one bit toggle made it valid, then you have enough information to fix this case.
- If more than one bit toggle made it valid, you don't have enough information to fix this case.
Bottom line, if every one-bit error possibility can be made valid with a single bit toggle (the second last bullet point above), the correction code is perfect.
You should also check to ensure that every valid one will become invalid if a single bit is toggled, but I'll leave that an an exercise since you should now have enough information on how to do this.