• 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. how to print the absolute/relative path from file

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 143
  • Views 3945
  • 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

how to print the absolute/relative path from file

saurabh96
saurabh96 over 3 years ago

Hello I have two setting file....setting file 1 which consists of-

source netlist1                                                    (relative path)

top cell  test21

setting file 2 which consists of-

source /xyz/path1/path2/netlist1                       (absolute path)

top cell  test21

procedure(readSetupFile(form)
  let((prt split removeQuotes commandArg)
    setup_file_path = form->setupFile->value
    removeQuotes=pcreCompile("['\"]")
    unless(blankstrp(form->setupFile->value)
      prt=infile(form->setupFile->value)
      when(prt
        while(gets(line prt)
          split=parseString(line)
          when(stringp(cadr(split))
            commandArgs=pcreReplace(removeQuotes cadr(split) "" 0)
            case(car(split)
              (("source")
                test = parseString(setup_file_path "/")
                test_dir = append1((reverse (cdr (reverse test))) commandArgs)
                netpath = buildString(test_dir "/" )
                form->netlistPath->value = strcat("/" netpath)
              )
              ("topcell"
                form->cell->value=commandArgs
              )
            )
          )
        )
        close(prt)
      )
    )
  )
)

; dummy form to test
hiCreateLayoutForm(
  'forumForm
  "Forum example"
  hiCreateFormLayout(
    'vbox
    ?items list(
      hiCreateStringField(
        ?name 'setupFile
        ?prompt "Setup File"
        ?callback "readSetupFile(hiGetCurrentForm())"
      )
      hiCreateStringField(
        ?name 'netlistPath
        ?prompt "Netlist Path"
      )
      hiCreateStringField(
        ?name 'cell
        ?prompt "Cell"
      )
    )
  )
)

hiDisplayForm(forumForm)

when i give setting file1 path /xyz/abc/cadence/setting1 then output is comign correct as /xyz/abc/cadence/netlist1.

but when am giving setting file 2  path  /xyz/abc/cadence/setting1 then output is comign incorrect as /xyz/abc/cadence//xyz/path1/path2/netlist1 

how to correct so gets the corrrect result.

  • Cancel
  • mbracht
    mbracht over 3 years ago

    Hi,

    If you expect me to help I need better problem descriptions! What exactly is that script/callback supposed to do in the first place? What do you mean by "output"? That callback's return value maybe? And what is the content of these files? I've been trying to understand your problem for the last 15 mins but to no avail! Not to mention that you keep sending your code without any indentations which renders it unreadable - well at least for me. The less time I need to reproduce your issue the better chance you have that I look into it!
    So please provide a clear problem description and an explanation what I need to do to see the behavior at my end.

    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to mbracht

    Hi Max,

    apologies,

    if you run above code...you will get this

    Now when i give my setting file 1 path which contains

    source netlist1                                                    

    top cell  test21

    you will get 

    but if if give setting2 file which constains

    source /xyz/path1/path2/netlist1   

    top cell  test21

    so the netlist path am getting wrong.

    Hope it clears some clouds.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • AurelBuche
    AurelBuche over 3 years ago

    I guess what you are looking for is simplifyFilename

    This function takes a path in argument and gives you the fully expanded path

    If you give it your relative path, it will expand it in the current directory, if you give it the full path it will leave it as is

    Hope this help

    Cheers

    Aurélien

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    I reformatted your code in the initial post - see it's much easier to read now? Usually you can do this in most browsers by saving the code in a file with a ".txt" suffix and loading it in the browser, and then copying and pasting into the forum (other methods are available if that doesn't work).

    Your "setting" file examples also ought to use "topcell" not "top cell".

    Essentially you'll need to fix the logic in this part of the code:

                  (("source")
                    test = parseString(setup_file_path "/")
                    test_dir = append1((reverse (cdr (reverse test))) commandArgs)
                    netpath = buildString(test_dir "/" )
                    form->netlistPath->value = strcat("/" netpath)
                  )

    to either check for the path beginning with "/" or to maybe use simplifyFilename. At the moment it is just blindly prepending the path of the set up file to the beginning of the netlist path. If your requirements are different than that, you'll need to write code to perform that different behaviour.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to Andrew Beckett

    Thanks Andrew,
    Is there any command in skill to check whether the path begins with "/"  like pattern matching.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    These two amongst others:

    ; because of a bug in the forums, I can't paste code calling the right function. So I used specialFunction instead. It should be a function
    ; which is a single word that begins with "sub" and ends in "string" - I just can't enter "substring"
    specialFunction(setup_file_path 1 1)=="/"

    pcreMatchp("^/" setup_file_path)

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to Andrew Beckett

    Ah, turns out that it does allow me to use "substring" in quotes. That's the function name I meant to use where specialFunction was. Sorry, if I use the correct function name directly, the forum posting gives an error.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to Andrew Beckett

    Thank you Andrew :}}

    • 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