2
\$\begingroup\$

The question is in the title.

If I have 4 inputs, how can I count the number of 1s using full/half adders and produce the binary equivalent of how many 1s exist in the 4 inputs?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ What have you tried so far and where did you get stuck? \$\endgroup\$
    – ocrdu
    Sep 15, 2020 at 12:26
  • 1
    \$\begingroup\$ Do you know how to make an n-bit (ripple carry) adder from full adders ? You can construct a 2-bit adder from the full adders and chain them to add up the four input lines. \$\endgroup\$
    – AJN
    Sep 15, 2020 at 12:45
  • 1
    \$\begingroup\$ Are you allowed to use ONLY half/full adders ? Are gates and flip flops allowed ? \$\endgroup\$
    – AJN
    Sep 15, 2020 at 12:46
  • 1
    \$\begingroup\$ A single full adder has three inputs, and the output is the count of how many of them are "1". You just need to extend this concept to add the fourth input. \$\endgroup\$
    – Dave Tweed
    Sep 15, 2020 at 13:14
  • \$\begingroup\$ I am allowed to use you gates and half/full adders, no FlipFlops. Yes, i can understand that if you have 3 bits you can use the Full Adder to get the result but given 4 bits, I just don't seem to achieve the same result.. \$\endgroup\$
    – Toxicone 7
    Sep 15, 2020 at 14:25

2 Answers 2

4
\$\begingroup\$

The solution. Basically figured it out myself and with the comments... You need to count the 3 bits with the full-adder and then use 2 half adders to add the sum of the 3 bits and the 4th bit and then another half adder for the 2 carries.

\$\endgroup\$
1
\$\begingroup\$

You can think of the problem as adding together four 1-bit numbers. The sum can range from 0 to 4, so you'll need a 3-bit result.

A single full-adder adds together three 1-bit numbers, producing a 2-bit result that ranges from 0 to 3. Now you need to add a fourth 1-bit number to that result. What's the simplest way to do that?

Show us what you've got so far, and we can offer more specific guidance.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you, I worked it out well and posted in the answers \$\endgroup\$
    – Toxicone 7
    Sep 15, 2020 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.