Hardware interview practice
Detect nonoverlapping 10110 sequences
Design a serial sequence detector that accepts one bit per clock and emits a one-cycle pulse when 10110 completes. Bits consumed by a match cannot begin the next match.
Starting point
Question code
input logic clk, rst_n, bit_in;
output logic detected;Reviewed example
Work through one case
Input
bit_in at successive rising edges = 1, 0, 1, 1, 0Expected output
detected = 0, 0, 0, 0, 1The fifth sampled bit completes 10110, so the registered output pulses for the following cycle and the FSM returns to its no-prefix state.
What to cover
Requirements
- Recognize the exact five-bit pattern 10110 without overlap.
- Pulse detected for exactly one destination clock cycle.
- Clear all partial-match state on reset.
- Retain the longest useful suffix after every mismatch, but return to the start state after a full match.
