Hardware interview practice
Get, set, clear, and toggle one bit
Implement helpers to read, set, clear, and toggle bit i of a 32-bit unsigned integer.
Reviewed example
Work through one case
Input
value = 8'b0010_1000, bit_index = 1Expected output
get=0, set=0010_1010, clear=0010_1000, toggle=0010_1010Bit 1 starts clear, so the example visibly distinguishes setting and toggling it from reading or clearing it.
What to cover
Requirements
- Build the mask from an unsigned one.
- Assume i is in the range 0 through 31.
