The following section describes the options available on the Optimization tab.
Reuse Timeout Variable Where Possible If selected, the code generator will attempt to combine multiple timeout variables into a single variable if they are exclusive, i.e., the timeouts can’t be pending at the same time. (RAM optimization) Clutch Entrance To State Hierarchy If selected, the code will be optimized to enter the innermost state in a state hierarchy, wherever possible. (ROM, runtime optimization) Merge State Sequences with no Guard on Transition If selected, code will be optimized to merge state sequences with no guards on transition into a single state wherever possible. (RAM, ROM, runtime optimization)
• If selected, the code will be optimized to inline the test on default transitions into other transitions’ testing. (RAM, ROM optimization).
• The code below represents the “before” and “after” for this option.if(currentState_S1 == 0){
currentState_S1 = FS_DefaultOfS1;
} else {...if(currentState_S1 == 0 || inState(DefaultOf_S1)){... Inline Setting of “Need Another Step” bit
• At the end of the statechart code, there is a section that tests whether a transition was made in the current step. If so, a flag is raised to indicate that the superstep task should perform another step over the task's code frame. This 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 will be put inline in the transition code, eliminating the need for the state variable that stores the transition's target state.
• When selected, you can enter the maximum number of transitions you are willing to tolerate. If the number of actual transitions will be greater than this, the optimization will not be performed. (RAM, ROM optimization) Inline Entering/Exiting Reactions
• If selected, the code is optimized to try to inline the entering and exiting reactions of states, in order to avoid generating the entering and exiting reaction functions. (RAM, ROM optimization)
• When this option is selected, you can also specify the maximum number of statements that should be inlined. You can also specify the maximum number of instances - you may not want this inlining to be carried out if it will have to be done a large number of times. Empty Overlapping Tests for State Hierarchy
• When there is a state hierarchy, you are obviously not in the inner state if you have not entered the surrounding state. When this option is selected, the code will be optimized by skipping such overlapping comparisons. (ROM optimization, but may reduce runtime efficiency) Generate Model Data and Functions This option allows you to specify that code should be generated for all elements in the model, or only for elements that are used. If the latter option is selected, then if variables/functions are defined but not used/called anywhere in the code, no code will be generated for them.