• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Finding Layer Box In a Instance

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 145
  • Views 16884
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Finding Layer Box In a Instance

harishgurram
harishgurram over 11 years ago

 Hi,

I have placed a instance in my cell view(layout). 

Is there any functions to get the bBox of a particular layer purpose pair, with out flattening the instance.

  • Cancel
  • theopaone
    theopaone over 11 years ago

    Assuming you have the instance ID captured in the variable instId:

    ;Operate on the master of the instance.

     master = instId~>master

    ;Find the lpp in the master

    lppId = car( setof( lp master~>lpps lp~>layerName == myLayerName && lp~>purpose == myPurpose ) )
    lppShapes = lppId~>shapes

    ; Loop through each shape to find the total bounding box

    bBox = car(lppShapes)~>bBox
    llx = xCoord( car( bBox ) )
    lly = yCoord( car( bBox ) )
    urx = xCoord( cadr( bBox ) )
    ury = yCoord( cadr( bBox ) )

    foreach( shape cdr(lppShapes)
        llxy = car(shape~>bBox)
        urxy = cadr(shape~>bBox)
         when( xCoord(llxy) < llx llx = xCoord(llxy) )
         when( yCoord(llxy) < lly lly = yCoord(llxy) )

    ;; Do the same for urxy

      ) ; foreach
    ;; Now transform the points back to the top level cell
    newBBox = dbTransformUserBBox( list( list( llx lly) list(urx ury) ) getInstTransform( instId ))

    Note: This code was written in this editor and not tested. Use at your own risk.

     Ted

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    Hadn't seen Ted's response before I wrote this (was based on something I had already for a different purpose, so didn't have to start from scratch). Mine handles hierarchy within the instance (most of the work is to handle mosaics).

    Regards,

    Andrew

    /* abGetLayerBBox.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 06, 2014 
    Modified   
    By         
    
    Find the bounding box of a layer purpose pair within a
    cellView. For example:
    
    bBox=abGetLayerBBox(geGetEditCellView() list("Metal1" "drawing"))
    
    or for an instance:
    
    bBox=abGetLayerBBox(instId~>master list("Metal3" "drawing") instId~>transform)
    
    ***************************************************
    
    SCCS Info: @(#) abGetLayerBBox.il 08/06/14.06:28:58 1.1
    
    */
    
    
    /***************************************************************
    *                                                              *
    *             (abGetLayerBBoxExtend bBox newBBox)              *
    *                                                              *
    *   Utility function to find the overall bBox of two bBoxes    *
    *                                                              *
    ***************************************************************/
    
    (defun abGetLayerBBoxExtend (bBox newBBox)
      (cond
        ((null bBox) newBBox)
        ((null newBBox) bBox)
        (t
          (list
            (mapcar 'min (lowerLeft bBox) (lowerLeft newBBox))
            (mapcar 'max (upperRight bBox) (upperRight newBBox)))
          )
        )
      )
    
    /*****************************************************************
    *                                                                *
    *              (abGetLayerBBox cv lpp [transform])               *
    *                                                                *
    * Get the bounding box of a layer purpose pair within a cellView *
    *   with an optional transform (needed for the recursion, but    *
    *                   also useful for instances)                   *
    *                                                                *
    *****************************************************************/
    
    (defun abGetLayerBBox (cv lpp @optional 
                                    (transform list(0:0 "R0" 1))
                                    )
      (let (bBox)
        (foreach shape 
                 (dbGetq
                   (car (exists LPP (dbGetq cv lpps) 
                                (and
                                  (equal (dbGetq LPP layerName) (car lpp))
                                  (equal (dbGetq LPP purpose) (cadr lpp)))))
                   shapes)
                 (setq bBox (abGetLayerBBoxExtend 
                              bBox
                              (dbTransformBBox (dbGetq shape bBox) transform)))
                 )
        (foreach inst (dbGetq cv instances)
                 (when (equal (dbGetq inst objType) "inst")
                   (setq bBox (abGetLayerBBoxExtend 
                                bBox
                                (abGetLayerBBox 
                                  (dbGetq inst master) 
                                  lpp
                                  (dbConcatTransform
                                    (dbGetq inst transform)
                                    transform)
                                  )
                                ))
                   )
                 )
        (foreach via (dbGetq cv vias)
                 (setq bBox (abGetLayerBBoxExtend 
                              bBox
                              (abGetLayerBBox 
                                (dbGetq (dbGetq via viaHeader) master) 
                                lpp
                                (dbConcatTransform
                                  (list (dbGetq via origin) (dbGetq via orient) 1)
                                  transform)
                                )
                              ))
                 )
        (foreach mosaic (dbGetq cv mosaics)
                 (if (equal (dbGetq mosaic mosaicType) "simple")
                   (let (master orient xy isOA newTransform mosaicTransform)
                     ;-------------------------------------------------------
                     ; OpenAccess stores mosaics differently - in CDB,
                     ; the individual instances are rotated - in OA, the
                     ; whole mosaic is rotated. So need to detect database
                     ; type used, and adjust transformations accordingly
                     ;-------------------------------------------------------
                     (setq isOA (and (isCallable 'dbGetDatabaseType)
                                     (equal (dbGetDatabaseType) "OpenAccess")))
                     (setq master 
                           (dbGetq (car (dbGetq mosaic instanceList)) master))
                     (setq orient (car (dbGetq mosaic tileArray)))
                     ;-------------------------------------------------------
                     ; If OA, the transformation of the whole mosaic
                     ; is calculated - by shifting to the origin, rotating,
                     ; and then shifting back
                     ;-------------------------------------------------------
                     (when isOA
                       (setq mosaicTransform
                             (dbConcatTransform
                               (dbConcatTransform
                                 (list 
                                   (mapcar 'minus (dbGetq mosaic xy)) "R0" 1)
                                 (list (list 0 0) orient 1))
                               (list (dbGetq mosaic xy) "R0" 1))
                             ))
                     ;-------------------------------------------------------
                     ; Iterate over the rows and columns, flattening each
                     ; sub-instance in the simple mosaic
                     ;-------------------------------------------------------
                     (for row 0 (sub1 (dbGetq mosaic rows))
                          (for col 0 (sub1 (dbGetq mosaic columns))
                               (setq xy
                                     (list
                                       (plus (xCoord (dbGetq mosaic xy))
                                             (times col (dbGetq mosaic uX)))
                                       (plus (yCoord (dbGetq mosaic xy))
                                             (times row (dbGetq mosaic uY)))
                                       ))
                               ;---------------------------------------------
                               ; Compute the transformation of the sub-instance
                               ; Done differently for OA and CDB
                               ;---------------------------------------------
                               (setq newTransform
                                     (if isOA
                                       (dbConcatTransform
                                         (dbConcatTransform
                                           (list xy "R0" 1)
                                           mosaicTransform)
                                         transform)
                                       (dbConcatTransform
                                         (list xy orient 1)
                                         transform)
                                       ))
                               ;---------------------------------------------
                               ; Call abGetLayerBBox recursively
                               ;---------------------------------------------
                               (setq bBox 
                                     (abGetLayerBBoxExtend 
                                       bBox
                                       (abGetLayerBBox master lpp newTransform)
                                       ))
                               ) ; for col
                          ) ; for row
                     ) ; let
                   (warn "Complex mosaic %s in %s/%s/%s ignored\n"
                         (dbGetq mosaic name)
                         (dbGetq cv libName)
                         (dbGetq cv cellName)
                         (dbGetq cv viewName)
                         )
                   )
                 )
        bBox
        )
      ) 
    
     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • SteffenLGF
    SteffenLGF over 8 years ago

    Andrew,

    based on what I read in the documentation the required functionality should already be implemented by the 'rodGetBBox' function.

    When I try it this function appears to be unable to deal with mosaics, though, and only the first original shape of a mosaic is found.

    • Is your code above a work-around to deal with the fact that rodGetBBox does not handle mosaics?
    • am I using the function incorrectly?
    • or do I misunderstand the description of rodGetBBox?


    Thanks in advance
    Steffen

    to deal with the fact that load("~/skill/14lpp/apmpm/v1.il")load("~/skill/14lpp/apmom/v1.il")load("/home/sloeffle/sandbox/cdt/pcell/gf7b/skill/Moonraker0p9/slCdtExt.il")load("~/skill/14lpp/apmom/v1.il")startFindercv=geGetWindowCellView()instHier = dbInstQuery(cv cv->bBox)insthierinstHiercar(instHier)nth(0 instHier)nth(1 instHier)nth(2 instHier)nth(3 instHier)nth(4 instHier)nth(5 instHier)nth(6 instHier)length(instHier)instHier = dbInstQuery(cv cv->bBox 0 1)instHier = dbInstQuery(cv cv->bBox 0 4)instHierinstHier = dbInstQuery(cv cv->bBox 0 2)instHiercar(instHoer)->cellNamecar(instHier)->cellNamecar(nth(1 instHier))->cellNameinstHier = dbInstQuery(cv cv->bBox 0 3)instHier = dbInstQuery(cv cv->bBox 0 4)instHier = dbInstQuery(cv cv->bBox 0 4)instHier = dbInstQuery(cv cv->bBox )length(instHier)wanted=setof(instPath dbInstQuery(cv cv~>bBox ) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")wanted=setof(instPath dbInstQuery(cv cv~>bBox 0 3) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")wanted=setof(instPath dbInstQuery(cv cv~>bBox 0 2) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")wanted=setof(instPath dbInstQuery(cv cv~>bBox 0 3) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")cv->cellNamep1=car(wanted)foreach(p p1 fprintf(stdout "%s\n" p->cellName))foreach(p p1 fprintf(stdout "%A\n" p->bBox))load("~/skill/14lpp/apmom/v1.il")load("~/skill/14lpp/apmom/v1.il")load("~/skill/14lpp/apmom/v1.il")dbIddbId->cellViewcvTopCellload("~/skill/14lpp/apmom/v1.il")load("~/skill/14lpp/apmom/v1.il")padsforeach(p pads p = car(last(p)))ppadsa='(1 2 3)foreach(i a printf("%S\A\n" i))foreach(i a printf("%A\n" i))foreach(i a i++ printf("%A\n" i))foreach(i a i++ printf("%A\n" i))foreach(i a i++ printf("%A\n" i))aforeach(i a i=i++ printf("%A\n" i))load("~/skill/14lpp/apmom/v1.il")padsetspadsforeach(p padsets cons(car(last(p)) pads))padsforeach(p padsets printf("%A\n" (car(last(p)))))lastpadslcar(padsets)car(padsets)last(car(padsets))car(last(car(padsets)))padsetsp1=car(padsets)cons(car(last(p)) pads)cons(car(last(p1)) pads)padsa=list(1 2)cons(3 a)aload("~/skill/14lpp/apmom/v1.il")load("~/skill/14lpp/apmom/v1.il")padsbBoxcellcell        dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )cell = "apmom3v3_L1_1_W1_1_C7C5_dev"cell        dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )cell = "apmom3v3_L1_1_W1_1_C7C5_dev"cell        dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )       dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )cvTopCell = geWindowCellView()cvTopCell = geGetWindowCellView()       dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )       dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )                                            if(dbIsId(dbId)                 then slSetListParam(cells list(cell "dbId" ) dbId )                else fprintf(stdout "dbID for %s fails\n" cell)                        break()        )dbId->bBox        padsets = setof(instPath dbInstQuery(cvTopCell dbId~>bBox 0 3) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")        dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )        if(dbIsId(dbId)                 then slSetListParam(cells list(cell "dbId" ) dbId )                else fprintf(stdout "dbID for %s fails\n" cell)                        break()        )            fprintf(stdout "cell = %20s," cell)origin = 0:0        dbId =  dbCreateInstByMasterName(                                    cvTopCell                                    lib                                    cell                                    "layout"                                    strcat("i" sprintf(nil "%02d" i++) cell)                                    origin; cdtGetListParam(cells list(cell "origin"))                                    "R0"                                    )        if(dbIsId(dbId)                 then slSetListParam(cells list(cell "dbId" ) dbId )                else fprintf(stdout "dbID for %s fails\n" cell)                        break()        )            fprintf(stdout "cell = %20s," cell)        padsets = setof(instPath dbInstQuery(cvTopCell dbId~>bBox 0 3) if(listp(instPath) car(last(instPath)) instPath)~>cellName=="padset_GSG_apmom")        pads=nil        foreach(p padsets pads = cons(car(last(p)) pads))        fprintf(stdout " number of padsets found: %d," length(pads))dbId->bBoxforeach(p pads printf("%A\n" p->bBox))dbId->xyforeach(p pads printf("%A\n" p->xy))        bBox = list(                    list(                            apply( 'min mapcar(lambda( ( xy) xCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                            apply( 'min mapcar(lambda( ( xy) yCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                        )                    list(                            apply( 'max mapcar(lambda( ( xy) xCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                            apply( 'max mapcar(lambda( ( xy) yCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                        )                    )mapcar(lambda( ( xy) xCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads)mapcar(lambda( ( xy) yCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads)mapcar(lambda( ( xy) rodGetBBox(?figId xy ?layer "C4")) pads)mapcar(lambda( ( xy) xy->bBox pads))mapcar(lambda( ( xy) xy->bBox ) pads)mapcar(lambda( ( xy) rodGetBBox(?figId xy ?layer "C4")) pads)car(pads)->cellnamecar(pads)->cellName        bBox = list(                    list(                            apply( 'min mapcar(lambda( ( xy) xCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                            apply( 'min mapcar(lambda( ( xy) yCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                        )                    list(                            apply( 'max mapcar(lambda( ( xy) xCoord(lowerLeft(rodGetBBox(?figIp=car(pads)d xy ?layer "C4")))) pads))                            apply( 'max mapcar(lambda( ( xy) yCoord(lowerLeft(rodGetBBox(?figId xy ?layer "C4")))) pads))                        )                    )p=car(pads)p->bBoxp0=car(pads)p1=car(last(pads))p1->bBox

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    rodGetBBox was added in IC616 ISR1 (I think), and I suspect I was unaware of that when I wrote the above (otherwise I might have mentioned it). It also seems that rodGetBBox doesn't support mosaics (this doesn't appear to be mentioned in the documentation, but I found CCR 1153760 asking for this to be addressed - as far as I can see, that's not happened yet).

    So you might need to either use code similar to mine above, or push for rodGetBBox to be enhanced to support mosaics (even if you push, that's not going to happen overnight - but a duplicate CCR request would increase the likelihood of it being done sooner rather than later). I suggest you contact customer support referencing CCR 1153760 so a duplicate can be filed.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information