Read in 8 bits and output the number of 1's as a 4 bit number using logic gates

Thread Starter

Vincent Del Vecchio

Joined Oct 7, 2016
1
My teacher assigned a project where we have to read in 8 bits and output the number of 1's as a 4 bit number using logic gates. He did not teach us about half adders, full adders, or anything past the basic logic gates (and, or, nor, etc...).

I've done research on half and full adders but I still don't understand how to get a 4 bit output after using them to add the 8 bits together.
 

Papabravo

Joined Feb 24, 2006
21,159
What you need to do is think of this as a boolean function of 8 input variables with four outputs. If you make a truth table with 256 possible input values each of which has four outputs then you can write a sum of products expression for each of the four bits.
 

ci139

Joined Jul 11, 2016
1,898
i never thought about but is there possible to use some prediction method to solve it - i must check . . .
 

Papabravo

Joined Feb 24, 2006
21,159
i never thought about but is there possible to use some prediction method to solve it - i must check . . .
It is a straightforward combinatorial Boolean function. No need for a prediction method since there is a unique SOP representation for each output bit.

I just realized that the 8th row of Pascal's Triangle will give you the number of terms for each of the 9 possible values for the sum of the 1's in an 8-bit quantity.
 
Last edited:

WBahn

Joined Mar 31, 2012
29,978
My teacher assigned a project where we have to read in 8 bits and output the number of 1's as a 4 bit number using logic gates. He did not teach us about half adders, full adders, or anything past the basic logic gates (and, or, nor, etc...).

I've done research on half and full adders but I still don't understand how to get a 4 bit output after using them to add the 8 bits together.
Are half-adders and full-adders fair game? If so, go learn about them. If not, then consider the alternatives.

If you broke the input into two 4-bit inputs, could you do the logic to output a 3-bit value for each indicating how many 1's it had? Could you combined these two sets of three inputs to give the final four inputs?

Failing that, go for the low hanging fruit first.

If you were only asked to build a circuit that output a HI if the number of 1's in the circuit was even or odd, could you do that?

If you were only asked to build a circuit that output a HI if all eight bits were 1, could you do that?

Now consider what the lsb and msb of the 4-bit output really tell you.
 

ci139

Joined Jul 11, 2016
1,898
WTH -- aah Pascals triangle 1,11,121,1331,e.c. it gives you basic N-dimensional "solids" as : 1=(center) single dot , (center&point(unipolar direction)) self-pointer , (center and two (direction)point(er)s) line , 2D-triangle , 14641◄tetra-hedron , 5D-"tetra"(projects as pentagram to 3D at certain rotation)
number of points lines sides e.c.
i couldn't match the way to opt so i built 0 bubbler filter and static counter (like an excel table) . . . this -- nothing to do (other interesting)
Draft_8bitSUM.png
 

Attachments

Top