Expressions are constructed from operands and operators. The operators of an expression indicate which operations to apply to the operands. The order of evaluation of operators in an expression is determined by the precedence and associativity of the operators.

Numerical values

A numeric value can be an integer (e.g. 12, -44), a floating point number (3.14159), an integer or floating point number followed by an integer exponent (1e-14, 2.65e3), or an integer or floating point number followed by one of the following scale factors:

Suffix Scale factor Description
f, F 10-15 femto
p, P 10-12 pico
n, N 10-9 nano
u, U, µ 10-6 micro
MIL 25.4*10-6 mil
m, M 10-3 milli
k, K 103 kilo
MEG 106 mega
g, G 109 giga
t, T 1012 tera

Letters immediately following a number that are not scale factors are ignored, and letters immediately following a scale factor are ignored. Hence, 10, 10V, 10Volts, and 10Hz all represent the same number, and M, MA, MSec, and MMhos all represent the same scale factor. Note that 1000, 1000.0, 1000Hz, 1e3, 1.0e3, 1KHz, and 1K all represent the same number.

Note Note

There will be no distinction between uppercase and lowercase characters. You should be using MEG to indicate 106. The suffix m or M is always interpreted as milli (10-3). Scale suffixes must be entered immediately after the number, spaces between the number and scale suffixes are not allowed.


Boolean values

Relational operators, equality and boolean operators consider the value zero as false and any non-zero value as true.


Arithmetic operators

Operator Description Type Example
- Unary minus Unary -x
+ Addition Binary y+x
- Subtraction Binary y-x
* Multiplication Binary y*x
/ Division Binary y/x
\
DIV
Integer division Binary y\x
%
MOD
Modulus (remainder after integer division) Binary y%x
^ Exponentiation. xy. The same function as the POW(x, y). Binary x^y
** Exponentiation. |x|y. The same function as the PWR(x, y). This operator is defined only for compatibility with the models developed for PSPICE. Do not use in expressions relating to generators of type B. Binary x**y


Relational operators

These operators produce a result equal to 0.0 if the relation is false and 1.0 if the relation is true.

Operator Description Type
< Define a "less than" relational operator that returns 1.0 if the first operand is less than the second, 0.0 otherwise Binary
> Define a "greater than" relational operator that returns 1.0 if the first operand is greater than the second, 0.0 otherwise Binary
<= Define a "less than or equal" relational operator that returns 1.0 if the first operand is less than or equal to the second, 0.0 otherwise Binary
>= Define a "greater than or equal" relational operator that returns 1.0 if the first operand is greater than or equal to the second, 0.0 otherwise Binary


Equality operators

These operators produce a result equal to 0.0 if the relation is false and 1.0 if the relation is true.

Operator Description Type
== The equality operator returns 1.0 if the values of its operands are equal, 0.0 otherwise Binary
!=
<>
The inequality operator returns 0.0 if its operands are equal, 1.0 otherwise Binary


Boolean operators

These operators produce a result equal to 0.0 (FALSE) or 1.0 (TRUE). The value of the operands is:

FALSE if operand is zero
TRUE if operand is not zero

Operator Description Type
&&
AND
Computes the boolean AND of its operands; that is, the result is true (1.0) if and only if both its operands are true. Binary
NAND Computes the boolean NAND of its operands; that is, the result is false (0.0) if and only if both its operands are true. Binary
||
OR
Computes the boolean OR of its operands; that is, the result is false (0.0) if and only if both its operands are false. Binary
NOR Computes the boolean NOR of its operands; that is, the result is true (1.0) if and only if both its operands are false. Binary
XOR Computes the boolean XOR of its operands; that is, the result is true (1.0) if and only if inputs differ (one is true, the other is false).
Binary
!
NOT
Boolean negation operator is a unary operator that negates its operand. It returns true (1.0) if and only if its operand is false. Unary


Logical operators

These operators produce a result equal to LZERO (FALSE) or LONE (TRUE). The value of the operands is:

LONE if operand >= VTHRESH
LZERO if operand < VTHRESH

The parameters VTHRESH, LONE and LZERO are set in Simulator options.

Operator Description Type
& Computes the logical AND of its operands; that is, the result is true (LONE) if and only if both its operands are true (LONE) Binary
| Computes the logical OR of its operands; that is, the result is false (LZERO) if and only if both its operands are false (LZERO) Binary
~ Logical negation operator is a unary operator that negates its operand. It returns true (LONE) if and only if its operand is false (LZERO) Unary


Constants

Name Description Value
BOLTZ Boltzman constant 1.38062-23
C The speed of light 2.9979258
E The constant base of the natural logarithm 2.718...
FALSE False 0.0
ECHARGE The charge of an electron 1.60219-19
KELVIN Absolute zero in °C -273.15
LN10 The natural logarithm of 10 2.302...
LN2 The natural logarithm of 2 0.693...
LOG10E The base-10 logarithm of e 0.434...
LOG2E The base-2 logarithm of e 1.442...
PI The constant pi 3.141...
PLANCK Planck's constant 6.62620-34
SQRT2 The square root of 2 1.414...
TRUE True 1.0
TWOPI The constant pi * 2 6.282...


