Question about Embedded Coder handling of tunable parameters
Show older comments
I have two models using data dictionaries with Simulink Parameters having storage class SimulinkGlobal. One model references the parameter from a reference model and when I build that model using Embedded Coder it is generated as a global variable with prefix "rtP_". The second model has a parameter with the same storage class but the parameter is used at the top level of the model, and when Embedded Coder generates code the parameter gets put into a structure for "parameters (auto storage)". Why the difference in behavior that depends on where the parameter is used in the model hierarchy? I dumped the model configuration settings to an M file and compared and there is no difference in the model configuration that seems to be causing the change in the generated code.
Answers (1)
Akshat Dalal
on 2 Mar 2025
Moved: Walter Roberson
on 2 Mar 2025
0 votes
Hi Benjamin,
When parameters are used in a referenced model, Embedded Coder often generates them as global variables with a prefix like rtP_. This is because the referenced model is treated as a standalone entity that might be reused in different contexts, necessitating global access to its parameters.
In contrast, parameters used directly at the top level of a model are often placed in a parameter structure. This is because the top-level model typically doesn't need the same level of modularity and reuse, allowing for parameters to be grouped together for efficiency and organization.
You can refer the following documentations for more information:
- https://www.mathworks.com/help/ecoder/ref/code-generation-pane-symbols.html
- https://www.mathworks.com/help/ecoder/ref/systemgeneratedidentifiers.html
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!