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

Extend.find components #207

Merged
merged 2 commits into from
Mar 23, 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 klayout_dot_config/grain.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<salt-grain>
<name>siepic_tools</name>
<version>0.5.5</version>
<version>0.5.6</version>
<api-version>0.27</api-version>
<title>SiEPIC Tools</title>
<doc>Tools for designing Silicon Photonic Integrated Circuits, including waveguides, component simulations, functional verification, DRC verification, Functional verification, netlist extraction, circuit simulations. Layout can be implemented graphically or by programming in Python using the SiEPIC functions and KLayout Python API. Framework and examples for creating layouts using scripts. Includes a generic PDK (GSiP). Other PDKs are installed separately, and depend on SiEPIC-Tools.</doc>
Expand Down
2 changes: 1 addition & 1 deletion klayout_dot_config/python/SiEPIC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SiEPIC-Tools package for KLayout
'''

__version__ = '0.5.5'
__version__ = '0.5.6'

print("KLayout SiEPIC-Tools version %s" %__version__)

Expand Down
21 changes: 19 additions & 2 deletions klayout_dot_config/python/SiEPIC/extend.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,23 @@ def find_components(self, cell_selected=None, inst=None, verbose=False):
cell_selected: only find components that match this specific cell.

inst: return only the component that matches the instance inst

limitation:
- flat components only. doesn't find the component if it is buried in a hierarchy
- no function for instance.find_components. Instead we find based on cell, then try to match it to the requested instance.

'''

if cell_selected != None and type(cell_selected) != type([]):
cell_selected=[cell_selected]

if verbose:
print('*** Cell.find_components:')
if cell_selected[0]:
print(' - cell_selected=%s' % (cell_selected[0].name if cell_selected[0] else None))
if inst:
print(' - inst=%s' % (inst.cell.name))

if cell_selected != None and type(cell_selected) != type([]):
cell_selected=[cell_selected]

components = []

Expand Down Expand Up @@ -968,8 +978,12 @@ def find_components(self, cell_selected=None, inst=None, verbose=False):
idx = len(components) # component index value to be assigned to Component.idx
component_ID = idx
subcell = iter1.cell() # cell (component) to which this shape belongs
if verbose:
print(' - looking at shape in cell %s. ' % subcell.name)
if cell_selected and not subcell in cell_selected:
# check if subcell is one of the arguments to this function: cell_selected
if verbose:
print(' - cell_selected and not subcell (%s) in cell_selected (%s). ' % (subcell.name, cell_selected[0].name))
iter1.next()
continue
component = subcell.basic_name().replace(' ', '_') # name library component
Expand Down Expand Up @@ -1095,6 +1109,9 @@ def find_components(self, cell_selected=None, inst=None, verbose=False):
if component_matched:
return component_matched

if components == []:
raise Exception ('SiEPIC.extend.find_components: No component found for cell_selected=%s' % (cell_selected[0].name if cell_selected else None))

return components
# end def find_components

Expand Down
8 changes: 7 additions & 1 deletion klayout_dot_config/python/SiEPIC/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,9 +1736,15 @@ def connect_cell(instanceA, pinA, cellB, pinB, mirror = False, verbose=False, tr
raise Exception("instanceA needs to be an Instance, not an index")

# Find the two components:
componentA = instanceA.parent_cell.find_components(cell_selected=instanceA.cell, inst=instanceA)
componentA = instanceA.parent_cell.find_components(cell_selected=instanceA.cell, inst=instanceA, verbose=verbose)
componentB = cellB.find_components()
if componentA==[]:
if verbose:
print('*** WARNING: componentA not found, looking lower in the hierarchy')
componentA = instanceA.cell.find_components(inst=instanceA, verbose=verbose)
if componentA==[]:
if verbose:
print('*** WARNING: componentA not found, looking higher in the hierarchy which may not work correctly: instanceA.parent_cell.find_components(inst=instanceA)')
componentA = instanceA.parent_cell.find_components(inst=instanceA)
if componentA==[]:
if _globals.Python_Env == "KLayout_GUI":
Expand Down
5 changes: 3 additions & 2 deletions klayout_dot_config/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "SiEPIC"
version = "0.5.5"
version = "0.5.6"
authors = [
{ name="Lukas Chrostowski", email="[email protected]" },
]
Expand All @@ -14,7 +14,8 @@ classifiers = [
]
dependencies = [
"numpy",
"scipy"]
"scipy",
"pandas"]

[project.urls]
Homepage = "https://github.com/SiEPIC/SiEPIC-Tools"
Expand Down
Loading
Loading