next up previous contents index
Next: Expression Lists Up: Plots, Vectors and Expressions Previous: Measurement Functions   Contents   Index


HSPICE Compatibility Functions

The following functions are available, for compatibility with HSPICE.

These functions differ from other math functions in that they take multiple comma-separated arguments, Other math functions internally accept a single argument, but if there are multiple comma-separated terms, they will be collapsed into a single argument through evaluation of the comma operator

a,b = (a + j*b)
which yields a complex value. This will not be true in the functions listed below - the comma really means separate arguments in this case.

The first group of functions are equivalent to the HSPICE Monte Carlo functions that are called in .param lines in HSPICE. In WRspice, these are regular math functions.

These functions will return mean values unless enabled. They are enabled while in Monte Carlo analysis, or if the random variable is set, either from the command line or from a .options line in a circuit file.

unif(nom, rvar)
Uniform relative random value function.

This returns a vector the same length as nom, complex or real as nom. If the length of rvar is less than the length of nom, rvar is extended by replicating the highest index value of rvar.

If we are not running Monte Carlo analysis, and the random variable is not set, the return vector is the same as nom (no random values are generated). Otherwise the return vector contains uniformly distributed random values, each in the range [nom - nom*rvar, nom + nom*rvar] term-by-term.

Below, random is a pseudo-function that returns a random number between -1 and 1.

If nom is complex and var is complex:
out[i].real = nom[i].real*(1 + random()*rvar[i].real)
out[i].imag = nom[i].imag*(1 + random()*rvar[i].imag)

If nom is complex and var is real:
out[i].real = nom[i].real*(1 + random()*rvar[i])
out[i].imag = nom[i].imag*(1 + random()*rvar[i])

If nom is real and var is complex:
out[i] = nom[i].real*(1 + random()*rvar[i].real)

If nom is real and var is real:
out[i] = nom[i]*(1 + random()*rvar[i])

aunif(nom, var)
Uniform absolute random value function.

This returns a vector the same length as nom, complex or real as nom. If the length of var is less than the length of nom, var is extended by replicating the highest index value of var.

If we are not running Monte Carlo analysis, and the random variable is not set, the return vector is the same as nom (no random values are generated). Otherwise The return vector contains uniformly distributed random values, each in the range [nom - var, nom + var] term-by-term.

Below, random is a pseudo-function that returns a random number between -1 and 1.

If nom is complex and var is complex:
out[i].real = nom[i].real + random()*var[i].real
out[i].imag = nom[i].imag + random()*var[i].imag

If nom is complex and var is real:
out[i].real = nom[i].real + random()*var[i]
out[i].imag = nom[i].imag + random()*var[i]

If nom is real and var is complex:
out[i] = nom[i].real + random()*var[i].real

If nom is real and var is real:
out[i] = nom[i] + random()*var[i]

gauss(nom, rvar, sigma)
Gaussian relative random number generator.

This returns a vector the same length as nom, complex or real as nom. If the length of rvar is less than the length of nom, rvar is extended by replicating the highest index value of rvar. Only the zero'th (real) component of sigma is used.

If fewer than three arguments are given, this reverts to the original WRspice gauss function (now called ogauss).

If we are not running Monte Carlo analysis, and the random variable is not set, the return vector is the same as nom (no random values are generated). Otherwise the return vector contains gaussian-distributed random values. The (scalar) sigma value gives the specified sigma of the rvar data, generally 1 or 3.

Below, the pseudo-function gauss returns a gaussian random number with zero mean and unit standard deviation.

If nom is complex and var is complex:
out[i].real = nom[i].real*(1 + gauss()*rvar[i].real/sigma)
out[i].imag = nom[i].imag*(1 + gauss()*rvar[i].imag/sigma)

If nom is complex and var is real:
out[i].real = nom[i].real*(1 + gauss()*rvar[i]/sigma)
out[i].imag = nom[i].imag*(1 + gauss()*rvar[i]/sigma)

If nom is real and var is complex:
out[i] = nom[i].real*(1 + gauss()*rvar[i].real/sigma)

