Starting in R2018a, for new models:
To apply model-wide memory section settings, do not use the model configuration parameters under Code Generation > Advanced parameters > Memory Sections. Instead, use the Code Mappings editor. To define the memory sections, continue to use packages or you can use the Embedded Coder Dictionary.
To set a naming rule for shared utility functions, do not use the model configuration parameter Code Generation > Identifiers > Advanced parameters > Shared utilities identifier format. Instead, you use the Embedded Coder Dictionary to create a function customization template that specifies the naming rule, then apply the template by using the Code Mappings editor.
For general information about the Simulink Editor Code perspective mode, the Code Mappings editor, and the Embedded Coder Dictionary, see C Code Generation Configuration for Model Interface Elements.
In a model that you created in a release before R2018a, when someone enables Code perspective mode, Simulink® migrates memory section and shared utility settings from the configuration parameters to the Code Mappings editor of the model. If necessary, as part of this migration, Simulink configures the Embedded Coder Dictionary that the model uses:
To refer to the package that defines the memory sections, as described in Refer to Code Generation Definitions in a Package.
To contain a function customization template that specifies the naming rule and, if applicable, memory section settings that you specified for shared utilities.
Also, if you use the coder.mapping.create
function on such a model, Simulink migrates memory section and shared utility settings in this manner.
The migration process makes changes to the model file, which you must save. The changes include:
Translating the configuration parameter settings into Code Mappings editor settings.
If the model is not linked to a data dictionary, configuring the Embedded Coder Dictionary in the model file to refer to the memory section package and to contain a function customization template.
If the model is linked to a data dictionary, the migration process makes changes to the dictionary, which you must save. The changes include:
If the configuration parameters are stored in the model
file (the model does not refer to a
Simulink.ConfigSet
object), configuring
the Embedded Coder Dictionary of the data dictionary to
refer to the memory section package and to contain a
function customization template.
If the data dictionary references other dictionaries, the migration process configures the dictionary at the bottom of the reference hierarchy so other models and dictionaries in the hierarchy can use the memory section and function template definitions.
If the model refers to a
Simulink.ConfigSet
object, configuring
the Embedded Coder Dictionary of the data dictionary that
stores the object.
Typically, when you enable the Code perspective mode, Simulink executes the migration process without prompting you. Do not enable Code perspective mode unless you are ready to migrate memory section and shared utility naming settings.
Code perspective mode prompts you to accept the migration if your model meets either of these conditions:
The model has multiple configuration sets (one active and one or more inactive).
The model refers to a Simulink.ConfigSet
object.
If you do not accept, you cannot use the Code perspective.
If you use Simulink data dictionaries, before you or other users open the Code perspective in any models, consider creating and configuring the dictionaries first.
In a hierarchy of referenced data dictionaries (for example, a dictionary hierarchy that parallels a model hierarchy), only one dictionary can contain an Embedded Coder Dictionary. Setting up data dictionaries before migrating associated models enables you to control where the Embedded Coder Dictionary resides in the dictionary hierarchy. Create or identify a data dictionary at the bottom of the hierarchy so that all of the models can access the memory section and function template definitions. Then, when you initiate migration by enabling Code perspective for a model, Simulink configures that data dictionary.
For information about sharing an Embedded Coder Dictionary between models by using referenced dictionaries, see Share Embedded Coder Dictionary Definition Between Models.
The migration process makes changes based on the active configuration set of the model (see Manage Configuration Sets for a Model) at the time that you enable Code perspective mode. Before you enable Code perspective, activate the configuration set whose settings you want the migration process to use.
The process ignores settings in inactive configuration sets. If different configuration sets of the model specify different settings, you must choose one set to migrate.
In a branching hierarchy of referenced models and referenced data
dictionaries, after you or other users migrate referenced models in
different branches, enabling Code perspective mode in a parent model can
generate an error due to the presence of multiple Embedded Coder
Dictionaries in the data dictionary hierarchy. To resolve these errors,
use coder.dictionary.move
and coder.dictionary.remove
to transfer and delete Embedded
Coder Dictionaries until only one dictionary remains. Place the
remaining Embedded Coder Dictionary in a data dictionary at the bottom
of the hierarchy so that all of the models can
access the memory section and function template definitions.
For information about sharing an Embedded Coder Dictionary between models by using referenced dictionaries, see Share Embedded Coder Dictionary Definition Between Models.
After you migrate a model, Embedded Coder® ignores memory section and shared utility settings in the
configuration parameters. If you use set_param
or
get_param
to access these configuration
parameter settings programmatically, the functions generate warnings. To
change or set these settings, use the Code Mappings editor or the
equivalent programmatic interface as described in Configure Default C Code Generation for Categories of Data Elements and Functions.
However, if a model contains atomic subsystems that have nondefault memory section settings, the model continues to depend on the Package setting in the configuration parameters. See Override Default Memory Placement for Subsystem Functions and Data.
If a model refers to a Simulink.ConfigSet
object,
after migration, the model no longer uses the
memory section and shared utility settings in the object. If you used
the object to set the configuration parameters of multiple
models:
Changing memory section and shared utility settings in the object affects only models that you have not migrated.
Migrated models no longer
acquire memory section and shared utility settings from a
single location (the Simulink.ConfigSet
object). To change these settings for these models, you must
use the Code Mappings editor of each individual
model.
Code Mappings Editor | Embedded Coder Dictionary