Separate C Code Interface Configuration Definition from Model-Specific Configurations - MATLAB & Simulink (original) (raw)

To generate C code for deployment to a specific target execution environment, in an Embedded Coder Dictionary, define a data or service code interface configuration definition. You can store the interface configuration definition in a shared Embedded Coder Dictionary, which is separate from your models. Separating the code interface configuration definition from your model-specific configurations in this way enables you to:

For information on creating a shared coder dictionary, see Configure Default Code Mapping in a Shared Dictionary.

Set Up Models to Use Standard Code Interface Configuration

When you separate your code interface configuration definition from your model, you can set up multiple models to use the same code interface configuration. Sharing the definition among multiple models enables you to generate standardized code for the same target execution environment from the models. The typical setup of models with a code interface configuration is:

By using this setup, you can maintain the code interface configuration definition for multiple models in one location. When you make changes to the code interface configuration definition, you can generate code that reflects the latest configuration without changing the models. You can easily apply standard code interfaces to the models to which the dictionary is attached by selecting the dictionary defaults, and you can apply non-default code interfaces to individual models by using the Code Mappings editor or the code mappings programming interface.

For more information about sharing your code interface configuration definition with models, see Deploy Code Generation Definitions.

Apply Code Interface Definitions to Model Elements with Flexibility

Storing code interface definitions in a shared coder dictionary gives modelers flexibility in applying the definitions to a model because the code definitions are separate from the elements in a model. Configure data elements and functions in your model by mapping them to code definitions. You can map data elements and functions to code definitions in multiple ways, depending on the type of code interface configuration definition that you use.

Data Interface Configuration

When you use a data interface configuration, the code generator creates a program intended to run on the target device. The generated code uses the data interfaces that you define. You can apply the code definitions from a data interface configuration to models in these ways:

For more information, see C Data Code Interface Configuration for Model Interface Elements.

Service Interface Configuration

When you use a service interface configuration, the code generator creates an algorithm that you intend to deploy within a larger application. The target platform middleware calls the algorithm code and provides the services for the target device. The generated code calls the services according to your definitions in the service interface configuration. You can apply the code definitions from a service interface configuration to models in these ways:

For more information, see C Data Code Interface Configuration for Model Interface Elements.

Generate Code for Different Platforms

By separating code definitions from your design data, you can generate code for different target platforms from the same model or model hierarchy. For example, you can share an Embedded Coder Dictionary with models for an embedded real-time (ERT) system target file. For each of the models, maintain a separate AUTOSAR dictionary with definitions for an AUTOSAR system target file. To configure the models for the ERT system target file:

  1. Specify an ERT-based system target file for the models.
  2. Create code interface definitions in the shared coder dictionary.
  3. For each model, in the Code Mappings editor, map categories of model elements and individual model elements to definitions in the shared coder dictionary.

When you specify the ERT-based system target file, the models use this code mapping.

When you use an AUTOSAR code generation target, you define the interface in the AUTOSAR dictionaries and configure models by using the AUTOSAR code mappings. For more information, see AUTOSAR Component Configuration (AUTOSAR Blockset). When you specify the AUTOSAR-based system target file, the models use the AUTOSAR code mapping.

To generate code for either platform, specify the system target file. The code mapping for the model is updated to reflect the mapping and definitions that you specified for that platform. For more information, see Manage Multiple Code Mappings for a Model.

See Also

Topics