Skip to content

Integer Math

The Integer Math components provide mathematical functions for integer data, allowing bitwise mathematical operations.

This group includes the following components:

This group also includes the following components, if RPvdsEx Device Setup is configured for a high performance device, such as the RXn or RZn:

FromBits

Description:

Converts bit format to an integer value. See ToBits.

Name Description Data Type
Inputs Input Logic
Output Integer calculated from Logical Inputs Integer
Rst Resets output to zero Logic

Equation:

I1 = L0-7 Bit-mask

Example(s):

B0=1, B1=1, B2=1, B3=0, B4=0, B5=0, I1=7

B0=1, B1=0, B2=0, B3=0, B4=1, B5=1, I1=49

B0=1, B1=1, B2=1, B3=1, B4=1, B5=1, I1=63

iAbsVal

Description:

Computes the absolute value of the signal.

Name Description Data Type
Input Input Integer
Output Absolute value of Input Integer

Equation:

Io = |Ii|

Example(s):

AbsVal (-2) = 2

AbsVal (2) = 2

iAnd

Description:

Bitwise AND function. Bitwise AND of integer input and N.

Name Description Data Type
Input Input Integer
Output Bitwise AND function Integer
N Decimal value for doing Bitwise conversion Integer

Equation:

Io = Ii AND N1

Example(s):

7(0000 0111) AND 3 (0000 0011)= 3

7(0000 0111) AND 9 (0000 1001)= 1

iBitShift

Description:

Bit shifts input by N bits. Positive N bit shifts to the left negative shifts to the right.

Name Description Data Type
Input Input Integer
Output Input shifted by N bits Integer
N Decimal value for doing Bit shift Integer

Equation:

Io = Ii * 2N1

Example(s):

N=1; iBitShift (20) = 40

iCompare

Description:

Compares input to K using specified Test and reports TRUE or FALSE as logic High or Low respectively. Test can be EQ: Equal; NE: Not Equal; GT: Greater Than; LT: Less Than; GE: Greater than or Equal to; LE: Less than or equal to. Can be thought of as an If... statement.

Name Description Data Type
Input Input Integer
Output One if test is true 0 if test is false Logic
K Test value Integer
Test Compare type: EQ: Equal; NE: Not Equal; GT: Greater Than; LT: Less Than; GE: Greater than or Equal to; LE: Less than or equal to Static

Equation:

Io = iCompare (Ii Test K)

Example(s):

K = 20; Test Eq; When Ii = 20, Io =1, otherwise Io =0;

K=20; Test GT; When Ii > 20, Io =1; otherwise Io =0;

iLimit

Description:

Limits the signal to the Maximum and Minimum levels specified. If the input signal is greater than the Max value then the signal out is the Max value. If the input signal is less than the Min value then the signal out is the Min value. If the input signal is between the Min and Max values it is passed through as the signal output without change.

Important!: If Max is defined as a value less than the defined Min value, the output will always be the defined Min, regardless of the input value.

Name Description Data Type
Input Input Integer
Output Value no less than Min and no greater than Max Integer
Max Maximum input value Integer
Min Minimum input value Integer

Equation:

If Fi > D1 then Fo = D1

Else If D2 <= Fi <= D1 then Fo = Fi

Else If Fi < D2 then Fo = D2

iNot

Description:

Inverts bits of integer value.

Name Description Data Type
Input Input Integer
Output Bit-Inverted value of Input Integer

Equation:

Io = NOT (Ii)

Example(s):

NOT (0x000F) = 0xFFF0

NOT(7)=-8

iOr

Description:

Bitwise OR function.

Name Description Data Type
Input Input Integer
Output Bitwise OR function Integer
N Decimal value for doing Bitwise OR Integer

Equation:

Io = Ii OR N1

Example(s):

7(0000 0111) OR 3 (0000 0011)= 7

7(0000 0111) OR 9 (0000 1001)= 15

iScaleAdd

Description:

Multiply signal by scale factor and add shift factor. The SF parameter can be used to apply a simple scalar, or modulate a signal. The Shift parameter can be used to place a DC shift on a signal or add two signals together.

Name Description Data Type
Input Input Integer
Output Scaled plus add value of Input Integer
SF Scale factor (multiply) Integer
Shift DC offset adds a value after SF Integer

Equation:

Output = (Input* SF) + Shift

iSign

Description:

This component determines the sign of the input.

Name Description Data Type
Input Input Integer
Output Sign of Input value (-1,0,1) Integer

Equation:

If Ii < 0 then Io = -1

Else If Ii = 0 then Io = 0

Else If Ii > 0 then Io = 1

iXor

Description:

Output is changed based on the bit-form of the parameter value using an exclusive OR bit mask. Exclusive OR only includes those bit-values that have a single 1. See the examples below.

Name Description Data Type
Input Input Integer
Output Bitwise XOR function Integer
N Decimal value for doing Bitwise OR Integer

Equation:

Io = Ii IXOR (Np )

Example(s):

7(0000 0111) IXOR 1 (0000 0001) = 6

7(0000 0111) IXOR 7(0000 0111) = 0

14(0000 1110) IXOR 7 (0000 0111) = 9

MCiAnd

Description:

Multi-channel bitwise AND function. Bitwise AND of integer input and N.

Name Description Data Type
Input Multi-channel Input Integer
Output Bitwise AND function Integer
N Decimal value for doing Bitwise conversion Integer

Equation:

Io = Ii AND N1

Example(s):

7(0000 0111) AND 3 (0000 0011)= 3

7(0000 0111) AND 9 (0000 1001)= 1

MCiOr

Description:

Multi-channel bitwise OR function.

Name Description Data Type
Input Multi-channel Input Integer
Output Bitwise OR function Integer
N Decimal value for doing Bitwise OR Integer

Equation:

Io = Ii OR N1

Example(s):

7(0000 0111) OR 3 (0000 0011)= 7

7(0000 0111) OR 9 (0000 1001)= 15

MCiShift

Description:

Bit shifts the multi-channel input by N bits. Positive N bit shifts to the left negative shifts to the right.

Name Description Data Type
Input Multi-channel Input Integer
Output Inputs shifted N bits Integer
N Decimal value for doing Bit shift Integer

Equation:

Io = I1 * 2N1

Example(s):

N=1; MCiShift (20) = 40

ToBits

-

Description:

Converts the first 6 bits of an Integer to a series of logical outputs. Values greater than 63 and less than 0 may give unexpected results. See FromBits.

Note:

The b0 output is a primary output on the ToBits component. The b1 through b5 outputs are secondary. This may cause a problem when connecting b1 through b5 to logic inputs requiring a primary input (e.g. And, Or etc.). Use a ConstL between the two components to solve this problem.

Name Description Data Type
Input Input Integer
Outputs Logical values from Integer input Integer
Rst Resets outputs to zero Logic

Equation:

Io = Ii Bit-mask

Example(s):

Ii=7: B0=1, B1=1, B2=1, B3=0, B4=0, B5=0

Ii=2001: B0=1, B1=0, B2=0, B3=0, B4=1, B5=0

Ii=-1: B0=1, B1=1, B2=1, B3=1, B4=1, B5=1