• 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. How to print all the hierarchies of a cell being used in...

Stats

  • Replies 14
  • Subscribers 148
  • Views 3817
  • Members are here 0

How to print all the hierarchies of a cell being used in a design using Skill Script?

GB20250109498
GB20250109498 27 days ago

Hi, I want to search a cell used in a top schematic and print the hierarchies of the cell being used, Could you please help? I want to print the hiearchy in terms of cell names not instance names, Thanks in advance.

  • Cancel
  • Sign in to reply
Parents
  • Aurel B
    Aurel B 27 days ago

    I think that there is a dedicated function for that in the recent Virtuoso versions.
    Otherwise the following should work in almost every versions : 

    (inScheme
    (let ( opened_views_table
           sch_view_names
           )
    
      (defglobalfun report_hierarchy ( cv "d" )
        "Return all the Libray, Cell, View tuples used in CV."
        (setq sch_view_names (parseString (schGetEnv "viewNameList") " ,"))
        ;; Reset table properly
        (setq opened_views_table (makeTable t nil))
        (let ( ( debug_mode (status debugMode        ) )
               ( tail_call  (status optimizeTailCall ) )
               )
          ;; Use tail-call optimization
          (sstatus debugMode        nil)
          (sstatus optimizeTailCall t  )
          (unwindProtect
            ;; Browse cellviews recursively, return the list of opened ones.
            (progn
              (browse (open (get_lcv cv)))
              opened_views_table[?]
              )
            ;; Properly reset tail-call optimization and close opened cellviews
            (progn
              (sstatus optimizeTailCall tail_call )
              (sstatus debugMode        debug_mode)
              (foreach key opened_views_table (dbClose opened_views_table[key]))
              (setq opened_views_table nil)
              ));progn ;unwindProtect
          ));let ;fun
    
      (defun get_lcv ( cv )
        "Return CV library, cell and view."
        (list cv->libName cv->cellName cv->viewName))
    
      (defun open ( lcv )
        "Return opened cellview described by LCV."
        (or opened_views_table[lcv]
            (setf opened_views_table[lcv] (apply 'dbOpenCellViewByType lcv))
            ))
    
      (defun browse ( cv )
        "Recursively browse CV and fill opened_views_table accordingly."
        ;; Browse cellview header
        (foreach header cv->instHeaders
          (let ( ( lcv (get_lcv header) )
                 )
            (unless opened_views_table[lcv]
              (let ( ( sub_cv (open lcv) )
                     )
                (case sub_cv->cellViewType
                  ;; Header describes a symbol, find first associated view.
                  ( "schematicSymbol"
                    (letseq ( ( lib   (car  lcv) )
                              ( cell  (cadr lcv) )
                              ( view  (car (exists view sch_view_names (ddGetObj lib cell view) )))
                              )
                      (when view (browse (open (list lib cell view))))
                      ))
                  ;; TODO - Support config views
    
                  ;; Any other view type, browse it directly
                  ( t (browse sub_cv) )
                ));case ;let
              ));unless ;let
          ));for each header ;fun
    
    
      )); Scheme closure
    
    
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 27 days ago in reply to Aurel B

    Or use Edit->Hierarchy->Print Tree rather than having to write SKILL code. Or if you want to do this from SKILL, you can use schPrintTree or schPrintTreeConfig as a SKILL equivalent (these were added in IC23.1 ISR12). These also handle traversing config views rather than just a view list.

    Alternatively, if you want to do it from a config using SKILL in an older version, you can use my code in:

    How to print a hierarchy tree of a config-based schematic, normal schematic, or layout view using GUI or SKILL code in batch mode non-graphically

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Aurel B
    Aurel B 27 days ago in reply to Andrew Beckett

    The ones I had in mind were : 
    schProduceUniqueCVHier & schProduceCVHierConfig but I haven't tried them yet.

    From https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/64551/how-to-use-schproduceuniquecvhier-in-scheme

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 26 days ago in reply to Andrew Beckett

    Hi Andrew,

    Thanks for the reply.   But My requirement was something like this. Could you please help here? Sorry if my description was confusing,

    I want to print the cellname_c hierarchy like "cellname_a:cellname_b: cellname_c".

    Hierarchy for cellname_e should be printed like "cellname_a:cellname_d:cellname_e"

    Thanks,

    Ganesh

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 26 days ago in reply to GB20250109498

    There is 1 predefined functoion "geGetInstHier( getCurrentWindow( ) )" which will print the hierarchy path in terms of instance name, I want to print in terms of cellname.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 26 days ago in reply to GB20250109498

    Ganesh,

    I threw this together. This needs the CCSschTree.il code mentioned by me earlier, but customises it to produce the output you want. It has the advantage that it can traverse layout hierarchies, schematics with a view list and config views.

    Unfortunately I'm struggling to get this to upload. I'll try again shortly.

    Andrew

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

    /* CCSgetAllHierPaths.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jan 21, 2026 
    Modified   
    By         
    
    Retrieve all the hierarchical paths (just showing cellNames).
    
    Uses CCSschTree underneath - article 11300048 on ASK - to do the
    hierarchy traversal. That handles both simple view switching and
    Function to count the number of leaf (or stopping) cells in a
    design. This uses CCSschTree - sourcelink solution 11300048
    to do the hierarchy traversal.
    
    The function can be used either with a config view, or with 
    a (say) schematic view and a provided view and stop list.
    
    For example:
    
    CCSgetAllHierPaths(
        ?libName "ether_sims" 
        ?cellName "adc_sample_hold_sim" 
        ?viewName "schematic" 
        ?viewList "spectre schematic cmos_sch veriloga" 
        ?stopList "spectre"
    )
    
    Or:
    
    CCSgetAllHierPaths(
        ?libName "ether_sims" 
        ?cellName "adc_sample_hold_sim" 
        ?viewName "config_spectre"
    )
    
    Or a layout:
    
    CCSgetAllHierPaths(
        ?libName "ether" 
        ?cellName "top" 
        ?viewName "layout"
        ?useViewSwitching nil
    )
    
    This function returns a list, so you could obviously print everything out using:
    
    foreach(hierPath 
        CCSgetAllHierPaths(
            ?libName "ether_sims" 
            ?cellName "adc_sample_hold_sim" 
            ?viewName "config_spectre"
        )
        printf("%s\n" hierPath)
    )
    
    ***************************************************
    
    SCCS Info: @(#) CCSgetAllHierPaths.il 01/21/26.12:15:36 1.2
    
    */
    /*******************************************************************************
    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *
    *   their own risk. The code may require modification to satisfy the           *
    *   requirements of any user. The code and any modifications to the code may   *
    *   not be compatible with current or future versions of Cadence products.     *
    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *
    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *
    *   OR FITNESS FOR A PARTICULAR USE.                                           *
    *******************************************************************************/
    
    ;------------------------------------------------------------------------
    ; Create a class to act as the collector for CCSschTree - this
    ; captures the info for each hierarchical path as the hierarchy
    ; is traversed
    ;------------------------------------------------------------------------
    (defclass CCSgetAllHierPathsClass ()
      (
       (currentHierPath @initform nil)
       (hierPathTable @initform (makeTable 'hierPathTable nil))
       )
      )
    
    ;------------------------------------------------------------------------
    ; Method for CCSschTreeOutputElement to record each
    ; hierarchical path and then push as the hierarchy is descended
    ;------------------------------------------------------------------------
    (defmethod CCSschTreeOutputElement
      ((obj CCSgetAllHierPathsClass) _indent _instInfo _lib _cell _view 
                                   _boundLib boundCell _boundView
                                   _displaySwitchedView isStoppingView)
      ;----------------------------------------------------------------------
      ; Record the hierarchical path in the table
      ; Do it this way to allow duplicates to be filtered (mainly
      ; for config traversal) - rather than printing out as we go along
      ;----------------------------------------------------------------------
      (let ((hierPath (reverse (getq obj currentHierPath))))
        (setarray (getq obj hierPathTable)
                  (if hierPath
                    (strcat (buildString hierPath ":") ":" boundCell)
                    boundCell)
                  t)
        )
      (unless isStoppingView
        (pushf boundCell (getq obj currentHierPath))
        )
      )
    
    ;------------------------------------------------------------------------
    ; Method for CCSschTreeOutputPop to return back through the hierarchy
    ;------------------------------------------------------------------------
    (defmethod CCSschTreeOutputPop ((obj CCSgetAllHierPathsClass) _indent)
      (popf (getq obj currentHierPath))
      )
    
    
    /*********************************************************************
    *                                                                    *
    *        (CCSgetAllHierPaths (@key libName cellName viewName         *
    *               (viewList "schematic cmos.sch symbol")               *
    *                        (stopList "symbol")                         *
    *                        (useViewSwitching t)                        *
    *                                 )                                  *
    *                                                                    *
    *  Main entry point. Give a lib/cell/view (which can be a config).   *
    *  If not a config, uses view switching with the view list and stop  *
    * list unless ?useViewSwitching is nil - which is for layout views.  *
    * Returns a list of colon-separated strings listing the hierarchical *
    *                        path of cell names.                         *
    *                                                                    *
    *********************************************************************/
    
    (defun CCSgetAllHierPaths (@key libName cellName viewName
                                  (viewList "schematic cmos.sch symbol")
                                  (stopList "symbol")
                                  (useViewSwitching t)
                                  )
      (let (obj config cv)
        ;--------------------------------------------------------------------
        ; Create the object used in CCSschTree in lieu of a port
        ;--------------------------------------------------------------------
        (setq obj (makeInstance 'CCSgetAllHierPathsClass))
        ;--------------------------------------------------------------------
        ; Is this a config view or not?
        ;--------------------------------------------------------------------
        (setq config
              (and
                (hdbIsConfig libName cellName viewName)
                (hdbOpen libName cellName viewName "r")))
        (if config
          (progn
            (CCShdbSchTree
              ?libName libName
              ?cellName cellName
              ?viewName viewName
              ?port obj)
            (hdbClose config)
            )
          (progn
            (setq cv (dbOpenCellViewByType libName cellName viewName))
            (when cv
              (CCSschTree
                ?cellView cv
                ?viewList viewList
                ?stopList stopList
                ?useViewSwitching useViewSwitching
                ?port obj)
              (dbClose cv)
              )
            )
          )
        ; return the sorted uniquified list of colon-separated
        ; cell names in a hierPath
        (sort (getq (getq obj hierPathTable) ?) 'alphalessp)
        ) 
      ) 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 25 days ago in reply to Andrew Beckett

    Thank you, Andrew. Slight smile  

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

    Thank you, Andrew. Slight smile  

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett 25 days ago in reply to GB20250109498

    I also just realised today that if you use Edit->Hierarchy->Design Hierarchy in Virtuoso Schematic Editor XL in IC25.1 and then export this to CSV (the save icon at the bottom), it's pretty much what you want in the first two columns in the CSV.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 24 days ago in reply to Andrew Beckett

    Thanks Andrew, As of now we are using IC23.1, we dont have Edit->Hierarchy->Design Hierarchy option.

    I have one query in CCSgetAllHierPaths().

    can we print only the "search cell" hierachy instead of printing all the hoerachy in our design? This will reduce our execution time as well as load.

    Thanks,
    Ganesh

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 24 days ago in reply to GB20250109498

    Hi Ganesh,

    GB20250109498 said:
    can we print only the "search cell" hierachy instead of printing all the hoerachy in our design? This will reduce our execution time as well as load.

    I don't understand what you mean by the "search cell" hierarchy. Can you please clarify?

    Andrew 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 24 days ago in reply to Andrew Beckett

    Hi Andrew,

    What I mean to say is, instead of printing every hierarchy in the design, I want to print only the hierarchy where a particular cell is being used.

    This will be helpful when we r working on a lower cell and want to know where and all hierarchies the cell is being used. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 24 days ago in reply to GB20250109498

    This wouldn't be any faster as it would still need to visit the entire hierarchy to see whether it is used anywhere.

    So you could just post-process the results to filter out those which have the given cell name in the result hierarchy path.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • GB20250109498
    GB20250109498 24 days ago in reply to Andrew Beckett

    Got it Andrew, Thanks.

    • 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