# Micro-Cap Operators and Functions

Posted by admin 09/01/2016 0 Comment(s) Arithmetic + Addition - Subtraction * Multiplication / Division MOD Modulus (remainder after integer division) DIV Integer division Digital D(A) Digital state on node A HEX(A,B,C,D) Hex value of the digital states of nodes A, B, C, D BIN(A,B,C,D) Binary value of the digital states of nodes A, B, C, D DEC(A,B,C,D) Decimal value of the digital states of nodes A, B, C, D OCT(A,B,C) Octal value of the digital states of nodes A, B, C, D & Bitwise AND of two digital node states | Bitwise OR of two digital node states ^ Bitwise XOR of two digital node states ~ Bitwise NOT of a digital node state Transcendental SIN(z) Sine function COS(z) Cosine function TAN(z) Tangent function COT(z) Cotangent function SEC(z) Secant function CSC(z) Cosecant function ASIN(z) Inverse sine function ACOS(z) Inverse cosine function ATAN(z) Inverse tangent function ATN(z) Inverse tangent function ARCTAN(z) Inverse tangent function = ATN(z) ATAN2(y,x) Inverse tangent function = ATN(y/x) ACOT(z) Inverse cotangent function ASEC(z) Inverse secant function ACSC(z) Inverse cosecant function SINH(z) Hyperbolic sine COSH(z) Hyperbolic cosine TANH(z) Hyperbolic tangent COTH(z) Hyperbolic cotangent SECH(z) Hyperbolic secant CSCH(z) Hyperbolic cosecant ASINH(z) Inverse hyperbolic sine ACOSH(z) Inverse hyperbolic cosine ATANH(z) Inverse hyperbolic tangent ACOTH(z) Inverse hyperbolic cotangent ASECH(z) Inverse hyperbolic secant ACSCH(z) Inverse hyperbolic cosecant LN(z) Natural Log LOG(z) Common log LOG10(z) Common log EXP(z) Exponential EXPL(x,max) Exponential: if x is less than max then exp(x) else exp(max)*(x+1-max ) EXPLP(x,max) Derivative of EXPL with respect to x POW(z,x) Complex power of operator, z^x PWR(y,x) Real power of operator, y^x PWRS(y,x) Real signed power of operator: |y|^x, if y>0, -|y|^x if y<0 ** or ^ Power of operator, ie; 5**2=25 or 5^2=25 DB(z) 20 * LOG(|z|) RE(z) Real part of z IM(z) Imaginary part of z. IMAG() and IMG() also work. MAG(z) Magnitude of z. M() also works. PH(z) Phase of z in degrees. PHASE() and P() also work. GD(z) Group delay, Delta(phase of z)/Delta(frequency) SPICE3 Boolean operators & Analog AND | Analog OR ~ Analog NOT ^ Analog XOR Standard Boolean and inequality operators AND And operator NAND Nand operator OR Or operator NOR Nor operator XOR Exclusive-Or operator NOT Negation operator < Less than operator > Greater than operator <= Less than or equal operator >= Greater than or equal operator != Not equal to operator <> Not equal to operator == Equal to operator Limiting and conditional operators MIN(z1,z2) Minimum of real and imaginary parts of z1 and z2 MAX(z1,z2) Maximum of real and imaginary parts of z1 and z2 LIMIT(z,z1,z2) Returns z, with its real part limited to the range of RE(z1) to RE(z2) and the imaginary part limited to the range IM(z1) to IM(z2) IF(b,z1,z2) If b is true, the function returns z1, else it returns z2 Signal Processing / FFT Functions HARM(u[,bw]) Harmonics of waveform u. bw = optional bandwidth. HARMN(u) Harmonics of waveform u normalized to the value at the fundamental. bw = optional bandwidth. THD(S[,F]) Total harmonic distortion of spectrum S as a percent of the value at the reference frequency F. If F is missing, it is set to the first harmonic (1/tmax in transient analysis). IHD(S[,F]) Individual harmonic distortion of spectrum S as a percent of the value at F. It is similar to THD but not cumulative. FFT(u) Standard forward Fourier transform of waveform u FFTS(u[,bw]) Forward Fourier transform of waveform u, scaled so that RE(FFTS(u)) produces the Fourier series cosine coefficients and IM(FFTS(u)) produces the Fourier series sine coefficients. BW = optional bandwidth. It is similar to HARM() function. FS(u,[[n1],n2]) Partial Fourier series representation of waveform u, compiled from the terms n1 through n2. N1 defaults to 0 and n2 defaults to the FFT Number of Points / 2. RES(u,[[n1],n2]) The residue function shows the waveform u minus the Fourier terms n1 through n2. N1 defaults to 0. N2 defaults to 1, so that RES(u) is RES(u,0,1) and thus essentially shows the distortion components due to the 2'nd and higher harmonics. IFT(S) Standard inverse Fourier transform of spectrum S IFTS(S) Scaled inverse Fourier transform of spectrum S. Scaling is such that IFTS(FFTS(u)) = u. CONJ(S) Conjugate of spectrum S CS(u,v) Cross spectrum = CONJ(FFT(v))*FFT(u)*dt*dt AS(u) Auto spectrum of waveform u = CS(u,u) CC(u,v) Cross correlation of u and v = IFT(CS(u,v))/dt AC(u) Auto correlation of waveform u is = IFT(AS(u))/dt COH(u,v) Coherence of u and v =CC(u,v)/sqr(AC(u(0))*AC(v(0))) Integration and differentiation DER(u,x) Calculates the derivative of u with respect to x. SUM(y,x[,start]) Running integral of y with respect to x, with optional start parameter. Integral begins at x=start. Start defaults to the analysis variable minimum (tmin, fmin, or dcmin), or 0, depending upon the integration variable, x. SD(y[,start]) Running integral of y with respect to T in transient, F in AC, or DCINPUT1 in DC, with an optional start parameter. Integral begins at start. Start defaults to tmin, fmin, dcmin, according to the analysis type. DD(y) Numerical derivative of y with respect to T in transient, F in AC, or DCINPUT1 in DC. RMS(y[,start]) Running root-mean-square of y with respect to F in AC, T in transient, or DCINPUT1 in DC, with an optional start parameter. Integral begins at start which defaults to tmin, fmin, or dcmin, according to the analysis type. AVG(y[,start]) Running average of y with respect to T in transient, F in AC, or DCINPUT1 in DC. The optional start parameter defaults to tmin, fmin, dcmin. SDT(y) Running integral of y with respect to T (Time). Integral begins at T = tmin DDT(y) Numerical derivative of y with respect to T (Time) DEL(y) Change in y from the prior data point to the current point. A numerical derivative is formed by the ratio of two operators. For example, DEL(y)/DEL(t) approximates the numerical time derivative of y. LAST(y,n) The n'th prior value of y. N=1 returns the value of y at the last timestep. N=2 returns the value of y at the timestep before last and so on. Special functions ABS(z) Absolute value function CURVEY("F","W") Imports the Y component of curve W from the User source file F. CURVEX("F","W") Imports the X component of curve W from file F. DELAY(x,d) Returns expression x delayed by d seconds. DIFA(u,v[,d]) DIFA reports differences between two analog curves. It compares the u expression with the v expression at every analysis point, and returns 1 if the absolute value of the result is more than d. Otherwise, it returns 0. DIFD(u,v[,d]) DIFD reports differences between two digital curves. It compares the u level with the v level at every analysis point, and returns 1 if they differ for a time exceeding d. Otherwise, it returns 0. FACT(u) Factorial of the integer value of u. u! Factorial of the integer value of u. When using the ! notation, u must be a symbolic variable or a constant. IMPORT(f,y) Imports curve y from the file f. INT(x) Truncated integer function. INT(2.7) = 2 NINT(x) Round up integer function. INT(2.7) = 2 IMPULSE(y) Impulse function of amplitude y and area of 1.0 JN(n,z[,m]) N'th order Bessel function of the first kind of the complex expression z, compiled from the series using m terms. M defaults to 10. J0(z) Zero'th order Bessel function of the first kind of the complex expression z. Same as JN(0,z,10) J1(z) First order Bessel function of the first kind of the complex expression z. Same as JN(1,z,10) LAST(z,n) Curve z delayed by n time points MAXR(x) Returns the largest value of x encountered at any time during a transient or DC sweep analysis run. MINR(x) Returns the smallest value of x encountered at any time during a transient or DC sweep analysis run. NORM(z,x0) Curve z normalized at the value of z when the X expression is equal to x0. DB operators normalized to 0. PN(n,x) N'th order Legendre polynomial function of x NORMMAX(z) Curve z normalized at the maximum value of z NORMMIN(z) Curve z normalized at the minimum value of z PROD(n,n1,n2,z) Calculates the product of the series of the complex expression z = z(n), for n = n1 to n = n2. SERIES(n,n1,n2,z) Calculates the summation of the series of the complex expression z = z(n), for n = n1 to n = n2. SGN(y) +1 (if y>0), 0 (if y=0), -1 (if y<0) SQRT(z) Complex square root STP(x) Step function of amplitude 1.0 starting at T >= x TABLE(x,x1,y1..xn,yn) This function performs a table lookup. It returns a value for y associated with the value of x, interpolated from the table. X values less than x1 generate an answer of y1. X values greater than xn generate an answer of yn. W(z) Lambert W function for complex z YN(n,z[,m]) N'th order Bessel function of the second kind of the complex expression z, compiled from the series using m terms. M defaults to 10. Y0(z) Zero'th order Bessel function of the second kind of the complex expression z. Same as YN(0,z,10) Y1(z) First order Bessel function of the second kind of the complex expression z. Same as YN(1,z,10) Random functions RND Returns a new random value at every time point. RNDR Returns a new random value at the start of each run command. RNDC Returns a new random value at the start of each new Monte Carlo, temperature, or stepping run.. Monte Carlo functions AGAUSS(val,abs,s) Returns a random value determined by a Gaussian distribution with a mean value of val and a standard deviation of abs/s. GAUSS(val,rel,s) Returns a random value determined by a Gaussian distribution with a mean value of val and a standard deviation of val*rel/s. UNIF(val,rel) Returns a random value uniformly distributed between val - val*rel and val + val*rel. AUNIF(val,abs) Returns a random value uniformly distributed between val - abs and val + abs.