Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Model Referencing Pane

Model Referencing Pane Overview

Specify the options for including other models in this model, this model in other models, and for building simulation and code generation targets.

Configuration

Set the parameters displayed.

Tips

  • To open the Model Referencing pane, in the Simulink® Editor, select Simulation > Model Configuration Parameters > Model Referencing.

  • The Model Referencing pane allows you to specify options for:

    • Including other models in this model.

    • Including the current model in other models.

  • The option descriptions use the term this model to refer to the model that you are configuring and the term referenced model to designate models referenced by this model.

See Also

Rebuild

Select the method used to determine when to rebuild simulation and Simulink Coder™ targets for referenced models before updating, simulating, or generating code from this model.

There are four rebuild options. Two options, Always and Never, either always rebuild the model reference target or never rebuild the target, respectively. The other two options, If any changes detected and If any changes in known dependencies detected, cause Simulink to check the model and its dependencies to determine whether or not to rebuild the model reference target. As part of this checking, Simulink:

  • Automatically identifies a set of "known" target dependencies that it examines for changes.

  • May compute the model's structural checksum, which reflects changes to the model that can affect simulation results.

For additional background information to help you determine which rebuild option setting to use, see the "Definitions" and "Tips" sections.

Settings

Default: If any changes detected

Always

Always rebuild targets referenced by this model before simulating, updating, or generating code from this model.

If any changes detected

Rebuild a target for a referenced model if Simulink detects a change that could affect simulation results. To do this, Simulink first looks for changes to the target dependencies and to the model, and, if none are found, it then computes the structural checksum of the model to check that the model reference target is up to date.

If any changes in known dependencies detected

Rebuild a target if Simulink detects a change in target dependencies or in both the model and its structural checksum. If Simulink does not detect a change in target dependencies or the model, it does not compute the structural checksum of the model and does not rebuild the model reference target. You must list all user-created dependencies in the Configuration Parameters > Model Referencing > Model dependencies parameter.

Never

Never rebuild targets referenced by this model before simulating, updating, or generating code from this model.

Definitions

Known target dependencies

Known target dependencies are files and data outside of model files that Simulink examines for changes when checking to see if a model reference target is up to date. Simulink automatically computes a set of known target dependencies. Simulink examines the known target dependencies to determine whether they have changed, which it can do quickly. Examples of known target dependencies are:

  • Changes to the model workspace, if its data source is a MAT-file or MATLAB® file

  • Enumerated type definitions

  • User-written S-functions and their TLC files

  • Files specified in the Model dependencies parameter

  • External files used by Stateflow®, a MATLAB Function block, or a MATLAB System block

Potential target dependencies

Potential dependencies are files and data outside of model files, as well as model configuration settings, that Simulink examines for changes when checking to see if a model reference target is up to date. Simulink automatically computes the set of potential dependencies. Simulink examines the potential dependencies, which it can do quickly. Examples of potential dependencies are:

  • Changes to global variables

  • Changes to the Configuration Parameters > Code Generation > Generate code only parameter

  • Changes to targets of models referenced by this model

  • The Configuration Parameters > Diagnostics > Data Validity > Signal resolution parameter is set to a value other than Explicit only.

Simulink examines each potential target dependency to determine whether that the state of that dependency is a trigger for causing a structural checksum check.

User-created dependencies

Although Simulink automatically examines every known target dependency, you can have files that can impact the simulation results of your model that Simulink does not automatically identify. Some examples of user-created dependencies are:

  • MATLAB files that contain code executed by callbacks

  • MAT-files that contain definitions for variables used by the model that are loaded as part of a customized initialization script

You can add user-created dependencies to the set of known target dependencies by using the Model dependencies parameter.

Structural checksum

As part of determining whether a model reference target is up to date, Simulink may compute the structural checksum of a model, which reflects changes to the model that can affect simulation results.

When Simulink computes the structural checksum, it loads and compiles the model. To compile the model, Simulink must execute callbacks and access all variables that the model uses. As a result, the structural checksum reflects changes to the model that can affect simulation results, including changes in user-created dependencies, regardless of whether you have specified those user-created dependencies in the Model dependencies parameter.

For more information about the kinds of changes that affect the structural checksum, see the Simulink.BlockDiagram.getChecksum documentation.

Tips

  • You do not need to have the same rebuild option setting for every model in a model reference hierarchy. When you simulate, update, or generate code for a model, the rebuild option setting for that model applies to all models that it references.

  • To improve rebuild detection speed and accuracy, use the Model dependencies parameter to specify user-created dependencies. If you use the If any changes in known dependencies detected rebuild option, then specify all user-created dependencies for your model in the Model dependencies parameter.

  • Each rebuild option setting has benefits and limitations, depending on your rebuild goal. The following table lists the options in the order of the thoroughness of rebuild detection. For detailed information about how Simulink determines whether a model reference target is out of date, see the Change Detection Processing table, which is part of the next tip.

    Benefits and Limitations of Each Option

    Rebuild GoalRebuild Option SettingNotes

    Make all the model reference targets up to date.

    Always

    Requires the most processing time.

    Can trigger unnecessary builds before simulating, updating, or generating code from a referenced model.

    Before you deploy a model, use the Always setting.

    Perform extensive detection of changes to dependencies of the referenced models.

    If any changes detected

    Default.

    Reduces the number of rebuilds, compared to the Always setting.

    Detects changes in the dependencies of the target, as well as changes in the structural checksum of the referenced model.

    The structural checksum can detect changes that occur in user-created dependencies that are not specified with the Model dependencies parameter.

    Reduce time required for rebuild detection.

    If any changes in known dependencies detected

    Reduces the number of rebuilds, compared to the If any changes detected option. Ignores cosmetic changes, such as annotation changes, in the referenced model and its libraries.

    Subset of the checks performed by the If any changes detected option.

    Invalid simulation results may occur if you do not specify with the Model dependencies parameter every user-created dependency.

    Avoid rebuilds during model development.

    Never

    Least amount of processing time, but requires that you ensure that the model reference targets are up to date.

    If you are certain that the model reference targets are up to date, you can use this option to avoid target dependency checking when simulating, updating, or generating code from a model.

    May lead to invalid results if referenced model targets are not in fact up to date.

    To have Simulink check for changes in known target dependencies and report if the model reference targets may be out of date, use the Never rebuild diagnostic parameter.

    To manually rebuild model reference targets, use the slbuild function.

  • To detect whether to perform a rebuild, Simulink uses different processing for each Rebuild setting. The following table summarizes the main types of change detection checks that Simulink performs.

    Change Detection Processing

    Rebuild Option SettingSimulink Change Detection Processing

    Always

    Does no change detection processing.

    Always rebuilds targets referenced by this model before simulating, updating, or generating code from this model.

    If any changes detected

    and

    If any changes in known dependencies detected

    See the flow chart, below.

    Never

    Change detection processing determined by the Never rebuild diagnostic parameter.

    The following flow chart describes the processing Simulink performs when you set Rebuild to either If any changes detected or If any changes in known dependencies detected. The "Compare Checksum" boxes indicate that Simulink detects whether the structural checksum has changed. If the structural checksum has changed, then Simulink performs a rebuild.

  • The following examples illustrate differences between the If any changes detected and If any changes in known dependencies detected options.

    If you change a MATLAB file that is executed as part of a callback script (or other user-created dependency) that you have not listed in the Model dependencies parameter:

    • If any changes detected – Causes a rebuild, because the change to the file changes the structural checksum of the model.

    • If any changes in known dependencies detected – Does not cause a rebuild, because no known target dependency has changed.

    If you move a block in a model:

    • If any changes detected – Causes a rebuild, because the model has changed.

    • If any changes in known dependencies detected – Does not cause a rebuild, because this change does not change the model's structural checksum.

Dependency

Selecting Never enables the Never rebuild diagnostic parameter.

Command-Line Information

Parameter: UpdateModelReferenceTargets
Type: string
Value: 'Force' | 'IfOutOfDateOrStructuralChange' | 'IfOutOfDate' | 'AssumeUpToDate'
Default: 'IfOutOfDateOrStructuralChange'
UpdateModelReferenceTargets ValueEquivalent Rebuild Value
'Force'Always
'IfOutOfDateOrStructuralChange'If any changes detected
'IfOutOfDate'If any changes in known dependencies detected
'AssumeUpToDate'Never

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precaution

If any changes detected or Never

If you use the Never setting, then set the Never rebuild diagnostic parameter to Error if rebuild required.

See Also

Never rebuild diagnostic

Select the diagnostic action that Simulink software should take if it detects a model reference target that needs to be rebuilt.

Settings

Default: Error if rebuild required

none

Simulink takes no action.

Warn if rebuild required

Simulink displays a warning.

Error if rebuild required

Simulink terminates the simulation and displays an error message.

