DesignThe machine
A Moore machine with 8 states, built from D flip-flops, that detects a 4-bit sequence anywhere in a continuous stream. When a partial match breaks, the machine falls back to the state for the suffix it has already seen instead of resetting to zero.
OptimizationCheaper in gates
- A custom Gray-code state assignment changes only one state bit per transition, which reduces the terms each next-state equation has to cover.
- Karnaugh-map simplification took total gate input cost from 83 to 63, a 24% cut with no change in behaviour.
SimulationVerification
I checked timing and state transitions in Quartus Prime simulation, covering partial matches, broken matches and back-to-back detections as well as the normal case.