• 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 call a function in a pcDefinePcell

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 143
  • Views 4974
  • 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 call a function in a pcDefinePcell

LorinLiu
LorinLiu over 1 year ago

Hi,

I create a Multi-layer Pcell by calculating the coordinates. The function of calculating the coordinates is so long that the whole code of generating pcell will also be long. So I want to create a function which can calculate these coordinates, and I just need to call this function whenever and wherever I want to calculating these coordinates. Here is the problem, I define this function by using defun(), if I put the  function outside pcDefinePcell, after running DRC, the report says the calculating function that I create is not defined. If I put these function inside pcDefinePcell, the pcell shows one more layer which is "marker error" which is explained as "function .... redefined". I want to know how to figure this problem? thx.

  • Cancel
  • LorinLiu
    LorinLiu over 1 year ago

    procedure(coordinate_O_function(Width Length Corner) let(() scale = 1.0e6 ; Define the layers w = evalstring(Width ) * scale l = evalstring(Length) * scale cor = evalstring(Corner) * scale x = 0 y = 0 a = w/2 - cor b = l/2 c = w/2 d = l/2 - cor p1 = list(x+a y+b) p2 = list(x+c y+d) p3 = list(x+c -(y+d)) p4 = list(x+a -(y+b)) p5 = list(-(x+a) -(y+b)) p6 = list(-(x+c) -(y+d)) p7 = list(-(x+c) y+d) p8 = list(-(x+a) y+b) ) )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • p94todorov
    p94todorov over 1 year ago

    Hi Lorin,

    when you define a function outside of the pCell body, you need to load it to your environment, usually from the libInit.il file for your given library. If you are doing a PDK-related work it is best to add all external functions in a separate context file.

    In case you need a particular function to sit within the pcDefinePCell body, then you can do it by defining a lambda function anywhere within the variable scope:

    pcDefinePCell(l_cellInffo ( ... pCellParams...)

        let((pcellVars)

        ...

        putd('myFuncName lambda((funcParams)

            let((funcVars)

                ... function body ...

            );let

         ));myFuncName

         ....

         myFuncName(param1 param2 ...)

         ....

    );pcDefinePCell

         

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to p94todorov

    I would recommend using the libInit.il approach rather than using putd() within the pcDefinePCell body.

    By the way LorinLiu, I would suggest you use cdfParseFloatString() rather than evalstring() in your code to convert to numbers, because you don't want to have the fun of somebody entering "(exit)" as the value of Width...

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • LorinLiu
    LorinLiu over 1 year ago in reply to Andrew Beckett

    Thank you Andrew for the response and advice. I will try libInit.il approach later and replace evalstring() with cdfParseFloatString() .

    But I still want to know what happened to this procedure. I have loaded this function to my environment. When I run DRC, it still reports "undefined function". But I can execute this function alone. Why?   body of pcDefinePcell

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to LorinLiu

    Because for DRC you are (presumably, you didn't say which tool you're using) doing a stream out (GDS) of the layout and that's done as an external process. Any code you load in the CIW won't be seen.

    This is why the suggestion is to put the code in (or load it from) the libInit.il in the library containing the PCell. If you do this, it will be loaded during stream out and the function would then be defined.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • LorinLiu
    LorinLiu over 1 year ago in reply to Andrew Beckett

    The DRC tool I use is Calibre. So Calibre won't see the function that I load to the CIW? CIW belongs to Cadence. I see. I will take your advice, Andrew. Thanks a lot. I am a beginner to skill. Thanks again!

    Regards,

    Lorin

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to LorinLiu

    Hi Lorin,

    Calibre itself is not reading SKILL, but the first step it runs is to export a stream (GDS) file (essentially the same as using File→Export→Stream) and that's a background process. It's still a Cadence executable, but because it's not in the same process as Virtuoso it doesn't see functions that are in Virtuoso's memory (i.e. what you loaded in the CIW).

    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