Optimize generated code using the specified minimum and maximum values for signals and parameters in the model.
Category: Optimization
Default: Off
Optimizes the generated code using range information derived from the minimum and maximum specified values for signals and parameters in the model.
Ignores specified minimum and maximum values when generating code.
To detect mismatches between model and generated code simulations that arise from
the use of this parameter, before running normal, accelerator, software-in-the-loop (SIL), or processor-in-the-loop
(PIL) simulations, set Diagnostics > Data Validity > Simulation range checking to Warning
or
Error
.
Specify minimum and maximum values for signals and parameters in the model for:
Inport and Outport blocks.
Block outputs.
Block inputs, for example, for the MATLAB Function and Stateflow Chart blocks.
Simulink.Signal
objects.
This optimization does not take into account minimum and maximum values specified for:
Merge block inputs. To work around this, use a
Simulink.Signal
object on the Merge block output
and specify the range on this object
Bus elements.
Conditionally-executed subsystem (such as a triggered subsystem) block outputs that are directly connected to an Outport block.
Outport blocks in conditionally-executed subsystems can have an initial value specified for use only when the system is not triggered. In this case, the optimization cannot use the range of the block output because the range might not cover the initial value of the block.
If you use the Polyspace® Code Prover™software to verify code generated using this optimization, it might mark code that was previously green as orange. For example, if your model contains a division where the range of the denominator does not include zero, the generated code does not include protection against division by zero. Polyspace Code Prover might mark this code orange because it does not have information about the minimum and maximum values specified for the inputs to the division.
The Polyspace
Code Prover software does automatically capture some minimum and maximum values
specified in the MATLAB® workspace, for example, for Simulink.Signal
and
Simulink.Parameter
objects. In this example, to provide range
information to the Polyspace
Code Prover software, use a Simulink.Signal
object on the input of
the division and specify a range that does not include zero.
The Polyspace Code Prover software stores these values in a Data Range Specification (DRS) file. However, they do not capture minimum and maximum values specified in your Simulink® model. To provide additional min/max information to Polyspace Code Prover, you can manually define a DRS file. For more information, see the Polyspace Code Prover documentation.
If you are using double-precision data types and the Code Generation > Interface > Support non-finite numbers configuration parameter is selected, this optimization does not occur.
If your model contains multiple instances of a reusable subsystem and each instance uses input signals with different specified minimum and maximum values, this optimization might result in different generated code for each subsystem so code reuse does not occur. Without this optimization, the Simulink Coder™ software generates code once for the subsystem and shares this code among the multiple instances of the subsystem.
The Model Advisor check Check safety-related optimization settings (Simulink Check) generates a warning if this option is selected. For many safety-critical applications, removing dead code automatically is unacceptable because doing so might make code untraceable.
Enabling this optimization improves the ability of the Fixed-Point Designer™ software to eliminate unnecessary utility functions and saturation code from the generated code.
This parameter appears for ERT-based targets only.
This parameter requires a Embedded Coder® license when generating code.
Parameter:
UseSpecifiedMinMax |
Value:
'on' | 'off' |
Default:
'off' |
Application | Setting |
---|---|
Debugging | Off |
Traceability | Off |
Efficiency | On |
Safety precaution | No impact |