• 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 reuse code already written ?

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 13606
  • 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 reuse code already written ?

MalcolmWhite
MalcolmWhite over 6 years ago

I'm wondering how to use what I think is called "code-branching" to use another procedure I've already written so I don't have to keep

pasting the code again into whatever I'm using now for some specific function. So say for example i have:

procedure( changeShapeTometal2()

   selectedSet()~>layerName="M2"

)

and I have attached that to a bindkey which I use once in a while when the need calls for it.  But now I'm working and I find another

thing that I can automate which will speed up my work, I need to do something like this:

procedure( makeShapesStretchToLeftEdge()

   foreach(shape selectedSet()

       shape~>bBox=list(0:yCoord(car(shape~>bBox)) cadr(shape~>bBox) )

  )

so after the spot where I change the bBox to be at X=0 I want to change all those shapes to M2,  I don't want to add the code to change

the layerName because I already have that written some where , it would make sense to me to just add the procedure call and then

return to where I was,  Do I need to do anything to the original procedure which changes the layerName so once that branch is done it

returns to the code where I am stretching to the left Edge?

Thanks.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    I'm a bit mystified by this question. It's just a matter of calling the function:

    procedure( makeShapesStretchToLeftEdge()
       foreach(shape selectedSet()
           shape~>bBox=list(0:yCoord(car(shape~>bBox)) cadr(shape~>bBox) )
      )
      changeShapeTometal2()
      ; you could now add more code here to do something else too
    )

    The whole point of a function is that it returns to where you were after you call it.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MalcolmWhite
    MalcolmWhite over 6 years ago in reply to Andrew Beckett

    Hi Andrew - ok - thanks for answering that question - I was asking if perhaps , as an example, to the second code which changes layer I would have to add a line at the end like return() or some such call to make the branch resume at the first code which stretches shapes to the left edge. Apparently what you are saying, is that skill understands somehow the branch is done and it can resume the first code. ( the second function runs to completion before anything else in the primary procedure resumes ).  Sorry, I realize it's kinda simplistic, but I don't want code from one function to continue before code from the second procedure completes.  I also wanted to make sure the invocation of a procedure from within a procedure the flow returns to the line exactly after the invocation.  I appreciate your time to answer this.  Regards. Malcolm

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to MalcolmWhite

    The return() function is only ever used in SKILL inside a prog() call, and it's to allow you to return from anywhere within that prog() function. Since SKILL is a functional language, everything in SKILL is a function, and the general convention is  that the return value of a function is the last thing computed in the body of a block of code (e.g. a procedure). So if you do:

    procedure(addNums(a b)
      printf("TWO NUMBERS ARE %N %N\n" a b)
      a+b
    )

    Then if you do c=addNums(3 4) then c will be set to 7.

    SKILL is single-threaded, so you don't need to worry about a function continuing before the other function returns. I suspect you're over-thinking this!

    Kind 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