To improve code efficiency, you can specify No. of Transition <= 0. This criteria determines whether the optimization is performed. When you apply this optimization, MicroC makes the following changes to the generated code:
● The declaration ofStateInfo_<CTRL Activity
Name > nextState_<CTRL ActivityName = 0;
is removed— there is no need for this local variable after the optimization.
● All the assignments tonextState_<CTRL Activity Name>
are replaced with assignments tocurrentState_<CTRL Activity Name>
.
● After every transition, MicroC makes the following assignment:
cgGlobalFlags |= BITSUPERSTEP_<Task Name>;
● The code at the end of thecgDo...()
is removed. This is the code that was inlined:if (nextState_<CTRL Activity Name> != 0) {
if (currentState_<CTRL Activity Name> !=
nextState_<CTRL Activity Name>)
cgGlobalFlags |= BITSUPERSTEP_<Task Name>;
currentState_<CTRL Activity Name> =
nextState_<CTRLActivity Name>;
● If a transition is inside an AndState component, the assignment to currentState includes a reset of the bits that represent the component that is the LCA of the transition. For example:nextState_OPT_NEXT_STATE_CTRL =
(nextState_OPT_NEXT_STATE_CTR &~
(FM2_<ComponentLCA of Transition>)) |FS_<Next State>;
Note: The optimization will not take place if there is an entering or exiting reaction that could not be optimized out.