1

I'm designing a circuit that needs to check if the popcount (number of bit sets to 1) of two 16-bit vectors are equal. So what I need is to perform the operation

logic[15:0] A,B;

if (popcount(A) == popcount(B)) begin
...
end

(here popcount is assumed to be an already defined function)

The trivial solution is indeed to compute the actual values and compare them, but I was wondering if there is another way requiring less levels of logic to complete the operation. I tried to think about a way to exploit their parity, but without much success...

asa
  • 39
  • 1
  • 2
  • Just write the logic in a human-readable way and let the synthesizer deal with optimizing it. – mkrieger1 Jun 29 '19 at 10:54
  • there are some population count algorithms around designed to reduce logic levels. Here is an example: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.534.7271&rep=rep1&type=pdf. There are definitely more. Search for htem. – Serge Jun 30 '19 at 02:29

0 Answers0