Select Code Generation Output for Target Platform Deployment - MATLAB & Simulink (original) (raw)

Main Content

When you want to generate code for a specific target platform, you configure the model at a high level by selecting the code output and, for C code, the code interface configuration. These high-level code output options determine which configuration parameters and code interface options are available for your model.

Example Model Hierarchy

For this example, open the model RollAxisAutopilotHarness by entering this command at the MATLAB® Command Window:

openExample("RollAxisAutopilotHarness")

The top model is a harness model that generates test inputs for the component modelRollAxisAutopilot. The harness model is for simulation only. You generate code for the model RollAxisAutopilot.

Select Output for Simulation Harness

For the simulation harness model, specify the output as simulation only. This specification indicates to the code generator to not generate code for this model.

  1. Navigate to the top model RollAxisAutopilotHarness.
  2. Open the Embedded Coder app.
  3. On the C Code tab, from the Output drop-down list, click Simulation Only.

Model RollAxisAutopilotHarness showing the C Code tab. The model is configured for simulation only and the C Code tab does not show code generation options.

The C Code tab hides the code generation actions because you do not generate code for this model. The code generation actions appear when you navigate into a model that is configured for code generation.

Specify Code Generation Output

To generate code for a target platform, specify the target and language as the code generation output for a model. You can specify these code generation output types:

For the model RollAxisAutopilot, select the outputEmbedded Code − C.

  1. Navigate to the referenced model RollAxisAutopilot.
  2. On the C Code tab, from the Output drop-down list, click Embedded Code − C.

Model RollAxisAutopilot configured for embedded C code. The C Code tab shows code generation options.

Next, configure the model to use a code interface configuration to generate code for the target platform.

Select C Code Interface Configuration

When you generate C code, you can generate code for a specific target platform by selecting a code interface configuration. A code interface configuration defines the interfaces in the generated code and controls how the code interacts with the target platform on which you run the code. You select one of these types of code interface configurations:

To apply a code interface configuration, select the Embedded Coder Dictionary that contains the configuration. For this example, configure the component modelRollAxisAutopilot to use the dictionary and service code interface configuration that you create in Create a Service Interface Configuration.

  1. Navigate to the referenced model RollAxisAutopilot.
  2. On the C Code tab, from the Code Interface drop-down list, click Set up shared Embedded Coder Dictionary.
  3. Select an .SLDD file that contains your Embedded Coder Dictionary. For this example, select InterfaceCoderDictionary.sldd, which you create in Create a Service Interface Configuration. ClickOpen and Next.

The Embedded Coder Dictionary provides the code interface configuration for the model. You can configure the code interface in more detail by mapping model elements to code definitions from the interface configuration.

See Also

Topics