• 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 the lowerleft(x1,y1) and upperright(x2,y2) of a...

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 143
  • Views 6679
  • 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 the lowerleft(x1,y1) and upperright(x2,y2) of a bounding box

JMCaJHU
JMCaJHU over 16 years ago

 Hi,

I'm new to Cadence and skill.  I've been studying sample code and ultimately need to make procedures that will create instances of different inv, different or gates and other logic gates in a row.  To do this, I plan to find the width of the gate, and stack them side by side.  Is there any code that will let me find a bounding box's x1 and x2?  I can then subtract to find its width and run a for loop that places an instance every n(x2-x1). 

 

I realize there is already a similar question.  I tried that code but it didnt seem to work.

JC 

  • Cancel
  • dmay
    dmay over 16 years ago

    There are several ways to do this. The Skill shortcuts are easier to read and understand, but the pure cars and cdrs are more efficient. 

    bBox = list(0:10 20:30)
    ;In Skill's purest and simplest form
    ll = car(bBox)
    ur = cadr(bBox) ;same as car(cdr(bBox))
    x1 = car(ll)
    x2 = car(ur)
    y1 = cadr(ll)
    y2 = cadr(ur)
    println(list(x1 x2 y1 y2))

    ;In Skill's purest and shortest form
    x1 = caar(bBox) ;same as car(car(bBox))
    x2 = caadr(bBox) ;same as car(car(cdr(bBox)))
    y1 = cadar(bBox) ;same as car(cdr(car(bBox)))
    y2 = cadadr(bBox) ;same as car(cdr(car(cdr(bBox))))
    println(list(x1 x2 y1 y2))

    ;Using some of Skill's shortcuts
    x1 = leftEdge(bBox)
    x2 = rightEdge(bBox)
    y1 = bottomEdge(bBox)
    y2 = topEdge(bBox)
    println(list(x1 x2 y1 y2))

    ;Using some of Skill's shortcuts
    ll = lowerLeft(bBox)
    ur = upperRight(bBox)
    x1 = xCoord(ll)
    x2 = xCoord(ur)
    y1 = yCoord(ll)
    y2 = yCoord(ur)
    println(list(x1 x2 y1 y2))

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 16 years ago

    Hi JC,

    To add to what Derek has said, a neat way to get just the width of a bounding box, assuming that bBox contains the bounding box of hte object is:

     abs(apply('difference mapcar('car bBox)))

     This obtains the car of each of the bBox elements, then it subtracts one from the other and then it takes the absolute value, to make the width a positive number.

    I hope that this helps!

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 16 years ago

     Oops, hit the "Post" button prematurely there.

    Anyway, to continue my thread, the above method may seem cumbersome for just getting the width, but it can be extended to other things. Let's say you wanted to find the left most point of all of the bounding boxes stored in bBoxes, you could iterate over them manually and store the smaller X value of either the lowerleft point or the previous left-most point each iteration, or you could do it in one statement:

      apply('min mapcar('caar bBoxes))
    

    This iterates over each bBox in bBoxes and takes the caar (the car of the car) of each one to find the X ordinate of the lowerleft coordinate and then this list is passed to the min function which returns the lowest X value. Cool huh?

    Also, by the way, don't forget to use lowerLeft() and upperRight() for clarity in your code, but beware that these are simply aliases for the car and cadr functions respectively, they do not check to see if the input is a valid bounding box, they will just expect a list and operate on it, e.g. the following would not cause an error or warning:

      lowerLeft( list( 1 2 3 4 ) ) 

    However, there is a handy function, isBBox() that can be used to validate that you have a correct bounding box.

    Happy coding!

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • JMCaJHU
    JMCaJHU over 16 years ago

     Thanks for the multiple examples guys, it really helped understand lists.  I guess my biggest problem is selecting the bounding box and parsing it as a list.   I'm working on basic cells such as inv and or cells with only one bounding box.  I started playing around with dbComputeBBox but its still not working. The code is:

    db_inv_master=dbOpenCellViewByType("tsmcinv" "inv" "layout" "" "r")

    bBox=dbComputeBBox(db_inv_master)

    ll = lowerLeft(bBox)
    ur = upperRight(bBox)
    x1 = xCoord(ll)
    x2 = xCoord(ur)
    y1 = yCoord(ll)
    y2 = yCoord(ur)
    println(x1)

    This code resulted in an error of mismatched types, so i tried:

    bBox=list(list(dbComputeBBox(db_inv_master) ))

    but that just gives an output of t/nil when it should output the x1 coord

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 16 years ago

    The dbComputeBBox routine returns a t or a nil and does not return a bBox. I'm not familiar with that routine and its purpose, but that is not what you want. The mismatched types is due to the fact that you are using commands for lists and your bBox is a boolean.

    Simply change the dbComputeBBox line in your code to be this:

    bBox = db_inv_master~>bBox

    The rest of the code should work fine.

     -Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 16 years ago

     Hi JC,

    Oops - the dbComputeBBox() forces the bounding box to be recalculated but it does not return the bounding box of the cellview.  The bounding box of a database object can be found easily by querying the bBox attribute of it. Using your example:

    bBox = db_inv_master~>bBox

    Then the code should work. As a suggestion I would recommend "defensive" programming, i.e. check what you are expecting and only continue if it is correct. Example of this:

    when( bBox = db_inv_master~>bBox ;; when this attribute is non-nil
     ll = lowerLeft(bBox)
     ...
    ); when

    Or you could issue a warning, depending on what you want to do:

    bBox = db_inv_master~>bBox
    if(isBBox(bBox) then
     ;; do the code
    else
     warn("Did not obtain a valid bBox - %L" bBox)
    ); if

    Notice the use of the isBBox() function to validate the bounding box in the second example.

    Hopefully the examples above help you to get past this problem.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • JMCaJHU
    JMCaJHU over 16 years ago

     thanks so much for the help guys

    • 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