icap4 Simulation Templates

 

 

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.

Operation of a template that performs a sensitivity analysis is sketched in the following pseudo-code example:

1.     Instruct the netlist builder to show tolerances
2.     Suppress automatic vector saves
3.     Suppress spice printout
4.     Save vectors needed for measurements
5.     run a reference simulation of whatever kind (op, tran, …) was selected
6.     make the user defined measurements and store the results
7.     loop through all parameters having tolerances
        7.1. alter this parameter and run a simulation
        7.2. make the user defined measurements and store the results
        7.3. store the difference of vectors between this simulation and the reference
8.     loop through all plots except the reference
        8.1. print the sensitivity for each parameter

Lines 1,2 and 3 are directives for the netlist builder while the remaining items are either ICL scripts or insertion points for the netlist builder to insert ICL scripts. Critical to this methodology is the capability to refer to an element in a reference simulation that corresponds to the same element in the current simulation; methods for doing this are provided by new IsSpice4 script enumerating functions.

To provide a capability to insert script fragments repetitively, SpiceNet uses keywords stored in a script file (*.scp files in the SPICE8\Script directory) to tell the netlist builder to insert the required script fragment or to provide options defined by the keyword. These keywords are:

Options
 #tolerance Makes a netlist with tolerances taken from SpiceNet
 #nosave Eliminates the save commands generated by SpiceNet in order to minimize the amount of memory required during multiple analysis passes
 #noprint Eliminates the "print" statements generated by SpiceNet in order to minimize the amount of memory required during multiple analysis passes

Templates

#vector Generates save commands from the measurement vector list
#simulation Generates the simulation control statements (tran, AC, etc.)
#mprint Generates "print" commands for measurements from thesaved vectors. You use #mprint in conjunction with set printmode = [save] or [print]
 #include file Inserts the named file, if no path name is given or a relative path is used, the project folder is taken to be the current folder

Since we must be able to use the same script for different circuits and measurements we must have methods to enumerate the data in each analysis and make comparisons without knowledge of the specific measurements. We have added the following functions and commands to the IsSpice4 Interactive Command Language.

alterparam vec Command to change a parameter (identified by param) value by vec
 current An alias for the name of y-axis vector of the active trace of the active plot, with a plot-name prefix, so that it uniquely identifies a specific trace, even if there are multiple plots containing traces with the same names.
 currentname An alias for the name of y-axis vector of the active trace of the active plot, without a plot-name prefix.
getparam vec Function that returns the value of a param identified by vec.
nextparam vec A command to enumerate parameters that have tolerances. If vec is null, param is set to the first instance parameter that has a tolerance if vec is param, param is set to the next param, if no more parameters are left, param is set to null. This is a command and it has no return value.
nextplot(vec) Function that returns an alias for the scale of the next plot or null if no more plots if vec is null, it returns the first plot scale alias.
nextvector(vec) Function that returns an alias for the next vector, null if none or the first vector if vec is null
null A special vector that can be used in an expression without being declared.
param A special vector used to identify an instance or model parameter. This vector is global and is used to identify the current parameter. Use setparm to assign it a vector value.
printname vec Command to print the parameter name for vec in the next column.
printtext text Command to print text strings in columns. Multiple text strings in quotes is allowed.
printval vec Command to print vec in the next column, new line if no vec.
setparam vec Command to set the current param to vec
tolerance vec Function to return the tolerance of a param identified by vec.
unalterparam Command to restore the parameter value

Since nextvector and nextplot return an alias, the vector can be used to access similar data in another plot; for example:

nv = nextvector(null)
while nv != null
      nv = nv - temp.nv
      nv = nextvector(nv)
end

This script can be used to save the difference for each vector in a plot for a sensitivity analysis. The complete script for the original pseudo-code example is then:

*1. Instruct the netlist builder to show tolerances
      #tolerance

*2. Suppress automatic vector saves
      #nosave

*3. Suppress IsSpice4 printout
      #noprint

*4. Save vectors needed for measurements
      #vector

*5. Run a reference simulation of whatever kind (op, tran, …) was selected
      #simulate

*6. Make the user-defined measurements and store the results
      set printmode = save
      #mprint
      nameplot ref

*7. Loop through all parameters having tolerances
      nextparam null
      while param != null
*7.1. Alter this parameter and run a simulation
      alterparam tolerance(param)/3

*7.2. Make the user-defined measurements and store the results
      #simulate
      #mprint
      paramvec = param

*7.3. Store the difference of vectors between this simulation and 
         the reference simulation
      nv = nextvector(null)
      while nv != null
            if length(nv) = 1
                  nv = nv - ref.nv
            end
      end
      unalterparam
      nextparam param
end
*8. Loop through all plots except the reference
      set printmode = print
      pl = nextplot(null)
      while pl != null
*8.1. Print the sensitivity for each parameter
      if default != ref.default ; except the reference plot
            echo -n "sensitivity for "
            printparam paramvec
            echo -n " tolerance = "
            printval tolerance(paramvec) * 100
            echo " %"
            print text Measurement Value Sensitivity ; headers
            printtest ; newlines
            printtext
            nv = nextvector(null)
            while nv != null
                  if length(nv) = 1
                        printparam nv
                        printval ref.nv nv
                        printval
                  end
                  nv = nextvector(nv)
            end
      end
      pl = nextplot(pl)
      end


Discussion: The above script has several limitations. First, it only reports on scalar measurements; measurements culminating in a single reported value. For example, average value, peak-peak value, or maximum value of a voltage, current or power waveform. This was done to simplify the script since differences in vectors can't be saved without first making them have a common scale. Scripts to perform this operation are described in Plots, Vectors and Scripts. Secondly, the printout would probably not satisfy many users. Therein lies the power of Simulation Templates. It's relatively easy for the user to make a specialized print format that works best for their own business or contract requirements. Finally, the results can't be read back into the results data structure for ICAP/4Windows, ICAP/4Professional or Test Designer. For sensitivity analysis, it requires making a plot that has the desired output the current plot and adding the #mprint keyword after setting printmode = print. Sensitivity itself doesn't produce useful results; however, it is the beginning of a script to find tolerances by RSS, root summed square, techniques or EVA, extreme value analysis. Both of these scripts are included in all ICAP/4 products. For products that don't produce measurement scripts (i.e. ICAP/4Rx), the #include function can be used to bring in measurement and save script files located in the project folder.