文档

选择模型层次结构的仿真模式

当您模拟模型层次结构时,您应该考虑如何执行顶级模型和引用模型。

  • 顶级模型 - 支持所有模金宝app拟金宝app®simulation modes. To speed up execution of a top model, you can use Simulink accelerator or rapid accelerator mode.

  • 引用模型 - 尽管您可以为模型指定任何模拟模式,但是当您引用该模型时,Modelblock 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 aModel堵塞。

For information on simulation modes, see选择模拟模式andHow Acceleration Modes Work

模型参考模拟模式

You can specify any of these simulation modes for aModel堵塞:

  • 普通的

  • 加速器

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

  • 循环处理器(PIL) - 需要嵌入式编码器

当您在普通和加速器模式之间进行选择时,必须在灵活性和速度之间进行权衡。正常模式支持更多模拟和状金宝app态流金宝app®引用模型中的功能,例如示波器,端口值显示和调试工具。加速器模式支持引用模型中的功能较少金宝app,但模拟模型层次结构更快。

建模要求 普通的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.

模型在加速器模式下执行比正常模式更快。在模拟模型之前,Simulink必须构建和编译模拟目标,这金宝app对于原型制作可能是不希望的。有关更多信息,请参阅Model Reference Simulation Targets

Debugging

使用Simulin金宝appk调试器,您可以在正常模式下执行的引用模型内设置断点。有关更多信息,请参阅金宝appSimulink调试器

使用Simulin金宝appk Profiler,您可以启用在正常模式下执行的引用模型的分析。在父模型上启用分析并不能为参考模型进行分析。看How Profiler Captures Performance Data

对于在加速器模式下执行的引用模型,忽略了Simulink调试器和Simulink Profiler采取的规格和操作。金宝app

Testing

金宝appSimulink Coverage™model coverage analysis supports referenced models that execute in normal mode.

Simulink Coverage模型覆盖分析忽略了在加速器模式下执行的引用模型。

可调性

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

如果在加速器模式下执行的引用模型使用基本工作区中的变量或数据字典来设置参数值,则可以调整这些变量的值。有关更多信息,请参见其他建模目标的可调性考虑因素和局限性

数据记录

数据记录为在正常模式下执行的引用模型提供了广泛的支持。金宝app

For referenced models that execute in accelerator mode,To Workspaceblocks log data only if they use the时间序列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.

  • 范围,,,,浮动范围,,,,and范围Viewerblocks in the referenced model

  • Runtime displays, such as port values

有关更多信息,请参阅在正常模式下模拟多个引用的模型实例

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

这些可视化方法没有显示在加速器模式下执行的引用模型的数据。

  • 范围,,,,浮动范围,,,,and范围Viewerblocks in the referenced model

  • Runtime displays, such as port values

超模范围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.

诊断

配置参数设置按指定应用。

For models referenced in accelerator mode, Simulink can ignore some configuration parameter settings. For details, see在加速器模式下被忽略的诊断

运行时检查

运行时检查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一个ssignment,,,,Selector,,,,MATLAB Function,,,,andMATLAB系统blocks.

模拟肮脏的模型 You can use unsaved models when they are referenced in normal mode. 创建模型时,您不能将该模型用作加速器模式引用模型,直到将模型保存到磁盘为止。
Linearization analysis and optimization

正常模式允许引用模型的逐个阻滞线性化,从而实现了准确的线性化。

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

一个MATLAB Function块在参考enced model that executes in normal mode can call MATLAB®声明为代码生成的外部功能。

一个MATLAB Function块在参考enced model that executes in accelerator mode cannot call MATLAB functions that are declared extrinsic for code generation.

S功能

在正常模式下执行的引用模型比在加速器模式下执行的引用模型支持更多的S功能。金宝app有关更多信息,请参见S功能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功能in Referenced Models

SIL和PIL模拟模式通过为嵌入式处理器生成生产代码执行引用模型。SIL模式为PIL模拟提供了方便的替代方案,因为当目标硬件不可用时,它可以在主机平台上运行。有关更多信息,请参阅SIL和PIL模拟(Embedded Coder).

覆盖模式

The simulation mode of the parent model can override the simulation mode of aModel堵塞。This table shows which simulation mode Simulink uses for a referenced model instance based on the simulation mode of the parent model and relatedModel堵塞。

Simulation Mode Used by Parent Model Simulation Mode of Model Block
普通的 加速器
普通的

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

兼容 - 引用模型在加速器模式下模拟。

加速器

Overridden — Referenced model simulates in accelerator mode.

兼容 - 引用模型在加速器模式下模拟。

快速加速器(仅仅是顶级型号)

For information on SIL and PIL, see模型参考层次结构中的模拟模式覆盖行为(Embedded Coder).

Related Topics