• 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. Does it have a certain sequence when traversing instances...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 144
  • Views 1581
  • 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

Does it have a certain sequence when traversing instances in a cellview using "foreach"?

richardyuan
richardyuan over 3 years ago

I need to write the cell name of each instance of a rather large array(~400x400) to a text file by its location. For example, an array of 2x3 intances with the name "AA"~"FF", the content of the output file should be like this:

AA BB CC

DD EE FF

Each name is placed by the location of each instance. I have  the rough idea of traversing instances in the cellview directly, but I'm not sure about the sequence. Dose it traverse certainly from the left to the right first and then from the top to the bottom? If it is, then the script is simple(suppose the array size is row*col, the origin of top left instance is (x0 y0), the pitch of horizontal and vertical is x_pitch and y_pitch):

foreach(inst cv~>instances

    if(car(instace~>xy) == x0 then printf("\n"))

    printf("%s " inst~>name)

)

But if the traversing sequence is random. It will be time consuming for the script:

for(i 1 row

    for(j 1 col

        foreach(inst cv~>instances

            if(col == 1 then printf("\n"))

            if( ((car(inst~>xy) - x0)/x_pitch + 1) == row && ((y0 - cadr(inst~>xy)/y_pitch + 1) == col then

                printf("%s" inst~>name)

            )

        )

    )

)

In this case, it seems that we need a method to get the instance by the coordinate of its origin. But I didn't find such a method. Any better idea?

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    No, the database is not ordered by coordinate. There is some ordering based on the order of creation of the objects, but this is not something that should be relied upon as there's no guarantee that any database operation will preserve the order. It's certainly not documented that there's any reliable order that you can safely rely on, so even if you empirically discover some order you should not use it.

    There's a sort-of discussion about something similar in this post, but I think you can just use:

    procedure(CCFcompareXY(instA instB)
      let(((xyA instA~>xy) (xyB instB~>xy))
        yCoord(xyA) < yCoord(xyB) ||
        yCoord(xyA) == yCoord(xyB) && xCoord(xyA) < xCoord(xyB)
      )
    )

    instances=sort(cv~>instances 'CCFcompareXY)

    This gives the instances bottom to top, and then left to right in each row. If you wanted it top to bottom, then you'd change the less than in:

    yCoord(xyA) < yCoord(xyB)

    to:

    yCoord(xyA) > yCoord(xyB)

    Hope that helps. Then you can just do a foreach(inst instances ...)

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • richardyuan
    richardyuan over 3 years ago in reply to Andrew Beckett

    Thank you, Andrew. It works fine for the mentioned array. (Though I stiil have a little concern about the efficiency of "sort", for the number of instances would be over 30000)

    But I found actually the instances are not placed as an array. I need to check the empty area if any instance exists. I've opened a new thread for that.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to richardyuan

    I'm not sure why you would be concerned about the sort. I checked with an example where instances were randomly placed, using the sorting method it took 0.5s with 30,000 instances, and 1.8s with 100,000 instances. The sort is a quicksort and is quite efficient. Given that you are asking to order the instances by x and y, there's not much other choice! Well, there might be given the answer I'm about to give with your other post, but I'm sure that would be a slower method in general.

    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