.. _tut-evaluation-spiceopus:

SPICE OPUS simulator interface
==============================

This demo shows how to use the SPICE OPUS simulator interface. Let us first 
take a look at the files in the folder. 

File ``demo/evaluation/01-simulator-spiceopus/cmos180n.lib`` defines two MOSFET 
models: ``nmosmod`` is a NMOS model and ``pmosmod`` is a PMOS model. A total of 
5 variants of these two models are defined in the sections of the library file: 

  * ``tm`` - a typical mean model
  * ``wp`` - worst power model
  * ``ws`` - worst speed model
  * ``wo`` - worst one model
  * ``wz`` - worst zero model
  * ``wcd`` - Monte Carlo model for worst case and worst case distance analysis
  
File ``demo/evaluation/01-simulator-spiceopus/mosmm.inc`` defines the wrappers 
around ``nmosmod`` and ``pmosmod``. 

.. literalinclude:: ../demo/evaluation/01-simulator-spiceopus/mosmm.inc
   :language: none

Every wrapper is a parameterized subcircuit. Parameters ``w``, ``l``, and ``m`` 
specify the channel dimensions and the device multiplier. Parameters ``vtmm`` 
and ``u0mm`` specify the normalized mismatch in terms of normal distribution's 
standard deviation (+1 corresponds to sigma and -1 to -sigma). The typical mean 
model is obtained by setting ``vtmm`` and ``u0mm`` to 0. 

The circuit is described in file 
``demo/evaluation/01-simulator-spiceopus/opamp.cir``. 

.. literalinclude:: ../demo/evaluation/01-simulator-spiceopus/opamp.cir
   :language: none

The file follows the standard SPICE OPUS netlist syntax, except for the missing 
``.end`` statement which is added later by PyOPUS. 

.. figure:: tutorial.evaluation.01-simulator-spiceopus-opamp.png
	:scale: 100%
	:align: center

	The schematic of the opamp subcircuit.
	
.. figure:: tutorial.evaluation.01-simulator-spiceopus-opamptb.png
	:scale: 100%
	:align: center

	The testbench circuit surrounding the opamp.  
	
The following Python script constructs 5 OP analyses (jobs) and passes them to 
the simulator interface. The ``vdd`` and the ``temperature`` parameter are 
specified in the job descriptions. The simulator interface optimizes the order of 
evaluation in such manner that the number of simulator calls is minimized. During 
this process the jobs are grouped in job groups. The job groups are printed. 

The two circuit parameters (``mirr_w`` and ``mirr_l``) are not specified in the 
netlist. They are passed to the simulator interface. Finally, every job groups is 
run and the results are collected. For every job some of the results are printed.  

In the end all intermediate files generated by the simulator interface and the 
simulator are deleted. 

File: ``demo/evaluation/01-simulator-spiceopus/runme.py``

.. literalinclude:: ../demo/evaluation/01-simulator-spiceopus/runme.py
