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 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.
The first step will undoubtedly be XORing the two bit sets. Then you need to count the number of logical ones in the output. The best method for designing your circuit would be to make a complete analogy of the hack discussed in this question and explained perfectly in its answer by nneonneo. This would result in the optimal tree of adders, rather than relying on sequential counting. The idea is that in each layer you know how to cap the maximum possible sum of a subset of the inputs, and in how many bits it will fit, eliminating the need for a carry bit. The programming approach is designed for 32 bits but easily modifiable for less or more than that.
For more possible algorithms for computing Hamming weight see this link.