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 3 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
4 changes: 2 additions & 2 deletions src/pyedb/dotnet/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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 All @@ -93,6 +92,7 @@
from pyedb.dotnet.edb_core.padstack import EdbPadstacks
from pyedb.dotnet.edb_core.siwave import EdbSiwave
from pyedb.dotnet.edb_core.stackup import Stackup
from pyedb.dotnet.edb_core.terminal.terminal import Terminal
from pyedb.generic.constants import AEDT_UNITS, SolverType
from pyedb.generic.general_methods import (
generate_unique_name,
Expand Down Expand Up @@ -4135,7 +4135,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.terminal.terminal import PointTerminal

point_terminal = PointTerminal(self)
return point_terminal.create(name, net_name, location, layer)
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/cell/layout_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def component(self):
-------
:class:`dotnet.edb_core.edb_data.nets_data.EDBComponent`
"""
from pyedb.dotnet.edb_core.edb_data.components_data import EDBComponent
from pyedb.dotnet.edb_core.hierarchy.component import EDBComponent

edb_comp = self._edb_object.GetComponent()
if edb_comp.IsNull():
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

from pyedb.dotnet.clr_module import String
from pyedb.dotnet.edb_core.definition.component_def import EDBComponentDef
from pyedb.dotnet.edb_core.edb_data.components_data import EDBComponent
from pyedb.dotnet.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.dotnet.edb_core.edb_data.sources import Source, SourceType
from pyedb.dotnet.edb_core.general import convert_py_list_to_net_list
from pyedb.dotnet.edb_core.hierarchy.component import EDBComponent
from pyedb.dotnet.edb_core.padstack import EdbPadstacks
from pyedb.generic.general_methods import (
_retry_ntimes,
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/definition/component_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def components(self):
-------
dict of :class:`EDBComponent`
"""
from pyedb.dotnet.edb_core.edb_data.components_data import EDBComponent
from pyedb.dotnet.edb_core.hierarchy.component import EDBComponent

comp_list = [
EDBComponent(self._pedb, l)
Expand Down
10 changes: 4 additions & 6 deletions src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,7 @@ def get_terminal(self, name=None, create_new_terminal=False):
if create_new_terminal:
term = self._create_terminal(name)
else:
from pyedb.dotnet.edb_core.edb_data.terminals import (
PadstackInstanceTerminal,
)
from pyedb.dotnet.edb_core.terminal.terminal import PadstackInstanceTerminal

term = PadstackInstanceTerminal(self._pedb, self._edb_object.GetPadstackInstanceTerminal())
if not term.is_null:
Expand All @@ -1198,7 +1196,7 @@ def get_terminal(self, name=None, create_new_terminal=False):
@property
def terminal(self):
"""Terminal."""
from pyedb.dotnet.edb_core.edb_data.terminals import PadstackInstanceTerminal
from pyedb.dotnet.edb_core.terminal.terminal import PadstackInstanceTerminal

term = PadstackInstanceTerminal(self._pedb, self._edb_object.GetPadstackInstanceTerminal())
return term if not term.is_null else None
Expand All @@ -1212,7 +1210,7 @@ def _create_terminal(self, name=None):
@pyedb_function_handler
def create_terminal(self, name=None):
"""Create a padstack instance terminal"""
from pyedb.dotnet.edb_core.edb_data.terminals import PadstackInstanceTerminal
from pyedb.dotnet.edb_core.terminal.terminal import PadstackInstanceTerminal

term = PadstackInstanceTerminal(self._pedb, self._edb_object.GetPadstackInstanceTerminal())
return term.create(self, name)
Expand Down Expand Up @@ -1637,7 +1635,7 @@ def is_pin(self, pin):
@property
def component(self):
"""Component."""
from pyedb.dotnet.edb_core.edb_data.components_data import EDBComponent
from pyedb.dotnet.edb_core.hierarchy.component import EDBComponent

comp = EDBComponent(self._pedb, self._edb_object.GetComponent())
return comp if not comp.is_null else False
Expand Down
2 changes: 1 addition & 1 deletion src/pyedb/dotnet/edb_core/edb_data/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from pyedb.dotnet.edb_core.edb_data.terminals import (
from pyedb.dotnet.edb_core.terminal.terminal import (
BundleTerminal,
EdgeTerminal,
PadstackInstanceTerminal,
Expand Down
4 changes: 2 additions & 2 deletions src/pyedb/dotnet/edb_core/edb_data/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def get_terminal(self, name=None, create_new_terminal=False):
@property
def terminal(self):
"""Terminal."""
from pyedb.dotnet.edb_core.edb_data.terminals import PinGroupTerminal
from pyedb.dotnet.edb_core.terminal.terminal import PinGroupTerminal

term = PinGroupTerminal(self._pedb, self._edb_pin_group.GetPinGroupTerminal())
return term if not term.is_null else None
Expand Down Expand Up @@ -356,7 +356,7 @@ def create_terminal(self, name=None):
"""
if not name:
name = generate_unique_name(self.name)
from pyedb.dotnet.edb_core.edb_data.terminals import PinGroupTerminal
from pyedb.dotnet.edb_core.terminal.terminal import PinGroupTerminal

term = PinGroupTerminal(self._pedb)
term = term.create(name, self.net_name, self.name)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
from pyedb.dotnet.edb_core.cell.hierarchy.model import PinPairModel, SPICEModel
from pyedb.dotnet.edb_core.definition.package_def import PackageDef
from pyedb.dotnet.edb_core.edb_data.padstacks_data import EDBPadstackInstance
from pyedb.dotnet.edb_core.hierarchy.netlist_model import NetlistModel
from pyedb.dotnet.edb_core.hierarchy.pin_pair_model import PinPair
from pyedb.dotnet.edb_core.hierarchy.s_parameter_model import SparamModel
from pyedb.dotnet.edb_core.hierarchy.spice_model import SpiceModel
from pyedb.generic.general_methods import is_ironpython

if not 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/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()
Loading
Loading