• 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 use variable in defcell

Stats

  • Replies 9
  • Subscribers 151
  • Views 550
  • Members are here 0

how to use variable in defcell

MorrisDH
MorrisDH 1 month ago

I am open to suggestions if there is a better way to create a symbol cellview but the following is what I am using.

defcell("realCellName" defSymbol( nil ) )

It works fine for a basic symbol with no pins which is all I need. It creates a symbol cellview under the cell "realCellName".

The following does not work as expected.

cellName = "realCellName"

defcell(cellName defSymbol( nil ))

It creates a new cell named "cellName" instead of parsing the variable. Is it not possible for defcell to recognize variables?

Or maybe there is a better way to create simple symbol cellviews.

Thanks

  • Sign in to reply
  • Cancel

Top Replies

  • Andrew Beckett
    Andrew Beckett 1 month ago +1
    No, the documentation makes it clear that this must be a literal string. It's not a SKILL function - it's a definition using an s-expression within a TSG file. You could of course template it yourself…
  • Andrew Beckett
    Andrew Beckett 29 days ago in reply to MorrisDH +1
    MorrisDH said: Apparently dbOpenCellViewByType(testLibName testCellName "symbol" "schematicSymbol" "w") creates a cellview call "symbol" but it is an empty cellview Of course. Why would it do anything…
  • Andrew Beckett
    Andrew Beckett 29 days ago in reply to MorrisDH +1
    That's because you have defsymbol( nil ) . The nil is unexpected and hence incorrect. If you just have defsymbol( ) then it wouldn't have this issue. Andrew
Parents
  • Andrew Beckett
    Andrew Beckett 1 month ago

    No, the documentation makes it clear that this must be a literal string. It's not a SKILL function - it's a definition using an s-expression within a TSG file.

    You could of course template it yourself using something like this:

    let(((tsgFile "myfile.tsg") tsgPort cellName tsgTemplate)
      cellName="realCellName"
      tsgPort=outfile(tsgFile)
      tsgTemplate=`defcell(,cellName defSymbol( nil ))
      pprint(tsgTemplate tsgPort)
      newline(tsgPort)
      close(tsgPort)
      ;(tsgFile)
    )

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett 1 month ago

    No, the documentation makes it clear that this must be a literal string. It's not a SKILL function - it's a definition using an s-expression within a TSG file.

    You could of course template it yourself using something like this:

    let(((tsgFile "myfile.tsg") tsgPort cellName tsgTemplate)
      cellName="realCellName"
      tsgPort=outfile(tsgFile)
      tsgTemplate=`defcell(,cellName defSymbol( nil ))
      pprint(tsgTemplate tsgPort)
      newline(tsgPort)
      close(tsgPort)
      ;(tsgFile)
    )

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
  • MorrisDH
    MorrisDH 30 days ago in reply to Andrew Beckett

    Interesting, I found the defcell function is a script I wrote years ago to create symbols. And yes, it writes a file, then loads it to generate the symbols. I'd forgotten why I'd done it that way.

    There must be a better/alternative way to create a symbol without depending on writing to a file.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MorrisDH
    MorrisDH 30 days ago in reply to MorrisDH

     dbOpenCellViewByType seems to work fine. I'd tried it before but it returned error because cellview did not exist. I had to specify "w" and not "r" for it to work.

    However, I still get error with dbSave and dbClose on the symbol

    symbolID = dbOpenCellViewByType(testLibName testCellName "symbol" "schematicSymbol" "w")
    dbSave(symbolId)
    dbClose(symbolId)

    *Error* dbSave: argument #1 should be a database object (type template = "dggggg") - nil

    The dbSave and dbClose work with layout and schematic views. But I get the above error with symbol views.



    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MorrisDH
    MorrisDH 30 days ago in reply to MorrisDH

    Typo. Switched letter "D" to "d".

    It's all good now.

    problem solved.

    Thanks,

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MorrisDH
    MorrisDH 30 days ago in reply to MorrisDH

    Apparently dbOpenCellViewByType(testLibName testCellName "symbol" "schematicSymbol" "w") creates a cellview call "symbol" but it is an empty cellview.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 29 days ago in reply to MorrisDH
    MorrisDH said:
    Apparently dbOpenCellViewByType(testLibName testCellName "symbol" "schematicSymbol" "w") creates a cellview call "symbol" but it is an empty cellview

    Of course. Why would it do anything else? How would it know what the content was, given that all you did was open the cellVIew in write (which means overwrite) mode? You could also use "a" which would create if it didn't exist, but leave the existing contents.

    If you are wanting an alternative to tsg() (text-to-symbol generator - I see no problem with the fact that it needs a file as input), you could use the schViewToView functionality, particularly schPinListToSymbol - there you can give info on the pins and it will construct a tsg-like symbol using the current tsg template (which can be set with the schematic tsgTemplateType cdsenv var, with the name-to-file mapping being controlled via the tsgTemplateMasters SKILL variable - search in the documentation for more details). You can also use schSchemToPinList to get a pin list from a schematic. Overall this approach has less flexibility than everything that tsg() offers, but it's usually sufficient...

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • MorrisDH
    MorrisDH 29 days ago in reply to Andrew Beckett

    Yep. I went back to the template. I'd actually done something similar in a script I wrote a few years ago. I'd forgotten all about it.

    Appreciate your patient assistance.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MorrisDH
    MorrisDH 29 days ago in reply to Andrew Beckett

    Created this procedure based on the template. 

    procedure( makeTheSymbol(@key cellName libName)
      let(((tsgFile "myfile.tsg") tsgPort tsgTemplate)
        tsgPort=outfile(tsgFile)
        tsgTemplate=`defcell(,cellName defsymbol( nil ))
        pprint(tsgTemplate tsgPort)
        newline(tsgPort)
        close(tsgPort)
        lmOpenLib(libName)
        load(tsgFile)
      ) ; let
    ) ; procedure

    It appears to work perfectly but I do get a warning.

    *WARNING* TSG: Invalid identifier

    Is that something I should be concerned about?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 29 days ago in reply to MorrisDH

    That's because you have defsymbol( nil ) . The nil is unexpected and hence incorrect. If you just have defsymbol( ) then it wouldn't have this issue.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • 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.

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

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