Variables

Name Description
TIME The current time in transient analysis.
TEMP Current temperature.
GMIN The lowest permissible conductance, can be set using the option GMIN.
FREQ The current AC frequency in radians.
VT Thermal voltage (k•T/q = 1.38E-23•T/1.602E-19)


Functions

If the argument of log(), ln(), or sqrt() becomes less than zero, the absolute value of the argument is used. If a divisor becomes zero or the argument of log() or ln() becomes zero, an error will result. Other problems may occur when the argument for a function in a partial derivative enters a region where that function is undefined.

Function Description
ABS(x) Absolute value of x
ACOS(x) Inverse cosine of x
ACOSH(x) Inverse hyperbolic cosine of x
ASIN(x) Inverse sine of x
ASINH(x) Inverse hyperbolic sine of x
ATAN(x)
ARCTAN(x)
Inverse tangent of x
ATANH(x) Inverse hyperbolic tangent of x
ATAN2(x,y) Arctan of x/y
CEIL(x) Return the smallest integer that is greater than or equal to x
COS(x) Cosine of x
COSH(x) Hyperbolic cosine of x
DEG(x) Converts the value of x from radians to degrees
EXP(x) Exponential ex
FLOOR(x) Return the largest integer that is less than or equal to x
IF(x,a,b) If x is different from zero returns a, otherwise returns b. The discontinuity created by the two branches of the operator IF can cause convergence problems
LIMIT(x,min,max) Returns min if x<min, returns max if x>max, otherwise returns x
LN(x) Return the natural logarithm of x. If the argument becomes less than zero, the absolute value of the argument is used. If the argument becomes zero, an error will result.
LOG(x) If is included in an expression of an element of type B then calculates the decimal logarithm. If is included in an expression of an element of type E or G then calculates the natural logarithm. If the argument becomes less than zero, the absolute value of the argument is used. If the argument becomes zero, an error will result.
LOG10(x) Return the decimal logarithm of x. If the argument becomes less than zero, the absolute value of the argument is used. If the argument becomes zero, an error will result.
MAX(a,b) Maximum of a and b
MIN(a,b) Minimum of a and b
POW(x,y)  xy. Same as x^y.
PWR(x,y)  |x|y
PWRS(x,y) If x > 0 return |x|y.
If x < 0 return -|x|y
RAD(x) Converts the value of x from degrees to radians
ROUND(x) Return the nearest integer to x
SGN(x) If  x < 0 return -1. If x > 0 return 1. If x = 0 return 0
SIN(x) Sine of x
SINH(x) Hyperbolic sine of x
SQRT(x) Return the square root of x. If the argument becomes less than zero, the absolute value of the argument is used.
STP(x) If x < 0 return 0, 1 otherwise
TABLE(x,x1,y1,x2,y2...xn,yn) Return the y value corresponding to x. The value of y is calculated by linear interpolation between the pairs of values ​​xn, yn of the table. If x is greater than the max xn, then the value is the yn associated with the largest xn. If x is less than the smallest xn, then the value is the yn associated with the smallest xn.
TAN(x) Tangent of x
TANH(x) Hyperbolic tangent of x
U(x) If x < 0 return 0, 1 otherwise
URAMP(x) If x < 0 return 0, x otherwise
Note Note

The argument of the trigonometric functions are in radians.

The function LOG(x) has a dual behavior. In fact, it calculates the decimal logarithm in SPICE3 while in PSPICE computes the natural logarithm. The function LOG(x) has a different behavior depending on the type of element containing the expression. If LOG(x) is included in an expression of an element of type B then calculates the decimal logarithm. If LOG(x) is included in an expression of an element of type E or G then calculates the natural logarithm. In PSPICE elements of type B does not correspond to the generators and in SPICE3 elements of type E and G do not accept an arbitrary function.


Bit-a-Bit Functions

The following functions convert their arguments in 32-bit integers.

Function Description
BITNOT(x) Binary NOT.
BITAND(x,y) Binary AND.
BITOR(x,y) Binary OR.
BITXOR(x,y) Binary XOR.
BITODD(x) The output is 1 when an odd number of bits is 1.
BITEVEN(x) The output is 1 when an even number of bits is 1.
BITSHL(x,n,w,m) Shift left of w bits of the number x repeated n times. m is reload mode: 0=0, 1=1, 2=keeps the bit, 3=keeps and inverts the bit, 4=rotates the opposite bit, 5=rotates and inverts the opposite bit.
BITSHR(x,n,w,m) Shift right of w bits of the number x repeated n times. m is reload mode: 0=0, 1=1, 2=keeps the bit, 3=keeps and inverts the bit, 4=rotates the opposite bit, 5=rotates and inverts the opposite bit.

Examples

B1 0 1 I=cos(v(1))+sin(v(2))
B1 0 1 V=ln(cos(log(v(1,2)^2)))-v(3)^4+v(2)^v(1)
B1 3 4 I=17
B1 3 4 V=exp(pi^i(vdd))

See also

Non-linear Dependent Sources