Home > Community > Forums > Custom IC SKILL > Access elements of symbol in skill

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

 Access elements of symbol in skill 

Last post Thu, Oct 3 2013 9:39 AM by Sandeep4386. 9 replies.
Started by Sandeep4386 25 Sep 2013 03:28 PM. Topic has 9 replies and 903 views
Page 1 of 1 (10 items)
Sort Posts:
  • Wed, Sep 25 2013 3:28 PM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Access elements of symbol in skill Reply
    corModelSpec = (("/home/bin/toplevel.scs" "top_sf"))
    corModelSpec is of a type symbol. How can I access only second string out from this, so that my output will be top_sf.
     
    I tried rindex but it doesn't quite give the desired output.
     
    param_value=rindex(strcat(corModelSpec) "t") ;
    println(param_value) 
     
    Output: "top_sf\"))"
    I would like to get rid of brackets and double quotes from the output. Any help would be appreciated. Thanks.
     
    -Sandeep 
     
    Filed under:
    • Post Points: 20
  • Wed, Sep 25 2013 10:27 PM

    Re: Access elements of symbol in skill Reply

    What you've posted doesn't make sense. If corModelSpec was the value you'd specified, it's a list not a symbol.

    From what you've described (because the strcat would fail if it was a list), you must have:

    corModelSpec="((\"/home/bin/toplevel.scs\" \"top_sf\"))"

    I've no idea why you have it as a string. Or maybe it really is a symbol, but that would be very odd indeed:

    stringToSymbol(corModelSpec) =>
    \(\(\"\/home\/bin\/toplevel\.scs\"\ \"top_sf\"\)\)

    If it was a list, this would be easy:

    corModelSpec='(("/home/bin/toplevel.scs" "top_sf"))
    cadar(corModelSpec) =>  "top_sf"

    This is equivalent to car(cdr(car(corModelSpec))) - the car is the first element in the list, and cdr is the tail of the list.

    If you really do have it as a symbol, then you should take a serious look at the code and pick an appropriate data structure. But you could get it into a list using:

    equivList=car(linereadstring(symbolToString(corModelSpec)))

    Regards,

    Andrew.

    • Post Points: 20
  • Wed, Oct 2 2013 1:02 PM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: Access elements of symbol in skill Reply
    Thanks Andrew,
    Well I might now have clarified the issue well enough in my last post.
    I am trying to access all adexl corners and design variable and concatenate all of them in one string.  Here is a part of my code:
     
    i=0
    (foreach cparam corner->params()

                    (printf "\t\t %s = %L\n" cparam->name cparam->value)
    cparam_name=sprintf(nil "%s" cparam->name)
    sprintf(cparam_value "%L" cparam->value)
    Type=type('cparam_value)
    printf("%s type is %s \n" cparam_name Type)
    when(i==0
       cparam_total_new=""
     
    )  
    i++
    if(cparam_name!="corModelSpec" then
    sprintf(cparam_total_new strcat(cparam_total_new "_" cparam_name cparam_value))
    else
    println(cparam_name)
    println(cparam_value)
    cparam_value_modelfile=rindex(strcat(cparam_value) "top")
    println(cparam_value_modelfile)
    )
       )
    and here is the output:
     
     StartFreq = 800
    StartFreq type is symbol 
    corModelSpec = (("/home/specmod/models/spectre/toplevel.scs" "top_tt"))
    corModelSpec type is symbol 
    "corModelSpec"
    "((\"/home/specmod/models/spectre/toplevel.scs\" \"top_tt\"))"
    "top_tt\"))"
    temperature = 120
    temperature type is symbol 
     
    I think somehow sprintf is converting string to a symbol? 
     
     
    • Post Points: 20
  • Wed, Oct 2 2013 1:26 PM

    Re: Access elements of symbol in skill Reply

    No, it's because your code is doing this:

     Type=type('cparam_value)

    You've quoted the variable name, so type is returning the type of its argument, which is a symbol. If it wasn't quoted, you'd get the type of the value of the variable which would be list for the first and fixnum or flonum for the second.

    Regards,

    Andrew 

    • Post Points: 35
  • Wed, Oct 2 2013 1:38 PM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: Access elements of symbol in skill Reply
    Hi Andrew,
    So how I can only extract second element of 'corModelSpec' string?Since its a string, I can't use cadar on it. Here is the output when I remove the quote in type function.  Type=type(cparam_value)
     
    Corner C0_0 StartFreq = 500
    StartFreq type is string 
    corModelSpec = (("/home/specmod/models/spectre/toplevel.scs" "top_ff"))
    corModelSpec type is string 
    "corModelSpec"
    "((\"/home/specmod/models/spectre/toplevel.scs\" \"top_ff\"))"
    *Error* cadar: argument #1 should be a list (type template = "l") - "((\"/home/specmod/models/spectre/toplevel.scs\" \"top_ff\"))"
    • Post Points: 5
  • Wed, Oct 2 2013 1:45 PM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: Access elements of symbol in skill Reply
    Actually your suggestion in very first reply worked great! Thanks a lot equivList=car(linereadstring(cparam_value)) cparam_value1=cadar(equivList) It outputs "top_tt", exactly what I wanted.
    • Post Points: 20
  • Wed, Oct 2 2013 1:57 PM

    Re: Access elements of symbol in skill Reply
    You do seem to be over complicating this. Why not just use cparam->value which should be a list if it's a corModelSpec, rather than converting the list to a string and then back to a list again which seems to be a very roundabout way of doing things...
    • Post Points: 20
  • Wed, Oct 2 2013 2:15 PM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: Access elements of symbol in skill Reply
    Ok, I have one more quick question, my skill code here lists all the design variables used in adexl setup. Is there a way I can access only the variables which are being swept in the simulation and ignore those which are not being varied at all?
    • Post Points: 20
  • Wed, Oct 2 2013 8:45 PM

    Re: Access elements of symbol in skill Reply

    You've not shown enough of your code to know what you're actually doing - for example, your previous code snippets did not show how the variable corner was being set - I could guess, but I might guess incorrectly...

     

    • Post Points: 20
  • Thu, Oct 3 2013 9:39 AM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: Access elements of symbol in skill Reply
    Hi Andrew,
    First let me give a little bit of background about the code. I have a verilogA code which writes data to a file. I use $fopen to name and open the file and $fstrobe for writing to a file. I am running sim with multiple corners and this file is generated for every corner and has extension _dat. I'm trying to figure out the way such that I can rename these files with respective corner names and design variables swept while generating the file. Below skill code will copy these files to a different directory and rename it with useful information:
     
    session = (axlGetWindowSession)
          histName = (axlGetHistoryName (axlGetCurrentHistory session ))
          rdb = (axlReadHistoryResDB histName)
          points = rdb->points()

          printf("History %s\n" histName)

          (foreach p points          
    printf("Design Point ID %d\n" p->id)
              (foreach corner (p->corners())

                 printf("\tCorner %s" corner->name)
    sprintf(corner_name "%s" corner->name)           
    i=0
     
    (foreach cparam corner->params()

                    (printf "\t\t %s = %L\n" cparam->name cparam->value)
    cparam_name=sprintf(nil "%s" cparam->name)
    Type=type(cparam->value)
    printf("%s type is %s \n" cparam_name Type)

    when(i==0
      cparam_total_new=""
    )  
    i++
    if(cparam_name!="corModelSpec" then
    sprintf(cparam_total_new strcat(cparam_total_new "_" cparam_name cparam_value))
    else
    cparam_value_modelfile=cadar(cparam->value)
      )
      )

                (foreach test (setof x p->tests() (equal x->cornerName corner->name))

                    printf("\tTest %s\n" test->name)
    sprintf(testName "%s" test->name)
                printf("\tResults dir %s\n\n" test->resultsDir)


    ;axlsession=axlGetWindowSession()
    ;sdb=axlGetMainSetupDB(axlsession)
    ;test = axlGetTest(sdb testName)
    ;toolargs = axlGetTestToolArgs(test)
    ;lib = cadr(assoc("lib" toolargs))
    ;cell = cadr(assoc("cell" toolargs))
    ;view = cadr(assoc("view" toolargs))

    sprintf(resultsDir "%s" test->resultsDir)
    sprintf(command "mkdir -p /scratch/$USER/%s" "dat_file_dir")
    system(command)
    sprintf(copyDirName "/scratch/$USER/%s/%s_%s_%s_dat" "dat_file_dir" corner_name cparam_value_modelfile cparam_total_new )
    sprintf(origDirName "%s/netlist" resultsDir)
    sprintf(command "cp %s/*_dat %s" origDirName copyDirName)
    println(command)
    system(command)
                )
              )
          )
     
    Now I have following issues with this code:
    1. It renames the file with all design variables specified in adexl, irrespective of they are being swept or not. How can I access the variables which are being swept and ignore the ones which are same throught the simulation?
    2.While moving this file to different directory, I am using directory name as /scratch/$USER/dat_file_dir, however I would like to use cellname instead of dat_file_dir here. I used following lines of code (commented out in above code) but it give me below error when I replace 'dat_file_dir' by 'cell'.
     
    ;axlsession=axlGetWindowSession()
    ;sdb=axlGetMainSetupDB(axlsession)
    ;test = axlGetTest(sdb testName)
    ;toolargs = axlGetTestToolArgs(test)
    ;lib = cadr(assoc("lib" toolargs))
    ;cell = cadr(assoc("cell" toolargs))
    ;view = cadr(assoc("view" toolargs)
     *Error* get/getq: first arg must be either symbol, list, defstruct or user type - 1005
    Any help would be appreciated. 
     
    Regards,
    Sandeep 
     
    • Post Points: 5
Page 1 of 1 (10 items)
Sort Posts:
Started by Sandeep4386 at 25 Sep 2013 03:28 PM. Topic has 9 replies.