DescriptionQ504
Q504FWASIC interview problem
Compute Hamming distance
TechniquesBitsXORPopcount
DifficultyEasy
TopicBit Manipulation
LanguageSystemVerilog
Requirements2 checkpoints
01
Problem
Return the number of bit positions where two 32-bit integers differ.
Example input and output
Use this case to check your interpretationInput
left = 4'b1010, right = 4'b0011Output
2Explanation
The XOR is 1001, which contains two set bits.
02
Requirements (2)
- Use XOR to expose mismatches.
- Count the set bits in the XOR result.
