Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popcount output width #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
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