Hardware interview practice
Popcount an arbitrary bit vector
Return the number of 1 bits in a packed bit vector.
Reviewed example
Work through one case
Input
bits = 12'b1010_0011_0101Expected output
6The count covers the full supplied vector width rather than assuming a fixed 32-bit value.
What to cover
Requirements
- Derive the loop bound from $bits(v).
- Count only known 1 values.
