Arithmetic Blocks

Build the calculation into the system.

Explore arithmetic components in the general-block library. Keep supported operations, data types, and port definitions together when building a calculation.

Arithmetic Block Models

General_Expression

General Expression

Description

General_Expression provides a capability to generate an output
which is a function of the data received at the input ports
and specified constants, Variables or Macros. The number of
input ports and the naming of the input ports is arbitrary
(in1 is provided as a default). A variety of operators may
be used, including:        +, -, *, /, %,
         RANDOM, SQRT(x), LOG(x), EXP(x), ABS(x), TRUNC(x),
         ROUND(x), FLOAT(x), SQR(x), MIN(x,y), MAX(x,y)
 (see:
   SCHEDULER functions)

The user specifies the output function as an attribute string
for an attribute "out", for example, expressions could be:
    out = in1 * in2 * 1.0e-7
    out = in1 * in2 * in3
    out = bozo * data_rate + gandalf (assuming that bozo and
               gandalf are either inputs, variables or macros)

Because General_Expression is an interpreted rather than compiled
block, its execution time is relatively long.

Ports

Input Ports

  • in1-n            Data Type: INTEGER or REAL

Output Ports

  • real_out    Data Type: REAL
  • int_out     Data Type: INTEGER

Parameters

  • out     Data Type: General Arithmetic Expression

Reciprocal

A Rec

File: general_blocks/Arithmetic/reciprocal.sim
Description
The model inverts real input. If the input is zero, a value representing floating point infinity is placed on the output.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

tan_X

tan X

File: general_blocks/Arithmetic/real_tan.sim
Description
The model calculates the tangent of the radian argument on the port in and places the result the port out.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

R_subtract

R subtract

File: general_blocks/Arithmetic/real_subtract.sim
Description
The model subtracts in2 from in1 and places the result on the port out.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rsqrt

File: general_blocks/Arithmetic/real_sqrt.sim
Description
The model returns the Square Root of the value of in. If the value is negative then an error message will be printed in the simulation Error file and the port out will not be enabled.

Ports

Input Ports

  • in       Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

sin_X

sin X

File: general_blocks/Arithmetic/real_sin.sim
Description
The model calculates the sine of the radian argument on the port in and places the result on the port out.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

X_powr_Iconst

X powr Iconst

File: general_blocks/Arithmetic/real_raise_by_constant.sim
Description
The model is used to raise a real input by an integer power.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • Iconst Value: 50  Data Type: INTEGER

Ilimiter

File: general_blocks/Arithmetic/Ilimiter.sim
Description
Limiter for integer inputs.

Ports

Input Ports

  • in     Data Type: INTERGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • ulimit  Data Type: INTEGER
  • llimit  Data Type: INTEGER

Rlimiter

File: general_blocks/Arithmetic/Rlimiter.sim
Description
Limiter for real inputs.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • ulimit  Data Type: REAL
  • llimit  Data Type: REAL

X_powr_Y

X powr Y

File: general_blocks/Arithmetic/real_raise.sim
Description
The model is used to raise a real number (in1) to a power specified by another number (in2).

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

R_divprotect

R divprotect

File: general_blocks/Arithmetic/real_protect.sim
Description
The model divides one real number by another. If the in2 value is equal to 0.0 then the FLT_MAX is put on out.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rchs

File: general_blocks/Arithmetic/real_negate.sim
Description
The model is used to change a sign of a REAL number. The port in is multiplied by -1.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

R_mult

R mult

File: general_blocks/Arithmetic/real_multiply.sim
Description
The model multiplies the value of in1 by int2.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rmin

File: general_blocks/Arithmetic/real_min.sim
Description
The model selects the smallest of the two real input values and places it on out.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rmax

File: general_blocks/Arithmetic/real_max.sim
Description
The model selectes the largest of the two real inputs values and places it on out.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

ln_X

in X

File: general_blocks/Arithmetic/real_ln.sim
Description
The model computes the natural logarithm of in and places the value of the natural log on out.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rgain

File: general_blocks/Arithmetic/real_gain.sim
Description
The model multplies the real input by the Gain parameter.

Ports

InputPorts

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • Gain Data Type: REAL

exp_X

exp X

File: general_blocks/Arithmetic/real_exp.sim
Description
The model the function exp(x). The constant e (2.7182818..) is raised to the power specified by the input value on in. The result is placed on out.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

R_div

R div

File: general_blocks/Arithmetic/real_divide.sim
Description
The model divides the value of in1 by the value of in2 and places the result on out. If in2 is zero then a message will be written to the simulation Error file (divide by zero error).

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

cos_X

cos X

File: general_blocks/Arithmetic/real_cos.sim
Description
The model calculates the cosine of the radian argument on in.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

