Simulink CodeGeneration Assertion Fail

14 views (last 30 days)
Berkan Uzunoglu
Berkan Uzunoglu on 22 Nov 2021
Edited: Abhas on 30 Nov 2024
Hi everyone,
I am using Matlab R2019B (update 7). Right now, I am trying to run Model-in-the-Loop (MIL) simulations for our project; however, I faced with an error. I googled the error and searched in Matlab Community, but I could not see exactly same error. I shared the error at below.
I would be grateful if you can help me or guide me to overcome the issue.
Thanks in advance.
Code generation assertion 'nullptr != mdlVar' failed in 'b:\matlab\src\slcg_impl\rtwcg\rtwcgsignal.cpp:974'
[ 0] 0x0000000009c263a1 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11232161 sl_pir::copyContentBetweenModels+00532065
[ 1] 0x0000000009c2860c C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11240972 sl_pir::copyContentBetweenModels+00540876
[ 2] 0x0000000009c24b71 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11225969 sl_pir::copyContentBetweenModels+00525873
[ 3] 0x00000000098d6f12 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+07761682 ssSetOutputSupportHalfPrecisionDataType+00045858
[ 4] 0x0000000100bf1ab7 C:\Program Files\MATLAB\R2019b\bin\win64\rtwcg.dll+04987575 RTWCG::RTWCGCtx::constructCode+00002935
[ 5] 0x00000000098d2498 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+07742616 ssSetOutputSupportHalfPrecisionDataType+00026792
[ 6] 0x0000000009fc8929 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+15042857 BlockSetLocation+00036553
[ 7] 0x0000000009c7ae0b C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11578891 sleGetRTWBlockForSLBlock+00024139
[ 8] 0x0000000009c791a7 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11571623 sleGetRTWBlockForSLBlock+00016871
[ 9] 0x0000000009c56d20 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11431200 sl_pir::copyContentBetweenModels+00731104
[ 10] 0x0000000009c5b026 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11448358 sl_pir::copyContentBetweenModels+00748262
[ 11] 0x0000000009c5708d C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11432077 sl_pir::copyContentBetweenModels+00731981
[ 12] 0x0000000009c4b6a3 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11384483 sl_pir::copyContentBetweenModels+00684387
[ 13] 0x0000000009cb1076 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11800694 MaskInterface::getStandaloneDialogUDI+00136630
[ 14] 0x0000000009cba2fe C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+11838206 MaskInterface::getStandaloneDialogUDI+00174142
[ 15] 0x00000000099d1e30 C:\Program Files\MATLAB\R2019b\bin\win64\libmwsimulink.dll+08789552 slFullGetParam+00003200
### Build procedure for model: 'GC' aborted due to an error.
Code generation assertion 'nullptr != mdlVar' failed in 'b:\matlab\src\slcg_impl\rtwcg\rtwcgsignal.cpp:974'.
Component:Simulink | Category:Model error
Error while bringing model references of model RW_MILmdl up to date: see errors reported above for details.
  2 Comments
Afraa Ibtissem Derbal
Afraa Ibtissem Derbal on 14 Apr 2022
Hello, i am having the same problem, did you find a solution to it please ?
Nagaraju
Nagaraju on 15 Oct 2024
change model configuration parameter : BusAssignmentInplaceUpdate --> off

Sign in to comment.

Answers (1)

Abhas
Abhas on 30 Nov 2024
Edited: Abhas on 30 Nov 2024
I recently encountered a similar issue while running Model-in-the-Loop (MIL) simulations in MATLAB. After some research and troubleshooting, I found a MathWorks bug report that matches the problem and provides a clear resolution: https://www.mathworks.com/support/bugreports/2093493?s_tid=srchtitle_support_results_1_%20BusAssignmentInplaceUpdate%20
The issue you are experiencing appears to be caused by the "Bus Assignment block" in conjunction with the "BusAssignmentInplaceUpdate" configuration parameter being enabled. Here's the detailed breakdown:
Problem:
Generated code can fail or produce incorrect results when the following conditions are met:
  1. Your model contains a "Bus Assignment block".
  2. The "BusAssignmentInplaceUpdate" parameter is selected in the configuration settings.
  3. The input signal to the Bus Assignment block is fed into a subsystem or Stateflow chart.
  4. In the subsystem or Stateflow block's "Code Generation" tab, the "Function packaging" parameter is set to "Auto" or "Nonreusable function".
This can lead to assertion failures during code generation, such as the one you provided:
Solution:
The suggested workaround is to disable the "BusAssignmentInplaceUpdate" blocks parameter. Here's how to apply the fix:
  1. Open your Simulink model.
  2. Go to the "Model Configuration Parameters" dialog box.
  3. Navigate to the "Optimization" tab.
  4. Under the "Signal and State" section, locate the "BusAssignmentInplaceUpdate" parameter.
  5. Clear this parameter (uncheck the box).
  6. Save your model and attempt to re-run the MIL simulation.
You may follow the below link to know more about "BusAssignmentInplaceUpdate" parameter: https://www.mathworks.com/help/ecoder/ref/performinplaceupdatesforassignmentandbusassignmentblocks.html

Categories

Find more on Test Model Components in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!