Hardware interview practice
Implement a parameterized shift register
Write a parameterized serial-in, parallel-out register that shifts toward the MSB on enabled clock edges and supports every width W >= 2.
Starting point
Question code
parameter int W = 8;
input logic clk, rst_n, en, serial_in;
output logic [W-1:0] q;Reviewed example
Work through one case
Input
W=8, q=8'b0000_0101, serial_in=1, en=1; then a rising edgeExpected output
q=8'b0000_1011The old low seven bits shift up and the new serial bit enters bit 0.
What to cover
Requirements
- Use active-low asynchronous reset to zero.
- Shift only when en is high.
- Load serial_in into bit 0 and move existing bits toward the MSB.
- Hold state when disabled and require W >= 2.
