Electronic – Designing a circuit that calculates Hamming distance

decoder

I came across this question and I couldn't find it in textbooks or the internet. Seems pretty unique.

I guess there would be some comparators and adders involved, but I have no clue where to start. I'd appreciate if someone could explain in very simple, newbie proof terms.

Best Answer

"the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different." (Wiki)

Simple approach: compare the bits pairwise using XOR (output is 1 when the inputs differ) and add the outputs of the XORs using a string of adders.

This will work, but there is probably a simpler way to add a bunch of 1's and 0's than using full adders.

I am not sure I agree with the WiKi definition, to me Hamming distance is a property of an encoding (a subset of valid values, within a larger set of possible values). An encoding (or a subset) is a mathematical construct, not a physical value, so you can't input it to a digital circuit.