08-03-2012, 10:22 AM
The underlying reason for these rules is to maximize the likelihood of the generated code being of the form intended, and maintain the greatest level of control over the generated code, by the model developer. In the Stateflow environment there is generally reduced capability to tailor the content, to affect the generated code, and more is left to the discretion of the code generator.
Application of 38B will persuade the developer to implement any more complex functionality in the Simulink domain where there is more scope to ensure the generated code is as expected, especially with respect to data typing and scaling application across operations. 48A reinforces that, but also rules out using complex MATLAB functions for which generated code could easily be considerably more lengthy and complex than expected, e.g. a simple looking expression like inv(A) can yield more complex code than the developer might expect and, more importantly, it could lead to unexpected consequences that are hard to deal with; what happens if A is a singular matrix?
However, neither of the guidelines completely rule out the use of MATLAB functions. If you believe there is a legitimate need for using simple functions, like min and max, for which you can easily demonstrate that the generated code is robust and without unexpected side-effects, then it is legitimate to raise a formal deviation against 48A, as per Section 2.2 of MISRA AC SLSF.
Application of 38B will persuade the developer to implement any more complex functionality in the Simulink domain where there is more scope to ensure the generated code is as expected, especially with respect to data typing and scaling application across operations. 48A reinforces that, but also rules out using complex MATLAB functions for which generated code could easily be considerably more lengthy and complex than expected, e.g. a simple looking expression like inv(A) can yield more complex code than the developer might expect and, more importantly, it could lead to unexpected consequences that are hard to deal with; what happens if A is a singular matrix?
However, neither of the guidelines completely rule out the use of MATLAB functions. If you believe there is a legitimate need for using simple functions, like min and max, for which you can easily demonstrate that the generated code is robust and without unexpected side-effects, then it is legitimate to raise a formal deviation against 48A, as per Section 2.2 of MISRA AC SLSF.
<t></t>