Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions docs/json_netlisting.md
Original file line number Diff line number Diff line change
@@ -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": \[]

}



5 changes: 5 additions & 0 deletions netlists/lcm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cell": "lcm",
"devices": [],
"nets": []
}
7 changes: 6 additions & 1 deletion src/glayout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/glayout/blocks/lcm.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions src/glayout/util/netlist_json.py
Original file line number Diff line number Diff line change
@@ -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)