Skip to content

Conversation

diskouna
Copy link

@diskouna diskouna commented Jan 1, 2025

This PR fixes the popcount output width calculation. The hamming weight of an input of width INPUT_WIDTH can range from 0 (all bits deasserted) to INPUT_WIDTH (all bits asserted), giving a total of INPUT_WIDTH + 1 values. The minimum number of bits required to represent these values is ceil(log2(INPUT_WIDTH+1)).

Some simulation waveforms generated using Vivado2024 are shown below:

sim_data_w5
sim_data_w981

Happy New Year!
diskouna

Copy link
Collaborator

@niwis niwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @diskouna. Looks good to me. Since this changes the interfaces of popcount, I'll merge this in the next major release.

@niwis niwis added the v2 label Jan 15, 2025
@niwis niwis added this to the v2.0 milestone Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants