Skip to Main Content Skip to Search
Product Documentation

Referenced Model Simulation Modes

About Referenced Model Simulation Modes

Simulink executes the top model in a model reference hierarchy just as it would if no referenced models existed. All Simulink simulation modes are available to the top model. Simulink can execute a referenced model in any of four modes: Normal, Accelerator, Software-in-the-loop (SIL), or Processor-in-the-loop (PIL).

Normal Mode

Simulink executes a Normal mode submodel interpretively. Normal mode, compared to other simulation modes:

Normal mode executes slower than Accelerator mode does.

Simulation results for a given model are nearly the same in either Normal or Accelerator mode. Trivial differences can occur due to differences in the optimizations and libraries that you use.

You can use Normal mode with multiple instances of a referenced model. For details, see Using Normal Mode for Multiple Instances of Referenced Models.

Accelerator Mode

Simulink executes an Accelerator mode submodel by creating a MEX-file (or simulation target) for the submodel, then running the MEX-file. See Model Reference Simulation Targets for more information. Accelerator mode:

Simulation results for a given model are nearly identical in either Normal or Accelerator mode. Trivial differences can occur due to differences in the optimizations and libraries that you use.

Software-in-the-Loop (SIL) Mode

Simulink executes a SIL-mode referenced model by generating production code using the model reference target for the submodel. This code is compiled for, and executed on, the host platform.

With SIL mode, you can:

SIL mode provides a convenient alternative to PIL simulation when the target hardware is not available.

This option requires Embedded Coder software.

For more information, see Numerical Equivalence Checking in the Embedded Coder documentation.

Processor-in-the-Loop (PIL) Mode

Simulink executes a PIL-mode referenced model by generating production code using the model reference target for the submodel. This code is cross-compiled for, and executed on, a target processor or an equivalent instruction set simulator.

With PIL mode, you can:

This option requires Embedded Coder software.

For more information, see Numerical Equivalence Checking in the Embedded Coder documentation.

Specifying the Simulation Mode

The Model block for each instance of a referenced model controls its simulation mode. To set or change the simulation mode for a submodel:

  1. Access the block parameter dialog box for the Model block. (See Navigating a Model Block.)

  2. Set the Simulation mode parameter.

  3. Click OK or Apply.

Mixing Simulation Modes

The following table summarizes the relationship between the simulation mode of the parent model and its submodels.

Parent Model Simulation ModeSubmodel Simulation Modes
Normal
  • Submodels can use Normal, Accelerator, SIL, or PIL mode.

  • A submodel can execute in Normal mode only if every model that is superior to it in the hierarchy also executes in Normal mode. A Normal mode path then extends from the top model through the model reference hierarchy down to the Normal mode submodel.

Accelerator
  • All subordinate models must also execute in Accelerator mode.

  • When a Normal mode model is subordinate to an Accelerator mode model, Simulink posts a warning and temporarily overrides the Normal mode specification.

  • When a SIL-mode or PIL-mode model is subordinate to an Accelerator mode model, an error occurs.

SIL
  • All subordinate models also execute in SIL mode regardless of the simulation mode specified by their Model blocks.

  • The SIL mode Model block uses the model reference targets of the blocks beneath.

  • Only one Model block, starting at the top of a model reference hierarchy, can execute at a time in SIL mode. See Simulation Mode Override Behavior in Model Reference Hierarchy.

PIL
  • All subordinate models also execute in PIL mode regardless of the simulation mode specified by their Model blocks.

  • The PIL mode Model block uses the model reference targets of the blocks beneath.

  • Only one Model block, starting at the top of a model reference hierarchy, can execute at a time in PIL mode. See Simulation Mode Override Behavior in Model Reference Hierarchy.

For more information about SIL and PIL modes, see in the Embedded Coder documentation:

Using Normal Mode for Multiple Instances of Referenced Models

You can simulate a model that has multiple references in Normal mode.

Normal Mode Visibility

All instances of a Normal mode referenced model are part of the simulation. However, Simulink displays only one instance in a model window; that instance is determined by the Normal Mode Visibility setting. Normal mode visibility includes the display of Scope blocks and data port values.

If you do not set Normal Mode Visibility, Simulink picks one instance of each Normal mode model to display.

After a simulation, if you try to open a referenced model from a Model block that has Normal Mode Visibility set to off, Simulink displays a warning.

For a description of how to set up your model to control which instance of a referenced model in Normal mode has visibility and to ensure proper simulation of the model, see Specifying the Instance That Has Normal Mode Visibility.

Examples of a Model with Multiple Referenced Instances in Normal Mode

sldemo_mdlref_basic.  The sldemo_mdlref_basic demo model has three Model blocks (CounterA, CounterB, and CounterC) that each reference the sldemo_mdlref_counter model.

If you update the diagram, the sldemo_mdlref_basic displays different icons for each of the three Model blocks that reference sldemo_mdlref_counter.

Model BlockIcon CornersSimulation Mode and Normal Mode Visibility Setting
CounterAWhite Normal mode, with Normal Mode Visibility enabled
CounterBGray cornersNormal mode, with Normal Mode Visibility disabled
CounterCBlack cornerAccelerator mode (Normal Mode Visibility is not applicable)

