traversing hierarchical nested output from dbGetTrueOverlaps

Discussion in 'Cadence' started by vlsidesign, May 20, 2008.

  1. vlsidesign

    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.
     
    vlsidesign, May 20, 2008
    #1
  2. vlsidesign

    vlsidesign Guest

    <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.
     
    vlsidesign, May 21, 2008
    #2
  3. vlsidesign

    vlsidesign Guest

    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?
     
    vlsidesign, May 22, 2008
    #3
  4. vlsidesign

    S. Badel Guest

    This recursion is tricky especially when I rarely program. And then
    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
     
    S. Badel, May 22, 2008
    #4
  5. vlsidesign

    vlsidesign Guest

    On May 22, 2:54 am, "S. Badel" <>
    wrote:
    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.

    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.
     
    vlsidesign, May 22, 2008
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.