Skip to content

kfnetlist

kfnetlist is a standalone, Rust-backed netlist schema for kfactory and netlist tooling.

It provides a fast, type-safe data model for circuit connectivity — instances, nets, ports, and arrays — with full JSON/dict serialization and Pydantic v2 integration. The core is implemented in Rust via PyO3 and has zero runtime Python dependencies.



Key Features

  • Rust coreNetlist, Net, and port types implemented in Rust for speed and memory safety
  • Zero runtime dependencies — the base package has no Python dependencies
  • Full serializationto_json() / from_json() and to_dict() / from_dict() on every type
  • Pydantic v2 support — all types implement __get_pydantic_core_schema__
  • Equivalent ports — fold electrically-equivalent ports into canonical names for netlist comparison
  • Instance flattening — merge sub-cell instances into the parent, reconnecting touching nets
  • Port checkingPortCheck bitmask and check_connection() for geometric port-pair comparison
  • Netlist extraction — extract hierarchical netlists from kfactory/klayout cells

Relationship to kfactory

kfnetlist is the netlist data model that kfactory uses internally. It is published as a separate package so that:

  • Tools that only need netlist manipulation do not have to depend on kfactory or klayout
  • The netlist schema can evolve on its own release cadence
  • Downstream projects can consume netlists without pulling in a full layout framework

For end-to-end examples of netlist extraction using kfactory, see the kfactory schematics documentation.