Unrolling ARID_DEF structs

25 visualizzazioni (ultimi 30 giorni)
Felix
Felix il 29 Ott 2024
Risposto: Felix il 17 Dic 2024
Hi!
Generating code for a .slx component gives a very large ARID_DEF struct which contains all of the variables in the component, in all of the files and functions. This makes the struct very large and hard to integrate/optimize onto hardware with limited memory.
It would be beneficial to "unroll" this struct and divide it into smaller structs, such that critical variables can be put on fast memory and non-critical variables onto slower memory. Right now I have to decide where to place the entire struct.
How can one achieve this?
For example:
function1.m
variableA
variableB
function2.m
variableC
variableD
shall not result in
typedef struct
{
variableA;
variableB;
variableC;
variableD;
}
ARID_DEF_COMPONENTNAME_T;
but rather
typedef sub_struct1
{
variableA;
variableB;
}
ARID_DEF_SUBSTRUCT1_T;
typedef sub_struct2
{
variableC;
variableD;
}
ARID_DEF_SUBSTRUCT2_T;

Risposte (2)

Maneet Kaur Bagga
Maneet Kaur Bagga il 20 Nov 2024
Hi,
As per my understanding, to optimize the large "ARID_DEF" struct by splitting it into smaller sub-structs, you can use the following as a possible workaround:
  • Use Simulink Data Dictionary (SLDD) to Segment Variables: In the Simulink Data Dictionary, group related variables into smaller "Simulink.Bus" objects. Assign the "Simulink.Bus" objects to subsystems/functions within the model.
  • Custom Storage Classes: Define custom storage classes for the variables using Embedded Coder. Group variables by assigning them to specific "Simulink.Signal" or "Simulink.Parameter" objects with unique storage classes.
  • Manual Splitting in the Generated Code: Post-process the generated code to reorganize the "ARID_DEF" struct into smaller structs. Use "coder.cstructname" to control how specific variables appear in the struct.
  • Subsystem Partitioning: Partition your Simulink model into smaller subsystems that encapsulate related variables. The generated code will create structs local to each subsystem, splitting the large "ARID_DEF" struct.
Please refer to the following MathWorks Documentation for "coder.cstructname" for better understanding:
Hope this helps!
  1 Commento
Akshay
Akshay il 17 Dic 2024
Subsystem Partitioning: Partition your Simulink model into smaller subsystems that encapsulate related variables. The generated code will create structs local to each subsystem, splitting the large "ARID_DEF" struct how to do this? is there any config setting?

Accedi per commentare.


Felix
Felix il 17 Dic 2024
I found the answer to my problem.
The setting below does exactly what I wanted.
setInternalDataPackaging(slMap,'PrivateGlobal')

Categorie

Scopri di più su Code Interface Configuration and Integration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by