Verification of Code Generation Assumptions
At the start of a software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation, the software verifies some configuration parameter settings with reference to the target hardware.
For example, in the Configuration Parameters dialog box, the Hardware Implementation settings specify target behavior, which result in the implementation of implicit assumptions in the generated code. Incorrect settings can lead to:
Suboptimal code
Code execution failure, incorrect code output, and nondeterministic code behavior
The software checks:
The correctness of settings. For example, the integer bit length in the Number of bits: int field.
Whether the settings are optimized. For example, the rounding of signed integer division in the Signed integer division rounds to field.
The simulation generates a Coder Assumptions page for the code generation report, which provides a list of:
Code generation assumptions that are checked
Expected results for the assumption checks
This table shows when checks occur and outcomes when code generation assumptions are incorrect.
Stage | What is Checked | Outcome |
---|---|---|
Preprocessor | Number of bits per:
If Support long
long ( For each data type, the preprocessor check is not performed if the number of bits exceeds these settings for the target C preprocessor:
| Error if data type sizes for model and target hardware do not match. |
Run-time | Number of bits per:
| Error if data type sizes for model and target hardware do not match. |
If Support long long
( | Error if:
| |
Size of:
You cannot configure these data type sizes through the Hardware Implementation pane. The check is performed only if Support: floating-point numbers is selected. | Warning if data type sizes for model and target hardware do not match. For | |
Number of bits per:
| Error if data type sizes for model and target hardware do not match. | |
Signed integer division rounds to
( | Warning if model parameter setting is
Error if
target hardware behavior is undefined and model parameter
setting is not
Error if target hardware behavior is defined but settings for model and target hardware do not match. | |
Byte ordering
( | Warning if setting is
| |
Shift right on a signed integer as arithmetic
shift ( | Error if settings for model and target hardware do not match. | |
Remove root level I/O zero
initialization
( | Warning if | |
Remove internal data zero
initialization
( | Warning if | |
Use dynamic memory allocation for model
initialization
( | Warning if | |
Simulation behavior for denormal
numbers ( | Error if behavior for model and target hardware does not match. |
See Also
Hardware Implementation Pane | Suppress generation of fixed-point word size checks