How to write a state machine for Verilog HDL