FiniteStateMachine

Parent Previous Next

Behavior / FiniteStateMachine
Block Name: FiniteStateMachine


This is a typed composite actor designed to be a Hierarchical FSM. Inside the FSM-Hierarchical is a finite-state machine controller, and inside each state in the FSM is a refinement model. To use this block, just drag it into a model, and look inside to start constructing the controller. You may add ports to get inputs and outputs, and add states to the controller. You may add one or more refinements to a state (each of these refinements will be executed when this actor is executed). Each refinement is required to have its own simulator, so you will need to choose a simulator.

The controller is a finite-state machine (FSM), which consists of states and transitions. One of the states is an initial state. When this blockexecutes, if the current state has a refinement, then that refinement is executed. Then the guards on all the outgoing transitions of the current state are evaluated, and if one of those guards is true, then the transition is taken. Taking the transition means that the actions associated with the transition are executed (which can result in producing outputs), and the new current state is the state at the destination of the transition. It is an error if more than one of the guards evaluates to true.

To add a state, drag in a state from the library at the left. To add a transition, position the mouse over the source state, hold the control button, and drag to the destination state. The destination state may be the same state, in which case the transition is used simply to execute its actions.

Adding or removing ports in this blockresults in the same ports appearing or disappearing in the FSM controller and in each of the refinements. Similarly, adding or removing ports in the controller or in the refinements results in this actor and the other refinements reflecting the same change to the ports. That is, this block, the controller, and the refinments all contain the same ports.

There is one subtlety regarding ports however. If you add an output port to a refinement, then the corresponding port in the controller will be both an input and an output. The reason for this is that the controller can access the results of executing a refinement in order to choose a transition.


Created with the Personal Edition of HelpNDoc: Free Web Help generator