Main Content

Model Configuration Parameters: Code Generation Optimization

The Code Generation > Optimization category includes parameters for improving the simulation speed of your models and improving the performance of the generated code. Model configuration parameters to improve the generated code require Simulink® Coder™ or Embedded Coder®.

ParameterDescription

Default parameter behavior

Transform numeric block parameters into constant inlined values in the generated code.

Pass reusable subsystem outputs as

Specify how a reusable subsystem passes outputs.

Remove root level I/O zero initialization

Specify whether to generate initialization code for root-level inports and outports set to zero.

Remove internal data zero initialization

Specify whether to generate initialization code for internal work structures, such as block states and block outputs, to zero.

Level

Choose the optimization level that you want to apply to the generated code.

Priority

Optimize the generated code for increased execution efficiency, decreased RAM consumption, or a balance between the two.

Specify custom optimizations

Instead of applying an optimization level, select this parameter to select the optimization parameters in the Details section.

Use memcpy for vector assignment

Optimize code generated for vector assignment by replacing for loops with memcpy.

Memcpy threshold (bytes)

Specify the minimum array size in bytes for which memcpy and memset function calls should replace for loops for vector assignments in the generated code.

Enable local block outputs

Specify whether block signals are declared locally or globally.

Reuse local block outputs

Specify whether Simulink Coder software reuses signal memory.

Eliminate superfluous local variables (Expression folding)

Collapse block computations into single expressions.

Reuse global block outputs

Reuse global memory for block outputs.

Perform in-place updates for Assignment and Bus Assignment blocks

Reuse the input and output variables of Bus Assignment and Assignment blocks if possible.

Reuse buffers for Data Store Read and Data Store Write blocks

Remove temporary buffers for Data Store Read and Data Store Write blocks. Use the Data Store Memory block directly if possible.

Simplify array indexing

Replace multiply operations in array indices when accessing arrays in a loop.

Pack Boolean data into bitfields

Specify whether Boolean signals are stored as one–bit bitfields or as a Boolean data type.

Bitfield declarator type specifier

Specify the bitfield type when selecting configuration parameter Pack Boolean data into bitfields.

Reuse buffers of different sizes and dimensions

Reduce memory consumption by reusing buffers to store data of different sizes and dimensions.

Optimize global data access

Select global variable optimization.

Optimize block operation order in the generated code

Reorder block operations in the generated code for improved code execution speed.

Use bitsets for storing state configuration

Use bitsets to reduce the amount of memory required to store state configuration variables.

Use bitsets for storing Boolean data

Use bitsets to reduce the amount of memory required to store Boolean data.

Maximum stack size (bytes)

Specify the maximum stack size in bytes for your model.

Loop unrolling threshold

Specify the minimum signal or parameter width for which a for loop is generated.

Optimize using the specified minimum and maximum values

Optimize generated code using the specified minimum and maximum values for signals and parameters in the model.

Maximum number of arguments for subsystem outputs

Set maximum number of subsystem outputs to pass individually.

Inline invariant signals

Transform symbolic names of invariant signals into constant values.

Remove code from floating-point to integer conversions with saturation that maps NaN to zero

Remove code that handles floating-point to integer conversion results for NaN values.

Use memset to initialize floats and doubles to 0.0

Specify whether to generate code that explicitly initializes floating-point data to 0.0.

Remove code from floating-point to integer conversions that wraps out-of-range values

Remove wrapping code that handles out-of-range floating-point to integer conversion results.

Remove Code from Tunable Parameter Expressions That Saturate Out-of-Range Values

Remove wrapping code of tunable parameters.

Remove code that protects against division arithmetic exceptions

Specify whether to generate code that guards against division by zero and INT_MIN/-1 operations for integers and fixed-point data.

Buffer for reusable subsystemsImprove reuse by inserting buffers at reusable subsystem boundaries.

Disable incompatible optimizations

Specify whether to disable optimizations that are incompatible with Simulink Code Inspector.

Base storage type for automatically created enumerationsSet the storage type and size for enumerations created with active state output.
Use signal labels to guide buffer reuseFor signals with the same label, the code generator attempts to use the same signal memory.
Generate parallel for-loopsSpecify whether for-loops in the generated code shall be implement in parallel for Matlab Function, Matlab System or a For Each block.
Signal storage reuseSpecify reuse of memory buffers allocated to store block input and output signals thereby reducing the memory requirement of real-time program
Operator to represent Bitwise and Logical Operator blocksSpecify whether the generated code contains bitwise or logical operators or both.

Related Topics