米ain Content

Generate Code by Using the Quick Start Tool

The Quick Start tool helps you prepare a model for generating readable, efficient code. To start the tool, open the Embedded Coder®应用程序。在C Code选项卡,单击Quick Start

After you start the tool, you must answer these questions about the code that you want to generate:

  • 代码生成的模型或子系统是什么?

  • What is the type of code output for your generated code?

  • 您的申请是否需要重新进入的多个实体代码?

  • 什么是目标硬件处理器类型?

  • What is your primary code generation objective?

该工具针对模型验证您的选择,并介绍生成代码所需的参数更改。如果选择生成代码,则该工具将参数更改为您的配置集并生成代码。代码生成后,您可以查看代码生成报告,并查找有关构建,自定义,优化和包装代码的信息。有关代码生成报告的更多信息,请参阅Reports for Code Generation

要进一步自定义生成的代码,请单击Finish,然后将嵌入式编码器应用程序与代码透视环境一起使用。代码透视图提供了控制生成代码中模型数据和功能的名称和表示的工具。有关更多信息,请参阅C代码生成的模型接口元素配置

快速开始模型分析

在快速启动过程的每个步骤中,该工具可针对您的选择验证您的模型。该工具检查模型条件,以防止您继续代码生成。在分析步骤中,该工具还必须检查您的模型或子系统以获取以下问题的答案。答案有助于确定代码部署的最佳配置。

您的系统中有多少样品率?

The Quick Start tool evaluates your model to determine the number of periodic sample rates in your system.

Single rate Your model has only one periodic sample rate. The generated code has a single-entry point function that runs at the time interval of the sample rate.
米ultirate

Your model has more than one periodic sample rate. It is possible that the generated code does not execute at the same time intervals. After the analysis step, you can choose to generate a single-entry point function for each of the sample rates or generate a different entry point function for each sample rate.

If you choose to generate multitasking code, the code generator produces multiple entry-point functions. These functions run as multiple tasks. Each entry-point function is called at an interval defined by the sample rate that is configured in the model.

如果您的模型包含异步速率,则会生成附加的入口点函数,以在特定的中断时间运行。

For more information about sample rates, seeTime-Based Scheduling and Code Generation

您的系统是否包含连续状态?

快速启动工具评估您的模型连续块,以确定要使用的正确求解器。

No 如果您的系统不包含连续状态,则快速启动工具将配置您的模型,如果您没有选择一个固定的离散求解器进行代码生成。
是的 如果您的系统确实包含连续状态,则快速启动工具将配置您的模型,如果您没有选择固定步骤连续求解器进行代码生成。该工具还选择金宝app支持连续configuration parameter.

For more information on solvers, seeSolver Selection Criteria

Did you configure your system for export function calls?

快速启动工具评估您的模型,以查看是否必须生成调度程序代码。

No 如果您没有将系统配置为导出功能调用,则生成的代码包括系统算法和调度程序代码的代码。
是的 如果将系统配置为导出功能调用,则生成的代码包括系统算法的代码。您可以手动编写调度程序代码或从其他模型中生成它。

有关更多信息,请参阅导出功能模型概述

Does your system contain referenced models?

快速启动工具评估您的模型,以查看它是否取决于其他模型的代码。

No 如果您的系统不包含引用的模型,则生成的代码不取决于其他模型的代码。
是的 如果您的系统包含引用的模型,则为您的模型的生成代码取决于引用模型生成的其他模块。代码生成器可以优化生成的代码,因为它知道您的模型与引用模型之间的关系。当快速启动工具将配置参数应用于模型时,它还将更改应用于引用模型。

有关更多信息,请参阅Generate Code for Model Reference Hierarchy

Configuration Parameter Changes for Models That Have a Configuration Reference

To apply configuration parameter changes to a model that has an active configuration reference, the Quick Start tool:

  • 创建一个Simulink.ConfigSet目的快速开始_时间戳在包含原始配置集的工作区或数据字典中。新对象是具有应用参数更改的原始配置集的副本。

  • 创建一个Simulink.ConfigSetRef指向新配置集对象的对象。

  • Attaches the new configuration reference to the model and makes it the active configuration.

  • If your system contains referenced models that share your original configuration set, the tool attaches the new configuration reference to the referenced models and makes the new configuration reference the active configuration.

要恢复原始配置集,请激活原始配置集Simulink.ConfigSetRef目的。

笔记

如果快速启动工具在MATLAB中创建配置集对象®workspace, you must save the object to preserve the configuration set after the MATLAB session ends. For more information, see保存配置集

Next Steps

通过使用快速启动工具生成代码后,可能的下一步是:

To control the names and representation of the model data and functions in the generated code, use the Code Mappings editor and the Model Data Editor in the Embedded Coder app. For more information, seeC代码生成的模型接口元素配置

Related Topics