Right now I am in a middle of an important digital assignment. I require some help with designing a digital logic circuit. I am kind of stuck.

Part of my circuit digital design requires me to design a circuit to calculate the weight of any random byte. In other words, I have to count the number of logic 1s present in a 8-bit binary vector either using adders or counters but I cannot get my head around how to do this properly. One of the conditions is that all 8 bits cannot be zeros or ones.

3 bits would be required to hold the maximum count that is 7 e.g. ABC. I approached by trying a combination of full and half but the circuit is a bit messy and complicated and not working 100%. I wonder if there is a solution using counters. I am allowed to use any ECAD tool.

Any suggestions and ideas will be appreciated. Please illustrate if any particular counter is recommended. There are eight inputs to the counter and three outputs from the counter.

I hope I was able to explain my problem.