• 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. Having procedure describe the file in which it was generated...

Stats

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

Having procedure describe the file in which it was generated.

liorscotland
liorscotland over 7 years ago

Hello all.

We have several files, with several definitions for procedures.

We'd like to have a procedure called, and automatically describe which file is it called from.

I have tried to use macros, and write this:

( defmacro procedure_debug ( @rest all_argsy )
  ( printf "The proc name %s is defined in file%s:\n" ( car ( car ,all_argsy ) )
( apply 'simplifyFilename '( #.get_filename( piport ) ) ) )
  ( apply 'procedure ,all_argsy )
)

The issue is that it keeps reporting the file in which the macro was defined, and not where the procedure was defined...

Any ideas? I have thought that the macro expansion would get the trick.
And if anyone know how to rename procedure in SKILL++ to something else, and have my macro replace it, that would be even better.

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Hi Lior,

    First of all, if the code is loaded with "debugMode" enabled (sstatus "debugMode" t) then you can do:

    whereIs(myFunc)

    and it will tell you where it was defined (it stores some properties on the symbol for the function name to record that, but only when debug mode is enabled).

    Your macro is a bit odd. Normally you wouldn't use apply within a macro - and the read-time eval # operator is read very early - when the file is read, so surrounding it in a macro is not going to help, as it's already expanded at the time the file containing the macro is read.

    If you use this though:

    (defmacro procedure_debug ( @rest all_argsy )
      `(progn
         (printf "The proc name %s is defined in file %s\n"
    	     ',(caar all_argsy)
    	     (get_filename piport))
         (procedure ,@all_argsy)
         )
      )

    That should work.

    Renaming the procedure isn't going to do what you want I don't think (and you can't really do that anyway - you can have a local function with the same name as a global function in SKILL++ and that will mask the global function, but the trouble is that this really  only works for lambda functions, not macros or syntax forms).

    Regards,

    Andrew.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • liorscotland
    liorscotland over 7 years ago in reply to Andrew Beckett

    Hi Andrew.
    I was just about to reply that I got this working, like what you have suggested.
    And yes, it would appear that the debug is a better approach. Is there a course in these advanced subjects? I also found little explanation on the #. syntax form. Can you provide a link to explanation? I, in fact, would suggest SKILL Advanced course 2, which is the level after the Advanced course. The reason I have asked for the rename, because it is one of TCL's more powerful features. One could rename any procedure, and setup a different procedure to wrap it. I guess I found 1 point where TCL seems to be more powerful than scheme/SKILL++. It is usually the reverse.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • liorscotland
    liorscotland over 7 years ago in reply to Andrew Beckett

    Hi Andrew.
    I was just about to reply that I got this working, like what you have suggested.
    And yes, it would appear that the debug is a better approach. Is there a course in these advanced subjects? I also found little explanation on the #. syntax form. Can you provide a link to explanation? I, in fact, would suggest SKILL Advanced course 2, which is the level after the Advanced course. The reason I have asked for the rename, because it is one of TCL's more powerful features. One could rename any procedure, and setup a different procedure to wrap it. I guess I found 1 point where TCL seems to be more powerful than scheme/SKILL++. It is usually the reverse.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to liorscotland

    Hi Lior,

    The read-time eval was documented as a result of your case 46018509 (CCR 1619877) and is documented from IC617 ISR7 onwards in the Advanced Topics chapter of the SKILL Language User Guide.

    It is possible to rename a function implemented in SKILL - just not one that is implemented at the C level. As I said, you can mask any function (whether it's implemented in SKILL or C) using a lexically scoped function in SKILL++ but I think doing this for a syntax form such as procedure isn't really possible. Even renaming functions at the SKILL level when you can do it should be done very cautiously as you can then break things very easily (I certainly would never want to do it for anything as fundamental as procedure even if I could). You can use getd to get hold of the existing function object, and then putd to store a new one - or you can just define a new procedure which then calls the original one.

    Here's an example of doing the SKILL++ lexically scoped mask of a function - I'm locally defining arrayref to allow an auto-allocating hash table to support multi-dimensions without declaring in advance (note, this would need to be in a file with .ils suffix). This wouldn't work for procedure because you'd really need local macro support (e.g. using macrolet, which doesn't exist in SKILL) to do it.

    let((a)
     flet(((arrayref (arr ind) arr[ind] || (arr[ind]=makeTable('tab nil))))
    
      a=makeTable('tab nil)
      a["hello"]["world"]["andrew"]=123
      
     )
    )
    
    defmacro(WithAutoHash (@rest body)
     `flet(((arrayref (arr ind) arr[ind] || (arr[ind]=makeTable('tab nil))))
       ,@body
      )
    )
    
    procedure(TrExampleArray()
      let(((arr makeTable('tab nil)))
        WithAutoHash(
          arr["my"]["big"]["test"]=7
          arr["my"]["other"]["test"]=9
          arr
        )
      )
    )

    Not sure there's enough demand (maybe) for an Advanced**2 SKILL course that I didn't cover in the Advanced class...

    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