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.
Control the maximum allowable stack size to provide some control over whether data is defined locally or globally in the generated code.
Enable parameters that provide the capability to reuse memory allocated for signals.
Where possible, the code generator declares block outputs as local variables, so that it can potentially reuse these variables.
The code generator attempts to reuse global variables.
Choose a global variable reference optimization to satisfy your memory usage and execution speed requirements.
The code generator eliminates data copies from local variables back to global block I/O structures by passing reusable subsystem outputs as individual arguments instead of as a pointer to a structure stored in global memory.
To reduce global RAM for a nonreusable subsystem, generate a function interface that passes data through arguments instead of global variables.
Control whether to initialize internal data (blocks states and block outputs) and external data (root inports and outports whose value is zero) in the generated code.
Remove unreachable (dead-code) instances of the reset and disable functions from the generated code for ERT-based systems that include model referencing hierarchies.
Use the numerical values of invariant signals instead of their symbolic names in the generated code.
Reduce global RAM usage by inlining the literal numeric values of block parameters.
The code generator optimizes the generated code by combining
if-else statements that share the same condition.
The code generator eliminates dead (that is, unused) code paths from the generated code.
The code generator increases execution speed and reduces ROM consumption by removing code that does not impact computational results.
The code generator uses data dependency analysis to combine
for constructs to reduce static
code size and runtime branching.
Reuse buffers for matrices that have different sizes and shapes.
Reduce the amount of memory that stores state configuration
Optimize memory that the code generator allocates for elapsed time or absolute time.
The code generator optimizes the generated code by storing
logical signals as
The code generator reduces RAM consumption by packing boolean data into 1-bit bitfields.
The code generator reduces stack memory by replacing temporary local arrays with local variables.
Generate code whose floating-point data types are only single precision, for example, for targeting a single-precision processor.
To generate more efficient code, match parameter data types with signal data types or store parameters in smaller data types.
Generate code with Logical or Bitwise Operators or a combination of both operators.