DescriptionQ567
Q567FWASIC interview problem
Isolate the lowest set bit
TechniquesBitsTwo's complement
DifficultyEasy
TopicBit Manipulation
LanguageSystemVerilog
Requirements2 checkpoints
01
Problem
Return a mask containing only the least-significant 1 bit of x.
Example input and output
Use this case to check your interpretationInput
value = 8'b1011_0000Output
8'b0001_0000Explanation
value & -value isolates bit 4, the least-significant set bit.
02
Requirements (2)
- Return zero when x is zero.
- Use two's-complement arithmetic.
