MONTE, Monte Carlo analysis Simulation Template: ```*Instruct the netlist builder to show tolerances #tolerance *Suppress IsSpice4 printout #noprint *Set the output file pointer to the beginning to remove * the input net list set rewind *Set the noecho environment for print formatting set noecho *Run the specified simulation and save the results #simulation set printmode = save #mprint *Set the print format SET COLWIDTH=22 SET SPICEDIGITS=5 *Rename the simulation plot nameplot ref *Makes The netlist builder set the lots, cases and distribution in *variable called maxlots, maxcases and distribution. #setmonte *Initialize variables constants.binsize = .5 constants.numplots=0 constants.lots = 1 constants.maxlot = \$maxlots + 1 constants.maxcase = \$maxcases + 1 *Loops through the lots while constants.lots < constants.maxlot *Tell the user where we are printstatus -t "lot " printstatus -v lots *Loops through the cases constants.cases = 1 while constants.cases < constants.maxcase *Tell the user where we are printstatus -t "case " printstatus -v constants.cases *Tells the simulator the lot and case number In order to *initialize the pseudo random number generators. monte constants.lots constants.cases *Save all parameter values that have tolerances *in the current plot saveparams *Run the specified simulation and save the results #simulation constants.numplots = constants.numplots + 1 #mprint constants.cases = constants.cases + 1 end; end case loop constants.lots = constants.lots + 1 end; end lot loop *Initialize for saving measured results set printmode = print setplot ref probability = 100/numplots + 100*vector(numplots)/(numplots+1) setplot ref newplot prob probability setplot ref *Make a vector in the prob plot to save results nv = nextvector(null) while nv <> null if length(nv) = 1 prob.nv = unitvec(length(prob.default)) end nv = nextvector(nv) end ``` ```*Loop through the plots setplot refnv=nextvector(null)while nv <> null if length(nv) = 1 constants.plotnum = 0 constants.foundit = 0 pl=nextplot(null) while pl <> null if sameplot(ref.default) = 0 if sameplot(constants.default) = 0 if sameplot(prob.default) = 0 nv2 = nextvector(null) *Add results to the prob vector for each measurement*where each element corresponds to a simulation plot while nv2 <> null if isdef(nv2) if nv = nv2 prob.nv[constants.plotnum] = nv constants.foundit = 1 end end nv2 = nextvector(nv2) end constants.plotnum = constants.plotnum + constants.foundit constants.foundit = 0 end end end pl = nextplot(pl) end end setplot ref nv = nextvector(nv)end *Re-enable echo unset noecho *Set up a plot to hold 5 sigma high results newplot montemax ref.default ref.default setplot prob homecursors *Loop through measurements nv = nextvector(null) while nv <> null if length(ref.nv) = 1 *Save 5 sigma high results montemax.nv = ref.nv + 5 * stddevpts(prob.nv) end nv = nextvector(nv) end ; end measurements loop``` ECHO ECHO *Print 5 sigma high results so that they can be read into the database. setplot montemax echo ########## Monte Carlo Hi analysis Results ############# #mprint *Print run time RUSAGE ELAPSED *Initialize IsSpice for Data Reduction setplot prob