R_add

R add

File: general_blocks/Arithmetic/real_add.sim
Description
The model adds the value of in1 and in2.

Ports

Input Ports

  • in1     Data Type: REAL
  • in2     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

Rabs

File: general_blocks/Arithmetic/real_abs.sim
Description
The model places the absolute value of in on the port out.

Ports

Input Ports

  • in     Data Type: REAL

Output Ports

  • out     Data Type: REAL

Parameters

  • none

I_subtract

I subtract

File: general_blocks/Arithmetic/int_subtract.sim
Description
The model subtracts in2 from in1 and places the result on the port out.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out    Data Type: INTEGER

Parameters

  • none

I_divprotect

I divprotect

File: general_blocks/Arithmetic/int_protect.sim
Description
The model divides on integer number by another. If the in2 value is equal to 0, then INT_MAX is put on out.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Ichs

File: general_blocks/Arithmetic/int_negate.sim
Description
The model changes the sign of an INTEGER value. The sign is changed by multiplying in value by -1.

Ports

Input Ports

  • in     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Imult

File: general_blocks/Arithmetic/int_multiply.sim
Description
The model multiplies the integer values placed on in1 and in2, and places the product on out.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Imod

File: general_blocks/Arithmetic/int_modulus.sim
Description
The model divides the value of in1 by the value of in2 and places the quotient on the quo port and the remainder on the rem port. If the value of in2 is equal to zero, then a message will be written to the simulation error file (divide by zero error).

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • quo     Data Type: INTEGER
  • rem     Data Type: INTEGER

Parameters

  • none

I_mod

I mod

File: general_blocks/Arithmetic/int_mod.sim
Description
The model divides the value of in1 by the value of in2 and places the remainder on the out port. If the value of in2 is equal to zero, the a message will be written to the simulation error file (divide by zero error).

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Imin

File: general_blocks/Arithmetic/int_min.sim
Description
The model selects the smallest of the two integer input values and places it on out.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data TYpe: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Imax

File: general_blocks/Arithmetic/int_max.sim
Description
The model selects the largest of the two integer input values and places it on out.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Igain

File: general_blocks/Arithmetic/int_gain.sim
Description
The model multiplies the integer input value by the gain parameter.

Ports

Input Ports

  • in     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • gain     Data Type: INTEGER

I_div

I div

File: general_blocks/Arithmetic/int_divide.sim
Description
The model divides the value of in1 by the value of in2 and places the result on out. If in2 is equal to 0 then a message will be written to the simulation Error file (divide by zero error).

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

I_add

I add

File: general_blocks/Arithmetic/int_add.sim
Description
The model adds the value of in1 and in2.

Ports

Input Ports

  • in1     Data Type: INTEGER
  • in2     Data TYpe: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Iabs

File: general_blocks/Arithmetic/int_abs.sim
Description
The model places the absolute value of in on the port out.

Ports

Input Ports

  • in     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Increment

File: general_blocks/Arithmetic/increment.sim
Description
The model increments the in value by one.

Ports

Input Ports

  • in     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

  • none

Decrement

File: general_blocks/Arithmetic/decrement.sim
Description
The model decrements the in value by one.

Ports

Input Ports

  • in     Data Type: INTEGER

Output Ports

  • out     Data Type: INTEGER

Parameters

none


five_input_expression

Five Input Exp

File: general_blocks/Arithmetic/5_input_expression.sim
Description
The user can specify a function of the inputs which will be evaluated when all the inputs used in the expression are enabled.

Ports

Input Ports

  • in1     Data Type: NUMERIC
  • in2     Data Type: NUMERIC
  • in3     Data Type: NUMERIC
  • in4     Data Type: NUMERIC
  • in5     Data Type: NUMERIC

Output Ports

  • real_out     Data Type: REAL
  • int_out     Data Type: INTEGER

Parameters

  • none

one_input_expression_I

one input expression I

File: general_blocks/Arithmetic/one_input_expression_I.sim
Description
This box calculates a function of the input of the form
output = m * input + b

Ports

Input Ports

  • in     Data Type: INT

Output Ports

  • real_out     Data Type: REAL

Parameters

  • m     Data Type: REAL
  • b     Data Type: REAL

one_input_expression_R

one input expression R

File: general_blocks/Arithmetic/one_input_expression_R.sim
Description
This box calculates a function of the input of the form
output = m * input + b

Ports

Input Ports

  • in            Data Type: REAL

Output Ports

  • real_out     Data Type: REAL

Parameters

  • m     Data Type: REAL
  • b     Data Type: REAL

This page is an editorial rewrite of source documentation. Historical status, availability, and platform notes are not independently verified for a current release. Technical examples are reference material, not a live simulator.