Skip to content

Commit

Permalink
test #26 done
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Oct 17, 2024
1 parent 7086282 commit 6d46384
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 162 deletions.
18 changes: 10 additions & 8 deletions src/pyedb/grpc/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3938,15 +3938,17 @@ def create_model_for_arbitrary_wave_ports(
if not reference_layer in [padstack_inst.start_layer, padstack_inst.stop_layer]:
padstack_inst.delete()
else:
if padstack_inst.net_name in signal_nets:
if padstack_inst.net.name in signal_nets:
padstack_instances_index.insert(padstack_inst.id, padstack_inst.position)
if not padstack_inst.padstack_definition in used_padstack_defs:
used_padstack_defs.append(padstack_inst.padstack_definition)
if not padstack_inst.padstack_def.name in used_padstack_defs:
used_padstack_defs.append(padstack_inst.padstack_def.name)

polys = [
poly
for poly in self.modeler.primitives
if poly.layer_name == reference_layer and poly.type == "Polygon" and poly.has_voids
if poly.layer.name == reference_layer
and self.modeler.primitives[0].primitive_type.name == "POLYGON"
and poly.has_voids
]
if not polys:
self.logger.error(
Expand All @@ -3958,10 +3960,10 @@ def create_model_for_arbitrary_wave_ports(
for poly in polys:
for void in poly.voids:
void_bbox = (
void.polygon_data.bbox[0].x.value,
void.polygon_data.bbox[0].y.value,
void.polygon_data.bbox[1].x.value,
void.polygon_data.bbox[1].y.value,
void.polygon_data.bbox()[0].x.value,
void.polygon_data.bbox()[0].y.value,
void.polygon_data.bbox()[1].x.value,
void.polygon_data.bbox()[1].y.value,
)
included_instances = list(padstack_instances_index.intersection(void_bbox))
if included_instances:
Expand Down
1 change: 1 addition & 0 deletions src/pyedb/grpc/edb_core/layers/stackup_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class StackupLayer(GrpcStackupLayer):
def __init__(self, pedb, edb_object=None):
super().__init__(edb_object.msg)
self._pedb = pedb
self._edb_object = edb_object

@property
def _stackup_layer_mapping(self):
Expand Down
64 changes: 47 additions & 17 deletions src/pyedb/grpc/edb_core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"""
import math

from ansys.edb.core.definition.bondwire_def import (
BondwireDefType as GrpcBondwireDefType,
)
from ansys.edb.core.geometry.arc_data import ArcData as GrpcArcData
from ansys.edb.core.geometry.point_data import PointData as GrpcPointData
from ansys.edb.core.geometry.polygon_data import (
Expand All @@ -38,6 +35,7 @@
from ansys.edb.core.primitive.primitive import (
RectangleRepresentationType as GrpcRectangleRepresentationType,
)
from ansys.edb.core.primitive.primitive import BondwireType as GrpcBondwireType
from ansys.edb.core.primitive.primitive import PathCornerType as GrpcPathCornerType
from ansys.edb.core.primitive.primitive import PathEndCapType as GrpcPathEndCapType
from ansys.edb.core.utility.value import Value as GrpcValue
Expand Down Expand Up @@ -632,15 +630,16 @@ def create_polygon(self, main_shape, layer_name, voids=[], net_name=""):
"""
net = self._pedb.nets.find_or_create_net(net_name)
if isinstance(main_shape, list):
new_points = []
for idx, i in enumerate(main_shape):
new_points = self._edb.Geometry.PointData(GrpcValue(i[0]), GrpcValue(i[1]))
polygon_data = GrpcPolygonData(points=new_points)
new_points.append(GrpcPointData([GrpcValue(i[0]), GrpcValue(i[1])]))
polygon_data = GrpcPolygonData(points=new_points)

elif isinstance(main_shape, Modeler.Shape):
polygon_data = self.shape_to_polygon_data(main_shape)
elif isinstance(main_shape, GrpcPolygonData):
polygon_data = main_shape
else:
polygon_data = main_shape
if polygon_data or polygon_data.points:
if not polygon_data.points:
self._logger.error("Failed to create main shape polygon data")
return False
for void in voids:
Expand All @@ -660,7 +659,7 @@ def create_polygon(self, main_shape, layer_name, voids=[], net_name=""):
if polygon.is_null or polygon_data is False: # pragma: no cover
self._logger.error("Null polygon created")
return False
return polygon
return Polygon(self._pedb, polygon)

def create_rectangle(
self,
Expand Down Expand Up @@ -1279,6 +1278,8 @@ def create_bondwire(
end_x,
end_y,
net,
start_cell_instance_name=None,
end_cell_instance_name=None,
bondwire_type="jedec4",
):
"""Create a bondwire object.
Expand Down Expand Up @@ -1309,22 +1310,48 @@ def create_bondwire(
Y value of end point.
net : str or :class:`Net <ansys.edb.net.Net>` or None
Net of the Bondwire.
start_cell_instance_name : str, optional
Cell instance name where the bondwire starts.
end_cell_instance_name : str, optional
Cell instance name where the bondwire ends.
Returns
-------
:class:`pyedb.dotnet.edb_core.dotnet.primitive.BondwireDotNet`
Bondwire object created.
"""
from ansys.edb.core.hierarchy.cell_instance import (
CellInstance as GrpcCellInstance,
)

start_cell_inst = None
end_cell_inst = None
cell_instances = {cell_inst.name: cell_inst for cell_inst in self._active_layout.cell_instances}
if start_cell_instance_name:
if start_cell_instance_name not in cell_instances:
start_cell_inst = GrpcCellInstance.create(
self._pedb.active_layout, start_cell_instance_name, ref=self._pedb.active_layout
)
else:
start_cell_inst = cell_instances[start_cell_instance_name]
cell_instances = {cell_inst.name: cell_inst for cell_inst in self._active_layout.cell_instances}
if end_cell_instance_name:
if end_cell_instance_name not in cell_instances:
end_cell_inst = GrpcCellInstance.create(
self._pedb.active_layout, end_cell_instance_name, ref=self._pedb.active_layout
)
else:
end_cell_inst = cell_instances[end_cell_instance_name]

if bondwire_type == "jedec4":
bondwire_type = GrpcBondwireDefType.JEDEC4_BONDWIRE_DEF
bondwire_type = GrpcBondwireType.JEDEC4
elif bondwire_type == "jedec5":
bondwire_type = GrpcBondwireDefType.JEDEC5_BONDWIRE_DEF
bondwire_type = GrpcBondwireType.JEDEC5
elif bondwire_type == "apd":
bondwire_type = GrpcBondwireDefType.APD_BONDWIRE_DEF
bondwire_type = GrpcBondwireType.APD
else:
bondwire_type = GrpcBondwireDefType.JEDEC4_BONDWIRE_DEF
return Bondwire.create(
bondwire_type = GrpcBondwireType.JEDEC4
bw = Bondwire.create(
layout=self._active_layout,
bondwire_type=bondwire_type,
definition_name=definition_name,
Expand All @@ -1338,9 +1365,10 @@ def create_bondwire(
end_x=GrpcValue(end_x),
end_y=GrpcValue(end_y),
net=net,
end_context=self._pedb.active_cell,
start_context=self._pedb.active_cell,
end_context=end_cell_inst,
start_context=start_cell_inst,
)
return Bondwire(self._pedb, bw)

def create_pin_group(
self,
Expand All @@ -1367,7 +1395,9 @@ def create_pin_group(
if isinstance(pins_by_id, int):
pins_by_id = [pins_by_id]
for p in pins_by_id:
edb_pin = self._pedb.layout.find_object_by_id(p)
edb_pin = None
if p in self._pedb.padstacks.instances:
edb_pin = self._pedb.padstacks.instances[p]
if edb_pin and not p in pins:
pins[p] = edb_pin
if not pins_by_aedt_name:
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/grpc/edb_core/padstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def instances(self):
pad_stack_inst = self._pedb.layout.padstack_instances
if len(self._instances) == len(pad_stack_inst):
return self._instances
self._instances = {i.id: PadstackInstance(self._pedb, i) for i in pad_stack_inst}
self._instances = {i.edb_uid: PadstackInstance(self._pedb, i) for i in pad_stack_inst}
return self._instances

@property
Expand Down
140 changes: 81 additions & 59 deletions src/pyedb/grpc/edb_core/primitive/bondwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,40 @@ class Bondwire(GrpcBondWire):
def __init__(self, _pedb, edb_object):
super().__init__(edb_object.msg)
self._pedb = _pedb
self._edb_object = edb_object

def __create(self, **kwargs):
return Bondwire.create(
self._pedb.layout._edb_object,
kwargs.get("net"),
self._bondwire_type[kwargs.get("bondwire_type")],
kwargs.get("definition_name"),
kwargs.get("placement_layer"),
kwargs.get("width"),
kwargs.get("material"),
kwargs.get("start_context"),
kwargs.get("start_layer_name"),
kwargs.get("start_x"),
kwargs.get("start_y"),
kwargs.get("end_context"),
kwargs.get("end_layer_name"),
kwargs.get("end_x"),
kwargs.get("end_y"),
)
@property
def material(self):
return self.get_material().value

@material.setter
def material(self, value):
self.set_material(value)

# def __create(self, **kwargs):
# return Bondwire.create(
# self._pedb.layout,
# kwargs.get("net"),
# self._bondwire_type[kwargs.get("bondwire_type")],
# kwargs.get("definition_name"),
# kwargs.get("placement_layer"),
# kwargs.get("width"),
# kwargs.get("material"),
# kwargs.get("start_context"),
# kwargs.get("start_layer_name"),
# kwargs.get("start_x"),
# kwargs.get("start_y"),
# kwargs.get("end_context"),
# kwargs.get("end_layer_name"),
# kwargs.get("end_x"),
# kwargs.get("end_y"),
# )

@property
def type(self):
"""str: Bondwire-type of a bondwire object. Supported values for setter: `"apd"`, `"jedec4"`, `"jedec5"`,
`"num_of_type"`"""
return self.type.name.lower()
return super().type.name.lower()

@type.setter
def type(self, bondwire_type):
Expand All @@ -68,60 +77,49 @@ def type(self, bondwire_type):
"jedec5": GrpcBondWireType.JEDEC5,
"num_of_type": GrpcBondWireType.NUM_OF_TYPE,
}
self.type = mapping[bondwire_type]
super(Bondwire, self.__class__).type.__set__(self, mapping[bondwire_type])

@property
def cross_section_type(self):
"""str: Bondwire-cross-section-type of a bondwire object. Supported values for setter: `"round",
`"rectangle"`"""
return super().cross_section_type.name
return super().cross_section_type.name.lower()

@cross_section_type.setter
def cross_section_type(self, bondwire_type):
def cross_section_type(self, cross_section_type):
mapping = {"round": GrpcBondwireCrossSectionType.ROUND, "rectangle": GrpcBondwireCrossSectionType.RECTANGLE}
super().cross_section_type = mapping[bondwire_type]
super(Bondwire, self.__class__).cross_section_type.__set__(self, mapping[cross_section_type])

@property
def cross_section_height(self):
"""float: Bondwire-cross-section height of a bondwire object."""
return super().cross_section_height.value

@cross_section_height.setter
def cross_section_height(self, height):
super().cross_section_height = GrpcValue(height)

def get_trajectory(self):
"""Get trajectory parameters of a bondwire object.
Returns
-------
tuple[float, float, float, float]
Returns a tuple of the following format:
**(x1, y1, x2, y2)**
**x1** : X value of the start point.
**y1** : Y value of the start point.
**x1** : X value of the end point.
**y1** : Y value of the end point.
"""
return [i.value for i in self.get_trajectory()]

def set_trajectory(self, x1, y1, x2, y2):
"""Set the parameters of the trajectory of a bondwire.
Parameters
----------
x1 : float
X value of the start point.
y1 : float
Y value of the start point.
x2 : float
X value of the end point.
y2 : float
Y value of the end point.
"""
values = [GrpcValue(i) for i in [x1, y1, x2, y2]]
self.set_trajectory(*values)
def cross_section_height(self, cross_section_height):
super(Bondwire, self.__class__).cross_section_height.__set__(self, GrpcValue(cross_section_height))

# @property
# def trajectory(self):
# """Get trajectory parameters of a bondwire object.
#
# Returns
# -------
# tuple[float, float, float, float]
#
# Returns a tuple of the following format:
# **(x1, y1, x2, y2)**
# **x1** : X value of the start point.
# **y1** : Y value of the start point.
# **x1** : X value of the end point.
# **y1** : Y value of the end point.
# """
# return [i.value for i in self.get_traj()]
#
# @trajectory.setter
# def trajectory(self, value):
# values = [GrpcValue(i) for i in value]
# self.set_traj(values[0], values[1], values[2], values[3])

@property
def width(self):
Expand All @@ -130,4 +128,28 @@ def width(self):

@width.setter
def width(self, width):
super().width = GrpcValue(width)
super(Bondwire, self.__class__).width.__set__(self, GrpcValue(width))

# @property
# def start_elevation(self):
# layer = self.get_start_elevation(self._pedb.active_cell)
# return layer.name
#
# @start_elevation.setter
# def start_elevation(self, layer):
# if not layer in self._pedb.stackup.layers:
# return
# layer = self._pedb.stackup.layers[layer]
# self.set_start_elevation(self._pedb.active_cell, layer)
#
# @property
# def end_elevation(self):
# layer = self.get_end_elevation(self._pedb.active_cell)
# return layer.name
#
# @end_elevation.setter
# def end_elevation(self, layer):
# if not layer in self._pedb.stackup.layers:
# return
# layer = self._pedb.stackup.layers[layer]
# self.set_end_elevation(self._pedb.active_cell, layer)
4 changes: 2 additions & 2 deletions src/pyedb/grpc/edb_core/primitive/padstack_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ def position(self):
position = self.get_position_and_rotation()
if self.component:
out2 = self.component.transform.transform_point(GrpcPointData(position[:2]))
self._position = out2
self._position = [round(out2[0].value, 6), round(out2[1].value, 6)]
else:
self._position = position[:2]
self._position = [round(pt.value, 6) for pt in position[:2]]
return self._position

@position.setter
Expand Down
Loading

0 comments on commit 6d46384

Please sign in to comment.