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 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 18 Gen 2013
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.

Più risposte (0)

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by