If you do the following steps, then the ScopeA block appears as shown below:

  1. Simulate sldemo_mdlref_basic.

  2. Open the sldemo_mdlref_counter model.

  3. Open the ScopeA block.

That ScopeA block reflects the results of simulating the CounterA Model block, which has Normal Mode Visibility enabled.

If you try to open mdlref_counter model from the CounterB Model block (for example, by double-clicking the Model block), ScopeA in mdlref_counter still shows the results of the CounterA Model block, because that is the Model block with Normal Mode Visibility set to on.

sldemo_mdlref_depgraph.  The sldemo_mdlref_depgraph demo model shows the use of the Model Dependency Viewer for a model that has multiple Normal mode instances of a referenced model. The demo shows what you need to do to set up a model with multiple referenced instances in Normal mode.

Setting Up a Model with Multiple Instances of a Referenced Model in Normal Mode

This section describes how to set up a model to support the use of multiple instances of Normal mode referenced models.

  1. Set the Configuration Parameters > Model Referencing > Total number of instances allowed per top model parameter to Multiple.

    If you cannot use the Multiple setting for your model, because of the requirements described in the Total number of instances allowed per top model parameter documentation, then you can have only one instance of that referenced model be in Normal mode.

  2. For each instance of the referenced model that you want to be in Normal mode, in the block parameters dialog box for the Model block, set the Simulation Mode parameter to Normal. Ensure that all the ancestors in the hierarchy for that Model block are in Normal mode.

    The corners of icons for Model blocks that are in Normal mode can be white (empty), or gray after you update the diagram or simulate the model.

  3. (If necessary) Modify S-functions used by the model so that they work with multiple instances of referenced models in Normal mode. For details, see Supporting the Use of Multiple Instances of Referenced Models That Are in Normal Mode.

By default, Simulink assigns Normal mode visibility to one of the instances. After you have performed the steps in this section, you can specify a non-default instance to have Normal mode visibility. For details, see Specifying the Instance That Has Normal Mode Visibility.

Specifying the Instance That Has Normal Mode Visibility

This section describes how to specify Normal Mode Visibility for an instance other than the one that an instance that Simulink selects automatically.

You need to:

  1. (Optionally) Determine Which Instance Has Normal Mode Visibility.

  2. Set Normal Mode Visibility.

  3. Simulate the top model to apply the new Normal Mode Visibility settings.

Determine Which Instance Has Normal Mode Visibility.  If you do not already know which instance currently has Normal mode visibility, you can determine that by using one of these approaches:

Set Normal Mode Visibility.  To enable Normal Mode Visibility for a different instance of the referenced model than the instance that currently has Normal Mode Visibility, use one of these approaches:

Working with the Model Block Normal Mode Visibility Dialog Box

If you have a model that has multiple instances of a referenced model in Normal mode, you can use the Block Model Normal Mode Visibility dialog box to set Normal Mode Visibility for a specific instance. For a description of Normal mode visibility, see Normal Mode Visibility.

Alternatively, you can set the ModelReferenceNormalModeVisibility parameter. For information about how to specify an instance of a referenced model that is in Normal mode that is different than the instance automatically selected by Simulink, see Specifying the Instance That Has Normal Mode Visibility.

Opening the Model Block Normal Mode Visibility Dialog Box.  To open the Model Block Normal Mode Visibility dialog box, navigate to the top model and select the Edit > Links and Model Blocks > Normal Mode Visibility menu item.

The dialog box for the sldemo_mdlref_basic demo model, with the hierarchy pane expanded, looks like this:

The model hierarchy pane shows a partial model hierarchy for the model from which you opened the dialog box. The hierarchy stops at the first Model block that is not in Normal mode. The model hierarchy pane does not display Model blocks that reference protected models.

Selecting a Model for Normal Mode Visibility.  

The dialog box shows the complete model block hierarchy for the top model. The Normal mode instances of referenced models have check boxes. Select the check box for the instance of each model that you want to have Normal mode visibility.

When you select a model, Simulink:

When a model is deselected, Simulink deselects all children of that model.

Opening a Model from the Model Block Normal Mode Visibility Dialog Box.  You can open a model from the Model Block Normal Mode Visibility dialog box by right-clicking the model in the model hierarchy pane and clicking Open.

Refreshing the Model Reference Hierarchy.  To ensure the model hierarchy pane of the Model Block Normal Mode Visibility dialog box reflects the current model hierarchy, click Refresh.

Accelerating a Freestanding or Top Model

You can use Simulink Accelerator mode or Rapid Accelerator mode to achieve faster execution of any Simulink model, including a top model in a model reference hierarchy. For details about Accelerator mode, see the Accelerating Models documentation. For information about Rapid Accelerator mode, see Rapid Simulations.

When you execute a top model in Simulink Accelerator mode or Rapid Accelerator mode, all submodels execute in Accelerator mode. For any submodel that specifies Normal mode, Simulink displays an warning message.

Be careful not confuse Accelerator mode execution of a referenced model with:

While the different types of acceleration share many capabilities and techniques, they have different implementations, requirements, and limitations.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS