Choose Simulation Modes for Model Hierarchies

When you simulate a model hierarchy, you should consider how top models and referenced models execute.

  • Top model — Supports all Simulink® simulation modes. To speed up execution of a top model, you can use Simulink accelerator or rapid accelerator mode.

  • Referenced model — Although you can specify any simulation mode for a model, when you reference that model, the Model block for each instance of the referenced model controls the simulation mode of the instance. The simulation mode of a parent model can override the simulation mode of a Model block.

For information on simulation modes, see Choosing a Simulation Mode and How Acceleration Modes Work.

Model Reference Simulation Modes

You can specify any of these simulation modes for a Model block:

  • Normal

  • Accelerator

  • Software-in-the-loop (SIL) — requires Embedded Coder®

  • Processor-in-the-loop (PIL) — requires Embedded Coder

When you choose between normal and accelerator mode, you must make a tradeoff between flexibility and speed. Normal mode supports more Simulink and Stateflow® features in referenced models, such as scopes, port value display, and debugging tools. Accelerator mode supports fewer features in referenced models, but simulates model hierarchies faster.

Modeling RequirementNormal ModeAccelerator Mode
Simulation speed

Models execute slower in normal mode than accelerator mode. However, referenced models that execute in normal mode do not delay simulation to build and compile simulation targets because normal mode executes referenced models interpretively.

Models execute faster in accelerator mode than normal mode. Before simulating the model, Simulink must build and compile simulation targets, which can be undesirable for prototyping. For more information, see Model Reference Simulation Targets.

Debugging

With the Simulink Debugger, you can set a breakpoint inside a referenced model that executes in normal mode. For more information, see Simulink Debugger.

With the Simulink Profiler, you can enable profiling for a referenced model that executes in normal mode. Enabling profiling on a parent model does not enable profiling for referenced models. See How Profiler Captures Performance Data.

For referenced models that execute in accelerator mode, specifications made and actions taken by the Simulink Debugger and Simulink Profiler are ignored.

Testing

Simulink Coverage™ model coverage analysis supports referenced models that execute in normal mode.

Simulink Coverage model coverage analysis ignores referenced models that execute in accelerator mode.

Tunability

You can tune block parameters during simulation for referenced models that execute in normal mode.

If a referenced model that executes in accelerator mode uses variables in the base workspace or a data dictionary to set parameter values, you can tune the values of those variables. For more information see Tunability Considerations and Limitations for Other Modeling Goals.

Data logging

Data logging provides extensive support for referenced models that execute in normal mode.

For referenced models that execute in accelerator mode, To Workspace blocks log data only if they use the Timeseries format for saving.

Data visualization

You can view instance-specific simulation results with the Simulation Data Inspector.

These visualization methods show data for only one instance of a referenced model that executes in normal mode.

  • Scope, Floating Scope, and Scope Viewer blocks in the referenced model

  • Runtime displays, such as port values

For more information, see Simulate Multiple Referenced Model Instances in Normal Mode.

You can view instance-specific simulation results with the Simulation Data Inspector.

These visualization methods show no data for referenced models that execute in accelerator mode.

  • Scope, Floating Scope, and Scope Viewer blocks in the referenced model

  • Runtime displays, such as port values

Top model Scope blocks can display data for referenced models that execute in accelerator mode if you use the Signal & Scope Manager to add test points in the referenced model. Adding or removing a test point requires rebuilding the model reference simulation target for a model.

Diagnostics

Configuration parameter settings are applied as specified.

For models referenced in accelerator mode, Simulink can ignore some configuration parameter settings. For details, see Diagnostics That Are Ignored in Accelerator Mode.

Runtime checks

Runtime checks are enabled.

Some blocks include runtime checks that are disabled when you include the block in a referenced model in accelerator mode. Examples of these blocks include Assignment, Selector, MATLAB Function, and MATLAB System blocks.

Simulating dirty modelsYou can use unsaved models when they are referenced in normal mode.When you create a model, you cannot use that model as an accelerator mode referenced model until you have saved the model to disk.
Linearization analysis and optimization

Normal mode allows block-by-block linearization of a referenced model, which achieves an accurate linearization.

In accelerator mode, discrete states of model references are not exposed to linearization. These discrete states are not perturbed during linearization and, therefore, are not truly free in the trimming process.

The outputs of random blocks are not kept constant during trimming. Outputs that are not kept constant can affect the optimization process.

Extrinsic functions

A MATLAB Function block in a referenced model that executes in normal mode can call MATLAB® functions that are declared extrinsic for code generation.

A MATLAB Function block in a referenced model that executes in accelerator mode cannot call MATLAB functions that are declared extrinsic for code generation.

S-Functions

Referenced models that execute in normal mode support more S-functions than referenced models that execute in accelerator mode. For more information see, S-Functions in Referenced Models.

Referenced models that execute in accelerator mode support fewer S-functions than referenced models that execute in normal mode. For more information see, S-Functions in Referenced Models.

SIL and PIL simulation modes execute referenced models by generating production code for embedded processors. SIL mode provides a convenient alternative to PIL simulation because it can run on a host platform when the target hardware is not available. For more information, see SIL and PIL Simulations (Embedded Coder).

Overridden Simulation Modes

The simulation mode of the parent model can override the simulation mode of a Model block. This table shows which simulation mode Simulink uses for a referenced model instance based on the simulation mode of the parent model and related Model block.

Simulation Mode Used by Parent ModelSimulation Mode of Model Block
NormalAccelerator
Normal

Compatible — Referenced model simulates in normal mode.

Compatible — Referenced model simulates in accelerator mode.

Accelerator

Overridden — Referenced model simulates in accelerator mode.

Compatible — Referenced model simulates in accelerator mode.

Rapid accelerator (top model only)

For information on SIL and PIL, see Simulation Mode Override Behavior in Model Reference Hierarchy (Embedded Coder).

Related Topics