Pass fixed-size scalar root inputs by value for code generation
Option to pass scalar input to model by reference or value
Model Configuration Pane: Model Referencing
Description
The Pass fixed-size scalar root inputs by value for code generation configuration parameter determines whether a model that references this model passes its scalar root inputs to this model by reference or by value.
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 and usually generates more efficient code.
Passing root inputs by value for a model that contains a function-call subsystem might cause the simulation behavior to differ from the generated code behavior. When the software provides an error or warning about function-call subsystem inputs that might cause inconsistent behavior, latch the function-call subsystem inputs. For more information, see Context-dependent inputs.
Set Configuration Parameter for Referenced Model
In a model reference hierarchy, how you open the Configuration Parameters dialog box determines whether you edit the configuration parameter for the top model in the current model hierarchy or the current referenced model.
Top model in the current model hierarchy — In the Simulink® Toolstrip, on the Modeling tab, click Model Settings.
Current referenced model — In the Simulink Toolstrip, on the Modeling tab, click the Model Settings button arrow. Then, in the Referenced Model section, select Model Settings.
Alternatively, open the referenced model as a top model. Then, in the Simulink Toolstrip, on the Modeling tab, click Model Settings.
Dependencies
To enable this parameter, set Total
number of instances allowed per top model to One
or
Multiple
.
Settings
off
(default) | on
on
A model that references this model passes scalar inputs to this model by value.
off
The parent model passes the inputs by reference. It passes the addresses of the inputs rather than the input values.
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | No 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. |
Programmatic Use
Parameter:
ModelReferencePassRootInputsByReference |
Value1
:
'on' | 'off' |
Default:
'on' |
Limitations
The Pass fixed-size scalar root inputs by value for code generation configuration parameter setting 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.
If you have a Simulink Coder™ license, selecting Pass fixed-size scalar root inputs by value for code generation can affect reuse of code generated for subsystems. For more information, see Generate Reentrant Code from Subsystems (Simulink Coder).
For simulation 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 configuration parameter.
Version History
Introduced before R2006a
See Also
1 This table maps the programmatic values to the equivalent interactive values of the Pass fixed-size scalar root inputs by value for code generation configuration parameter.
ModelReferencePassRootInputsByReference
Value | Equivalent Pass fixed-size scalar root inputs by value for code generation Value |
---|---|
'on' | off |
'off' | on |