Documentation

Simulate Model Referencing Models

Simulating a model that uses model referencing differs in some ways from simulating a standalone model that does not use model referencing.

Simulate a Top Model

Simulink® executes the top model in a model reference hierarchy the same way that it executes models without model referencing. All the Simulink simulation modes are available to the top model. To achieve faster execution of a top model in a model reference hierarchy, you can use Simulink accelerator mode or rapid accelerator mode. For details about accelerator mode, see the Acceleration documentation. For information about rapid accelerator mode, see Accelerate, Refine, and Test Hybrid Dynamic System on Host Computer by Using RSim System Target File.

When you execute a top model in Simulink accelerator mode or rapid accelerator mode, all referenced models execute in accelerator mode.

Simulate a Referenced Model

You can simulate a referenced model in one of these modes:

  • Normal

  • Accelerator

  • Software-in-the-loop (SIL)

  • Processor-in-the-loop (PIL)

For more information about using these simulation modes for referenced models, see Comparison of Simulation Modes for Referenced Models.

The simulation modes used for referenced models depend on the simulation mode of the parent model. For details, see Parent and Referenced Model Simulation Modes.

Specify the Simulation Mode for Referenced Models

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

  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.

Comparison of Simulation Modes for Referenced Models

You can use rapid accelerator mode for the top model in a model reference hierarchy, but not for referenced models.

The different simulation modes for referenced models share many capabilities and techniques, but they have different implementations, requirements, and limitations.

Simulation ModeDescriptionWhen to Use
NormalExecutes referenced model interpretively.

Simulink executes a normal mode referenced model interpretively. Compared to other simulation modes, normal mode:

  • Executes more slowly.

  • Requires no delay for code generation or compilation.

  • Works with more Simulink and Stateflow® tools, supporting tools such as:

    • Scopes, port value display, and other output viewing tools.

    • Model coverage analysis.

    • Stateflow debugging and animation.

  • Provides more accurate linearization analysis.

  • Supports more S-functions than accelerator mode does.

You can use normal mode with multiple instances of a referenced model. For details, see Simulate Models with Multiple Referenced Model Instances.

Accelerator

Executes the referenced model by creating a MEX-file (a simulation target) for the referenced model, then running the MEX-file.

For more information, see Model Referencing Simulation Targets.

  • Executes faster than normal mode.

  • Takes time for code generation and code compilation.

  • Does not fully support some Simulink tools, such as Model Coverage and the Simulink Debugger.

  • Supports Scope blocks, but requires using the Signal & Scope Manager and adding test points to signals. Adding or removing a test point requires rebuilding the SIM target for a model.

SIL

Executes referenced model by generating production code. This code is compiled for, and executed on, the host platform.

Requires Embedded Coder® software. For more information, see SIL and PIL Limitations and Numerical Equivalence Testing in the Embedded Coder documentation.

  • Verifies generated source code without modifying the original model.

  • Supports the reuse of test harnesses for the original model with the generated source code.

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

PIL

Executes referenced model by generating production code. This code is cross-compiled for, and executed on, a target processor or an equivalent instruction set simulator.

Requires Embedded Coder software. For more information, see SIL and PIL Limitations and Numerical Equivalence Testing in the Embedded Coder documentation.

  • Verifies deployment object code on target processors without modifying the original model.

  • Supports the reuse of test harnesses for the original model with the generated source code.

    Note:   Simulation results for a given model are nearly identical in normal and accelerator modes. Trivial differences can occur, depending on differences in the optimizations and libraries that you use.

Parent and Referenced Model Simulation Modes

The simulation modes you can use for a referenced model depends on the simulation mode of its parent model.

Parent Model Simulation ModeReferenced Model Simulation Modes
Normal
  • Referenced models can use normal, accelerator, SIL, or PIL mode.

  • If every model that is superior to a referenced model in the model reference hierarchy also executes in normal mode, that referenced model can execute in normal mode.

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

  • When a normal mode model is subordinate to an accelerator mode model, Simulink returns 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
  • If their simulation modes are normal, accelerator, or SIL, all subordinate models also execute in SIL mode. Otherwise, an error occurs. See Simulation Mode Override Behavior in Model Reference Hierarchy.

  • Multiple Model blocks, starting at the top of a model reference hierarchy, can execute in SIL mode. However, during code coverage or code execution profile, only one Model block can execute at a time in SIL mode.

PIL

Related Examples

More About

Was this topic helpful?