Specifying User-Defined Analysis (.MEASURE)

Use the .MEASURE statement to modify information and define the results of successive simulations.

The .MEASURE statement prints user-defined electrical specifications of a circuit and is used extensively in optimization. The specifications include propagation, delay, rise time, fall time, peak-to-peak voltage, minimum and maximum voltage over a specified period, and a number of other user-defined variables. With either the error function or GOAL parameter, .MEASURE is also used extensively for optimization of circuit component values and curve fitting measured data to model parameters.

Measurement results are computed based on postprocessing output. Using the INTERP option to reduce the size of postprocessing output may lead to interpolation error in measurement results. See Input and Output for more information on the INTERP option.

The .MEASURE statement has several different formats, depending on the application. You can use it for either DC sweep, AC, or transient analysis.

Fundamental measurement modes are:

When a .MEASURE statement fails to execute, Star-Hspice writes 0.0e0 in the .mt# file as the .MEASURE result, and writes "FAILED" in the output listing file. Use the MEASFAIL option to write out results to the .mt#, .ms#, or .ma# files. See Input and Output for additional information on the MEASFAIL option.

The user can also control the output variables which are listed in the .measure statement by using the .putmeas option. See Input and Output Options0 for additional information.

Measure Parameter Types

Measurement parameter results produced by .PARAM statements in .SUBCKT blocks cannot be used outside the subcircuit. That means measurement parameters defined in .SUBCKT statements cannot be passed as bottom-up parameters in hierarchical designs.

Measurement parameter names cannot conflict with standard parameter names. Star-Hspice issues an error message if it encounters a measurement parameter with the same name as a standard parameter definition.

To prevent parameter values given in .MEASURE statements from overwriting parameter assignments in other statements, Star-Hspice keeps track of parameter types. If the same parameter name is used in both a .MEASURE statement and a .PARAM statement at the same hierarchical level, Star-Hspice terminates with an error. No error occurs if the parameter assignments are at different hierarchical levels. PRINT statements that occur at different levels do not print hierarchical information for the parameter name headings.

The following example illustrates how Star-Hspice handles .MEASURE statement parameters.

...
.MEASURE tran length TRIG v(clk) VAL = 1.4 TD = 11ns RISE = 1
+ TARGv(neq) VAL = 1.4 TD = 11ns RISE = 1 
.SUBCKT path out in width = 0.9u length = 600u
+ rm1 in m1 m2mg w = 'width' l = 'length/6'
...
.ENDS

