Papers
Topics
Authors
Recent
Search
2000 character limit reached

pyspi: Python Package for SPICE Netlists

Updated 10 January 2026
  • pyspi is a Python framework that generates modular, parametric SPICE netlists, enabling efficient electronic circuit simulation.
  • It uses symbolic and statistical parameter handling with a robust API to support hierarchical circuit composition and design space exploration.
  • An alternative implementation, SPIKE, extends the pyspi name to Fourier spectroscopy processing, offering pipelines for FFT, phasing, and baseline correction.

The term "pyspi" refers to multiple Python packages in scientific domains, distinct both by their target field and functionality. The two most prominent are: (i) pyspi, a modular and parametric SPICE netlist generator for electronic circuit simulation, and (ii) SPIKE (“Spectrometry Processing Innovative KErnel”), a Fourier spectroscopy processing kernel. Each is detailed below in its technical context.

1. Modular and Parametric SPICE Netlist Generation with pyspi

The "pyspi" framework is a generic, open-source Python system for constructing modular, highly-parametric SPICE netlists that are simulator-agnostic. It was developed to address the combinatorial complexity inherent in modern electronic system design, where topologies, device variants, and parametric sweeps must be rapidly explored and exported for further simulation. The package enables users to define reusable electronic component templates, instantiate design spaces with symbolic or statistical parameters, and export netlists compatible with major simulators (Gutiérrez et al., 2023).

Key capabilities include programmable component definitions, parametric sweeps (including process corners), high-level circuit composition, and hierarchical subcircuit encapsulation. The system eliminates ad hoc, platform-dependent scripting approaches by offering a robust Python API grounded in architectural primitives.

2. Installation and Dependencies

pyspi requires Python 3.6 or greater. Its core and optional dependencies are designed for rapid deployment and scientific interoperability:

Component Dependency Role
Symbolic computation sympy Symbolic parameter formulas (e.g., device sizing)
Parameter files, PDKs pyyaml (optional) Metadata, parameter sweeps
Statistical utilities numpy (optional) Randomization, statistical parameterization
Simulation launch PySpice, XycePy (optional) Direct SPICE engine invocation

Installation may proceed either by cloning the repository (git clone ...; pip install .) or by using PyPI. Import verification is available post-install.

3. Core Architecture and Data Model

The pyspi architecture divides into five synergistic subsystems (Gutiérrez et al., 2023):

  • Parameter Handling:

The Params class encapsulates parameter dictionaries (float/int, stochastic, or formulaic). ParamSet supports process corner definitions (mapping corner labels to Params).

  • Component and Model Templates:

Component provides reusable device blueprints, supporting operator overloading for port and parameter rebinding. Model formally encapsulates .lib or .model statements for device definitions (e.g., MOS parameters). Subcircuits are first-class, class-inherited circuit objects.

  • Manipulation Primitives:

Specialized classes such as Chain, Parallel, Array, NamedChain, and Inject create large or patterned circuit topologies efficiently, supporting large-scale, programmatic instantiation.

  • Circuit Composition:

The Circuit class assembles all components, manipulations, and subcircuits. The += operator is overloaded for composition, while into_subckt() commits compositions as reusable subcircuits.

  • Export and Parsing Backends:

Generic and simulator-specific exporters (Exporter) render circuits to various SPICE netlist styles (plain, NGspice, Spectre, HSpice, Xyce, Verilog-A). Reader classes handle parsing technology files (PDKs) and Verilog-A subcircuit imports.

4. Parametric and Algorithmic Netlist Assembly

Parameter definitions in pyspi can be static, dynamic (arbitrary Python), or symbolic (Sympy formulas). For example:

nmos_params={w=0.135,  vthN(0.4,0.1),  test=1/vth}nmos\_params = \{\,w=0.135,\;v_{th}\sim\mathcal{N}(0.4,0.1),\;\mathrm{test}=1/v_{th}\}

with

ParamSet{TT ⁣:nmos_params}\text{ParamSet}\bigl\{TT\!:nmos\_params\bigr\}

Assembly is algorithmically deterministic. During export, the system traverses circuit elements in insertion order, recursively expanding manipulation classes into concrete components, flattening subcircuits, evaluating all parameter formulas, assigning unique instance labels, and emitting required SPICE syntax. This allows hierarchical composition, parametric sweeps, process-corner enumeration, and systematic defect injection to be incorporated into netlists with single-line primitives.

5. Usage Modalities and API Examples

pyspi is designed for flexibility in both interactive and scripted workflows. Sample applications include:

  • Defining Parametric Circuits:

1
2
3
4
5
6
7
8
9
from pyspi import Params, Component, Circuit, Exporter
rc_params = Params({ "R": 10e3, "C": 100e-12 })
R1 = Component("Res", ["in", "out"], { "R": rc_params["R"] }, prefix="R")
C1 = Component("Cap", ["out", "0"], { "C": rc_params["C"] }, prefix="C")
netlist = Circuit()
netlist += R1 @ ["Vin", "Vmid"]
netlist += C1 @ ["Vmid", "0"]
exporter = Exporter("ngspice")
exporter.dump_to_file("rc_lowpass.cir")

  • Parametric Sweeps:

1
2
3
4
5
import numpy as np
freqs = np.logspace(1, 6, num=50)
for Rval in freqs:
    R1 = Component("Res", ["in","out"], {"R": Rval}, prefix="R")
    # ... (rest as above)
Netlist generation to various formats occurs via the appropriate exporter class, supporting simulator-specific syntax adaptation.

6. Extensibility and Simulator Integration

To add a new export target, only three methods (header, format_component, footer) must be implemented in a subclass. To import new process design kits or subcircuit definitions, Reader plugins can be registered. As all pyspi circuits exist as pure Python data structures until export, integration into third-party DSE loops, optimization engines, or testing frameworks is direct and nonintrusive (Gutiérrez et al., 2023).

The out-of-the-box exporters handle .lib/.include and .subckt syntax differences across common SPICE engines. Integration with wrappers like PySpice or XycePy facilitates scripting of simulation runs.

7. Alternative: SPIKE for Fourier Spectroscopies

A second package, SPIKE (referred to as "pyspi" in some contexts), targets the processing of Fourier spectroscopies (NMR, FT-ICR-MS, Orbitrap). It provides pipelines for apodization, FFT routines, phasing, peak-picking, baseline correction, and linear prediction (Chiron et al., 2016). SPIKE is architected for big-data handling (parallelism, HDF5/on-disk storage), with key modules for chained processing (“pipe” mechanism), instrument-specific I/O (Bruker, ThermoFisher, mzXML), visualization (matplotlib, Qt GUI), and workflow scripting. Its principal algorithms directly implement domain-standard windowing functions, optimized FFT, phasing algorithms (using Hilbert transforms), baseline correction (Savitzky–Golay, L1 regularization), and AR modeling with Burg's method.

This alternative usage of "pyspi/SPIKE" is entirely orthogonal to electronic design automation, and pertains to analytical chemistry and signal processing. All features are designed for reproducibility, extensible plugins, and batch-mode operation with configuration via YAML/INI (Chiron et al., 2016).


In summary, "pyspi" as referenced in the context of modular SPICE netlist generation is a Python framework that systematizes circuit DSE via symbolic, statistical, and reusable tools for automated SPICE netlist export across multiple simulators (Gutiérrez et al., 2023). Researchers in electronic design or computational spectroscopy should verify package identity before adoption, as "pyspi" denotes distinct specialist packages in each field.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Python Package pyspi.