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

Discussion in 'Homework Help' started by Vincent Del Vecchio, Oct 7, 2016.

  1. Vincent Del Vecchio

    Thread Starter New Member

    Oct 7, 2016
    1
    0
    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.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    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.
     
  3. ci139

    Member

    Jul 11, 2016
    341
    38
    i never thought about but is there possible to use some prediction method to solve it - i must check . . .
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    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: Oct 8, 2016
  5. WBahn

    Moderator

    Mar 31, 2012
    17,720
    4,788
    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.
     
    ErnieM likes this.
  6. ci139

    Member

    Jul 11, 2016
    341
    38
    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
     
Loading...