Introduction to Measurement Expressions

This document describes the measurement expressions that are available for use with several Agilent EEsof EDA products. For a complete list of available measurement functions, refer to the Alphabetical Listing of Measurement Functions or consult the index.

Measurement expressions are equations that are evaluated during simulation post processing. They can be entered into the program using various methods, depending on which product you are using. Unlike the expressions described in Simulator Expressions, these expressions are evaluated after a simulation has completed, not before the simulation is run. Measurement expressions can also be easily used in a Data Display. For more information on entering equations in a data display, refer to Data Display.

Although there is some overlap among many of the more commonly used functions, measurement expressions and simulator expressions are derived from separate sources, evaluated at different times, and can have subtle differences in their usages. Thus, these two types of expressions need to be considered separately. For an overview of how measurement expressions are evaluated, refer to How Measurement Expressions are Evaluated.

How Measurement Expressions are Evaluated

Within this document you will find information on:

You will also find a complete list of functions that can be used as measurement expressions individually, or combined together as a nested expression. These functions have been separated into libraries and are listed in alphabetical order within each library. The functions available include:

For a complete list of all functions provided in this document, refer to the Alphabetical Listing of Measurement Expressions in Chapter 2 or consult the index.

Measurement Expressions Syntax

Use the following guidelines when creating measurement expressions:

Case Sensitivity

All variable names, functions names, and equation names are case sensitive in measurement expressions.

Variable Names

Variables produced by the simulator can be referenced in equations with various degrees of rigidity. In general a variable is defined as:
DatasetName.AnalysisName.AnalysisType.CircuitPath.VariableName
By default, in the Data Display window, a variable is commonly referenced as:
DatasetName..VariableName where the double dot ".." indicates that the variable is unique in this dataset. If a variable is referenced without a dataset name, then it is assumed to be in the current default dataset.

When the results of several analyses are in a dataset, it becomes necessary to specify the analysis name with the variable name. The double dot can always be used to pad a variable name instead of specifying the complete name.

In most cases a dataset contains results from a single analysis only, and so the variable name alone is sufficient. The most common use of the double dot is when it is desired to tie a variable to a dataset other than the default dataset.

Built-in Constants
Constant Description Value
PI (also pi) π 3.1415926535898
e Euler's constant 2.718281822
ln10 natural log of 10 2.302585093
boltzmann Boltzmann's constant 1.380658e-23 J/K
qelectron electron charge 1.60217733e-19 C
planck Planck's constant 6.6260755e-34 J*s
c0 Speed of light in free space 2.99792e+08 m/s
e0 Permittivity of free space 8.85419e-12 F/m
u0 Permeability of free space 12.5664e-07 H/m
i, j sqrt(-1) 1i

Operator Precedence

Measurement expressions are evaluated from left to right, unless there are parentheses. Operators are listed from higher to lower precedence. Operators on the same line have the same precedence. For example, a+b*c means a+(b*c), because * has a higher precedence than +. Similarly, a+b-c means (a+b)-c, because + and - have the same precedence (and because + is left-associative).
The operators !, &&, and || work with the logical values. The operands are tested for the values TRUE and FALSE, and the result of the operation is either TRUE or FALSE. In AEL a logical test of a value is TRUE for non-zero numbers or strings with non-zero length, and FALSE for 0.0 (real), 0 (integer), NULL or empty strings. Note that the right hand operand of && is only evaluated if the left hand operand tests TRUE, and the right hand operand of || is only evaluated if the left hand operand tests FALSE.

Operator Precedence
Operator Name Example
( ) function call, matrix indexer foo(expr_list)
[ ] sweep indexer, sweep generator X[expr_list]
{ } matrix generator {expr_list}
** exponentiation expr**expr
! not !expr
* multiply expr * expr
+ add expr + expr
:: sequence operator exp::expr::expr
< less than expr < expr
==,EQUALS equal expr == expr
&& AND logical and expr && expr
|| OR logical or expr || expr

Conditional Expressions

The if-then-else construct provides an easy way to apply a condition on a per-element basis over a complete multidimensional variable. It has the following syntax:
A = if ( condition ) then true_expression else false_expression

Condition, true_expression, and false_expression are any valid expressions. The dimensionality and number of points in these expressions follow the same matching conditions required for the basic operators.

Multiple nested if-then-else constructs can also be used:
A = if ( condition ) then true_expression elseif ( condition2) then true_expression else false_expression

