Spice simulator interface classess
Spice
Analog simulation interface package for TheSyDeKick.
Provides utilities to import spice-like modules to Python environment and generate testbenches for the various simulation cases.
Initially written by Okko Järvinen, 2019
Notes for developers
There are now two ways to provide simulator dependent structures that are (most of the time) followed:
1. Simulator dependent properties are defined in packages <simulator>/<simulator>.py that are used as spice_simulator instance in this spice class inside spice_simulator property. Properties and attributed of instance of this class (i.e. all TheSyDeKick Entitites) are made visible to spice_simulators through passing the self as parent argument in instance creation. Properties defined inside spice_simulator are accessed and set through corresponding properties of this class.
2. This is an interface package, generic spice simulation related methods should be provided in spice_methods module.
- class spice.spice[source]
- connect_spice_inputs()[source]
Automatically called function to connect iofiles (inputs) to top entity IOS Bundle items.
- connect_spice_outputs()[source]
Automatically called function to connect iofiles (outputs) to top entity IOS Bundle items.
- property dcsource_bundle
A thesdk.Bundle containing spice_dcsource objects. The spice_dcsource objects are automatically added to this Bundle, nothing should be manually added.
This is to automate biasing and operation conditions of the circuit.
- Type:
Bundle
- property distributed_run
If True, distributes applicable simulations (currently DC sweep supported) into the LSF cluster. The number of subprocesses launched is set by self.num_processes.
(Default False)
- Type:
- property dspf
List containing filenames for DSPF-files to be included for post-layout simulations. The names given in this list are matched to dspf-files in ‘./spice/’ -directory. A postfix ‘.pex.dspf’ is automatically appended to the given names (this will probably change later).
Example
self.dspf = ['adc_top_level']
would include files ‘./spice/adc_top_level.pex.dspf’ as a top level dspf-file in the testbench. If the dspf-file contains definition matching the original design name of the top-level netlist, it gets also renamed to match the module name (dspf-file for top-level instance is possible).
- Type:
[str]
- property errpreset
Global accuracy parameter for Spectre simulations. Options include ‘liberal’, ‘moderate’ and ‘conservative’, in order of rising accuracy.
Example
self.spice_simulator.errpreset='conservative'
- Type:
- extract_powers()[source]
Automatically called function to extract transient power and current consumptions. The consumptions are extracted for spice_dcsource objects with the attribute extract=True.
The extracted consumptions are accessible on the top-level after simulation as:
# Dictionary with averaged power of each supply + total self.extracts.Members['powers'] # Dictionary with averaged current of each supply + total self.extracts.Members['currents'] # Dictionary with transient current of each supply self.extracts.Members['curr_tran']
The keys in the aforementioned dictionaries match the name-fields of the respective spice_dcsource objects.
- property extracts
A thesdk.Bundle containing extracted quantities.
- Type:
Bundle
- property interactive_spice
Launch simulator in interactive mode. A waveform viewer (ezwave by default) is opened during the simulation for debugging. See plotprogram for selecting waveform viewer program.
( Default : False )
- Type:
- property iofile_eventdict
Dictionary to store event type output from the simulations. This should speed up reading the results.
NOTE: Eldo seems to force output names to uppercase, let’s uppercase everything here to avoid key mismatches. (This should be changed).
- Type:
- property load_output_file
Whether to load the outputs from simulator output file. This only works if the file exists in the state directory, i.e. the simulator was run with save_output_file=True. WARNING: This will read the IOS from the output file, and REWRITE THE ENTITY STATE on disk.
( Default : False )
- Type:
- property load_state
Feature for loading results of previous simulation. The Spice simulation is not re-executed, but the outputs will be read from existing files. The string value should be the runname of the desired simulation.
( Default ‘’ )
Example
Loading the most recent result automatically:
self.load_state = 'last' # or self.load_state = 'latest'
Loading a specific past result using the runname:
self.load_state = '20201002103638_tmpdbw11nr4'
List available results by providing any non-existent runname:
self.load_state = 'this_does_not_exist'
- Type:
- property nproc
Requested maximum number of threads for multithreaded simulations.
Eldo : maps to command line parameter ‘-nproc’
Spectre : maps to command line parameter ‘+mt’.
Ngspice : maps to ‘set num_threads=’ line in testbench.
- Type:
- property plotlist
List of net names to be saved in the waveform database.
Note
Obsolete! Moved to spice_simcmd as a keyword argument.
- Type:
[ str ]
- property plotprogram
Sets the program to be used for visualizing waveform databases. Options are ezwave (default) or viva.
- Type:
- property postlayout
Enables post-layout optimizations in the simulator command options. (Default : False )
- Type:
- property postlayout_subckts
List containing filenames for subcircuit DSPF-files to be included for post-layout simulations. The names given in this list are matched to dspf-files in ‘./spice/’ -directory. A postfix ‘.pex.dspf’ is automatically appended to the given names (this will probably change later).
Example
self.postlayout_subckts = ['inv_v2','switch_v3']
would include files ‘./spice/inv_v2.pex.dspf’ and ‘./spice/switch_v3.pex.dspf’ as postlayout_subckts-files in the testbench. If top level dspf (self.dspf) is given these are omitted. Otherwise simulator will replace subcircuits with corresponding name with the postlayout netlist defined in the dspf file.
- Type:
[str]
- property preserve_spicefiles
If True, do not delete generated Spice files (testbench, subcircuit, etc.) after simulations. Useful for debugging.
(Default : False )
- Type:
- read_oppts()[source]
Internally called function to read the DC operating points of the circuit TODO: Implement for Eldo as well.
- read_spice_outputs()[source]
Automatically called function to call read() functions of each iofile with direction ‘output’.
- run_plotprogram()[source]
Starting a parallel process for waveform viewer program.
The plotting program command can be set with ‘plotprogram’. Tested for spectre and eldo.
- property save_database
Whether to save the waveform database (.wdb-file for eldo, raw-database for spectre), when save_state=True.
( Default : False)
- Type:
- property save_output_file
If True and save_state is True, copy the output file of simulator to entity statedir. Useful for scavenging results if simulator exited but state was not written to disk for some reason.
( Default : False)
- Type:
- property simcmd_bundle
A thesdk.Bundle containing spice_simcmd objects. The spice_simcmd objects are automatically added to this Bundle, nothing should be manually added.
- Type:
Bundle
- property spice_simulator
The simulator specific operation is defined with an instance of simulator specific class. Properties and methods return values from that class.
- property spice_submission
Defines spice submission prefix from thesdk.GLOBALS[‘LSFSUBMISSION’] and thesdk.GLOBALS[‘LSFINTERACTIVE’] for LSF submissions.
Usually something like ‘bsub -K’ or ‘bsub -I’.
- Type:
- property spice_tb
Testbench instance. You can set the attributes of the testbench and dut below it before you execute run_spice. if
Example
- ::
self.spice_tb.dut.custom_subckt_name=’custom_inverter’ self.run_spice()
- Type:
- property spicecmd
Simulation command string to be executed on the command line. Automatically generated.
- Type:
- property spicecorner
Feature for specifying the ‘section’ of the model library file and simulation temperature. The path to model libraries should be set in TheSDK.config as either ELDOLIBFILE, SPECTRELIBFILE or NGSPICELIBFILE variable.
Example
self.spicecorner = { 'temp': 27, 'corner': 'top_tt' }
- Type:
- property spicedbpath
Path to output waveform database. (<spicesimpath>/tb_<entityname>.<resultfile_ext>) (For now only for spectre. HOW? should work for Eldo too)
- Type:
- property spicemisc
List of manual commands to be pasted to the testbench. The strings are pasted to their own lines (no linebreaks needed), and the syntax is unchanged.
Example
Setting initial voltages from testbench (Eldo):
for i in range(nodes): self.spicemisc.append('.ic NODE<%d> 0' % i)
The same example for Spectre:
self.spicemisc.append('simulator lang=spice') for i in range(nodes): self.spicemisc.append('.ic NODE<%d> 0' % i) self.spicemisc.append('simulator lang=spectre')
- Type:
[str]
- property spiceoptions
Feature for specifying options for spice simulation. The key is the name of the option (as in simulator manual specifies), and the value is the value given to said option. Valid key-value pairs can be found from the manual of the simulator (Eldo, Spectre or Ngspice).
Example
self.spiceoptions = { 'save': 'lvlpub', 'nestlvl': '1', 'pwr': 'subckts', 'digits': '12' }
- Type:
- property spiceparameters
Feature for specifying simulation parameters for spice simulation. The key is the name of the parameter , and the value is the value given to said parameter.
Example
self.spiceparameters = { 'nf_pmos': 8, 'nf_nmos': 4, 'ibias': 100e-6 }
- Type:
- property spicesimpath
Path to the directory where the simulation results are stored.
( Default : self.simpath )
- Type:
- property spicesrc
Path to the source netlist. Can be set manually to desired location.
( Default: ‘spice/entityname.scs’ )
- N.B!:
Netlist has to contain the top-level design as a subcircuit definition!
- Type:
- property spicesrcpath
Path to the spice source of the entity. Can be set manually to desired location. This variable provides the dspf-parasitic netlist filepath.
( Default: <entity path>/spice )
- Type:
- property spicesubcktsrc
Path to the parsed subcircuit file. (‘<spicesimpath>/subckt_entityname.<suffix>’). This shouldn’t be set manually.
- Type:
- property spicetbsrc
Path to the spice testbench (‘<spicesimpath>/tb_entityname.<suffix>’). This shouldn’t be set manually.
- Type:
- property syntaxdict
Internally used dictionary for common syntax conversions between Spectre, Eldo, and Ngspice.
- Type:
Spice Common
Mix-in class of ommon properties and methods for spice simulator classes
- class spice.spice_common.spice_common[source]
Common properties and methods for spice simulator tool classes. Most of these are overloaded in __init__.py
- property extracts
Bundle
A thesdk.Bundle containing extracted quantities.
- property is_strobed
Check if simulation was strobed or not
- property strobe_indices
Internally set list of indices corresponding to time,amplitude pairs whose time value of is a multiple of the strobeperiod (see spice_simcmd).
Spice Testbench
Testbench generation class for spice simulations.
- class spice.testbench.testbench(parent=None, **kwargs)[source]
This class generates all testbench contents. This class is utilized by the main spice class.
Executes init of testbench_common, thus having the same attributes and parameters.
- Parameters:
**kwargs – See module testbench_common
- property DEBUG
This fixes DEBUG prints in spice_iofile, by propagating the DEBUG flag of the parent entity.
- property dcsourcestr
DC source definitions parsed from spice_dcsource objects instantiated in the parent entity.
- Type:
- property dspfincludecmd
String
DSPF-file inclusion string pointing to files corresponding to self.dspf in the parent entity.
- property dut
Design under test
- Type:
- export(**kwargs)[source]
Internally called function to write the testbench to a file.
- Parameters:
force (Bool, False) –
- property includecmd
String
Subcircuit inclusion string pointing to generated subckt_* -file.
- property inputsignals
Input signal definitions parsed from spice_iofile objects instantiated in the parent entity.
- Type:
- property libcmd
Library inclusion string. Parsed from self.spicecorner -dictionary in the parent entity, as well as ‘ELDOLIBFILE’ or ‘SPECTRELIBFILE’ global variables in TheSDK.config.
- Type:
- property misccmd
String
Miscellaneous command string corresponding to self.spicemisc -list in the parent entity.
- property parameters
String
Spice parameters string parsed from self.spiceparameters -dictionary in the parent entity.
- property plotcmd
All output IOs are mapped to plot or print statements in the testbench. Also manual plot commands through spice_simcmd.plotlist are handled here.
- Type:
- property simcmdstr
Simulation command definition parsed from spice_simcmd object instantiated in the parent entity.
- Type:
- property testbench_simulator
The simulator specific operation is defined with an instance of simulator specific class. Properties and methods return values from that class.
- Type:
- Type:
- Type:
Spice Testbench
Testbench generation class for spice simulations.
- class spice.testbench_common.testbench_common(parent=None, **kwargs)[source]
This class generates all testbench contents. This class is utilized by the main spice class.
- property dcsources
bundle of DC sources inherited from parent
- Type:
bundle
- esc_bus(name, esc_colon=True)[source]
Helper function to escape bus characters for Spectre simulations:
self.esc_bus('bus<3:0>') # Returns 'bus\<3\:0\>'
- property header
The header of the testbench
- property iofiles
bundle of iofiles inherited from parent
- Type:
bundle
- property options
Spice options string parsed from self.spiceoptions -dictionary in the parent entity.
- Type:
- property simcmds
bundle of simulation commands inherited from parent
- Type:
bundle
Spice IO-file
Provides spice file IO related attributes and methods for TheSDK spice.
Initially written by Okko Järvinen, 2020
- class spice.spice_iofile.spice_iofile(parent=None, **kwargs)[source]
Class to provide file IO for spice simulations. When created, adds a spice_iofile object to the parents iofile_bundle property. Accessible as iofile_bundle.Members[‘name’].
- dir
Direction of the IO.
- Type:
‘in’ or ‘out’
- iotype
Type of the IO signal. Event type signals are time-value pairs (analog signal), whereas sample type signals are sampled by a clock signal (digital bus). Sample type signals can be used for discrete time & continuous amplitude outputs (sampled voltage for example), by setting iotype=’sample’ and ioformat=’volt’. Time type signals return a vector of timestamps corresponding to threshold crossings.
- Type:
‘event’, ‘sample’ or ‘time’
- ioformat
Formatting of the sampled signals. Digital output buses are formatted to unsigned integers when ioformat = ‘dec’. For ‘bin’, the digital output bus is returned as a string containing ones and zeros. When ioformat = ‘volt’, the output signal is sampled at the clock and the floating point value is returned. Voltage sampling is only supported for non-bus signals.
- Type:
‘dec’, ‘bin’ or ‘volt’
- sourcetype
Type of the source associated to a file. Default ‘V’.
- Type:
‘V’, ‘I’ or ‘ISUB’
- datatype
Inherited from the parent. If complex, the ioname is handled as a complex signal. Currently implemented only for writing the ouputs in testbenches and reading them in.
- Type:
- trigger
Name of the clock signal node in the Spice netlist. If a single string is given, the same clock signal is used for all bits/buses. If a list is given, and the length matches ionames list length, each ioname will be assigned its own clock. Applies only to sample type outputs.
- vth
Threshold voltage of the trigger signal and the bit rounding. Applies only to sample type outputs.
- Type:
- edgetype
Type of triggering edge. When time type signal is used, the edgetype values can define the extraction type as ‘risetime’ or ‘falltime’ additionally. Default ‘rising’.
- Type:
‘rising’, ‘falling’ or ‘both’
- after
Initial delay added to the input signal (sample) or time extraction (time). Useful for ignoring inital settling, for example. Applies only to sample and time outputs. Default 0.
- Type:
- big_endian
Flag to read the extracted bus as big-endian. Applies only to sample type outputs. Default False.
- Type:
- strobe
True if the event type IO uses only the strobe filtered values. False if the IO contains all of the values simulated values (not consistently strobed). Default False.
- Type:
Examples
Initiated in parent as:
_=spice_iofile(self,name='foobar')
Defining analog input voltage signals from python to spice:
_=spice_iofile(self,name='inp',dir='in',iotype='event',sourcetype='V',ionames='INP') _=spice_iofile(self,name='inn',dir='in',iotype='event',sourcetype='V',ionames='INN')
Defining time-domain output signal containing rising edge threshold crossing timestamps of an analog clock signal:
_=spice_iofile(self,name='clk_rise',dir='out',iotype='time',sourcetype='V', ionames='CLK',edgetype='rising',vth=self.vdd/2)
Defining digital output signal triggered with a falling edge of the analog clock:
_=spice_iofile(self,name='dout',dir='out',iotype='sample',sourcetype='V', ioformat='bin',ionames='DOUT<7:0>',edgetype='falling', vth=self.vdd/2,trigger='CLK')
Defining a discrete time & continuous amplitude output signal triggered with a rising edge of the analog clock. The iofile returns a 2D-vector similar to ‘event’ type signals:
_=spice_iofile(self,name='sampled_input',dir='out',iotype='sample',sourcetype='V', ioformat='volt',ionames='INP',edgetype='rising', vth=self.vdd/2,trigger='CLK')
Defining digital input signal with decimal format. The input vector is a list of integers, which get converted to binary bus of 4-bits (inferred from ‘CTRL<3:0>’). The values are changed at 1 MHz interval in this example.:
_=spice_iofile(self,name='ctrl',dir='in',iotype='sample',ionames='CTRL<3:0>',rs=1e6, vhi=self.vdd,trise=5e-12,tfall=5e-12,ioformat='dec')
- Parameters:
parent (object, None) – The parent object initializing the iofile instance. Default None
**kwargs –
- name: str
Name of the file. Appended with random string during the simulation.
- param: str, -g g_file
The string defining the testbench parameter to be be passed to the simulator at command line.
- property DEBUG
This fixes DEBUG prints in spice_iofile, by propagating the DEBUG flag of the parent entity.
- append_to_data(arr=None, bits=False, buswidth=None)[source]
Helper method to append array to self.Data.
The array(s) are padded with np.nan when bits=False, and ‘UUUU’ when bits=True. This is called automatically for time and sample type IOs.
- property file
List<str>
List containing filepaths to files associated with this spice_iofile. For digital buses or arrays of signals, the list contains multiple files which are automatically handled together. These filepaths are set automatically.
- interp_crossings(data, vth, nint, edgetype)[source]
Helper method called for ‘time’ and ‘sample’ type outputs.
Interpolates the requested threshold crossings (rising or falling) from the ‘event’ type input signal. Returns the time-stamps of the crossing instants in a 1D-vector.
- Parameters:
data (ndarray) – Input data array. Expected an ‘event’ type 2D-vector where first column is time and second is voltage.
vth (float) – Threshold voltage.
nint (int) – Interpolation factor. The two closest points on each side of a threshold crossing are used for linear interpolation endpoints, where nint points are added to find as close x-value of the threshold crossing as possible.
edgetype (str) – Direction of the crossing: ‘rising’, ‘falling’ or ‘both’.
- Returns:
1D-vector with time-stamps of interpolated threshold crossings.
- Return type:
ndarray
- property ionames
List<str>
Set by argument ‘ionames’. This property casts the given argument to a list if needed.
- parse_io_from_file(filepath, start, stop, dtype, labels, queue)[source]
Parse specific lines from a spectre print file.
This is wrapped to a function to allow parallelism.
- sample_signal(signal, trigger, nint=1)[source]
Helper method called for ‘sample’ type outputs.
Finds the signal y-values at time instants defined by the clock signal (trigger).
- Parameters:
data (ndarray) – Input data array. Expected an ‘event’ type 2D-vector where first column is time and second is voltage.
vth (float) – Threshold voltage.
nint (int) – Interpolation factor. The two closest points on each side of a threshold crossing are used for linear interpolation endpoints, where nint points are added to find as close x-value of the threshold crossing as possible.
edgetype (str) – Direction of the crossing: ‘rising’, ‘falling’ or ‘both’.
- Returns:
1D-vector with time-stamps of interpolated threshold crossings.
- Return type:
ndarray
Spice Simulation Command
Class for spice simulation commands.
Initially written by Okko Järvinen, 9.1.2020
- class spice.spice_simcmd.spice_simcmd(parent, **kwargs)[source]
Class to provide simulation command parameters to spice testbench. When instantiated in the parent class, this class automatically attaches spice_simcmd objects to simcmd_bundle -bundle in testbench.
- sim
Simulation type.
- Type:
‘tran’ or ‘dc’
- plotlist
List of node names or operating points to be plotted. Node names follow simulator syntax. For Eldo, the voltage/current specifier is expected:
self.plotlist = ['v(OUT)','v(CLK)']
For Spectre, the node name is enough:
self.plotlist = ['OUT','CLK']
Note
Below applies only for Spectre!
When capturing operating point information with Spectre, adding the instance name to plotlist saves all operating points for the device, e.g:
self.plotlist = [XTB_NAME.XSUBCKT/M0]
saves all operating points defined by the model for the device M0 in subckt XSUBCKT.
Wildcards are supported, but should be used with caution as the output file can quickly become excessively large. For example to capture the gm of all transistor use:
self.plotlist = [*:gm]
It is highly recommended to exclude the devices that are not needed from the output to reduce file size. Examples of such devices are RC-parasitics (include option savefilter=’rc’ in self.spiceoptions to exclude them) and dummy transistors. See excludelist below.
- excludelist
Applies for Spectre only! List of device names NOT to be included in the output report. Wildcards are supported. Exclude list is especially useful for DC simulations when specifiying outputs with wildcards.
For example, when capturing gm for all transistors, use exclude list to exclude all dummy transistors with:
self.excludelist = [XTB_NAME*DUMMY_ID*],
where DUMMY_ID is extraction tool / runset specific dummy identifier.
- sweep
DC & Spectre models only. Name of parameter to be swept in DC analysis. If given as a list, performs a nested sweep of the parameters defined by the list (first element will be the outermost sweep). For example:
_spice_simcmd(sim=’dc’,sweep=’temp’,swpstart=27,swpstop=87)
sweeps the top-level parameter temp (temperature) from 27 to 87 in 10 degree increments.
- Type:
List[str]
- subcktname
If given, sweeps the parameter defined by property sweep from the subcircuit given by this property. For example:
_=spice_simcmd(sim='dc',sweep='Vb',subcktname='XSUBCKT', swpstart=0.1,swpstop=1.5,step=0.05)
sweeps the Vb parameter from subcircuit XSUBCKT from 0.1 volts to 1.5 volts with 0.05 volt increments.
- Type:
List[str]
- devname
If given, sweeps the parameter defined by property sweep from the device given by this property. For example:
_=spice_simcmd(sim='dc', sweep='w', deviceswp='XSUBCKT.XNMOS', swpstart='10u', swpstop='14u', step='0.1u')
sweeps the width of transistor XNMOS of subckt XSUBCKT from 10u to 14u in 0.1u increments.
- Type:
List[str]
- tstop
Transient simulation duration. When not defined, the simulation time is the duration of the longest input signal.
- fscale
Logarithmic or linear scale for frequency. Default ‘log’.
- Type:
‘log’ or ‘lin’
- fstepsize
Step size for AC analysis, if scale if ‘lin’. If fscale is ‘log’, this parameter gives number of points per decade. Default 0.
- Type:
- cmin
Spectre cmin parameter: this much cap from each node to ground. Might speed up simulation. Default None (not used).
- Type:
- mc
Enable Monte Carlo simulation. This flag will enable Monte Carlo modeling for a single simulation. It will NOT execute multiple runs or do any statistical analysis. Intended use case is to generate a group of entities in the testbench with each having mc=True, simulating them in parallel (see run_parallel() of thesdk-class), post-processing results in Python.
- Type:
- step
According to Spectre: minimum time step used by the simulator solely to maintain the aesthetics of the computed waveforms.
- Type:
- strobeperiod
For Spectre only! Forces simulator to write output data to file at interval defined by this parameter. Note that the simulator still outputs points between the sampling points.
- Type:
- skipstart
For Spectre only! Delay between start of transient simulation and first strobed output, if strobedelay is None.
- Type:
Examples
Initiated in parent as:
_=spice_simcmd(self,sim='tran',tprint=1e-12,tstop='10n', uic=True,noise=True,fmin=1,fmax=5e9)
For a simple transient with inferred simulation duration:
_=spice_simcmd(self,sim='tran')
Spice Module
Class for Spice netlist parsing.
- class spice.spice_module.spice_module(**kwargs)[source]
This class parses source netlist for subcircuits and handles the generation of a separate pruned subckt_* -file. This class is internally utilized by the spice_testbench module.
- property custom_subckt_name
Custom name of the subcircuit to look from from the netlist file during parsing for ‘subckt’ property. Enables using compatible (in term sof IOs paremeters) netlists defined for designs of different name.
- Type:
Example
Most common use case of module is a dut in a testbench. There you can set this parameter before execution as:
self.spice_tb.dut.custom_subckt_name = 'some_name' self.run_spice()
- export_subckts(**kwargs)[source]
Internally called function to write the parsed subcircuit definitions to a file.
- Parameters:
file (str) – Path to file where to write.
force (Bool, False) – Force writing
- property file
Filepath to the entity’s spice netlist source file (i.e. ‘./spice/entityname.scs’).
- Type:
- property instance
The subcircuit instance to be placed in the testbench. Parsed from the subckt property
- Type:
Ngspice
Simulator specific definitions for Ngspice
Initially written by Marko Kosunen, 2021
- class spice.ngspice.ngspice.ngspice(parent=None, **kwargs)[source]
This class is used as instance in simulatormodule property of spice class. Contains language dependent definitions.
- Parameters:
parent (object, None (mandatory to define). TheSyDeKick parent entity object for this simulator class.) –
**kwargs – None
- property csvskip
int
- Type:
Needs documentation. Lines skipped in result file
- property plflag
Postlayout simulation accuracy/RC reduction flag.
- property plotprogram
String
Sets the program to be used for visualizing waveform databases.
- read_oppts()[source]
Internally called function to read the DC operating points of the circuit TODO: Implement for Eldo as well.
- run_plotprogram()[source]
Starting a parallel process for waveform viewer program.
The plotting program command can be set with ‘plotprogram’. Tested for spectre and eldo.
- property spicecmd
Simulation command string to be executed on the command line. Automatically generated.
- Type:
- property syntaxdict
Dictionary
Internally used dictionary for syntax conversions
Eldo
Eldo simulation interface package for TheSyDeKick.
Initially written by Okko Järvinen, 2019
- class spice.eldo.eldo.eldo(parent=None, **kwargs)[source]
This class is used as instance in spice_simulatormodule property of spice class. Contains simulator dependent definitions.
- Parameters:
parent (object, None (mandatory to define). TheSyDeKick parent entity object for this simulator class.) –
**kwargs – None
- property cmdfile_ext
str
- Type:
Extension of the command file
- property commentchar
str
- Type:
Comment character of the simulator
- property commentline
str
- Type:
Comment line for the simulator
- property csvskip
int
- Type:
Needs documentation. Lines skipped in result file
- property dcsource_declaration
str
- Type:
DC source declaration
- property dspfinclude
str
- Type:
Netlist dspf-file include string
- property eventoutdelim
str
- Type:
Delimiter for the events
- property include
str
- Type:
Netlist include string
- property lastline
str
- Type:
Last line of the simulator command file
- property nprocflag
str
- Type:
String for defining multithread execution
- property option
str
- Type:
Netlist option definition string
- property parameter
str
- Type:
Netlist parameter definition string
- property plflag
Postlayout simulation accuracy/RC reduction flag.
- property plotprogram
String
Sets the program to be used for visualizing waveform databases. Options are ezwave (default) or viva.
- read_oppts()[source]
Internally called function to read the DC operating points of the circuit TODO: Implement for Eldo as well.
- property resultfile_ext
str
- Type:
Extension of the result file
- run_plotprogram()[source]
Starting a parallel process for waveform viewer program.
The plotting program command can be set with ‘plotprogram’. Tested for spectre and eldo.
- property simulatorcmd
str
- Type:
Simulator execution command
- property spicecmd
String
Simulation command string to be executed on the command line. Automatically generated.
- property subckt
str
- Type:
Subcircuit include string
- property syntaxdict
Spectre
Spectre simulation interface package for Spectre for TheSyDeKick.
Initially written by Okko Järvinen, 2019
- class spice.spectre.spectre.spectre(parent=None, **kwargs)[source]
This class is used as instance in spice_simulatormodule property of spice class. Contains simulator dependent definitions.
- Parameters:
parent (object, None (mandatory to define). TheSyDeKick parent entity object for this simulator class.) –
**kwargs – None
- property cmdfile_ext
str
- Type:
Extension of the command file
- property commentchar
str
- Type:
Comment character of the simulator
- property commentline
str
- Type:
Comment line for the simulator
- property csvskip
int
- Type:
Needs documentation. Lines skipped in result file
- property dcsource_declaration
str
- Type:
DC source declaration
- property dspfinclude
str
- Type:
Netlist dspf-file include string
- property errpreset
String
Global accuracy parameter for Spectre simulations. Options include ‘liberal’, ‘moderate’ and ‘conservative’, in order of rising accuracy. You can set this by accesssing spice langmodule
Example
self.spice_langmodule.errpreset=’conservative’
- property eventoutdelim
str
- Type:
Delimiter for the events
- property include
str
- Type:
Netlist include string
- property lastline
str
- Type:
Last line of the simulator command file
- property nprocflag
str
- Type:
String for defining multithread execution
- property option
str
- Type:
Netlist option definition string
- property parameter
str
- Type:
Netlist parameter definition string
- property plflag
Postlayout simulation accuracy/RC reduction flag. See: https://community.cadence.com/cadence_blogs_8/b/cic/posts/spectre-optimizing-spectre-aps-performance
- property plflag_simcmd_prefix
Simulator specific prefix for enabling postlayout optimization Postfix comes from self.plflag (user defined)
- property plotprogram
String
Sets the program to be used for visualizing waveform databases. Options are ezwave (default) or viva.
- read_oppts()[source]
Internally called function to read the DC operating points of the circuit TODO: Implement for Eldo as well.
- property resultfile_ext
str
- Type:
Extension of the result file
- run_plotprogram()[source]
Starting a parallel process for waveform viewer program.
The plotting program command can be set with ‘plotprogram’ property.
- property simulatorcmd
str
- Type:
Simulator execution command
- property spicecmd
String
Simulation command string to be executed on the command line. Automatically generated.
- property subckt
str
- Type:
Subcircuit include string
- property syntaxdict
Ngspice Testbench
Simulators sepecific testbench generation class for Ngspice.
- class spice.ngspice.ngspice_testbench.ngspice_testbench(parent=None, **kwargs)[source]
Executes init of testbench_common, thus having the same attributes and parameters.
- Parameters:
**kwargs – See module testbench_common
- property dcsourcestr
DC source definitions parsed from spice_dcsource objects instantiated in the parent entity.
- Type:
- property inputsignals
Input signal definitions parsed from spice_iofile objects instantiated in the parent entity.
- Type:
- property libcmd
Library inclusion string. Parsed from self.spicecorner -dictionary in the parent entity, as well as ‘ELDOLIBFILE’ or ‘SPECTRELIBFILE’ global variables in TheSDK.config.
- Type:
- property options
String
Spice options string parsed from self.spiceoptions -dictionary in the parent entity.
- property plotcmd
All output IOs are mapped to plot or print statements in the testbench. Also manual plot commands through spice_simcmd.plotlist are handled here.
- Type:
- property simcmdstr
String
Simulation command definition parsed from spice_simcmd object instantiated in the parent entity.
Eldo Testbench
Simulators sepecific testbench generation class for Ngspice.
- class spice.eldo.eldo_testbench.eldo_testbench(parent=None, **kwargs)[source]
Executes init of testbench_common, thus having the same attributes and parameters.
- Parameters:
**kwargs – See module testbench_common
- property dcsourcestr
String
DC source definitions parsed from spice_dcsource objects instantiated in the parent entity.
- property inputsignals
Input signal definitions parsed from spice_iofile objects instantiated in the parent entity.
- Type:
- property libcmd
Library inclusion string. Parsed from self.spicecorner -dictionary in the parent entity, as well as ‘ELDOLIBFILE’ or ‘SPECTRELIBFILE’ global variables in TheSDK.config.
- Type:
- property options
String
Spice options string parsed from self.spiceoptions -dictionary in the parent entity.
- property plotcmd
All output IOs are mapped to plot or print statements in the testbench. Also manual plot commands through spice_simcmd.plotlist are handled here.
- Type:
Spectre Testbench
Simulators sepecific testbench generation class for Spectre.
- class spice.spectre.spectre_testbench.spectre_testbench(parent=None, **kwargs)[source]
Executes init of testbench_common, thus having the same attributes and parameters.
- Parameters:
**kwargs – See module testbench_common
- property dcsourcestr
DC source definitions parsed from spice_dcsource objects instantiated in the parent entity.
- Type:
- property inputsignals
Input signal definitions parsed from spice_iofile objects instantiated in the parent entity.
- Type:
- property libcmd
Library inclusion string. Parsed from self.spicecorner -dictionary in the parent entity, as well as ‘ELDOLIBFILE’ or ‘SPECTRELIBFILE’ global variables in TheSDK.config.
- Type:
- property num_cols
Number of columns in the output file, when using Spectre. Each signal takes 1 column (unless it is complex, then two). Each column is 15 bit wide, hence number of columns is multiplied by 15.
- property options
String
Spice options string parsed from self.spiceoptions -dictionary in the parent entity.
- property plotcmd
All output IOs are mapped to plot or print statements in the testbench. Also manual plot commands through spice_simcmd.plotlist are handled here.
- Type:
Spice DC Source
Class for generating DC voltage/current sources in the Spectre or Eldo testbench.
Initially written by Okko Järvinen, 9.1.2020
- class spice.spice_dcsource.spice_dcsource(parent, **kwargs)[source]
Class to provide DC source definitions to spice testbench. When instantiated in the parent class, this class automatically attaches spice_dcsource objects to dcsource_bundle -bundle in testbench.
- paramname
To parameterize the DC source, provide this value during instantiation. The parameter will be automatically added to spiceparameters with the default value of self.value.
- Type:
- sourcetype
Type of the DC source. Either ‘V’ for voltage or ‘I’ for current.
- Type:
‘V’ or ‘I’
- extract
Flag the source for transient current and power consumption extraction. Extracted currents and powers are accessible through dictionaries self.currents and self.powers in the parent object. Default False.
- Type:
- ext_stop
Time to stop extracting average transient power consumption. Default is simulation end time.
- Type:
- noise
Enable the noise contribution of this source (only when transient noise is enabled). Default is True.
- Type:
Examples
A voltage source connected between circuit nodes ‘VDD’ and ‘VSS’, for which power and current consumptions are extracted in transient simulation. Initiated in parent as:
_=spice_dcsource(self,name='supply',value=1.0,extract=True,pos='VDD',neg='VSS') _=spice_dcsource(self,name='ground',value=0,pos='VSS',neg='0') # Ground 'source'
A bias current flowing from ‘VDD’ to node ‘IBIAS’:
_=spice_dcsource(self,name='bias',sourcetype='I',value=25e-6,pos='VDD',neg='IBIAS')
- property ext_file
String
Optional filepath for extracted transient current when self.extract=True.