DescriptionQ563
Q563DVASIC interview problem
Popcount an arbitrary bit vector
TechniquesPacked vectorPopcount
DifficultyEasy
TopicVerification Utilities
LanguageSystemVerilog
Requirements2 checkpoints
01
Problem
Return the number of 1 bits in a packed bit vector.
Example input and output
Use this case to check your interpretationInput
bits = 12'b1010_0011_0101Output
6Explanation
The count covers the full supplied vector width rather than assuming a fixed 32-bit value.
02
Requirements (2)
- Derive the loop bound from $bits(v).
- Count only known 1 values.
