Skip to content

Commit

Permalink
test #53 done
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Oct 22, 2024
1 parent 9b1bc4b commit 1c269d4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
8 changes: 5 additions & 3 deletions src/pyedb/grpc/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from pyedb.grpc.edb_core.modeler import Modeler
from pyedb.grpc.edb_core.net import Nets
from pyedb.grpc.edb_core.nets.differential_pair import DifferentialPairs
from pyedb.grpc.edb_core.nets.extended_net import ExtendedNet
from pyedb.grpc.edb_core.nets.extended_net import ExtendedNets
from pyedb.grpc.edb_core.nets.net_class import NetClass
from pyedb.grpc.edb_core.padstack import Padstacks
from pyedb.grpc.edb_core.ports.ports import BundleWavePort, CoaxPort, GapPort, WavePort
Expand Down Expand Up @@ -336,6 +336,7 @@ def _init_objects(self):
self._materials = Materials(self)
self._source_excitation = SourceExcitation(self)
self._differential_pairs = DifferentialPairs(self)
self._extended_nets = ExtendedNets(self)

@property
def cell_names(self):
Expand Down Expand Up @@ -875,8 +876,9 @@ def extended_nets(self):
>>> edbapp.extended_nets
"""

if self.active_db:
return [ExtendedNet(self, net) for net in self.active_layout.extended_nets]
if not self._extended_nets:
self._extended_nets = ExtendedNets(self)
return self._extended_nets

@property
def differential_pairs(self):
Expand Down
48 changes: 29 additions & 19 deletions src/pyedb/grpc/edb_core/nets/extended_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class ExtendedNets:
def __init(self, pedb):
def __init__(self, pedb):
self._pedb = pedb

@property
Expand Down Expand Up @@ -65,7 +65,7 @@ def create(self, name, net):
if isinstance(net, str):
net = [net]
for i in net:
extended_net.add_net(i)
extended_net.add_net(self._pedb.nets.nets[i])
return self.items[name]

def auto_identify_signal(self, resistor_below=10, inductor_below=1, capacitor_above=1e-9, exception_list=None):
Expand Down Expand Up @@ -176,10 +176,18 @@ def generate_extended_nets(
if exception_list is None:
exception_list = []
_extended_nets = []
_nets = self.nets
_nets = self._pedb.nets.nets
all_nets = list(_nets.keys())[:]
net_dicts = self._comps_by_nets_dict if self._comps_by_nets_dict else self.components_by_nets
comp_dict = self._nets_by_comp_dict if self._nets_by_comp_dict else self.nets_by_components
net_dicts = (
self._pedb.nets._comps_by_nets_dict
if self._pedb.nets._comps_by_nets_dict
else (self._pedb.nets.components_by_nets)
)
comp_dict = (
self._pedb.nets._nets_by_comp_dict
if self._pedb.nets._nets_by_comp_dict
else (self._pedb.nets.nets_by_components)
)

def get_net_list(net_name, _net_list):
comps = []
Expand All @@ -189,25 +197,21 @@ def get_net_list(net_name, _net_list):
for vals in comps:
refdes = vals
cmp = self._pedb.components.instances[refdes]
is_enabled = cmp.is_enabled
if not is_enabled:
if cmp.type not in ["inductor", "resistor", "capacitor"]:
continue
val_type = cmp.type
if val_type not in ["Inductor", "Resistor", "Capacitor"]:
if not cmp.enabled:
continue

val_value = cmp.rlc_values
if refdes in exception_list:
pass
elif val_type == "Inductor" and val_value[1] < inductor_below:
elif cmp.type == "inductor" and val_value[1] < inductor_below:
pass
elif val_type == "Resistor" and val_value[0] < resistor_below:
elif cmp.type == "resistor" and val_value[0] < resistor_below:
pass
elif val_type == "Capacitor" and val_value[2] > capacitor_above:
elif cmp.type == "capacitor" and val_value[2] > capacitor_above:
pass
else:
continue

for net in comp_dict[refdes]:
if net not in _net_list:
_net_list.append(net)
Expand All @@ -231,12 +235,18 @@ def get_net_list(net_name, _net_list):

if is_power:
if include_power:
self._pedb.extended_nets.create(i, new_ext)
ext_net = ExtendedNet.create(self._pedb.layout, i)
ext_net.add_net(self._pedb.nets.nets[i])
for net in new_ext:
ext_net.add_net(self._pedb.nets.nets[net])
else: # pragma: no cover
pass
else:
if include_signal:
self._pedb.extended_nets.create(i, new_ext)
ext_net = ExtendedNet.create(self._pedb.layout, i)
ext_net.add_net(self._pedb.nets.nets[i])
for net in new_ext:
ext_net.add_net(self._pedb.nets.nets[net])
else: # pragma: no cover
pass

Expand All @@ -249,7 +259,7 @@ class ExtendedNet(GrpcExtendedNet):
"""

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

@property
Expand Down Expand Up @@ -280,7 +290,7 @@ def serial_rlc(self):
for comp_name, comp_obj in self.components.items():
if comp_obj.type not in ["resistor", "inductor", "capacitor"]:
continue
if set(comp_obj.nets).issubset(set(nets)):
if set(list(nets.keys())).issubset(comp_obj.nets):
res[comp_name] = comp_obj
return res

Expand All @@ -292,6 +302,6 @@ def shunt_rlc(self):
for comp_name, comp_obj in self.components.items():
if comp_obj.type not in ["resistor", "inductor", "capacitor"]:
continue
if not set(comp_obj.nets).issubset(set(nets)):
if not set(list(nets.keys())).issubset(comp_obj.nets):
res[comp_name] = comp_obj
return res
2 changes: 1 addition & 1 deletion src/pyedb/grpc/edb_core/nets/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def components(self):
component = padstack_instance.component
if component:
try:
component[component.name] = component
components[component.name] = component
except:
pass
return components
Expand Down
13 changes: 7 additions & 6 deletions tests/grpc/system/test_edb_extended_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ def init(self, local_scratch, target_path, target_path2, target_path4):

def test_nets_queries(self, edb_examples):
"""Evaluate nets queries"""
# Done
edbapp = edb_examples.get_si_verse()
assert edbapp.extended_nets.auto_identify_signal()
assert edbapp.extended_nets.auto_identify_power()
extended_net_name, _ = next(iter(edbapp.extended_nets.items.items()))
assert edbapp.extended_nets[extended_net_name]
assert edbapp.extended_nets[extended_net_name].nets
assert edbapp.extended_nets[extended_net_name].components
assert edbapp.extended_nets[extended_net_name].rlc
assert edbapp.extended_nets[extended_net_name].serial_rlc
assert edbapp.extended_nets["1V0"].shunt_rlc
assert edbapp.extended_nets.items[extended_net_name]
assert edbapp.extended_nets.items[extended_net_name].nets
assert edbapp.extended_nets.items[extended_net_name].components
assert edbapp.extended_nets.items[extended_net_name].rlc
assert edbapp.extended_nets.items[extended_net_name].serial_rlc
assert edbapp.extended_nets.items["1V0"].serial_rlc
assert edbapp.extended_nets.create("new_ex_net", "DDR4_A1")
edbapp.close()

0 comments on commit 1c269d4

Please sign in to comment.