Forum Discussion
Altera_Forum
Honored Contributor
15 years agoCounting the position of ones in a binary vector
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_5...
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- the loop index is going up anyway. for bit index 3 then output nibble = 3 if it is '1' else nibble = 0 --- Quote End --- e.g. for bit 3, i == 3 and you will fill in nibble 3, but if this was the first bit (set to '1') encountered nibble 0 should get value 3. I don't think your code is doing that. Anyway I compiled my proposition, and it is actually not too bad, The compiler generated 477 LCs for a Cyclone II device. I still (would/will) have to simulate it.