Rapid Accelerator and sldrt.tlc compile issue: Code Generation and simulation targets registered different sets of persistent variables for the block.

조회 수: 7 (최근 30일)
Hello,
When I run my code with normal or accelerator mode or compile using grt.tlc my model executes succesfully. If I attempt to use rapid accelerator or sldrt.tlc, I receive this error:
Code generation and simulation targets registered different sets of persistent variables for the block. External or Rapid Accelerator mode simulation requires code generation and simulation targets to register the same set of persistent variables for this block. This discrepancy is typically caused by MATLAB functions that have different code paths for simulation and code generation targets where these code paths define different sets of persistent variables. Please identify these code paths in the offending block and rewrite the MATLAB code so that the set of persistent variables is the same between simulation and code generation.
This model is based almost entirely around stateflow and simply imports data from a binary file reader.
Things I've tried:
  1. Completely removed persistent variables from called matlab functions
  2. Followed this heirarchy for compiling matlab functions, made everything a subfunction, and then removed all extra files from the folder location. https://www.mathworks.com/help/coder/ug/how-matlab-resolves-function-calls-in-generated-code.html
  3. Tried various other compiling targets. Embedded coder returns a sizing error that I don't intend to fix currently.grt.tlc works great.
I can't find any information on the 2 seperate paths the error is referring to so I would be interested in knowing if that's a setting somewhere.

답변 (2개)

Pablo Romero
Pablo Romero 2022년 5월 31일
Please check out the following bug report.

Naomi
Naomi 2025년 3월 5일
편집: Naomi 2025년 3월 5일
Hello,
I am also having this issue but when running in real-time. @Pablo Romero the Bug report you posted above doesn't seem to work anymore, do you have an updated link for it?. I am running a real time simulation on a Speedgoat device. I am getting this error when I try to Run on Target:
Error:Error in 'Top_model/CVT_Model/Subsystem Reference/PLC/state machine/StateMachine' while executing C MEX S-function 'sf_sfun', (mdlSetWorkWidths), at time 0.0.
Caused by:
Code generation and simulation targets registered different sets of persistent variables for the block. External or Rapid Accelerator mode simulation requires code generation and simulation targets to register the same set of persistent variables for this block. This discrepancy is typically caused by MATLAB functions that have different code paths for simulation and code generation targets where these code paths define different sets of persistent variables. Please identify these code paths in the offending block and rewrite the MATLAB code so that the set of persistent variables is the same between simulation and code generation.
The StateMachine which is supposed to be giving the error is a stateflow block. However I cannot find the above mentioned function (C MEX S-function 'sf_sfun', (mdlSetWorkWidths)) anywhere inside it (visual search and search with Matlab).
Similarly to David above, I have noticed that if I run the model locally in Normal or Accelerator mode, it works. However if I run locally in Rapid Accelerator mode, I get the same error as running in Real-time.
Any ideas?

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by