Why does code generated by Embedded Coder change when subsystem does not change?

20 ビュー (過去 30 日間)
Etienne
Etienne 2024 年 11 月 14 日 16:18
回答済み: Mark McBroom 2024 年 11 月 16 日 22:38
Hi,
I am working on an aerospace product with Matlab/Simulink 2023b. Results of code generaton using Embedded Coder is unfortunately non-repeatable: file "A.c" from reusable subsystem stored in "A.mdl" sometimes changes when modifying other subsystems (B, C, ...) whereas file "A.mdl" has not changed. Changes in C code is not only in the comments or variable name; the number and order of statements change. However, the text generated by the %<ModelVersion> tag of our CGT template does not change.
This is problematic since once formal testing has been done on A, we want to take credit for it and avoid retesting it unless we do a functional change to A. It is not possible to skip retesting A.c because it's not impossible that Embedded Coder or the compiler introduce bugs.
Example of code generated:
/* DataTypeConversion: '<S395>/Data Type Conversion1' */
*rty_FMM_ACTIVEfdi_ui32 = (uint32_t)GNC_self_arg->dwork.fdi_ui8;
/* Constant: '<S395>/Constant1' */
*rty_FMM_ACTIVEoutflg_b = rtCP_pooled191;
/* Constant: '<S395>/Constant' */
*rty_FMM_ACTIVEstatusflg_ui32 = rtCP_pooled76;
which then becomes in a next generation where the model has not changed:
/* Constant: '<S366>/Constant1' */
*rty_FMM_ACTIVEoutflg_b = rtCP_pooled199;
/* DataTypeConversion: '<S366>/Data Type Conversion1' */
*rty_FMM_ACTIVEfdi_ui32 = (uint32_t)GNC_self_arg->dwork.fdi_ui8;
/* Constant: '<S366>/Constant' */
*rty_FMM_ACTIVEstatusflg_ui32 = rtCP_pooled81;
Is there some code generation settings that would allow deterministic behavior of Embedded Coder generation or a C-file basis?
Thanks

回答 (1 件)

Mark McBroom
Mark McBroom 2024 年 11 月 16 日 22:38
The code from a subsystem model can change if the parent model changes, even if no changes were made to the subsystem. During the code generation process, the subsystem is "inlined" into the parent model and the overal model is run through the code generation process. Changes to other parts of the parent model can result in to changes to the code from the subsystem. The recommended approach is to convert the subsystem reference to a model reference.

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by