SpiceNetlist

class caphe.SpiceNetlist

Represents a parsed SPICE netlist, containing models, subcircuits, instances, and parameters.

The SpiceNetlist acts as an intermediate representation bridging a SPICE text file and a circuit solver netlist. It stores the hierarchical structure of the circuit and handles parameter overrides and resolution.

Attributes:
modelsdict[str, CompactModel]

Available compact models (class references) mapped by name. {‘model’: MODEL}

subcircuitsdict[str, SubCircuit]

Available subcircuits mapped by name. {‘subckt’: SUBCKT}

instancesdict[str, Instance]

Global instances in the top-level circuit mapped by name. {‘inst’: INST}

paramsdict[str, Any]

Global parameters. {‘length’: 2.0}

analysisdict[str, Any]

SPICE simulation commands and settings.

model_infolist[str]

Paths to the Python scripts or modules defining the compact models.

library_infolist[LibraryInfo]

Information about parsed SPICE libraries including lib path and lib flavor.

classmethod from_spice(spice_file, flavor='spice', resolvers=[<luceda.spice.resolvers.SpiceNetlistInstanceResolver object>, <luceda.spice.resolvers.SpiceLibraryResolver object>, <luceda.spice.resolvers.SpiceModelResolver object>])

Creates a SpiceNetlist instance from a SPICE file.

The “spice” flavor is extended with keyword .PHDL_INCLUDE to support pointing to a python module with Python based Compact Model definitions, and .SMAT (.SMAT LIN NPTS WL_START WL_END) to support scattering matrix analysis over a range of wavelengths (e.g. .SMAT LIN 1001 1.5 1.6).

The “spectre” flavor is extended with keyword PHDL_INCLUDE to support pointing to a python module with Python based Compact Model definitions. Here, a scattering matrix wavelength analysis is supported using the OFA (optical frequency analysis) keyword (e.g. “ofa ofa sweepoption=wavelength start=1.5 stop=1.6 npts=1001” or “ofa ofa sweepoption=wavelength values=[1.5 1.6 1.7]”).

Parameters:
spice_filestr or Path

The path to the SPICE/Spectre netlist file.

flavor{“spice”, “spectre”}, optional

The flavor of the SPICE file. Defaults to “spice”.

resolverslist[NetlistResolver], optional

A list of resolvers to process the netlist (e.g., resolving libraries, models, and instances).

Returns:
SpiceNetlist

A resolved netlist object.

replace(updates)

Returns a shallow copy of the netlist with updated global, subcircuit-level, or instance-path specific parameters.

Supported Key Syntax:
  • “param_name”: Updates a global parameter.

  • “subckt_name:param_name”: Updates default parameters in a subcircuit definition.

  • “path.to.inst:param_name”: Overrides a parameter for a specific instance path.

Wildcards:

The ‘*’ character is supported for glob-style matching in all segments: - “_loss”: All global parameters ending in _loss. - “Waveguide:loss”: All subcircuits starting with Waveguide. - “PCELL_1.*.Generic*:length”: All Generic instances nested within PCELL_1.