Intusoft has built a comprehensive ICL from the basic script
language that began with UC Berkeley Spice3. This ICL has been
extended to enable many user defined analysis types, including
Worst Case, RSS, etc. The ICL is mostly common to both IsSpice
and IntuScope so that many ICL scripts can be run in either software
program. This feature has eliminated the need to use IntuScope
as a data reduction program for making measurements. In this
article, we will develop an ICL script for Monte Carlo analysis
that will return pre-defined measurement to the SpiceNet database
and also provide for interactive post processing using IntuScope.
To begin with, we will run the ICL as a Simulation Template.
That means that the script will reside in the script folder;
making it accessible from the ICAP/4 Simulation Control Panel.
Details about the ICL and Simulation Template syntax are in http://www.intusoft.com/script/pages/overview.htm.
Reviewing the Pieces that Make
Simulation Templates Work
A Simulation Template is an ICL script that has embedded instructions
telling the netlist program where to insert information and which
options are to be provided. It is used to expand SPICE beyond
the traditional limitations of the basic AC, DC, and Transient
analyses by allowing parameter variations and multiple analysis
passes to be run under one analysis umbrella.
1. Net List Formation:
A Simulation Template has several parts. First there are
directives to the net list builder, SpiceNet for ICAP/4, that
are prefixed using the # symbol. These directives control the
netlist format. For example, #tolerance tells the net list builder
to include component tolerances. #simulation tells the netlist
builder to insert the SPICE simulation the user selected in the
Simulation Setup Dialog. This allows the same template to be
used for different analysis (AC, DC, TRAN, etc).
2. Data Reduction: During a simulation, Spice3 compatible
simulators, including IsSpice4, organize simulation results into
plots, one for each simulation that is run. The plots contain
vectors (i.e. simulation waveforms and other results). Once a
simulation or group of simulations have been run; it is necessary
to get to the results so that measurements can be made. The ICL
uses nextplot and nextvector to enumerate all plots and vectors
so that you can analyze the results without knowing specifically
what was saved or how many simulations were run.
3. Data Output: SpiceNet reads measurements back into
its database from the IsSpice output file. The measurements wizard
takes care of defining and formatting these measurements. We
use the #mprint template to print results to the output file
or to save results as plot vectors. “set printmode = save/print”
distinguishes the direction; save or print. Importantly, the
save direction is not limited by the spice output digits setting
because it gets data directly from the simulator in the double
precision format. There are several additional ICL commands to
allow formatting of printed output so that you can get a human
readable report in the output file. Going one step further, you
can open IntuScope and run ICL scripts to get additional data
that you hadn’t anticipated before running the simulation.
Monte Carlo Strategy:
Monte Carlo analysis was performed one simulation at a time
in the past. Now, using Simulation Templates, we can run all
of the lots and cases within a single simulation. That means
that upon completion, all of the data will be available within
the IsSpice plots and vectors. We allow the user to make measurements
either before or after running the simulations.
A new dialog in IntuScope can be activated after running a
Monte Carlo analysis by pressing the <Monte> button in
the <Add Waveforms> dialog. To plot the statistical results,
you must have saved measurements in the “prob” plot.
You can add to the ones there using the <Monte Carlo> dialog.
Selecting vectors and functions from the appropriate lists does
this; then press the <Add Function to Plot> button. Incidentially,
you can plot all cases of each vector by selecting a vector's
x and y axis and pressing the <Plot all Cases> button.
The really neat stuff happens when you select a measurement
from the “prob” plot and press the plot group buttons.
You get histograms or cumulative probability plots scaled to
your data set. Cumulative probability warps the x axis into “sigmas”
based on a normal distribution. For small sample sizes, it is
much easier to visualize the distribution. We also plot the best
fit of a straight line through these data points. If the data
is normally distributed, it will lay along this straight line.
The slope of the line, or first polynomial coefficient is an
estimate of the standard deviation. The rms error is shown, and
if it’s small compared to the standard deviation, you are
probably looking at a normal distribution.
Next we added a feature to isolate the data set that created
each data point. Simply place cursor 0 on a data point and press
the report button. It tells you which simulation produced the
data and shows each parameter's value and its sigma deviation.
Using this feature, you can get an approximate separation of
class members for cases that have bi-modal distributions. Then
you can separate class members into several groups for more detailed
investigation.
Finally, you can substitute the values associated with one of
the simulations back into the schematic to evaluate a “worst
case” or re-center the design.
The Simulation Template:
The simulation template for Monte Carlo can be viewed in http://www.intusoft.com/scripts/pages/index/monte.htm.
There are two main loops, the first loop collects the statistical
data and the second one fills the “prob” plot with
the measurement results. New ICL command and templates are:
#setmonte: Makes SpiceNet set the lots, cases and distribution
in variable called maxlots, maxcases and distribution.
monte: Tells the simulator the lot and case number in
order to initialize the pseudo random number generators.
The “prob” plot contains vectors for each measurement.
The data in each vector corresponds to the simulation that created
it. For cumulative probability, the data is sorted and plotted
against a sigma vector. IntuScope back tracks the data by identifying
which cell in the corresponding “prob” vector has the
same value.
The IntuScope Monte Carlo Dialog
IntuScope recognizes the existence of a Monte Carlo data set
when a plot named “prob” is present in the IsSpice
data. The dialog shown below becomes accessible by pressing the
<Monte> button in the <Add Waveforms> dialog. |