Optimization Pane: Signals and Parameters

The Optimization > Signals and Parameters pane includes the following parameters when you select a GRT-based system target file:

The Optimization > Signals and Parameters pane includes the following parameters when you select an ERT-based system target file:

Optimization Pane: Signals and Parameters Tab Overview

Set up optimizations for a model's active configuration set.

Tips

  • To open the Optimization: Signals and Parameters pane, in the Simulink® Editor, select Simulation > Model Configuration Parameters > Optimization > Signals and Parameters.

  • Simulink Coder™ optimizations appear only when the Simulink Coder product is installed on your system. Selecting a GRT-based or ERT-based system target file changes the available options. ERT-based target optimizations require a Embedded Coder® license when generating code. See the Dependencies sections below for licensing information for each parameter.

See Also

Inline parameters

Transform tunable parameters into constant values.

Settings

Default: Off

On

Selecting Inline parameters has the following effects:

  • If you have a Simulink Coder license, the software uses the numerical values of model parameters, instead of their symbolic names, in generated code.

  • Reduces global RAM usage, because parameters are not declared in the global parameters structure.

  • Enables the Configure button. Clicking the Configure button opens the Model Parameter Configuration dialog box.

Off

Uses symbolic names for model parameters in generated code.

Tips

  • If a model contains a Constant block and the Inline parameters option is checked off, the Constant block does not receive the constant sample time it requests. The sample time cannot be constant, even if it is set to Inf. For more information, see Constant Sample Time.

  • To tune a global parameter, change the value of the corresponding workspace variable and select Update Diagram (Ctrl+D) from the Simulink Simulation menu.

  • You cannot tune inline parameters in code generated from a model. However, when simulating a model, you can tune an inline parameter if its value derives from a workspace variable. For example, suppose that a model has a Gain block whose Gain parameter is inline and equals a, where a is a variable defined in the model's workspace. When simulating the model, Simulink software disables the Gain parameter field, preventing you from using the block's dialog box to change the gain. However, you can still tune the gain by changing the value of a at the MATLAB® command line and updating the diagram.

  • When a top model uses referenced models or if a model is referenced by another model:

    • All referenced models must set Inline parameters to on if the top model has Inline parameters selected.

    • The top model can specify Inline parameters to be on or off.

    See Inline Parameter RequirementsInline Parameter Requirements for more information.

  • If your model contains an Environment Controller block, you can suppress code generation for the branch connected to the Sim port if you select Inline parameters and the branch does not contain external signals.

  • Simulink Scope and Signal Viewer blocks with Constant and Ground blocks — If you turn on inline parameters, the value of a Constant or Ground block does not change during the simulation. The constant value is determined before a simulation and plotted on a scope graph as a single point. To see a scope trace, change the sample time for a Constant or Ground block from inf to a value.

Dependencies

This parameter enables:

Command-Line Information

Parameter: InlineParams
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingOff for simulation or during development
On for production code generation
TraceabilityOn
EfficiencyOn
Safety precautionNo impact

See Also

Signal storage reuse

Reuse signal memory.

Settings

Default: On

On

Simulink software reuses memory buffers allocated to store block input and output signals, reducing the memory requirement of your real-time program.

Off

Simulink software allocates a separate memory buffer for each block's outputs. This makes all block outputs global and unique, which in many cases significantly increases RAM and ROM usage.

Tips

  • This option applies only to signals with storage class Auto.

  • Signal storage reuse can occur only among signals that have the same data type.

  • Clearing this option can substantially increase the amount of memory required to simulate large models.

  • Clear this option if you need to:

  • Simulink software opens an error dialog if Signal storage reuse is enabled and you attempt to use a Floating Scope or floating Display block to display a signal whose buffer has been reused.

Dependencies

This parameter enables:

Command-Line Information

Parameter:OptimizeBlockIOStorage
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn
Safety precautionNo impact

See Also

Enable local block outputs

Specify whether block signals are declared locally or globally.

Settings

Default: On

On

Block signals are declared locally in functions.

Off

Block signals are declared globally.

