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 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 18 de En. de 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.

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by