Integer Arithmetic Node
Note |
|---|
The settings in this node affect neither physical nor quantized experiments nor Object Based Controller Physical. |
This node contains the following options:
In this combo box, you select the set of arithmetic services you want to use. The combo box lists all sets available in the services.ini file of the current target; in addition, you can select <None> to switch off the use of arithmetic services.
Use the Edit button to open the services.ini file in a text editor.
Maximum bit Length (int)
Determines whether the code generated for integer variables uses 8, 16 or 32 bit arithmetic in the expressions for fixed-point arithmetic.
Use SHIFT Operation on Signed Values Instead of DIV Operation
Generates right shifts instead of division operations for divisions of signed numbers (default: deactivated).
Some compilers use logical instead of arithmetic right shifts. This may lead to sign errors if the option is not deactivated.
Note |
|---|
Enabling this option will cause the generated code to violate MISRA-C:2012 Rule 10.1, rationale 6. |
Generate Round Operation on float to integer Assignment
Activates or deactivates rounding when a floating-point variable is assigned to an integer variable. Rounding is done by adding (positive values) or subtracting (negative values) 0.5. If the option is deactivated, the decimal places are truncated (default: activated).
Generate Float Limiter on Assignment (may be changed locally)
If Generate Float Limiter on Assignment is activated, the following happens to modifiable elements (variable, message, etc.) with real*1 implementation data type:
If Limit Assignment is activated in an element's implementation, assignments to this element are limited to the model interval. If the lower bound is -oo, no limitation is generated for the lower bound. If the upper bound is +oo, no limitation is generated for the upper bound. The generated limiter code can optionally be replaced by limit services.
If the initial value the element is outside the model interval specified in the implementation, a warning WMdl7 is issued during code generation.
If Limit Assignment is deactivated, assignments to the element are not limited.
If Generate Float Limiter on Assignment is activated, the following happens to non-modifiable elements (normal or user-defined system constant) with real* implementation data type:
If the initial value of an element with real* implementation data type is outside the model interval specified in the implementation, an error MMdl44 is issued during code generation.
If Generate Float Limiter on Assignment is deactivated, assignments to modifiable elements (variable, message, etc.) with real* implementation data type are not limited. A warning (WIa181, WIa182, WIa183, WIa184) is issued if a range violation may occur.
Optimize Float limiters for Non-Integer ImplTypes
If this option is enabled, ASCET checks the possible ranges of assignments to modifiable elements (variable, message, etc.) with real*2 implementation data type. Limitation code is generated only if the possible range exceeds the range of the target element.
Checks for upper and lower limit are done independently so that the code for each boundary is optimized separately.
Temp Vars always 32 bit (integer)
Creates 32 bits for all temporary integer variables. If this option is deactivated, bit widths are generated flexible, depending on the actual requirements (default: deactivated).
Use power of 2 approximations when dividing by a literal
If the option is activated, the code generation searches, for multiplications and divisions with fractions, another fractions approximation where either numerator or denominator is a power of 2.
The optimization is applied only if an approximation is found that deviates at most 1 ‰ from the original fraction, and if the approximated literal induces no overflow.
You can set a threshold for the relative deviation of the approximation in the ASCET Options window, Build node, Warning threshold for power of two literals option. When the relative error exceeds this threshold, a warning WIle18 is issued during code generation.
EXAMPLE |
|---|
New Behaviour for Discrete Types
If activated, the generation of sdisc and udisc calculations is changed as follows, so that the elements behave like limitInt or wrapInt:
- If the Limit Assignments option in the implementation editor is activated, the calculations are generated as specified in the model, with limitation on assignment. An error is issued if the calculation may overflow.
If the Limit Assignments option in the implementation editor is deactivated, the calculations are generated as specified in the model, and they wrap around on overflow, both during calculations and on assignments.
Calculations with a potentially changed behavior are indicated by warnings of types WIle110, WIle111, WIle112, WIle113, WIle114, WIle115.
See also Testing the New Behavior for Integer Types.
See also
EXAMPLE