Memory Usage
Control memory consumption by specifying whether the code generator defines variables locally or globally and how data passes to subsystem functions. Modify configuration settings to reduce the amount of memory for storing data.
The code generator reduces ROM consumption by combining control flow constructs, removing dead code paths and code for blocks that do not have an impact on computational results. You can further reduce ROM consumption by removing code that you might not need such as initialization code, the reset and disable functions, and defensive code.
Topics
- Vector Operation Optimization
The code generator reduces stack memory by replacing temporary local arrays with local variables.
- Reduce Memory Usage for Boolean and State Configuration Variables
Reduce the amount of memory that stores state configuration variables and
Boolean
variables. - Optimize Generated Code Using memset Function
The
memset
function clears internal storage, regardless of type, to the integer bit pattern 0 (that is, all bits are off). - Customize Stack Space Allocation
Control the maximum allowable stack size to provide some control over whether data is defined locally or globally in the generated code.
- Configure Loop Unrolling Threshold
Starting at a default value of 5, the code generator begins to use a
for
loop instead of separate statements to assign values to the elements of a signal or parameter array. - Specify Single-Precision Data Type for Embedded Application
Generate code whose floating-point data types are only single precision, for example, for targeting a single-precision processor.
- Generate Efficient Code by Specifying Data Types for Block Parameters
To generate more efficient code, match parameter data types with signal data types or store parameters in smaller data types.
- Optimize Generated Code Using Boolean Data for Logical Signals
The code generator optimizes the generated code by storing logical signals as
Boolean
data types. - Optimize Memory Usage for Time Counters
Optimize memory that the code generator allocates for an elapsed time counter.