Home > Community > Forums > Custom IC SKILL > How to calculate area for a given schematic

## Email

Recipients email * (separate multiple addresses with commas)

Message *

 Send yourself a copy

## Subscribe

Intro copy of the newsletter section here, some intro copy of the newsletter. Instruction of how to subscribe to this newsletter.

First Name *

Last Name *

Email *

Company / Institution *

 Send Yourself A Copy

# How to calculate area for a given schematic

Last post Sun, May 31 2009 8:12 PM by IC Layout. 13 replies.
 Started by IC Layout 20 May 2009 08:30 PM. Topic has 13 replies and 4975 views
• #### Wed, May 20 2009 8:30 PM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
How to calculate area for a given schematic
 Hello! Every body, I am using cadence IC514 version and a 90nm PDK kit called "gpdk090".My intention is to calculate area for a given schematic.I wrote a procedure called "area()" which will calculate area in the current level (means for transistors, capacitors and resistors only).Now I need to call this procedure for every instance which is not a transistor,cap or a resistor.I wrote something like this........................foreach( inst geGetEditCellView()~>instances    when( inst~>purpose == "cell"        if( inst~>libName == "gpdk090" then            area()        else            label:            cv1=dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")            foreach( inst1 cv1~>instances                when( inst1~>purpose == "cell"                    if( inst1~>libName == "gpdk090" then                        area()                    else                        goto label        ]Can some body guide me in this way...                Thanks in Advance...                                                                    Prabhakar. K
• Post Points: 20
• #### Wed, May 20 2009 9:08 PM

Re: How to calculate area for a given schematic
 Most likely you're going to want to have your area function take the cellView it is analysing as an argument, and return the area so that you can sum it up in the parent.Secondly the goto you have there is just going to make this an infinite loop as soon as it comes across a pin in the schematic. I suspect that's not what you want.You're probably going to want to have a recursive function too - so that you descend down the hierarchy, view switching as you go.So, something like this pseudo-code:procedure(PKsumArea(@optional (cv geGetEditCellView()))  let((totalArea master)    foreach(inst cv~>instances      if(inst~>libName=="gpdk090" then        totalArea=totalArea+area(inst)      else        when(inst~>purpose=="cell"         master=dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")         when(master           totalArea=totalArea+PKsumArea(master)         )      )    )    totalArea ))Something like that...Andrew.
• Post Points: 20
• #### Sat, May 23 2009 1:43 AM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 Hello, Sir! I have re-written the code but still I am not able to display the result in user units (i.e sq.microns)..I am in confusion.......Please kindly read this code and suggest me........************************area.il**************************** Ap = Ac = Ar = An = evalstring("0u")div_fac = evalstring("1f")count = 0procedure( area(cv)    foreach(inst cv~>instances    when( and(inst~>purpose == "cell" inst~>libName == "gpdk090")        if(inst~>cellName == "pmos2v" then            w1 = evalstring(cdfFormatFloatString(dbGetq(inst "w") "u"))            l1 = evalstring(cdfFormatFloatString(dbGetq(inst "l") "u"))            m1 = evalstring(dbGetq(inst "m"))                f1 = evalstring(dbGetq(inst "fingers"))                            wp = w1 + evalstring("1.4u") ; (0.7u + 0.7u) oxide to nwell enclosure in vertical direction for "pmos2v"            lp = (f1*l1) + ((f1-1)*evalstring("0.36u")) + evalstring("2u")            ;0.36u is space b/w poly fingers             ;(1u + 1u)  poly to nwell enclosure in horizontal direction for "pmos2v"            areap = m1*wp*lp            Ap = Ap + areap            Ap1 = atof(cdfFormatFloatString(artMakeString(Ap) "p"))        else        if(inst~>cellName == "nmos2v" then            w1 = evalstring(cdfFormatFloatString(dbGetq(inst "w") "u"))            l1 = evalstring(cdfFormatFloatString(dbGetq(inst "l") "u"))            m1 = evalstring(dbGetq(inst "m"))                f1 = evalstring(dbGetq(inst "fingers"))                            wn = w1 + evalstring("0.6u") ; (0.3u + 0.3u) oxide to oxide_thk enclosure in vertical direction for "nmos2v"            ln = (f1*l1) + ((f1-1)*evalstring("0.36u")) + evalstring("1.12u")            ;0.36u is space b/w poly fingers             ;(0.56u + 0.56u)  poly to oxide_thk enclosure in horizontal direction for "nmos2v"            arean = m1*wn*ln            An = An + arean            An1 = atof(cdfFormatFloatString(artMakeString(An) "p"))        else        if( inst~>cellName == "mimcap" then            c1 = evalstring(dbGetq(inst "c"))            m1 = evalstring(dbGetq(inst "m"))                        areac = m1*c1            ratio = areac/div_fac            Ac = Ac + ratio        else        if( inst~>cellName == "resnsppoly" then            w1 = evalstring(cdfFormatFloatString(dbGetq(inst "segW") "u"))            l1 = evalstring(cdfFormatFloatString(dbGetq(inst "segL") "u"))            m1 = evalstring(dbGetq(inst "segments"))                         wr = (m1*w1) + (m1-1)*evlastring("0.6u") + evalstring("0.56u")            lr = l1 + evalstring("1.12u")            arear = wr*lr            Ar = Ar + arear            Ar1 = atof(cdfFormatFloatString(artMakeString(Ar) "p"))        else        println("Nothing to calculate"));if);if);if);if);when        when( and(inst~>purpose == "cell" inst~>libName != "gpdk090")            cv1 = dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")            println(inst~>cellName)            count = count + 1            area(cv1) ;function call            dbClose(cv1));when);foreach);procedurearea(geGetEditCellView())area = Ap1 + An1 + Ar1 + Acprintf("Number of instances/blocks in the design : %d \n" count)println(area);printf("The Total area of the design : %f \n" area)*************************end of area.il********************************And one more kind request How to get the area of each instance/block (which are in toplevel schematic only).Thanks in advance                             Prabhakr. K - Layout Design Engineer
• Post Points: 20
• #### Tue, May 26 2009 2:43 AM

Re: How to calculate area for a given schematic
 Why are you using evalstring() all over the place, including with constants? For example, you are doing things like evalstring("0.56u") when you could just use 0.56u directly (engineering suffixes are understood in SKILL natively). In other places you're doing things like:  evalstring(cdfFormatFloatString(dbGetq(inst "segL") "u")) I cannot fathom out why you're doing that. Reformatting a number to be in engineering suffixes, and then using evalstring on it? Why? If it's a string in the first place, just use:  cdfParseFloatString(inst~>segL)Later on  you have:  Ar=Ar+arear  Ar1=atof(cdfFormatFloatString(artMakeString(Ar) "p"))You're converting to a string, reformatting to have a "p" suffix, and then using atof (which will ignore the suffix) back to a float again. Why?Anyway, your function area does not explicitly return anything - it will return the last thing computed in the fucntion, which will be the return value of the foreach. The return value of foreach will be the list it processed. Most likely I'd expect you to need to sum up the area of all the instances (including the return value of the recursive area() call within area()), and make that the return value. Look at what my pseudo code does - totalArea is the last statement in the function, and that will be the return value. Best Regards,Andrew.
• Post Points: 35
• #### Wed, May 27 2009 8:27 AM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 Thanks for your concern towards my problem.......sir,My intention is to have total area for a given schematic & also drawing rectangles for the instances/blocks which are in top level schematic only.With the suggestions you had given now I am able to obtain area for the entire schematic......I tried to draw rectangles for the instances which are in toplevel but in vain.......Please have a look at my new code " area_mod.il" and suggest me........************************************ area_mod.il************************************** div_fac = 1f procedure( area_mod(inst) if(inst~>cellName == "pmos2v" then            w1 = cdfParseFloatString(dbGetq(inst "w") )            l1 = cdfParseFloatString(dbGetq(inst "l") )            m1 = evalstring(dbGetq(inst "m"))                f1 = evalstring(dbGetq(inst "fingers"))             wp = w1 + 1.4u           lp = f1*l1 + (f1-1)*0.36u + 2u           AREA = wp*lpelse       if(inst~>cellName == "nmos2v" then             w1 = cdfParseFloatString(dbGetq(inst "w") )            l1 = cdfParseFloatString(dbGetq(inst "l") )            m1 = evalstring(dbGetq(inst "m"))                f1 = evalstring(dbGetq(inst "fingers"))             wn = w1 + 0.6u           ln = f1*l1 + (f1-1)*0.36u +1.12u           AREA = wn*lnelse           if(inst~>cellName == "resnsppoly" then           w1 = cdfParseFloatString(dbGetq(inst "segW") )            l1 = cdfParseFloatString(dbGetq(inst "segL") )            m1 = evalstring(dbGetq(inst "segments"))                         wr = m1*w1 + (m1-1)*0.6u + 0.56u            lr = l1 + 1.12u           AREA = wr*lrelse             if( inst~>cellName == "mimcap" then            c1 = cdfParseFloatString(dbGetq(inst "c"))            m1 = evalstring(dbGetq(inst "m"))                        areac = m1*c1            AREA = areac/div_fac) ) ) )AREA);procedure procedure(PKsumArea(@optional (cv geGetEditCellView()))      foreach(inst cv~>instances      if(inst~>libName=="gpdk090" then        totalArea=totalArea+area_mod(inst);;;;shall I write 'dbCreateRect(.....) statement here.....for the toplevel transistors/res/caps      else        when(inst~>purpose=="cell"         master=dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")         when(maste                  println(master~>cellName)        PKsumArea(master)        ;;;;shall I write 'dbCreateRect(.....) statement here.....for the toplevel blocks (after calculating whole block area) ) ) ) )totalArea)PKsumArea()println(totalArea)******************************************** end of area_mo.il************************************I have used ' cdfFofmatFloatString ' for the purpose of drawing rectangles (by formating every value to suffix "p" in other case it's giving errors). I hope you are understanding my problem...........I am very very sorry....if you feel inconvinence..Thanks & regards........                    Prabhakar. K
• Post Points: 5
• #### Wed, May 27 2009 8:31 AM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 I am sorry ....I forgot to write a statement at the top of the code....Please notice this .........totalArea = 0uthanks & regards                       Prabhakar. K
• Post Points: 20
• #### Wed, May 27 2009 8:42 AM

Re: How to calculate area for a given schematic
 Why are you trying to draw rectangles in the schematic? Since you have those lines missing, I can't work out what you're trying to do or why it failed...Also, your code could seriously do with using local variables. At the moment everything is global, which in a recursive function is asking for trouble...And you still have unnecessary evalstring() calls in the code.Regards,Andrew.
• Post Points: 20
• #### Wed, May 27 2009 10:38 PM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 No, I would like to draw rects in a layout window....I got part of solution....drawing rects for transisitors/caps/resistors  which are in top level....***************************************************  totalArea = 0u  top = geGetEditCellView()~>cellName   procedure( PKsumArea(@optional (cv geGetEditCellView()))        foreach(inst cv~>instances                if(inst~>libName == "gpdk090" && cv~>cellName == top then                totalArea = totalArea + area(inst)                fig1=dbCreateRect(rv list("Metal1" "drawing") list(0:0 sqrt(atof(cdfFormatFloatString(artMakeString(area(inst)) "p"))):sqrt(atof(cdfFormatFloatString(artMakeString(area(inst)) "p")))))                ;where ' rv ' is a opend layout window                println(inst~>cellName)                else                if(inst~>libName == "gpdk090" && cv~>cellName != top then                totalArea = totalArea + area(inst)                else                when(inst~>purpose == "cell"                master = dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")                ;;for this particular 'master' I need to get/print area separately                when(master                println(master~>cellName)                PKsumArea(master)                )        ) ) ) ) totalArea ) PKsumArea() println(totalArea) println(cdfFormatFloatString(artMakeString(totalArea) "p"))******************************************************************;;;You might be surprised why I again wrote the bad statement  atof(cdfFormatFloatString(artMakeString(area(inst)) "p") ;;;;But I find this is the way to draw rectangles ;;;;if I wrote like this "dbCreateRect(rv list("Metal1" "drawing") list(0:0 sqrt(area(inst)):sqrt(area(inst))))" ;;;;I am getting this error " *WARNING* Rectangle being created has no area " ;;;;Please notice this ....and let me know the right solution....... ;;;;One more thing is that I am not getting the area of individual blocks which are in toplevel schematicthanks & regards....                           Prabhakar. K
• Post Points: 20
• #### Thu, May 28 2009 3:45 AM

Re: How to calculate area for a given schematic
 Wouldn't it be easier to do:; convert to micronswl=sqrt(area(inst)*1e6 dbCreateRect(rv list("Metal1" "drawing") list(0:0 wl:wl))What you have is a very complicated way of converting from metres to microns.And it only does it for the transistors because it's only in the then part of the if and not in the else part. Simple flow of control problem...Andrew.
• Post Points: 20
• #### Fri, May 29 2009 6:07 AM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 Really, I tried a lot.......Still I am not getting how to access the area of individual block area which is in tolevel schematic .In my every attempt the area is being adding to one variable only..I tried to have one more variable to add block area still results are not satisfactory.. Also I made three procedures same thing happening..If you don't mind can please send me a code snippet which will guide me in accessing the whole block  area ....Anyway I am getting the total area of given schematic perfectly...but it's only my part of intention... thanks & regards
• Post Points: 20
• #### Fri, May 29 2009 6:21 AM

Re: How to calculate area for a given schematic
 It's still very unclear what you're actually trying to do. Please post the current complete code, and a detailed specification of your requirements. That way somebody might have a chance to correct your code, or at least provide pointers as to what you really want. Regards,Andrew.
• Post Points: 20
• #### Fri, May 29 2009 6:38 AM

• IC Layout
• Joined on Fri, Mar 6 2009
• Posts 53
• Points 1,155
Re: How to calculate area for a given schematic
 Suppose If I have four 4:1 mux's and to resitors and few transistors/caps & each mux is having again two 2:1 mux's inside ..Now along with the total area I would like to have the area of each 4:1 Mux separately ...I am sending my code here..please notice the comment where I am getting the problem*******************************totalArea = 0u   procedure( area(inst)                if( inst~>cellName == "pmos2v"  then                    w1 = cdfParseFloatString(dbGetq(inst "w"))                    l1 = cdfParseFloatString(dbGetq(inst "l"))                    m1 = cdfParseFloatString(dbGetq(inst "m"))                    f1 = cdfParseFloatString(dbGetq(inst "fingers"))                        wp = w1 + 1.4u                        lp = f1*l1 + (f1-1)*0.36u + 2u                                AREA = m1*wp*lp                else                if(inst~>cellName == "nmos2v"  then                    w1 = cdfParseFloatString(dbGetq(inst "w"))                    l1 = cdfParseFloatString(dbGetq(inst "l"))                    m1 = cdfParseFloatString(dbGetq(inst "m"))                    f1 = cdfParseFloatString(dbGetq(inst "fingers"))                        wn = w1 + 0.6u                        ln = f1*l1 + (f1-1)*0.36u + 1.2u                                AREA = m1*wn*ln               else               if((inst~>cellName == "mimcap" ) then                    c1 = cdfParseFloatString(dbGetq(inst "c"))                    m1 = cdfParseFloatString(dbGetq(inst "m"))                                areac = m1 * c1                                AREA = areac/AA                else                if(inst~>cellName == "resnsppoly"  then                    w1 = cdfParseFloatString(dbGetq(inst "segW"))                    l1 = cdfParseFloatString(dbGetq(inst "segL"))                    m1 = dbGetq(inst "segments")                        wr = m1*w1 + (m1-1)*0.6u + 0.56u                        lr = l1 + 1.12u                                AREA = wr * lr ) ) ) ) AREA  );proc1**********************  procedure( PKsumArea(@optional (cv geGetEditCellView()))        foreach(inst cv~>instances                if(inst~>libName == "gpdk090" then                  totalArea = totalArea + area(inst)      else                when(inst~>purpose == "cell"                master = dbOpenCellViewByType(inst~>libName inst~>cellName "schematic")                ;;;;;;;;;;;;;;;;;;;;;for this particular 'master' --if it refers to toplevel schemaic --I need to get this area ;;;;;;;;;;;;;;;;;;;;;;;;;;;;                when(master                println(master~>cellName)                PKsumArea(master)                )        ) ) ) ) totalArea ) PKsumArea() println(totalArea)************************************************If still unclear I will send some more trials where I faild ........thanks & regards                          Prabhakar. K
• Post Points: 20
• #### Fri, May 29 2009 7:20 AM

Re: How to calculate area for a given schematic
 OK. I've tidied up the code, removed the global variables (made them local, except for AA which I didn't know what it was), changed the nested if-then-else in the area function to be a case(), coped with unrecognized devices, and added something to print out the area of the top level blocks as it goes along. ; globals used in this code that I can't account for: ; AA procedure( PKinstArea(inst) let((w1 l1 m1 f1 wp lp wr lr wn ln c1 areac AREA) case(inst~>cellName ("pmos2v" w1 = cdfParseFloatString(inst~>w) l1 = cdfParseFloatString(inst~>l) m1 = cdfParseFloatString(inst~>m) f1 = cdfParseFloatString(inst~>fingers) wp = w1 + 1.4u lp = f1*l1 + (f1-1)*0.36u + 2u AREA = m1*wp*lp ) ("nmos2v" w1 = cdfParseFloatString(inst~>w) l1 = cdfParseFloatString(inst~>l) m1 = cdfParseFloatString(inst~>m) f1 = cdfParseFloatString(inst~>fingers) wn = w1 + 0.6u ln = f1*l1 + (f1-1)*0.36u + 1.2u AREA = m1*wn*ln ) ("mimcap" c1 = cdfParseFloatString(inst~>c) m1 = cdfParseFloatString(inst~>m) areac = m1 * c1 AREA = areac/AA ) ("resnsppoly" w1 = cdfParseFloatString(inst~>segW) l1 = cdfParseFloatString(inst~>segL) m1 = inst~>segments wr = m1*w1 + (m1-1)*0.6u + 0.56u lr = l1 + 1.12u AREA = wr * lr ) (t warn("Unrecognized device %L\n" inst~>cellName) AREA = 0.0 ) ) ; case AREA ) ; let ) ; procedure PKinstArea procedure( PKsumArea(@optional (cv geGetEditCellView()) (topLevel t)) let((master instArea (area 0.0)) foreach(inst cv~>instances if(inst~>libName == "gpdk090" then area=area+PKinstArea(inst) else when(inst~>purpose == "cell" master = dbOpenCellViewByType(inst~>libName inst~>cellName "schematic") when(master instArea=PKsumArea(master nil) when(topLevel printf("Instance %s of %s has area %g\n" inst~>name inst~>cellName instArea) ) ; when topLevel area=area+instArea ) ; when master ) ; when purpose is cell ) ; if ) ; foreach area ) ) ; procedure PKsumArea totalArea=PKsumArea() printf("Total area is %g\n" totalArea) Regards,Andrew.
• Post Points: 20
• #### Sun, May 31 2009 8:12 PM

• IC Layout
• Joined on Fri, Mar 6 2009