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.
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
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.
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.
.MEASURE <DC|AC|TRAN> result TRIG ... TARG ...
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>
TRIG trig_var VAL = trig_val <TD = time_delay> <CROSS = c>
+ <RISE = r> <FALL = f>
TARG targ_var VAL = targ_val <TD = time_delay>
+ <CROSS = c | LAST> <RISE = r | LAST> <FALL = f | LAST>
.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.
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.
.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>
.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>
.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>
.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>
.MEASURE <DC|TRAN|AC> result FIND out_var1 AT = val <GOAL = val>
+ <MINVAL = val> <WEIGHT = val>
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.
.MEASURE <DC|TRAN|AC> result PARAM = 'equation'
+ <GOAL = val> <MINVAL = val>
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.
.MEASURE <DC|AC|TRAN> result func out_var <FROM = val> <TO = val>
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>
.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
The INTEGRAL function provides the integral of an output variable over a specified period.
.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).
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
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.
.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var AT = val <GOAL = val>
+ <MINVAL = val> <WEIGHT = val>
.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>
.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>
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
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.
.MEASURE <DC|AC|TRAN> result ERRfun meas_var calc_var <MINVAL = val>
+ < IGNORE | YMIN = val> <YMAX = val> <WEIGHT = val> <FROM = val>
+ <TO = val>
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 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).
Star-Hspice does not print out each calculated ERR1 value. When the ERR1 option is set, it returns an ERR value calculated as follows:
This option computes the absolute relative error at each point. For NPTS points, there are NPTS error function calls.
The returned value printed for ERR2 is
The + and - signs correspond to a positive and negative M/C ratio, respectively.