Problem with referenced models that contain calls to source code (accelerated mode)
3 次查看(过去 30 天)
显示 更早的评论
I have master model that contains a referenced model which invokes a callback function from external c-code via stateflow. What is not working is to simulate the master model in accelerated mode. Everything else works: - code generation to d-space target OK - Simulate normal mode OK - Simulate the referenced model OK I have put in the configuration parameters for the referenced model: Simulation target -> Header file: #include "CarCfgBits.h" Simulation target -> Source files: carCfgBits.c
Error message: Subsystemlib.lib(Subsystem.obj) : error LNK2019: unresolved external symbol extractCarCfgBits referenced in function Subsystem ..\..\..\Subsystem_msf.mexw64 : fatal error LNK1120: 1 unresolved externals
It does not seem that the source code is available (and including function extractCarCfgBits), when generating code for simulation target accelerated mode (for master model). Thus, the "refmodel_msf.mexw64" file can not be generated.
I attach a screenshot of how my test setup (minimized version) to reproduce the problem looks like.
Appreciate any feedback and hints here!
回答(2 个)
Shivang Menon
2016-11-3
编辑:Shivang Menon
2016-11-3
I understand you are trying to include custom code in a stateflow chart and use that model as a reference model in a top model. However, running the parent model in accelerator results in linker errors.
I think the build should also fail if top model is in normal mode and you run the reference model block as accelerator.
This is an expected behaviour. The rationale is that it can cause inconsistencies between simulation and generated code in some cases. Consider the following example
A parent model and a child model, both containing Stateflow charts (though not necessarily the same Stateflow chart). Both models have the same source files listed in their custom code, and both Stateflow charts call a common function from custom code containing a global variable declared/defined in the custom code.
When generating code for the "final" build, (i.e. not the simulation target), the parent model's Stateflow chart and the child model's Stateflow chart will both call the same hand code function and use the same global variable.
In contrast, if we simulate with the child model in "accelerator mode", the results are quite different; The parent model's Stateflow chart uses a simulation target with the custom code compiled into it (including the global variable), but the child model uses its own separate simulation target that has a separate copy of the custom code (including the global variable).
This case wouldn't result in any sort of compilation/linking failure because the accelerated child model reference's simulation target is never linked with the parent model's. However, one case has two global variables while the other has only one, and their results are almost certain to differ.
Also, a stateflow chart is simply an S-function. So whatever limitations for model referencing apply to S-functions apply to stateflow charts as well. Refer to the following link for model referencing limitations in accelerator mode for S-functions:
Model Referencing Limitations : Refer to the Limitations on Accelerator Mode Referenced Models section.
The fact that the top model works while running in Rapid Accelerator mode is surprising - maybe you are invoking one of the S-function limitations from the above link for accelerator mode.
Hope this helps!
0 个评论
Anders Ekwall
2016-11-7
1 个评论
Hriday Ranjan
2020-9-25
Hi Anders Ekwall,
Did you find the solution of this problem, i am facing the same issue.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model References 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!