diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index 0d8ab33c1..11eb5157b 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -33,6 +33,8 @@ libfte_a_SOURCES = \ com_history.h \ com_let.c \ com_let.h \ + com_option.c \ + com_option.h \ com_plot.c \ com_plot.h \ com_rehash.c \ diff --git a/src/frontend/com_option.c b/src/frontend/com_option.c new file mode 100644 index 000000000..2ece53aa5 --- /dev/null +++ b/src/frontend/com_option.c @@ -0,0 +1,117 @@ +#include +#include "ngspice.h" +#include "cktdefs.h" +#include "ftedefs.h" +#include +#include "circuits.h" +#include +#include "variable.h" + + +/* The option command. Syntax is option [opt ...] [opt = val ...]. + * Val may be a string, an int, a float, or a list of the + * form (elt1 elt2 ...). */ +void +com_option(wordlist *wl) +{ + +struct variable *vars; + char *s; + + CKTcircuit *circuit = NULL; + + if (!ft_curckt) { + fprintf(cp_err, "Error: no circuit loaded\n"); + return; + } + + circuit = (CKTcircuit *)(ft_curckt->ci_ckt); + + + if (wl == NULL) { + printf("******************************\n"); + printf("* Current simulation options *\n"); + printf("******************************\n\n"); + printf("Temperatures:\n"); + printf("temp = %f\n",circuit->CKTtemp); + printf("tnom = %f\n",circuit->CKTnomTemp); + + printf("\nIntegration method summary:\n"); + switch (circuit->CKTintegrateMethod) + { + case TRAPEZOIDAL: + printf("Integration Method = TRAPEZOIDAL\n"); + break; + case GEAR: + printf("Integration Method = GEAR\n"); + break; + default: + printf("Unknown integration method\n"); + } + printf("MaxOrder = %d\n", circuit->CKTmaxOrder); + + printf("\nTolerances (absolute):\n"); + printf("abstol (current) = %f\n", circuit->CKTabstol); + printf("chgtol (charge) = %f\n", circuit->CKTchgtol); + printf("volttol (voltage) = %f\n", circuit->CKTvoltTol); + printf("pivotabstol (pivot) = %f\n", circuit->CKTpivotAbsTol); + + printf("\nTolerances (relative):\n"); + printf("reltol (current) = %f\n", circuit->CKTreltol); + printf("pivotreltol (pivot) = %f\n", circuit->CKTpivotRelTol); + + printf("\nTruncation error:\n"); + printf("trtol = %f\n", circuit->CKTtrtol); +#ifdef NEWTRUNC + printf("ltereltol = %f\n", circuit->CKTlteReltol); + printf("lteabstol = %f\n", circuit->CKTlteAbstol); +#endif /* NEWTRUNC */ + + printf("\nConductances:\n"); + printf("gmin (devices) = %f\n", circuit->CKTgmin); + printf("diaggmin (stepping) = %f\n", circuit->CKTdiagGmin); + printf("gshunt = %f\n", circuit->CKTgshunt); + + + printf("delmin = %f\n", circuit->CKTdelmin); + + printf("\nDefault parameters for MOS devices\n"); + printf("Default M: %f\n", circuit->CKTdefaultMosM); + printf("Default L: %f\n", circuit->CKTdefaultMosL); + printf("Default W: %f\n", circuit->CKTdefaultMosW); + printf("Default AD: %f\n", circuit->CKTdefaultMosAD); + printf("Default AS: %f\n", circuit->CKTdefaultMosAS); + + return; + } + vars = cp_setparse(wl); + + /* This is sort of a hassle... */ + while (vars) { + switch (vars->va_type) { + case VT_BOOL: + s = (char *) &vars->va_bool; + break; + case VT_NUM: + s = (char *) &vars->va_num; + break; + case VT_REAL: + s = (char *) &vars->va_real; + break; + case VT_STRING: + s = vars->va_string; + break; + case VT_LIST: + s = (char *) vars->va_vlist; + break; + default: + s = (char *) NULL; + } + + /* qui deve settare le opzioni di simulazione */ + cp_vset(vars->va_name, vars->va_type, s); + vars = vars->va_next; + } + return; +} + diff --git a/src/frontend/com_option.h b/src/frontend/com_option.h new file mode 100644 index 000000000..ef3163db0 --- /dev/null +++ b/src/frontend/com_option.h @@ -0,0 +1,6 @@ +#ifndef _COM_OPTION_H +#define _COM_OPTION_H + +void com_option(wordlist *wl); + +#endif diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 7d325cb31..c5e64b93c 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -47,8 +47,13 @@ #include "com_plot.h" #include "com_setscale.h" #include "com_xgraph.h" +#include "com_state.h" #include "fourier.h" +#ifdef EXPERIMENTAL_CODE +#include "com_option.h" +#endif + /* FIXME: Integrate spcp_coms and nutcp_coms into one variable. */ @@ -66,11 +71,20 @@ struct comm spcp_coms[] = { { "define", com_define, FALSE, FALSE, TRUE, { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, (void (*)()) NULL, - "[[func (args)] stuff] : Define a user-definable function." } , + "[[func (args)] stuff] : Define a user-definable function." } , { "set", com_set, FALSE, FALSE, TRUE, { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, arg_set, "[option] [option = value] ... : Set a variable." } , + +#ifdef EXPERIMENTAL_CODE +/* PN support for altering options in interactive mode */ + { "option", com_option, FALSE, TRUE, TRUE, + { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, + arg_set, + "[option] [option = value] ... : Set a simulator option." } , +#endif + { "alias", com_alias, FALSE, FALSE, FALSE, { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, (void (*)()) NULL, @@ -435,6 +449,15 @@ struct comm nutcp_coms[] = { { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, arg_set, "[option] [option = value] ... : Set a variable." } , + +#ifdef EXPERIMENTAL_CODE +/* PN support for altering options in interactive mode */ + { "option", com_option, FALSE, TRUE, TRUE, + { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, + arg_set, + "[option] [option = value] ... : Set a simulator option." } , +#endif + { "alias", com_alias, FALSE, FALSE, FALSE, { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, (void (*)()) NULL, diff --git a/src/include/cpextern.h b/src/include/cpextern.h index 1ffbc97b6..975c2d4b7 100644 --- a/src/include/cpextern.h +++ b/src/include/cpextern.h @@ -165,6 +165,8 @@ extern struct variable *cp_setparse(wordlist *wl); /* var2.c */ extern void cp_vprint(void); extern void com_set(wordlist *wl); +extern void com_option(wordlist *wl); +extern void com_state(wordlist *wl); extern void com_unset(wordlist *wl); extern void com_shift(wordlist *wl); extern bool cp_getvar(char *name, int type, void *retval); diff --git a/src/misc/string.h b/src/misc/stringutil.h similarity index 87% rename from src/misc/string.h rename to src/misc/stringutil.h index c03391abf..350c2fdd3 100644 --- a/src/misc/string.h +++ b/src/misc/stringutil.h @@ -16,12 +16,12 @@ int ciprefix(register char *p, register char *s); void strtolower(char *str); char * gettok(char **s); -#ifndef HAVE_INDEX +#if !defined(HAVE_INDEX) && !defined(HAVE_STRCHR) char * index(register char *s, register char c); char * rindex(register char *s,register char c ); -#endif /* HAVE_INDEX */ +#endif /* !defined(HAVE_INDEX) && !defined(HAVE_STRCHR) */ #ifndef HAVE_BCOPY diff --git a/src/spicelib/parser/inp2r.c b/src/spicelib/parser/inp2r.c index f7c76b1ff..858392238 100644 --- a/src/spicelib/parser/inp2r.c +++ b/src/spicelib/parser/inp2r.c @@ -21,7 +21,7 @@ void INP2R(void *ckt, INPtables * tab, card * current) /* Rname [][][w=][l=][ac=] */ int mytype; /* the type we determine resistors are */ - int type; /* the type the model says it is */ + int type = 0; /* the type the model says it is */ char *line; /* the part of the current line left to parse */ char *saveline; /* ... just in case we need to go back... */ char *name; /* the resistor's name */ diff --git a/src/spicelib/parser/inpdoopt.c b/src/spicelib/parser/inpdoopt.c index 447314e1b..bbc135627 100644 --- a/src/spicelib/parser/inpdoopt.c +++ b/src/spicelib/parser/inpdoopt.c @@ -31,7 +31,7 @@ INPdoOpts(ckt,anal,optCard,tab) int error; int i; int which; - IFanalysis *prm; + IFanalysis *prm = NULL; which = -1; i=0; diff --git a/src/spicelib/parser/inpptree.c b/src/spicelib/parser/inpptree.c index eead80869..c01eef8a4 100644 --- a/src/spicelib/parser/inpptree.c +++ b/src/spicelib/parser/inpptree.c @@ -153,7 +153,7 @@ INPgetTree(char **line, INPparseTree ** pt, void *ckt, INPtables * tab) static INPparseNode *PTdifferentiate(INPparseNode * p, int varnum) { - INPparseNode *arg1, *arg2, *newp; + INPparseNode *arg1 = NULL, *arg2, *newp; /* printf("differentiating: "); printTree(p); printf(" wrt var %d\n", varnum);*/