Hardware interview practice
Detect the wildcard pattern 110?01
Implement both an overlapping FSM and a six-bit shift-register detector for 110?01, where ? is either binary value. Make their outputs agree.
Starting point
Question code
input logic clk, rst_n, in_bit;
output logic detect_fsm, detect_shift;Reviewed example
Work through one case
Input
Streams 110001, 110101, and 110111Expected output
First two match on bit 6; the third does notThe fourth bit may be 0 or 1, but the required fifth bit must be 0.
What to cover
Requirements
- Sample one binary input per rising edge and pulse on the final bit.
- Treat ? as a don't-care pattern position, not four-state X.
- Suppress detection until six bits have been sampled after reset.
- Preserve compatible prefix state for overlapping matches and assert both implementations agree.
