主要内容

配置系统目标文件

To configure a model for code generation, follow the steps inSelect a Solver That Supports Code GenerationSelect a System Target File from STF Browser。When you select a system target file, other model configuration parameters change to serve requirements of the execution environment. For example:

  • Code interface parameters

  • Build process parameters, such as the toolchain or template makefile

  • Target hardware parameters, such as word size and byte ordering

After selecting a system target file, you can modify model configuration parameter settings.

You can switch between different system target files in a single workflow for different code generation purposes (for example, rapid prototyping versus production code deployment). To switch, set up different configuration sets for the same model and switch the active configuration set for the current operation. For more information on how to set up configuration sets and change the active configuration set, see管理模型的配置集

Select a Solver That Supports Code Generation

要构建模型,模型配置必须指定与系统目标文件代码生成兼容的求解器。很少有系统目标文件支持使用可变式求解器或具有非零金宝app启动时间的型号的代码生成。

  • 通,ERT, ERT-based系统目标文件,set the类型配置参数到Fixed-step

  • For Rapid Simulation (Rsim) or S-Function (rtwsfcn) system target files, set the类型配置参数到Fixed-step或者可变步骤

For more information about the requirement that you use a fixed-step solver to generate code for a realtime system target file, see基于时间的调度和代码生成(Embedded Coder)

The Rapid Simulation (RSim) system target file supports a nonzero start time when the求解器选择配置参数设置为Use Simulink solver module。其他系统目标文件不支持非零的启动时间 - 代码生成器不会产生代码,金宝app并且构建过程会产生错误。

Select a System Target File from STF Browser

After you select a solver (seeSelect a Solver That Supports Code Generation),指定一个值System target fileconfiguration parameter. Enter the name of your system target file directly in the field or use the System Target File Browser to select a file.

To use the System Target File Browser:

  1. In the configuration parameters dialog box, next to theSystem target filefield, click the浏览按钮。浏览器显示可用系统目标文件的列表,包括自定义。

  2. 从列表中,选择您的文件,例如,GRT系统目标文件(grt.tlc)。列表框的背景变成黄色以表明未应用选择。点击Apply或者好的

    System Target File Browser

您还可以从MATLAB编程选择系统目标文件®代码,如所述Select a System Target File Programmatically

After selecting a system target file, you can modify model configuration parameter settings. Selecting a system target file for your model selects either the toolchain approach or template makefile approach for build process control. For more information about these approaches, see选择构建方法和配置构建过程

如果要在单个工作流程中以不同的代码生成目的切换不同的系统目标文件,请为同一模型设置不同的配置集。切换为当前操作的活动配置集。这种方法对于在快速原型制作和生产代码部署之间切换很有用。有关如何设置配置集并更改活动配置集的更多信息,请参见管理模型的配置集

Select a System Target File Programmatically

金宝app®models store model-wide parameters and system target file-specific data in配置集。每个配置集都包含一个组件,该组件定义了特定系统目标文件的结构和相关选项的当前值。金宝appSimulink从您指定的系统目标文件中加载一些此类信息。您可以通过复制和修改旧或添加新的配置集和浏览以选择新的系统目标文件来配置模型以生成替代代码。然后,您可以在这些集合之间进行交互性选择一个活动配置(只有一个配置集可以在给定时间处于活动状态)。

Scripts that automate system target file selection must emulate this process.

到程序系统目标文件选择:

  1. Obtain a handle to the active configuration set with a call to thegetActiveConfigsetfunction.

  2. 定义与所需系统目标文件,工具链或模板makefile和/或相对应的字符矢量变量制作command settings. For example, for the ERT system target file, you would define variables for the character vectors'ert.tlc','ERT_DEFAULT_TMF', 和'make_rtw'

  3. Select the system target file with a call to theswitchtargetfunction. In the function call, specify the handle for the active configuration set and the system target file.

  4. Set theTemplatemakefilemakecommand在步骤2中创建的相应变量的配置参数。

例如:

cs = getActiveConfigSet(model); stf = 'ert.tlc'; tmf = 'ert_default_tmf'; mc = 'make_rtw'; switchTarget(cs,stf,[]); set_param(cs,'TemplateMakefile',tmf); set_param(cs,'MakeCommand',mc);

For more information about selecting system target files programmatically, seeswitchtarget

Develop Custom System Target Files

You can create your own system target files that interface with external code or operating environments.

For more information on how to make custom system target files appear in the System Target File Browser and display relevant controls, see自定义目标以及它引用的主题。

See Also

|

相关话题