Built-In Functions

In addition to simple arithmetic operations (+, -, *, /), Star-Hspice provides a number of built-in functions that you can use in expressions. The Star-Hspice built-in functions are listed in Star-Hspice Built-in Functions.

Table 7-2: Star-Hspice Built-in Functions

HSPICE Form

Function

Class

Description

sin(x)

sine

trig

Returns the sine of x (radians)

cos(x)

cosine

trig

Returns the cosine of x (radians)

tan(x)

tangent

trig

Returns the tangent of x (radians)

asin(x)

arc sine

trig

Returns the inverse sine of x (radians)

acos(x)

arc cosine

trig

Returns the inverse cosine of x (radians)

atan(x)

arc tangent

trig

Returns the inverse tangent of x (radians)

sinh(x)

hyperbolic sine

trig

Returns the hyperbolic sine of x (radians)

cosh(x)

hyperbolic cosine

trig

Returns the hyperbolic cosine of x (radians)

tanh(x)

hyperbolic tangent

trig

Returns the hyperbolic tangent of x (radians)

abs(x)

absolute value

math

Returns the absolute value of x: |x|

sqrt(x)

square root

math

Returns the square root of the absolute value of x: sqrt(-x) = -sqrt(|x|)

pow(x,y)

absolute power

math

Returns the value of x raised to the integer part of y: x(integer part of y)

pwr(x,y)

signed power

math

Returns the absolute value of x raised to the y power, with the sign of x: (sign of x)|x|y

log(x)

natural logarithm

math

Returns the natural logarithm of the absolute value of x, with the sign of x: (sign of x)log(|x|)

log10(x)

base 10 logarithm

math

Returns the base 10 logarithm of the absolute value of x, with the sign of x: (sign of x)log10(|x|)

exp(x)

exponential

math

Returns e raised to the power x: ex

db(x)

decibels

math

Returns the base 10 logarithm of the absolute value of x, multiplied by 20, with the sign of x:
(sign of x)20log10(|x|)

int(x)

integer

math

Returns the integer portion of x. The fractional portion of the number is lost.

sgn(x)

return sign

math

Returns -1 if x is less than 0, 0 if x is equal to 0, and 1 if x is greater than 0

sign(x,y)

transfer sign

math

Returns the absolute value of x, with the sign of y: (sign of y)|x|

min(x,y)

smaller of two args

control

Returns the numeric minimum of x and y

max(x,y)

larger of two args

control

Returns the numeric maximum of x and y

lv(<Element>)
or
lx(<Element>)

element templates

various

Returns various element values during simulation. See "Element Template Output" in Chapter 7 for more information.

v(<Node>), i(<Element>)...

circuit output variables

various

Returns various circuit values during simulation. See DC and Transient Output Variables for more information.

Star-Hspice reserves the variable names listed in Star-Hspice Special Variables for use in elements such as E, G, R, C, and L. You cannot use them for any other purpose in your netlist (in .PARAM statements, for example) .

Table 7-3: Star-Hspice Special Variables

HSPICE Form

Function

Class

Description

time

current simulation time

control

Parameterizes the current simulation time during transient analysis.

temper

current circuit temperature

control

Parameterizes the current simulation temperature during transient/temperature analysis.

hertz

current simulation frequency

control

Parameterizes the frequency during AC analysis.

User-Defined Functions

An expression can contain parameters that have not yet been defined. A function must have at least one argument, and not more than two. Functions can be redefined.

Syntax

fname1 (arg1, arg2) = expr1 (fname2 (arg1, ...) = expr2) off

where:

fname

Specifies function name. This parameter must be distinct from array names and built-in functions. Subsequently defined functions must have all their embedded functions previously defined.

arg1, arg2

Specifies variables used in the expression.

off

Voids all user-defined functions.

Example

f(a,b) = POW(a,2)+a*b g(d) = SQRT(d) h(e) = e*f(1,2)-g(3)

Star-Hspice Manual - Release 2001.2 - June 2001