Manuals >Reference >ADS Simulator Print version of this Book (PDF file) |
![]() ![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Expression CapabilityThe ADS Simulator has a powerful and flexible symbolic expression capability, called VarEqn, which allows the user to define variables, expressions, and functions in the netlist. These can then be used to define other VarEqn expressions and functions, to specify device parameters and optimization goals, etc. The names for VarEqn variables, expressions, and functions follow the same hierarchy rules that instance and node names do. Thus, local variables in a subcircuit definition can assume values that differ from one instance of the subcircuit to the next. Functions and expressions can be defined either globally or locally anywhere in the hierarchy. All variables are local by default. Local variables are known in the subcircuit in which they are defined, and all lower subcircuits; they are not known at higher levels. Expressions defined at the root (the top level) are known everywhere within the circuit. To specify an expression to be global the global keyword must precede the expression. The global keyword causes the variable to be defined at the root of the hierarchy tree regardless of the lexical location. global exp1 = 2.718 The expression capability includes the standard math operations of + - / * ^ in addition to parenthesis grouping. Scale factors are also allowed in general expressions and have higher precedence than any of the math operators (see Units and Scale Factors). ConstantsAn integer constant is represented by a sequence of digits optionally preceded by a negative sign (e.g, 14, -3). A real number contains a decimal point and/or an exponential suffix using the e notation (e.g, 14.0, -13e-10). The only complex constant is the predefined constant j which is equal to the square root of -1. It can be used to generate complex constants from real and integer constants (e.g., j*3, 9.1 + j*1.2e-2). The predefined functions complex() and polar() can also be used to enter complex constants into an expression. A string constant is delimited by single quotes (e.g.,'string','this is a string'). Predefined Constants
Variablesx1 = 4.3inches + 3mils syc_a = cos(1.0+sin(pi*3)) Zin = 7.8k - j*3.2k The type of a variable is determined by the type of its value. For example, x=1 is an integer, x=1+j is complex, and x = "tuesday" is a string. Predefined VariablesIn addition to the predefined constants, there are several predefined global variables. Since they are variables, they can be modified and swept.
The sourcelevel variable is used by the spectral analysis when it needs to gradually increase source power from 0 to full scale to obtain convergence. It can be used by the user to sweep the level of ALL spectral source components, but is not recommended. The _v and _i variables should only be used in the context of the sdd device. Expressions
The main difference between expressions and variables is that a variable can be directly swept and modified by an analysis but an expression cannot. Note however, that any instance parameter that depends on an expression is updated whenever one of the variables that the expression depends upon is changed (e.g., by a sweep). Predefined Expressions
Functionsy_srl(freq, r, l) = 1.0/(r + j*freq*l) expl(a,b) = exp(a)*step(b-a) + exp(b)*(a-b-1)*step(a-b) In expression, the function's arguments can be used, as can any other VarEqn variables, expressions, or functions. Predefined Functions
Detailed Descriptions of the Predefined Functions_discrete_density (x1, p1, x2, p2, …) allows the user to define a discrete density distribution: returns x1 with probability p1, x2 with probability p2, etc. The xn, pn pairs needn't be sorted. The pns will be normalized automatically. _gaussian( [mean, sigma, lower_n_sigmas, upper_n_sigmas, lower_n_sigmas_del, upper_n_sigmas_del] ) returns a value randomly distributed according to the standard bell-shaped curve. mean defaults to 0. sigma defaults to 1. lower_n_sigmas, upper_n_sigmas define truncation limits (default to 3). lower_n_sigmas_del and upper_n_sigmas_del define a range in which the probability is zero (a bimodal distribution). _gaussian_tol( [percent_tol, lower_n_sigmas, upper_n_sigmas, lower_percent_tol, upper_percent_tol, lower_n_sigmas_del, upper_n_sigmas_del] ) is similar, but percent_tol defines the percentage tolerance about the nominal value (which comes from the RANDVAR expression). _get_fnom_freq(x) returns the actual analysis frequency associated with the carrier frequency specified in the surrounding FDD context. If x is negative, it is the carrier frequency index. If x is positive, it is the harmonic index. _mvgaussian(N, mean1, … meanN, sigma1, … sigmaN, correlation1,2, …, correlation1,N, …, correlationN-1,N) multivariate gaussian density function (correlation version). Returns an N dimensional vector. The correlation coefficient matrix must be positive definite. _mvgaussian_cov(N, mean1, … meanN, sigma1, … sigmaN, covariance1,2, ..., covariance1,N, ..., covarianceN-1,N) is similar, but defined in terms of covariance. The covariance matrix must be positive definite. _pwl_density(x1, p1, x2, p2, …) returns a value randomly distributed according to the piecewise-linear density function with values pn at xn, i.e. it will return xn with probability pn and return The xn, pn pairs needn't be sorted. The pns will be normalized automatically. _pwl_distribution(x1, p1, x2, p2, …) is similar, but is defined in terms of the distribution values. It will return a value less than or equal to xn with probability pn. The xn, pn pairs will be sorted in increasing xn order. After sorting, the pns should never decrease. The pns will be normalized so that pN=1. _randvar(distribution, mcindex, [nominal, tol_percent, x_min, x_max, lower_tol, upper_tol, delta_tol, tol_factor] ) returns a value randomly distributed according to the distribution. The value will be the same for a given value of mcindex. The other parameters are interpreted according to the distribution. _shift_reg(x, y, z, t) implements a z-bit shift register. x specifies the trigger. y = 0 means LSB First, Serial To Parallel, 1 means MSB First, Serial To Parallel, 2 means LSB First, Parallel to Serial, 3 means MSB First, Parallel to Serial. t is the input (output) value. _uniform( [lower_bound, upper_bound] ) returns a value between lower_bound and upper_bound. All such values are equally probable. _uniform_tol( [percent_tol, lower_tol, upper_tol] ) is similar, but tolerance version. access_all_data(InterpMode, source, indep1, dep1 …) datafile independent and dependent lookup/interpolation function. access_data(InterpMode, nData, source, dep1 …) datafile dependents' lookup/interpolation function. bin(String) calculates the integer value of a sequence of 1's and 0's. For example bin('11001100') = 204. The argument of the bin function must be a string denoted by single quotes. The main use of the bin function is with the System Model Library to define an integer which corresponds to a digital word. cxform(x, OutFormat, InFormat) transform complex data x from format InFormat to format OutFormat. The values for OutFormat and InFormat are 0: real and imaginary, 1: magnitude (linear) and phase (degrees), 2: magnitude (linear) and phase (radians), 3: magnitude (dB) and phase (degrees), 4: magnitude (dB) and phase (radians), 5: magnitude (SWR) and phase (degrees), 6: magnitude (SWR) and phase (radians). For example, to convert linear magnitude and phase in degrees to real and imaginary parts: result = cxform(invar, 0, 1) damped_sin(time, [offset, amplitude, freq, delay, damping, phase]). See Transient Source Functions. The function db(x) is a shorthand form for the expression: 20log(mag(x)). The deembed(x) function takes an array, x, of 4 complex numbers (the 2-port S-parameter array returned from the VarEqn interp() function) and returns an array of equivalent de-embedding S-parameters for that network. The array must be of length 4 (2 x 2--two-port data only), or an error message will result. The transformation used is: where det is the determinant of the 2 x 2 array.
This transformation assumes that the S-parameters are derived from equal port termination impedances. This transformation does not work when the port impedances are unequal.
The function deg(x) converts from radians to degrees. dphase(x, y) Calculates phase difference phase(x)-phase(y) (in radians). dsexpr(x, y) Evaluate x, a DDS expression, to an hpvar. y is the default location data directory. echo(x) prints argument on terminal and returns it as a value. erf_pulse(time, [low, high, delay, rise, fall, width, period] ) periodic pulse function, edges are error function (integral of Gaussian) shaped.
eval_poly(x, y, z) y is a real number. z is an integer that describes what to evaluate: -1 means the integral of the polynomial, 0 means the polynomial itself, +1 means the derivative of the polynomial. x is a VarEqn array that contains real numbers. The polynomial is exp_pulse(time, [low, high, delay1, tau1, delay2, tau2]) See Transient Source Functions. get_fund_freq(fund) returns the value of frequency (in Hertz) of a given fundamental defined by fund. index(nameArray, "varName", [caseSense, length] ) returns position of "varName" in nameArray, -1 if not found. caseSense sets case-sensitivity, defaults to yes. length sets how many characters to check, defaults to 0 (all). innerprod(x, y) forms the inner product of the vectors x and y: j and k are optional integers which specify a range of harmonics to include in the calculation: j defaults to 0 and k defaults to infinity. int(x) Truncates the fractional part of x. itob(x, [bits] ) convert integer x to bits-bit binary string. The function jn(n, x) is the n-th order bessel function evaluated at x. limit_warn( [Value, Min, Max, default, Name] ) sets Value to default, if not set. Limits it to Min and Max and generates a warning if the value is limited. makearray(arg1[,arg2,..] creates an array with elements defined by arg1 to argN where N can be any number of arguments. The data type of args must be Integer, Real, or Complex and the same for all args. word = bin('1101') fibo = makearray(0,1,1,2,3,5,8,word) foo = fibo[0] multi_freq(time, amplitude, freq1, freq2, n, [seed] ) seed defaults to 1. If it is 0, phase is set to 0, otherwise it is used as a seed for a randomly-generated phase. norm(x) returns the L-2 norm of the spectrum x: j and k are optional integers which specify a range of harmonics to include in the calculation: j defaults to 0 and k defaults to infinity. phase(x) is the same as phasedeg(x). The function phasedeg(x) returns phase in degrees. The function phaserad(x) returns phase in radians. The function polarcpx(x[,leave_as_real]) takes a complex argument, assumes that the real and complex part of the argument represents mag and phase (in radians) information, and converts it to real/imaginary. If the argument is real or integer instead of complex, the imaginary part is assumed to be zero. However, if the optional leave_as_real variable is specified, and is the value ``1'' (note that the legal values are ``0'' and ``1'' only), a real argument will be not be converted to a complex one. pulse(time, [low, high, delay, rise, fall, width, period]) See Transient Source Functions. pwl(...) piecewise-linear function. See Transient Source Functions. pwlr(...) piecewise-linear-repeated function. The function rect(t, tc, tp) is pulse function of variable t centered at time tc with duration tp. The function rad(x) converts from degrees to radians. read_data(source, locName, [fileType]) returns data from a file or dataset. source = "file" --- "dataset". locName is the name of the source. fileType specifies the file type. read_lib(libName, locName, [fileType]) returns data from a library. libName is the name of the library. locName is the name of the source. fileType specifies the file type. read_lib("libName", "item", "fileType")
rem(x, [y]) Returns remainder of dividing x/y. y defaults to 0 (which returns x). rms(x) returns the RMS value (including DC) of the spectrum x: j and k are optional integers which specify a range of harmonics to include in the calculation: j defaults to 0 and k defaults to infinity. The function rpsmooth(x) takes a VarEqn pointer (one returned by readraw()), converts to polar format the rectangular data given by the VarEqn pointer, and smooths out `phase discontinuities'.
This function uses an algorithm that assumes that the first point is correct (i.e., not off by some multiple of sffm(time, [offset, amplitude, carrier_freq, mod_index, signal_freq]) See Transient Source Functions. The sprintf() function is similar to the C function which takes a format string for argument s and a print argument x (x must be a string, an integer, or a real number) and returns a formatted string. This string then may be written to the console using the system function with an echo command. Transient Source FunctionsThere are several built-in functions that mimic Spice transient sources. They are:
There functions are typically used with the vt parameter of the voltage source and the it parameter of the current source. exp_pulseivs:vin n1 0 vt=exp_pulse(time) ics:iin n1 0 it=exp_pulse(time, -0.5mA, 0.5mA, 10ns, 5ns, 20ns, 8ns)
TSTEP is the output step-time time specified on the TRAN analysis. sffmivs:vin n1 0 vt=sffm(time, , , , 0.5) ics:iin n1 0 it=sffm(time, 0, 2, 1GHz, 1.2, 99MHz)
damped_sinivs:vin n1 0 vt=damped_sin(time) ics:iin n1 0 it=damped_sin(time, 0, 5V, 500MHz, 50ns, 200ns)
pulseivs:vin n1 0 vt=pulse(time) ics:iin n1 0 it=pulse(time, -5V, 5V, 500MHz, 50ns, 200ns)
pwlivs:vin n1 0 vt=pulse(time, 0, 0, 1ns, 1, 10ns, 1, 15ns, 0) ics:iin n1 0 it=pwl(time, 0, 0, 1ns, 1, 5ns, 1, 5ns, 0.5, 10ns,0.5, 15ns, 0)
Conditional ExpressionsThe ADS Simulator supports simple in-line conditional expressions: if boolExpr then expr else expr endif if boolExpr then expr elseif boolExpr then expr else expr endif boolExpr is a boolean expression, that is, an expression that evaluates to TRUE or FALSE. expr is any non-boolean expression. The else is required (because the conditional expression must always evaluate to some value). There can be any number of occurrences of elseif expr then expr. A conditional expression can legally occur as the right-hand side of an expression or function definition or, if parenthesized, anywhere in an expression that a variable can occur. Boolean operators
Boolean expressionsA boolean expression must evaluate to TRUE or FALSE and, therefore, must contain a relational operator (equals, =, ==, notequals, !=, <, >, <=, or >=). The only legal place for a boolean expression is directly after an if or an elseif. A boolean expression cannot stand alone, that is, x = a > b PrecedenceTightest binding: equals, =, ==, notequals, !=, >, <, >=, <= All arithmetic operators have tighter binding than the boolean operators. EvaluationBoolean expressions are short-circuit evaluated. For example, if when evaluating a and b, expression a evaluates to FALSE, expression b will not be evaluated. During evaluation of boolean expressions with arithmetic operands, the operand with the lower type is promoted to the type of the other operand. For example, in 3 equals x +j*b, 3 is promoted to complex. A complex number cannot be used with <, >, <=, or >=. Nor can an array (and remember that strings are arrays). This will cause an evaluation-time error. Pointers can be compared only with pointers. Examples:Protect against divide by zero: f(a) = if a equals 0 then 1.0e100 else 1.0/a endif f(mode) = if mode equals 0 then 1-a else f2(mode) endif f2(mode) = if mode equals 1 then log(1-a) else f3(mode) endif f3(mode) = if mode equals 2 then exp(1-a) else 0.0 endif f(mode) = if mode equals 0 then 1-a elseif mode equals 1 then \ log(1-a) elseif mode equals 2 then exp(1-a) else 0.0 endif exp_max = 1.0e16 x_max = ln(exp_max) exp_soft(x) = if x<x_max then exp(x) else (x+1-x_max)*exp_max endif |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() |