Tips

  • If it is not possible to declare an output as a local variable, the generated code declares the output as a global variable.

  • If you are constrained by limited stack space, you can turn Enable local block outputs off and still benefit from memory reuse.

Dependencies

  • This parameter requires a Simulink Coder license.

  • This parameter is enabled by Signal storage reuse.

Command-Line Information

Parameter: LocalBlockOutputs
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn
Safety precautionNo impact

See Also

Reuse local block outputs

Specify whether Simulink Coder software reuses signal memory.

Settings

Default: On

On
  • Simulink Coder software reuses signal memory whenever possible, reducing stack size where signals are being buffered in local variables.

  • Selecting this parameter trades code traceability for code efficiency.

Off

Signals are stored in unique locations.

Dependencies

This parameter:

  • Is enabled by Signal storage reuse.

  • Requires a Simulink Coder license.

Command-Line Information

Parameter: BufferReuse
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn
Safety precautionNo impact

See Also

Eliminate superfluous local variables (Expression folding)

Collapse block computations into single expressions.

Settings

Default: On

On
  • Enables expression folding.

  • Eliminates local variables, incorporating the information into the main code statement.

  • Improves code readability and efficiency.

Off

Disables expression folding.

Dependencies

  • This parameter requires a Simulink Coder license.

  • This parameter is enabled by Signal storage reuse.

Command-Line Information

Parameter: ExpressionFolding
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityNo impact for simulation or during development
Off for production code generation
EfficiencyOn
Safety precautionNo impact

See Also

Reuse global block outputs

Reuse global memory for block outputs.

Settings

Default: On

On
  • Software reuses signal memory whenever possible, reducing global variable use.

  • Selecting this parameter trades code traceability for code efficiency.

Off

Signals are stored in unique locations.

Dependencies

This parameter:

  • Is enabled by Signal storage reuse.

  • Requires an Embedded Coder license.

  • Appears only for ERT-based targets.

Command-Line Information

Parameter: GlobalBufferReuse
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn (execution, ROM, RAM)
Safety precautionNo impact

See Also

Minimize data copies between local and global variables

Reuse existing global variables to store temporary results.

Settings

Default: Off

On

Writes data for block outputs to global variables, reducing RAM consumption and execution time.

Off

Writes data for block outputs to local variables.

Dependencies

  • This parameter requires a Simulink Coder license.

  • This parameter is enabled by Signal storage reuse.

  • With an Embedded Coder license, if you select an embedded target such as ert.tlc, the software replaces Minimize data copies between local and global variables check box with the Optimize global data access list. When Minimize data copies between local and global variables is selected, Optimize global data access is set to Use global to hold temporary results.

Command-Line Information

Parameter: EnhancedBackFolding
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn (execution, ROM, RAM)
Safety precautionNo impact

See Also

Inline invariant signals

Transform symbolic names of invariant signals into constant values.

Settings

Default: Off

On

Simulink Coder software uses the numerical values of model parameters, instead of their symbolic names, in generated code. An invariant signal is not inline if it is nonscalar, complex, or the block inport the signal is attached to takes the address of the signal.

Off

Uses symbolic names of model parameters in generated code.

Dependencies

  • This parameter requires a Simulink Coder license.

  • This parameter is enabled by Inline parameters.

Command-Line Information

Parameter: InlineInvariantSignals
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn
Safety precautionNo impact

See Also

Inlining Invariant SignalsInlining Invariant Signals

Optimize global data access

Select global variable optimization.

Settings

Default: None

None

Use default optimizations.

Use global to hold temporary results

Maximize use of global variables.

Minimize global data access

Minimize use of global variables by using local variables to hold intermediate values.

Dependencies

  • This parameter is enabled by Signal storage reuse.

  • This parameter requires an Embedded Coder license.

  • Appears only for ERT-based targets.

Command-Line Information

Parameter: GlobalVariableUsage
Type: string
Value: 'None' | 'Use global to hold temporary results' | 'Minimize global data access'
Default: 'None'

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn (execution, ROM, RAM)
Safety precautionNo impact

See Also

Simplify array indexing

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

Settings

Default: Off

On

