Skip to content

Latest commit

 

History

History

Day-32

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

In this Verilog code:

  • 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.

In this testbench:

  • 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:
    1. Reset and no sequence detected.
    2. A single '1' with no sequence detected.
    3. The '101' sequence is detected.
    4. Reset and no sequence detected again.