1.3. pyopus.simulator.vacask — VACASK simulator support

VACASK batch mode interface (PyOPUS subsystem name: VASI)
VACASK is a free Verilog-A based circuit simulator. This module uses it in batch mode.
The circuit is loaded and elaborated once per job group. Simulator options, circuit variables (parameters), and save directives are set in the control block for every job separately. Consequently jobs with identical circuit definitions are joined in the same job group.
The temperature parameter represents the circuit’s temperature in degrees
centigrade (temp simulator option). The temp simulator option is not
allowed to appear in the simulator options list.
A job sequence in VACASK is a list of lists containing the indices of jobs belonging to individual job groups.
Every job produces one raw file holding one plot. See
pyopus.simulator.rawfile module for the details on the result files.
The analysis command of a job is a Python expression that evaluates to a
tuple (sweeps, analysis, sweepDepth). sweeps is a list of VACASK
sweep directives (outermost first) that are written in front of the
analysis, analysis is the analysis specification, and sweepDepth is
the number of outer sweeps whose sweep points are split into separate
results. Swept analyses are built with an() (an_general()) and
sweep() (an_sweep()). Sweep points are accessed with the
sweepPointCount(),
sweepPoint(), and
sweepVars() methods of
VacaskSimulationResults.
- class pyopus.simulator.vacask.Vacask(binary=None, args=[], debug=0, timeout=None)[source]
A class for interfacing with the VACASK simulator in batch mode.
binary is the path to the VACASK simulator binary. If it is not given the
VACASKHOMEenvironmental variable is used as the path to the VACASK installation. The simulator is assumed to be inVACASKHOME/bin. IfVACASKHOMEis not defined the system path is searched. If the binary is not found there it is assumed to be in the current working directory.args specifies a list of additional arguments passed to the simulator binary at startup.
If debug is greater than 0 debug messages are printed at the standard output. If it is above 1 a part of the simulator output is also printed. If debug is above 2 full simulator output is printed.
timeout is the maximal time in seconds a simulator run (one job group) may take. If it is exceeded the simulator is killed and the run is reported as failed.
None(default) means no limit.The save directives from the simulator job description are evaluated in an environment where the following objects are available:
all- a reference to thesave_all()functionv- a reference to thesave_voltage()functioni- a reference to thesave_current()functiondv- a reference to thesave_dvoltage()functiondi- a reference to thesave_dcurrent()functionp- a reference to thesave_property()functionipath- a reference to theipath()function
Similarly the environment for evaluating the analysis command given in the job description consists of the following objects:
op- a reference to thean_op()functiondc- a reference to thean_dc()functiontf- a reference to thean_tf()functionac- a reference to thean_ac()functiontran- a reference to thean_tran()functionnoise- a reference to thean_noise()functionan- a reference to thean_general()functionsweep- a reference to thean_sweep()functionipath- a reference to theipath()functionparam- a dictionary containing the members of theparamsentry in the simulator job description together with the parameters from the dictionary passed at the last call to thesetInputParameters()method. The parameters values given in the job description take precedence over the values passed to thesetInputParameters()method.
Values of simulator options (
optionsentry of the job description) and parameters (paramsentry and the values passed tosetInputParameters()) are converted to VACASK syntax:boolbecomes1or0integers and reals are converted with
str()strings are double quoted
lists and NumPy arrays become vectors (
[...])tuples become lists (
{...})
The same rules apply to the values in the args dictionaries of
an_general()andan_sweep().For every job group one simulator input file is generated. It includes the circuit definitions, followed by a control block with one section per job. Every section clears the settings of the previous job, sets the simulator options, circuit variables, and save directives, and runs the job’s analysis. See
writeFile()for details.- cleanupResults(i)[source]
Removes all result files that were produced during the simulation of the i-th job group. Simulator input files are left untouched.
- classmethod findSimulator()[source]
Finds the simulator. Location is defined by the VACASKHOME environmental variable. If VACASKHOME is not set the system path is used.
- optimizedJobSequence()[source]
Returns the optimized job sequence.
Jobs in a job group have identical circuit definitions. Simulator options, parameters, and save directives are set for every job separately.
- readResults(jobIndex, runOK=None)[source]
Read results of a job with given jobIndex.
runOK specifies the status returned by the
runJobGroup()method which produced the results. If not specified the run status stored by the simulator is used.Returns an object of the class
VacaskSimulationResults. If the run failed or the results file cannot be read theNoneis returned.The sweep depth of the job (the third member of the tuple returned by the analysis generator, recorded by
writeFile()) is passed to theVacaskSimulationResultsconstructor. It determines how the results are split into sweep points. IfwriteFile()was not yet called for the job group containing the job (e.g. results of an earlier run are read with a new simulator object) the sweep depth is unknown and 0 is used, i.e. the whole result is treated as a single sweep point.
- runFile(fileName)[source]
Runs the simulator on the input file given by fileName.
Returns
Trueif the simulation finished successfully. This does not mean that any results were produced. It only means that the return code from the simuator was 0 (OK).
- runJobGroup(i)[source]
Runs the i-th job group.
First calls the
writeFile()method followed by thecleanupResults()method that removes any old results produced by previous runs of the jobs in i-th job group. Finally therunFile()method is invoked. Its return value is stored in thelastRunStatusmember.The function returns a tuple (jobIndices, status) where jobIndices is a list of job indices corresponding to the i-th job group. status is the status returned by the
runFile()method.
- unoptimizedJobSequence()[source]
Returns the unoptimized job sequence. If there are n jobs the job list the following list of lists is returned:
[[0], [1], ..., [n-1]]. This means we have n job groups with one job per job group.
- writeFile(i)[source]
Prepares the simulator input file for running the i-th job group.
The file is named
simulatorID.groupi.simwhere i is the index of the job group.System description modules are converted to
includedirectives. They are followed by acontrolblock holding the commands for all jobs in the job group.Every job starts with a
clearcommand that clears save directives, circuit variables, and simulator options set by the previous job. Next therawfile="binary"andstrictoutput=2simulator options are set. Consequently all output files with simulation results are .raw files in binary format.Simulator options are set with the
optionssimulator command. Values are converted to VACASK syntax (booleans to 0/1, strings are quoted, lists and arrays become vectors, tuples become lists).The parameters set with the last call to
setInputParameters()method are joined with the parameters in the job description. The values from the job description take precedence over the values specified with thesetInputParameters()method. All parameters are written to the input file in form ofvarsimulator commands.The
temperatureparameter is written as thetempsimulator option.Save directives are written as a series of
savesimulator commands.Every analysis command is evaluated in its corresponding environment taking into account the parameter values passed to the
setInputParameters()method. The resulting sweep statements are written in front of theanalysiscommand. The sweep depth is stored forreadResults().The analysis is named by
_analysisName(). The name is quoted if it is not a valid VACASK identifier. The analysis results are stored in a file named after the analysis with the.rawextension.The function returns the name of the simulator input file it generated.
- class pyopus.simulator.vacask.VacaskSimulationResults(rawData, params={}, variables={}, results={}, sweepDepth=0)[source]
Objects of this class hold VACASK simulation results.
rawData is the list of plots returned by
raw_read(). VACASK raw files hold only one result (one plot) so only the first plot is used.params and variables are the parameters and Python variables of the job that produced the results. results is passed to the
SimulationResultsconstructor.sweepDepth is the number of outer sweeps whose sweep points are split into separate results. The first sweepDepth vectors in the raw file are the sweep variables (outermost first). A new sweep point starts wherever the value of any of these vectors changes. The default scale is the vector that follows the sweep variables. If sweepDepth is 0 the whole result is one sweep point and the default scale is the first vector in the raw file.
By default all accessor methods return the data of all sweep points.
sweepPoint()returns a shallow copy of the results object restricted to a single sweep point. The copy shares the raw data with the original object. CallingsweepPoint()on such a copy raises an error.The values of the sweep variables are returned by
sweepVars(). For results of small-signal analyses (e.g. AC, noise) these values are complex because all vectors in the raw file are complex.- driverTable()[source]
Returns a dictionary of available driver functions for accessing simulation results.
They are used for measurement evaluation in
PerformanceEvaluatorobjects where they appear as a part of the environment for evaluating the measures. The following functions (dictionary key names) are available:ipath- a reference to theipath()function for constructing object paths in hierarchical designsscaleName- thescaleName()methodscale- thescale()methodvectorNames- thevectorNames()methodvector- thevector()methodv- thev()methodi- thei()methodp- thep()methodns- thens()methodsweepPointCount- thesweepPointCount()methodsweepPoint- thesweepPoint()method. The returned object provides the same methods (e.g.sweepPoint(k).v('out')) restricted to the k-th sweep point.sweepVars- thesweepVars()method
The functions apply to the whole result (all sweep points) if this object was not obtained with
sweepPoint(). Otherwise they apply to the sweep point held by this object.
- i(name)[source]
Retrieves the current flowing through instance name.
Equivalent to VACASK vector
name:flow(br).
- ns(reference, name=None, contrib=None)[source]
Retrieves the noise spectrum density of contribution contrib of instance name to the output noise spectrum density. reference can be
'input'or'output'.If name and contrib are not given the total output or the equivalent total input noise spectrum density is returned (depending on the value of reference).
Partial and total noise spectra are returned as squared noise (in V^2/Hz or A^2/Hz). VACASK computes only output referred spectra. Input referred spectra (total and partial) are obtained by dividing the output referred spectra by the power gain from the input source to the output (vector
gain).
- p(name, parameter, index=None)[source]
Retrieves the property named parameter belonging to instance named name. VACASK does not support vector properties so index must not be given.
Note that this works only of the property was saved with a corresponding save directive.
Equivalent to VACASK vector
name.parameter.
- scale(vecName=None)[source]
If vecName is specified returns the scale corresponding to the specified vector. Usually this is the default scale.
If vecName is not specified returns the default scale.
- scaleName(vecName=None)[source]
If vecName is specified returns the name of the scale vector corresponding to the specified vector. Usually this is the default scale.
If vecName is not specified returns the name of the vector holding the default scale.
- sweepPoint(index=0)[source]
Return simulation results for the sweep point with given index (0 to
sweepPointCount()-1).The returned object is a shallow copy of this object. It shares the raw data with this object, but all its accessor methods return only the part of the vectors that belongs to the selected sweep point. Its
sweepVars()method returns the values of the sweep variables for that sweep point.If sweepDepth is 0 there is one sweep point holding the whole result.
Raises an error if there are no results or if this object was itself obtained with
sweepPoint().
- sweepPointCount()[source]
Return the number of sweep points.
Returns 0 if there are no results or if the object was obtained with
sweepPoint()(i.e. it already holds a single sweep point).
- sweepVars()[source]
Return the values of sweep variables in a dictionary. Keys are sweep names, ordered from the outermost to the innermost sweep.
For the full results object the values are arrays with one entry per sweep point. For an object obtained with
sweepPoint()the values are scalars belonging to that sweep point.For results of small-signal analyses (e.g. AC, noise) the values are complex. If sweepDepth is 0 the dictionary is empty.
- pyopus.simulator.vacask.an_ac(start, stop, sweep, points)[source]
Generates the VACASK simulator command that invokes the small signal (AC) analysis. The range of the frequency sweep is given by start and stop. sweep is one of
'lin'- linear sweep with the number of points given by points'dec'- logarithmic sweep with points per decade (scale range of 1..10) given by points'oct'- logarithmic sweep with points per octave (scale range of 1..2) given by points
Equivalent of VACASK
analysis name ac from=start to=stop mode="sweep" points=pointssimulator command.
- pyopus.simulator.vacask.an_dc(start, stop, sweep, points, name, parameter, index=None)[source]
Generates the VACASK simulator command that invokes the operating point sweep (DC) analysis. start and stop give the initial and the final value of the swept parameter.
sweep can be one of
'lin'- linear sweep with the number of points given by points'dec'- logarithmic sweep with points per decade (scale range of 1..10) given by points'oct'- logarithmic sweep with points per octave (scale range of 1..2) given by points
name gives the name of the instance whose parameter is swept. If name is
Noneand parameter is'temperature'the circuit temperature is swept. VACASK does not support vector parameters so index must not be given.VACASK cannot sweep an instance parameter that is bound to an expression. The swept parameter must be given a literal value in the netlist (e.g.
dc=0).The swept values are stored in vector
dcsweep.Equivalent of VACASK
sweep dcsweep instance="name" parameter="param" from=start to=stop mode="sweep" points=pointsfollowed byanalysis name opsimulator command.
- pyopus.simulator.vacask.an_general(anType, args={}, sweeps=[], sweepDepth=None)[source]
Constructs an arbitrary VACASK analysis of type anType with arguments given by args dictionary and optional sweeps given by sweeps list.
Keys of args are analysis parameter names. Values are converted to VACASK values (strings are quoted, lists and arrays become vectors, tuples become lists).
sweeps is a list of complete VACASK sweep statements (
sweep name ...), outermost sweep first.sweepDepth is the number of outermost sweeps whose sweep points are split into separate results (see
VacaskSimulationResults.sweepPoint()). The remaining (innermost) sweeps are treated as part of the analysis, i.e. the first of them becomes the default scale. If sweepDepth is not given all sweeps are split (sweepDepth equals the length of sweeps).Equivalent of VACASK sweep statements given by sweeps followed by
analysis name anType arg1=value1 arg2=value2 ...simulator command.
- pyopus.simulator.vacask.an_noise(start, stop, sweep, points, input, outp=None, outn=None, outcur=None, ptsSum=1)[source]
Generates the VACASK simulator command that invokes the small signal noise analysis. The range of the frequency sweep is given by start and stop. sweep is one of
'lin'- linear sweep with the number of points given by points'dec'- logarithmic sweep with points per decade (scale range of 1..10) given by points'oct'- logarithmic sweep with points per octave (scale range of 1..2) given by points
input is the name of the independent voltage/current source that is used for calculating the input referred noise. outp and outn give the voltage that is used as the output voltage. If only outp is given the output voltage is the voltage at node outp. If outn is also given, the output voltage is the voltage between nodes outp and outn. If outcur is given the current flowing through the instance with that name (
outcur:flow(br)) is considered to be the output. ptsSum is ignored.VACASK computes only output referred noise spectra: the total (vector
onoise) and the partial spectra of instances (n(inst)) and their contributions (n(inst,contrib)). The power gain from input to the output is stored in vectorgain. Input referred spectra (total and partial) are obtained by dividing the output referred spectra bygain(seeVacaskSimulationResults.ns()).Equivalent of VACASK
analysis name noise out=... in="input" from=start to=stop mode="sweep" points=pointssimulator command.
- pyopus.simulator.vacask.an_op()[source]
Generates the VACASK simulator command that invokes the operating point analysis.
Equivalent of VACASK
analysis name opsimulator command.Analysis generators return a tuple (sweeps, analysis, depth). sweeps is a list of sweep statements, outermost first. analysis is the analysis type followed by analysis parameters. depth is the number of outer sweeps whose sweep points are split into separate results. Sweeps that form the scale of the analysis (e.g. the sweep of a DC analysis) are not counted in depth.
- pyopus.simulator.vacask.an_sweep(name, args={})[source]
Constructs a VACASK sweep named name with arguments given by args.
Keys of args are sweep parameter names. Values are converted to VACASK values (strings are quoted, lists and arrays become vectors, tuples become lists).
VACASK cannot sweep an instance parameter that is bound to an expression. A parameter swept with
instance=...andparameter=...must be given a literal value in the netlist.Equivalent of VACASK
sweep name arg1=value1 arg2=value2 ...statement. The result can be passed as a member of the sweeps list inan_general().
- pyopus.simulator.vacask.an_tf(src, outp=None, outn=None, outcur=None)[source]
Generates the VACASK simulator command that invokes the small signal (TF) analysis.
src is the name of the independent voltage/current source that generates the input signal. VACASK computes the transfer functions from all independent sources so src is used only for retrieving the results. outp and outn give the voltage that is used as the output voltage. If only outp is given the output voltage is the voltage at node outp. If outn is also given, the output voltage is the voltage between nodes outp and outn. If outcur is given the current flowing through the instance with that name (
outcur:flow(br)) is considered to be the output.The transfer functions are small-signal DC transfer functions evaluated at the operating point which VACASK computes before the analysis.
The results are stored in vectors
tf(src),zin(src), andyin(src).Equivalent of VACASK
analysis name dcxf out=...simulator command.
- pyopus.simulator.vacask.an_tran(step, stop, start=0.0, maxStep=None, uic=False)[source]
Generates the VACASK simulator command that invokes the transient analysis. The range of the time sweep is given by start and stop. step is the intiial time step. The upper limit on the time step is given by maxStep. If the uic flag is set to
Truethe initial conditions are used as the first point of the transient analysis instead of the operating point analysis results.If uic is
Trueand maxStep is not given, the default value maxStep is step.Equivalent of VACASK
analysis name tran step=step stop=stop start=start maxstep=maxStep [icmode="uic"]simulator command.
- pyopus.simulator.vacask.ipath(input, outerHierarchy=None, innerHierarchy=None, objectType='inst')[source]
Constructs a hierarchical path for the instance with name given by input. The object is located within outerHierarchy (a list of instances with innermost instance listed first). innerHierarchy a list of names specifying the instance hierarchy inner to the input instance. The innermost instance name is listed first. If outerHierarchy is not given input is assumed to be the outermost element in the hierarchy. Similarly if innerHierarchy is not given input is assumed to be the innermost element in the hierarchy.
Returns a string representing a hierarchical path.
If input is a list the return value is also a list representing hierarchical paths corresponding to elements in input.
innerHierarchy and outerHierarchy can also be ordinary strings (equivalent to a list with only one string as a member).
The objectType argument is for compatibility with other simulators. Because VACASK treats the hierarchical paths of all objects in the same way, the return value does not depend on objectType. The available values of objectType are
'inst','mod', and'node'.VACASK hierarchical paths begin with the outermost instance followed by its enclosed instances. Colon (
:) is used as the separator between instances in the hierarchy. Sox2:x1:m1is an instance namedm1that is a part ofx1(insidex1) which in turn is a part ofx2(insidex2).Some examples:
ipath('m1', ['x1', 'x2'])- instance namedm1insidex1insidex2. Returns'x2:x1:m1'.ipath('x1', innerHierarchy=['m0', 'x0'])- instancem0insidex0insidex1. Returns'x1:x0:m0'.ipath(['m1', 'm2'], ['x1', 'x2']) - instances ``m1andm2insidex1insidex2. Returns['x2:x1:m1', 'x2:x1:m2'].ipath(['xm1', 'xm2'], ['x1', 'x2'], 'm0')- instances namedm0inside pathsx2:x1:xm1andx2:x1:xm2. Returns['x2:x1:xm1:m0', 'x2:x1:xm2:m0'].
- pyopus.simulator.vacask.save_all()[source]
Returns a save directive that saves all results the analysis normally saves in its output.
Equivalent of VACASK
save defaultsimulator command.
- pyopus.simulator.vacask.save_current(what)[source]
If what si a string it returns a save directive that instructs the simulator to save the current flowing through instance names *what in simulator output. If what is a list of strings multiple save diretives are returned instructing the simulator to save the currents flowing through instances with names given by the what list.
Applies to op, dc, and tran analyses and to the operating point results of small signal analyses.
Equivalent of VACASK
save i(what)simulator command.
- pyopus.simulator.vacask.save_dcurrent(what)[source]
If what is a string it returns a save directive that instructs the simulator to save the small signal current flowing through instance names *what in simulator output. If what is a list of strings multiple save diretives are returned instructing the simulator to save the small signal currents flowing through instances with names given by the what list.
Applies to ac analysis.
Equivalent of VACASK
save di(what)simulator command.
- pyopus.simulator.vacask.save_dvoltage(what)[source]
If what is a string it returns a save directive that instructs the simulator to save the small signal voltage of node named what in simulator output. If what is a list of strings multiple save directives are returned instructing the simulator to save the small signal voltages of nodes with names given by the what list.
Applies to ac analysis.
Equivalent of VACASK
save dv(what)simulator command.
- pyopus.simulator.vacask.save_property(devices, params, indices=None)[source]
Saves the properties given by the list of property names in params of instances with names given by the devices list.
If params and devices have n and m memebrs, n*m save directives are returned describing all combinations of device name and property name.
VACASK does not support vector properties. Specifying indices raises an error.
Equvalent of VACASK
save p(device, property)simulator command.
- pyopus.simulator.vacask.save_voltage(what)[source]
If what is a string it returns a save directive that instructs the simulator to save the voltage of node named what in simulator output. If what is a list of strings multiple save directives are returned instructing the simulator to save the voltages of nodes with names given by the what list.
Applies to op, dc, and tran analyses and to the operating point results of small signal analyses.
Equivalent of VACASK
save v(what)simulator command.