• 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 Fetch all the instances in from a Top cell Hierarchy...

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 7497
  • 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

How to Fetch all the instances in from a Top cell Hierarchy?

Sandeep Kailasa
Sandeep Kailasa over 2 years ago

I am able to fetch the cell details from the Top cell. But When I am recursively calling the function to print parameters of Cells, then I am getting instances of instance  as nil. If i am calling the celldetails function below, I am unable to get the instances details as it is not considered as an top cell. Can someone help me with this. 

Thanks ,

Sandeep

Skill Code:


cellinstances=list()

procedure(celldetails(cv)
printf("\n\nHello Sandeep Kailasa\n")
printf("Top CELL name is :%L\n" cv~>cellName)
printf("Cell View Type is %L\n" cv~>cellViewType)
printf("\nInstances of Cell %L are : %L\n" cv~>cellName cv~>instances~>cellName)
foreach(inst cv~>instances
printf("Purpose of Instance %L is %L\n" inst~>cellName inst~>purpose)


case(inst~>cellName
("pmos4"
printf("Instance name is : %L\n" inst~>cellName)
printf("Instance %L-%L connected to Pins: %L\n" inst inst~>cellName inst~>conns~>net~>name)
printf("Instance %L-%L connected to Terminals: %L\n" inst inst~>cellName inst~>conns~>name)
)
("nmos4"
printf("Instance name is : %L\n" inst~>cellName)
printf("Instance %L-%L connected to Pins: %L\n" inst inst~>cellName inst~>conns~>net~>name)
printf("Instance %L-%L connected to Terminals: %L\n" inst inst~>cellName inst~>conns~>name)
)
(;rexMatchp("pin$")
"iopin"
printf("Instance is a iopin %L\n" inst)
)
(
"opin"
printf("Instance is a opin %L\n" inst)
)
(
"ipin"
printf("Instance is a ipin %L\n" inst)
)

(t

when(!memq(inst~>cellName cellinstances)
cellinstances=cons(inst~>cellName cellinstances)
printf("\n\nInstance name is : %L\n" inst~>cellName)
printf("Instance %L-%L connected to Pins: %L\n" inst inst~>cellName inst~>conns~>net~>name)
printf("Instance %L-%L connected to Terminals: %L\n" inst inst~>cellName inst~>conns~>name)

printf( "\n............Calling the function .........\n")
celldetails(inst)
printf("\n...........Returning from Function..............\n\n\n")
);when
)
);case
);foreach

);procedure

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    I reformatted the code (it is very hard to follow without indentation) and fixed various issues. The main things I fixed where:

    1. celldetails() was being called recursively with the instance id rather than the cellView id of the switched view (even if you'd have passed inst~>master it would have then been traversing the symbol; I am assuming here you're traversing a schematic hierarchy)
    2. You've used memq to compare a string against a list of strings - you should never use memq with strings (the documentation says this too, I think)
    3. I changed the global variable cellinstances to instead be an optional argument to the function and the return value of the function - this avoids the need for any global variables

    Here's the updated version:

    ;; remove need for cellinstances to be global by having optional argument
    ;; and returning the cellinstances list from the function
    procedure(celldetails(cv @optional cellinstances)
     let((master)
      printf("\n\nHello Sandeep Kailasa\n")
      printf("Top CELL name is :%L\n" cv~>cellName)
      printf("Cell View Type is %L\n" cv~>cellViewType)
      printf("\nInstances of Cell %L are : %L\n"
             cv~>cellName
             cv~>instances~>cellName
            )
      foreach(inst cv~>instances
        printf("Purpose of Instance %L is %L\n" inst~>cellName inst~>purpose)
        
        
        case( (inst~>cellName)
          ("pmos4"
           printf("Instance name is : %L\n" inst~>cellName)
           printf("Instance %L-%L connected to Pins: %L\n"
                  inst
                  inst~>cellName
                  inst~>conns~>net~>name
                 )
           printf("Instance %L-%L connected to Terminals: %L\n"
                  inst
                  inst~>cellName
                  inst~>conns~>name
                 )
          )
          ("nmos4"
           printf("Instance name is : %L\n" inst~>cellName)
           printf("Instance %L-%L connected to Pins: %L\n"
                  inst
                  inst~>cellName
                  inst~>conns~>net~>name
                 )
           printf("Instance %L-%L connected to Terminals: %L\n"
                  inst
                  inst~>cellName
                  inst~>conns~>name
                 )
          )
          (;rexMatchp("pin$")
           "iopin"
           printf("Instance is a iopin %L\n" inst)
          )
          ("opin"
           printf("Instance is a opin %L\n" inst)
          )
          ("ipin"
           printf("Instance is a ipin %L\n" inst)
          )
          
          (t
           
           ;; do NOT use memq with strings. Change to member
           when(!member(inst~>cellName cellinstances)
             cellinstances = cons(inst~>cellName cellinstances)
             printf("\n\nInstance name is : %L\n" inst~>cellName)
             printf("Instance %L-%L connected to Pins: %L\n"
                    inst
                    inst~>cellName
                    inst~>conns~>net~>name
                   )
             printf("Instance %L-%L connected to Terminals: %L\n"
                    inst
                    inst~>cellName
                    inst~>conns~>name
                   )
             
             ;; you need to pass the master not the instance id. Also, if it's
             ;; a schematic, you'll need to view-switch into the schematic.
             ;; only call the function recursively if there is a switch view
             master = dbGetAnyInstSwitchMaster(inst "schematic cmos.sch")
             when(master
               printf("\n............Calling the function .........\n")
               cellinstances=celldetails(master cellinstances)
               printf("\n...........Returning from Function..............\n\n\n")
               )
            ) ;when
          )
         ) ;case
       ) ;foreach
      ;; return the updated list of cells already visited
      cellinstances
      ); let
      
     ) ;procedure

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Sandeep Kailasa
    Sandeep Kailasa over 2 years ago in reply to Andrew Beckett

    Thanks for your reply Andrew.. 

    I am using dbOpenCellViewByType(inst~>libName inst~>cellName "schematic"), then its working fine for me. Can I know how to change any of the parameters of the cells/ instances in the above code?

    Thanks,

    Sandeep

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to Sandeep Kailasa

    OK, that seems a more complicated solution than just using dbGetAnyInstSwitchMaster (if you want to restrict it just to schematic views, you could pass "schematic" rather than "schematic cmos.sch" - the view list was just an example), but it should work.

    What do you mean by "how to change any of the parameters of the cells/instances"? What are you trying to do? Your question is rather vague - if you want to change parameters on an instance, you'd set the properties on the instance when you are accessing it, but your intentions are rather unclear... rather than me trying to guess what you might actually mean, it would be better if you explained it clearly yourself.

    Thanks,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Sandeep Kailasa
    Sandeep Kailasa over 2 years ago in reply to Andrew Beckett

    Thanks Andrew,

    The thing is I am able to get and access all the cells/instances in the Hierarchy . Now I have to change any of the parameters of the cell like changing  its CellName or net name or pin or Instance Name or any other parameters of the cell. I have to do the above mentioned changes in my Skill Script. Is there any Function to do that. Will the Setq function work for this.

    Regards,

    Sandeep

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to Sandeep Kailasa

    Sandeep,

    setq() is just the functional equivalent of "=" (i.e. assignment). I doubt this is what you want. So:

    setq(a 5)

    is the same as

    a=5

    If you want to set a property on an instance, use either:

    inst~>w="2u" ; assuming the property was called w
    dbReplaceProp(inst "w" "string" "2u") ; you have to get the type right if you use this approach

    (that said, the type of the value has to be correct anyway).

    To change the cellName, you have to replace the master:

    newMaster=dbOpenCellViewByType("theLib" "theCell" "symbol")
    inst~>master=newMaster

    With most PDKs you would normally find that changing parameters would require CDF callbacks to be called to ensure everything is consistent (unfortunately; I've written much about this before - see The dangers of CDF callbacks) - using something like this would help too: How to call CDF callbacks procedurally from SKILL to update CDF parameters?

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to Sandeep Kailasa

    Sandeep,

    setq() is just the functional equivalent of "=" (i.e. assignment). I doubt this is what you want. So:

    setq(a 5)

    is the same as

    a=5

    If you want to set a property on an instance, use either:

    inst~>w="2u" ; assuming the property was called w
    dbReplaceProp(inst "w" "string" "2u") ; you have to get the type right if you use this approach

    (that said, the type of the value has to be correct anyway).

    To change the cellName, you have to replace the master:

    newMaster=dbOpenCellViewByType("theLib" "theCell" "symbol")
    inst~>master=newMaster

    With most PDKs you would normally find that changing parameters would require CDF callbacks to be called to ensure everything is consistent (unfortunately; I've written much about this before - see The dangers of CDF callbacks) - using something like this would help too: How to call CDF callbacks procedurally from SKILL to update CDF parameters?

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Children
No Data

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