When a point has been specified, the only measurement form available is
A .measure statement can contain any number of measurements, including no measurements. If no measurement is specified, the vector produced contains only zeros, however the scale vector contains the start and stop values, which may be the only result needed. The created vector, which is added to the current plot, will be of length equal to the number of measurements, with the results placed in the vector in order.
The measurement scale point(s) in .measure statements are also saved in a vector, which is the scale for the result vector. If the measurement name is ``result'', then the scale vector is named ``result_scale''. The scale contains one or two values, depending on whether it is a point or interval measurement.
By default, nothing is printed on-screen for a .measure line during interactive simulation. If the keyword print appears in the .measure line, the results will be printed on the standard output. A more concise format can be obtained from the alternative keyword print_terse. The result vectors are created in all cases.
If the keyword stop appears in a .measure line, the analysis will be paused when all measurements are complete. Thus if the deck contains several .measure lines and stop is given in at least one, the analysis will pause when all of the measurements are complete, not just the one containing stop. The analysis can then be resumed with the resume command, or reset with the reset command.
When a .measure is included in an iterative analysis (Monte Carlo, loop, etc.), data are saved as follows. Before each iteration, the previous result vector and its scale are saved to the end of a ``history'' vector and scale, and are then deleted. The result vector and scale are recreated when the measurement is completed during the iteration. Thus, at the end of the analysis, for a measurement named ``example'', one would have the following vectors:
|example||the result from the final trial|
|example_scale||the measurement interval or point in the last trial|
|example_hist||results from the prior trials|
|example_hist_scale||intervals from the prior trials|
Thus, during each trial, the result vector will have the same properties as in a standard run. It can be used in the .control block of a Monte Carlo or operating range file (recall that $?vector can be used to query existence, and that if there is no checkPNTS vector defined, the .control block is called once at the end of each trial).
Multiple .measure lines can be ``chained'' in the following manner. The vector name following the from, to, trig, or targ keywords can be the name of another measure. In this case, the effective start time is the measure time of the referenced measure. The measure time is the end of the interval or the measure point. The td, rise, and other keywords can be used in the referencing measure. The td will be added to the imported time, and the other keywords operate in the normal way. If there are no keywords other than td specified, the time is the delay time plus the imported time.
.measure tran t1 trig v(5) val=.4m rise=3
.measure tran t2 trig v(5) val=.4m rise=4
.measure tran pw trig t1 td=20p targ t2 td=20p pw v(5) max v(5)
In this case, the measures t1 and t2 ``frame'' a period of an (assumed) repeating signal v(5). Note that no actual measurement is performed for these lines. Their purpose is to be referenced in the third line, which takes as its interval the t1-t2 interval delayed by 20 pS, and measures the pulse width and peak value.
It is possible to reference .measure results in sources. The referencing token has the same form as a circuit variable, with an optional index, i.e.
@result[index]where the index, if used, is an integer that references a specific component of the result (0-based). The value is always zero for timepoints before the measurement has been performed, and a constant value afterward.
.measure tran peak from=50n to=150n max v(5)
.measure tran stuff trig v(4) val=4.5 rise=1 targ v(4) val=4.5 fall=2
+ min v(4) max v(4) pp v(4) avg v(4) rms v(4) print
vxx 1 0 @peak
vyy 2 0 @stuff
In this example, during transient analysis, vxx is zero until 150 nS, where the measurement takes place, at which point it jumps to the value measured. Likewise, vyy is zero until the measurement, at which point it jumps to the third component (``pp v(4)'') result. The resulting voltages can be used elsewhere in the circuit. Note that we have two implementations of a behavioral peak detector.