From 4b05dc4c691462a958f79e91b52b4dff6958d821 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Mon, 5 Aug 2024 07:02:40 -0700 Subject: [PATCH 1/2] fix vlsir tests --- .../vlsir/tests/resources/pads_correct.cir | 48 +++++++++---------- .../vlsir/tests/resources/pads_correct.scs | 48 +++++++++---------- .../vlsir/tests/resources/pads_correct.sp | 48 +++++++++---------- gplugins/vlsir/tests/test_vlsir.py | 15 +++--- 4 files changed, 80 insertions(+), 79 deletions(-) diff --git a/gplugins/vlsir/tests/resources/pads_correct.cir b/gplugins/vlsir/tests/resources/pads_correct.cir index 15f8874b..1ac00fac 100644 --- a/gplugins/vlsir/tests/resources/pads_correct.cir +++ b/gplugins/vlsir/tests/resources/pads_correct.cir @@ -2,94 +2,94 @@ ; Generated by `vlsirtools.XyceNetlister` ; -.SUBCKT straight_e0091ba5 +.SUBCKT straight_L392_N2_CSmetal3_W10 + 1 ; No parameters .ENDS -.SUBCKT straight_af1bc243 +.SUBCKT straight_L200_N2_CSmetal3_W10 + 1 ; No parameters .ENDS -.SUBCKT straight_ea93caa4 +.SUBCKT straight_L8_N2_CSmetal3_W10 + 1 ; No parameters .ENDS -.SUBCKT bend_euler_cross_sectionmetal3 +.SUBCKT wire_corner_CSmetal3_RNone + 1 ; No parameters .ENDS -.SUBCKT straight_55343d8d +.SUBCKT straight_L400_N2_CSmetal3_W10 + 1 ; No parameters .ENDS -.SUBCKT pad -+ 1 +.SUBCKT pad_S100_100_LMTOP_BLNo_fdaf576b ++ 1 2 ; No parameters .ENDS -.SUBCKT pads_correct +.SUBCKT pads_correct_Ppad_CSmetal3 ; No ports ; No parameters x1 -+ tl,tr -+ pad ++ tl,tr tl ++ pad_S100_100_LMTOP_BLNo_fdaf576b + ; No parameters x2 -+ tl,tr -+ straight_ea93caa4 ++ tl,tr tr ++ pad_S100_100_LMTOP_BLNo_fdaf576b + ; No parameters x3 -+ tl,tr -+ bend_euler_cross_sectionmetal3 ++ bl,br br ++ pad_S100_100_LMTOP_BLNo_fdaf576b + ; No parameters x4 -+ tl,tr -+ straight_af1bc243 ++ bl,br bl ++ pad_S100_100_LMTOP_BLNo_fdaf576b + ; No parameters x5 + tl,tr -+ bend_euler_cross_sectionmetal3 ++ straight_L8_N2_CSmetal3_W10 + ; No parameters x6 + tl,tr -+ pad ++ wire_corner_CSmetal3_RNone + ; No parameters x7 + tl,tr -+ straight_e0091ba5 ++ straight_L200_N2_CSmetal3_W10 + ; No parameters x8 -+ bl,br -+ pad ++ tl,tr ++ wire_corner_CSmetal3_RNone + ; No parameters x9 -+ bl,br -+ straight_55343d8d ++ tl,tr ++ straight_L392_N2_CSmetal3_W10 + ; No parameters x10 + bl,br -+ pad ++ straight_L400_N2_CSmetal3_W10 + ; No parameters .ENDS diff --git a/gplugins/vlsir/tests/resources/pads_correct.scs b/gplugins/vlsir/tests/resources/pads_correct.scs index 465fcdbd..96d0e4c9 100644 --- a/gplugins/vlsir/tests/resources/pads_correct.scs +++ b/gplugins/vlsir/tests/resources/pads_correct.scs @@ -2,110 +2,110 @@ // Generated by `vlsirtools.SpectreNetlister` // -subckt straight_e0091ba5 +subckt straight_L392_N2_CSmetal3_W10 + 1 + // No parameters ends -subckt straight_af1bc243 +subckt straight_L200_N2_CSmetal3_W10 + 1 + // No parameters ends -subckt straight_ea93caa4 +subckt straight_L8_N2_CSmetal3_W10 + 1 + // No parameters ends -subckt bend_euler_cross_sectionmetal3 +subckt wire_corner_CSmetal3_RNone + 1 + // No parameters ends -subckt straight_55343d8d +subckt straight_L400_N2_CSmetal3_W10 + 1 + // No parameters ends -subckt pad - + 1 +subckt pad_S100_100_LMTOP_BLNo_fdaf576b + + 1 2 + // No parameters ends -subckt pads_correct +subckt pads_correct_Ppad_CSmetal3 + // No ports + // No parameters 1 + // Ports: - + ( tl,tr ) - + pad + + ( tl,tr tl ) + + pad_S100_100_LMTOP_BLNo_fdaf576b + // No parameters 2 + // Ports: - + ( tl,tr ) - + straight_ea93caa4 + + ( tl,tr tr ) + + pad_S100_100_LMTOP_BLNo_fdaf576b + // No parameters 3 + // Ports: - + ( tl,tr ) - + bend_euler_cross_sectionmetal3 + + ( bl,br br ) + + pad_S100_100_LMTOP_BLNo_fdaf576b + // No parameters 4 + // Ports: - + ( tl,tr ) - + straight_af1bc243 + + ( bl,br bl ) + + pad_S100_100_LMTOP_BLNo_fdaf576b + // No parameters 5 + // Ports: + ( tl,tr ) - + bend_euler_cross_sectionmetal3 + + straight_L8_N2_CSmetal3_W10 + // No parameters 6 + // Ports: + ( tl,tr ) - + pad + + wire_corner_CSmetal3_RNone + // No parameters 7 + // Ports: + ( tl,tr ) - + straight_e0091ba5 + + straight_L200_N2_CSmetal3_W10 + // No parameters 8 + // Ports: - + ( bl,br ) - + pad + + ( tl,tr ) + + wire_corner_CSmetal3_RNone + // No parameters 9 + // Ports: - + ( bl,br ) - + straight_55343d8d + + ( tl,tr ) + + straight_L392_N2_CSmetal3_W10 + // No parameters 10 + // Ports: + ( bl,br ) - + pad + + straight_L400_N2_CSmetal3_W10 + // No parameters diff --git a/gplugins/vlsir/tests/resources/pads_correct.sp b/gplugins/vlsir/tests/resources/pads_correct.sp index 69838f80..05c8cc61 100644 --- a/gplugins/vlsir/tests/resources/pads_correct.sp +++ b/gplugins/vlsir/tests/resources/pads_correct.sp @@ -2,103 +2,103 @@ * Generated by `vlsirtools.SpiceNetlister` * -.SUBCKT straight_e0091ba5 +.SUBCKT straight_L392_N2_CSmetal3_W10 + 1 * No parameters .ENDS -.SUBCKT straight_af1bc243 +.SUBCKT straight_L200_N2_CSmetal3_W10 + 1 * No parameters .ENDS -.SUBCKT straight_ea93caa4 +.SUBCKT straight_L8_N2_CSmetal3_W10 + 1 * No parameters .ENDS -.SUBCKT bend_euler_cross_sectionmetal3 +.SUBCKT wire_corner_CSmetal3_RNone + 1 * No parameters .ENDS -.SUBCKT straight_55343d8d +.SUBCKT straight_L400_N2_CSmetal3_W10 + 1 * No parameters .ENDS -.SUBCKT pad -+ 1 +.SUBCKT pad_S100_100_LMTOP_BLNo_fdaf576b ++ 1 2 * No parameters .ENDS -.SUBCKT pads_correct +.SUBCKT pads_correct_Ppad_CSmetal3 * No ports * No parameters x1 -+ tl,tr -+ pad ++ tl,tr tl ++ pad_S100_100_LMTOP_BLNo_fdaf576b * No parameters x2 -+ tl,tr -+ straight_ea93caa4 ++ tl,tr tr ++ pad_S100_100_LMTOP_BLNo_fdaf576b * No parameters x3 -+ tl,tr -+ bend_euler_cross_sectionmetal3 ++ bl,br br ++ pad_S100_100_LMTOP_BLNo_fdaf576b * No parameters x4 -+ tl,tr -+ straight_af1bc243 ++ bl,br bl ++ pad_S100_100_LMTOP_BLNo_fdaf576b * No parameters x5 + tl,tr -+ bend_euler_cross_sectionmetal3 ++ straight_L8_N2_CSmetal3_W10 * No parameters x6 + tl,tr -+ pad ++ wire_corner_CSmetal3_RNone * No parameters x7 + tl,tr -+ straight_e0091ba5 ++ straight_L200_N2_CSmetal3_W10 * No parameters x8 -+ bl,br -+ pad ++ tl,tr ++ wire_corner_CSmetal3_RNone * No parameters x9 -+ bl,br -+ straight_55343d8d ++ tl,tr ++ straight_L392_N2_CSmetal3_W10 * No parameters x10 + bl,br -+ pad ++ straight_L400_N2_CSmetal3_W10 * No parameters diff --git a/gplugins/vlsir/tests/test_vlsir.py b/gplugins/vlsir/tests/test_vlsir.py index a2f8a465..40871ecc 100644 --- a/gplugins/vlsir/tests/test_vlsir.py +++ b/gplugins/vlsir/tests/test_vlsir.py @@ -21,27 +21,28 @@ def pkg() -> Package: def test_kdb_vlsir(pkg) -> None: """Test the conversion from KLayout DB Netlist to VLSIR Package""" + name = "pads_correct_Ppad_CSmetal3" assert pkg is not None assert len(pkg.modules) == 7 assert len(pkg.modules[6].instances) == 10 - assert pkg.modules[6].name == "pads_correct" + assert pkg.modules[6].name == name @pytest.mark.parametrize("spice_format", ["spice", "spectre", "xyce", "verilog"]) def test_export_netlist(pkg, spice_format) -> None: """Test the export of a VLSIR Package to a netlist in the supported formats""" - outfile = PATH.module / "vlsir" / "tests" / "resources" / "pads_correct" - format_to_suffix = { - "spice": ".sp", - "spectre": ".scs", - "xyce": ".cir", - } if spice_format == "verilog": with pytest.raises(NotImplementedError): export_netlist(pkg, fmt=spice_format) else: + outfile = PATH.module / "vlsir" / "tests" / "resources" / "pads_correct" + format_to_suffix = { + "spice": ".sp", + "spectre": ".scs", + "xyce": ".cir", + } outpath = outfile.with_suffix(format_to_suffix[spice_format]) with open(outpath, "w") as f: export_netlist(pkg, fmt=spice_format, dest=f) From 23dd65d15ab19c801ed2257a9982b266cafce326 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Mon, 5 Aug 2024 07:21:08 -0700 Subject: [PATCH 2/2] fix litho parameters --- gplugins/sax/parameter.py | 52 ++++++++++++--------------- gplugins/sax/tests/test_parameters.py | 4 +++ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/gplugins/sax/parameter.py b/gplugins/sax/parameter.py index 789b0e2a..19b2db3d 100644 --- a/gplugins/sax/parameter.py +++ b/gplugins/sax/parameter.py @@ -96,12 +96,6 @@ def __init__(self, **kwargs) -> None: return None -def array_to_tuples(array, n): - array = [float(x) for x in array] - # Form tuples of size n - return [tuple(array[i : i + n]) for i in range(0, len(array), n)] - - class LithoParameter(Parameter): def __init__( self, @@ -167,11 +161,13 @@ def layer_dilation_erosion(self, component, dilation_value): if hasattr(buffered_polygons, "geoms") else [buffered_polygons] ): - for poly in np.array(buffered_polygon.exterior.coords.xy): - temp_component.add_polygon(poly, layer=layer) + coords_tuple = tuple( + map(tuple, buffered_polygon.exterior.coords) + ) + temp_component.add_polygon(coords_tuple, layer=layer) else: - for layer_polygon in layer_polygons: - temp_component.add_polygon(layer_polygon, layer=layer) + for poly in layer_polygons: + temp_component.add_polygon(poly, layer=layer) # Transform ports ports = [] for port in component.ports: @@ -193,14 +189,14 @@ def layer_x_offset(self, component, offset_value): temp_component = gf.Component() for layer, layer_polygons in component.get_polygons_points().items(): for layer_polygon in layer_polygons: - if layer == self.layer: + if layer == self.layer.layer1.layer1.layer: shapely_polygon = shapely.geometry.Polygon(layer_polygon) translated_polygon = translate( shapely_polygon, xoff=offset_value, yoff=0.0 ) - temp_component.add_polygon( - translated_polygon.exterior.coords, layer=layer - ) + + coords_tuple = tuple(map(tuple, translated_polygon.exterior.coords)) + temp_component.add_polygon(coords_tuple, layer=layer) else: temp_component.add_polygon(layer_polygon, layer=layer) # Transform ports @@ -218,14 +214,13 @@ def layer_y_offset(self, component, offset_value): temp_component = gf.Component() for layer, layer_polygons in component.get_polygons_points().items(): for layer_polygon in layer_polygons: - if layer == self.layer: + if layer == self.layer.layer1.layer1.layer: shapely_polygon = shapely.geometry.Polygon(layer_polygon) translated_polygon = translate( shapely_polygon, xoff=0.0, yoff=offset_value ) - temp_component.add_polygon( - translated_polygon.exterior.coords, layer=layer - ) + coords = tuple(map(tuple, translated_polygon.exterior.coords)) + temp_component.add_polygon(coords, layer=layer) else: temp_component.add_polygon(layer_polygon, layer=layer) # Transform ports @@ -242,7 +237,7 @@ def layer_y_offset(self, component, offset_value): def layer_round_corners(self, component, round_value): temp_component = gf.Component() for layer, layer_polygons in component.get_polygons_points().items(): - if layer == self.layer: + if layer == self.layer.layer1.layer1.layer: # Make sure all layer polygons are fused properly shapely_polygons = [ shapely.geometry.Polygon(polygon) for polygon in layer_polygons @@ -259,9 +254,8 @@ def layer_round_corners(self, component, round_value): .buffer(-2 * round_value, join_style=1) .buffer(round_value, join_style=1) ) - temp_component.add_polygon( - buffered_polygon.exterior.coords, layer=layer - ) + coords = tuple(map(tuple, buffered_polygon.exterior.coords)) + temp_component.add_polygon(coords, layer=layer) else: for layer_polygon in layer_polygons: temp_component.add_polygon(layer_polygon, layer=layer) @@ -337,11 +331,11 @@ def layer_round_corners(self, component, round_value): c.add_port(name="o2", center=(3, -2), width=1, orientation=90, layer=1) c.show() - param = LithoParameter(layername="core") - eroded_c = param.layer_dilation_erosion(c, 0.2) - eroded_c.show() - # param = LithoParameter(layername="core") + # eroded_c = param.layer_dilation_erosion(c, 0.2) + # eroded_c.show() + + # param = LithoParameter(layername="core") # FIXME # eroded_c = param.layer_dilation_erosion(c, -0.2) # eroded_c.show() @@ -353,6 +347,6 @@ def layer_round_corners(self, component, round_value): # eroded_c = param.layer_y_offset(c, 0.5) # eroded_c.show() - # param = LithoParameter(layername="core") - # eroded_c = param.layer_round_corners(c, 0.2) - # eroded_c.show() + param = LithoParameter(layername="core") + eroded_c = param.layer_round_corners(c, 0.2) + eroded_c.show() diff --git a/gplugins/sax/tests/test_parameters.py b/gplugins/sax/tests/test_parameters.py index a13ec5e7..2ee44767 100644 --- a/gplugins/sax/tests/test_parameters.py +++ b/gplugins/sax/tests/test_parameters.py @@ -65,3 +65,7 @@ def test_litho_parameters() -> None: param = LithoParameter(layername="core") param.layer_round_corners(c, 0.2) + + +if __name__ == "__main__": + test_litho_parameters()