Skip to content

advanced net query #1352

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

Merged
merged 2 commits into from
Jul 5, 2022
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
6 changes: 6 additions & 0 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def test_08_nets_query(self):
assert not signalnets[list(signalnets.keys())[0]].IsPowerGround()
assert len(list(signalnets[list(signalnets.keys())[0]].primitives)) > 0

assert self.edbapp.core_nets.find_or_create_net("GND")
assert self.edbapp.core_nets.find_or_create_net(start_with="gn")
assert self.edbapp.core_nets.find_or_create_net(start_with="g", end_with="d")
assert self.edbapp.core_nets.find_or_create_net(end_with="d")
assert self.edbapp.core_nets.find_or_create_net(contain="usb")

def test_09_assign_rlc(self):
assert self.edbapp.core_components.set_component_rlc(
"C3B14", res_value=1e-3, cap_value="10e-6", isparallel=False
Expand Down
64 changes: 58 additions & 6 deletions pyaedt/edb_core/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,27 +598,79 @@ def delete_nets(self, netlist):
return nets_deleted

@pyaedt_function_handler()
def find_or_create_net(self, net_name=""):
def find_or_create_net(self, net_name="", start_with="", contain="", end_with=""):
"""Find or create the net with the given name in the layout.

Parameters
----------
net_name : str, optional
Name of the net to find or create. The default is ``""``.

start_with : str, optional
All net name starting with the string. Not case-sensitive.

contain : str, optional
All net name containing the string. Not case-sensitive.

end_with : str, optional
All net name ending with the string. Not case-sensitive.

Returns
-------
object
Net Object
"""
if not net_name:
if not net_name and not start_with and not contain and not end_with:
net_name = generate_unique_name("NET_")
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
return net
else:
net = self._edb.Cell.Net.FindByName(self._active_layout, net_name)
if net.IsNull():
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
return net
if not start_with and not contain and not end_with:
net = self._edb.Cell.Net.FindByName(self._active_layout, net_name)
if net.IsNull():
net = self._edb.Cell.Net.Create(self._active_layout, net_name)
return net
elif start_with:
nets_found = [
self.nets[net].net_object for net in list(self.nets.keys()) if net.lower().startswith(start_with)
]
return nets_found
elif start_with and end_with:
nets_found = [
self.nets[net].net_object
for net in list(self.nets.keys())
if net.lower().startswith(start_with) and net.lower().endswith(end_with)
]
return nets_found
elif start_with and contain and end_with:
nets_found = [
self.nets[net].net_object
for net in list(self.nets.keys())
if net.lower().startswith(start_with) and net.lower().endswith(end_with) and contain in net.lower()
]
return nets_found
elif start_with and contain:
nets_found = [
self.nets[net].net_object
for net in list(self.nets.keys())
if net.lower().startswith(start_with) and contain in net.lower()
]
return nets_found
elif contain and end_with:
nets_found = [
self.nets[net].net_object
for net in list(self.nets.keys())
if net.lower().endswith(end_with) and contain in net.lower()
]
return nets_found
elif end_with and not start_with and not contain:
nets_found = [
self.nets[net].net_object for net in list(self.nets.keys()) if net.lower().endswith(end_with)
]
return nets_found
elif contain and not start_with and not end_with:
nets_found = [self.nets[net].net_object for net in list(self.nets.keys()) if contain in net.lower()]
return nets_found

@pyaedt_function_handler()
def is_net_in_component(self, component_name, net_name):
Expand Down