Main Content

Pass fixed-size scalar root inputs by value for code generation

Description

Specify whether a model that calls (references) this model passes its scalar inputs to this model by value.

Category: Model Referencing

Settings

Default: Off (GUI), 'on' (command-line)

On

A model that calls (references) this model passes scalar inputs to this model by value.

Off

The calling model passes the inputs by reference (it passes the addresses of the inputs rather than the input values).

Tips

  • This option is ignored in either of these two cases:

    • The C function prototype control is not the default.

    • The C++ encapsulation interface is not the default.

  • Passing root inputs by value allows this model to read its scalar inputs from register or local memory, which is faster than reading the inputs from their original locations.

  • Enabling this parameter can result in the simulation behavior differing from the generated code behavior under certain modeling semantics. If you use the default setting of Enable all as errors for the Configuration Parameters > Diagnostics > Connectivity > Context-dependent inputs parameter, then Simulink® reports cases where the modeling semantics may result in inconsistent behaviors for simulation and for generated code. If the diagnostic identifies an issue, latch the function-call subsystem inputs. For more information about latching function-call subsystems, see Context-dependent inputs.

  • If the Context-dependent inputs diagnostic reports no issues for a model, consider enabling the Pass fixed-size scalar root inputs by value for code generation parameter, which usually generates more efficient code for such a model.

  • If you have a Simulink Coder™ license, selecting this option can affect reuse of code generated for subsystems. See Generate Reentrant Code from Subsystems (Simulink Coder) for more information.

  • For SIM targets, a model that references this model passes inputs by reference, regardless of how you set the Pass fixed-size scalar root inputs by value for code generation parameter.

Command-Line Information

Parameter:ModelReferencePassRootInputsByReference
Value: 'on' | 'off'
Default: 'on'

Note

The command-line values are reverse of the settings values. Therefore, 'on' in the command line corresponds to the description of “Off” in the settings section, and 'off' in the command line corresponds to the description of “On” in the settings section.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precaution

No recommendation

For the diagnostic action to take when the software has to compute the input to a function-call subsystem, see Context-dependent inputs.

Related Topics