• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Access elements of symbol in skill

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 143
  • Views 18716
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Access elements of symbol in skill

Sandeep4386
Sandeep4386 over 12 years ago
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 
 
  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sandeep4386
    Sandeep4386 over 11 years ago
    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? 
     
     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    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 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sandeep4386
    Sandeep4386 over 11 years ago
    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\"))"
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sandeep4386
    Sandeep4386 over 11 years ago
    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.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago
    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...
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sandeep4386
    Sandeep4386 over 11 years ago
    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?
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    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...

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sandeep4386
    Sandeep4386 over 11 years ago
    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 
     
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information