Statechart Implementation: Data Usage
A StateInfo data type will be defined, and a few variables of that type will be declared, when a statechart is created.
For the previous example, the StateInfo data type would be named StateInfo_A11_CTRLcnt1 and will be defined as an unsigned type of either 8, 16 or 32 bits; like “ typedef int8 StateInfo_A11_CTRLcnt1”. The size depends on the topology of the Statechart which is described later in this document.
The StateInfo variables will be currentState, nextState, staySame. For the example of A11_CTRL:
The currentState and nextState variables will always be allocated. The staySame variable will be allocated only if either of the entering or exiting reaction functions is required, as discussed below.
currentState is allocated as global variable, while nextState and staySame are allocated as local, automatic, variables to the statechart function cgDo_… .
Note: Further Optimization: In specific topologies it is possible to use only a single StateInfo variable, i.e. the currentState.