Home / Learn Verilog / Testing State Machines

Testing State Machines

Check all states and transitions.

Quick summaryCheck all states and transitions.

How to think about this

FSM testresetapply inputscompare state/outreport
FSM test

The basic idea

A good test visits every state and every transition and checks outputs.

Why this comes up

FSM bugs hide in rare transitions.

The mechanics

Drive inputs in a scripted order and compare with expected states.

Where it is used

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Self-checking FSM testVerilog: edit and run

A task checks the state after each clock.

Quick check

1. FSM tests should cover...