# Non-linear Transfer Function

Select menu Place > Analog Behavioural > Non-linear Transfer Function. This displays:

You may specify an equation that defines an output voltage or current in terms of any number of input voltages and currents. Input voltages are specified in the form V(a) or V(a,b) where a and b may be any arbitrary name of your choice. Input currents are specified in the form I(a). On completion, SIMetrix will generate a schematic symbol complete with the input voltages and/or currents that you reference in the equation. There is no need to specify how many input voltages and currents you wish to use. SIMetrix will automatically determine this from the equation.

As well as input voltage and currents, you can also reference the output voltage or current in your equation. A single ended output voltage is accessed using V(out) while a differential output voltage is accessed using V(outp,outn). If you specify an output voltage, you may also access the current flowing through it using I(out).

In the example above, the expression shown - V(vina,vinb)*I(iin) - multiplies a voltage and current together. This could be used to monitor the power in a two terminal device as shown in the following schematic.:

In the above, ARB1 is the device created from the Non-linear Transfer Function menu. ARB1-OUTP will carry a voltage equal to the power dissipation in R1.

In this topic:

## Expression

The expression entered defines the output of the device in terms of its inputs. Expressions generally comprise the following elements:

• Circuit variables
• Parameters
• Constants.
• Operators
• Functions
• Look up tables
These are described in the following sections.

### Circuit Variables

Circuit variables allow the expression to reference input voltages and currents.

Voltages are of the form:

V(node_name1)
OR
V(node_name1, node_name2)

Where node_name1 and node_name2 are input connections.The second form above returns the difference between the voltages on node_name1 and node_name2. The special names out, outp and outn may be used to access the voltage on the output. Use out for the single ended output configuration and outp and/or outn for the differential output configuration.

Currents are of the form:

I(source_name)

Where source_name is the name of an input current. For output voltage configurations, you can use I(out) to access the output current of the device itself. For example

100*I(OUT)

Implements a 100 ohm resistor for a device configured with a differential output voltage.

### Parameters

The expression may use any number of parameters. These can be local or global. Local parameters are defined in the Local parameters edit box on the right hand side. Global parameters must defined within the schematic, usually in the F11 window.

To enter local parameters, enter one or more definitions in the form name=expression in the Local parameters edit box. expression may be a constant or an expression referring to other local or global parameters. expression may not contain circuit variables. (E.g. V(in1)). Comment lines may be entered and must start with a '*'.

### Built-in Parameters

A number of parameter names are assigned by the simulator. These are:

 Parameter name Description TIME Resolves to time for transient analysis. Resolves to 0 otherwise including during the pseudo transient operation point algorithm TEMP Resolves to current circuit temperature in Celsius HERTZ Resolves to frequency during AC sweep and zero in other analysis modes PTARAMP Resolves to value of ramp during pseudo transient operating point algorithm. Otherwise this value resolves to 1.

### Constants

Apart from simple numeric values, arbitrary expressions may also contain the following built-in constants:

 Constant name Value Description PI 3.14159265358979323846 $\pi$ E 2.71828182845904523536 e TRUE 1.0 FALSE 0.0 ECHARGE 1.6021918e-19 Charge on an electron in coulombs BOLTZ 1.3806226e-23 Boltzmann's constant

### Operators

These are listed below and are listed in order of precedence. Precedence controls the order of evaluation. So 3*4 + 5*6 = (3*4) + (5*6) = 42 and 3+4*5+6 = 3 + (4*5) + 6 = 29 as '*' has higher precedence than '+'.

 Operator Description ~ ! - Digital NOT, Logical NOT, Unary minus ^ or ** Raise to power. * / Multiply, divide + - Plus, minus >= <=, > < Comparison operators == != or <> Equal, not equal & Digital AND (see below) | Digital OR (see below) && Logical AND || Logical OR test ? true_expr : false_expr Ternary conditional expression (see below)

### Comparison, Equality and Logical Operators

These are Boolean in nature either accepting or returning Boolean values or both. A Boolean value is either TRUE or FALSE. FALSE is defined as equal to zero and TRUE is defined as not equal to zero. So, the comparison and equality operators return 1.0 if the result of the operation is true otherwise they return 0.0.

The arguments to equality operators should always be expressions that can be guaranteed to have an exact value e.g. a Boolean expression or the return value from functions such as SGN. The == operator, for example, will return TRUE only if both arguments are exactly equal. So the following should never be used:

v(n1)==5.5

v(n1) may not ever be exactly 5.0. It may be 5.4999999999 or 5.50000000001 but only by chance will it be 5.5.

These operators are intended to be used with the IF() function described in Ternary Conditional Expression.

### Digital Operators

These are the operators '&', '|' and '~'. These are now considered to be obsolete and may not be supported in future versions of SIMetrix. These operators implement logic operations in the analog domain and are continuous in nature.

### Ternary Conditional Expression

This is of the form:

test_expression ? true_expression : false_expression

The value returned will be true_expression if test_expression resolves to a non-zero value, otherwise the return value will be false_expression. This is functionally the same as the IF() function described in the functions table below.

### Functions

 Function Description ABS(x) $|x|$ ACOS(x), ARCCOS(x) $\cos^{-1}(x)$ ACOSH(x) $\cosh^{-1}(x)$ ASIN(x), ARCSIN(x) $\sin^{-1}(x)$ ASINH(x) $\sinh^{-1}(x)$ ATAN(x), ARCTAN(x) $\tan^{-1}(x)$ ATAN2(x,y) $\tan^{-1}(x/y)$. Valid if y=0 ATANH(x) $\tanh^{-1}(x)$ COS(x) $\cos(x)$ COSH(x) $\cosh(x)$ DDT(x) $dx/dt$ EXP(x) $e^{x}$ FLOOR(x), INT(x) Next lowest integer of $x$. IF(cond, x, y[, maxslew]) if cond is TRUE $result=x$ else $result=y$. If $maxslew>0$ the rate of change of the result will be slew rate controlled. See IF() Function. IFF(cond, x, y[, maxslew]) As IF(cond, x, y, maxslew) LIMIT(x, lo, hi) if $xhi$ $result=hi$ else $result=x$ LIMITS(x, lo, hi, sharp) As LIMIT but with smoothed corners. The 'sharp' parameter defines the abruptness of the transition. A higher number gives a sharper response. LIMITS gives better convergence than LIMIT. See LIMITS() Function. below LN(x) $\ln(x)$ If $x<10^{-100}$ $result=-230.2585093$ LNCOSH(x) $\ln(\cosh(x))$ = $\int \tanh(x) dx$ LOG(x) $log_{10}(x)$. If $x<10^{-100}$ $result=-100$ LOG10(x) $log_{10}(x)$. If $x<10^{-100}$ $result=-100$ MAX(x, y) Returns larger of $x$ and $y$ MIN(x,y) Returns smaller of $x$ and $y$ PWR(x,y) $x^y$ PWRS(x,y) $x>=0$: $x^y$, $x<0$: $-x^y$ SDT(x) $\int x dt$ SGN(X) $x>0$: 1, $x<0$: -1, $x=0$: 0 SIN(x) $\sin(x)$ SINH(x) $\sinh(x)$ SQRT(x) $x>=0$: $\sqrt{x}$, $x<0$: $\sqrt{-x}$ STP(x) $x<=0$: 0, $x>0$: 1 TABLE(x,xy_pairs) lookup table. Refer to Lookup tables TABLEX(x,xy_pairs) Same as TABLE except end points extrapolated. Refer to Lookup tables TAN(x) $\tan(x)$ TANH(x) $\tanh(x)$ U(x) as STP(x) URAMP(x) $x<0$: 0, $x>=0$: $x$

### Monte Carlo Distribution Functions

The following functions return a randomly generated value when running a Monte Carlo analysis. They can be used to define component tolerances.

 Name Distribution Lot? DISTRIBUTION User defined distribution No DISTRIBUTIONL User defined distribution Yes UD Alias for DISTRIBUTION() No UDL Alias for DISTRIBUTIONL() Yes GAUSS Gaussian No GAUSSL Gaussian Yes GAUSSTRUNC Truncated Gaussian No GAUSSTRUNCL Truncated Gaussian Yes UNIF Uniform No UNIFL Uniform Yes WC Worst case No WCL Worst case Yes GAUSSE Gaussian logarithmic No GAUSSEL Gaussian logarithmic Yes UNIFE Uniform logarithmic No UNIFEL Uniform logarithmic Yes WCE Worst case logarithmic No WCEL Worst case logarithmic Yes

A full discussion on the use of Monte Carlo distribution functions is given in Simulator Reference Manual/Monte Carlo, Sensitivity and Worst-case/Specifying Tolerances.

