cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
5,373 Views
Registered: ‎01-24-2014

how to check which input has most high value wires among 4 8-bit inputs

Jump to solution

Hello everyone. Now I want to implement a module, which has four 8-bit inputs, each bit has only two value:1 or 0, and the output shoud be the input which has the most high value wires. So I have to check which input has most bits with value 1. The method I can think up is to add each input's 8 bits, and compare the results to get the biggest one. In this case, 4*(4+2+1)adders and 3 compare needed, as I will connect tens of this module, this method costs too much time and consumes too much resource. So does anyone has a better solution? Thank you very much in advance.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor
Visitor
9,013 Views
Registered: ‎03-29-2012

Re: how to check which input has most high value wires among 4 8-bit inputs

Jump to solution

Here is a discussion of a similar approach optimized for speed and resources.

 

http://fpgacpu.wordpress.com/2014/09/05/quick-fpga-hacks-population-count/

View solution in original post

2 Replies
Highlighted
Visitor
Visitor
9,014 Views
Registered: ‎03-29-2012

Re: how to check which input has most high value wires among 4 8-bit inputs

Jump to solution

Here is a discussion of a similar approach optimized for speed and resources.

 

http://fpgacpu.wordpress.com/2014/09/05/quick-fpga-hacks-population-count/

View solution in original post

Highlighted
Observer
Observer
5,329 Views
Registered: ‎01-24-2014

Re: how to check which input has most high value wires among 4 8-bit inputs

Jump to solution

Thank you  very much. This is really a good way to sum the nonzero input wires.

0 Kudos