Counting the position of ones in a binary vector

Thread Starter

ganeshmirajkar

Joined May 4, 2011
2
I want to design a combinatorial circuit for an fpga which will count the position of ones in a 16 bit vector.
eg1 if vector is 16'b0000_0000_0011_0101 then output should be
64'h0000_0000_0000_5420

eg2 if vector is 16'b0000_1010_0000_1010 then output should be
64'h0000_0000_0000_b931.

Please help.
Thanks in advance....
 

Georacer

Joined Nov 25, 2009
5,182
Do you actually want to build the circuit? It looks awful big for a mere homework assignment.

Hint: Use some counters to help you in your work.
One to count how deep you are in the input vector in order to produce the position of each ace.
One to count how many aces you have recorder in order to position you in the output vector.

Keep in mind that this is the Homework Help section, where you have to post your efforts in solving your problem first, before receiving any help.
 

Thread Starter

ganeshmirajkar

Joined May 4, 2011
2
yes i actually want to build this circuit in an fpga. Well this is no homework actually...this is one of the design problems.....i am facing.
 
Top