DescriptionQ312
Q312FWASIC interview problem
Rotate a packed word
TechniquesBitsRotationParameterized width
DifficultyMedium
TopicBit Manipulation
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
Implement rotate-left and rotate-right for a W-bit packed vector.
Example input and output
Use this case to check your interpretationInput
W=8, word = 8'b1001_0001, rotate_left = 3Output
8'b1000_1100Explanation
The upper three bits wrap into the low end rather than being discarded.
02
Requirements (4)
- 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.
