Documentation

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

Default parameter behavior

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

Settings

Default: Tunable for GRT targets | Inlined for ERT targets

Inlined

Set Default parameter behavior to Inlined to reduce global RAM usage and increase efficiency of the generated code. The code does not allocate memory to represent numeric block parameters such as the Gain parameter of a Gain block. Instead, the code inlines the literal numeric values of these block parameters.

Tunable

Set Default parameter behavior to Tunable to enable tunability of numeric block parameters in the generated code. The code represents numeric block parameters and variables that use the storage class Auto, including numeric MATLAB® variables, as tunable fields of a global parameters structure.

Tips

  • Whether you set Default parameter behavior to Inlined or to Tunable, create parameter data objects to preserve tunability for block parameters. For more information, see Control Parameter Representation and Declare Tunable Parameters in the Generated Code.

  • When you switch from a system target file that is not ERT-based to one that is ERT-based, Default parameter behavior sets to Inlined by default. However, you can change the setting of Default parameter behavior later.

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

    • All referenced models must set Default parameter behavior to Inlined if the top model has Default parameter behavior set to Inlined.

    • The top model can specify Default parameter behavior as Tunable or Inlined.

  • If your model contains an Environment Controller block, you can suppress code generation for the branch connected to the Sim port if you set Default parameter behavior to Inlined and the branch does not contain external signals.

Dependencies

When you set Default parameter behavior to Inlined, you enable these configuration parameters:

Command-Line Information

Parameter: DefaultParameterBehavior
Type: string
Value: 'Inlined' | 'Tunable'
Default: 'Tunable' for GRT targets | 'Inlined' for ERT targets

Recommended Settings

ApplicationSetting
DebuggingTunable during development
Inlined for production code generation
TraceabilityInlined
EfficiencyInlined
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 when you set Default parameter behavior to Inlined.

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingOff
TraceabilityOff
EfficiencyOn
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 and memset function calls should replace for loops for vector assignments in the generated code.

Settings

Default: 64

Dependencies

  • This parameter requires a Simulink Coder license.

  • For the memcpy optimization, 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

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

No impact

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

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
EfficiencyStructure reference (ROM), Individual arguments (execution, 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.

  • 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 when you set Default parameter behavior to Inlined.

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 declare specific tunable parameters when you set Default parameter behavior to Inlined. The parameters that you select appear in the generated code as tunable parameters. For more information about Default parameter behavior, see Default parameter behavior.

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 Type qualifier.

Was this topic helpful?