Verification of Code Generation Assumptions - MATLAB & Simulink (original) (raw)
Main Content
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: char (ProdBitPerChar)short (ProdBitPerShort)int (ProdBitPerInt)long (ProdBitPerLong)If Support long long (ProdLongLongMode) is selected, number of bits per long longFor each data type, the preprocessor check is not performed if the number of bits exceeds these settings for the target C preprocessor: For signed integer math,TargetPreprocMaxBitsSint.For unsigned integer math,TargetPreprocMaxBitsUint. | Error if data type sizes for model and target hardware do not match. |
Run-time | Number of bits per: char (ProdBitPerChar)short (ProdBitPerShort)int (ProdBitPerInt)long (ProdBitPerLong) | Error if data type sizes for model and target hardware do not match. |
If Support long long (ProdLongLongMode) is selected, number of bits per long long | Error if: Target hardware does not support long long.Data type sizes for model and target hardware do not match. | |
Size of: floatdoubleYou 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 double, warning is generated if size of target hardware data type is not 32 or 64 bits. | |
Number of bits per: pointer (ProdBitPerPointer)size_t (ProdBitPerSizeT)ptrdiff_t (ProdBitPerPtrDiffT) | Error if data type sizes for model and target hardware do not match. | |
Signed integer division rounds to (ProdIntDivRoundTo) setting | Warning if model parameter setting isUndefined.Error if target hardware behavior is undefined and model parameter setting is notUndefined.Error if target hardware behavior is defined but settings for model and target hardware do not match. | |
Byte ordering (ProdEndianess) setting | Warning if setting isUnspecified. Otherwise, error if settings for model and target hardware do not match. | |
Shift right on a signed integer as arithmetic shift (ProdShiftRightIntArith) setting | Error if settings for model and target hardware do not match. | |
Remove root level I/O zero initialization (ZeroExternalMemoryAtStartup) setting | Warning if ZeroExternalMemoryAtStartup is 'off' and initial values of global variables in the target application are not zero. | |
Remove internal data zero initialization (ZeroInternalMemoryAtStartup) setting | Warning if ZeroInternalMemoryAtStartup is 'off' and initial values of global variables in the target application are not zero. | |
Use dynamic memory allocation for model initialization (GenerateAllocFcn) setting | Warning if GenerateAllocFcn is'on' and initial values of dynamically allocated memory in the target application are not zero. | |
Simulation behavior for denormal numbers (DenormalBehavior) setting | Error if behavior for model and target hardware does not match. |
See Also
Hardware Implementation Pane | Suppress generation of fixed-point word size checks