From 49f2a7bcf094d175a638ad58c17be01eee201440 Mon Sep 17 00:00:00 2001 From: Priyanka Banik Date: Sun, 11 Jan 2026 22:06:02 +0530 Subject: [PATCH 1/3] Fix netlisting by using JSON output from PCells --- netlists/lcm.json | 5 +++++ src/glayout/blocks/lcm.py | 23 +++++++++++++++++++++++ src/glayout/util/netlist_json.py | 12 ++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 netlists/lcm.json create mode 100644 src/glayout/blocks/lcm.py create mode 100644 src/glayout/util/netlist_json.py diff --git a/netlists/lcm.json b/netlists/lcm.json new file mode 100644 index 00000000..85177dd6 --- /dev/null +++ b/netlists/lcm.json @@ -0,0 +1,5 @@ +{ + "cell": "lcm", + "devices": [], + "nets": [] +} diff --git a/src/glayout/blocks/lcm.py b/src/glayout/blocks/lcm.py new file mode 100644 index 00000000..33efd56b --- /dev/null +++ b/src/glayout/blocks/lcm.py @@ -0,0 +1,23 @@ +from glayout.util.netlist_json import write_netlist_json + + +def lcm(...): + ... + +netlist_dict = { + "block": "lcm", + "devices": [ + { + "name": "M1", + "type": "nmos", + "connections": {"D": "out", "G": "in", "S": "vss", "B": "vss"} + } + ] +} + +write_netlist_json( + netlist_dict, + "netlists/lcm.json" +) + + return comp diff --git a/src/glayout/util/netlist_json.py b/src/glayout/util/netlist_json.py new file mode 100644 index 00000000..54a6beec --- /dev/null +++ b/src/glayout/util/netlist_json.py @@ -0,0 +1,12 @@ +import json +from pathlib import Path + +def write_netlist_json(netlist: dict, path: str): + path = Path(path) + path.parent.mkdir(parents=True, exist_ok=True) + with open(path, "w") as f: + json.dump(netlist, f, indent=2) + +def read_netlist_json(path: str) -> dict: + with open(path, "r") as f: + return json.load(f) From f2d9acba4390b07517e892acbb36aa4d9241ad06 Mon Sep 17 00:00:00 2001 From: Priyanka Banik Date: Wed, 14 Jan 2026 19:59:32 +0530 Subject: [PATCH 2/3] Fix analyze_dataset crash by guarding layout imports --- src/glayout/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glayout/__init__.py b/src/glayout/__init__.py index 6e0c7e80..89ea1f2d 100644 --- a/src/glayout/__init__.py +++ b/src/glayout/__init__.py @@ -31,7 +31,12 @@ def activate(self): ihp130 = None # Primitive components -from .primitives.via_gen import via_stack, via_array +try: + from .primitives.via_gen import via_stack, via_array +except ModuleNotFoundError: + # Allow JSON-only workflows (dataset analysis / netlisting) + via_stack = None + via_array = None from .primitives.fet import nmos, pmos, multiplier from .primitives.guardring import tapring from .primitives.mimcap import mimcap, mimcap_array From cdc3698998442a41dd5f83d37a3fdae19ed4fffc Mon Sep 17 00:00:00 2001 From: Priyanka Banik Date: Sat, 7 Feb 2026 20:57:50 +0530 Subject: [PATCH 3/3] docs: document JSON netlisting schema and dataset flow --- docs/json_netlisting.md | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 docs/json_netlisting.md diff --git a/docs/json_netlisting.md b/docs/json_netlisting.md new file mode 100644 index 00000000..7e36c6da --- /dev/null +++ b/docs/json_netlisting.md @@ -0,0 +1,76 @@ +\# JSON-based Netlisting for Dataset Generation + + + +\## Overview + + + +To enable reliable dataset generation, netlists are serialized into a + +JSON format instead of Python lists or in-memory objects. + + + +This avoids unreadable list errors encountered during sampling and + +allows downstream dataset scripts to consume netlists deterministically. + + + +--- + + + +\## Where the JSON Is Generated + + + +The JSON netlist is generated during the netlisting stage of pcell + +evaluation. + + + +Relevant files: + +\- `src/glayout/util/netlist\_json.py` + +\- pcell entry points (e.g. `lcm.py`) + +\- higher-level composite / sampling scripts + + + +The pcell itself does not write files directly. It returns a structured + +netlist object which is then serialized to JSON by the dataset flow. + + + +--- + + + +\## JSON Schema + + + +Example JSON netlist: + + + +```json + +{ + +  "cell": "lcm", + +  "devices": \[], + +  "nets": \[] + +} + + +