traversing hierarchical nested output from dbGetTrueOverlaps

V

vlsidesign

Guest
Was hoping to get a hint. I have a shape (at top/current level of
heir) and I want to check to see if that shape overlaps a particular
cell with a certain name. It looks like the dbGetTrueOverlaps is
probably what I need to get all the instances. I've noticed that when
there are instances buried down in the hierarchy that it gives me a
hierarchical list of sorts.

I want to (unless there is a better way) somehow traverse through
these and look at each cell's dbID "name" attribute and then compare
it with a regular expression. It seems like I may need some sort of
clever "recursion" of sorts to do this, because I can't find an API
like getInstTransform that can deal with this hierarchy and give me
the name attribute of each cell in hierarchy.

Just wondering if I am on the right track, or if I am overlooking
something easier. The recursion and map functions are little tricky
for me, perhaps I will be more comfortable after working with and
experimenting with them.

Any thoughts are appreciated.
 
On May 20, 3:22 pm, vlsidesign <ford...@gmail.com> wrote:
<snip>
I want to (unless there is a better way) somehow traverse through
these and look at each cell's dbID "name" attribute and then compare
it with a regular expression. It seems like I may need some sort of
clever "recursion" of sorts to do this, because I can't find an API
like getInstTransform that can deal with this hierarchy and give me
the name attribute of each cell in hierarchy.

snip

I was looking through the sklanguser.pdf and on page 187, they have a
procedure for "Copying a list hierarchically". I think I will be able
to use this sort of recursion to do what I need it to. Cadence
installs quite a few manuals that have a lot of great information that
can be searched, I originally was not having luck searching for
"recursion", but stumbled upon this "Advanced List Operations"
section.
 
On May 20, 5:21 pm, vlsidesign <ford...@gmail.com> wrote:
On May 20, 3:22 pm, vlsidesign <ford...@gmail.com> wrote:
snip>> I want to (unless there is a better way) somehow traverse through
these and look at each cell's dbID "name" attribute and then compare
it with a regular expression. It seems like I may need some sort of
clever "recursion" of sorts to do this, because I can't find an API
like getInstTransform that can deal with this hierarchy and give me
the name attribute of each cell in hierarchy.

snip

I was looking through the sklanguser.pdf and on page 187, they have a
procedure for "Copying a list hierarchically". I think I will be able
to use this sort of recursion to do what I need it to. Cadence
installs quite a few manuals that have a lot of great information that
can be searched, I originally was not having luck searching for
"recursion", but stumbled upon this "Advanced List Operations"
section.
This recursion is tricky especially when I rarely program. And then
when I need to, it takes a bit of time to do it. I think this will do
it for me though.

procedure( gfCheck(g_list)
foreach(elem g_list

if( atom(elem)
printf("do your check here")
)

if( listp(elem)
gfCheck(elem)
)

);foreach
); proc

I saw a function in this newsgroup to take a hierarchical list, and
build a flat list, but I can't seem to quite get it to work yet.
Anyway, have any luck on that?
 
This recursion is tricky especially when I rarely program. And then
when I need to, it takes a bit of time to do it. I think this will do
it for me though.
Recursion really isn't that hard. You just have to make sure it'll stop at some point. And also
think on how the return values will be arranged back the stack to the toplevel function.

Back to your initial question, I think you can do it fairly easy with dbGetOverlaps (if you're
searching for instances, I think you do not need "true" overlaps since the instances bounding boxes
are rectangular). You just have to understand what dbGetTrueOverlaps is returning.

Assume you're doing this

instances = dbGetOverlaps( cv bBox nil 32 )

Then each element in the result will be either
(a) an instance (or mosaic) id, or
(b) a list. ; in this case the car of the list will the containing instance, and the cdr will be
either (a) or (b) in turn

The bottomline is, if you're not going to use the hierarchical path, then the element you are
searching for is always the leaf ; i.e. it is the only element which is not a list.

Therefore

foreach( elem instances
while(listp(elem) elem=cadr(elem))
when( elem~>cellName == "myCell"
printf("I found a myCell\n")
) ; when
) ; foreach

should do it.

Recursion is also a possibility ; and the code you pasted looks ok from a recursion perspective,
however it does check the complete hierarchical path for each element. I'd rather code it this way

procedure( SBcheckCellName( elem )
if( listp( elem )
SBcheckCellName(cadr(elem))
elem~>cellName == "myCell" && 1 || 0
) ;if
) ; procedure

Then the results of dbGetTrueOverlaps is processed like

printf(
"The shape is overlapping %d instances of myCell\n"
apply('plus mapcar('SBcheckCellName instances))
)



Hope this can inspire you for your code. Cheers,

Stéphane
 
On May 22, 2:54 am, "S. Badel" <stephane.ba...@REMOVETHISepfl.ch>
wrote:
<snip>
instances = dbGetOverlaps( cv bBox nil 32 )

Then each element in the result will be either
(a) an instance (or mosaic) id, or
(b) a list. ; in this case the car of the list will the containing instance, and the cdr will be
either (a) or (b) in turn

The bottomline is, if you're not going to use the hierarchical path, then the element you are
searching for is always the leaf ; i.e. it is the only element which is not a list.

Therefore

foreach( elem instances
while(listp(elem) elem=cadr(elem))
when( elem~>cellName == "myCell"
printf("I found a myCell\n")
) ; when
) ; foreach
Clever, this works good. I "think" I get it. If I might say some more
to make sure I am understanding.

So the dbGetOverlaps returns the following, basically a list of
elements that contain either...
a) an atom (instance id or mosiac) which is the object that is at the
top level
and/or
b)nested list

A example of a dbGetOverlaps return value would be:

(dbid1 (dbid1 dbid2) (dbid1(dbid2 dbid3)))

Where dbid1 might be "TOP" cell, and dbid2 might be "SUB1" cell, and
dbid3 might be "SUB2", where TOP is at top level hierarchy, SUB1 would
be one level down, and SUB2 would be 2 levels down.

<snip>
Hope this can inspire you for your code. Cheers,

Stéphane
Excellent, this is very helpful, and inspiring. I will also check out
your recursion example, but I wanted to make sure I was understanding
dbGetOverlaps return value first. Thanks for your time and insight.
 

Welcome to EDABoard.com

Sponsor

Back
Top