Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFACTOR: Pyedb hierarchy terminal refactoring #565

Merged
merged 19 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/api/ComponentsEdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Instances and definitions
These classes are the containers of data management for components reference designator and definitions.


.. currentmodule:: pyedb.dotnet.edb_core.edb_data.components_data
.. currentmodule:: pyedb.dotnet.edb_core.cell.hierarchy.component

.. autosummary::
:toctree: _autosummary
Expand Down
25 changes: 19 additions & 6 deletions src/pyedb/dotnet/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
from pyedb.configuration.configuration import Configuration
from pyedb.dotnet.application.Variables import decompose_variable_value
from pyedb.dotnet.edb_core.cell.layout import Layout
from pyedb.dotnet.edb_core.cell.terminal.bundle_terminal import BundleTerminal
from pyedb.dotnet.edb_core.cell.terminal.edge_terminal import EdgeTerminal
from pyedb.dotnet.edb_core.cell.terminal.padstack_instance_terminal import (
PadstackInstanceTerminal,
)
from pyedb.dotnet.edb_core.cell.terminal.pingroup_terminal import PinGroupTerminal
from pyedb.dotnet.edb_core.cell.terminal.point_terminal import PointTerminal
from pyedb.dotnet.edb_core.cell.terminal.terminal import Terminal
from pyedb.dotnet.edb_core.components import Components
from pyedb.dotnet.edb_core.dotnet.database import Database
from pyedb.dotnet.edb_core.dotnet.layout import LayoutDotNet
Expand Down Expand Up @@ -74,7 +82,6 @@
SiwaveSYZSimulationSetup,
)
from pyedb.dotnet.edb_core.edb_data.sources import SourceType
from pyedb.dotnet.edb_core.edb_data.terminals import Terminal
from pyedb.dotnet.edb_core.edb_data.variables import Variable
from pyedb.dotnet.edb_core.general import (
LayoutObjType,
Expand Down Expand Up @@ -438,12 +445,18 @@ def terminals(self):
"""

temp = {}
terminal_mapping = Terminal(self)._terminal_mapping
for i in self.layout.terminals:
terminal_type = i.ToString().split(".")[-1]
ter = terminal_mapping[terminal_type](self, i)
temp[ter.name] = ter

if terminal_type == "PinGroupTerminal":
temp[i.GetName()] = PinGroupTerminal(self, i)
elif terminal_type == "PadstackInstanceTerminal":
temp[i.GetName()] = PadstackInstanceTerminal(self, i)
elif terminal_type == "EdgeTerminal":
temp[i.GetName()] = EdgeTerminal(self, i)
elif terminal_type == "BundleTerminal":
temp[i.GetName()] = BundleTerminal(self, i)
elif terminal_type == "PointTerminal":
temp[i.GetName()] = PointTerminal(self, i)
return temp

@property
Expand Down Expand Up @@ -4135,7 +4148,7 @@ def get_point_terminal(self, name, net_name, location, layer):
-------
:class:`legacy.edb_core.edb_data.terminals.PointTerminal`
"""
from pyedb.dotnet.edb_core.edb_data.terminals import PointTerminal
from pyedb.dotnet.edb_core.cell.terminal.point_terminal import PointTerminal

point_terminal = PointTerminal(self)
return point_terminal.create(name, net_name, location, layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import warnings

from pyedb.dotnet.edb_core.cell.hierarchy.model import PinPairModel, SPICEModel
from pyedb.dotnet.edb_core.cell.hierarchy.netlist_model import NetlistModel
from pyedb.dotnet.edb_core.cell.hierarchy.pin_pair_model import PinPair
from pyedb.dotnet.edb_core.cell.hierarchy.s_parameter_model import SparamModel
from pyedb.dotnet.edb_core.cell.hierarchy.spice_model import SpiceModel
from pyedb.dotnet.edb_core.definition.package_def import PackageDef
from pyedb.dotnet.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.generic.general_methods import is_ironpython
Expand Down Expand Up @@ -55,121 +59,6 @@ class EDBComponent(object):

"""

class _PinPair(object): # pragma: no cover
def __init__(self, pcomp, edb_comp, edb_comp_prop, edb_model, edb_pin_pair):
self._pedb_comp = pcomp
self._edb_comp = edb_comp
self._edb_comp_prop = edb_comp_prop
self._edb_model = edb_model
self._edb_pin_pair = edb_pin_pair

def _edb_value(self, value):
return self._pedb_comp._get_edb_value(value) # pragma: no cover

@property
def is_parallel(self):
return self._pin_pair_rlc.IsParallel # pragma: no cover

@is_parallel.setter
def is_parallel(self, value):
rlc = self._pin_pair_rlc
rlc.IsParallel = value
self._set_comp_prop() # pragma: no cover

@property
def _pin_pair_rlc(self):
return self._edb_model.GetPinPairRlc(self._edb_pin_pair)

@property
def rlc_enable(self):
rlc = self._pin_pair_rlc
return [rlc.REnabled, rlc.LEnabled, rlc.CEnabled]

@rlc_enable.setter
def rlc_enable(self, value):
rlc = self._pin_pair_rlc
rlc.REnabled = value[0]
rlc.LEnabled = value[1]
rlc.CEnabled = value[2]
self._set_comp_prop() # pragma: no cover

@property
def resistance(self):
return self._pin_pair_rlc.R.ToDouble() # pragma: no cover

@resistance.setter
def resistance(self, value):
self._pin_pair_rlc.R = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def inductance(self):
return self._pin_pair_rlc.L.ToDouble() # pragma: no cover

@inductance.setter
def inductance(self, value):
self._pin_pair_rlc.L = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def capacitance(self):
return self._pin_pair_rlc.C.ToDouble() # pragma: no cover

@capacitance.setter
def capacitance(self, value):
self._pin_pair_rlc.C = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def rlc_values(self): # pragma: no cover
rlc = self._pin_pair_rlc
return [rlc.R.ToDouble(), rlc.L.ToDouble(), rlc.C.ToDouble()]

@rlc_values.setter
def rlc_values(self, values): # pragma: no cover
rlc = self._pin_pair_rlc
rlc.R = self._edb_value(values[0])
rlc.L = self._edb_value(values[1])
rlc.C = self._edb_value(values[2])
self._set_comp_prop() # pragma: no cover

def _set_comp_prop(self): # pragma: no cover
self._edb_model.SetPinPairRlc(self._edb_pin_pair, self._pin_pair_rlc)
self._edb_comp_prop.SetModel(self._edb_model)
self._edb_comp.SetComponentProperty(self._edb_comp_prop)

class _SpiceModel(object): # pragma: no cover
def __init__(self, edb_model):
self._edb_model = edb_model

@property
def file_path(self):
return self._edb_model.GetSPICEFilePath()

@property
def name(self):
return self._edb_model.GetSPICEName()

class _SparamModel(object): # pragma: no cover
def __init__(self, edb_model):
self._edb_model = edb_model

@property
def name(self):
return self._edb_model.GetComponentModelName()

@property
def reference_net(self):
return self._edb_model.GetReferenceNet()

class _NetlistModel(object): # pragma: no cover
def __init__(self, edb_model):
self._edb_model = edb_model

@property
def netlist(self):
return self._edb_model.GetNetlist()

def __init__(self, pedb, cmp):
self._pedb = pedb
self.edbcomponent = cmp
Expand Down Expand Up @@ -211,7 +100,7 @@ def _pin_pairs(self):
edb_comp_prop = self.component_property
edb_model = self._edb_model
return [
self._PinPair(self, self.edbcomponent, edb_comp_prop, edb_model, pin_pair)
PinPair(self, self.edbcomponent, edb_comp_prop, edb_model, pin_pair)
for pin_pair in list(edb_model.PinPairs)
]

Expand Down Expand Up @@ -313,23 +202,23 @@ def spice_model(self):
if not self.model_type == "SPICEModel":
return None
else:
return self._SpiceModel(self._edb_model)
return SpiceModel(self._edb_model)

@property
def s_param_model(self):
"""Get assigned S-parameter model properties."""
if not self.model_type == "SParameterModel":
return None
else:
return self._SparamModel(self._edb_model)
return SparamModel(self._edb_model)

@property
def netlist_model(self):
"""Get assigned netlist model properties."""
if not self.model_type == "NetlistModel":
return None
else:
return self._NetlistModel(self._edb_model)
return NetlistModel(self._edb_model)

@property
def solder_ball_height(self):
Expand Down
30 changes: 30 additions & 0 deletions src/pyedb/dotnet/edb_core/cell/hierarchy/netlist_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


class NetlistModel(object): # pragma: no cover
def __init__(self, edb_model):
self._edb_model = edb_model

@property
def netlist(self):
return self._edb_model.GetNetlist()
105 changes: 105 additions & 0 deletions src/pyedb/dotnet/edb_core/cell/hierarchy/pin_pair_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


class PinPair(object): # pragma: no cover
def __init__(self, pcomp, edb_comp, edb_comp_prop, edb_model, edb_pin_pair):
self._pedb_comp = pcomp
self._edb_comp = edb_comp
self._edb_comp_prop = edb_comp_prop
self._edb_model = edb_model
self._edb_pin_pair = edb_pin_pair

def _edb_value(self, value):
return self._pedb_comp._get_edb_value(value) # pragma: no cover

@property
def is_parallel(self):
return self._pin_pair_rlc.IsParallel # pragma: no cover

@is_parallel.setter
def is_parallel(self, value):
rlc = self._pin_pair_rlc
rlc.IsParallel = value
self._set_comp_prop() # pragma: no cover

@property
def _pin_pair_rlc(self):
return self._edb_model.GetPinPairRlc(self._edb_pin_pair)

@property
def rlc_enable(self):
rlc = self._pin_pair_rlc
return [rlc.REnabled, rlc.LEnabled, rlc.CEnabled]

@rlc_enable.setter
def rlc_enable(self, value):
rlc = self._pin_pair_rlc
rlc.REnabled = value[0]
rlc.LEnabled = value[1]
rlc.CEnabled = value[2]
self._set_comp_prop() # pragma: no cover

@property
def resistance(self):
return self._pin_pair_rlc.R.ToDouble() # pragma: no cover

@resistance.setter
def resistance(self, value):
self._pin_pair_rlc.R = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def inductance(self):
return self._pin_pair_rlc.L.ToDouble() # pragma: no cover

@inductance.setter
def inductance(self, value):
self._pin_pair_rlc.L = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def capacitance(self):
return self._pin_pair_rlc.C.ToDouble() # pragma: no cover

@capacitance.setter
def capacitance(self, value):
self._pin_pair_rlc.C = value
self._set_comp_prop(self._pin_pair_rlc) # pragma: no cover

@property
def rlc_values(self): # pragma: no cover
rlc = self._pin_pair_rlc
return [rlc.R.ToDouble(), rlc.L.ToDouble(), rlc.C.ToDouble()]

@rlc_values.setter
def rlc_values(self, values): # pragma: no cover
rlc = self._pin_pair_rlc
rlc.R = self._edb_value(values[0])
rlc.L = self._edb_value(values[1])
rlc.C = self._edb_value(values[2])
self._set_comp_prop() # pragma: no cover

def _set_comp_prop(self): # pragma: no cover
self._edb_model.SetPinPairRlc(self._edb_pin_pair, self._pin_pair_rlc)
self._edb_comp_prop.SetModel(self._edb_model)
self._edb_comp.SetComponentProperty(self._edb_comp_prop)
Loading
Loading