SLiCAPngspice.py
SLiCAP module for interfacing with NGspice.
- class MOS(refDes, lib, dev, W, L, M)
MOS Transistor.
- Parameters:
refDes (str) – Reference designator used in SLiCAP circuit file
lib (str) – path to library file, absolute or relative to python script.
dev (str) – Device name (as in library)
MOS attributes:
self.refDes = refDes
self.lib = lib
self.dev = dev
self.modelDef = Text string with SLiCAP model definition for this device
self.parDefs = Dictionary with SLiCAP parameter definitions for this device
self.params = Dictionary with names and values of parameters provided by ngspice
self.errors = Relative difference between forward and reverse parameter measurement
self.step = Step data for VG or ID, defaults to False
- getOPid(ID, VD, VS, VB, f, step=None)
Returns operating point information of the device with the drain current as (swept) independent variable.
- Parameters:
W (float) – Width of the device in [m]
L (float) – Length of the device in [m]
M (int) – Number of devices in parallel
ID (float) – Drain current [A]
VD (float) – Drain voltage with respect to ground in [V]
VS (float) – Source voltage with respect to ground in [V]
VB (float) – Bulk voltage with respect to ground in [V]
step – Step data for ID; list with start value, number of values and stop value. Defaults to None
- getOPvg(VG, VD, VS, VB, f, step=None)
Returns operating point information of the device with the gate voltage as (swept) independent variable.
- Parameters:
W (float) – Width of the device in [m]
L (float) – Length of the device in [m]
M (int) – Number of devices in parallel
VG (float) – Gate voltage with respect to ground in [V]
VD (float) – Drain voltage with respect to ground in [V]
VS (float) – Source voltage with respect to ground in [V]
VB (float) – Bulk voltage with respect to ground in [V]
step – Step data for VG; list with start value, number of values and stop value. Defaults to None
- getSv_inoise(ID, VD, VS, VB, fmin, fmax, numDec)
- ngspice2traces(cirFile, simCmd, namesDict, stepCmd=None, parList=None, traceType='magPhase', squaredNoise=False)
Creates a dictionary with values or traces from an ngspice run.
- Parameters:
cirFile (str) – Name of the circuit file withouit ‘.cir’ extension, located in the cir folder.
simCmd (str) –
ngspice instruction,
ac dec 20 1 10meg
tran 1n 10u
dc Source Vstart Vstop Vincr [ Source2 Vstart2 Vstop2 Vincr2 ]
noise V(out) Vs dec 10 1 10meg 1
op
stepCmd (str, nonetype) –
Step instruction or None if no parameter stepping is performed:
Syntax: <parname> <stepmethod> <firstvalue> (<lastvalue> <numberofvalues | listwithvalues>)
parname (str): name of the parameter (not a RefDes)
stepmethod (str): lin, log or list
namesDict (dict) –
Dictionary with key-value pairs:
key: plot label (str)
value: nodal voltage, branch current or device parameter in ngspice notation
traceType (str) –
Type of traces for AC analysis or noise analysis:
realImag
magPhase
dBmagPhase
onoise
inoise
parList (list) –
List with parameter definitions, each item in the list must be a tuple with the name and the value of a parameter. The name must be a string, and the value a string, an integer, a float, or a SPICE expression (between curly brackets). The order of parameter definitions should be such that SPICE can evaluate a numeric value for each parameter in a non-recursive way.
- Example:
>>> params = [('R', '1k'), ('C', '1n'), ('tau', '{1/(R*C)}')]
squaredNoise (Bool) –
True: output in V^2/Hz, A^2/Hz, V^2 or A^2
False: output in V/rt(Hz), A/rt(Hz), V or A
Defaults to True
- Returns:
In case of an “OP” instruction without parameter stepping:
A dictionary with key-value pairs:
key: str Name of the variable
value: float Value of the parameter, voltage or current
In all other cases: a tuple (dict, str1, str2)
dict
key: str Name of the variable
value: SLiCAP.SLiCAPplots.trace object or single value
str1: name of the x-variable
str2: units if the x-variable
- Return type:
tuple: dict, (dict, str, str)
- selectTraces(traceDict, namesList)
This function returns a dictionary selected traces from a dictionary with traces.
- Parameters:
traceDict – A dictionary with key-value pairs: - key: name of the trace - value: a SLiCAP.SLiCAPplots.trace object holding trace (x, y) data and a trace label
namesList – A list with names of traces (== keys in traceDict) that needs to be returned
- Returns:
a dictionary with selected traces (sub of traceDict)
- Return type:
dict