Count number of logic 1's in 7 bit number

Discussion in 'Homework Help' started by ppd, Feb 11, 2011.

  1. ppd

    Thread Starter New Member

    Feb 11, 2011
    2
    1
    What is the simplest logic circuit to count the number of logic ones in a 7 bit input, using only half adders and full adders?
     
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Since you will be using adders, try to see the operation as a sum of numbers. You have 7 numbers, the figures of your 7-bit number. All 7 numbers are 1-bit long. Let's name the figures of your number b0-b6, from the LSB to the MSB. Let's break down the operation:

    Using a 1-bit Full Adder you can add 3 1-bit numbers (1st summand, 2nd summand, Carry-in) and get a 2-bit number.
    Thus you can sum b0,b1,b2 with one FA, and b3,b4,b5 with a second FA.

    You now have 2 2-bit numbers and one 1-bit number, the b6.

    Using a 2-bit FA (which is made of 2 1-bit FA), you can add 2 2-bit numbers and 1 1-bit number (the carry in). You already have the 2 2-bit numbers as the result of the 2 previous additions, and the b6 will be used as the carry-in.
    In the end, you end up wit 1 3-bit number, which can have a maximum value of 7.

    In that implementation we used 4 Full Adders.

    Is that clear?
     
    Tirumala and saichand like this.
  3. ppd

    Thread Starter New Member

    Feb 11, 2011
    2
    1
    That was perfectly clear. Thank you!
     
    Tirumala likes this.
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    I 'll keep asking until someone answers "Crystal!".

    Then I 'll keep asking some more...
     
    shankariyer96 likes this.
Loading...