Skip to content

Commit

Permalink
layout validation (#3686)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* fix

* fix

* fix

* fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix

* fix

* fix

* Update pyaedt/edb.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/edb_core/edb_data/connectable.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/edb_core/edb_data/nets_data.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/edb_core/layout_validation.py

Co-authored-by: Kathy Pippert <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: ring630 <@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kathy Pippert <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2023
1 parent c6620b4 commit 5653f90
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 178 deletions.
6 changes: 5 additions & 1 deletion _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_003_create_coax_port_on_component(self):
assert self.edbapp.components["U6"].pins["R3"].id
assert self.edbapp.terminals
assert self.edbapp.ports
assert self.edbapp.components["U6"].pins["R3"].get_connected_objects()

def test_004_get_properties(self):
assert len(self.edbapp.components.components) > 0
Expand Down Expand Up @@ -2892,10 +2893,13 @@ def test_147_find_dc_shorts(self):
target_path = os.path.join(self.local_scratch.path, "test_dc_shorts", "ANSYS-HSD_V1_dc_shorts.aedb")
self.local_scratch.copyfolder(source_path, target_path)
edbapp = Edb(target_path, edbversion=desktop_version)
dc_shorts = edbapp.nets.find_dc_shorts()
dc_shorts = edbapp.layout_validation.dc_shorts()
assert dc_shorts
# assert len(dc_shorts) == 20
assert ["LVDS_CH09_N", "GND"] in dc_shorts
assert ["LVDS_CH09_N", "DDR4_DM3"] in dc_shorts
assert ["DDR4_DM3", "LVDS_CH07_N"] in dc_shorts
assert len(edbapp.nets["DDR4_DM3"].find_dc_short()) > 0
edbapp.nets["DDR4_DM3"].find_dc_short(True)
assert len(edbapp.nets["DDR4_DM3"].find_dc_short()) == 0
edbapp.close()
54 changes: 53 additions & 1 deletion pyaedt/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
from pyaedt.edb_core.edb_data.terminals import PadstackInstanceTerminal
from pyaedt.edb_core.edb_data.terminals import Terminal
from pyaedt.edb_core.edb_data.variables import Variable
from pyaedt.edb_core.general import LayoutObjType
from pyaedt.edb_core.general import Primitives
from pyaedt.edb_core.general import TerminalType
from pyaedt.edb_core.general import convert_py_list_to_net_list
from pyaedt.edb_core.hfss import EdbHfss
from pyaedt.edb_core.ipc2581.ipc2581 import Ipc2581
from pyaedt.edb_core.layout import EdbLayout
from pyaedt.edb_core.layout_validation import LayoutValidation
from pyaedt.edb_core.materials import Materials
from pyaedt.edb_core.net_class import EdbDifferentialPairs
from pyaedt.edb_core.net_class import EdbExtendedNets
Expand Down Expand Up @@ -328,6 +331,11 @@ def project_variables(self):
p_var[i] = Variable(self, i)
return p_var

@property
def layout_validation(self):
""":class:`pyaedt.edb_core.edb_data.layout_validation.LayoutValidation`."""
return LayoutValidation(self)

@property
def variables(self):
"""Get all Edb variables.
Expand Down Expand Up @@ -1032,9 +1040,53 @@ def layout_instance(self):
"""Edb Layout Instance."""
return self.layout.layout_instance

@pyaedt_function_handler
def get_connected_objects(self, layout_object_instance):
"""Get connected objects.
Returns
-------
list
"""
temp = []
for i in list(
[
loi.GetLayoutObj()
for loi in self.layout_instance.GetConnectedObjects(layout_object_instance._edb_object).Items
]
):
obj_type = i.GetObjType().ToString()
if obj_type == LayoutObjType.PadstackInstance.name:
from pyaedt.edb_core.edb_data.padstacks_data import EDBPadstackInstance

temp.append(EDBPadstackInstance(i, self))
elif obj_type == LayoutObjType.Primitive.name:
prim_type = i.GetPrimitiveType().ToString()
if prim_type == Primitives.Path.name:
from pyaedt.edb_core.edb_data.primitives_data import EdbPath

temp.append(EdbPath(i, self))
elif prim_type == Primitives.Rectangle.name:
from pyaedt.edb_core.edb_data.primitives_data import EdbRectangle

temp.append(EdbRectangle(i, self))
elif prim_type == Primitives.Circle.name:
from pyaedt.edb_core.edb_data.primitives_data import EdbCircle

temp.append(EdbCircle(i, self))
elif prim_type == Primitives.Polygon.name:
from pyaedt.edb_core.edb_data.primitives_data import EdbPolygon

temp.append(EdbPolygon(i, self))
else:
continue
else:
continue
return temp

@property
def pins(self):
"""EDBPadstackInstance of Component.
"""EDB padstack instance of the component.
.. deprecated:: 0.6.62
Use new method :func:`edb.padstacks.pins` instead.
Expand Down
28 changes: 24 additions & 4 deletions pyaedt/edb_core/edb_data/connectable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from pyaedt import pyaedt_function_handler


class LayoutObjInstance:
"""Manages EDB functionalities for the layout object instance."""

def __init__(self, pedb, edb_object):
self._pedb = pedb
self._edb_object = edb_object


class LayoutObj(object):
"""Manages EDB functionalities for the layout object."""

Expand Down Expand Up @@ -28,9 +36,10 @@ def _edb(self):
return self._pedb.edb_api

@property
def _layout(self):
"""Return Ansys.Ansoft.Edb.Cell.Layout object."""
return self._pedb.active_layout
def _layout_obj_instance(self):
"""Returns :class:`pyaedt.edb_core.edb_data.connectable.LayoutObjInstance`."""
obj = self._pedb.layout_instance.GetLayoutObjInstance(self._edb_object, None)
return LayoutObjInstance(self._pedb, obj)

@property
def _edb_properties(self):
Expand All @@ -41,9 +50,14 @@ def _edb_properties(self):
def _edb_properties(self, value):
self._edb_object.SetProductSolverOption(self._edb.edb_api.ProductId.Designer, "HFSS", value)

@property
def _obj_type(self):
"""Returns LayoutObjType."""
return self._edb_object.GetObjType().ToString()

@property
def is_null(self):
"""Determine if this object is null."""
"""Flag indicating if this object is null."""
return self._edb_object.IsNull()

@property
Expand Down Expand Up @@ -81,6 +95,12 @@ def net(self):

return EDBNetsData(self._edb_object.GetNet(), self._pedb)

@net.setter
def net(self, value):
"""Set net."""
net = self._pedb.nets[value]
self._edb_object.SetNet(net.net_object)

@property
def component(self):
"""Component connected to this object.
Expand Down
16 changes: 16 additions & 0 deletions pyaedt/edb_core/edb_data/nets_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ def components(self):
comps[comp.refdes] = comp
return comps

@pyaedt_function_handler
def find_dc_short(self, fix=False):
"""Find DC-shorted nets.
Parameters
----------
fix : bool, optional
If `True`, rename all the nets. (default)
If `False`, only report dc shorts.
Returns
-------
List[List[str, str]]
[[net name, net name]].
"""
return self._app.layout_validation.dc_shorts(self.name, fix)

@pyaedt_function_handler()
def plot(
self,
Expand Down
6 changes: 0 additions & 6 deletions pyaedt/edb_core/edb_data/padstacks_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,12 +1869,6 @@ def get_connected_object_id_set(self):
layoutObjInst = self.object_instance
return [loi.GetLayoutObj().GetId() for loi in layoutInst.GetConnectedObjects(layoutObjInst).Items]

@pyaedt_function_handler()
def _get_connected_object_obj_set(self):
layoutInst = self._edb_padstackinstance.GetLayout().GetLayoutInstance()
layoutObjInst = self.object_instance
return list([loi.GetLayoutObj() for loi in layoutInst.GetConnectedObjects(layoutObjInst).Items])

@pyaedt_function_handler()
def get_reference_pins(self, reference_net="GND", search_radius=5e-3, max_limit=0, component_only=True):
"""Search for reference pins using given criteria.
Expand Down
21 changes: 10 additions & 11 deletions pyaedt/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ def type(self):
-------
str
"""
types = ["Circle", "Path", "Polygon", "Rectangle", "Bondwire"]
str_type = self.primitive_type.ToString().split(".")
if str_type[-1] in types:
return str_type[-1]
return None
return self._edb_object.GetPrimitiveType().ToString()

@property
def net_name(self):
Expand Down Expand Up @@ -149,6 +145,15 @@ def is_void(self):
"""
return self._edb_object.IsVoid()

def get_connected_objects(self):
"""Get connected objects.
Returns
-------
list
"""
return self._pedb.get_connected_objects(self._layout_obj_instance)


class EDBPrimitives(EDBPrimitivesMain):
"""Manages EDB functionalities for a primitives.
Expand Down Expand Up @@ -349,12 +354,6 @@ def get_connected_object_id_set(self):
layoutObjInst = layoutInst.GetLayoutObjInstance(self.primitive_object, None) # 2nd arg was []
return [loi.GetLayoutObj().GetId() for loi in layoutInst.GetConnectedObjects(layoutObjInst).Items]

@pyaedt_function_handler()
def _get_connected_object_obj_set(self):
layoutInst = self.primitive_object.GetLayout().GetLayoutInstance()
layoutObjInst = layoutInst.GetLayoutObjInstance(self.primitive_object, None)
return list([loi.GetLayoutObj() for loi in layoutInst.GetConnectedObjects(layoutObjInst).Items])

@pyaedt_function_handler()
def convert_to_polygon(self):
"""Convert path to polygon.
Expand Down
7 changes: 6 additions & 1 deletion pyaedt/edb_core/edb_data/terminals.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,12 @@ def create(self, padstack_instance, name=None, layer=None, is_ref=False):
layer_obj = self._pedb.stackup.signal_layers[layer]

terminal = self._edb.cell.terminal.PadstackInstanceTerminal.Create(
self._layout, self.net.net_object, name, padstack_instance._edb_object, layer_obj._edb_layer, isRef=is_ref
self._pedb.active_layout,
self.net.net_object,
name,
padstack_instance._edb_object,
layer_obj._edb_layer,
isRef=is_ref,
)
terminal = PadstackInstanceTerminal(self._pedb, terminal)

Expand Down
33 changes: 33 additions & 0 deletions pyaedt/edb_core/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,36 @@ class TerminalType(Enum):
PadstackInstanceTerminal = 3
BundleTerminal = 4
PinGroupTerminal = 5


class Primitives(Enum):
Rectangle = 0
Circle = 1
Polygon = 2
Path = 3
Bondwire = 4
PrimitivePlugin = 5
Text = 6
Path3D = 7
BoardBendDef = 8
InValidType = 9


class LayoutObjType(Enum):
InvalidLayoutObj = -1
Primitive = 0
PadstackInstance = 1
Terminal = 2
TerminalInstance = 3
CellInstance = 4
Layer = 5
Net = 6
Padstack = 7
Group = 8
NetClass = 9
Cell = 10
DifferentialPair = 11
PinGroup = 12
VoltageRegulator = 13
ExtendedNet = 14
LayoutObjTypeCount = 15
Loading

0 comments on commit 5653f90

Please sign in to comment.