Skip to content

popcount: Fix output width #251

Merged
phsauter merged 2 commits intopulp-platform:v2-devfrom
diskouna:fix_popcount_width
Apr 23, 2026
Merged

popcount: Fix output width #251
phsauter merged 2 commits intopulp-platform:v2-devfrom
diskouna:fix_popcount_width

Conversation

@diskouna
Copy link
Copy Markdown

@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
Copy Markdown
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
@colluca colluca mentioned this pull request Apr 17, 2026
14 tasks
@phsauter phsauter changed the base branch from master to v2-dev April 23, 2026 13:22
@phsauter phsauter changed the title Fix popcount output width popcount: Fix output width Apr 23, 2026
@phsauter phsauter merged commit e16fb19 into pulp-platform:v2-dev Apr 23, 2026
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.

3 participants