• 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 access pcell instance co-ordinates from within Pcell...

Stats

  • Locked Locked
  • Replies 11
  • Subscribers 143
  • Views 18126
  • 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 access pcell instance co-ordinates from within Pcell code.

Jameel
Jameel over 14 years ago
Hi, Is there a way to find out the co-ordinates of the pcell instance from within the pcell code? Say for example, I want to create a pcell that prints a label showing the co-ordinates of the where the pcell is placed. within the code of the pcell I can create the label at the origin but i need to know the co-ordinates of the pcell instance in order to print the label. One way of doing this would be to pass the co-ordinate of the pcell instance as parameters, but am not sure if this is the correct way to do it. Thanks, -Jameel
  • Cancel
  • dmay
    dmay over 14 years ago

    Create a label inside the pcell code where:

    labelType = "ILLabel"
    and
    theLabel = sprintf(nil "%P" ilInst~>xy)

    This is a skill label that is interpreted on the instance. The ilInst will resolve to the actual instance placed. The ILLabel will evaluate the given Skill and display its result on the placed instance.

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 14 years ago

    Hi Jameel,

    Your question is a little imprecise, what do you mean by "co-ordinates" of the pcell instance, the bounding box co-ordinates, or the origin?

    Hopefully Derek's answer solves the problem, but if you were looking for the bounding box, you could access ilInst~>bBox instead, for example.

    The problem is that within the PCell itself, it knows its own origin as 0,0 but the instance origin could be anywhere when the pcell instance is placed, however the pcell (master/supermaster) has no knowledge of the "parent" cellview where it is being placed. Likewise for the cell's bounding box - within the cell's coordinate system it will be one thing, but when placed in a cellview, the instance's transform needs to be taken into consideration.

    I think Derek's answer should answer your question though.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jameel
    Jameel over 14 years ago
    Thanks Derek, it worked!
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jameel
    Jameel over 14 years ago

    Hi  Lawrence, Derek,

    Below is a simple pcell that I built  using your input. When I load it up I get this error - *Error* eval: unbound variable - ilInst

    Do you know what's wrong?

    Thanks,

    -Jameel

     

     

     

     

     

     

     

    pcDefinePCell(
    ; Identify the target cellview.
        list(ddGetObj("test") "PCELL_TEST" "layout")
        ; Declare formal parameter name-value pairs.
        (
            (layer "RDL") ;;
        )
        let(() ;; Define the contents of the cellview.
            dbCreateLabel(
                pcCellView ;; cellview label appears in
                list("TEXT" "drawing") ;; layer on which label appears
                (0:0) ;; where label appears
                sprintf(nil "special point = %P" ilInst~>xy) ;; label text
                "centerCenter" ;; label justification
                "R0" ;; label orientation
                "stick" ;; font
                10.0 ;; height for the label
            )
        ) ;; let
    ) ;; pcDefinePCell

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 14 years ago

    Hi Jameel,

    I had a quick play and the label needs to contain the expression to evaluate, something like the following:

            lab=dbCreateLabel(
                pcCellView ;; cellview label appears in
                list("text" "drawing") ;; layer on which label appears
                (0:0) ;; where label appears
                "car(ilInst~>xy)" ;; label text
                "centerCenter" ;; label justification
                "R0" ;; label orientation
                "stick" ;; font
                1.0 ;; height for the label
            )
    	lab~>labelType="ILLabel"
    

    Now, when I set the label to something like "ilInst~>name" the instance names seemed to show just fine (e.g. "I1"), but with the label as "ilInst~>xy" it did not show any value.  I'm not quite sure why, but if the label looked like a list (e.g. the origin point) or something other than a single number or single name, it did not show.  I have not got time to look into this any further, but the above is a partial solution, so if nothing else, perhaps two separate labels could be created, one for the x value and one for the y?

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Lawrence, Jameel,

    The problem with the original code is that it was accessing the variable ilInst directly in the pcell code. This makes no sense because:

    a) ilInst is only set as evaluated labels are evaluated and the displayed
    b) the pcell has no knowledge of the instance that instantiates it - this is obvious when you realise that you could have many instances of the same variant; the pcell only gets evaluated once (it would be very inefficient otherwise).

    Normally the label display functions need to return an atomic (often a string) value.

    So you'd need to make the label:

       label=dbCreateLabel(
                pcCellView ;; cellview label appears in
                list("TEXT" "drawing") ;; layer on which label appears
                (0:0) ;; where label appears
    "sprintf(nil \"special point = %P\" ilInst~>xy)"
                "centerCenter" ;; label justification
              "R0" ;; label orientation
                "stick" ;; font
                10.0 ;; height for the label
            )
    label~>labelType="ILLabel"

    That way the sprintf is the expression evaluated during label display.

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jameel
    Jameel over 14 years ago

    Thanks this works great!

     

    On a different note, I am having trouble streaming out a datbase containing an instance of a pcell. I get the following error when I try to stream out. The pcell works great in layout view.

    \o *WARNING* Pcell evaluation for NQ78Z/encapRodPcell/layout has the following error(s):
    \o *WARNING* ("eval" 0 t nil ("*Error* eval: undefined function" CCScreateBoxAndLabels))
    \o *WARNING* Error kept in "errorDesc" property of the label "pcellEvalFailed" on layer/purpose "marker/error" in the submaster.

     

    Here is the pcell code I am working with.....

    procedure(CCScreateBoxAndLabels(cv w l "dnn")
      let( (rectRodObj)
      ;; create a rectangle on metal1 with x & y dimensions set by w & l
      rectRodObj = rodCreateRect(
          ?name     "myRect"
          ?cvId     cv
          ?layer    list("PI" "drawing")
          ?width    w
          ?length   l
          ?origin   list(0 0)
      )
      ); let
    ); procedure CCScreateBoxAndLabels

    ;; Create the PCell, the "drawing routine" is encapsulated in the
    ;; CCScreateBoxAndLabels function which does all the work

    pcDefinePCell(
      list(ddGetObj("NQ78Z") "encapRodPcell" "layout")
      (
        (w 1.0)
        (l 0.6)
      )
      let( ((cv pcCellView))
        CCScreateBoxAndLabels(cv w l)
      ); let
    )

    ;; Create the CDF for the 'l' and 'w' parameters, the width (w)
    ;; parameter is either hidden or displayed but not editable.
    let( (cellId cdfId)
      when(cellId = ddGetObj("NQ78Z" "encapRodPcell")
        ;; if the cell CDF already exists, delete it
        when( cdfId = cdfGetBaseCellCDF(cellId)
          cdfDeleteCDF(cdfId)
        )
        ;; create the base cell CDF
        cdfId = cdfCreateBaseCellCDF(cellId)
        ;; create the parameters
        cdfCreateParam( cdfId
          ?name     "l"
          ?prompt   "Length"
          ?defValue 0.6
          ?type     "float"
          ?display  "t"
        )
        cdfCreateParam( cdfId
          ?name     "w"
          ?prompt   "Width"
          ?defValue 1.0
          ?type     "float"
          ;; comment out the next line and uncomment the lines below
          ;; it if the parameter is to be visible but not editable
          ?display  "nil"
    ;      ?display "t"
    ;      ?editable        "nil"
        )
        cdfSaveCDF(cdfId)
      ); when
    ); let for CDF creation 

     

     

     

     

    I tried may other simple pcell examples but keep getting the perror at stream out. I am loading the above pcell code when icfb starts up through .cdsinit.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago

    Jameel,

    A few things:

    1. The code for the pcell itself (i.e. the body of the pcDefinePCell) does not need to be loaded each time - in fact if another user is using it, they probably wouldn't have write permission to redefine the pcell every time. The code for the body of the pcDefinePCell is stored within the pcell's view on disk.
    2. Similarly you would not want to define the CDF each time - that's also stored permanently.
    3. Any auxilliary functions you call from the body of your pcell (e.g.CCScreateBoxAndLabels) do however need loading each time the session starts - because these are not stored within the pcell view itself.
    4. So you should probably put the pcDefinePCell calls and CDF definition either in a separate file, or surround it in a procedure definition:
      procedure(MYdefinePCellsAndCDF()
        pcDefinePCell(...)
        let(... ; define CDF
        )
      )

      and then call MYdefinePCellsAndCDF whenever you want to redefine the pcells
    5. It's better to load the auxilliary functions from the libInit.il within the library containing the pcells (NQ78Z in this case). The libInit.il will get loaded the first time the library gets accessed - either within virtuoso itself or within the background stream out process. pipo/strmout (depending on the version you're using) does not load the .cdsinit file - hence the problem with the function not being defined.

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Jameel
    Jameel over 14 years ago

    Andrew,

    Your suggestion  worked very well ,Thanks!

    As an experimtnt I also tried the following.

    moved the pcDefinePCell and CDF definition to a new file test1.il and auxillary function iCCScreateBoxAndLabels in t2.il

    First time, I started cadence and loaded t2.il manually, then loaded t1.il . The pcells were now created properly and I was able to instantiate them ok.

     

    I then closed cadence and added load t2.il in my .cdsinit file and started cadence. Again I was able to looat the pcell instances without problem.

     

     

    However when I tried to stream out again I get the same undefined function error. It looks like the strem out process doesnot read the .cdsinit file, is that correct? Also, it looks like strmout started from cadence does not see the auxillary function even if that function was manually loaded. 

     

    Thanks,

    -Jamele

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Jameel,

    Did you not read what I said in my last reply? I stated that pipo/strmout (the background process that does the GDS writing) does not read the .cdsinit.

    I suggested that you have a libInit.il inside the library containing the pcell; this is then loaded the first time the library is accessed - whether that is in virtuoso (or icfb) or pipo/strmout (or indeed any other application that accesses the library).

    There is a way of passing a user defined SKILL file to the stream process, but libInit.il is the cleanest and best way of doing this.

    Regards,

    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