ID: Title | hisl_0001: Usage of Abs block | ||
---|---|---|---|
Description | To support robustness of generated code, when using the Abs block, | ||
A | Avoid Boolean and unsigned data types as inputs to the Abs block. | ||
B | Select block parameter Saturate on integer overflow. | ||
Notes | The Abs block does not support Boolean data types. Specifying an unsigned input data type, might optimize the Abs block out of the generated code, resulting in a block you cannot trace to the generated code. For signed data types, Simulink® does not represent the absolute value of the most negative value. When you select Saturate on integer overflow, the absolute value of the data type saturates to the most positive representable value. When you clear Saturate on integer overflow, absolute value calculations in the simulation and generated code might not be consistent or expected. | ||
Rationale | A | Support generation of traceable code. | |
B | Achieve consistent and expected behavior of model simulation and generated code. | ||
Model Advisor Checks | Check usage of Abs blocks (Simulink Check) | ||
References |
| ||
Last Changed | R2018b | ||
Examples |
Recommended Not Recommended |
ID: Title | hisl_0002: Usage of Math Function blocks (rem and reciprocal) | ||
---|---|---|---|
Description | To support robustness of
generated code, when using the Math Function block with
remainder-after-division ( | ||
A | Protect the input of the
| ||
B | Protect the second input of the
| ||
Note | You
can get a divide-by-zero operation, resulting in an infinite
( | ||
Rationale | Protect against overflows and undefined numerical results. | ||
Model Advisor Checks | Check usage of Math Function blocks (rem and reciprocal functions) (Simulink Check) | ||
References |
| ||
Last Changed | R2017b | ||
Examples | In the following example, when the input signal oscillates around zero, the output exhibits a large change in value. You need further protection against the large change in value.
|
ID: Title | hisl_0003: Usage of Square Root blocks | ||
---|---|---|---|
Description | To support robustness of generated code, when using the Square Root block, do one of the following: | ||
A | Account for complex numbers as the output. | ||
B | Protect the input from going negative. | ||
Rationale | A, B | Avoid undesirable results in generated code. | |
Model Advisor Checks | Check usage of Sqrt blocks (Simulink Check) | ||
References |
| ||
Last Changed | R2016a | ||
Examples |
|
ID: Title | hisl_0028: Usage of Reciprocal Square Root blocks | ||
---|---|---|---|
Description | To support robustness of generated code, when using the Reciprocal Square Root block, do one of the following: | ||
A | Protect the input from going negative. | ||
B | Protect the input from going to zero. | ||
Note | You can get a divide-by-zero
operation, resulting in an | ||
Rationale | A, B | Avoid undesirable results in generated code. | |
Model Advisor Checks | Check usage of Reciprocal Sqrt blocks (Simulink Check) | ||
References |
| ||
Last Changed | R2016a | ||
Examples |
|
ID: Title | hisl_0004: Usage of Math Function blocks (natural logarithm and base 10 logarithm) | ||
---|---|---|---|
Description | To support
robustness of generated code, when using the Math
Function block with natural logarithm
( | ||
A | Protect the input from going negative. | ||
B | Protect the input from equaling zero. | ||
C | Account for complex numbers as the output value. | ||
Notes | If you set the
output data type to complex, the natural logarithm and
base 10 logarithm functions output complex values for
negative input values. If you set the output data type to
real, the functions output | ||
Rationale | A, B, C | Support generation of robust code. | |
Model Advisor Checks | Check usage of Math Function blocks (log and log10 functions) (Simulink Check) | ||
References |
| ||
Last Changed | R2017b | ||
Examples |
You can protect against:
The following example displays the
resulting output for input values ranging from
|
ID: Title | hisl_0005: Usage of Product blocks | ||
---|---|---|---|
Description | To support robustness of generated code, when using the Product block with divisor inputs, | ||
A | In
| ||
B | In | ||
Notes | When using Product blocks
for element-wise divisions, you might get a divide by zero, resulting in a
When using Product blocks to compute the inverse
of a matrix, or a matrix division, you might get a divide by a singular matrix. This
division results in a | ||
Rationale | A and B | Protect against overflows. | |
Model Advisor Checks | Adherence to this modeling guideline cannot be verified by using a Model Advisor check. | ||
References |
| ||
Prerequisites | hisl_0314: Configuration Parameters > Diagnostics > Data Validity > Signals | ||
Last Changed | R2019a |
ID: Title | hisl_0029: Usage of Assignment blocks |
---|---|
Description | To support robustness of generated code, when using the Assignment block, initialize array fields before their first use. |
Notes | If the output vector of the Assignment block is not initialized with an input to the block, elements of the vector might not be initialized in the generated code. When the Assignment block is used iteratively and all array field are assigned during one simulation time step, you do not need initialization input to the block. Accessing uninitialized elements of block output can result in unexpected behavior. |
Rationale | Avoid undesirable results in generated code. |
Model Advisor Checks | Check usage of Assignment blocks (Simulink Check) |
References |
|
Last Changed | R2016a |
Examples |
Not Recommended: No initialization input Y0 when block is not used iteratively Recommended: Initialization input Y0 when block is not used iteratively Recommended: Initialize array fields when block is used iteratively |
ID: Title | hisl_0066: Usage of Gain blocks | ||
---|---|---|---|
Description | To support traceability of generated code, the
value of the Gain block must not resolve to
1 . | ||
Notes | The code generation process
can remove Gain values equal to An exception to this rule is setting the Gain value to a named parameter data object with a non-auto storage class. | ||
Rationale | Support the generation of traceable code. | ||
Model Advisor Checks | Check usage of Gain blocks (Simulink Check) | ||
References |
| ||
Last Changed | R2018a |