Metadata-Version: 2.4
Name: pyspicey
Version: 0.1.3
Summary: A quick reference and code generator for SPICE netlist commands
Project-URL: Homepage, https://github.com/ethnchiu/pyspicey
Project-URL: Issues, https://github.com/ethnchiu/pyspicey/issues
Author-email: Ethan Chiu <chiue2023@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: circuit-simulation,cli,electronics,netlist,ngspice,spice
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# pyspicey

[![Tests](https://github.com/ethnchiu/pyspicey/actions/workflows/tests.yml/badge.svg)](https://github.com/ethnchiu/pyspicey/actions/workflows/tests.yml)
[![Publish](https://github.com/ethnchiu/pyspicey/actions/workflows/publish.yml/badge.svg)](https://github.com/ethnchiu/pyspicey/actions/workflows/publish.yml)
[![PyPI](https://img.shields.io/pypi/v/pyspicey.svg)](https://pypi.org/project/pyspicey/)

<p align="center">
  <img
    src="https://raw.githubusercontent.com/ethnchiu/pyspicey/main/assets/pyspicey-logo.png"
    alt="pyspicey"
    width="200"
  >
</p>

A command-line reference and code generator for SPICE netlist syntax. Look up
a device or statement, see exactly what parameters it takes, and generate a
correct line of SPICE code without having to remember argument order.

## Install

```bash
pip install pyspicey
```

## Usage

List every available command, grouped by category:

```bash
$ pyspicey --list
Available SPICE commands (run `pyspicey <name> --help` for details):

Analysis Statements:
  ac     Small-signal AC sweep analysis (.AC)
  dc     DC sweep analysis (.DC)
  op     DC operating point analysis (.OP)
  tran   Transient analysis (.TRAN)

Controlled Sources:
  e      Voltage-controlled voltage source (VCVS)
  f      Current-controlled current source (CCCS)
  g      Voltage-controlled current source (VCCS)
  h      Current-controlled voltage source (CCVS)

Independent Sources:
  i      Independent DC/AC current source
  v      Independent DC/AC voltage source

Passive Elements:
  c      Capacitor
  l      Inductor
  r      Resistor

Semiconductor Devices:
  d      Diode
  m      MOSFET
  q      Bipolar junction transistor (BJT)

Source Functions:
  exp    Exponential waveform source function
  pulse  Pulse waveform source function
  pwl    Piecewise linear waveform source function
  sffm   Single-frequency FM waveform source function
  sin    Sinusoidal waveform source function

Subcircuits:
  x      Subcircuit instantiation
```

See the full parameter reference for a command:

```bash
$ pyspicey pwl --help
usage: pyspicey pwl [-h] [--current] [--r REPEAT] [--td TD]
                     name n_plus n_minus points [points ...]

Generates a waveform that linearly interpolates between explicit (time,
value) points, holding at the final value after the last point. Embed this
in a V or I source line.

positional arguments:
  name        Element name (V prefix added automatically, unless --current
              is given)
  n_plus      Positive node
  n_minus     Negative node
  points      Time/value pairs: t1 v1 t2 v2 ...

options:
  -h, --help  show this help message and exit
  --current   Emit an I (current) source instead of a V (voltage) source
  --r REPEAT  Repeat (loop) time
  --td TD     Time delay before the waveform starts

examples:
  pyspicey pwl VS in 0 0 0 1m 5 2m 0 3m 0
```

Generate the actual line of SPICE code:

```bash
$ pyspicey pwl VS in 0 0 0 1m 5 2m 0
VS in 0 PWL(0 0 1m 5 2m 0)

$ pyspicey r 1 in out 10k
R1 in out 10k

$ pyspicey tran 1u 10m --uic
.TRAN 1u 10m UIC
```

Append generated lines straight into a netlist file with `-o`/`--output`
instead of printing them:

```bash
$ pyspicey -o circuit.spice r 1 in out 10k
$ pyspicey -o circuit.spice c 1 out 0 1u --ic 0
$ cat circuit.spice
R1 in out 10k
C1 out 0 1u IC=0
```

## What's covered

- **Passive elements**: `r`, `c`, `l`
- **Independent sources**: `v`, `i`
- **Source functions** (embedded in a V/I line): `pulse`, `sin`, `pwl`,
  `exp`, `sffm`
- **Semiconductor devices**: `d` (diode), `q` (BJT), `m` (MOSFET)
- **Controlled sources**: `e` (VCVS), `g` (VCCS), `f` (CCCS), `h` (CCVS)
- **Subcircuits**: `x`
- **Analysis statements**: `dc`, `ac`, `tran`, `op`

Syntax follows the common Berkeley SPICE3 / ngspice conventions. Some
simulators (LTspice, HSPICE, PSpice) may diverge slightly — check your simulator's docs for anything unusual.

## License

Apache License 2.0 — see [LICENSE](https://github.com/ethnchiu/pyspicey/blob/main/LICENSE).
