How can I get rid of the dead code generated from a division block using Simulink Coder and Polyspace Client for C/C++ 8.4 (R2012b)?
3 次查看(过去 30 天)
显示 更早的评论
In our application we can't have deadcode. When generating code from a division block in my Simulink model, Polyspace found dead code in the generated code.
Please see attached screenshot for Polyspace report on the dead code.
How can I optimize this away?
采纳的回答
MathWorks Support Team
2013-1-18
By default, Simulink Coder tries to generate defensive code to cover edge cases. In doing so, sometimes it generates dead code.
The way to avoid generating defensive code against division by 0 is through the Optimization panel of the Configuration Parameters Window.
First, bring up Configuration Parameters Window by pressing Ctrl+E or go to Simulink menu -> Simulation -> Model Configuration Parameters.
Then, you can select the Optimization tab on the menu on the left panel. On the right panel, under Code generation -> Integer and fixed-point, please check the third check-box.
It should say "Remove Code that protects against division arithmetic exceptions"
Please see attached screenshot for illustration of the instruction above.
With the above optimization checked, there should no longer be dead code generated for the Division block.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bug Finder Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!