- We define the states (S0, S1, S2, S3) that the FSM can be in.
- We create state transition logic in the first
always
block, which updates thestate
based on the current state and the inputdata_in
. The FSM starts in state S0 when reset is asserted and transitions through the states as it detects the sequence "101." - We have another
always
block that determines when the sequence is detected (state S3), setting thedetected
output high. - The module has inputs for
clk
,reset
, anddata_in
, and an outputdetected
that indicates when the sequence is detected.
To use this module, you would need to instantiate it in your top-level design and connect the clk
, reset
, data_in
, and detected
signals accordingly.