Data Copy Reduction
Reduce RAM and ROM consumption and increase code execution speed by eliminating data copies in the generated code. The code generator eliminates some data copies. You can eliminate other data copies by adjusting certain model parameter settings, specifying the same name for the input and output arguments of MATLAB Function blocks, and by using Simulink signals to specify reuse.
Topics
- Minimize Computations and Storage for Intermediate Results at Block Outputs
The code generator folds block computations into a single expression, instead of generating separate code statements and storage declarations for each block in a model.
- Fold Expressions
Expression fold code to minimize the computation of intermediate results at block outputs and the storage of such results in temporary buffers or variables.
- Enable and Reuse Local Block Outputs in Generated Code
Where possible, the code generator declares block outputs as local variables, so that it can potentially reuse these variables.
- Generate Efficient Code for Buses
Model buses to maximize efficiency of the generated code.
- Inline Invariant Signals
Use the numerical values of invariant signals instead of their symbolic names in the generated code.
- Use memcpy Function to Optimize Generated Code for Vector Assignments
The code generator optimizes the generated code for vector assignments by replacing
for
loops withmemcpy
function calls.