Changing Definitions of Shared Coder Dictionary

3 vues (au cours des 30 derniers jours)
Taylor
Taylor le 5 Mar 2024
Réponse apportée : Aditya le 25 Juin 2024
Hi,
I'm generating code for a simulation environment and an embedded target environment. When generating code in an embedded environment, I'm assigning all signals to a custom data class using the code mappings interface to place the definitions in a globally accessable location. When generating code in a simulation environment, I'm using the CAPI interface to access the signals and therefore, do not want the signals generated globally as generating code globally creates issues generating code for a single reference model.
I would really like to define two different shared coder dictionaries and simulink config sets that both have the same storage class titles, but different underlying definitions. Is there a way to do this? The storage class definition seems to be tied with a specific csc definition.

Réponses (1)

Aditya
Aditya le 25 Juin 2024
Yes, you can define different storage classes and configurations for your simulation and embedded environments in Simulink by using shared coder dictionaries and configuration sets. This approach allows you to manage different storage class definitions and code generation settings without conflicts.
1) Create Shared Coder Dictionaries
  1. Open Simulink and create a new model or open your existing model.
  2. Go to the Modeling tab and select Model Properties > Code Mappings.
  3. In the Code Mappings editor, create a new shared coder dictionary for the simulation environment:
  • Click on Manage Data Representations.
  • Create a new coder dictionary (e.g., SimulationCoderDictionary.sldd).
  • Define your storage classes in this dictionary.
  • Repeat the above steps to create another shared coder dictionary for the embedded environment (e.g., EmbeddedCoderDictionary.sldd).
2) Create Configuration Sets
  1. Open the Model Explorer from the Modeling tab.
  2. In the Model Explorer, create two configuration sets:
  • One for the simulation environment (e.g., SimulationConfigSet).
  • One for the embedded environment (e.g., EmbeddedConfigSet).
  • Link each configuration set to the appropriate shared coder dictionary:
  • In the Model Explorer, select the configuration set for the simulation environment.
  • Go to the Code Generation pane.
  • Under Code Generation > Interface, set the Shared Coder Dictionary to SimulationCoderDictionary.sldd.
  • Repeat the above steps for the embedded environment configuration set, linking it to EmbeddedCoderDictionary.sldd.
3) Switch Between Configuration Sets
  1. In the Model Explorer, you can switch between configuration sets by right-clicking on the model and selecting Configuration > Set Active.
  2. Choose the appropriate configuration set (either SimulationConfigSet or EmbeddedConfigSet) based on your current environment.

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by