Separate C Code Interface Configuration Definition from Model-Specific Configurations
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:
Create, store, and maintain the interface specifications for your generated code in one place.
Use one code interface configuration to generate code from multiple models for the same target execution environment.
Select the code interface definition that the code generator uses by default for each category of interfaces.
Configure the code interface of an individual model element by mapping it to a specific code interface definition.
Use one model to generate code that is configured differently for different target execution environments.
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:
The code interface configuration is saved in a shared coder dictionary
.sldd
file.The model configuration parameter Shared coder dictionary is used to attach the shared coder dictionary to each model.
The code interface definitions from the shared code interface configuration definition appear in the Code Mapping editor for the models that use the shared dictionary. You can configure the code interface of each model individually by mapping:
Model functions to function customization templates
Model data elements to storage classes or service interfaces, depending on the type of interface configuration that you choose
The shared coder dictionary specifies a dictionary default definition for each code interface category. If you do not select a different definition in the Code Mappings editor, the code generator uses the dictionary default definition for code generation.
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:
Apply a definition to a category of data elements or functions by default for the models to which the shared coder dictionary is attached by specifying the definition as the dictionary default for the category.
Modelers can apply a definition to a category of data elements or functions by default in one model by specifying the definition as the model default for that category. The model default selection overrides the dictionary default for the shared coder dictionary that the model uses.
Modelers can apply a definition to one data element or function in one model by specifying the definition using the mapping for individual model elements. The selection for an individual model element overrides the dictionary default and model default selections for that function or data element.
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:
Apply a definition to a category of data elements or functions by default for the models to which the shared coder dictionary is attached by specifying the definition as the dictionary default for the category.
Modelers can apply a definition to one data element or function in one model by specifying the definition using the mapping for individual model elements. The selection for an individual model element overrides the dictionary default and model default selections for that function or data element.
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:
Specify an ERT-based system target file for the models.
Create code interface definitions in the shared coder dictionary.
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.