Skip to content

Commit

Permalink
Merge pull request #207 from SiEPIC/extend.find_components
Browse files Browse the repository at this point in the history
Extend.find components
  • Loading branch information
lukasc-ubc authored Mar 23, 2024
2 parents 88fbc52 + 08532fb commit c391f54
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 238 deletions.
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

0 comments on commit c391f54

Please sign in to comment.