netlist_io ¤
File-input adapter: parse and evaluate model cards, then build kfnetlist topology.
NetlistParse supplies syntax; kfnetlist owns circuit connectivity. Library resolution retains card scopes and OSDI metadata until compilation provisions models and passes a kfnetlist.Netlist to compile_circuit.
Modules:
| Name | Description |
|---|---|
expressions | Evaluate NetlistParse expression nodes with explicit, scoped name lookup. |
library | Scoped model-card loading and hierarchical circuit elaboration. |
model | Reusable model-library registrations for schematic instance elaboration. |
osdi | Provision OpenVAF modules and compile an elaborated library topology. |
sources | Parse SPICE independent-source specifications into waveform source settings. |
syntax | Direct NetlistParse syntax access, preserving symbolic expressions. |
units | Explicit scalar unit conversion at the schematic/library boundary. |
Classes:
| Name | Description |
|---|---|
Library | Load existing model libraries and elaborate their public subcircuits. |
LibraryModel | Register one library wrapper, binding settings separately per instance. |
NetlistDefinition | Canonical topology and shared leaf models, before solver compilation. |
NetlistError | A netlist could not be parsed or resolved without changing its meaning. |
ResolvedCircuit | Evaluated model cards awaiting conversion to kfnetlist and native models. |
ResolvedInstance | A leaf compact model with evaluated model and instance parameters. |
Functions:
| Name | Description |
|---|---|
parse_source | Parse the value part of a SPICE V/I source card: |
parse_waveform | Parse |
Library ¤
Library(
*,
temperature_c: float = 27.0,
include_paths: tuple[Path, ...] = (),
dialect: str = "ngspice",
statistical_mode: str = "reject"
)
Load existing model libraries and elaborate their public subcircuits.
Parameters and model cards are evaluated separately for each instance. Libraries retain their lexical scopes, local nodes and conditional branches.
Methods:
| Name | Description |
|---|---|
from_file | Read a library and select a named corner section when requested. |
include | Add a library to the same root scope, preserving declaration order. |
inspection_sources | Fingerprint actual parsed source dependencies without native loading. |
instantiate | Expand a library subcircuit without loading executable OSDI modules. |
refreshed | Reuse unchanged parsed cards or reparse edited, removed or shadowed source dependencies. |
resolve | Expand instances declared at the top level of a loaded circuit file. |
with_temperature | Reparse source declarations at a new temperature without mutation. |
Source code in circulax/netlist_io/library.py
from_file classmethod ¤
from_file(
path: str | Path,
*,
section: str | None = None,
temperature_c: float = 27.0,
include_paths: tuple[Path, ...] = (),
dialect: str = "ngspice",
statistical_mode: str = "reject"
) -> Library
Read a library and select a named corner section when requested.
statistical_mode="nominal" explicitly evaluates agauss at its nominal value. The default rejects random functions; sampling is unsupported.
Source code in circulax/netlist_io/library.py
include ¤
Add a library to the same root scope, preserving declaration order.
Source code in circulax/netlist_io/library.py
inspection_sources ¤
Fingerprint actual parsed source dependencies without native loading.
Source code in circulax/netlist_io/library.py
instantiate ¤
instantiate(
subcircuit: str,
nodes: tuple[str, ...] | None = None,
settings: dict[str, float] | None = None,
*,
name: str = "X1"
) -> ResolvedCircuit
Expand a library subcircuit without loading executable OSDI modules.
Source code in circulax/netlist_io/library.py
refreshed ¤
refreshed() -> Library
Reuse unchanged parsed cards or reparse edited, removed or shadowed source dependencies.
Source code in circulax/netlist_io/library.py
resolve ¤
resolve() -> ResolvedCircuit
Expand instances declared at the top level of a loaded circuit file.
Source code in circulax/netlist_io/library.py
with_temperature ¤
Reparse source declarations at a new temperature without mutation.
Source code in circulax/netlist_io/library.py
LibraryModel ¤
LibraryModel(
library: Library | None,
subcircuit: str,
*,
defaults: Mapping[str, Any] | None = None,
params_map: Mapping[str, str] | None = None,
port_map: Mapping[str, str] | None = None,
parameter_units: Mapping[str, tuple[str, str]] | None = None,
parameter_values: Mapping[str, Mapping[Any, float]] | None = None,
expressions: Mapping[str, str] | None = None,
module_paths: tuple[Path, ...] = (),
osdi_modules: tuple[Path, ...] = (),
compiler: str | None = None,
cache_dir: Path | None = None,
analysis: str = "dc",
state_policy: str = "reject",
simparams: Mapping[str, float] | None = None
)
Register one library wrapper, binding settings separately per instance.
This object is deliberately non-callable. compile_circuit elaborates wrapper instances to kfnetlist and lets kfnetlist flatten their topology. OSDI descriptor definitions are shared; card and instance values populate individual leaf settings and therefore rows in the native device batch.
params_map maps schematic setting names to library parameter names. parameter_units explicitly declares (source, target) units for those schematic settings. Defaults use the same source units. expressions maps library parameter names to safe expressions over converted settings. Unspecified defaults remain owned by the original library cards.
A temperature_c setting (degrees Celsius) selects the card temperature. It stays available to expressions and parameter_units/parameter_values, but is forwarded to the library as a parameter only when params_map names it.
@tags circulax-simulation
Methods:
| Name | Description |
|---|---|
from_file | Register lazily; parse the selected corner only when instantiated. |
inspection_identity | Return deterministic read-only provenance and resolved topology. |
instantiate | Build the resolved topology and retain reusable native models. |
resolve | Evaluate settings and cards without building or provisioning models. |
Source code in circulax/netlist_io/model.py
from_file classmethod ¤
from_file(
path: str | Path,
subcircuit: str,
*,
section: str | None = None,
sections: tuple[str, ...] = (),
dialect: str = "ngspice",
temperature_c: float = 27.0,
include_paths: tuple[Path, ...] = (),
**options: Any
) -> LibraryModel
Register lazily; parse the selected corner only when instantiated.
@tags circulax-simulation
Source code in circulax/netlist_io/model.py
inspection_identity ¤
Return deterministic read-only provenance and resolved topology.
Source/include contents and available native artifact bytes contribute to the fingerprint. Native artifacts are not loaded or ABI-validated; this identity does not establish backend readiness.
Source code in circulax/netlist_io/model.py
instantiate ¤
instantiate(settings: Mapping[str, Any] | None = None) -> NetlistDefinition
Build the resolved topology and retain reusable native models.
Source code in circulax/netlist_io/model.py
resolve ¤
resolve(settings: Mapping[str, Any] | None = None) -> ResolvedCircuit
Evaluate settings and cards without building or provisioning models.
Returns ordered electrical leaf topology and public terminal aliases using the same corner, unit and expression bindings as execution. Source files may be parsed and cached; no native model, compiler or simulator is loaded or executed by this operation.
@tags circulax-simulation
Source code in circulax/netlist_io/model.py
NetlistDefinition dataclass ¤
Canonical topology and shared leaf models, before solver compilation.
NetlistError ¤
Bases: ValueError
A netlist could not be parsed or resolved without changing its meaning.
ResolvedCircuit dataclass ¤
ResolvedCircuit(
instances: list[ResolvedInstance],
loads: list[tuple[str, Path]],
ports: dict[str, str] = dict(),
temperature_c: float = 27.0,
)
Evaluated model cards awaiting conversion to kfnetlist and native models.
This intermediate retains ordered terminals and load declarations needed for OSDI provisioning. Compilation builds the canonical kfnetlist.Netlist.
Methods:
| Name | Description |
|---|---|
compile | Compile with immutable native analysis mode: dc (default), ac, or tran. |
compile ¤
compile(
*,
module_paths: tuple[Path, ...] = (),
osdi_modules: tuple[Path, ...] = (),
compiler: str | None = None,
cache_dir: Path | None = None,
backend: str = "dense",
analysis: str = "dc",
state_policy: str = "reject",
simparams: Mapping[str, float] | None = None
) -> Any
Compile with immutable native analysis mode: dc (default), ac, or tran.
simparams supplies numeric $simparam settings to all native devices. Separate registrations are required to change mode. For AC, retain DC conductance and obtain capacitance from an AC registration.
osdi_modules registers compiled .osdi/.va files by their own descriptor name directly, for libraries (e.g. plain ngspice model cards) that reference a module by name without a load statement.
Source code in circulax/netlist_io/library.py
ResolvedInstance dataclass ¤
A leaf compact model with evaluated model and instance parameters.
parse_source ¤
parse_source(
spec: str,
*,
dialect: str = "spice",
tstep: float | None = None,
tstop: float | None = None,
pwl_points: int | None = None
) -> dict[str, float | tuple[float, ...]]
Parse the value part of a SPICE V/I source card: [DC] value and/or a waveform.
Accepts "1.2", "DC 1.2", "SIN(...)" and "DC 0.5 SIN(...)" (in either order). dc_given preserves whether an operating-point override was supplied. Without one, DC analysis uses the waveform's time-zero value. Transients always initialize from the waveform, independently of an explicit DC override. AC clauses are rejected (source-driven AC is out of scope).
Returns:
| Type | Description |
|---|---|
dict[str, float | tuple[float, ...]] | Keyword settings with |
dict[str, float | tuple[float, ...]] | for |
@tags circulax-simulation
Source code in circulax/netlist_io/sources.py
parse_waveform ¤
parse_waveform(
waveform: str,
*,
dialect: str = "spice",
tstep: float | None = None,
tstop: float | None = None,
pwl_points: int | None = None
) -> dict[str, float | tuple[float, ...]]
Parse SIN(...), PULSE(...) or PWL(...) into waveform source settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform | str | SPICE waveform text, e.g. | required |
dialect | str | Number-suffix dialect; | 'spice' |
tstep | float | None | SPICE | None |
tstop | float | None | SPICE | None |
pwl_points | int | None | When set, emit | None |
Returns:
| Type | Description |
|---|---|
dict[str, float | tuple[float, ...]] | Keyword settings for the waveform source components, including |
dict[str, float | tuple[float, ...]] | Fields not needed by the waveform keep their component defaults. |
@tags circulax-simulation