clk
is the clock input.reset
is the reset input.x
is the input signal to detect the sequence "101."y
is the output signal that will be '1' when the sequence is detected, and '0' otherwise.
The code defines a 3-bit sequence detector using the Moore model. It has four states (S0
to S3
), where S3
represents the state when the "101" sequence is detected. The output y
is set to '1' only when the sequence is detected in state S3
. The FSM transitions through these states based on the input signal x
. The sequence detector resets to S0
when the reset
signal is asserted.
- We instantiate the
sequence_detector_moore
module and connect its inputs and outputs. - We generate a clock signal (
clk
) that toggles every 5 time units. - We define four test cases:
- Reset and no sequence detected.
- A single '1' with no sequence detected.
- The '101' sequence is detected.
- Reset and no sequence detected again.