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.
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 formll = 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 formx1 = 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 shortcutsx1 = leftEdge(bBox)x2 = rightEdge(bBox)y1 = bottomEdge(bBox)y2 = topEdge(bBox)println(list(x1 x2 y1 y2))
;Using some of Skill's shortcutsll = lowerLeft(bBox)ur = upperRight(bBox)x1 = xCoord(ll)x2 = xCoord(ur)y1 = yCoord(ll)y2 = yCoord(ur)println(list(x1 x2 y1 y2))
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!
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.
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")
ll = lowerLeft(bBox)
ur = upperRight(bBox)
x1 = xCoord(ll)
x2 = xCoord(ur)
y1 = yCoord(ll)
y2 = yCoord(ur)
This code resulted in an error of mismatched types, so i tried:
but that just gives an output of t/nil when it should output the x1 coord
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.