Counting 1 bits using full adders

Thread Starter

oldlaptopuser

Joined Oct 4, 2015
3
Hello,

I'm only using FA and simple gates (and, or, xor, not, etc). I'm given 6 bits as input, and I'm trying to count the 1 bits, I've done the following:

I use 2 FA as a filter, if they both carry out, I use another FA as a filter to see 2 or 4 is carried. With these 3 FA, I'll receive 4 outputs with the values of 1, 1, 2, and 4.

I can convey 0-6 bits used in 3 bits (000 - 110). What should I be looking at to assign those 4 outputs to the 3 bits? I feel like my mind is slipping and the solution should be relatively simple, but I get confused.

So many combinations seem possible, it seems a brute force method seems horrible. What should I be looking at?

Right now I'm pursuing adding both possible 1's in a FA to see if I have a 1 or 2. So now the potential output is 1, 2, 2, 4 (as opposed to 1,1,2,4) but this is still 4 outputs.
 
Last edited:

WBahn

Joined Mar 31, 2012
25,223
How about showing a sketch of the circuit(s) you are considering?

You can build the circuit using 4 FA and no other gates at all. In fact, you could count the number of 1 bits among seven inputs.

The key is to exploit the primary difference between a half adder and a full adder.
 

Thread Starter

oldlaptopuser

Joined Oct 4, 2015
3
Nevermind! I was able to figure it out. I'm so happy, my eyes got teary!

However, I don't think my solution is optimal after what you just said. I've attached my solution. What should I be looking for to further minimize?
 

Attachments

WBahn

Joined Mar 31, 2012
25,223
Good job. Nothing like the sense of accomplishment in figuring out the solution on your own.

If you only have six inputs, you can also use three FA and one HA and since a HA is just an XOR and an AND gate, you can use three FA, one XOR and one AND.
 
Top