Ivan asked in Science & MathematicsEngineering · 9 months ago

# Is there any integrated circuit that takes an 8 bit input and outputs a 3 bit sum of those inputs?

Relevance
• 9 months ago

Sure, Shifting 8 bit input, counting the 1s does nicely. Overflow would get dropped, hence an error. 4 bit can count that high.

Piece of cake for an 8 bit Upc

• Lisa A
Lv 7
9 months ago

Is this a trick exam question? They want you to try and fail to design it, and realize why you can't. Because the sum of 8 binary numbers ranges from 0 to 8 decimal. Which is from 0000 to 1000 binary. So you need 4 bits of output, not 3. It isn't possible for the circuit that you describe to exist, because you can't design such a thing, logically.

• Ivan9 months agoReport

Sorry, I meant 4 bit output. It's not an exam question. I'm just building a project where I have to read the digital outputs of 8 sensors and I don't want to use 8 GPIOs on my microcontroller so I was wondering if there's any IC that counts all the inputs and gives out the result on a 4 bit bus.

• Dixon
Lv 7
9 months ago

You actually need a four bit output because there are 9 possible sums; zero and 1 to 8.

I don't know if this circuit has a name and I can't remember ever seeing one as a stand alone IC but I've done it a few times in VHDL. For myself, I call it a "tally to n". So in this case it would be a tally to 8 adder.

In hardware you would do that with a pyramid off adders. Roughly described below - hope I didn't go off the rails tho...

The first stage would be 4 half adders, each one adding up pairs of bits from the input and giving a two bit output . We treat the sum and carry as a single two bit bus representing the sum. This is the jump from a tally to weighted numbers but we now have four weighted numbers to add together.

The next stage would be adding up pairs of the first stage output busses. Each pair would be added together with a 2 bit adder (3 bit output)

Similarly, the final stage adds the two previous stage outputs using a 3 bit adder, to give a four bit result.

• ...Show all comments
• Dixon
Lv 7
9 months agoReport

daniel g has a good point. If you do it over several clock cycles you can do with just a few standard ICs (parallel load shift reg into a counter and a bit of control for reset / latch etc.) But still not one IC.

• 9 months ago

Do you mean a count of how many of those inputs have a logic "1" value? If all of the inputs were "1", that would be an output value of "1000", so you need 4 bit output, not 3. I would consider using a EPROM with a look-up table.

• ...Show all comments
• Morningfox
Lv 7
9 months agoReport

Otherwise, you might need 7 half-adders and 4 full adders. Take a look at http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.534.7271&rep=rep1&type=pdf.