• 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. Looking for alternate of dbInstQuery

Stats

  • Replies 2
  • Subscribers 148
  • Views 228
  • Members are here 0

Looking for alternate of dbInstQuery

Duc Loc
Duc Loc 7 days ago

Hi all,

 

I'm working on copying instance from a lower hierarchy to the top level and found a solution here: SKILL: How to copy all cells with a specific name in the layout hierarchy to the top level

When I tried it, dbInstQuery was unable to finish because there are millions of instances in the hierarchy. I attempted to limit it using dbInstQuery(cv cv~>bBox startLevel stopLevel), but it wasn't efficient since the instance I need is deep in the hierarchy. Is there a function that can target a specific instance? I'm also open to other suggestions.

 

Thank you in advance,

Loc

  • Cancel
  • Sign in to reply
Parents
  • Andrew Beckett
    Andrew Beckett 7 days ago

    Loc,

    I just wrote a different approach which traverses the hierarchy (dealing with mosaics too) which should be much faster. I plan to write this up as an article for the ASK portal too.

    Regards,

    Andrew

    /* abCopyInstsToTop.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 09, 2026 
    Modified   
    By         
    
    Copy matching instances to the top cellView. Rather than using
    dbInstQuery to find all instances in the cellView, walks the hierarchy
    looking for matches instead - this will be more efficient in the 
    case where there are a lot of instances in the hierarchy.
    
    Example usage:
    
    newInsts=abCopyInstsToTop(?cellName "adc_comparator_actr" ?libName "ether")
    
    ***************************************************
    
    SCCS Info: @(#) abCopyInstsToTop.il 02/09/26.11:23:26 1.1
    
    */
    
    /*******************************************************************
    *                                                                  *
    *        (abCopyInstsToTop [?cellView (geGetEditCellView)]         *
    *                      [?destination destCV]                       *
    *                        [?libName libName]                        *
    *                       [?cellName cellName]                       *
    *                       [?viewName viewName]                       *
    *                      [?transform transform]                      *
    *                         [?copies copies]                         *
    *                                )                                 *
    *                                                                  *
    *   Look down through the hierarchy for any instance (or mosaic)   *
    * that matches the given libName/cellName/viewName. Note that the  *
    * match is only made on the arguments given (so if libName is not  *
    * specified, any libName will do). The destination defaults to the *
    *    top cellView started from. ?transform and ?copies are used    *
    *   internally for the recursion and would not be expected to be   *
    *               passed by a caller of the function.                *
    *     Returns a list of the instances that were created in the     *
    *                      destination cellView.                       *
    *                                                                  *
    *******************************************************************/
    
    (defun abCopyInstsToTop (@key (cellView (geGetEditCellView))
                                  destination
                                  libName cellName viewName
                                  (transform list(0:0 "R0" 1))
                                  copies)
      (unless destination
        (setq destination cellView))
      ;----------------------------------------------------------------------
      ; Deal with simple instances
      ;----------------------------------------------------------------------
      (foreach inst (getq cellView instances)
               (when (equal (getq inst objType) "inst")
                 (if (and
                       (or (null libName) (equal (getq inst libName) libName))
                       (or (null cellName) (equal (getq inst cellName) cellName))
                       (or (null viewName) (equal (getq inst viewName) viewName))
                       )
                   ; then
                   (setq copies
                         (cons (dbCopyFig inst destination transform)
                               copies))
                   ; else
                   (setq copies
                         (abCopyInstsToTop
                           ?cellView (getq inst master)
                           ?destination destination
                           ?libName libName
                           ?cellName cellName
                           ?viewName viewName
                           ?transform (dbConcatTransform 
                                        (getq inst transform) transform)
                           ?copies copies
                           )))))
      (foreach mosaic (getq cellView mosaics)
               ;-------------------------------------------------------------
               ; Don't bother checking for complex mosaics since these
               ; don't exist in OA
               ;-------------------------------------------------------------
               (let (master orient xy newTransform mosaicTransform)
                 (setq master 
                       (getq (car (getq mosaic instanceList)) master))
                 (if (and
                       (or (null libName) (equal (getq master libName) libName))
                       (or (null cellName) (equal (getq master cellName) cellName))
                       (or (null viewName) (equal (getq master viewName) viewName))
                       )
                   ; then
                   (setq copies
                         (cons (dbCopyFig mosaic destination transform)
                               copies))
                   ; else
                   (progn
                     (setq orient (car (getq mosaic tileArray)))
                     (setq mosaicTransform
                           (dbConcatTransform
                             (dbConcatTransform
                               (list 
                                 (mapcar 'minus (getq mosaic xy)) "R0" 1)
                               (list (list 0 0) orient 1))
                             (list (getq mosaic xy) "R0" 1))
                           )
                     ;-------------------------------------------------------
                     ; Iterate over the rows and columns, flattening each
                     ; sub-instance in the simple mosaic
                     ;-------------------------------------------------------
                     (for row 0 (sub1 (getq mosaic rows))
                          (for col 0 (sub1 (getq mosaic columns))
                               (setq xy
                                     (list
                                       (plus (xCoord (getq mosaic xy))
                                             (times col (getq mosaic uX)))
                                       (plus (yCoord (getq mosaic xy))
                                             (times row (getq mosaic uY)))
                                       ))
                               ;---------------------------------------------
                               ; Compute the transformation of the sub-instance
                               ;---------------------------------------------
                               (setq newTransform
                                     (dbConcatTransform
                                       (dbConcatTransform
                                         (list xy "R0" 1)
                                         mosaicTransform)
                                       transform))
                               ;---------------------------------------------
                               ; Call recursively
                               ;---------------------------------------------
                               (setq copies
                                     (abCopyInstsToTop
                                       ?cellView master
                                       ?destination destination
                                       ?libName libName
                                       ?cellName cellName
                                       ?viewName viewName
                                       ?transform newTransform
                                       ?copies copies
                                       ))
                               ))))))
      ;----------------------------------------------------------------------
      ; Return list of new instances that were copied
      ;----------------------------------------------------------------------
      copies
      )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett 7 days ago

    Loc,

    I just wrote a different approach which traverses the hierarchy (dealing with mosaics too) which should be much faster. I plan to write this up as an article for the ASK portal too.

    Regards,

    Andrew

    /* abCopyInstsToTop.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Feb 09, 2026 
    Modified   
    By         
    
    Copy matching instances to the top cellView. Rather than using
    dbInstQuery to find all instances in the cellView, walks the hierarchy
    looking for matches instead - this will be more efficient in the 
    case where there are a lot of instances in the hierarchy.
    
    Example usage:
    
    newInsts=abCopyInstsToTop(?cellName "adc_comparator_actr" ?libName "ether")
    
    ***************************************************
    
    SCCS Info: @(#) abCopyInstsToTop.il 02/09/26.11:23:26 1.1
    
    */
    
    /*******************************************************************
    *                                                                  *
    *        (abCopyInstsToTop [?cellView (geGetEditCellView)]         *
    *                      [?destination destCV]                       *
    *                        [?libName libName]                        *
    *                       [?cellName cellName]                       *
    *                       [?viewName viewName]                       *
    *                      [?transform transform]                      *
    *                         [?copies copies]                         *
    *                                )                                 *
    *                                                                  *
    *   Look down through the hierarchy for any instance (or mosaic)   *
    * that matches the given libName/cellName/viewName. Note that the  *
    * match is only made on the arguments given (so if libName is not  *
    * specified, any libName will do). The destination defaults to the *
    *    top cellView started from. ?transform and ?copies are used    *
    *   internally for the recursion and would not be expected to be   *
    *               passed by a caller of the function.                *
    *     Returns a list of the instances that were created in the     *
    *                      destination cellView.                       *
    *                                                                  *
    *******************************************************************/
    
    (defun abCopyInstsToTop (@key (cellView (geGetEditCellView))
                                  destination
                                  libName cellName viewName
                                  (transform list(0:0 "R0" 1))
                                  copies)
      (unless destination
        (setq destination cellView))
      ;----------------------------------------------------------------------
      ; Deal with simple instances
      ;----------------------------------------------------------------------
      (foreach inst (getq cellView instances)
               (when (equal (getq inst objType) "inst")
                 (if (and
                       (or (null libName) (equal (getq inst libName) libName))
                       (or (null cellName) (equal (getq inst cellName) cellName))
                       (or (null viewName) (equal (getq inst viewName) viewName))
                       )
                   ; then
                   (setq copies
                         (cons (dbCopyFig inst destination transform)
                               copies))
                   ; else
                   (setq copies
                         (abCopyInstsToTop
                           ?cellView (getq inst master)
                           ?destination destination
                           ?libName libName
                           ?cellName cellName
                           ?viewName viewName
                           ?transform (dbConcatTransform 
                                        (getq inst transform) transform)
                           ?copies copies
                           )))))
      (foreach mosaic (getq cellView mosaics)
               ;-------------------------------------------------------------
               ; Don't bother checking for complex mosaics since these
               ; don't exist in OA
               ;-------------------------------------------------------------
               (let (master orient xy newTransform mosaicTransform)
                 (setq master 
                       (getq (car (getq mosaic instanceList)) master))
                 (if (and
                       (or (null libName) (equal (getq master libName) libName))
                       (or (null cellName) (equal (getq master cellName) cellName))
                       (or (null viewName) (equal (getq master viewName) viewName))
                       )
                   ; then
                   (setq copies
                         (cons (dbCopyFig mosaic destination transform)
                               copies))
                   ; else
                   (progn
                     (setq orient (car (getq mosaic tileArray)))
                     (setq mosaicTransform
                           (dbConcatTransform
                             (dbConcatTransform
                               (list 
                                 (mapcar 'minus (getq mosaic xy)) "R0" 1)
                               (list (list 0 0) orient 1))
                             (list (getq mosaic xy) "R0" 1))
                           )
                     ;-------------------------------------------------------
                     ; Iterate over the rows and columns, flattening each
                     ; sub-instance in the simple mosaic
                     ;-------------------------------------------------------
                     (for row 0 (sub1 (getq mosaic rows))
                          (for col 0 (sub1 (getq mosaic columns))
                               (setq xy
                                     (list
                                       (plus (xCoord (getq mosaic xy))
                                             (times col (getq mosaic uX)))
                                       (plus (yCoord (getq mosaic xy))
                                             (times row (getq mosaic uY)))
                                       ))
                               ;---------------------------------------------
                               ; Compute the transformation of the sub-instance
                               ;---------------------------------------------
                               (setq newTransform
                                     (dbConcatTransform
                                       (dbConcatTransform
                                         (list xy "R0" 1)
                                         mosaicTransform)
                                       transform))
                               ;---------------------------------------------
                               ; Call recursively
                               ;---------------------------------------------
                               (setq copies
                                     (abCopyInstsToTop
                                       ?cellView master
                                       ?destination destination
                                       ?libName libName
                                       ?cellName cellName
                                       ?viewName viewName
                                       ?transform newTransform
                                       ?copies copies
                                       ))
                               ))))))
      ;----------------------------------------------------------------------
      ; Return list of new instances that were copied
      ;----------------------------------------------------------------------
      copies
      )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Duc Loc
    Duc Loc 4 days ago in reply to Andrew Beckett

    Thank you Andrew. I'll try this. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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.

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

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