Embedded coder handling data dictionary parameters differently depending on their location in a model hierarchy
6 次查看(过去 30 天)
显示 更早的评论
I am using MATLAB and Simulink R2017A to build two models. Both models have data dictionaries containing Simulink Parameters with storage class SimulinkGlobal. I use the Embedded Coder target to build model A to source code using the ERT target with a C++ class interface. In model A the parameter is used in a reference model and Embedded Coder defines the parameter in C++ as a global variable with an extern reference in the model header file. In model B the parameter is used in the top model only. Model B has no reference models, only the single model. Model B has the same code generation settings as Model A. But for model B, the parameter is added to a parameter structure definition in the model header file.
Why is there a difference handling SimulinkGlobal storage class parameters in these two examples?
Model A:
extern real_T rtP_some_parameter;
Model B:
// Parameters (auto storage)
struct P_SOME_Model_T_ {
real_T some_parameter;// Variable: some_parameter
// Referenced by: '<S82>/Constant'
};
0 个评论
回答(1 个)
Akshat Dalal
2025-3-2
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:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!