Skip to content

Commit

Permalink
Merge pull request #442 from gdsfactory/fix_klayout_netlist
Browse files Browse the repository at this point in the history
Fix klayout netlist
  • Loading branch information
joamatab authored Jul 25, 2024
2 parents 2e07dca + dec2de8 commit 573d5c3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 117 deletions.
12 changes: 6 additions & 6 deletions gplugins/klayout/get_netlist.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# type: ignore
import gdsfactory as gf
import kfactory as kf
import klayout.db as kdb
Expand Down Expand Up @@ -40,10 +41,11 @@ def get_l2n(
l2n = kf.kdb.LayoutToNetlist(c.begin_shapes_rec(0))
l2n.threads = kf.config.n_threads

reversed_layer_map = dict()
reversed_layer_map = {}
layers = gf.get_active_pdk().layers
for k, v in layers:
reversed_layer_map[v] = reversed_layer_map.get(v, set()) | {k}

for layer in layers:
reversed_layer_map[layer] = str(layer)

# define stack connections through vias
layer_connection_iter = [
Expand All @@ -60,8 +62,7 @@ def get_l2n(
labels = kdb.Texts(c.begin_shapes_rec(0))
# define the layers to be extracted
for l_idx in c.kcl.layer_indexes():
layer_info = c.kcl.get_info(l_idx)
names = reversed_layer_map[(layer_info.layer, layer_info.datatype)]
names = {reversed_layer_map[l_idx]}
try:
same_name_as_in_connections = next(iter(correct_layer_names & names))
except StopIteration:
Expand All @@ -83,7 +84,6 @@ def get_l2n(
l2n.connect(layer_via, layer_b)

l2n.extract_netlist()

return l2n


Expand Down
1 change: 1 addition & 0 deletions gplugins/klayout/plot_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ def _removal_condition(node: str, degree: int) -> bool:
l2n.write_l2n(str(path))

plot_nets(path)
plt.show()
16 changes: 5 additions & 11 deletions gplugins/lumerical/interconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
from gdsfactory import Component
from gdsfactory.config import PATH
from omegaconf import DictConfig

c = 2.9979e8
pi = np.pi
Expand All @@ -16,12 +15,10 @@

def install_design_kit(
session: object,
cml_path: pathlib.Path,
install_dir: pathlib.Path = PATH.interconnect,
overwrite: bool = False,
) -> None:
from gdsfactory.pdk import get_interconnect_cml_path

cml_path = get_interconnect_cml_path()
session.installdesignkit(str(cml_path), str(install_dir), overwrite)


Expand All @@ -32,9 +29,6 @@ def set_named_settings(
session.setnamed(element, param, val)


# TODO: Add custom s-parameter models using compound elements


def add_interconnect_element(
session: object,
label: str,
Expand Down Expand Up @@ -154,10 +148,10 @@ def send_to_interconnect(

netlist = c.get_netlist()

instances: DictConfig = netlist["instances"]
connections: DictConfig = netlist["connections"]
placements: DictConfig = placements or netlist["placements"]
ports: DictConfig = netlist["ports"]
instances = netlist["instances"]
connections = netlist["connections"]
placements = placements or netlist["placements"]
ports = netlist["ports"]

relay_count = 1
excluded = []
Expand Down
10 changes: 5 additions & 5 deletions gplugins/spice/tests/test_interconnect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yaml
from gdsfactory.config import GDSDIR_TEMP
from omegaconf import OmegaConf

from gplugins import PATH
from gplugins.spice.spice_to_yaml import spice_to_yaml
Expand Down Expand Up @@ -61,10 +61,10 @@ def test_interconnect():
mapping_path=mapping_path,
pdk="ubcpdk",
)
s = OmegaConf.load(picyaml_path)
s = yaml.safe_load(picyaml_path.read_text())
# print(s)
# print(len(s.instances))
assert len(s.instances) == 1
assert len(s["instances"]) == 1


if __name__ == "__main__":
Expand All @@ -78,7 +78,7 @@ def test_interconnect():
mapping_path=mapping_path,
pdk="ubcpdk",
)
s = OmegaConf.load(picyaml_path)
s = yaml.safe_load(picyaml_path.read_text())
# print(s)
# print(len(s.instances))
assert len(s.instances) == 1
assert len(s["instances"]) == 1
55 changes: 0 additions & 55 deletions gplugins/tidy3d/tests/tests_sparameters/test_simulation.py

This file was deleted.

6 changes: 6 additions & 0 deletions gplugins/vlsir/tests/test_vlsir.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ def test_export_netlist(pkg, spice_format) -> None:
export_netlist(pkg, fmt=spice_format, dest=f)
with open(outpath) as f:
assert f.read() is not None


if __name__ == "__main__":
c = pads_correct()
gdspath = c.write_gds()
kdbnet = get_netlist(gdspath)
Loading

0 comments on commit 573d5c3

Please sign in to comment.