• 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. Are there SKILL functions to modify cds.lib?

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 10517
  • 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

Are there SKILL functions to modify cds.lib?

MorrisDH
MorrisDH over 3 years ago

I am using shell commands to modify cds.lib because I've not found a skill command that will do this.

Add a library

shell("echo DEFINE myLib /path/to/myLib >> cds.lib")

ddUpdateLibList()

Delete a library

shell("cat cds.lib | grep -v myLib >> xx ; mv xx cds.lib")

ddUpdateLibList

Is there a SKILL funtion that will add or remove libraries from cds.lib?

  • Cancel
  • AurelBuche
    AurelBuche over 3 years ago

    Hi, I don't think there is any public function to do so

    Even in Cadence support articles, they use system calls How to work with an modified/updated cds.lib file within a SKILL script?

    You might delete in a more elegant way using sed (or in a safer way by adding UNDEFINE in your cds.lib) though

    Cheers

    Aurélien

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

    To add a library to the cds.lib, you can just use ddCreateLib - if the library directory already exists, all this does is add it to the cds.lib

    I don't believe there's a function just to remove an entry from the cds.lib (simplest is to concatenate an UNDEFINE statement to the end). The ddDeleteObj function will remove it, but it also removes the library from disk which you probably don't want.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MorrisDH
    MorrisDH over 3 years ago in reply to AurelBuche

    Not sure how to duplicate the functionality in sed. I like the UNDEFINE suggestion. Thanks,

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

    Hi Morris,

    I did such thing long time ago, but i forgot where i put it, so a have re-did it for you.

    See below the function lib2 comment that use sed (stream editor ) as Aurel suggested. Although one can imagine a pure skill function that read cds.lib parse it and change the library pattern. I show you also an example if you use relative path to a global variable $PRJ_DIR for instance.

    There is an example with "grep -q " that checks if the string is allready in the cds.lib to put it in. Although, if you want to create a library, within cadence, you need to use the skill function dbCreateLib.

    _______________

    ;ddSetForcedLib("");=> Forece reference cds.lib to be ./cds.lib if not
    
    defun(lib2comment (@optional (toinclude "DEFINE libA ./path/libA") (AA "")(BB "#") (cdslib "./cds.lib") (verb nil))
    let((cmd fp)
    cmd=strcat("cat " cdslib " |sed -e " "\"s,^" AA toinclude "," BB toinclude ",\" > ./tmp; mv ./tmp " cdslib)
    fp=outfile("./toScript.sh") fprintf(fp "%s" cmd) close(fp)
    when(verb  sh("cat ./toScript.sh"))
    sh("./toScript.sh ")
    ))
    
    lib2comment("DEFINE libB ./path/libB" "" "#"); => pattern does not exist => nothing commented
    lib2comment("DEFINE libA ./path/libA" "" "#"); => comment
    lib2comment("DEFINE libA ./path/libA" "#" ""); => uncomment
    lib2comment("INCLUDE \\$PRJ_DIR/project.lib" "#" "")
    lib2comment("INCLUDE \\$PRJ_DIR/project.lib" "" "#")
    sh("cat ./cds.lib")
    
    ;(setq cdslib "./cds.lib")
    
    defun(lib2add (@optional (toinclude "DEFINE libA ./path/libA") (cdslib "./cds.lib") (verb nil))
    let((cmd fp)
    cmd=strcat("if (! grep -q \"" toinclude "\" " cdslib "); then echo APPEND in cds.lib; echo " toinclude " >> "  cdslib "; else echo ALLREADY in cds.lib;fi ")
    fp=outfile("./toScript.sh") fprintf(fp "%s" cmd) close(fp)
    when(verb sh("cat ./toScript.sh"))
    sh("./toScript.sh")
    ))
    
    lib2add("DEFINE libB ./path/libB" "./cds.lib" t);=> nil
    sh("cat ./cds.lib")
    lib2comment("DEFINE libB ./path/libB" "" "#")
    __________________

    Hope it helps

    ++

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MorrisDH
    MorrisDH over 3 years ago in reply to ebecheto

    Hi ebecheto, Your solution is far more flexible than what I need. For my usage the library name and location will be the same always.  I will run your example out of curiosity and to see the generated sed command but my final solution will definitely be much simpler.

    Thanks,

    • 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