Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Coriolis VLSI EDA
Coriolis
Commits
d2e1ab37
Commit
d2e1ab37
authored
Jun 02, 2021
by
Jean-Paul Chaput
Browse files
Add rgetInstanceMatching to utilities, as reminder and for later use.
parent
1afc48fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
cumulus/src/plugins/alpha/utils.py
View file @
d2e1ab37
...
...
@@ -18,6 +18,7 @@ from Hurricane import Breakpoint
from
Hurricane
import
Box
from
Hurricane
import
Vertical
from
Hurricane
import
RoutingPad
from
helpers
import
trace
def
breakpoint
(
editor
,
level
,
message
):
...
...
@@ -96,3 +97,45 @@ def hpathToName ( path ):
if
len
(
s
):
s
+=
'_'
s
+=
head
.
getName
()
return
s
def
getInstanceMatching
(
cell
,
pattern
,
level
=
0
):
"""
getInstanceMatching(): returns first instance with the word being searched.
"""
for
instance
in
cell
.
getInstances
():
name
=
instance
.
getName
()
if
pattern
in
name
:
trace
(
550
,
'
\t
{} {} match pattern "{}"
\n
'
.
format
(
' '
*
level
,
instance
,
pattern
)
)
return
instance
return
None
def
rgetInstanceMatching
(
cell
,
path
,
level
=
0
):
"""
Get the instance designated by path (recursively). The path argument can be
either a string of instance names separated by dots or directly a list of
instances names.
It also "reconstructs" the actual full path name of the instances
found recursively.
"""
if
isinstance
(
path
,
str
):
path
=
path
.
split
(
'.'
)
elif
not
isinstance
(
path
,
list
):
raise
ErrorMessage
(
1
,
'rgetInstanceMatching(): "path" argument is '
\
'neither a string or a list ({})."'
\
.
format
(
path
)
)
# Find instance at this level.
instance
=
getInstanceMatching
(
cell
,
path
[
0
],
level
)
if
instance
is
None
:
raise
ErrorMessage
(
1
,
'rgetInstanceMatching(): No instance "{}" in cell "{}".'
\
.
format
(
path
[
0
],
cell
.
getName
())
)
iname
=
instance
.
getName
()
# Last instance (leaf search), return it.
if
len
(
path
)
==
1
:
return
instance
,
iname
# Chew down another level, another brick in the wall
rinstance
,
rname
=
rgetInstanceLike
(
instance
.
getMasterCell
(),
path
[
1
:],
level
+
1
)
# Accumulate the names recursively found "level0.level1.level2..."
return
rinstance
,
'{}.{}'
.
format
(
iname
,
rname
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment