For projects created with the MicroC profile
in Rational Rhapsody in the C language, you can use a feature that
generates statechart code for target microcontrollers more efficiently.
In
this implementation, the generated statechart code uses a top-down
algorithm that optimizes the processing of transitions. Efficiency
is gained in terms of RAM, ROM consumption, and code size.
The ability to generate optimized top-down code for statecharts
is activated through the C_CG::Configuration::StatechartImplementation property,
which must be set to OptimizedTopDown. After you
activate this feature, use the properties in the C_CG::OptimizedTopDownStatechart metaclass
to control the optimization of top-down code generation for statecharts.
Optimizations
The optimized top-down statechart
feature contains extensive code documentation and various code optimizations
that are controlled by properties. These optimizations are enabled
by the C_CG::OptimizedTopDownStatechart::AllowCodeOptimization property,
which must be set to Checked.
For code documentation,
use the C_CG::OptimizedTopDownStatechart::AddCodeDocumentation property,
which enables optimized top-down statechart code to include comments
for statechart implementation functions, state transitions, and static
reactions in a state.
For code optimizations, use the following
properties in the
C_CG::OptimizedTopDownStatechart metaclass:
- ClutchEntranceToStateHierarchy - Set to Checked
to enable the optimized top-down statechart code to be optimized to
enter the innermost state in a state hierarchy wherever possible.
- EmptyOverlappingTestsForStateHierarchy - Set
to Checked to enable the optimized top-down statechart
code to be optimized to skip overlapping comparisons when there is
a state hierarchy, so that control cannot be in the inner state if
it has not entered the surrounding state.
- InlineEnteringExitingReactions - Set to Checked to
enable the optimized top-down statechart code to be optimized to try
to inline the entering and exiting reactions of states, in order to
avoid generating the entering and exiting reaction functions.
- InlineMaxTranstionsCriteria - Set to a number
to enable the optimized top-down statechart code to be optimized as
follows: At the end of the statechart code, there is a section that
tests whether a transition was made in the current step. The test
of whether another step is needed uses a state variable that stores
the information about the state that is being entered. When this option
is selected, the code flagging the need for another step is put inline
in the transition code, eliminating the need for the state variable.
When selected, the user can enter the maximum number of transitions
to be tolerated. If the number of actual transitions is greater than
this number, the optimization is not performed.
- InlineRootStateDefaultTransitionTest - Set to Checked to
enable the optimized top-down statechart code to be optimized to inline
the test on default transitions into testing of other transitions.
- MergeStateSequenceWithNoGuard - Set to Checked to
enable the optimized top-down statechart code to be optimized to merge
state sequences with no guards on transition into a single state wherever
possible.