Skip to content

Commit

Permalink
Added created lumped port on given points (#955)
Browse files Browse the repository at this point in the history
* Added created lumped port on given points

* Added created lumped port on given points

* conflict fixed

* Update i18n.py

* Update compat.py

* Update compat.py

* Update atomic.py

* Update compat.py

* Update atomic.py

* Update compat.py

* Update i18n.py

* unit test added

* flake fix

* Update pyaedt/edb_core/hfss.py

Co-authored-by: Maxime Rey <[email protected]>

* Update pyaedt/edb_core/hfss.py

Co-authored-by: Maxime Rey <[email protected]>

* fixed unit test

* Replace property _edb_value by method _get_edb_value.

Co-authored-by: Maxime Rey <[email protected]>
Co-authored-by: Maxime Rey <[email protected]>
  • Loading branch information
3 people authored Mar 18, 2022
1 parent 2c30142 commit 9d06237
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
5 changes: 5 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def test_01B_get_vias_from_nets(self):
assert self.edbapp.core_padstack.get_via_instance_from_net("GND")
assert not self.edbapp.core_padstack.get_via_instance_from_net(["GND2"])

def test_01C_create_lumped_port_at_location(self):
assert self.edbapp.core_hfss.create_lumped_port_on_trace(
nets="M_DQ<11>", reference_layer="GND", point_list=[(17.169892e-3, 38.874954e-3)]
)

def test_02_get_properties(self):
assert len(self.edbapp.core_components.components) > 0
assert len(self.edbapp.core_components.inductors) > 0
Expand Down
64 changes: 50 additions & 14 deletions pyaedt/edb_core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def _db(self):
def _builder(self):
return self._pedb.builder

def _get_edb_value(self, value):
return self._pedb.edb_value(value)

@pyaedt_function_handler()
def get_trace_width_for_traces_with_ports(self):
"""Retrieve the trace width for traces with ports.
Expand Down Expand Up @@ -490,6 +493,7 @@ def create_lumped_port_on_trace(
return_points_only=False,
polygon_trace_threshhold=300e-6,
digit_resolution=6,
point_list=None,
):
"""Create an edge port on traces.
Expand All @@ -511,7 +515,13 @@ def create_lumped_port_on_trace(
``300-e6``.
digit_resolution : int, optional
The number of digits carried for the edges location accuracy. The default value is ``6``.
The number of digits carried for the edge location accuracy. The default value is ``6``.
point_list : list(tuples), optional
The list of points where to define ports. The port evaluation is done for each net provided and if a point
belongs to a center line points from a path or a polygon then the port will be created. If the point is not
found the ports will be skipped. If point_list is None, the algorithm will try to find the edges from
traces or polygons touching the layout bounding box.
Returns
-------
Expand All @@ -531,10 +541,16 @@ def create_lumped_port_on_trace(
elif isinstance(nn, self._edb.Cell.Net):
temp_nets.append(nn)
nets = temp_nets
if point_list:
if isinstance(point_list, tuple):
point_list = [point_list]
edges_pts = []
if nets:
if isinstance(reference_layer, str):
reference_layer = self._pedb.core_stackup.signal_layers[reference_layer]._layer
try:
reference_layer = self._pedb.core_stackup.signal_layers[reference_layer]._layer
except:
raise Exception("Failed to get the layer {}".format(reference_layer))
if not isinstance(reference_layer, self._edb.Cell.ILayerReadOnly):
return False
layout = nets[0].GetLayout()
Expand All @@ -551,19 +567,39 @@ def create_lumped_port_on_trace(
]
for path in net_paths:
trace_path_pts = list(path.GetCenterLine().Points)
for pt in trace_path_pts:
_pt = [round(pt.X.ToDouble(), digit_resolution), round(pt.Y.ToDouble(), digit_resolution)]
if bool(set(_pt) & set(layout_bbox)):
if return_points_only:
edges_pts.append(_pt)
else:
port_name = generate_unique_name("port")
if not self._hfss_terminals.CreateEdgePort(
path, pt, reference_layer, port_name
): # pragma: no cover
raise Exception(
"edge port creation failed on point {}, {}".format(str(pt[0]), str(_pt[1]))
port_name = "{}_{}".format(net.GetName(), path.GetId())
if point_list:
for _pt in point_list:
if isinstance(_pt, tuple):
found_pt = [
p
for p in trace_path_pts
if round(p.X.ToDouble(), 6) == round(_pt[0], 6)
and round(p.Y.ToDouble(), 6) == round(_pt[1], 6)
]
if found_pt:
pt = self._edb.Geometry.PointData(
self._get_edb_value(_pt[0]), self._get_edb_value(_pt[1])
)
if not self._hfss_terminals.CreateEdgePort(path, pt, reference_layer, port_name):
raise Exception(
"edge port creation failed on point {}, {}".format(
str(pt.X.ToDouble()), str(pt.Y.ToDouble())
)
)
else:
for pt in trace_path_pts:
_pt = [round(pt.X.ToDouble(), digit_resolution), round(pt.Y.ToDouble(), digit_resolution)]
if bool(set(_pt) & set(layout_bbox)):
if return_points_only:
edges_pts.append(_pt)
else:
if not self._hfss_terminals.CreateEdgePort(
path, pt, reference_layer, port_name
): # pragma: no cover
raise Exception(
"edge port creation failed on point {}, {}".format(str(pt[0]), str(_pt[1]))
)
for poly in net_poly:
pt_list = list(poly.GetPolygonData().Points)
points_at_border = [
Expand Down

0 comments on commit 9d06237

Please sign in to comment.