本页对应的英文页面已更新,但尚未翻译。 若要查看最新内容,请点击此处访问英文页面。

引用模型

生成和重用引用模型的代码

要了解为引用模型生成代码时的注意事项,请参阅Code Generation of Referenced Models。要查看为引用模型生成代码的示例,请参阅Generate Code for Referenced Models

模块

Model引用另一个模型来创建模型层次结构

函数

depview显示模型引用依存关系图,可选择是否显示库依存关系
find_mdlrefs在所有层或仅在顶层查找 Model 模块和引用模型
view_mdlrefsAnalyze and visualize model referencing dependencies without library dependencies
Simulink.SubSystem.convertToModelReference将子系统转换为模型引用
slbuild为模型构建独立可执行文件或模型引用目标

主题

Code Generation of Referenced Models

This section describes model referencing considerations that apply specifically to code generation by the Simulink® Coder™.

Simulink Coder Model Referencing Requirements

A model reference hierarchy must satisfy various Simulink Coder requirements, as described in this section.

Configure Referenced Models

Minimize occurrences of algebraic loops by selecting the Minimize algebraic loop occurrences parameter on the Model Reference pane.

Generate Code for Referenced Models

Introduces generating code for models referenced with Model blocks, and using Model Explorer to browse code files.

Generate Reusable Code from Model Reference Hierarchy

Generate reusable code from a top model with Model blocks.

Combine Code Generated for Multiple Models

Generate a single executable program from multiple models or multiple copies of the same model.

Build Model Reference Targets

By default, the Simulink engine rebuilds simulation targets before the Simulink Coder software generates model reference targets.

Establish Data Ownership in a Model Hierarchy

In the generated code, place the definitions of global variables with the components that define them.

Storage Classes for Signals Used with Model Blocks

Models containing Model blocks can use signals of storage class “Auto” without restriction.

Code Generation Model Referencing Limitations

Be aware of limitations that apply to using a model hierarchy for code generation.

Customize Library File Suffix and File Type

You can control the library file suffix and file type extension that the Simulink Coder code generator uses to name generated model reference libraries.

Simulink Cache Files for Incremental Code Generation

Share Simulink cache files in team-based development to reduce build time and avoid unnecessary code regeneration.