The type of the result depends on the type of the true and false expressions. The size of the result depends on the size of the condition, the true expression, and the false expression.

Examples

The following information shows several examples of conditional expressions using various operators.
boolV1=1
boolV2=1
eqOp=if (boolV1 == 1) then 1 else 0 eqOp returns 1
eqOp1=if (boolV1 EQUALS 1) then 1 else 0 eqOp1 returns 1
notEqOp=if (boolV1 != 1) then 1 else 0 notEqOp returns 1
notEqOp1=if (boolV1 NOTEQUALS 1) then 1 else 0 notEqOp1 returns 1
andOp=if (boolV1 == 1 AND boolV2 == 1) then 1 else 0 andOp returns 1
andOp1=if (boolV1 == 1 && boolV2 == 1) then 1 else 0 andOp returns 1
orOp=if (boolV1 == 1 OR boolV2 == 1) then 1 else 0 orOp returns 1
orOp1=if (boolV1 == 1 || boolV2 == 1) then 1 else 0 orOp returns 1

Manipulating Simulation Data with Expressions

Expressions defined in this documentation are designed to manipulate data produced by the simulator. Expressions may reference any simulation output, and may be placed in a Data Display window. For details on using and applying simulation data with measurement expressions, refer to Applying Measurements in Chapter 6 of the Using Circuit Simulators documentation.

Simulation Data

The expressions package has inherent support for two main simulation data features. First, simulation data are normally multidimensional. Each sweep introduces a dimension. All operators and relevant functions are designed to apply themselves automatically over a multidimensional simulation output. Second, the independent (swept) variable is associated with the data (for example, S-parameter data). This independent is propagated through expressions, so that the results of equations are automatically plotted or listed against the relevant swept variable.

Measurements and Expressions

Measurements are evaluated after a simulation is run and the results are stored in the dataset. The tag meqn_xxx (where xxx is a number) is placed at the beginning of all measurement results, to distinguish those results from data produced directly by the simulator.

Complex measurement equations are available for both circuit and signal processing simulations. Underlying a measurement is the same generic equations handler that is available in the Data Display window. Consequently, simulation results can be referenced directly, and the expression syntax is identical. All operators and almost all functions are available.

The expression used in an optimization goal or a yield specification is a measurement expression. It may reference any other measurement on the schematic.

Generating Data

The simulator produces scalars and matrices. When a sweep is being performed, the sweep can produce scalars and matrices as a function of a set of swept variables. It is also possible to generate data by using expressions. Two operators can be used to do this. The first is the sweep generator "[ ]", and the second is the matrix generator "{ }". These operators can be combined in various ways to produce swept scalars and matrices. The data can then be used in the normal way in other expressions. The operators can also be used to concatenate existing data, which can be very useful when combined with the indexing operators.

Sweep Generator Examples

Several sweep generator examples are given below:
arr1=[0,1,2,3,4,5] creates an array of six values
arr2=[0::1::5] generates the above data using the sequence operator
arrCat=[arr1,arr2] concatenates the two arrays
sunArr1=[arr1[3::5],arr1[0::2]] re-arranges the existing data in a different order
z=0*[1::50]
vpadded=[arr1,z] creates a zero-padded array

Matrix Generator Examples

