Home > Community > Forums > Custom IC SKILL > Easy way to convert a String to a Float?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Easy way to convert a String to a Float? 

Last post Fri, Mar 4 2011 1:00 AM by SebV. 8 replies.
Started by Patrick1982 23 Feb 2011 07:40 AM. Topic has 8 replies and 3188 views
Page 1 of 1 (9 items)
Sort Posts:
  • Wed, Feb 23 2011 7:40 AM

    Easy way to convert a String to a Float? Reply

    Hi Everyone,

    Firstly, I am using the Cadence Pcell Layout enviroment to create/modify Pcells. So in other words I am using the pcell menu within the layout window, I am not generating the pcell using skill.  I am trying to use an already supported device and I am trying to inherit certain parameters.  However, the parameters can only be inherited as a "string".  And in order to use this parameter else where within the pcell (i.e. stretch or repitition) it needs to be a "float". 

     So is there an easy way to convert a string to a float within cadence?

     Thanks very much,

    Patrick

    • Post Points: 20
  • Wed, Feb 23 2011 8:06 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,587
    • Points 15,915
    Re: Easy way to convert a String to a Float? Reply

    Hi Patrick,

    one of the easiest ways to do this is to use the function cdfParseFloatString() which takes a numeric string and outputs a floating point number.

    Best regards,

    Lawrence.

    Filed under: , , ,
    • Post Points: 35
  • Wed, Feb 23 2011 8:11 AM

    Re: Easy way to convert a String to a Float? Reply

    Excellent, that works perfect for what I need. Thanks very much Lawrence. 

    • Post Points: 20
  • Wed, Feb 23 2011 10:13 AM

    • stuso
    • Top 100 Contributor
    • Joined on Mon, Nov 3 2008
    • Posts 77
    • Points 1,315
    Re: Easy way to convert a String to a Float? Reply

    Hi guys,

    I was about to ask a similar question relating to an earlier post i had made which was:

    1) How to determine which type a variable is?

    2) How to convert variable types (which i have an idea of now with the parse example from Lawrence)

    Specifically my issue is that i have assigned the w&l of a transistor to variables X & Y but when i do X*Y it does not work, i assume its the format of the w&l initially OR that in assigning them to new variable names i have not specified a variable type therefore string is assumed. As if you type: 500n*2u directly into the CIW it returns a result OK.

    Thanks

    Stu

     

    • Post Points: 20
  • Wed, Feb 23 2011 10:30 AM

    Re: Easy way to convert a String to a Float? Reply

    Stu,

    The type() function will tell you the type of a variable (actually, to be precise, it tells you the type of the data pointed to by the variable, as variables do not have a type).

    To produce strings, the best way is to use something like:

    sprintf(nil "%g" X*Y)

    For example. What you have to set the parameters of a transistor to depends on things like the type of the parameter in the CDF and/or the type of the pcell parameter (I'm not quite sure exactly what you're trying to do) - it all depends on how it has been defined.

    Regards,

    Andrew.

    • Post Points: 20
  • Thu, Feb 24 2011 5:56 AM

    • stuso
    • Top 100 Contributor
    • Joined on Mon, Nov 3 2008
    • Posts 77
    • Points 1,315
    Re: Easy way to convert a String to a Float? Reply

    Hi Andrew,

    i am trying to estimate area of layout from schematic, so for example i have assigned gate length to a variable:

    cv=geGetWindowCellView(hiGetCurrentWindow())

    foreach(sd_instance cv~>instances

    if(sd_instance~>cellName     == "nmos_myPDK"           

    then

    sd_length         = sd_instance~>l

     

    so basically i have assigned gate length to "sd_length". I just did as you suggested:

    type(sd_length)

    string

    so i guess if i convert string to flonum (or some such number) then i can begin to multiple width x length x fingers...etc.

     

    Thanks

    Stu

    • Post Points: 20
  • Wed, Mar 2 2011 12:47 PM

    Re: Easy way to convert a String to a Float? Reply

     Hi Lawrence and Andrew,

    I've got another question for you guys.  Similar to my original question, I have a string "3u" but I want to convert it to a float, is there a way for me to just ignore the "u" in the string?

    Thanks very much,

    Patrick

    • Post Points: 20
  • Thu, Mar 3 2011 12:00 PM

    Re: Easy way to convert a String to a Float? Reply
    Patrick,

    You could use atof() for this.

    Regards,

    Andrew
    • Post Points: 5
  • Fri, Mar 4 2011 1:00 AM

    • SebV
    • Not Ranked
    • Joined on Tue, Dec 21 2010
    • Colombelles, Calvados
    • Posts 3
    • Points 30
    Re: Easy way to convert a String to a Float? Reply

     Hi Stu,

    Not directly related to your question, but to what you want to do.

    In the "Virtuoso Preview Fundamentals Reference" documentation "installdir/doc/prfref/prfref.pdf" (in IC 5.1.41 installation tree) there is a skill procedure example that estimate the layout area from schematic. Procedure name is "areaEstSchematic" (p638) may it help you.

    Regards,

    Seb

     

     

     

    Filed under:
    • Post Points: 5
Page 1 of 1 (9 items)
Sort Posts:
Started by Patrick1982 at 23 Feb 2011 07:40 AM. Topic has 8 replies.