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® app. On the C Code tab, click Quick Start.
After you start the tool, you must answer these questions about the code that you want to generate:
What is the model or subsystem for code generation?
What is the type of code output for your generated code?
Does your application require reentrant, multi-instance code?
What is the target hardware processor type?
What is your primary code generation objective?
The tool validates your choices against the model and presents the parameter changes required to generate code. If you choose to generate code, the tool applies the parameter changes to your configuration set and generates the code. After code generation, you can view the code generation report and find information on building, customizing, optimizing, and packaging the code. For more information about the code generation report, see Reports for Code Generation.
To further customize your generated code, click Finish, and then use the Embedded Coder app with the Code perspective environment. The Code perspective provides the tools to control the names and representation of the model data and functions in the generated code. For more information, see C Data Code Interface Configuration for Model Interface Elements.
Quick Start Model Analysis
At each step of the quick start process, the tool validates your model against your selections. The tool checks for model conditions that prevent you from proceeding with code generation. During the analysis step, the tool must also examine your model or subsystem for answers to the following questions. The answers help determine the best configuration for the deployment of your code.
How many sample rates are in your system?
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.|
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.
If your model contains an asynchronous rate, an additional entry-point function is generated to run at the specific interrupt time.
For more information about sample rates, see Time-Based Scheduling and Code Generation.
Does your system contain continuous states?
The Quick Start tool evaluates your model for continuous blocks to determine the correct solver to use.
|No||If your system does not contain continuous states, the Quick Start tool configures your model to use a fixed-step discrete solver for code generation if you have not selected one.|
|Yes||If your system does contain continuous states, the Quick Start tool configures your model to
use a fixed-step continuous solver for code generation if you have not selected
one. The tool also selects the |
For more information on solvers, see Solver Selection Criteria.
Did you configure your system for export function calls?
The Quick Start tool evaluates your model to see if scheduler code must be generated.
|No||If you did not configure your system for export function calls, the generated code includes code for the system algorithm and the scheduler code.|
|Yes||If you configured your system for export function calls, the generated code includes code for the system algorithm. You can manually write the scheduler code or generate it from other models.|
For more information, see Export-Function Models Overview.
Does your system contain referenced models?
The Quick Start tool evaluates your model to see if it depends on code from other models.
|No||If your system does not contain referenced models, the generated code does not depend on code from other models.|
|Yes||If your system contains referenced models, the generated code for your model depends on other modules generated from referenced models. The code generator can optimize the generated code because it is aware of the relationship between your model and the referenced models. When the Quick Start tool applies configuration parameter changes to your model, it also applies the changes to the referenced models.|
For more information, see 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:
QuickStart_in the workspace or data dictionary that contains the original configuration set. The new object is a copy of the original configuration set that has the parameter changes applied.
Simulink.ConfigSetRefobject that points to the new configuration set object.
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.
To restore the original configuration set, activate the original
If the Quick Start tool creates the configuration set object in the MATLAB® workspace, you must save the object to preserve the configuration set after the MATLAB session ends. For more information, see Save a Configuration Set.
After you generate code by using the Quick Start tool, the tool presents these possible next steps:
Other next steps include:
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, see C Data Code Interface Configuration for Model Interface Elements.
- Generate C or C++ Code from Stateflow Blocks (Stateflow)