Some examples of the matrix builds operator are given below:
v1={1,2,3,4,5} five-element vector
v2={1::5} five-element vector using the sequence operator
v3=1,0}, {0,1 2X2 identity matrix

Simple Sweeps and Using "[ ]"

Parameter sweeps are commonly used in simulations to generate, for example, a frequency response or a set of DC IV characteristics. The simulator always attaches the swept variable to the actual data (the data often being called the attached independent in equations).
Often after performing a swept analysis we want to look at a single sweep point or a group of points. The sweep indexer "[ ]" can be used to do this. The sweep indexer is zero offset, meaning that the first sweep point is accessed as index 0. A sweep of n points can be accessed by means of an index that runs from 0 to n-1. Also, the what() function can be useful in indexing sweeps. Use what() to find out how many sweep points there are, and then use an appropriate index. Indexing out of range yields an invalid result.

The sequence operator can also be used to index into a subsection of a sweep. Given a parameter X, a subsection of X may be indexed as

a=X[start::increment::stop]

Because increment defaults to one,

a=X[start::stop]

is equivalent to

a=X[start::1::stop]

The "::" operator alone is the wildcard operator, so that X and X[::] are equivalent. Indexing can similarly be applied to multidimensional data. As will be shown later, an index may be applied in each dimension.

S-Parameters and Matrices

As described above, the sweep indexer "[ ]" is used to index into a sweep. However, the simulator can produce a swept matrix, as when an S-parameter analysis is performed over some frequency range. Matrix entries can be referenced as S11 through Snm. While this is sufficient for most simple applications, it is also possible to index matrices by using the matrix indexer "()". For example, S(1,1) is equivalent to S11. The matrix indexer is offset by one meaning the first matrix entry is X(1,1). When it is used with swept data its operation is transparent with respect to the sweep. Both indexers can be combined. For example, it is possible to access S(1,1) at the first sweep point as S(1,1)[0]. As with the sweep indexer "[ ]", the matrix indexer can be used with wild cards and sequences to extract a submatrix from an original matrix.

Matrices

S-parameters above are an example of a matrix produced by the simulator. Matrices are more frequently found in signal processing applications. Mathematical operators implement matrix operations. Element-by-element operations can be performed by using the dot modified operators (.* and ./).

The matrix indexer conveniently operates over the complete sweep, just as the sweep indexer operates on all matrices in a sweep. As with scalars, the mathematical operators allow swept and non-swept quantities to be combined. For example, the first matrix in a sweep may be subtracted from all matrices in that sweep as
Y = X-X[0]

and Indexing

Multidimensional Sweeps and Indexing

In the previous examples we looked at single-dimensional sweeps. Multidimensional sweeps can be generated by the simulator by using multiple parameter sweeps. Expressions are designed to operate on the multidimensional data. Functions and operators behave in a meaningful way when a parameter sweep is added or taken away. A common example is DC IV characteristics.

The sweep indexer accepts a list of indices. Up to N indices are used to index N-dimensional data. If fewer than N lookup indices are used with the sweep indexer, then wild cards are inserted automatically to the left. This is best explained by referring to the above example files.

User-Defined Functions

By writing some Application Extension Language (AEL) code, you can define your own custom functions. The following file is provided specifically for this purpose:

$HPEESOF_DIR/expressions/ael/user_defined_fun.ael

By reviewing the other _fun.ael files in this directory, you can see how to write your own code. You can have as many functions as you like in this one file, and they will all be compiled upon program start-up. If you have a large number of functions to define, you may want to organize them into more than one file. In this case, include a line such as:

load("more_user_defined_fun.ael");

These load statements are added to the user_defined_fun.ael in the same directory in order to have your functions all compile. To create your own custom user defined functions:

  1. Copy the $HPEESOF_DIR/expressions/ael/user_defined_fun.ael file to one of the following directories.
    $HOME/hpeesof/expressions/ael (User Config)
    $HPEESOF_DIR/custom/expressions/ael (Site Config)
    Create the appropriate subdirectories if they do not already exist. The User Config is setup for a single user. The Site Config can be set up by a CAD Manager or librarian to control a site configuration for a group of users.
  2. Edit the new file and add any custom defined functions. If your custom functions reside in another file, you can add a load statement to your new user_defined_fun.ael file to include your functions in another file. For example:

    load("my_custom_functions_file.ael");

  3. Save your changes to the new file and restart so your changes take effect. The search path looks in the following locations for user defined functions.
    $HOME/hpeesof/expressions/ael (User Config)
    $HPEESOF_DIR/custom/expressions/ael (Site Config)
    $HPEESOF_DIR/expressions/ael (Default Config)
    Note
    If for some reason your functions are not recognized by the simulator, check to ensure that the user_defined_fun.atf (compiled version of user_defined_fun.ael file) was generated after restarting the software.

Functions Reference Format

The information below illustrates how each measurement expression in the functions reference is described.
<function name>
Presents a brief description of what the function does.
Syntax
Presents the general syntax of the function.
Arguments
Presents a table that includes each argument name, description, range, type, default value, and whether or not the argument is optional.
Examples
Presents one or more simple examples that use the function.
Defined in
Indicates whether the measurement function is defined in a script or is built in. All AEL functions are built in.
See also
Presents links to related functions, if there are any.
Notes/Equations
Describes any additional notes and/or equations that may help with understanding the function.

 

Privacy Statement  | Terms of Use  | Legal | Contact Us  | © Agilent 2000-2008 

Contents
Additional Resources