Hardware interview practice
Rotate a packed word
Implement rotate-left and rotate-right for a W-bit packed vector.
Reviewed example
Work through one case
Input
W=8, word = 8'b1001_0001, rotate_left = 3Expected output
8'b1000_1100The upper three bits wrap into the low end rather than being discarded.
What to cover
Requirements
- Require W to be a positive compile-time width.
- Normalize shifts larger than W.
- Return x unchanged when the normalized shift is zero.
- Do not accidentally perform a shift by W.
