FSM sequence detector in Verilog
Signal (non clock) assignments in a testbench should generally be non blocking (&lt;= operator). Clock assignments should be blocking (= operator). Otherwise there's a race condition.
There are probably exceptions to this rule, but it works for me. Beyond that you need a good understanding of the verilog simulation phases. This rule of thumb will work for you 95% of the time.