{"id":51027325,"url":"https://github.com/gdsfactory/kfnetlist","last_synced_at":"2026-06-21T20:31:08.890Z","repository":{"id":357281685,"uuid":"1235553006","full_name":"gdsfactory/kfnetlist","owner":"gdsfactory","description":"netlist and netlist extraction for kfactory","archived":false,"fork":false,"pushed_at":"2026-06-16T09:59:19.000Z","size":726,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-16T11:26:53.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gdsfactory.github.io/kfnetlist/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdsfactory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing/build_cell_netlist_deep_dive.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-11T12:40:08.000Z","updated_at":"2026-06-16T10:00:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gdsfactory/kfnetlist","commit_stats":null,"previous_names":["gdsfactory/kfnetlist"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/gdsfactory/kfnetlist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fkfnetlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fkfnetlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fkfnetlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fkfnetlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdsfactory","download_url":"https://codeload.github.com/gdsfactory/kfnetlist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fkfnetlist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34625624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-21T20:31:07.490Z","updated_at":"2026-06-21T20:31:08.885Z","avatar_url":"https://github.com/gdsfactory.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kfnetlist\n\n**kfnetlist** is a standalone, Rust-backed netlist schema for\n[kfactory](https://github.com/gdsfactory/kfactory) and netlist tooling.\n\nIt provides a fast, type-safe data model for circuit connectivity — instances,\nnets, ports, and arrays — with full JSON/dict serialization and Pydantic v2\nintegration. The core types are implemented in Rust (via PyO3) for performance\nand exposed as native Python classes.\n\n---\n\n## Installation\n\n```bash\npip install kfnetlist\n```\n\nOr with [uv](https://docs.astral.sh/uv/) (recommended):\n\n```bash\nuv add kfnetlist\n```\n\nBuilding from source requires a Rust toolchain and [maturin](https://www.maturin.rs/):\n\n```bash\ngit clone https://github.com/gdsfactory/kfnetlist.git\ncd kfnetlist\npip install maturin\nmaturin develop --release\n```\n\n## Quick Example\n\n```python\nfrom kfnetlist import Netlist, NetlistPort, PortRef\n\nnl = Netlist()\n\n# Add instances\nnl.create_inst(\"wg1\", kcl=\"MY_PDK\", component=\"straight\",\n               settings={\"width\": 500, \"length\": 10_000})\nnl.create_inst(\"wg2\", kcl=\"MY_PDK\", component=\"straight\",\n               settings={\"width\": 500, \"length\": 10_000})\n\n# Add a top-level port and connect it\np_in = nl.create_port(\"in\")\nnl.create_net(p_in, PortRef(instance=\"wg1\", port=\"o1\"))\n\n# Internal net\nnl.create_net(\n    PortRef(instance=\"wg1\", port=\"o2\"),\n    PortRef(instance=\"wg2\", port=\"o1\"),\n)\n\n# Serialize to JSON\nprint(nl.to_json())\n```\n\n## Connectivity Verification\n\nkfnetlist provides tools for LVS-style connectivity verification: detecting\nopens, comparing against reference netlists, and finding geometric shorts.\n\n```python\n# Check for open circuits\nopens = extracted_nl.detect_opens()\nif opens[\"unconnected_ports\"]:\n    print(f\"Unconnected: {opens['unconnected_ports']}\")\n\n# Compare against schematic\ndiff = extracted_nl.find_net_difference(schematic_nl)\nif diff[\"missing\"]:\n    print(f\"{len(list(diff['missing']))} nets missing from layout\")\n\n# Geometric short detection (requires klayout)\nfrom kfnetlist.extract import detect_shorts\nshorts = detect_shorts(l2n)\nfor s in shorts:\n    print(f\"Short: {s.net_a} \u003c-\u003e {s.net_b} on {s.layer}\")\n```\n\nFor a complete walkthrough, see the\n[LVS Verification Guide](https://gdsfactory.github.io/kfnetlist/guides/lvs_verification/).\n\n## Key Features\n\n- **Rust core** — Netlist, Net, and port types are implemented in Rust for\n  speed and memory safety, exposed via PyO3\n- **Zero runtime dependencies** — the base package has no Python dependencies\n- **Full serialization** — `to_json()` / `from_json()` and `to_dict()` /\n  `from_dict()` on every type\n- **Pydantic v2 support** — all types implement `__get_pydantic_core_schema__`\n- **Equivalent ports** — `Netlist.normalize()` folds electrically-equivalent\n  ports into canonical names for netlist comparison\n- **Instance flattening** — `Netlist.flatten_instances()` merges sub-cell\n  instances into the parent, reconnecting touching nets\n- **Port checking** — `PortCheck` bitmask and `check_connection()` for\n  geometric port-pair comparison (requires klayout)\n- **Connectivity verification** — `detect_opens()`, `find_net_difference()`,\n  and `detect_shorts()` for LVS-style verification workflows\n- **Netlist extraction** — `kfnetlist.extract` subpackage extracts hierarchical\n  netlists from kfactory/klayout cells (requires klayout)\n\n## Architecture\n\n```\nkfnetlist\n├── _native          # Rust extension (PyO3): Netlist, Net, NetlistPort,\n│                    #   PortRef, PortArrayRef, NetlistInstance, NetlistArray\n├── port_check       # PortCheck bitmask + check_connection()\n└── extract          # Netlist extraction from layout cells (requires klayout)\n    ├── _algo        #   Main extraction orchestrator\n    ├── _geometry    #   Optical net extraction from port adjacency\n    ├── _l2n         #   Electrical layout-to-netlist via klayout\n    └── _settings    #   Setting serialization helpers\n```\n\n## Documentation\n\nFull documentation: https://gdsfactory.github.io/kfnetlist\n\n## License\n\nkfnetlist is released under the [Apache License 2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fkfnetlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdsfactory%2Fkfnetlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fkfnetlist/lists"}