In array indices, replace multiply operations with add operations when accessing arrays in a loop in the generated code. When the original signal is multidimensional, the Embedded Coder generates one-dimensional arrays, resulting in multiply operations in the array indices. Using this setting eliminates costly multiply operations when accessing arrays in a loop in the C/C++ program. This optimization (commonly referred to as strength reduction) is particularly useful if the C/C++ compiler on the target platform does not have similar functionality. No appearance of multiply operations in the C/C++ program does not imply that the C/C++ compiler does not generate multiply instructions.

Off

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

Dependencies

This parameter:

  • Requires a Embedded Coder license to generate code.

  • Appears only for ERT-based targets.

Command-Line Information

Parameter: StrengthReduction
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Use memcpy for vector assignment

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

Settings

Default: On

On

Enables use of memcpy for vector assignment based on the associated threshold parameter Memcpy threshold (bytes). memcpy is used in the generated code if the number of array elements times the number of bytes per element is greater than or equal to the specified value for Memcpy threshold (bytes). One byte equals the width of a character in this context.

Off

Disables use of memcpy for vector assignment.

Dependencies

  • This parameter requires a Simulink Coder license.

  • When selected, this parameter enables the associated parameter Memcpy threshold (bytes).

Command-Line Information

Parameter: EnableMemcpy
Type: string
Value: 'on' | 'off'
Default: 'on'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyOn
Safety precautionNo impact

See Also

Memcpy threshold (bytes)

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

Settings

Default: 64

Specify the array size, in bytes, at which the code generator begins to use memcpy instead of for loops for vector assignments.

Dependencies

  • This parameter requires a Simulink Coder license.

  • This parameter is enabled when you select Use memcpy for vector assignment.

Command-Line Information

Parameter: MemcpyThreshold
Type: integer
Value: any valid quantity of bytes
Default: 64

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyAccept default or determine target-specific optimal value
Safety precautionNo impact

See Also

Pack Boolean data into bitfields

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

    Note:   You cannot use this optimization when you generate code for a target that specifies an explicit structure alignment.

Settings

Default: Off

On

Stores Boolean signals into one–bit bitfields in global block I/O structures or DWork vectors. This will reduce RAM, but might cause more executable code.

Off

Stores Boolean signals as a Boolean data type in global block I/O structures or DWork vectors.

Dependencies

This parameter:

  • Requires a Embedded Coder license.

  • Appears only for ERT-based targets.

Command-Line Information

Parameter: BooleansAsBitfields
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyOff (execution, ROM), On (RAM)
Safety precautionNo impact

See Also

Bitfield declarator type specifier

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

    Note:   The optimization benefit is dependent upon your choice of target.

Settings

Default: uint_T

uint_T

The type specified for a bitfield declaration is an unsigned int.

uchar_T

The type specified for a bitfield declaration is an unsigned char.

Tip

The Pack Boolean data into bitfields configuration parameter default setting uses unsigned integers. This might cause an increase in RAM if the bitfields are small and distributed. In this case, uchar_T might use less RAM depending on your target.

Dependency

Pack Boolean data into bitfields enables this parameter.

Command-Line Information

Parameter: BitfieldContainerType
Type: string
Value: uint_T | uchar_T
Default: uint_T

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyTarget dependent
Safety precautionNo impact

See Also

Pack Boolean data into bitfields

Loop unrolling threshold

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

Settings

Default: 5

Specify the array size at which the code generator begins to use a for loop instead of separate assignment statements to assign values to the elements of a signal or parameter array.

When there are perfectly nested loops, the code generator uses a for loop if the product of the loop counts for all loops in the perfect loop nest is greater than or equal to the threshold.

Dependency

This parameter requires a Simulink Coder license.

Command-Line Information

Parameter: RollThreshold
Type: string
Value: any valid value
Default: '5'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
Efficiency>0
Safety precaution>1

See Also

Maximum stack size (bytes)

Specify the maximum stack size in bytes for your model.

Settings

Default:Inherit from target

Inherit from target

The Simulink Coder software assigns the maximum stack size to the smaller value of the following:

  • The default value (200,000 bytes) set by the Simulink Coder software

  • Value of the TLC variable MaxStackSize in the system target file

