Main Content

Use Configuration Reference to Select Code Generation Target

This example shows how to use a configuration reference to select a code generation target for a model reference hierarchy without modifying individual models.

Open Example Model

Open the example model slexConfigSetRefExample.


To open the active configuration set for the model slexConfigSetRefExample, on the Modeling tab, click the Model Configuration Parameters button.

Because the model is using a referenced configuration, the Configuration Reference dialog box opens and displays a read-only view of the referenced configuration set. Information at the top of the dialog box indicates that the model is using the configuration set, Reference, located in the data dictionary, slexConfigSetRefData.sldd. In this example, Reference is another configuration reference, Configuration_ERT.

In the model editor, right-click the Model block, Amplifier, and select Open As Top Model.


Open the active configuration set for this model. The name and location for the referenced configuration is the same as in slexConfigSetRefExample.

Open the Referenced Configuration Set

If you need to change and apply parameter values in the configuration set, open Configuration_ERT for edit in the Configuration Parameters dialog box by clicking the Model Configuration Parameters icon at the top of either of the Configuration Reference dialog boxes.

Generate Code for ERT Target

The referenced configuration set is customized for ERT code generation. To generate code, press Ctrl+B.

### Starting serial model reference code generation build.
### Starting build procedure for: slexConfigSetRefMdlRef
### Successful completion of code generation for: slexConfigSetRefMdlRef
### Starting build procedure for: slexConfigSetRefExample
### Successful completion of code generation for: slexConfigSetRefExample

Build Summary

Code generation targets built:

Model                   Action           Rebuild Reason                            
slexConfigSetRefMdlRef  Code generated.  slexConfigSetRefMdlRef.c does not exist.  

Top model targets built:

Model                    Action           Rebuild Reason                                    
slexConfigSetRefExample  Code generated.  Code generation information file does not exist.  

2 of 2 models built (0 models already up to date)
Build duration: 0h 0m 22.343s

The code generation report displays once code generation is complete.

Switch Targets and Generate Code for AUTOSAR Target

For this model there is another configuration set, Configuration_AUTOSAR, that is customized for AUTOSAR code generation. At the top of the Configuration Reference dialog box, in the rightmost drop-down list, select Configuration_AUTOSAR. slexConfigSetREfExample and its referenced model, slexConfigSetMdlRef, now both use the configuration set, Configuration_AUTOSAR.

Because you edited the configuration reference, the data dictionary has unsaved changes. The configurations are stored outside of the models so the models do not have unsaved changes.

If you have downloaded the AUTOSAR package, you can now generate code for an AUTOSAR target. In the model editor window, press Ctrl+B.