Reusing Models in Codegen Projects for Different Targets

1 Ansicht (letzte 30 Tage)
Jason
Jason am 20 Feb. 2023
Beantwortet: Rishav am 5 Mai 2023
Hello, I am wondering what the best way is to reuse models within codegen projects targeting different platforms. I have multiple targets, each with a different System target TLC file (and a handful of different target-specific configuration settings). I would like to maintain a separate top-level model for each codegen target, but within each target-specific top-level model I want to reuse a common set of shared models, via Model Reference blocks.
I know I can create Configuration References using Data Dictionaries, as shown in various Help Topics such as Share a Configuration Across Referenced Models and Share a Configuration with Multiple Models. But it is not clear to me how to set multiple top-level models up as codegen harnesses, such that the (shared) referenced models automatically reference the configuration, including System target TLC file, from whichever top-level model I am initiating codegen from.
Is such a thing possible to do, and if so how? Or do I need to manually propagate / restore a different Configuraton Reference to the shared referenced models each time I want to perform codegen for a different target? Thanks in advance.

Antworten (1)

Rishav
Rishav am 5 Mai 2023
Hi Jason,
It is possible to reuse models within codegen projects targeting different platforms by using Model Reference blocks and Configuration References. However, you need to set up your models and configurations carefully to ensure that they are compatible with each other.
Here are the general steps you can follow to set up your models and configurations:
  1. Create a separate top-level model for each codegen target, and set the System target TLC file and other target-specific configuration settings in each model.
  2. Create a set of shared models that you want to reuse across your codegen targets, and add Model Reference blocks to your top-level models to reference these shared models.
  3. Create a Data Dictionary that contains the configuration settings that are common to all your codegen targets, such as model parameters and block settings. Add Configuration References to your top-level models to reference this Data Dictionary.
  4. In each of your shared models, use Configuration References to reference the Data Dictionary that contains the common configuration settings.
  5. When you initiate codegen for a particular target, make sure that you select the correct top-level model and set of configuration settings. The referenced models will automatically inherit the configuration settings from the top-level model via the Configuration References.
By following these steps, you can reuse your shared models across multiple codegen targets, while still maintaining separate top-level models for each target. However, you will need to ensure that the configuration settings in your Data Dictionary are compatible with the System target TLC files and other target-specific settings in your top-level models. If there are any conflicts, you may need to manually adjust the configuration settings in your shared models to ensure that they are compatible with your codegen targets.
Regards,
Rishav Saha

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by