Skip to content

Commit

Permalink
fix menu Layout > Show selected components
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasc-ubc committed Jul 29, 2024
1 parent ed2e2cf commit b9db833
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 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.11</version>
<version>0.5.12</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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def show_component_info():
text += ('&lt;br&gt;')
text += " selected cell name: %s" % obj.inst().cell.name
text += ('&lt;br&gt;')
c = cell.find_components(cell_selected=[obj.inst().cell],verbose=True)
c = cell.find_components(cell_selected=tuple([obj.inst().cell]),verbose=True, raiseException = False)
if c and c[0].cell:
text += c[0].display().replace(';','&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;')
if c[0].cell.is_pcell_variant():
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.11'
__version__ = '0.5.12'

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

Expand Down
17 changes: 13 additions & 4 deletions klayout_dot_config/python/SiEPIC/extend.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ def find_pins(self, verbose=False, polygon_devrec=None, GUI=False):
Electrical Pins have:
1) box on layer PinRec
2) text on layer PinRec, inside the box
Returns:
pins: SiEPIC.core.Pin
pin_errors: text
'''

if verbose:
Expand Down Expand Up @@ -946,7 +951,7 @@ def find_pins_component(self, component):
'''
from functools import lru_cache
@lru_cache(maxsize=None)
def find_components(self, cell_selected=None, inst=None, verbose=False):
def find_components(self, cell_selected=None, inst=None, verbose=False, raiseException = True):
'''
Function to traverse the cell's hierarchy and find all the components
returns list of components (class Component)
Expand All @@ -963,13 +968,15 @@ def find_components(self, cell_selected=None, inst=None, verbose=False):
inst: return only the component that matches the instance inst
raiseException: False turns of exception handling, and returns None instead
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([]):
if cell_selected != None and type(cell_selected) != type([]) and type(cell_selected) != tuple:
cell_selected=[cell_selected]

if verbose:
Expand Down Expand Up @@ -1143,8 +1150,10 @@ def find_components(self, cell_selected=None, inst=None, verbose=False):
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))

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

Expand Down
11 changes: 7 additions & 4 deletions klayout_dot_config/python/SiEPIC/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def connect_pins_with_waveguide(instanceA, pinA, instanceB, pinB, waveguide = No
else:
waveguide = waveguides[0]
print('error: waveguide type not found in PDK waveguides')
raise Exception('error: waveguide type (%s) not found in PDK waveguides' % waveguide_type)
raise Exception('error: waveguide type (%s) not found in PDK. Waveguides available: %s' % (waveguide_type, [w['name'] for w in waveguides]))
# check if the waveguide type is compound waveguide
if 'compound_waveguide' in waveguide:
waveguide = [w for w in waveguides if w['name']==waveguide['compound_waveguide']['singlemode']]
Expand Down Expand Up @@ -1780,7 +1780,8 @@ def connect_cell(instanceA, pinA, cellB, pinB, mirror = False, verbose=False, tr

if type(componentA) == type([]):
componentA = componentA[0]
componentB = componentB[0]
if type(componentB) == type([]):
componentB = componentB[0]
if verbose:
componentA.display()
componentB.display()
Expand All @@ -1794,9 +1795,11 @@ def connect_cell(instanceA, pinA, cellB, pinB, mirror = False, verbose=False, tr
import re
try:
if cpinA==[]:
cpinA = [p for p in componentA.pins if re.findall(r'\d+', pinA)[0] in p.pin_name]
if re.findall(r'\d+', pinA):
cpinA = [p for p in componentA.pins if re.findall(r'\d+', pinA)[0] in p.pin_name]
if cpinB==[]:
cpinB = [p for p in componentB.pins if re.findall(r'\d+', pinB)[0] in p.pin_name]
if re.findall(r'\d+', pinB):
cpinB = [p for p in componentB.pins if re.findall(r'\d+', pinB)[0] in p.pin_name]
except:
print('error in siepic.scripts.connect_cell')

Expand Down
2 changes: 1 addition & 1 deletion 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.11"
version = "0.5.12"
authors = [
{ name="Lukas Chrostowski", email="[email protected]" },
]
Expand Down

0 comments on commit b9db833

Please sign in to comment.