• 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 determine the direction of a wire out of a symbol...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 144
  • Views 16018
  • 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 determine the direction of a wire out of a symbol pin in schematic

Michele Ancis
Michele Ancis over 9 years ago

Hi,

I would like to write some SKILL to add wire stubs and labels to a certain symbol instantiated and selected in a schematic cellView.

I think I have the basics in place, i.e. reference to a selected cellView with geGetSelectedSet() and then dig into its instTerms and

from there to each instTerm~>term~>pins~>fig~>bBox, then transform it to the bBox relative to the cellview with dbTransformBBox()

basically:

cv = geGetSelSet()

foreach(instTerm cv~>instTerms

instTermBbox=car(instTerm~>term~>pins~>fig~>bBox)
instTermBboxInCv=dbTransformBBox(instTermBbox
                           car(inst~>transform))

)

code might need some polishing, especially when extracting the right item from the list returned by - for  instance - inst~>transform or ...~>bBox.

So from here, I can use schCreateWire() and schCreateLabel() to add a wire and label.

The point where I'm puzzled is: how to determine the direction of the wire? How do I determine the position of the pin within the shape?
I am thinking of using the symbol's bBox to infer whether the pin is on its top, bottom, left or right side, however when I query the bBox of the selected shape, I get something weird.

I have placed a single vcvs on an otherwise empty schematic. I select it in the window, and then call cv = geGetSelSet().

cv~>bBox returns the following:

(((-0.48125 -0.2125)
(0.91875 0.26875)
)

The strange thing about this bBox is that the y coords (I'm assuming they are the second elements in each tuple) are more or less correct, i.e. they correspond roughly to the bottom and top pin extremes, whereas the the x coords are further away from the boundaries of the symbol.

So I'm wondering what this means and how to interpret it.

Thanks for any help,

Michele

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Hi Michele,

    Here's a snippet of some code I've used to determine which edge the pin is on (it doesn't have a prefix, because it was a local function in a SKILL++ source file, so adjust it to suit your needs):

        /***************************************************************
        *                                                              *
        *                   (getClosestEdge xy bBox)                   *
        *                                                              *
        *  INTERNAL function to return one of the symbols left, right  *
        *   bottom or top to indicate whether the specified point is   *
        *  closest to which edge - given a bBox of the symbol - prior  *
        *  to adding pins or labels. Helpful to determine orientation  *
        *                       of labels, etc.                        *
        *                                                              *
        ***************************************************************/
        (defun getClosestEdge (xy bBox)
          (let (edgeData distances)
            (setq edgeData
                  (list
                    (list (xCoord (lowerLeft bBox)) (xCoord xy) 'left)
                    (list (yCoord (lowerLeft bBox)) (yCoord xy) 'bottom)
                    (list (xCoord (upperRight bBox)) (xCoord xy) 'right)
                    (list (yCoord (upperRight bBox)) (yCoord xy) 'top)
                    ))
            (setq distances 
                  (foreach mapcar edge edgeData
                           (list (abs (difference (car edge) (cadr edge)))
                                 (caddr edge))))
            (cadar (sortcar distances 'lessp))
            )
          )

    The bBox could be the bBox of the symbol, but the problem is that this is skewed by any labels that are in the symbol - remember the bBox is the overall bBox. The xy was the centerBox() of the bBox of each pin. Once you know which side it's on, you can determine which direction to draw the stub, and which orientation to use for labels, etc.

    So what I have done before is look for the bBox of the "instance" layer on the symbol. Here's some code that does that (and falls back to the bBox if there is no instance layer):

            /******************************************************************
            *                                                                 *
            *                      (findSymbolBBox inst)                      *
            *                                                                 *
            *  Internal function to find the bbox of an instance, using the   *
            * instance layer if it exists - this produces a better box  - the *
            *             selection box - than the overall bbox.              *
            *                                                                 *
            ******************************************************************/
            (defun findSymbolBBox (inst)
              (let (master shapes instBox bBox)
                (setq master (getq inst master))
                (setq shapes
                      (getq 
                        (car (exists LP (getq master lpps)
                                     (and
                                       (equal (getq LP layerName) "instance")
                                       (equal (getq LP purpose) "drawing")
                                       )))
                        shapes))
                (if shapes
                  (progn
                    (setq instBox (getq (car shapes) bBox))
                    (foreach shape (cadr shapes)
                             (setq bBox (getq shape bBox))
                             (setq instBox
                                   (list
                                     (list 
                                       (min (xCoord (lowerLeft instBox))
                                            (xCoord (lowerLeft bBox)))
                                       (min (yCoord (lowerLeft instBox))
                                            (yCoord (lowerLeft bBox)))
                                       )
                                     (list 
                                       (max (xCoord (upperRight instBox))
                                            (xCoord (upperRight bBox)))
                                       (max (yCoord (upperRight instBox))
                                            (yCoord (upperRight bBox)))
                                       )
                                     ))
                             ) ; foreach shape
                    (setq instBox (dbTransformBBox instBox (getq inst transform)))
                    ) ; progn
                  (setq instBox (getq inst bBox))
                  ) ; if shapes
                instBox
                ) ; let
              ) ; defun findSymbolBBox

    Something like that would do, anyway! (the code above was hacked to remove some irrelevant feature which just confused matters, so hopefully it still works)

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Michele Ancis
    Michele Ancis over 9 years ago
    Thanks Andrew!
    I can certainly work on this basis :-)

    Regards,
    Michele
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • fatcat1206
    fatcat1206 over 9 years ago
    Hi Michele

    I also wrote a piece of code to create the stub, exactly like yours.
    I hope you have implemented the code.

    Here I'd like to mention that, inside cadence, there is already an API to do it.

    schHiCreateWireStubs()

    And instead of only selecting the instance, you can also select the pins for creating the stub.

    Best Regards

    Yi
    • 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