主要内容

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®仿真模式。为了加快顶级模型的执行,您可以使用simulink加速器或快速加速器模式。金宝app

  • Referenced model — Although you can specify any simulation mode for a model, when you reference that model, the模型引用模型的每个实例的块控制实例的仿真模式。父模型的仿真模式可以覆盖A的仿真模式模型堵塞。

有关模拟模式的信息,请参阅Choosing a Simulation Mode加速模式如何工作.

有关在模型层次结构中选择求解器的信息,请参见设置模型层次结构的配置参数.

模型Reference Simulation Modes

您可以为模型block:

  • Normal

  • 加速器

  • 循环软件(SIL) - 需要嵌入式编码器®

  • 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.

模型ing Requirement 正常模式 加速器Mode
模拟速度

模型在正常模式下执行比加速器模式慢。但是,在正常模式下执行的引用模型不会延迟模拟以构建和编译模拟目标,因为正常模式解释性地执行了引用模型。

模型s 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.

调试

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. See牧师如何捕获性能数据.

对于在加速器模式下执行的引用模型,specifications made and actions taken by the Simulink Debugger and Simulink Profiler are ignored.

测试

金宝appSimulink覆盖范围™模型覆盖分析支持在正常模式下执行的引用模型。金宝app

金宝appSimulink覆盖范围覆盖率分析模型忽略了参考模型that execute in accelerator mode.

Tunability

您可以在模拟过程中调整块参数,以获取在正常模式下执行的引用模型。

对于在加速器模式下执行的引用模型,如果引用模型使用基本工作区中的变量或数据字典来设置参数值,则可以调整变量的值。在模拟过程中,您不能在引用模型中调整块参数。有关更多信息,请参阅Tunability Considerations and Limitations for Other Modeling Goals.

Data logging

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

对于在加速器模式下执行的引用模型,到工作区仅在使用该数据时,只有在使用Timeseries保存格式。

数据可视化

您可以使用带有参考模型的所有实例查看模拟结果Simulation Data Inspector.

您可以查看每个实例的实例特定仿真结果Display引用模型中的块.

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.

您可以使用带有参考模型的所有实例查看模拟结果Simulation Data Inspector.

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

  • Scope,浮动范围, 和范围查看器引用模型中的块

  • 运行时显示,例如端口值标签

Top modelScopeblocks can display data for referenced models that execute in accelerator mode if you use the Viewers & Generators 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.

对于以加速器模式引用的模型,Simulink可以忽略某些配置参数设置。金宝app有关详细信息,请参阅Diagnostics That Are Ignored in Accelerator Mode.

Runtime checks

运行时检查已启用。

一些块包括在加速器模式下以引用模型中的块中包含块时禁用的运行时检查。这些块的示例包括任务,选择器,MATLAB功能, 和MATLABSystem块。

线性化分析和优化

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

在加速器模式下,模型参考的离散状态不暴露于线性化。这些离散状态在线性化过程中不会受到干扰,因此在修剪过程中并非真正自由。

在修剪过程中,随机块的输出不会保持恒定。不恒定的输出会影响优化过程。

外部功能

AMATLAB功能在正常模式下执行的引用模型中的块可以调用MATLAB®functions that are declared extrinsic for code generation.

AMATLAB功能在加速器模式下执行的引用模型中的块无法调用被声明为代码生成外部的MATLAB函数。

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功能.

在加速器模式下执行的引用模型比在正常模式下执行的引用模型支持更少的S函数。金宝app有关更多信息,请参见引用模型中的s功能.

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

父模型的仿真模式可以覆盖A的仿真模式模型堵塞。该表显示了基于父模型的仿真模式和相关的模拟模式使用哪种模拟模式模拟模型实例金宝app模型堵塞。

父模型使用的仿真模式 模型块的仿真模式
Normal 加速器
Normal

兼容 - 引用模型在正常模式下模拟。

Compatible — Referenced model simulates in accelerator mode.

加速器

覆盖 - 引用模型在加速器模式下模拟。

Compatible — Referenced model simulates in accelerator mode.

Rapid accelerator(top model only)

有关SIL和PIL的信息,请参阅Simulation Mode Override Behavior in Model Reference Hierarchy(Embedded Coder).

相关话题