<Specify a value>

Specify a positive integer value. Simulink Coder software assigns the maximum stack size to the specified value.

    Note:   If you specify a maximum stack size for a model, the estimated required stack size of a referenced model must be less than the specified maximum stack size of the parent model.

Tips

  • If you specify the maximum stack size to be zero, then the generated code implements all variables as global data.

  • If you specify the maximum stack to be inf, then the generated code contains the least number of global variables.

Command-Line Information

Parameter: MaxStackSize
Type: int
Value: Any valid value
Default: Inherit from target

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Customize Stack Space Allocation in the Simulink Coder documentation

Pass reusable subsystem outputs as

Specify how a reusable subsystem passes outputs.

Settings

Default: Structure reference

Structure reference

Passes reusable subsystem outputs as a pointer to a structure stored in global memory.

Individual arguments

Passes each reusable subsystem output argument as an address of a local, instead of as a pointer to an area of global memory containing all output arguments. This option reduces global memory usage and eliminates copying local variables back to global block I/O structures. When the signals are allocated as local variables, there may be an increase in stack size. If the stack size increases beyond a level that you want, use the default setting. The maximum number of output arguments passed individually is 12.

    Note:   The default option is used for reusable subsystems that have signals with variable dimensions.

Dependencies

This parameter:

  • Requires a Embedded Coder license.

  • Appears only for ERT-based targets.

Command-Line Information

Parameter: PassReuseOutputArgsAs
Type: string
Value: 'Structure reference' | 'Individual arguments'
Default: 'Structure reference'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact (execution), Structure reference (ROM), Individual arguments (RAM)
Safety precautionNo impact

See Also

Parameter structure

Control how parameter data is generated for reusable subsystems.

Settings

Default: Hierarchical

Hierarchical

Generates a separate header file, defining an independent parameter structure, for each subsystem that meets the following conditions:

  • The subsystem Code generation function packaging parameter is set to Reusable function.

  • The subsystem does not violate any code reuse limitations.code reuse limitations.

  • The subsystem does not access parameters other than its own (such as parameters of the root-level model).

Each subsystem parameter structure is referenced as a substructure of the root-level parameter data structure, creating a structure hierarchy.

NonHierarchical

Generates a single, flat parameter data structure. Subsystem parameters are defined as fields within the structure. A nonhierarchical data structure can reduce compiler padding between word boundaries, producing more efficient compiled code.

Dependencies

  • This parameter appears only for ERT-based targets.

  • This parameter requires a Embedded Coder license when generating code.

  • This parameter is enabled by Inline parameters.

Command-Line Information

Parameter: InlinedParameterPlacement
Type: string
Value: 'Hierarchical' | 'NonHierarchical'
Default: 'Hierarchical'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityHierarchical
EfficiencyNonHierarchical
Safety precautionNo impact

See Also

Model Parameter Configuration Dialog Box

The Model Parameter Configuration dialog box allows you to override the Inline parameters option (see Inline parametersInline parameters) for selected parameters.

    Note   Simulink software ignores the settings of this dialog box if a model contains references to other models. However, you can still tune parameters of such models, using Simulink.Parameter objects (see Inline Parameter Requirements for more information).

The dialog box has the following controls.

Source list

Displays a list of workspace variables. The options are:

  • MATLAB workspace — Lists all variables in the MATLAB workspace that have numeric values.

  • Referenced workspace variables — Lists only those variables referenced by the model.

Refresh list

Updates the source list. Click this button if you have added a variable to the workspace since the last time the list was displayed.

Add to table

Adds the variables selected in the source list to the adjacent table of tunable parameters.

New

Defines a new parameter and adds it to the list of tunable parameters. Use this button to create tunable parameters that are not yet defined in the MATLAB workspace.

    Note   This option does not create the corresponding variable in the MATLAB workspace. You must create the variable yourself.

Storage class

Used for code generation. For more information, see Storage class.

Storage type qualifier

Used for code generation. For more information, see Storage type qualifier.

Was this topic helpful?