Why does code generated by Embedded Coder change when subsystem does not change?
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Etienne
el 14 de Nov. de 2024 a las 16:18
Respondida: Mark McBroom
el 16 de Nov. de 2024 a las 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
0 comentarios
Respuestas (1)
Mark McBroom
el 16 de Nov. de 2024 a las 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.
0 comentarios
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!