Home > Community > Forums > Custom IC SKILL > methods for variable integer to string conversion

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: *

 methods for variable integer to string conversion 

Last post Fri, Nov 20 2009 8:48 AM by Andrew Beckett. 16 replies.
Started by JMCaJHU 07 Oct 2009 04:21 PM. Topic has 16 replies and 7768 views
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
  • Wed, Oct 7 2009 4:21 PM

    • JMCaJHU
    • Not Ranked
    • Joined on Mon, Mar 2 2009
    • Posts 13
    • Points 275
    methods for variable integer to string conversion Reply

     Is there any way to convert a variable of the integer type to a string.  Currently i must create a set of pins with names varying from IN0 onward.  I tried everything from casting the int to string with quotations to evaluating the symbol/variable then casting into a string with symbolToString.  All seem to be limited with no direct way from int to string.  Currently i have resorted to using random naming for the program to work as follows:

     for(j 0 n

    if(j==0 then
    db_outnet=dbCreateNet(db_outcell "IN0")
    db_figId = dbCreateRect(db_outcell  list("METAL1")  list(0:5.025 0.375:5.4))
    dbCreatePin(db_outnet db_figId "IN0")

    else
    outname=symbolToString(gensym('IN))
    db_outnet=dbCreateNet(db_outcell outname)
    db_figId = dbCreateRect(db_outcell  list("METAL1")  list(0:(3.7+rth*j) 0.375:(rth*j+4.1)))
    dbCreatePin(db_outnet db_figId outname)

    outname=symbolToString(gensym('IN))
    db_outnet=dbCreateNet(db_outcell outname)
    db_figId = dbCreateRect(db_outcell  list("METAL1")  list(0:(5.025+rth*j) 0.375:(rth*j+5.4)))
    dbCreatePin(db_outnet db_figId outname) 

     This creates IN0 then continues creating input pins in numerical order from a random index.  I need to be able to create "IN" + j.string in java terms.

    • Post Points: 35
  • Wed, Oct 7 2009 6:08 PM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,587
    • Points 15,915
    Re: methods for variable integer to string conversion Reply

    Hi,

    I think what you need is the sprintf() function, for example:

    db_outnet = dbCreateNet(db_outcell sprintf(nil "IN%d" j))
    db_figId = dbCreateRect(db_outcell list("METAL1") list(0:5.025 0.375:5.4))
    dbCreatePin(db_outnet db_figId sprintf(nil "IN%d" j))

    Hopefully the above will help you.  If you want to store this in a variable, use the first argument to sprintf for the variable name, e.g.

    sprintf(name "IN%d" j)
    db_outnet = dbCreateNet(db_outcell name)
    db_figId = dbCreateRect(db_outcell list("METAL1") list(0:5.025 0.375:5.4))
    dbCreatePin(db_outnet db_figId name)

    Since the counting variable j is an integer, I used %d for the format specifier, but other formats can be used too, such as %L (any format), %f (float), %g (numeric, efficient), %s (string).

    Regards,

    Lawrence.

    • Post Points: 35
  • Thu, Oct 8 2009 3:29 AM

    • IC Layout
    • Top 150 Contributor
    • Joined on Sat, Mar 7 2009
    • Hyderabad, Andhra Pradesh
    • Posts 53
    • Points 1,155
    Re: methods for variable integer to string conversion Reply

     Hi! you can build strings in this way also ...

    choose a proper way according to your need.. 

    1. artMakeString(300) or artMakeString(12.34)

    2. pcExprToString(320+130) ;; this results in "450" 

    I think in your case it seems that the answer given by Lawrence is fine....

    I added these lines to help you in othercase....

    Best Regards... 

    Prabhakar. K -- Layout Engineer 

    • Post Points: 5
  • Wed, Oct 14 2009 2:58 PM

    • JMCaJHU
    • Not Ranked
    • Joined on Mon, Mar 2 2009
    • Posts 13
    • Points 275
    Re: methods for variable integer to string conversion Reply

     thanks lawrence. the sprinf command was perfect

    • Post Points: 5
  • Tue, Nov 17 2009 3:55 PM

    • sprinter
    • Top 500 Contributor
    • Joined on Tue, Sep 29 2009
    • Posts 17
    • Points 310
    Re: methods for variable integer to string conversion Reply
    Hi Lawrence,

    I shall appreciate if you could help me achieve the opposite, i.e. converting string to a variable.

    I want the vertices of a polygon to be variables with an index (say 'm') included in its name which gets updated in a 'for' loop. I'm unable to assign an integer value to this. Please see below:

    pp1_1x=some integer variable

    pp1_1y=some integer variable

    pp1_2x=some integer variable

    pp1_2y=some integer variable

    and so on.

    In Matlab the vertices names would be as simple as:

    pp(m)_1x=interger variable,

    pp(m)_1y=integer variable, etc. & you can sweep the value of 'm'

    I tried this but obviously this didn't work in SKILL.

    the other thing I tried was this:

    m=1 (say)

    stringToSymbol(sprintf(x "pp%d_1x" m)

    this gives me x="pp1_1x"

     At this point I can assign an integer value to 'x' but "pp1_1x" is still an undefined variable, actually it's still a string.

     

    Therefore I tried to write to a symbol directly with this:

    printf("pp%d_1x" m)=some integer value

    but this is not even allowed. Please suggest.

     

    Regards,

    Adil Khalil.
    Filed under:
    • Post Points: 20
  • Tue, Nov 17 2009 11:11 PM

    Re: methods for variable integer to string conversion Reply

    Personally I think you should really use an array for this (or a table) because that's what arrays are for:

    declare(pp_1x[10])

    and then pp_1x[m]=...

    But if you really want to build a variable name dynamically, you'd do something like this:

    varName=stringToSymbol(sprintf(nil "pp%d_1x" m))
    set(varName 200)

    and now pp1_1x will be set to 200 (say).

    Regards,

    Andrew.

    • Post Points: 20
  • Wed, Nov 18 2009 1:35 PM

    • sprinter
    • Top 500 Contributor
    • Joined on Tue, Sep 29 2009
    • Posts 17
    • Points 310
    Re: methods for variable integer to string conversion Reply
    Thanks Andrew for your suggestions.

    I like the array idea too. However, it would be nice to be able to use a wild card so that I don't have to declare all the variables in the array. e.g. I thought declare(pp**_[10]) would let me declare the array just once for something like: pp1x_[m], pp1y_[m] ,pp2x_[m] ..... I couldn't find anything for a wild card in the Skill Language User Guide either. Is there a wild card in Skill?

    Another question on a different topic if you don't mind :)

    1. What's the best way to read a user input from the keyboard? fscanf would let you read from a file through a port but it wouldn't read from the keyboard entry. I've heard that enterString is the command for this purpose but I couldn't find its usage in the Skill language reference.

    Regards,

    Adil. 
    Filed under:
    • Post Points: 20
  • Wed, Nov 18 2009 2:03 PM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 394
    • Points 7,420
    Re: methods for variable integer to string conversion Reply

    I prefer to use tables whenever I can. They are very efficient and you wouldn't need to declar a fixed size in this case.

    ;Define your table
    varTbl = makeTable("varTbl" nil)

    You could do this in a variety of ways:
    sprintf(varName "pp%d_1x" m)
    varTbl[varName] = myvalue

    OR
    varTbl[list("pp_1x" m)] = myvalue

    OR, if there are a lot of values to deal with, you could create nested tables
    varTbl["pp_1x"] = makeTable("pp1x" nil)
    varTbl["pp_1y"] = makeTable("pp1y" nil)
    varTbl["pp_2x"] = makeTable("pp2x" nil)
    varTbl["pp_2y"] = makeTable("pp2y" nil)
    foreach(m mList
        varTbl["pp_1x"][m] = myvalue1x
        varTbl["pp_1y"][m] = myvalue1y
        varTbl["pp_2x"][m] = myvalue2x
        varTbl["pp_2y"][m] = myvalue2y
    )

    As for reading input from the keyboard, it depends on what you want to do. Are you working in Virtuoso? Then you can use bindkeys. The enterString should be in the documentation.

    enterString(
    [?prompts l_promptList]
    [?form s_form]
    [?initProc t_initProcName]
    [?doneProc t_doneProcName]
    [?formProc t_formProcName]
    [?alwaysMap g_alwaysMap]
    [?cmdName t_cmdName]
    )

    Derek

    • Post Points: 20
  • Wed, Nov 18 2009 2:50 PM

    • sprinter
    • Top 500 Contributor
    • Joined on Tue, Sep 29 2009
    • Posts 17
    • Points 310
    Re: methods for variable integer to string conversion Reply
    Hi Derek,

    Thank you for your nice suggestion.   

    It appears that even if I choose to use tables, I would still need to create as many tables as there're variables which comes to the same as having to declare as many variables if I choose array.

    enterString:

    I want to enter parameters like space, trace width etc. for my transformer (ROD based) code in the CIW window. I want to be prompted for data entry when I load the file. An example would be quite helpful to understand its usage.

      Did find the usage in the 'skillfinder' but without any example. Skill language reference doesn't even list this command.

    Thanks,

    Adil.
    • Post Points: 20
  • Wed, Nov 18 2009 3:17 PM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 394
    • Points 7,420
    Re: methods for variable integer to string conversion Reply

    Actually, the first two examples I showed you used only one table. The "keys" to the table are either unique strings or unique lists.

    Sounds like you ought to be writing a pcell rather than prompting for parameters in the CIW. Have you looked at the pcell documentation? The enterString help is in the Cadence User Interface Skill Reference.

    As for creating pcells, here is a place to start: http://www.cadence.com/Community/forums/p/12699/19577.aspx#19577

    Derek

    • Post Points: 20
  • Wed, Nov 18 2009 11:08 PM

    Re: methods for variable integer to string conversion Reply

    Derek's suggestion is exactly what I'd have said - in fact I nearly suggested it in the first place, but it wasn't entirely clear to me what your objective was.

    Prompting for parameters in the CIW is almost never a good idea. Either the pcell approach or using a form would be a better idea.

    http://www.cadence.com/Community/forums/p/13412/20801.aspx#20801

    for example.

    Regards,

    Andrew.

    • Post Points: 20
  • Thu, Nov 19 2009 7:49 AM

    • sprinter
    • Top 500 Contributor
    • Joined on Tue, Sep 29 2009
    • Posts 17
    • Points 310
    Re: methods for variable integer to string conversion Reply

    Thanks Andrew & Derek for your useful inputs.

    Yes, you're right, I've made a transformer pcell using ROD functions. Right now, I fill in the parameters (space, width, etc. ) in the code itself & then load the file in the CIW. Your idea of using a form is perfect. I was thinking, instead of making a form afresh, which may take some effort for a new Skill user like me, why not pull (copy) an existing CDF form from the IBM library & add a few fields. An inductor CDF form would be a close match for this as there're no transformers in the IBM PDK. I shall appreciate if you could outline some steps towards achieving this.

     

    Best regards,

    Adil.

    • Post Points: 20
  • Thu, Nov 19 2009 8:03 AM

    Re: methods for variable integer to string conversion Reply

    Adil,

    If it's really a pcell (defined with pcDefinePCell), then it makes no sense to create a form. 

    If you have no CDF defined, you should just be able to place an instance of the pcell (as usual) in the layout and the prompts will be names of the pcell parameters - and all will be fine.

    If you want to make the create instance/edit properties form a little cleaner, you may then want to define CDF for the component. This allows you to give nicer prompts to the user. If you do this, please ensure that your CDF default values match the pcell default values (you'll get in a horrible mess otherwise).

    To create the CDF, you can start with Tools->CDF->Edit CDF. Make sure you pick "Base" and then add the parameters you need - make sure the types match the types you're using for each CDF parameter.

    You may find it easier to define a few, then use:

    cdfDump("libName" "fileName.cdf" ?cellName "cellName")

    (change the bits in quotes as you need)

    Regards,

    Andrew.

    • Post Points: 20
  • Fri, Nov 20 2009 7:00 AM

    • sprinter
    • Top 500 Contributor
    • Joined on Tue, Sep 29 2009
    • Posts 17
    • Points 310
    Re: methods for variable integer to string conversion Reply
    Thanks Andrew for your reply.

     If it's really a pcell (defined with pcDefinePCell), then it makes no sense to create a form

    Well, I've not defined it with pcDefinePCell, all I've done is that I've put together ROD functions, like CreatePolygon etc.  and made the transformer.   

    If you want to make the create instance/edit properties form a little cleaner, you may then want to define CDF for the component. This allows you to give nicer prompts to the user. If you do this, please ensure that your CDF default values match the pcell default values (you'll get in a horrible mess otherwise).

    I think this is what I will end up doing but by copying the existing inductor CDF and modifying it.

     

    Regards,

    Adil.
    • Post Points: 20
  • Fri, Nov 20 2009 8:02 AM

    Re: methods for variable integer to string conversion Reply
    Hi Adil,

    Note that unless you make it into a pcell, creating CDF is going to be of no help. CDF is Component Description Format, and unless you have a component (ie a cellView) there is no point in using cell CDF.

    Regards,

    Andrew
    • Post Points: 20
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts:
Started by JMCaJHU at 07 Oct 2009 04:21 PM. Topic has 16 replies.