
How can I explicitly initialize specific zero-valued Data Store Memories?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 14 Oct 2022
Réponse apportée : MathWorks Support Team
le 23 Jan 2023
I am generating code for a model using Embedded Coder. This model contains some "Data Store Memory" (DSM) blocks that may be zero-valued at initialization. I am aware that zero-valued initializations can be omitted if I check the setting:
Model Configuration Parameter > Code Generation > Optimization > Remove internal data zero initialization
This disables all initialization lines in the generated code if the DSM block is initialized to be zero. However, this is quite inflexible because in some cases, omitting the initialization is beneficial e.g. for a large array that does not need to be read. In other cases, I require the initialization e.g. I need to compare the value drawn from the data store using "Data Store Read" block.
Is there a way to manually select certain zero-valued DSM blocks to explicitly initialize?
Réponse acceptée
MathWorks Support Team
le 14 Oct 2022
Starting from MATLAB R2022a, zero-valued DSM blocks initialized inside the "Initialize Function" block retain their initialization in generated code even if "Remove internal data zero initialization" is set. For example, the following image illustrates the initialization of "maxData" if these blocks are placed inside an "Initialize Function" block:

Thus, you can include all the zero-valued DSM blocks that need to be initialized in the "Initialize Function" block and leave the rest of the zero-valued DSM blocks outside.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!