home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991 */
- /* By MicroSim Corporation, All Rights Reserved */
- /****************************************************************************/
- /* exprs.h
- * $Revision: 1.10 $
- * $Author: sv $
- * $Date: 11 Apr 1991 15:10:52 $ */
-
- /******************* USERS OF DEVICE EQUATIONS OPTION ***********************/
- /******** Do not change this file **********/
-
- /* Expression definitions */
-
- struct expcnst { /* constant struct */
- int type; /* type: CNSTRING, CNFLOAT */
- #define CNSTRING 1
- #define CNFLOAT 2
- union {
- char *str;
- double flt;
- }
- data; /* Data value */
- };
-
- struct SP_ExpDef {
- int EXtype; /* EXCNST, EXPRM, or EXSRC */
- char *EXtext; /* Text of expression */
- int EXnrvp; /* Length of rvp */
- int *EXrvp; /* Reverse polish expression */
- int EXncnst; /* Number of constants */
- struct expcnst *EXcnst; /* Constants used by expression */
- };
- typedef struct SP_ExpDef EXPR;
-
- #define EXCNST 1 /* has: constants only */
- #define EXPRM 2 /* has: global symbols, constants */
- #define EXLAPL 3 /* has: "s", global symbols, constants */
- #define EXSRC 4 /* has: variables, globals, constants */
- #define EXSTRING 5 /* string (TEXT) value expression */
- #define EXSTRCNST 6 /* string expression -- constants only */
-
- /* Generalized value definitions */
-
- typedef struct value {
- union {
- char *str;
- double flt;
- }
- val; /* use this if expr is NULL */
- struct SP_ExpDef *expr; /* pre-parsed stuff to evaluate */
- } VALUE; /* or NULL if constant */
-
- /* For type punning in readin, etc: */
- /* dvalue has double, then expr ptr */
- /* mvalue has MDLPARM, then expr ptr */
-
- struct dvalue {
- double val;
- struct SP_ExpDef *expr;
- };
-
- struct mvalue {
- MDLPARM val;
- struct SP_ExpDef *expr;
- };
-
- struct svalue { /* string value */
- char *val;
- struct SP_ExpDef *expr;
- };
-
- /* declarator macros for (double,expr) and (modelpar,expr) pairs */
- #define DXPR(d,e) double d; EXPR *e
- #define MXPR(m,e) MDLPARM m; EXPR *e
- #define SXPR(s,e) char *s; EXPR *e
-
- /* Definitions for stack(s) used during expression evaluation */
-
- #define EXMSTK 40 /* Max. size of stack */
-
- /* Expression operators */
-
- #define EXEND -1
- #define EXNOOP -2
- #define EXADD -3
- #define EXSUB -4
- #define EXMLT -5
- #define EXDVD -6
- #define EXABS -7
- #define EXMNS -8
- #define EXPLS -9
- #define EXCNS -10
-
- #define EXPARAM -11
- #define EXTIME -12
- #define EXS -13
-
- #define EXEXP -19
- #define EXLOG -20
- #define EXLOG10 -21
- #define EXPWR -22
- #define EXPWRS -23
- #define EXPWR2 -24
- #define EXSQRT -25
- #define EXSIN -26
- #define EXCOS -27
- #define EXTAN -28
- #define EXATAN -29
-
- #define EXSTRPARM -30 /* string type parm */
- #define EXCONCAT -31 /* string concatenation */
- #define EXSTRINT -32 /* string value of flt */
- #define EXSTRCNS -33 /* string constant value */
- #define EXSTREND -34 /* string end */
-
- /* table of predefined identifiers (for behavioral modelling) */
- GLOBAL struct {
- char *iname;
- char itype; /* function or sweepvar */
- #define IDFUNC 0
- #define IDSVAR 1
- #define IDRSVD 2 /* reserved, will be global params later */
- #define IDSTRFUNC 3 /* string value function */
- int iargs; /* # args */
- int iopcode; /* RPN opcode */
- int arg1type; /* type of arg 1: ARGFLOAT or ARGSTRING */
- int arg2type; /* type of arg 2 and up: ARGFLOAT or ARGSTRING */
- #define ARGFLOAT 1
- #define ARGSTRING 2
- #define ARGNONE 0
- } Builtins[]
- #ifdef Main_Pgm
- =
- {
- {"EXP", IDFUNC, 1, EXEXP, ARGFLOAT, ARGNONE},
- {"LOG", IDFUNC, 1, EXLOG, ARGFLOAT, ARGNONE},
- {"LOG10", IDFUNC, 1, EXLOG10, ARGFLOAT, ARGNONE},
- {"PWR", IDFUNC, 2, EXPWR, ARGFLOAT, ARGFLOAT},
- {"PWRS", IDFUNC, 2, EXPWRS, ARGFLOAT, ARGFLOAT},
- {"SQRT", IDFUNC, 1, EXSQRT, ARGFLOAT, ARGNONE},
- {"SIN", IDFUNC, 1, EXSIN, ARGFLOAT, ARGNONE},
- {"COS", IDFUNC, 1, EXCOS, ARGFLOAT, ARGNONE},
- {"TAN", IDFUNC, 1, EXTAN, ARGFLOAT, ARGNONE},
- {"ATAN", IDFUNC, 1, EXATAN, ARGFLOAT, ARGNONE},
- {"ARCTAN", IDFUNC, 1, EXATAN, ARGFLOAT, ARGNONE},
- {"ABS", IDFUNC, 1, EXABS, ARGFLOAT, ARGNONE},
- {"TIME", IDSVAR, 0, EXTIME, ARGNONE, ARGNONE},
- {"S", IDSVAR, 0, EXS, ARGNONE, ARGNONE},
- {" TEMP", IDRSVD, 0, 0, ARGNONE, ARGNONE},
- {" VT", IDRSVD, 0, 0, ARGNONE, ARGNONE},
- {"TEXTINT", IDSTRFUNC, 1, EXSTRINT, ARGFLOAT, ARGNONE}
- }
- #endif
- ;
-
- GLOBAL int NBuiltins
- #ifdef Main_Pgm
- = (sizeof Builtins)/(sizeof(Builtins[0]))
- #endif
- ;
-
- /* parameter-related definitions: */
-
- /* used in par_type field in ParDef */
- #define PARGLOB 0
- #define PARLOC 1
- #define PARANY 2
- #define PARSTRGLOB 3
- #define PARSTRLOC 4
- #define PARSTRANY 5
-
- /* ParDef is returned by AddParam, used for Globals params */
- struct ParDef {
- struct ParDef *par_next;
- struct SymTabE *stp;
- int par_index;
- int par_type;
- int freeable; /* if OK to free expr part of value */
- struct value par_value;
- };
-
- /* ParLocDef is used by .subckt and x_dev to maintain lists of locals */
- struct ParLocDef {
- struct ParLocDef *parloc_next;
- struct SymTabE *stlp;
- int marked;
- int type; /* float or string: PARLOC or PARSTRLOC */
- struct value parloc_value;
- };
-
- /* YES if want to save expression text
- NO if do not save */
- GLOBAL int SP_ExprSaveText
- #ifdef Main_Pgm
- = NO
- #endif
- ;
-