If nom is real and var is real:
out[i] = nom[i]*(1 + gauss()*rvar[i]/sigma)

agauss(nom, var, sigma)
Gaussian absolute random number generator.

This returns a vector the same length as nom, complex or real as nom. If the length of var is less than the length of nom, var is extended by replicating the highest index value of var. Only the zero'th (real) component of sigma is used.

If we are not running Monte Carlo analysis, and the random variable is not set, the return vector is the same as nom (no random values are generated). Otherwise the return vector contains gaussian-distributed random values. The (scalar) sigma value gives the specified sigma of the var data, generally 1 or 3.

Below, the pseudo-function gauss returns a gaussian random number with zero mean and unit standard deviation.

If nom is complex and var is complex:
out[i].real = nom[i].real + gauss()*var[i].real/sigma
out[i].imag = nom[i].imag + gauss()*var[i].imag/sigma

If nom is complex and var is real:
out[i].real = nom[i].real + gauss()*var[i]/sigma
out[i].imag = nom[i].imag + gauss()*var[i]/sigma

If nom is real and var is complex:
out[i] = nom[i].real + gauss()*var[i].real/sigma

If nom is real and var is real:
out[i] = nom[i] + gauss()*var[i]/sigma

limit(nom, var)
Random limit function.

This returns a vector the same length as nom, complex or real as nom. If the length of var is less than the length of nom, var is extended by replicating the highest index value of var.

If we are not running Monte Carlo analysis, and the random variable is not set, the return vector is the same as nom (no random values are generated). Otherwise the return vector contains either nom + var or nom - var determined randomly, term-by-term.

If nom is complex and var is complex:
out[i].real = nom[i].real +/- var[i].real randomly
out[i].imag = nom[i].imag +/- var[i].imag randomly

If nom is complex and var is real:
out[i].real = nom[i].real +/- var[i] randomly
out[i].imag = nom[i].imag +/- var[i] randomly

If nom is real and var is complex:
out[i] = nom[i].real +/- var[i].real randomly

If nom is real and var is real:
out[i] = nom[i] +/- var[i] randomly

The remaining functions are for HSPICE compatibility, but are not exclusive to the HSPICE Monte Carlo analysis. These also have multiple arguments.

pow(x, y)
This returns a real or complex vector the same length as x. If the length of y is less than the length of x, y is extended by replicating the highest index value of y.

This returns a vector containing xy computed using complex values, term-by-term, however if y is real, is is truncated to an integer value.

If x is complex and y is complex:
out = xy (same as ^ operator)

If x is complex and y is real:
out = x(int)y (same as ^ operator, but y is truncated to integer)

If x is real and y is complex:
out = xy (same as ^ operator)

If x is real and y is real:
out = x(int)y (same as ^ operator, but y is truncated to integer)

pwr(x, y)
This returns a real vector the same length as x. If the length of y is less than the length of x, y is extended by replicating the highest index value of y.

If x is complex and y is complex:
out[i] = (sign of x[i].real)(mag(x[i]) ^ y[i].real)

If x is complex and y is real:
out[i] = (sign of x[i].real)(mag(x[i]) ^ y[i])

If x is real and y is complex:
out[i] = (sign of x[i].real)(abs(x[i]) ^ y[i].real)

If x is real and y is real:
out[i] = (sign of x[i])(abs(x[i]) ^ y[i])

sign(x, y)
This returns a vector the same length as x, complex or real as x. If the length of y is less than the length of x, y is extended by replicating the highest index value of y.

If x is complex and y is complex:
out[i].real = (sign of y[i].real)abs(x[i].real)
out[i].imag = (sign of y[i].imag)abs(x[i].imag)

If x is complex and y is real:
out[i].real = (sign of y[i])abs(x[i].real)
out[i].imag = (sign of y[i])abs(x[i].imag)

If x is real and y is complex:
out[i] = (sign of y[i].real)abs(x[i])

If x is real and y is real:
out[i] = (sign of y[i])abs(x[i])


next up previous contents index
Next: Expression Lists Up: Plots, Vectors and Expressions Previous: Measurement Functions   Contents   Index
Stephen R. Whiteley 2024-10-26