The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines. May 26th, 2018, 2:52pm
  HomeHelpSearchLoginRegisterPM to admin  
 
Pages: 1
Send Topic Print
How to define my own functions in calculator? (Read 2869 times)
stephen
Junior Member
**
Offline



Posts: 24

How to define my own functions in calculator?
Mar 18th, 2004, 1:08pm
 
How to define my own special functions in the calculator? I know from the manual that it involves writing skill code. But I don't see where I shall put the skill code. Anybody knows?

Thanks.
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1659
Bracknell, UK
Re: How to define my own functions in calculator?
Reply #1 - Mar 21st, 2004, 12:51pm
 
Here's a simple example:

Code:
(procedure (abCalcDoubleCB)
  (calSpecialFunctionInput 'abCalcDouble nil))

(procedure (abIndepVarCB)
  (calSpecialFunctionInput 'abIndepVar nil))

(procedure (abCalcRegister)
  /* register my own functions */
  (calRegisterSpecialFunction
   (list "double" 'abCalcDoubleCB))
  (calRegisterSpecialFunction
   (list "indepVar" 'abIndepVarCB))
  t)

; now call the registration function
(abCalcRegister)
 



The code should be in a file, when you can then load
from the  .cdsinit file (see documentation on that file)
using:

Code:
(load "/path/to/the/above/file.il")
 



Regards,

Andrew.

Back to top
 
 
View Profile WWW   IP Logged
stephen
Junior Member
**
Offline



Posts: 24

Re: How to define my own functions in calculator?
Reply #2 - Mar 21st, 2004, 11:32pm
 
Thanks for your reply. I suppose I still have to write a file to put the code for function abCalcDouble, right? When I test this code, cadence complaint that this function is undefined.

So where shall I put the code the function abCalcDouble?

What I actually need is an enhancement to the rms function. The rms function doesn't subtract the DC value first. So I need sth like rms(x-average(x)). Since I do this many times a day, I want to define a special function for it. I don't understand the syntax of skill code very much. It looks like a rule definition language instead of a programming language like C. Can you possibly offer a code example for the RMS function that I need?

Thanks again

[quote author=Andrew Beckett  link=1079644139/0#1 date=1079902314]Here's a simple example:

Code:
(procedure (abCalcDoubleCB)
  (calSpecialFunctionInput 'abCalcDouble nil))

(procedure (abIndepVarCB)
  (calSpecialFunctionInput 'abIndepVar nil))

(procedure (abCalcRegister)
  /* register my own functions */
  (calRegisterSpecialFunction
   (list "double" 'abCalcDoubleCB))
  (calRegisterSpecialFunction
   (list "indepVar" 'abIndepVarCB))
  t)

; now call the registration function
(abCalcRegister)
 



The code should be in a file, when you can then load
from the  .cdsinit file (see documentation on that file)
using:

Code:
(load "/path/to/the/above/file.il")
 



Regards,

Andrew.

[/quote]
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1659
Bracknell, UK
Re: How to define my own functions in calculator?
Reply #3 - Mar 22nd, 2004, 1:35am
 
Stephen,

Whoops, in cut and pasting the code, I missed out one of the
functions in my example. Here it is:

Code:
(procedure (abCalcDouble arg1)
  (times arg1 2))
 



SKILL is a full-featured programming language. Essentially it is LISP, although it can be written with a C-like syntax. The above examples were all written with a LISP-like syntax (that's my personal preference, but it makes no difference to how the code works)

To write it in C-like syntax, you could do:

Code:
procedure(MYrms(x)
  rms(x-average(x))
)

procedure(MYrmsCB()
  calSpecialFunctionInput('MYrms nil)
)

procedure(MYregisterCalcFuncs()
  calRegisterSpecialFunction(
    list("MYrms" 'MYrmsCB)
  )
)

; call the function to register the MYrms func:
MYregisterCalcFuncs()
 



In fact all the calculator does is build a SKILL expression - you'll see that the definition of MYrms() above uses exactly the expression you mentioned.

More information can be found on SKILL by reading the SKILL Language User Guide in cdsdoc - this is written in the style of a book on a programming language, much as you'd find in a bookshop.

Regards,

Andrew.

Back to top
 
 
View Profile WWW   IP Logged
monglebest
New Member
*
Offline



Posts: 6
Austin
Re: How to define my own functions in calculator?
Reply #4 - May 16th, 2018, 11:57am
 
I am reading the
Cadence SKILL Language User Guide
Product Version 6.1.6 January 2015
but cannot find any keyword starting with calRegisterSpecialFunction, calSpecialFunctionInput, calCreateSpecialFunction or related with calculator.

I also checked
Virtuoso Design Environment SKILL Reference
Product Version 6.1.6 January 2015

Am I refer to something wrongly?
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1659
Bracknell, UK
Re: How to define my own functions in calculator?
Reply #5 - May 19th, 2018, 12:46am
 
That's because it's in the Virtuoso Visualization and Analysis XL SKILL Reference manual.

If you had just run "cdnshelp" from the command line or use Help->search box at the top in the CIW, or Help->User Guide (say) and then use View->Show Navigation and then search there, you'd find it.

Note that in IC617 there's no longer a need to register functions this way - you can use the "fx" button in the function panel in the ViVA calculator to add your own functions - all you need is a file with the main code that does the work - the UI and registration is handled within the calculator itself.

Regards,

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Trouble viewing this site? Copyright © 2002-2014 Designer's Guide Consulting. 'Designer's Guide' is a registered trademark of Designer's Guide LLC. All rights reserved.

Our colleges are not as safe as they seem. Sexual assault is pervasive and the treatment of the victim by the adminstration is often as damaging as the assault: Campus Survivors, Campus Survivors Forum.

Some of our other sites that you might find useful: Avendesora, Inform and QuantiPhy.