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:

Arithmetic Service Set

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 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 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.

ClosedEXAMPLE

If the option is deactivated (default), the following code is generated:

result = input * (sint32)433 / (sint16)500;

If the option is activated, the generated code becomes

result = input * 28377 >> 15;

The precision is almost identical in both cases, but the runtime-consuming division operation is replaced by an effective and fast shift.

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:

See also Testing the New Behavior for Integer Types.

See also

Arithmetic Services

Testing the New Behavior for Integer Types