Optimize Generated Code

How to Optimize Generated Code for Embeddable Targets

To optimize code generation for your model:

  1. Open the Model Configuration Parameters dialog box.

  2. In the Model Configuration Parameters dialog box, select the Optimization > Stateflow pane.

  3. Choose from these options:

    • Use bitsets for storing state configuration — Reduces the amount of memory that stores state configuration variables. However, it can increase the amount of memory that stores target code if the target processor does not include instructions for manipulating bitsets.

    • Use bitsets for storing Boolean data — Reduces the amount of memory that stores Boolean variables. However, it can increase the amount of memory that stores target code if the target processor does not include instructions for manipulating bitsets.

        Note:   You cannot use bitsets when you generate code for these cases:

        • An external mode simulation

        • A target that specifies an explicit structure alignment

Design Tips for Optimizing Generated Code

The following design tips can help optimize generated code.

 Do not access machine-parented data in a graphical function

 Be explicit about the inline option of a graphical function

 Avoid using multiple edge-triggered events in Stateflow charts

 Combine input signals of a chart into a single bus object

Was this topic helpful?