Mealy state machine defined