• 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. Is there a way to give a procedure access to it's argument...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 1784
  • 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

Is there a way to give a procedure access to it's argument list as a string?

CADcasualty
CADcasualty over 4 years ago

Say I have something like:

var1=vector(1 2 "abc" 3 4)

var2=vector("x" "y" "z")

and I define a procedure like:

procedure( myProc(arg1 arg2])
  ...blah...)

and I call the procedure with 

myVar = myProc(var1 var2[1])

Is there any way to give the procedure access to the actual text of the arguments it was called with i.e. for the above example I'd like the procedure to be able to pick apart the string "arg1 arg2[1]". The reason I want to be able to do this is that I'd like the procedure to be able to peek into other elements of var2 even though it was only passed a specific element of it. Thanks!

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    I'm not convinced this is a good idea, because it would be quite disturbing to a reader of the code - it would be hard for the user to know that the code had this unusual side effect simply by seeing the code. Wouldn't it be better to make your function take arguments arg1 arg2 index2 and then inside you can access arg2[index]?

    Anyway, if you really want to do this, you can use a macro - for example:

    procedure(myProcReal(arg1 arg2 arg1Code arg2Code)
        printf("%L = %L\n" arg1Code arg1)
        printf("%L = %L\n" arg2Code arg2)
    )
    
    defmacro(myProc (arg1 arg2)
        `myProcReal(,arg1 ,arg2 ',arg1 ',arg2)
    )
    
    var1=vector(1 2 "abc" 3 4)
    var2=vector("x" "y" "z")
    myVar = myProc(var1 var2[1])
    

    This outputs:

    var1 = array@0x20e8038
    var2[1] = "y"

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • CADcasualty
    CADcasualty over 4 years ago in reply to Andrew Beckett

    Yea - that code is beyond my skill level (a pun you're likely completely sick of by now). In order to not over burden you, I find myself framing my question in the simplest possible way but upon reading your answer feel I maybe should have not obfuscated my actual intent (which would have extended the scope of the initial question into something like "how do I go about architecting my code to do this?"). I need to ponder rewriting my code a bit before responding further. Many thanks as always for your rapid and precise answer.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to CADcasualty

    I probably should have given a bit of explanation. Essentially a normal procedure has all of its arguments evaluated before it is called, so it can't see the literal arguments. There is a "nlambda" procedure, but use of that is discouraged (it doesn't play nicely with SKILL++). So the best approach is a macro - macros get evaluated early, and can see the code passed to the macro without evaluation. So all this macro does is convert the two arguments to directly pass through to an underlying function, plus quoting the code from each argument so that the underlying function sees the code too.

    However, as I said, you probably don't want to do that ;-)

    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