In the above listing, the `length' in the resistor statement

rm1 in m1 m2mg w = 'width' l = 'length/6'

does not inherit its value from the length in the .MEASURE statement

.MEASURE tran length ...

since they are of different types. The correct value of l in rm1 should be

l = length/6 = 100u

instead of a value derived from the measured value in transient analysis.

.MEASURE Statement: Rise, Fall, and Delay

This format is used to measure independent-variable (time, frequency, or any parameter or temperature) differential measurements such as rise time, fall time, slew rate, and any measurement that requires the determination of independent variable values. The format specifies substatements TRIG and TARG. These two statements specify the beginning and ending of a voltage or current amplitude measurement.

The rise, fall, and delay measurement mode computes the time, voltage, or frequency between a trigger value and a target value. Examples for transient analysis include rise/fall time, propagation delay, and slew rate measurement. Applications for AC analysis are the measurement of the bandwidth of an amplifier or the frequency at which a certain gain is achieved.

Syntax

.MEASURE <DC|AC|TRAN> result TRIG ... TARG ...
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

where:

 

MEASURE

Specifies measurements. You can abbreviate to MEAS.

result

Name that is associated with the measured value in the Star-Hspice output. The item measured is the independent variable beginning at the trigger and ending at the target: for transient analysis it is time; for AC analysis it is frequency; for DC analysis it is the DC sweep variable. If the target is reached before the trigger is activated, the resulting value is negative.
Note: The terms "DC", "TRAN", and "AC" are illegal for result name.

TRIG..., TARG ...

Identifies the beginning of trigger and target specifications, respectively.

<DC|AC|TRAN>

Specifies the analysis type of the measurement. If omitted, the last analysis mode requested is assumed.

GOAL

Specifies the desired measure value in optimization. The error is calculated by .

MINVAL

If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

WEIGHT

The calculated error is multiplied by the weight value. Used in optimization. Default = 1.0.

Trigger

TRIG trig_var VAL = trig_val <TD = time_delay> <CROSS = c>
+ <RISE = r> <FALL = f>

or

TRIG AT = val

Target

TARG targ_var VAL = targ_val <TD = time_delay>
+ <CROSS = c | LAST> <RISE = r | LAST> <FALL = f | LAST>

where:

 

TRIG

Indicates the beginning of the trigger specification

trig_val

Value of trig_var at which the counter for crossing, rises, or falls is incremented by one

trig_var

Specifies the name of the output variable, which determines the logical beginning of measurement. If the target is reached before the trigger is activated, .MEASURE reports a negative value.

TARG

Indicates the beginning of the target signal specification

targ_val

Specifies the value of the targ_var at which the counter for crossing, rises, or falls is incremented by one

targ_var

Name of the output variable whose propagation delay is determined with respect to the trig_var

time_delay

Amount of simulation time that must elapse before the measurement is enabled. The number of crossings, rises, or falls is counted only after time_delay value. The default trigger delay is zero.

CROSS = c
RISE = r
FALL = f

The numbers indicate which occurrence of a CROSS, FALL, or RISE event causes a measurement to be performed. For

RISE = r, the WHEN condition is met and measurement is performed when the designated signal has risen r rise times. For FALL = f, measurement is performed when the designated signal has fallen f fall times. A crossing is either a rise or a fall, so for CROSS = c, measurement is performed when the designated signal has achieved a total of c crossing times, as a result of either rising or falling. For TARG, the last event is specified with the LAST keyword.

LAST

Measurement is performed when the last CROSS, FALL, or RISE event occurs. For CROSS = LAST, measurement is performed the last time the WHEN condition is true for either a rising or falling signal. For FALL = LAST, measurement is performed the last time the WHEN condition is true for a falling signal. For RISE = LAST, measurement is performed the last time the WHEN condition is true for a rising signal. LAST is a reserved word and cannot be chosen as a parameter name in the above .MEASURE statements.

AT = val

Special case for trigger specification. The "val" is the time for TRAN analysis, the frequency for AC analysis, or the parameter for DC analysis, at which measurement is to start.

Example
.MEASURE TRAN tdlay TRIG V(1) VAL = 2.5 TD = 10n RISE = 2
+ TARG V(2) VAL = 2.5        FALL = 2

This example specifies that a propagation delay measurement is taken between nodes 1 and 2 for a transient analysis. The delay is measured from the second rising edge of the voltage at node 1 to the second falling edge of node 2. The measurement is specified to begin when the second rising voltage at node 1 is 2.5 V and to end when the second falling voltage at node 2 reaches 2.5 V. The TD = 10n parameter does not allow the crossings to be counted until after 10 ns has elapsed. The results are printed as tdlay = <value>.

.MEASURE TRAN riset TRIG I(Q1) VAL = 0.5m RISE = 3
+ TARG I(Q1) VAL = 4.5m RISE = 3
.MEASURE pwidth TRIG AT = 10n TARG V(IN) VAL = 2.5 CROSS = 3

The last example uses the short form of TRIG. AT = 10n specifies that the time measurement is to begin at time t = 10 ns in the transient analysis. The TARG parameters specify that the time measurement is to end when V(IN) = 2.5 V on the third crossing. The variable pwidth is the printed output variable.


NOTE: If the .TRAN statement is used in conjunction with a .MEASURE statement, using a nonzero START time in the .TRAN statement can result in incorrect .MEASURE results. Do not use nonzero START times in .TRAN statements when .MEASURE is also being used.

FIND and WHEN Functions

The FIND and WHEN functions allow any independent variables (time, frequency, parameter), any dependent variables (voltage or current, for example), or the derivative of any dependent variables to be measured when some specific event occurs. These measure statements are useful in unity gain frequency or phase measurements, as well as for measuring the time, frequency, or any parameter value when two signals cross each other, or when a signal crosses a constant value. The measurement starts after a specified time delay, TD. It is possible to find a specific event by setting RISE, FALL, or CROSS to a value (or parameter) or LAST for last event. LAST is a reserved word and cannot be chosen as a parameter name in the above measure statements. See Displaying Simulation Results for the definitions of parameters on measure statement.

Syntax
.MEASURE <DC|TRAN| AC> result WHEN out_var = val <TD = val>
+ < RISE = r | LAST > < FALL = f | LAST > < CROSS = c | LAST >
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

or

.MEASURE <DC|TRAN|AC> result WHEN out_var1 = out_var2 < TD = val >
+ < RISE = r | LAST > < FALL = f | LAST > < CROSS = c| LAST >
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

or

.MEASURE <DC|TRAN|AC> result FIND out_var1 WHEN out_var2 = val < TD = val >
+ < RISE = r | LAST > < FALL = f | LAST >
+ < CROSS = c| LAST > <GOAL = val> <MINVAL = val> <WEIGHT = val>

or

.MEASURE <DC|TRAN|AC> result FIND out_var1 WHEN out_var2 = out_var3
+ <TD = val > < RISE = r | LAST > < FALL = f | LAST >
+ <CROSS = c | LAST> <GOAL = val> <MINVAL = val> <WEIGHT = val>

or

.MEASURE <DC|TRAN|AC> result FIND out_var1 AT = val <GOAL = val>
+ <MINVAL = val> <WEIGHT = val>
Parameter Definitions

 

CROSS = c

RISE = r

FALL = f

The numbers indicate which occurrence of a CROSS, FALL, or RISE event causes a measurement to be performed. For RISE = r, the WHEN condition is met and measurement is performed when the designated signal has risen r rise times. For FALL = f, measurement is performed when the designated signal has fallen f fall times. A crossing is either a rise or a fall, so for CROSS = c, measurement is performed when the designated signal has achieved a total of c crossing times, as a result of either rising or falling.

<DC|AC|TRAN>

Specifies the analysis type of the measurement. If omitted, the last analysis type requested is assumed.

FIND

Selects the FIND function

GOAL

Specifies the desired .MEASURE value. It is used in optimization. The error is calculated by .

LAST

Measurement is performed when the last CROSS, FALL, or RISE event occurs. For CROSS = LAST, measurement is performed the last time the WHEN condition is true for either a rising or falling signal. For FALL = LAST, measurement is performed the last time the WHEN condition is true for a falling signal. For RISE = LAST, measurement is performed the last time the WHEN condition is true for a rising signal. LAST is a reserved word and cannot be chosen as a parameter name in the above .MEASURE statements.

MINVAL

If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

out_var(1,2,3)

Variables used to establish conditions at which measurement is to take place

result

Name associated with the measured value in the Star-Hspice output

TD

Identifies the time at which measurement is to start

WEIGHT

Calculated error is multiplied by the weight value. Default = 1.0.

WHEN

Selects the WHEN function

Equation Evaluation

Use this statement to evaluate an equation that is a function of the results of previous .MEASURE statements. The equation must not be a function of node voltages or branch currents.

Syntax

.MEASURE <DC|TRAN|AC> result PARAM = 'equation'
+ <GOAL = val> <MINVAL = val>

Average, RMS, MIN, MAX, INTEG, and Peak-To-Peak

The average (AVG), RMS, MIN, MAX, and peak-to-peak (PP) measurement modes report statistical functions of the output variable rather than the analysis value. Average calculates the area under the output variable divided by the periods of interest. RMS takes the square root of the area under the output variable square divided by the period of interest. MIN reports the minimum value of the output function over the specified interval. MAX reports the maximum value of the output function over the specified interval. PP (peak-to-peak) reports the maximum value minus the minimum value over the specified interval.

Syntax
.MEASURE <DC|AC|TRAN> result func out_var <FROM = val> <TO = val>
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

where:

 

<DC|AC|TRAN>

Specifies the analysis type of the measurement. If omitted, the last analysis mode requested is assumed.

FROM

Specifies the initial value for the "func" calculation. For transient analysis, value is in units of time.

TO

Specifies the end of the "func" calculation.

GOAL

Specifies the desired .MEASURE value. It is used in optimization. The error is calculated by

MINVAL

If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

func

Indicates the type of the measure statement, one of the following:

  • AVG (average):
    Calculates the area under the out_var divided by the periods of interest
  • MAX (maximum):
    Reports the maximum value of the out_var over the specified interval
  • MIN (minimum):
    Reports the minimum value of the out_var over the specified interval
  • PP (peak-to-peak):
    Reports the maximum value minus the minimum value of the out_var over the specified interval
  • RMS (root mean squared):
    Calculates the square root of the area under the out_var 2 curve divided by the period of interest

result

Name that is associated with the measured value in the Star-Hspice output. The value is a function of the variable specified (out_var) and func.

out_var

Name of any output variable whose function ("func") is to be measured in the simulation.

WEIGHT

The calculated error is multiplied by the weight value. Default = 1.0.

Example

.MEAS TRAN avgval AVG V(10) FROM = 10ns TO = 55ns

The example above calculates the average nodal voltage value for node 10 during the transient sweep from the time 10 ns to 55 ns and prints out the result as "avgval".

.MEAS TRAN MAXVAL MAX V(1,2) FROM = 15ns TO = 100ns

The example above finds the maximum voltage difference between nodes 1 and 2 for the time period from 15 ns to 100 ns.

.MEAS TRAN MINVAL MIN V(1,2) FROM = 15ns TO = 100ns

.MEAS TRAN P2PVAL PP I(M1) FROM = 10ns TO = 100ns

INTEGRAL Function

The INTEGRAL function provides the integral of an output variable over a specified period.

Syntax
.MEASURE <DC|AC|TRAN> result INTEGRAL out_var <FROM = val>
+ <TO = val> <GOAL = val> <MINVAL = val> <WEIGHT = val>

The same syntax used for the average (AVG), RMS, MIN, MAX, and peak-to-peak (PP) measurement mode is used for the INTEGRAL function with func to be defined as INTEGRAL (INTEG).

Example

The following example calculates the integral of I(cload) from 10 ns to 100 ns.

.MEAS TRAN charge INTEG I(cload) FROM = 10ns TO = 100ns

DERIVATIVE Function

The DERIVATIVE function provides the derivative of an output variable at a given time or frequency or for any sweep variable, depending on the type of analysis. It also provides the derivative of a specified output variable when some specific event occurs.

Syntax
.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var AT = val <GOAL = val>
+ <MINVAL = val> <WEIGHT = val>

or

.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var WHEN var2 = val
+ <RISE = r | LAST> <FALL = f | LAST> <CROSS = c | LAST>
+ <TD = tdval> <GOAL = goalval> <MINVAL = minval> <WEIGHT = weightval>

or

.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var WHEN var2 = var3
+ <RISE = r | LAST> <FALL = f | LAST> <CROSS = c | LAST>
+ <TD = tdval> <GOAL = goalval> <MINVAL = minval> <WEIGHT = weightval>

where:

 

AT = val

Value of out_var at which the derivative is to be found

CROSS = c

RISE = r

FALL = f

The numbers indicate which occurrence of a CROSS, FALL, or RISE event causes a measurement to be performed. For RISE = r, the WHEN condition is met and measurement is performed when the designated signal has risen r rise times. For FALL = f, measurement is performed when the designated signal has fallen f fall times. A crossing is either a rise or a fall, so for CROSS = c, measurement is performed when the designated signal has achieved a total of c crossing times, as a result of either rising or falling.

<DC|AC|TRAN>

Specifies the analysis type measured. If omitted, the last analysis mode requested is assumed.

DERIVATIVE

Selects the derivative function. May be abbreviated to DERIV.

GOAL

Specifies the desired .MEASURE value. It is used in optimization. The error is calculated by .

LAST

Measurement is performed when the last CROSS, FALL, or RISE event occurs. For CROSS = LAST, measurement is performed the last time the WHEN condition is true for either a rising or falling signal. For FALL = LAST, measurement is performed that last time the WHEN condition is true for a falling signal. For RISE = LAST, measurement is performed the last time the WHEN condition is true for a rising signal. LAST is a reserved word and cannot be chosen as a parameter name in the above .MEASURE statements.

MINVAL

If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

out_var

Variable for which the derivative is to be found

result

Name associated with the measured value in the Star-Hspice output

TD

Identifies the time at which measurement is to start

var(2,3)

Variables used to establish conditions at which measurement is to take place

WEIGHT

The calculated error between result and GOAL is multiplied by the weight value. Default = 1.0.

WHEN

Selects the WHEN function

Example

The following example calculates the derivative of V(out) at 25 ns:

.MEAS TRAN slew rate DERIV V(out) AT = 25ns

The following example calculates the derivative of v(1) when v(1) is equal to 0.9*vdd:

.MEAS TRAN slew DERIV v(1) WHEN v(1) = '0.90*vdd'

The following example calculates the derivative of VP(output)/360.0 when the frequency is 10 kHz:

.MEAS AC delay DERIV 'VP(output)/360.0' AT = 10khz

ERROR Function

The relative error function reports the relative difference of two output variables. This format is often used in optimization and curve fitting of measured data. The relative error format specifies the variable to be measured and calculated from the .PARAM variables. The relative error between the two is calculated using the ERR, ERR1, ERR2, or ERR3 function. With this format, you can specify a group of parameters to vary to match the calculated value and the measured data.

Syntax
.MEASURE <DC|AC|TRAN> result ERRfun meas_var calc_var <MINVAL = val>
+ < IGNORE | YMIN = val> <YMAX = val> <WEIGHT = val> <FROM = val>
+ <TO = val>

where:

 

<DC|AC|TRAN>

Specifies the analysis type of the measurement. If omitted, the last analysis mode requested is assumed.

result

Name associated with the measured result in the output

ERRfun

ERRfun indicates which error function to use: ERR, ERR1, ERR2, or ERR3.

meas_var

Name of any output variable or parameter in the data statement. M denotes the meas_var in the error equation.

calc_var

Name of the simulated output variable or parameter in the .MEASURE statement to be compared with meas_var. C denotes the calc_var in the error equation.

IGNOR|YMIN

If the absolute value of meas_var is less than IGNOR value, then this point is not considered in the ERRfun calculation. Default = 1.0e-15.

FROM

Specifies the beginning of the ERRfun calculation. For transient analysis, the from value is in units of time. Defaults to the first value of the sweep variable.

WEIGHT

The calculated error is multiplied by the weight value. Default = 1.0.

YMAX

If the absolute value of meas_var is greater than the YMAX value, then this point is not considered in the ERRfun calculation. Default = 1.0e+15.

TO

Specifies the end of the ERRfun calculation. Defaults to the last value of the sweep variable.

MINVAL

If the absolute value of meas_var is less than MINVAL, the meas_var value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

Error Equations

ERR

ERR sums the squares of (M-C)/max (M, MINVAL) for each point, divides by the number of points, and then takes the square root of the result. M (meas_var) and C (calc_var) are the measured and calculated values of the device or circuit response, respectively. NPTS is the number of data points.

 

ERR1

ERR1 computes the relative error at each point. For NPTS points, there are NPTS ERR1 error function calculations. For device characterization, the ERR1 approach has been found to be more efficient than the other error functions (ERR, ERR2, ERR3).

, i = 1,NPTS

Star-Hspice does not print out each calculated ERR1 value. When the ERR1 option is set, it returns an ERR value calculated as follows:

 

ERR2

This option computes the absolute relative error at each point. For NPTS points, there are NPTS error function calls.

, i = 1,NPTS

The returned value printed for ERR2 is

 

ERR3

, i = 1,NPTS

The + and - signs correspond to a positive and negative M/C ratio, respectively.


NOTE: If the measured value M is less than MINVAL, the MINVAL is used instead. Also, if the absolute value of M is less than the IGNOR | YMIN value or greater than the YMAX value, then this point is not considered in the error calculation.
Star-Hspice Manual - Release 2001.2 - June 2001