Tip

If you set the Rebuild parameter to Never and set the Never rebuild diagnostic parameter to Error if rebuild required or Warn if rebuild required, then Simulink:

  • Performs the same change detection processing as for the If any changes in known dependencies detected rebuild option setting, except it does not compare structural checksums

  • Issues an error or warning (depending on the Never rebuild diagnostic setting), if it detects a change

  • Never rebuilds the model reference target

Selecting None bypasses dependency checking, and thus enables faster updating, simulation, and code generation. However, the None setting can cause models that are not up to date to malfunction or generate incorrect results. For more information on the dependency checking, see Rebuild.

Dependency

This parameter is enabled only if you select Never in the Rebuild field.

Command-Line Information

Parameter: CheckModelReferenceTargetMessage
Type: string
Value: 'none' | 'warning' | 'error'
Default: 'error'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionError if rebuild required

See Also

Enable parallel model reference builds

Specify whether to use automatic parallel building of the model reference hierarchy whenever possible.

Settings

Default: Off

On

Simulink software builds the model reference hierarchy in parallel whenever possible (based on computing resources and the structure of the model reference hierarchy).

Off

Simulink never builds the model reference hierarchy in parallel.

Dependency

Selecting this option enables the MATLAB worker initialization for builds parameter.

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

MATLAB worker initialization for builds

Specify how to initialize MATLAB workers for parallel builds.

Settings

Default: None

None

Simulink software takes no action. Specify this value if the child models in the model reference hierarchy do not rely on anything in the base workspace beyond what they explicitly set up (for example, with a model load function).

Copy base workspace

Simulink attempts to copy the base workspace to each MATLAB worker. Specify this value if you use a setup script to prepare the base workspace for all models to use.

Load top model

Simulink loads the top model on each MATLAB worker. Specify this value if the top model in the model reference hierarchy handles all of the base workspace setup (for example, with a model load function).

Limitation

For values other than None, limitations apply to global variables in the base workspace. Global variables are not propagated across parallel workers and do not reflect changes made by top and child model scripts.

Dependency

Selecting the option Enable parallel model reference builds enables this parameter.

Command-Line Information

Parameter: ParallelModelReferenceMATLABWorkerInit
Type: string
Value: 'None' | 'Copy Base Workspace' | 'Load Top Model'
Default: 'None'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Total number of instances allowed per top model

Specify how many references to this model can occur in another model.

Settings

Default: Multiple

Zero

The model cannot be referenced. An error occurs if a reference to the model occurs in another model.

One

The model can be referenced at most once in a model reference hierarchy. An error occurs if more than one reference exists.

Multiple

The model can be referenced more than once in a hierarchy, provided that it contains no constructs that preclude multiple reference. An error occurs if the model cannot be multiply referenced, even if only one reference exists.

To use multiple instances of a referenced model in Normal mode, use the Multiple setting. For details, see Using Normal Mode for Multiple Instances of Referenced Models.

Command-Line Information

Parameter: ModelReferenceNumInstancesAllowed
Type: string
Value: 'Zero' | 'Single' | 'Multi'
Default: 'Multi'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

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

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

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 Reusable Code and Referenced ModelsReusable Code and Referenced Models 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
Type: string
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 precautionOff

See Also

Minimize algebraic loop occurrences

Try to eliminate artificial algebraic loops from a model that involve the current referenced model

Settings

Default: Off

On

Simulink software tries to eliminate artificial algebraic loops from a model that involve the current referenced model.

Off

Simulink software does not try to eliminate artificial algebraic loops from a model that involve the current referenced model.

Tips

Enabling this parameter together with the Simulink Coder Single output/update function parameter results in an error.

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionOff

See Also

Propagate all signal labels out of the model

Pass propagated signal names to output signals of Model block.

Settings

Default: Off

On

Simulink propagates signal names to output signals of the Model block.

Off

Simulink does not propagate signal names to output signals of the Model block.

Tips

  • Enable this parameter for each instance of a referenced model for which you want to propagate signal labels.

  • The following models illustrate the default behavior, when signal label propagation is enabled for every eligible signal. Inside the referenced model, signal label propagation occurs as in any model. However, the output signal from the Model block Out2 port displays empty brackets for the propagated signal label.

  • The following models illustrate the behavior when you enable the Propagate all signal labels out of the model parameter for the referenced model. The output signal from the Model block Out2 port displays the propagated signal name (Chirp_sig), whose source is inside the referenced model.

