Main Content

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, theModelblock 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 aModelblock.

For information on simulation modes, seeChoosing a Simulation ModeandHow Acceleration Modes Work.

For information on selecting solvers for models in a model hierarchy, seeSet Configuration Parameters for Model Hierarchies.

Model Reference Simulation Modes

You can specify any of these simulation modes for aModelblock:

  • 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 Requirement Normal Mode Accelerator 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, seeManage Simulation Targets for Referenced Models.

Debugging

With the Simulink Debugger, you can set a breakpoint inside a referenced model that executes in normal mode. For more information, seeSimulink 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. SeeHow 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覆盖率分析模型忽略了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 seeTunability 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 Workspaceblocks log data only if they use theTimeseriesformat for saving.

Data visualization

You can view simulation results for all instances of the referenced model with theSimulation Data Inspector.

You can view instance-specific simulation results for each instance withDisplayblocks in the referenced model.

Scopes and port value labels display data for only the instance of the referenced model that has normal mode visibility enabled. For more information, seeSimulate Multiple Referenced Model Instances in Normal Mode.

You can view simulation results for all instances of the referenced model with the Simulation Data Inspector.

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

  • Scope,Floating Scope, andScope Viewerblocks in the referenced model

  • Runtime displays, such as port value labels

Top modelScopeblocks 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, seeDiagnostics 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 includeAssignment,Selector,MATLAB Function, andMATLAB Systemblocks.

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

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

AMATLAB Functionblock 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, seeSIL and PIL Simulations(Embedded Coder).

Overridden Simulation Modes

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

Simulation Mode Used by Parent Model Simulation Mode of Model Block
Normal Accelerator
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, seeSimulation Mode Override Behavior in Model Reference Hierarchy(Embedded Coder).

Related Topics