pdkmaster.io.spice package¶
pdkmaster.io.spice.spice_¶
This module contains support for direct SPICE input and output.
- class pdkmaster.io.spice.spice_.SpicePrimsParamSpec[source]¶
Bases:
Dict[_DevicePrimitive,Dict[str,Any]]SpicePrimsParamSpecis a structure to declare extra parameters related toDevicePrimitiveTobject of a technology that are needed specifically to generate SPICE/PySpice circuits.This class is used by first generating an empty object and then adding SPICE parameters for primitives using the
add_device_params()method.- add_device_params(*, prim: Resistor, model: str | None = None, is_subcircuit: bool | None = False, subcircuit_paramalias: Dict[str, str] | None = None, sheetres: float | None = None)[source]¶
- add_device_params(*, prim: MIMCapacitor | Diode, model: str | None = None, is_subcircuit: bool | None = True, subcircuit_paramalias: Dict[str, str] | None = None)
- add_device_params(*, prim: MOSFET, model: str | None = None, is_subcircuit: bool | None = False)
- add_device_params(*, prim: Bipolar, model: str | None = None, is_subcircuit: bool | None = False)
The
add_device_params()method is called at most once for each device primitive one wants to add params for. The params that can be specified depend on the device primitive type.- Parameters:
model –
alternative model name for use in SPICE circuit.
By default the name of the primitive is also used as the SPICE model name
is_subcircuit –
wether the model is a SPICE subcircuit or element
Default is
Truefor aMIMCapacitorandFalsefor the other device primitives.subcircuit_paramalias (for
Resistor,MIMCapacitorandDiode) –alias for parameters for the subcircuit model.
This value is a dict that specifies the alias for the parameters of the primitive. The keys the names of the parameter for the
DevicePrimitiveTthe values the name of the parameter used by the SPICE subcircuit.Either no parameter has to be specified are all of them. It may not be specified when
is_subcircuitisFalse.Default values:
for
Resistor:{"width": "w", "length": "l"},for
MIMCapacitor:{"width": "w", "height": "h"},for
Diode:{"width": "w", "height": "h"},
sheetres (for
Resistor) – the sheet resistance for theResistorprimitive
pdkmaster.io.spice.pyspice¶
This module allows to convert PDKMaster based circuits into PySpice circuits.
Currently PDKMaster only supports to create circuits with primitives from the technology and does not allow to also SPICE generic elements like a generic resistor or capacitance. This means that these elements need to be added to the circuit after they have been converted to PySpice.
This is planned to be tackled in #40
API Notes
This module is WIP and has no stable API; backwards compatibility may be broken at any time.
- class pdkmaster.io.spice.pyspice.PySpiceFactory(*, libfile: str, corners: Iterable[str], conflicts: Dict[str, Tuple[str, ...]], prims_params: SpicePrimsParamSpec)[source]¶
Bases:
objectThe
PySpiceFactoryallows to convert_Circuitobjects generated throughCircuitFactoryobject toPySpicecircuits and sub circuits.Typically the PDK provider will also provide a
PySpiceFactoryobject that allows to convert toPySpiceobjects that use the SPICE simulation files provided by the PDK.- Parameters:
libfile – the full path to the SPICE lib file to include in the generated SPICE objects
corners – A list of valid corners for this lib file.
conflicts –
For a given corner it gives the conrers with which it conflicts, e.g. if you have:
"typ": ("ff", "ss"),as an element in the dict it means that you can’t specify
"typ"corner with the"ff"and"ss"corner.prims_params – extra parameters for the models of
DevicePrimitiveTobject. SeeSpicePrimsParamSpecfor more information.
API Notes
The API of
PySpiceFactoryis in flux and no backwards compatiblity guarantees are given at this moment.
- new_pyspicecircuit(*, corner: str | Iterable[str], top: _Circuit, subckts: Iterable[_Circuit] | None = None, title: str | None = None, gnd: str | None = None)[source]¶
This method converts a PDKMaster
_Circuitobject to a PySpiceCircuitobject.The returned object type is actually a cubclass of the PySpice Circuit class.
- Parameters:
corner – The corner(s) valid for the Circuit. This needs to be a valid corner as specified during
PySpiceFactoryinit.top – The top circuit for the generated PySpice
Circuitobject. The top circuit will be included in the PySpiceCircuitas a subcircuit and then instantiated as Xtop. For each of the pins a net in the SPICE top level will be generated with the same name.subckts – An optional list of subcircuits. These will be included in the generated object as PySpice subcircuits. If not provided a list will be generated hierarchically from the given top Circuit.
title – An optional title to set in the generated PySpice object.
gnd – An optional name of the ground net name in the circuit.
- new_pyspicesubcircuit(*, circuit: _Circuit, lvs: bool = False)[source]¶
This method convert a PDKMaster
_Circuitobject to a PySpiceSubCircuitobject.The returned object type is actually a subclass of the PySpice
SubCircuitclass.- Parameters:
circuit – The circuit to make a PySpice
Circuitfor.lvs – wether to generate a subcircuit for (klayout) based. lvs generated circuit may use other device primitive in the generated netlists than the other ones that are mainly to be used in simulation.