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/__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 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)