Finite state machine simulation