### IF() Function

IF(condition, true-value, false-value[, max-slew])
The result is:

if condition is non-zero, result is true-value, else result is false-value.

If max-slew is present and greater than zero, the result will be slew-rate limited in both positive and negative directions to the value of max-slew.

In some situations, for example if true-value and false-value are constants, the result of this function will be discontinuous when condition changes state. This can lead to non-convergence as there is no lower bound on the time-step. In these cases a max-slew parameter can be included. This will limit the slew rate so providing a controlled transition from the true-value to the false-value and vice-versa.

If the simulator setting .OPTIONS DISCONTINUOUSIFSLEWRATE=max-slew, is provided, SIMetrix will automatically apply a max-slew parameter to all occurrences of the IF() function if both true-value and false-value are constants. This provides a convenient way of resolving convergence issues with third-party models that make extensive use of discontinuous if expressions. Note that the DISCONTINUOUSIFSLEWRATE option is also applied to conditional expressions using the C-style condition ? true-value : false-value syntax.

### LIMITS() Function

LIMITS(x, low, high, sharp)
The LIMITS() function is similar to LIMIT but provides a smooth response at the corners which leads to better convergence behaviour. The behaviour is shown below

The LIMITS function follows this equation:

LIMITS(x, low, high, sharp) = $0.5*((\ln(\cosh(v1))-\ln(\cosh(v2)))/v3 +(low+high))$

Where
• v1 = sharp/(high-low)*(x-low)
• v2 = sharp/(high-low)*(x-high)
• v3 = sharp/(high-low)

### Look-up Tables

Expressions may contain any number of look-up tables. This allows a transfer function of a device to be specified according to - say - measured values without having to obtain a mathematical equation. Look-up tables are specified in terms of x, y value pairs which describe a piece-wise linear transfer function. There are three ways to create a lookup table:
Method 1 Syntax in form: TABLE[xy_pairs](input_expression).
 xy_pairs A sequence of comma separated pairs of constant values that define the input and output values of the table. For each pair, the first value is the x or input value and the second is the y or output value. Only explicit numeric constants may be used. Even internal constants such as PI may not be used. input_expression Expression defining the input or x value of the table.
Method 2 Syntax in form: TABLE(input_expression, xy_pairs).
 input_expression Expression defining the input or x value of the table. xy_pairs A sequence of comma separated pairs of values that define the input and output values of the table. For each pair, the first value is the x or input value and the second is the y or output value. Unlike method 1, values do not need to be literal constants and may be expressions containing parameters and circuit variables that reference input voltages and currents. The TABLE function retains the value of the end point for x values beyond the range of the table. For example, if the last point for the TABLE function is (10,5) then any input greater than 10 will give an output of 5. If any value references a circuit variable, the expression in which the TABLE function is used must ultimately be evaluated in an arbitrary source
Method 3 Syntax in form: TABLEX(input_expression, xy_pairs).
 input_expression Expression defining the input or x value of the table. xy_pairs Same as method 2 except that out-of-range points are extrapolated from the final segment. See Table Lookup Example

Method 1 is more efficient at handling large tables (hundreds of values). However, method 2 is generally more flexible and is the recommended choice for most applications. Method 2 is also compatible with other simulators whereas method 1 is proprietary to SIMetrix.

For an example see Table Lookup Example

## Examples

### Table Lookup Example

The following arbitrary source definition implements a soft limiting function

Using method 1:
table[-10, -5, -5, -4, -4, -3.5, -3, -3, 3, 3, 4, 3.5, 5, 4, 10, 5](v(N1))
Using method 2:
TABLE(v(N1), -10, -5, -5, -4, -4, -3.5, -3, -3, 3, 3, 4, 3.5, 5, 4, 10, 5)
Using method 3:
TABLEX(v(N1), -10, -5, -5, -4, -4, -3.5, -3, -3, 3, 3, 4, 3.5, 5, 4, 10, 5)

The resulting transfer functions are illustrated in the following picture:

## Verilog-A Implementation

If you have SIMetrix Pro or SIMetrix Elite you may select the Compile to binary using Verilog-A option. This will build a definition of the device using the Verilog-A language then compile it to a binary DLL. This process takes place when you run the simulation. The benefit of using Verilog-A is that there is a wider range of functions available and for complex definitions there will also be a performance benefit. Refer to the Verilog-A Manual for details of available functions.