Skip to content

Getting started

Installation

Nimphel requires Python 3.10 or newer. Clone the repository and create the development environment with uv:

git clone https://github.com/servinagrero/nimphel
cd nimphel
uv sync

Run the test suite with:

uv run pytest

Installing only the runtime library does not install the documentation tool. Use the documentation dependency group when working on this site:

uv sync --group docs

Build a circuit

A Component describes how to create instances. It defines the target primitive or model, its semantic kind, ordered pin names, and optional parameter defaults.

from nimphel import Circuit, Component, ComponentKind

resistor = Component(
    target="resistor",
    pins=("p", "n"),
    kind=ComponentKind.RESISTOR,
    defaults={"r": "1k"},
)

with Circuit(name="divider") as circuit:
    first = resistor(("vin", "vout"))
    second = resistor(("vout", 0), r="2k")

assert first.ref == "R1"
assert second.ref == "R2"

Factories automatically register instances with the innermost active circuit or subcircuit. The equivalent explicit form is:

circuit = Circuit(name="divider")
circuit.add(resistor(("vin", "vout")))
circuit.add(resistor(("vout", 0), r="2k"))

Write Spectre output

from nimphel.writers import SpectreWriter

print(SpectreWriter().dumps(circuit))

The result is:

R1 (vin vout) resistor r=1k
R2 (vout 0) resistor r=2k

Continue with the core API for subcircuits, directives, validation, and reference allocation.