Command-Line Information

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

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionOff

See Also

Propagate sizes of variable-size signals

Select how variable-size signals propagate through referenced models.

Settings

Default: Infer from blocks in model

Infer from blocks in model

Searches a referenced model and groups blocks into the following categories.

CategoryDescriptionExample Blocks in This Category
1Output signal size depends on input signal values.Switch or Enable Subsystem block whose parameter Propagate sizes of variable-size signals is set to During execution
2States require resetting when the input signal size changes.Unit Delay block in an Enabled Subsystem whose parameter Propagate sizes of variable-size signals is set to Only when enabling
3Output signal size depends only on the input signal size.Gain block.

The search stops at the boundary of Enable, Function-Call, and Action subsystems because these subsystems can specify when to propagate the size of a variable-size signal.

Simulink sets the propagation of variable-size signals for a referenced model as follows:

  • One or more blocks in category 1, and all other blocks are in category 3, select During execution.

  • One or more blocks in category 2, and all another blocks are in category 3, select Only when enabling.

  • Blocks in category 1 and 2, report an error.

  • All blocks in category 3 with a conditionally executed subsystem that is not an Enable, Function-Call, or Action subsystem, report an error. Simulink, in this case, cannot determine when to propagate sizes of variable-size signals.

  • All blocks in category 3 with only conditionally executed subsystems that are an Enable, Function-Call, or Action subsystem, support both Only with enabling and During execution.

Only when enabling

Propagates sizes of variable-size signals for the referenced model only when enabling (at Enable method).

During execution

Propagates sizes of variable-size signals for the referenced model during execution (at Outputs method).

Command-Line Information

Parameter: PropagateVarSize
Type: string
Value: 'Infer from blocks in model' | 'Only when enabling'| 'During execution'
Default: 'Infer from blocks in model'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Model dependencies

Although Simulink automatically examines every known target dependency, you can have files that can impact the simulation results of your model that Simulink does not automatically identify. Some examples of user-created dependencies are:

  • MATLAB files that contain code executed by callbacks

  • MAT-files that contain definitions for variables used by the model that are loaded as part of a customized initialization script

You can add user-created dependencies to the set of known target dependencies by using the Model dependencies parameter.

Simulink examines the files specified with the Model dependencies parameter when determining whether the model reference target is up to date. If the Rebuild parameter is set to:

  • Always, then the listed files are not examined.

  • Either If any changes detected or If any changes in known dependencies detected, then changes to listed files cause the model reference target to rebuild.

  • Never, and the Never rebuild diagnostic parameter is set to either Warn if rebuild required or Error if rebuild required, then changes to listed files cause Simulink to report a warning or error.

Settings

Default: ''

  • Specify the dependencies as a cell array of strings, where each cell array entry is one of the following:

    • File name — Simulink looks on the MATLAB path for a file with the given name. If the file is not on the MATLAB path, then specify the path to the dependent file, as described below.

    • Path to the dependent file — The path can be relative or absolute, and must include the file name.

    • Folder — Simulink treats every file in that folder as a dependent file. Simulink does not include files of subfolders of the folder you specify.

  • File names must include a file extensions (for example, .m or .mat)

  • File names and paths can include spaces.

  • You can use the following characters in the strings:

    • The token $MDL, as a prefix to a dependency to indicate that the path to the dependency is relative to the location of this model file

    • An asterisk (*), as a wild card

    • A percent sign (%), to comment out a line

    • An ellipsis (...), to continue a line

    For example:

    {'D:\Work\parameters.mat', '$MDL\mdlvars.mat', ...
    'D:\Work\masks\*.m'}
    

Tips

  • To improve rebuild detection speed and accuracy, use the Model dependencies parameter to specify model dependencies other than those that Simulink checks automatically as part of the its rebuild detection. For details, see the Rebuild parameter documentation.

  • If the Rebuild setting is If any changes in known dependencies detected, to prevent invalid simulation results, add every user-created dependency (for example, MATLAB code files or MAT-files).

  • Using the Simulink Manifest Tools can help you to identify model dependencies. For more information, see Analyze Model Dependencies.

  • If Simulink cannot find a specified dependent file when you update or simulate a model that references this model, Simulink displays a warning.

  • The dependencies automatically include the model and linked library files, so you do not need to specify those files with the Model dependencies parameter.

Command-Line Information

Parameter: ModelDependencies
Type: string
Value: any valid value
Default: ''

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Was this topic helpful?