DescriptionQ788
Q788FWASIC interview problem
Count set bits with Kernighan's method
TechniquesBitsPopcount
DifficultyEasy
TopicBit Manipulation
LanguageSystemVerilog
Requirements2 checkpoints
01
Problem
Return the number of 1 bits in a 32-bit unsigned integer.
Example input and output
Use this case to check your interpretationInput
value = 8'b1011_0100Output
4Explanation
Four iterations clear the lowest remaining one-bit before the value reaches zero.
02
Requirements (2)
- Clear one set bit per iteration.
- Return zero for an all-zero input.
