diff --git a/src/Makefile.am b/src/Makefile.am index f6f40cc27..9da736ad2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = analysis circuit devices frontend hlp maths misc parser include +SUBDIRS = misc maths analysis circuit frontend hlp parser devices include bin_PROGRAMS = ngspice nutmeg help sconvert proc2mod multidec makeidx @@ -67,6 +67,7 @@ ngspice_SOURCES = \ ngspice_LDADD = \ spice.o \ frontend/libfte.a \ + frontend/plotting/libplotting.a \ devices/libdev.a \ $(DYNAMIC_DEVICELIBS) \ analysis/libckt.a \ @@ -92,6 +93,7 @@ nutmeg_SOURCES = \ nutmeg_LDADD = \ frontend/libfte.a \ + frontend/plotting/libplotting.a \ parser/libparser.a \ hlp/libhlp.a \ maths/cmaths/libcmaths.a \ diff --git a/src/analysis/cktdisto.c b/src/analysis/cktdisto.c index dbdf42153..137e7c8ac 100644 --- a/src/analysis/cktdisto.c +++ b/src/analysis/cktdisto.c @@ -13,7 +13,6 @@ Author: 1988 Jaijeet S Roychowdhury #include "devdefs.h" #include "vsrc/vsrcdefs.h" #include "isrc/isrcdefs.h" -#include "fteconst.h" #include "iferrmsg.h" #include "distodef.h" #include "sperror.h" diff --git a/src/analysis/cktnoise.c b/src/analysis/cktnoise.c index 6e51d1e0f..02805b2f6 100644 --- a/src/analysis/cktnoise.c +++ b/src/analysis/cktnoise.c @@ -16,7 +16,6 @@ Author: 1987 Gary W. Ng #include #include "cktdefs.h" #include "devdefs.h" -#include "fteconst.h" #include "iferrmsg.h" #include "noisedef.h" #include "sperror.h" diff --git a/src/analysis/noisean.c b/src/analysis/noisean.c index 184af4f50..efac07c0e 100644 --- a/src/analysis/noisean.c +++ b/src/analysis/noisean.c @@ -13,7 +13,6 @@ Author: 1987 Gary W. Ng #include #include "acdefs.h" #include "cktdefs.h" -#include "fteconst.h" #include "iferrmsg.h" #include "noisedef.h" #include "sperror.h" diff --git a/src/frontend/.cvsignore b/src/frontend/.cvsignore index e440fafda..8cb5c0556 100644 --- a/src/frontend/.cvsignore +++ b/src/frontend/.cvsignore @@ -1,3 +1,4 @@ Makefile.in Makefile .deps +.libs diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index d5fa3dbf5..5363c2f0d 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -1,125 +1,135 @@ ## Process this file with automake to produce Makefile.in +SUBDIRS = plotting + noinst_LIBRARIES = libfte.a libfte_a_SOURCES = \ - agraf.c \ - agraf.h \ - arg.c \ - arg.h \ - aspice.c \ - aspice.h \ - breakp.c \ - breakp.h \ - breakp2.c \ - breakp2.h \ - circuits.c \ - circuits.h \ - clip.c \ - clip.h \ - compose.c \ - compose.h \ - cpitf.c \ - cpitf.h \ - debugcom.c \ - debugcom.h \ - define.c \ - define.h \ - device.c \ - device.h \ - diff.c \ - diff.h \ - dimens.c \ - dimens.h \ - display.c \ - display.h \ - doplot.c \ - doplot.h \ - dotcards.c \ - dotcards.h \ - error.c \ - error.h \ - evaluate.c \ - evaluate.h \ - fourier.c \ - fourier.h \ - gens.c \ - gens.h \ - graf.c \ - graf.h \ - graphdb.c \ - graphdb.h \ - grid.c \ - grid.h \ - inp.c \ - inp.h \ - inpcom.c \ - inpcom.h \ - interp.c \ - interp.h \ - linear.c \ - linear.h \ - misccoms.c \ - misccoms.h \ - miscvars.c \ - miscvars.h \ - mw_coms.c \ - mw_coms.h \ - newcoms.c \ - newcoms.h \ - nutctab.c \ - nutctab.h \ - nutinp.c \ - nutinp.h \ - nutmegif.c \ - nutmegif.h \ - options.c \ - options.h \ - outitf.c \ - outitf.h \ - parse.c \ - parse.h \ - plot5.c \ - plot5.h \ - plotcurv.c \ - plotcurv.h \ - points.c \ - points.h \ - postcoms.c \ - postcoms.h \ - postsc.c \ - postsc.h \ - rawfile.c \ - rawfile.h \ - resource.c \ - resource.h \ - runcoms.c \ - runcoms.h \ - runcoms2.c \ - runcoms2.h \ - shyu.c \ - shyu.h \ - signal_handler.c\ - signal_handler.h\ - spec.c \ - spec.h \ - spcmdtab.c \ - spiceif.c \ - spiceif.h \ - subckt.c \ - subckt.h \ - typesdef.c \ - typesdef.h \ - vectors.c \ - vectors.h \ - where.c \ - where.h \ - x11.c \ - x11.h \ - xgraph.c \ - xgraph.h - + commands.c \ + commands.h \ + com_compose.c \ + com_compose.h \ + com_display.c \ + com_display.h \ + com_let.c \ + com_let.h \ + com_setscale.c \ + com_setscale.h \ + \ + agraf.c \ + agraf.h \ + arg.c \ + arg.h \ + aspice.c \ + aspice.h \ + breakp.c \ + breakp.h \ + breakp2.c \ + breakp2.h \ + circuits.c \ + circuits.h \ + clip.c \ + clip.h \ + cpitf.c \ + cpitf.h \ + debugcom.c \ + debugcom.h \ + define.c \ + define.h \ + device.c \ + device.h \ + diff.c \ + diff.h \ + dimens.c \ + dimens.h \ + display.c \ + display.h \ + doplot.c \ + doplot.h \ + dotcards.c \ + dotcards.h \ + error.c \ + error.h \ + evaluate.c \ + evaluate.h \ + fourier.c \ + fourier.h \ + gens.c \ + gens.h \ + graf.c \ + graf.h \ + graphdb.c \ + graphdb.h \ + grid.c \ + grid.h \ + inp.c \ + inp.h \ + inpcom.c \ + inpcom.h \ + interp.c \ + interp.h \ + linear.c \ + linear.h \ + misccoms.c \ + misccoms.h \ + miscvars.c \ + miscvars.h \ + mw_coms.c \ + mw_coms.h \ + newcoms.c \ + newcoms.h \ + nutinp.c \ + nutinp.h \ + nutmegif.c \ + nutmegif.h \ + options.c \ + options.h \ + outitf.c \ + outitf.h \ + parse.c \ + parse.h \ + plotcurv.c \ + plotcurv.h \ + points.c \ + points.h \ + postcoms.c \ + postcoms.h \ + postsc.c \ + postsc.h \ + rawfile.c \ + rawfile.h \ + resource.c \ + resource.h \ + runcoms.c \ + runcoms.h \ + runcoms2.c \ + runcoms2.h \ + shyu.c \ + shyu.h \ + signal_handler.c\ + signal_handler.h\ + spec.c \ + spec.h \ + spiceif.c \ + spiceif.h \ + subckt.c \ + subckt.h \ + typesdef.c \ + typesdef.h \ + vectors.c \ + vectors.h \ + where.c \ + where.h +# TESTS = testcommands +# +# bin_PROGRAMS = testcommands +# +# testcommands_SOURCES = \ +# testcommands.c \ +# testcommands.h +# +# testcommands_LDADD = libfte.a plotting/libplotting.a ../misc/libmisc.a INCLUDES = -I$(top_srcdir)/src/include @X_CFLAGS@ diff --git a/src/frontend/README b/src/frontend/README new file mode 100644 index 000000000..9a1f9421f --- /dev/null +++ b/src/frontend/README @@ -0,0 +1,5 @@ +This directory contains the code that is behind the commands of the +interactive frontend. Note that every command has a source file +associated with it. The source file is prefixed with `com_' to +distinguish command source files from other supporting code. + diff --git a/src/frontend/agraf.c b/src/frontend/agraf.c index e036221d0..53a50c3aa 100644 --- a/src/frontend/agraf.c +++ b/src/frontend/agraf.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "agraf.h" diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index f8bef98d8..29e8c56e1 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -31,7 +31,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include #include "fteinp.h" -#include "ftedata.h" +#include "dvec.h" #ifndef SEEK_SET diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index 1496cba6d..98bf66c92 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -10,10 +10,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftedebug.h" #include "breakp.h" +#include "completion.h" static bool satisfied(struct dbcomm *d, struct plot *plot); static void printcond(struct dbcomm *d, FILE *fp); diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index 01e8b84f3..e06839dbc 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftedebug.h" #include "breakp2.h" diff --git a/src/frontend/circuits.c b/src/frontend/circuits.c index b2250af0d..f1a1ee8da 100644 --- a/src/frontend/circuits.c +++ b/src/frontend/circuits.c @@ -9,7 +9,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "circuits.h" diff --git a/src/frontend/compose.c b/src/frontend/com_compose.c similarity index 96% rename from src/frontend/compose.c rename to src/frontend/com_compose.c index 6dbcbf947..cd8e83171 100644 --- a/src/frontend/compose.c +++ b/src/frontend/com_compose.c @@ -1,22 +1,63 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ +/* The 'compose' command. This is a more powerful and convenient form + * of the 'let' command. */ +#include +#include +#include +#include +#include +#include +#include -/* - * The 'compose' command. This is a more powerful and convenient form of the - * 'let' command. - */ +#include "com_compose.h" +#include "completion.h" +#include "streams.h" -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "fteparse.h" -#include "compose.h" +/* Copy the data from a vector into a buffer with larger dimensions. */ +static void +dimxpand(struct dvec *v, int *newdims, double *data) +{ + complex *cdata = (complex *) data; + bool realflag = isreal(v); + int i, j, o, n, t, u; + int ncount[MAXDIMS], ocount[MAXDIMS]; + + for (i = 0; i < MAXDIMS; i++) + ncount[i] = ocount[i] = 0; + + for (;;) { + for (o = n = i = 0; i < v->v_numdims; i++) { + for (j = i, t = u = 1; j < v->v_numdims; j++) { + t *= v->v_dims[j]; + u *= newdims[j]; + } + o += ocount[i] * t; + n += ncount[i] * u; + } + + if (realflag) { + data[n] = v->v_realdata[o]; + } else { + realpart(&cdata[n]) = realpart(&v->v_compdata[o]); + imagpart(&cdata[n]) = imagpart(&v->v_compdata[o]); + } + /* Now find the nextstrchr element... */ + for (i = v->v_numdims - 1; i >= 0; i--) { + if ((ocount[i] < v->v_dims[i] - 1) && + (ncount[i] < newdims[i] - 1)) { + ocount[i]++; + ncount[i]++; + break; + } else + ocount[i] = ncount[i] = 0; + } + if (i < 0) + break; + } + + return; +} -static void dimxpand(struct dvec *v, int *newdims, double *data); /* The general syntax is 'compose name parm = val ...' @@ -47,7 +88,10 @@ static void dimxpand(struct dvec *v, int *newdims, double *data); void com_compose(wordlist *wl) { - double start, stop, step, lin; + double start = 0.0; + double stop = 0.0; + double step = 0.0; + double lin = 0.0; double center; double span; double mean, sd; @@ -66,9 +110,10 @@ com_compose(wordlist *wl) char *resname, *s, *var, *val; double *td, tt; - double *data; - complex *cdata; - int length, dim, type = SV_NOTYPE, blocksize; + double *data = NULL; + complex *cdata = NULL; + int length = 0; + int dim, type = SV_NOTYPE, blocksize; bool realflag = TRUE; int dims[MAXDIMS]; struct dvec *result, *vecs = NULL, *v, *lv = NULL; @@ -435,50 +480,3 @@ com_compose(wordlist *wl) cp_addkword(CT_VECTOR, result->v_name); return; } - -/* Copy the data from a vector into a buffer with larger dimensions. */ - -static void -dimxpand(struct dvec *v, int *newdims, double *data) -{ - complex *cdata = (complex *) data; - bool realflag = isreal(v); - int i, j, o, n, t, u; - int ncount[MAXDIMS], ocount[MAXDIMS]; - - for (i = 0; i < MAXDIMS; i++) - ncount[i] = ocount[i] = 0; - - for (;;) { - for (o = n = i = 0; i < v->v_numdims; i++) { - for (j = i, t = u = 1; j < v->v_numdims; j++) { - t *= v->v_dims[j]; - u *= newdims[j]; - } - o += ocount[i] * t; - n += ncount[i] * u; - } - - if (realflag) { - data[n] = v->v_realdata[o]; - } else { - realpart(&cdata[n]) = realpart(&v->v_compdata[o]); - imagpart(&cdata[n]) = imagpart(&v->v_compdata[o]); - } - /* Now find the nextstrchr element... */ - for (i = v->v_numdims - 1; i >= 0; i--) { - if ((ocount[i] < v->v_dims[i] - 1) && - (ncount[i] < newdims[i] - 1)) { - ocount[i]++; - ncount[i]++; - break; - } else - ocount[i] = ncount[i] = 0; - } - if (i < 0) - break; - } - - return; -} - diff --git a/src/frontend/com_compose.h b/src/frontend/com_compose.h new file mode 100644 index 000000000..5f2d72516 --- /dev/null +++ b/src/frontend/com_compose.h @@ -0,0 +1,10 @@ + +#ifndef _COM_COMPOSE_H +#define _COM_COMPOSE_H + +#include + + +void com_compose(wordlist *wl); + +#endif diff --git a/src/frontend/com_display.c b/src/frontend/com_display.c new file mode 100644 index 000000000..5194d57d5 --- /dev/null +++ b/src/frontend/com_display.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include + +#include "com_display.h" +#include "streams.h" +#include "plotting/plotting.h" +#include "plotting/pvec.h" + + +/* For the sort in display. */ +static int +dcomp(const void *d1, const void *d2) +{ + struct dvec **v1 = (struct dvec **) d1; + struct dvec **v2 = (struct dvec **) d2; + + return (strcmp((*v1)->v_name, (*v2)->v_name)); +} + + + +/* Display vector status, etc. Note that this only displays stuff + * from the current plot, and you must do a setplot to see the rest of + * it. */ +void +com_display(wordlist *wl) +{ + struct dvec *d; + struct dvec **dvs; + int len = 0, i = 0; + bool b; + char *s; + + /* Maybe he wants to know about just a few vectors. */ + + out_init(); + while (wl) { + s = cp_unquote(wl->wl_word); + d = vec_get(s); + if (d == NULL) + fprintf(cp_err, "Error: no such vector as %s.\n", + wl->wl_word); + else + while (d) { + pvec(d); + d = d->v_link2; + } + if (wl->wl_next == NULL) + return; + wl = wl->wl_next; + } + if (plot_cur) + for (d = plot_cur->pl_dvecs; d; d = d->v_next) + len++; + if (len == 0) { + fprintf(cp_out, "There are no vectors currently active.\n"); + return; + } + out_printf("Here are the vectors currently active:\n\n"); + dvs = (struct dvec **) tmalloc(len * (sizeof (struct dvec *))); + for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++) + dvs[i] = d; + if (!cp_getvar("nosort", VT_BOOL, (char *) &b)) + qsort((char *) dvs, len, sizeof (struct dvec *), dcomp); + + out_printf("Title: %s\n", plot_cur->pl_title); + out_printf("Name: %s (%s)\nDate: %s\n\n", + plot_cur->pl_typename, plot_cur->pl_name, + plot_cur->pl_date); + for (i = 0; i < len; i++) { + d = dvs[i]; + pvec(d); + } + return; +} diff --git a/src/frontend/com_display.h b/src/frontend/com_display.h new file mode 100644 index 000000000..d7bb80b4d --- /dev/null +++ b/src/frontend/com_display.h @@ -0,0 +1,8 @@ +#ifndef _COM_DISPLAY_H +#define _COM_DISPLAY_H + +#include + +void com_display(wordlist *wl); + +#endif diff --git a/src/frontend/com_let.c b/src/frontend/com_let.c new file mode 100644 index 000000000..af670b41e --- /dev/null +++ b/src/frontend/com_let.c @@ -0,0 +1,206 @@ +#include + +#include +#include +#include + +#include "com_let.h" +#include "com_display.h" +#include "completion.h" +#include "streams.h" + +void +com_let(wordlist *wl) +{ + char *p, *q, *s; + int indices[MAXDIMS]; + int numdims; + wordlist fake_wl; + int need_open; + int offset, length; + struct pnode *nn; + struct dvec *n, *t; + int i, cube; + int depth; + int newvec; + char *rhs; + + fake_wl.wl_next = NULL; + + if (!wl) { + com_display((wordlist *) NULL); + return; + } + + p = wl_flatten(wl); + + /* extract indices */ + numdims = 0; + if ((rhs =strchr(p, '='))) { + *rhs++ = 0; + } else { + fprintf(cp_err, "Error: bad let syntax\n"); + return; + } + if ((s =strchr(p, '['))) { + need_open = 0; + *s++ = 0; + while (!need_open || *s == '[') { + depth = 0; + if (need_open) + s++; + for (q = s; *q && (*q != ']' && (*q != ',' || depth > 0)); q++) { + switch (*q) { + case '[': + depth += 1; + break; + case ']': + depth -= 1; + break; + } + } + + if (depth != 0 || !*q) { + printf("syntax error specifyingstrchr\n"); + return; + } + + if (*q == ']') + need_open = 1; + else + need_open = 0; + if (*q) + *q++ = 0; + for (s = q; *s && isspace(*s); s++) + ; + } + } + /* vector name at p */ + + for (q = p + strlen(p) - 1; *q <= ' ' && p <= q; q--) + ; + + *++q = 0; + + /* sanity check */ + if (eq(p, "all") ||strchr(p, '@')) { + fprintf(cp_err, "Error: bad variable name %s\n", p); + return; + } + + /* evaluate rhs */ + fake_wl.wl_word = rhs; + nn = ft_getpnames(&fake_wl, TRUE); + if (nn == NULL) { + /* XXX error message */ + tfree(p); + return; + } + t = ft_evaluate(nn); + if (!t) { + fprintf(cp_err, "Error: Can't evaluate %s\n", rhs); + tfree(p); + return; + } + + if (t->v_link2) + fprintf(cp_err, "Warning: extra wildcard values ignored\n"); + + n = vec_get(p); + + if (n) { + /* re-allocate? */ + /* vec_free(n); */ + newvec = 0; + } else { + if (numdims) { + fprintf(cp_err, "Can't assign into a subindex of a new vector\n"); + tfree(p); + return; + } + + /* create and assign a new vector */ + n = alloc(struct dvec); + ZERO(n, struct dvec); + n->v_name = copy(p); + n->v_type = t->v_type; + n->v_flags = (t->v_flags | VF_PERMANENT); + n->v_length = t->v_length; + + if (!t->v_numdims) { + n->v_numdims = 1; + n->v_dims[0] = n->v_length; + } else { + n->v_numdims = t->v_numdims; + for (i = 0; i < t->v_numdims; i++) + n->v_dims[i] = t->v_dims[i]; + } + + if (isreal(t)) + n->v_realdata = (double *) tmalloc(n->v_length * sizeof(double)); + else + n->v_compdata = (complex *) tmalloc(n->v_length * sizeof(complex)); + newvec = 1; + vec_new(n); + } + + /* fix-up dimensions */ + if (n->v_numdims < 1) { + n->v_numdims = 1; + n->v_dims[0] = n->v_length; + } + + /* Compare dimensions */ + offset = 0; + length = n->v_length; + + cube = 1; + for (i = n->v_numdims - 1; i >= numdims; i--) + cube *= n->v_dims[i]; + + for (i = numdims - 1; i >= 0; i--) { + offset += cube * indices[i]; + if (i < n->v_numdims) { + cube *= n->v_dims[i]; + length /= n->v_dims[i]; + } + } + + /* length is the size of the unit refered to */ + /* cube ends up being the length */ + + if (length > t->v_length) { + fprintf(cp_err, "left-hand expression is too small (need %d)\n", + length * cube); + if (newvec) + n->v_flags &= ~VF_PERMANENT; + tfree(p); + return; + } + if (isreal(t) != isreal(n)) { + fprintf(cp_err, + "Types of vectors are not the same (real vs. complex)\n"); + if (newvec) + n->v_flags &= ~VF_PERMANENT; + tfree(p); + return; + } else if (isreal(t)) { + bcopy((char *) t->v_realdata, (char *) (n->v_realdata + offset), + length * sizeof (double)); + } else { + bcopy((char *) t->v_compdata, (char *) (n->v_compdata + offset), + length * sizeof (complex)); + } + + n->v_minsignal = 0.0; /* How do these get reset ??? */ + n->v_maxsignal = 0.0; + + n->v_scale = t->v_scale; + + if (newvec) + cp_addkword(CT_VECTOR, n->v_name); + + /* XXXX Free t !?! */ + tfree(p); + return; +} diff --git a/src/frontend/com_let.h b/src/frontend/com_let.h new file mode 100644 index 000000000..ccce6771f --- /dev/null +++ b/src/frontend/com_let.h @@ -0,0 +1,8 @@ +#ifndef _COM_LET_H +#define _COM_LET_H + +#include + +void com_let(wordlist *wl); + +#endif diff --git a/src/frontend/com_setscale.c b/src/frontend/com_setscale.c new file mode 100644 index 000000000..050368db4 --- /dev/null +++ b/src/frontend/com_setscale.c @@ -0,0 +1,33 @@ +#include +#include +#include + +#include "com_setscale.h" +#include "plotting/plotting.h" +#include "plotting/pvec.h" + +/* Set the default scale to the named vector. If no vector named, + * find and print the default scale. + */ +void +com_setscale(wordlist *wl) +{ + struct dvec *d; + char *s; + + if (plot_cur) { + if (wl) { + s = cp_unquote(wl->wl_word); + d = vec_get(s); + if (d == NULL) + fprintf(cp_err, "Error: no such vector as %s.\n", + wl->wl_word); + else + plot_cur->pl_scale = d; + } else if (plot_cur->pl_scale) { + pvec(plot_cur->pl_scale); + } + } else { + fprintf(cp_err, "Error: no current plot.\n"); + } +} diff --git a/src/frontend/com_setscale.h b/src/frontend/com_setscale.h new file mode 100644 index 000000000..6ced5482b --- /dev/null +++ b/src/frontend/com_setscale.h @@ -0,0 +1,9 @@ +#ifndef _COM_SETSCALE_H +#define _COM_SETSCALE_H + +#include + + +void com_setscale(wordlist *wl); + +#endif diff --git a/src/frontend/commands.c b/src/frontend/commands.c new file mode 100644 index 000000000..b91332646 --- /dev/null +++ b/src/frontend/commands.c @@ -0,0 +1,744 @@ +/* NG-SPICE -- An electrical circuit simulator + * + * Copyright (c) 1990 University of California + * Copyright (c) 2000 Arno W. Peters + * + * Permission to use, copy, modify, and distribute this software and + * its documentation without fee, and without a written agreement is + * hereby granted, provided that the above copyright notice, this + * paragraph and the following three paragraphs appear in all copies. + * + * This software program and documentation are copyrighted by their + * authors. The software program and documentation are supplied "as + * is", without any accompanying services from the authors. The + * authors do not warrant that the operation of the program will be + * uninterrupted or error-free. The end-user understands that the + * program was developed for research purposes and is advised not to + * rely exclusively on the program for any reason. + * + * IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING + * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS + * DOCUMENTATION, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. THE AUTHORS SPECIFICALLY DISCLAIMS ANY + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE + * SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS + * HAVE NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, + * ENHANCEMENTS, OR MODIFICATIONS. */ + +/* Table of available commands. Note that they're sorted so that the + * commands that appear in the spiceinit file are at the top. */ + +#include +#include +#include + +#include "commands.h" + + +/* FIXME: Integrate spcp_coms and nutcp_coms into one variable. */ + + +/* Bool fields: stringargs, spiceonly, major */ + +struct comm spcp_coms[] = { + + { "let", com_let, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + arg_let, + "varname = expr : Assign vector variables." } , + { "reshape", com_reshape, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + arg_let, + "vector ... [ shape ] : change the dimensions of a vector." } , + { "define", com_define, FALSE, FALSE, TRUE, + { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[[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." } , + { "alias", com_alias, FALSE, FALSE, FALSE, + { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, + (void (*)()) NULL, + "[[word] alias] : Define an alias." } , + { "deftype", com_dftype, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, + (void (*)()) NULL, + "spec name pat ... : Redefine vector and plot types.\n" } , + { "plot", com_plot, FALSE, FALSE, TRUE, + { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, + arg_plot, + "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, + { "display", com_display, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, + arg_display, + ": Display vector status." } , + { "destroy", com_destroy, FALSE, FALSE, FALSE, + { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[plotname] ... : Throw away all the data in the plot." } , + { "setplot", com_splot, FALSE, FALSE, TRUE, + { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[plotname] : Change the current working plot." } , + { "setcirc", com_scirc, FALSE, TRUE, FALSE, + { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[circuit name] : Change the current circuit." } , + { "setscale", com_setscale, FALSE, FALSE, FALSE, + { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[vecname] : Change default scale of current working plot." } , + { "transpose", com_transpose, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Perform matrix transposition on multi-D vectors." } , + { "xgraph", com_xgraph, FALSE, FALSE, TRUE, + { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "file plotargs : Send plot to Xgraph-11." } , + { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, + { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "file plotargs : Produce hardcopy plots." } , + { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, + { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "plotargs : Produce ascii plots." } , + { "write", com_write, FALSE, FALSE, TRUE, + { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "file expr ... : Write data to a file." } , + { "compose", com_compose, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "var parm=val ... : Compose a vector." } , + { "unlet", com_unlet, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Undefine vectors." } , + { "print", com_print, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, + arg_print, + "[col] expr ... : Print vector values." } , + { "load", com_load, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, + arg_load, + "file ... : Load in data." } , + { "cross", com_cross, FALSE, FALSE, TRUE, + { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "vecname number [ vector ... ] : Make a vector in a strange way." } , + { "undefine", com_undefine, FALSE, FALSE, FALSE, + { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[func ...] : Undefine a user-definable function." } , + { "op", com_op, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.op line args] : Determine the operating point of the circuit." } , + { "tf", com_tf, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.tran line args] : Do a transient analysis." } , + { "tran", com_tran, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.tran line args] : Do a transient analysis." } , + { "ac", com_ac, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.ac line args] : Do an ac analysis." } , + { "dc", com_dc, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.dc line args] : Do a dc analysis." } , + { "pz", com_pz, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.pz line args] : Do a pole / zero analysis." } , + { "sens", com_sens, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.sens line args] : Do a sensitivity analysis." } , + { "disto", com_disto, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.disto line args] : Do an distortion analysis." } , + { "noise", com_noise, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.noise line args] : Do a noise analysis." } , + { "listing", com_listing, FALSE, TRUE, TRUE, + { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[logical] [physical] [deck] : Print the current circuit." } , + { "edit", com_edit, FALSE, TRUE, TRUE, + { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[filename] : Edit a spice deck and then load it in." } , + { "dump", com_dump, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Print a dump of the current circuit." } , + { "fourier", com_fourier, FALSE, FALSE, TRUE, + { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "fund_freq vector ... : Do a fourier analysis of some data." } , + { "spec", com_spec, FALSE, FALSE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 4, LOTS, + (void (*)()) NULL, + "start_freq stop_freq step_freq vector ... : Create a frequency domain plot." } , + { "show", com_show, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "devices ... : parameters ... : Print out device summary." } , + { "showmod", com_showmod, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "models ... : parameters ... : Print out model summary." } , + { "alter", com_alter, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "devspecs : parmname value : Alter device parameters." } , + { "altermod", com_altermod, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "devspecs : parmname value : Alter model parameters." } , + { "resume", com_resume, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Continue after a stop." } , + { "state", com_state, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "(unimplemented) : Print the state of the circuit." }, + { "stop", com_stop, FALSE, TRUE, FALSE, + { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[stop args] : Set a breakpoint." } , + { "trace", com_trce, FALSE, TRUE, FALSE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Trace a node." } , + { "save", com_save, FALSE, TRUE, FALSE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Save a spice output." } , + { "iplot", com_iplot, FALSE, TRUE, TRUE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Incrementally plot a node." } , + { "status", com_sttus, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Print the current breakpoints and traces." } , + { "delete", com_delete, FALSE, TRUE, FALSE, + { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [break number ...] : Delete breakpoints and traces." } , + { "step", com_step, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[number] : Iterate number times, or one." } , + { "reset", com_rset, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Terminate a simulation after a breakpoint (formerly 'end')." } , + { "run", com_run, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[rawfile] : Run the simulation as specified in the input file." } , + { "aspice", com_aspice, FALSE, FALSE, FALSE, + { 1, 1, 1, 1 }, E_DEFHMASK, 1, 2, + (void (*)()) NULL, + "file [outfile] : Run a spice job asynchronously." } , + { "jobs", com_jobs, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Report on asynchronous spice jobs." } , + { "rspice", com_rspice, FALSE, FALSE, FALSE, + { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[input file] : Run a spice job remotely." } , + { "bug", com_bug, FALSE, FALSE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Report a %s bug." } , + { "where", com_where, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Print last non-converging node or device" } , + { "newhelp", com_ahelp, FALSE, FALSE, TRUE, + { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[command name] ... : help." }, + { "tutorial", com_ghelp, FALSE, FALSE, TRUE, + { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, + (void (*)()) NULL, + "[subject] ... : Hierarchical documentation browser." } , + { "help", com_ghelp, FALSE, FALSE, TRUE, + { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[subject] ... : Hierarchical documentation browser." } , + { "oldhelp", com_help, FALSE, FALSE, TRUE, + { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[command name] ... : Print help." } , + { "quit", com_quit, FALSE, FALSE, TRUE, + { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, + (void (*)()) NULL, + ": Quit %s." } , + { "source", com_source, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "file : Source a %s file." } , + { "shift", com_shift, FALSE, FALSE, FALSE, + { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, + (void (*)()) NULL, + "[var] [number] : Shift argv or the named list var to the left." } , + { "unset", com_unset, FALSE, FALSE, FALSE, + { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Unset a variable." } , + { "unalias", com_unalias, FALSE, FALSE, FALSE, + { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "word ... : Undefine an alias." } , + { "history", com_history, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, + (void (*)()) NULL, + "[-r] [number] : Print command history." } , + { "echo", com_echo, FALSE, FALSE, FALSE, + { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[stuff ...] : Print stuff." } , + { "shell", com_shell, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[args] : Fork a shell, or execute the command." } , + { "rusage", com_rusage, FALSE, FALSE, FALSE, + { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[resource ...] : Print current resource usage." } , + { "cd", com_chdir, FALSE, FALSE, FALSE, + { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[directory] : Change working directory." } , + { "version", com_version, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[number] : Print the version number." } , + { "diff", com_diff, FALSE, FALSE, FALSE, + { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "plotname plotname [vec ...] : 'diff' two plots." } , + { "rehash", com_rehash, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Rebuild the unix command database." } , + { "while", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute while the condition is TRUE." } , + { "repeat", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[number] : Repeat number times, or forever." } , + { "dowhile", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute while the condition is TRUE." } , + { "foreach", NULL, FALSE, FALSE, FALSE, + { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "variable value ... : Do once for each value." } , + { "if", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute if the condition is TRUE." } , + { "else", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Goes with if." } , + { "end", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": End a block." } , + { "break", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Break out of a block." } , + { "continue", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Continue a loop." } , + { "label", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, + (void (*)()) NULL, + "word : Create someplace to go to." } , + { "goto", NULL, FALSE, FALSE, FALSE, + { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, + (void (*)()) NULL, + "word : Go to a label." } , + { "cdump", com_cdump, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Dump the current control structures." } , + { "settype", com_stype, FALSE, FALSE, FALSE, + { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "type vec ... : Change the type of a vector." } , + { "strcmp", com_strcmp, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, + (void (*)()) NULL, + "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , + { "linearize", com_linearize, FALSE, TRUE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + " [ vec ... ] : Convert plot into one with linear scale." } , + { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + NULL } +}; + + +/* Bool fields: stringargs, spiceonly, major */ +struct comm nutcp_coms[] = { + { "let", com_let, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + arg_let, + "varname = expr : Assign vector variables." } , + { "reshape", com_reshape, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + arg_let, + "vector ... [ shape ] : change the dimensions of a vector." } , + { "define", com_define, FALSE, FALSE, TRUE, + { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[[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." } , + { "alias", com_alias, FALSE, FALSE, FALSE, + { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, + (void (*)()) NULL, + "[[word] alias] : Define an alias." } , + { "deftype", com_dftype, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, + (void (*)()) NULL, + "spec name pat ... : Redefine vector and plot types.\n" } , + { "plot", com_plot, FALSE, FALSE, TRUE, + { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, + arg_plot, + "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, + { "display", com_display, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, + arg_display, + ": Display vector status." } , + { "destroy", com_destroy, FALSE, FALSE, FALSE, + { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[plotname] ... : Throw away all the data in the plot." } , + { "setplot", com_splot, FALSE, FALSE, TRUE, + { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[plotname] : Change the current working plot." } , + { "setcirc", NULL, FALSE, TRUE, FALSE, + { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[circuit name] : Change the current circuit." } , + { "setscale", com_setscale, FALSE, FALSE, FALSE, + { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[vecname] : Change default scale of current working plot." } , + { "transpose", com_transpose, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Perform matrix transposition on multi-D vectors." } , + { "xgraph", com_xgraph, FALSE, FALSE, TRUE, + { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "file plotargs : Send plot to Xgraph-11." } , + { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, + { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "file plotargs : Produce hardcopy plots." } , + { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, + { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "plotargs : Produce ascii plots." } , + { "write", com_write, FALSE, FALSE, TRUE, + { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "file expr ... : Write data to a file." } , + { "compose", com_compose, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "var parm=val ... : Compose a vector." } , + { "unlet", com_unlet, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Undefine vectors." } , + { "print", com_print, FALSE, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, + arg_print, + "[col] expr ... : Print vector values." } , + { "load", com_load, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, + arg_load, + "file ... : Load in data." } , + { "cross", com_cross, FALSE, FALSE, TRUE, + { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "vecname number [ vector ... ] : Make a vector in a strange way." } , + { "undefine", com_undefine, FALSE, FALSE, FALSE, + { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[func ...] : Undefine a user-definable function." } , + { "op", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.op line args] : Determine the operating point of the circuit." } , + { "tran", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.tran line args] : Do a transient analysis." } , + { "ac", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.ac line args] : Do an ac analysis." } , + { "dc", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.dc line args] : Do a dc analysis." } , + { "pz", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.pz line args] : Do a pole / zero analysis." } , + { "sens", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.ac line args] : Do a sensitivity analysis." } , + { "disto", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.disto line args] : Do an distortion analysis." } , + { "noise", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[.noise line args] : Do a noise analysis." } , + { "listing", NULL, FALSE, TRUE, TRUE, + { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[logical] [physical] [deck] : Print the current circuit." } , + { "edit", NULL, FALSE, TRUE, TRUE, + { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[filename] : Edit a spice deck and then load it in." } , + { "dump", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Print a dump of the current circuit." } , + { "fourier", com_fourier, FALSE, FALSE, TRUE, + { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "fund_freq vector ... : Do a fourier analysis of some data." } , + { "show", NULL, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "devspecs ... : parmspecs ... : Print out device parameters." } , + { "alter", NULL, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, + (void (*)()) NULL, + "devspecs : parmname value : Alter device parameters." } , + { "altermod", NULL, FALSE, TRUE, FALSE, + { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, + (void (*)()) NULL, + "devspecs : parmname value : Alter model parameters." } , + { "resume", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Continue after a stop." } , + { "state", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "(unimplemented) : Print the state of the circuit." }, + { "stop", NULL, FALSE, TRUE, FALSE, + { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[stop args] : Set a breakpoint." } , + { "trace", NULL, FALSE, TRUE, FALSE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Trace a node." } , + { "save", NULL, FALSE, TRUE, FALSE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Save a spice output." } , + { "iplot", NULL, FALSE, TRUE, TRUE, + { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [node ...] : Incrementally plot a node." } , + { "status", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Print the current breakpoints and traces." } , + { "delete", NULL, FALSE, TRUE, FALSE, + { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[all] [break number ...] : Delete breakpoints and traces." } , + { "step", NULL, FALSE, TRUE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[number] : Iterate number times, or one." } , + { "reset", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Terminate a simulation after a breakpoint (formerly 'end')." } , + { "run", NULL, FALSE, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[rawfile] : Run the simulation as specified in the input file." } , + { "bug", com_bug, FALSE, FALSE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Report a %s bug." } , + { "newhelp", com_ahelp, FALSE, FALSE, TRUE, + { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[command name] ... : help." }, + { "tutorial", com_ghelp, FALSE, FALSE, TRUE, + { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, + (void (*)()) NULL, + "[subject] ... : Hierarchical documentation browser." } , + { "help", com_ghelp, FALSE, FALSE, TRUE, + { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[subject] ... : Hierarchical documentation browser." } , + { "oldhelp", com_help, FALSE, FALSE, TRUE, + { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[command name] ... : Print help." } , + { "quit", com_quit, FALSE, FALSE, TRUE, + { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, + (void (*)()) NULL, + ": Quit %s." } , + { "source", nutcom_source, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "file : Source a %s file." } , + { "shift", com_shift, FALSE, FALSE, FALSE, + { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, + (void (*)()) NULL, + "[var] [number] : Shift argv or the named list var to the left." } , + { "unset", com_unset, FALSE, FALSE, FALSE, + { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "varname ... : Unset a variable." } , + { "unalias", com_unalias, FALSE, FALSE, FALSE, + { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "word ... : Undefine an alias." } , + { "history", com_history, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, + (void (*)()) NULL, + "[-r] [number] : Print command history." } , + { "echo", com_echo, FALSE, FALSE, FALSE, + { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[stuff ...] : Print stuff." } , + { "shell", com_shell, FALSE, FALSE, TRUE, + { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[args] : Fork a shell, or execute the command." } , + { "rusage", com_rusage, FALSE, FALSE, FALSE, + { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[resource ...] : Print current resource usage." } , + { "cd", com_chdir, FALSE, FALSE, FALSE, + { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[directory] : Change working directory." } , + { "version", com_version, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "[number] : Print the version number." } , + { "diff", com_diff, FALSE, FALSE, FALSE, + { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + "plotname plotname [vec ...] : 'diff' two plots." } , + { "rehash", com_rehash, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Rebuild the unix command database." } , + { "while", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute while the condition is TRUE." } , + { "repeat", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, + (void (*)()) NULL, + "[number] : Repeat number times, or forever." } , + { "dowhile", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute while the condition is TRUE." } , + { "foreach", NULL, FALSE, FALSE, FALSE, + { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "variable value ... : Do once for each value." } , + { "if", NULL, FALSE, FALSE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, + (void (*)()) NULL, + "condition : Execute if the condition is TRUE." } , + { "else", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Goes with if." } , + { "end", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": End a block." } , + { "break", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Break out of a block." } , + { "continue", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Continue a loop." } , + { "label", NULL, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, + (void (*)()) NULL, + "word : Create someplace to go to." } , + { "goto", NULL, FALSE, FALSE, FALSE, + { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, + (void (*)()) NULL, + "word : Go to a label." } , + { "cdump", com_cdump, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + (void (*)()) NULL, + ": Dump the current control structures." } , + { "settype", com_stype, FALSE, FALSE, FALSE, + { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, + (void (*)()) NULL, + "type vec ... : Change the type of a vector." } , + { "strcmp", com_strcmp, FALSE, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, + (void (*)()) NULL, + "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , + { "linearize", NULL, FALSE, TRUE, FALSE, + { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + " [ vec ... ] : Convert plot into one with linear scale." } , + + { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, + (void (*)()) NULL, + NULL } + +} ; diff --git a/src/frontend/commands.h b/src/frontend/commands.h new file mode 100644 index 000000000..bfbd5a89f --- /dev/null +++ b/src/frontend/commands.h @@ -0,0 +1,11 @@ +#ifndef _COMMANDS_H +#define _COMMANDS_H + +#include + + + +extern struct comm spcp_coms[]; +extern struct comm nutcp_coms[]; + +#endif diff --git a/src/frontend/completion.h b/src/frontend/completion.h new file mode 100644 index 000000000..c02334ed7 --- /dev/null +++ b/src/frontend/completion.h @@ -0,0 +1,25 @@ +#ifndef _COMPLETION_H +#define _COMPLETION_H + +/* The types for command completion keywords. Note that these + * constants are built into cmdtab.c, so DON'T change them unless you + * want to change all of the bitmasks in cp_coms. Note that this is + * spice- and nutmeg- dependent. */ + +#define CT_FILENAME 0 +#define CT_CKTNAMES 2 +#define CT_COMMANDS 3 +#define CT_DBNUMS 4 +#define CT_DEVNAMES 5 +#define CT_LISTINGARGS 6 +#define CT_NODENAMES 7 +#define CT_PLOT 8 +#define CT_PLOTKEYWORDS 9 +#define CT_RUSEARGS 10 +#define CT_STOPARGS 11 +#define CT_UDFUNCS 12 +#define CT_VARIABLES 13 +#define CT_VECTOR 14 +#define CT_TYPENAMES 16 + +#endif diff --git a/src/frontend/compose.h b/src/frontend/compose.h deleted file mode 100644 index 7e03a72e9..000000000 --- a/src/frontend/compose.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for compose.c - * 1999 E. Rouat - ************/ - -#ifndef COMPOSE_H_INCLUDED -#define COMPOSE_H_INCLUDED - -void com_compose(wordlist *wl); - - -#endif diff --git a/src/frontend/cpitf.c b/src/frontend/cpitf.c index f57463341..7758caf14 100644 --- a/src/frontend/cpitf.c +++ b/src/frontend/cpitf.c @@ -6,10 +6,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "cpitf.h" +#include "completion.h" /* Set some standard variables and aliases, etc, and init the ccom stuff. */ diff --git a/src/frontend/debugcom.c b/src/frontend/debugcom.c index bc2c6584f..36846e594 100644 --- a/src/frontend/debugcom.c +++ b/src/frontend/debugcom.c @@ -11,7 +11,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "cpdefs.h" #include "ftedefs.h" #include "ftedebug.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "debugcom.h" diff --git a/src/frontend/define.c b/src/frontend/define.c index acb430aba..fbe42a47c 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -17,10 +17,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "define.h" +#include "completion.h" /* static declarations */ static void savetree(struct pnode *pn); @@ -439,7 +440,7 @@ com_undefine(wordlist *wlist) */ void -ft_pnode(struct pn *pn) +ft_pnode(struct pnode *pn) { prtree1(pn, cp_err); } diff --git a/src/frontend/diff.c b/src/frontend/diff.c index e4c80cefb..1f99d46f1 100644 --- a/src/frontend/diff.c +++ b/src/frontend/diff.c @@ -10,8 +10,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftecmath.h" +#include "sim.h" + #include "diff.h" diff --git a/src/frontend/dimens.c b/src/frontend/dimens.c index db8788273..bb10dc9f6 100644 --- a/src/frontend/dimens.c +++ b/src/frontend/dimens.c @@ -8,7 +8,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group */ #include "ngspice.h" -#include "ftedata.h" /* For MAXDIMS */ +#include "dvec.h" /* For MAXDIMS */ #include "dimens.h" diff --git a/src/frontend/display.c b/src/frontend/display.c index 898468270..89e3cf1c1 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -15,8 +15,8 @@ Copyright 1990 Regents of the University of California. All rights reserved. /* static declarations */ -static int gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny); -static int gen_Input(REQUEST *request, RESPONSE *response); +static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny); +static void gen_Input(REQUEST *request, RESPONSE *response); static int nop(void); static int nodev(void); @@ -230,7 +230,7 @@ void Update(void) /* note: screen coordinates are relative to window so need to add viewport offsets */ -static int +static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny) { @@ -283,7 +283,7 @@ void Input(REQUEST *request, RESPONSE *response) } -static int +static void gen_Input(REQUEST *request, RESPONSE *response) { diff --git a/src/frontend/doplot.c b/src/frontend/doplot.c index 32e1bb61e..59e38bdff 100644 --- a/src/frontend/doplot.c +++ b/src/frontend/doplot.c @@ -11,10 +11,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "fteinput.h" #include "ftedbgra.h" #include "cpdefs.h" -#include "fteconst.h" +#include "plot.h" #include "ftedefs.h" #include "ftedev.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "fteext.h" #include "doplot.h" diff --git a/src/frontend/dotcards.c b/src/frontend/dotcards.c index d7cb4e987..a2e4f59f9 100644 --- a/src/frontend/dotcards.c +++ b/src/frontend/dotcards.c @@ -10,10 +10,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" -#include "dotcards.h" +#include +#include "dotcards.h" /* Extract all the .save lines */ diff --git a/src/frontend/evaluate.c b/src/frontend/evaluate.c index 92189e32f..e4a42b0bd 100644 --- a/src/frontend/evaluate.c +++ b/src/frontend/evaluate.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "ftecmath.h" #include @@ -22,9 +22,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group static RETSIGTYPE sig_matherr(void); static struct dvec * apply_func(struct func *func, struct pnode *arg); static char * mkcname(char what, char *v1, char *v2); -static struct dvec * doop(char what, void *(*func) (/* ??? */), - struct pnode *arg1, struct pnode *arg2); - /* We are careful here to catch SIGILL and recognise them as math errors. @@ -81,8 +78,226 @@ ft_evaluate(struct pnode *node) return (d); } -/* The binary operations. */ +/* Operate on two vectors, and return a third with the data, length, and flags + * fields filled in. Add it to the current plot and get rid of the two args. + */ + +static struct dvec * +doop(char what, + void*(*func) (void *data1, void *data2, + short int datatype1, short int datatype2, + int length), + struct pnode *arg1, + struct pnode *arg2) +{ + struct dvec *v1, *v2, *res; + complex *c1, *c2, lc; + double *d1, *d2, ld; + int length, i; + void *data; + bool free1 = FALSE, free2 = FALSE, relflag = FALSE; + + v1 = ft_evaluate(arg1); + v2 = ft_evaluate(arg2); + if (!v1 || !v2) + return (NULL); + + /* Now the question is, what do we do when one or both of these + * has more than one vector? This is definitely not a good + * thing. For the time being don't do anything. + */ + if (v1->v_link2 || v2->v_link2) { + fprintf(cp_err, "Warning: no operations on wildcards yet.\n"); + if (v1->v_link2 && v2->v_link2) + fprintf(cp_err, "\t(You couldn't do that one anyway)\n"); + return (NULL); + } + + /* How do we handle operations on multi-dimensional vectors? + * For now, we only allow operations between one-D vectors, + * equivalently shaped multi-D vectors, or a multi-D vector and + * a one-D vector. It's not at all clear what to do in the other cases. + * So only check shape requirement if its an operation between two multi-D + * arrays. + */ + if ((v1->v_numdims > 1) && (v2->v_numdims > 1)) { + if (v1->v_numdims != v2->v_numdims) { + fprintf(cp_err, + "Warning: operands %s and %s have incompatible shapes.\n", + v1->v_name, v2->v_name); + return (NULL); + } + for (i = 1; i < v1->v_numdims; i++) { + if ((v1->v_dims[i] != v2->v_dims[i])) { + fprintf(cp_err, + "Warning: operands %s and %s have incompatible shapes.\n", + v1->v_name, v2->v_name); + return (NULL); + } + } + } + + /* This is a bad way to do this. */ + switch (what) { + case '=': + case '>': + case '<': + case 'G': + case 'L': + case 'N': + case '&': + case '|': + case '~': + relflag = TRUE; + } + + /* Don't bother to do type checking. Maybe this should go in at + * some point. + */ + + /* Make sure we have data of the same length. */ + length = ((v1->v_length > v2->v_length) ? v1->v_length : v2->v_length); + if (v1->v_length < length) { + free1 = TRUE; + if (isreal(v1)) { + ld = 0.0; + d1 = (double *) tmalloc(length * sizeof (double)); + for (i = 0; i < v1->v_length; i++) + d1[i] = v1->v_realdata[i]; + if (length > 0) + ld = v1->v_realdata[v1->v_length - 1]; + for ( ; i < length; i++) + d1[i] = ld; + } else { + realpart(&lc) = 0.0; + imagpart(&lc) = 0.0; + c1 = (complex *) tmalloc(length * sizeof (complex)); + for (i = 0; i < v1->v_length; i++) + c1[i] = v1->v_compdata[i]; + if (length > 0) + lc = v1->v_compdata[v1->v_length - 1]; + for ( ; i < length; i++) + c1[i] = lc; + } + } else + if (isreal(v1)) + d1 = v1->v_realdata; + else + c1 = v1->v_compdata; + if (v2->v_length < length) { + free2 = TRUE; + if (isreal(v2)) { + ld = 0.0; + d2 = (double *) tmalloc(length * sizeof (double)); + for (i = 0; i < v2->v_length; i++) + d2[i] = v2->v_realdata[i]; + if (length > 0) + ld = v2->v_realdata[v2->v_length - 1]; + for ( ; i < length; i++) + d2[i] = ld; + } else { + realpart(&lc) = 0.0; + imagpart(&lc) = 0.0; + c2 = (complex *) tmalloc(length * sizeof (complex)); + for (i = 0; i < v2->v_length; i++) + c2[i] = v2->v_compdata[i]; + if (length > 0) + lc = v2->v_compdata[v1->v_length - 1]; + for ( ; i < length; i++) + c2[i] = lc; + } + } else + if (isreal(v2)) + d2 = v2->v_realdata; + else + c2 = v2->v_compdata; + + /* Some of the math routines generate SIGILL if the argument is + * out of range. Catch this here. + */ + if (setjmp(matherrbuf)) { + return (NULL); + } + (void) signal(SIGILL, (SIGNAL_FUNCTION) sig_matherr); + + /* Now pass the vectors to the appropriate function. */ + data = ((*func) ((isreal(v1) ? (void *) d1 : (void *) c1), + (isreal(v2) ? (void *) d2 : (void *) c2), + (isreal(v1) ? VF_REAL : VF_COMPLEX), + (isreal(v2) ? VF_REAL : VF_COMPLEX), + length)); + /* Back to normal */ + (void) signal(SIGILL, SIG_DFL); + + if (!data) + return (NULL); + /* Make up the new vector. */ + res = alloc(struct dvec); + ZERO(res,struct dvec); + if (relflag || (isreal(v1) && isreal(v2) && (func != cx_comma))) { + res->v_flags = (v1->v_flags | v2->v_flags | + VF_REAL) & ~ VF_COMPLEX; + res->v_realdata = (double *) data; + } else { + res->v_flags = (v1->v_flags | v2->v_flags | + VF_COMPLEX) & ~ VF_REAL; + res->v_compdata = (complex *) data; + } + + res->v_name = mkcname(what, v1->v_name, v2->v_name); + res->v_length = length; + + /* This is a non-obvious thing */ + if (v1->v_scale != v2->v_scale) { + fprintf(cp_err, "Warning: scales of %s and %s are different.\n", + v1->v_name, v2->v_name); + res->v_scale = NULL; + } else + res->v_scale = v1->v_scale; + + /* Copy a few useful things */ + res->v_defcolor = v1->v_defcolor; + res->v_gridtype = v1->v_gridtype; + res->v_plottype = v1->v_plottype; + + /* Copy dimensions. */ + if (v1->v_numdims > v2->v_numdims) { + res->v_numdims = v1->v_numdims; + for (i = 0; i < v1->v_numdims; i++) + res->v_dims[i] = v1->v_dims[i]; + } else { + res->v_numdims = v2->v_numdims; + for (i = 0; i < v2->v_numdims; i++) + res->v_dims[i] = v2->v_dims[i]; + } + + /* This depends somewhat on what the operation is. XXX Should fix */ + res->v_type = v1->v_type; + vec_new(res); + + /* Free the temporary data areas we used, if we allocated any. */ + if (free1) { + if (isreal(v1)) { + tfree(d1); + } else { + tfree(c1); + } + } + if (free2) { + if (isreal(v2)) { + tfree(d2); + } else { + tfree(c2); + } + } + + return (res); +} + + + +/* The binary operations. */ struct dvec * op_plus(struct pnode *arg1, struct pnode *arg2) { @@ -476,6 +691,11 @@ apply_func(struct func *func, struct pnode *arg) } (void) signal(SIGILL, (SIGNAL_FUNCTION) sig_matherr); +#if 0 + /* FIXME: The call to (*func->fu_func) has too many arguments; + hence the compiler quits. How to circumvent this (without + losing function prototypes)? For now, these functions have + been disabled. */ if (eq(func->fu_name, "interpolate") || eq(func->fu_name, "deriv")) /* Ack */ { @@ -487,13 +707,16 @@ apply_func(struct func *func, struct pnode *arg) v->v_length, &len, &type, v->v_plot, plot_cur, v->v_dims[0])); } else { +#endif data = ((*func->fu_func) ((isreal(v) ? (void *) v->v_realdata : (void *) v->v_compdata), (short) (isreal(v) ? VF_REAL : VF_COMPLEX), v->v_length, &len, &type)); +#if 0 } +#endif /* Back to normal */ (void) signal(SIGILL, SIG_DFL); @@ -586,215 +809,3 @@ mkcname(char what, char *v1, char *v2) return (s); } -/* Operate on two vectors, and return a third with the data, length, and flags - * fields filled in. Add it to the current plot and get rid of the two args. - */ - -static struct dvec * -doop(char what, void*(*func) (/* ??? */), struct pnode *arg1, - struct pnode *arg2) -{ - struct dvec *v1, *v2, *res; - complex *c1, *c2, lc; - double *d1, *d2, ld; - int length, i; - void *data; - bool free1 = FALSE, free2 = FALSE, relflag = FALSE; - - v1 = ft_evaluate(arg1); - v2 = ft_evaluate(arg2); - if (!v1 || !v2) - return (NULL); - - /* Now the question is, what do we do when one or both of these - * has more than one vector? This is definitely not a good - * thing. For the time being don't do anything. - */ - if (v1->v_link2 || v2->v_link2) { - fprintf(cp_err, "Warning: no operations on wildcards yet.\n"); - if (v1->v_link2 && v2->v_link2) - fprintf(cp_err, "\t(You couldn't do that one anyway)\n"); - return (NULL); - } - - /* How do we handle operations on multi-dimensional vectors? - * For now, we only allow operations between one-D vectors, - * equivalently shaped multi-D vectors, or a multi-D vector and - * a one-D vector. It's not at all clear what to do in the other cases. - * So only check shape requirement if its an operation between two multi-D - * arrays. - */ - if ((v1->v_numdims > 1) && (v2->v_numdims > 1)) { - if (v1->v_numdims != v2->v_numdims) { - fprintf(cp_err, - "Warning: operands %s and %s have incompatible shapes.\n", - v1->v_name, v2->v_name); - return (NULL); - } - for (i = 1; i < v1->v_numdims; i++) { - if ((v1->v_dims[i] != v2->v_dims[i])) { - fprintf(cp_err, - "Warning: operands %s and %s have incompatible shapes.\n", - v1->v_name, v2->v_name); - return (NULL); - } - } - } - - /* This is a bad way to do this. */ - switch (what) { - case '=': - case '>': - case '<': - case 'G': - case 'L': - case 'N': - case '&': - case '|': - case '~': - relflag = TRUE; - } - - /* Don't bother to do type checking. Maybe this should go in at - * some point. - */ - - /* Make sure we have data of the same length. */ - length = ((v1->v_length > v2->v_length) ? v1->v_length : v2->v_length); - if (v1->v_length < length) { - free1 = TRUE; - if (isreal(v1)) { - ld = 0.0; - d1 = (double *) tmalloc(length * sizeof (double)); - for (i = 0; i < v1->v_length; i++) - d1[i] = v1->v_realdata[i]; - if (length > 0) - ld = v1->v_realdata[v1->v_length - 1]; - for ( ; i < length; i++) - d1[i] = ld; - } else { - realpart(&lc) = 0.0; - imagpart(&lc) = 0.0; - c1 = (complex *) tmalloc(length * sizeof (complex)); - for (i = 0; i < v1->v_length; i++) - c1[i] = v1->v_compdata[i]; - if (length > 0) - lc = v1->v_compdata[v1->v_length - 1]; - for ( ; i < length; i++) - c1[i] = lc; - } - } else - if (isreal(v1)) - d1 = v1->v_realdata; - else - c1 = v1->v_compdata; - if (v2->v_length < length) { - free2 = TRUE; - if (isreal(v2)) { - ld = 0.0; - d2 = (double *) tmalloc(length * sizeof (double)); - for (i = 0; i < v2->v_length; i++) - d2[i] = v2->v_realdata[i]; - if (length > 0) - ld = v2->v_realdata[v2->v_length - 1]; - for ( ; i < length; i++) - d2[i] = ld; - } else { - realpart(&lc) = 0.0; - imagpart(&lc) = 0.0; - c2 = (complex *) tmalloc(length * sizeof (complex)); - for (i = 0; i < v2->v_length; i++) - c2[i] = v2->v_compdata[i]; - if (length > 0) - lc = v2->v_compdata[v1->v_length - 1]; - for ( ; i < length; i++) - c2[i] = lc; - } - } else - if (isreal(v2)) - d2 = v2->v_realdata; - else - c2 = v2->v_compdata; - - /* Some of the math routines generate SIGILL if the argument is - * out of range. Catch this here. - */ - if (setjmp(matherrbuf)) { - return (NULL); - } - (void) signal(SIGILL, (SIGNAL_FUNCTION) sig_matherr); - - /* Now pass the vectors to the appropriate function. */ - data = ((*func) ((isreal(v1) ? (void *) d1 : (void *) c1), - (isreal(v2) ? (void *) d2 : (void *) c2), - (isreal(v1) ? VF_REAL : VF_COMPLEX), - (isreal(v2) ? VF_REAL : VF_COMPLEX), - length)); - /* Back to normal */ - (void) signal(SIGILL, SIG_DFL); - - if (!data) - return (NULL); - /* Make up the new vector. */ - res = alloc(struct dvec); - ZERO(res,struct dvec); - if (relflag || (isreal(v1) && isreal(v2) && (func != cx_comma))) { - res->v_flags = (v1->v_flags | v2->v_flags | - VF_REAL) & ~ VF_COMPLEX; - res->v_realdata = (double *) data; - } else { - res->v_flags = (v1->v_flags | v2->v_flags | - VF_COMPLEX) & ~ VF_REAL; - res->v_compdata = (complex *) data; - } - - res->v_name = mkcname(what, v1->v_name, v2->v_name); - res->v_length = length; - - /* This is a non-obvious thing */ - if (v1->v_scale != v2->v_scale) { - fprintf(cp_err, "Warning: scales of %s and %s are different.\n", - v1->v_name, v2->v_name); - res->v_scale = NULL; - } else - res->v_scale = v1->v_scale; - - /* Copy a few useful things */ - res->v_defcolor = v1->v_defcolor; - res->v_gridtype = v1->v_gridtype; - res->v_plottype = v1->v_plottype; - - /* Copy dimensions. */ - if (v1->v_numdims > v2->v_numdims) { - res->v_numdims = v1->v_numdims; - for (i = 0; i < v1->v_numdims; i++) - res->v_dims[i] = v1->v_dims[i]; - } else { - res->v_numdims = v2->v_numdims; - for (i = 0; i < v2->v_numdims; i++) - res->v_dims[i] = v2->v_dims[i]; - } - - /* This depends somewhat on what the operation is. XXX Should fix */ - res->v_type = v1->v_type; - vec_new(res); - - /* Free the temporary data areas we used, if we allocated any. */ - if (free1) { - if (isreal(v1)) { - tfree(d1); - } else { - tfree(c1); - } - } - if (free2) { - if (isreal(v2)) { - tfree(d2); - } else { - tfree(c2); - } - } - - return (res); -} - diff --git a/src/frontend/fourier.c b/src/frontend/fourier.c index bdcc584cc..c1fe674f1 100644 --- a/src/frontend/fourier.c +++ b/src/frontend/fourier.c @@ -12,7 +12,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "sperror.h" #include "const.h" diff --git a/src/frontend/graf.c b/src/frontend/graf.c index 00b98d1d8..88b781053 100644 --- a/src/frontend/graf.c +++ b/src/frontend/graf.c @@ -13,9 +13,9 @@ Author: 1988 Jeffrey M. Hsu #include "ngspice.h" #include "cpdefs.h" /* for VT_ */ #include "cpextern.h" -#include "fteconst.h" +#include "plot.h" #include "ftedebug.h" /* for iplot */ -#include "ftedata.h" /* for struct dvec */ +#include "dvec.h" /* for struct dvec */ #include "ftedefs.h" /* for FTEextern.h and IPOINT{MIN,MAX} */ #include "fteinput.h" #include "ftegraph.h" diff --git a/src/frontend/grid.c b/src/frontend/grid.c index 7eac11015..0aed11550 100644 --- a/src/frontend/grid.c +++ b/src/frontend/grid.c @@ -11,7 +11,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include "ftegraph.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "grid.h" diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 1eff7c211..e1e34811f 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -12,11 +12,11 @@ Author: 1985 Wayne A. Christopher #include "cpdefs.h" #include "inpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "inp.h" - +#include "completion.h" /* static declarations */ static char * upper(register char *string); diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 06739ae31..b9c61fba2 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -11,7 +11,7 @@ Author: 1985 Wayne A. Christopher #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "inpcom.h" diff --git a/src/frontend/interp.c b/src/frontend/interp.c index 834f28ebf..6ecb8eb1a 100644 --- a/src/frontend/interp.c +++ b/src/frontend/interp.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "interp.h" @@ -24,7 +24,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group /* static declarations */ static int putinterval(double *poly, int degree, double *nvec, int last, double *nscale, int nlen, double oval, int sign); -static void printmat(char *name, double *mat, int m, int n); bool @@ -260,21 +259,6 @@ putinterval(double *poly, int degree, double *nvec, int last, double *nscale, in return (end); } -static void -printmat(char *name, double *mat, int m, int n) -{ - int i, j; - - printf("\n\r=== Matrix: %s ===\n\r", name); - for (i = 0; i < m; i++) { - printf(" | "); - for (j = 0; j < n; j++) - printf("%G ", mat[i * n + j]); - printf("|\n\r"); - } - printf("===\n\r"); - return; -} double ft_peval(double x, double *coeffs, int degree) diff --git a/src/frontend/linear.c b/src/frontend/linear.c index 0ac8006fc..d9e54a781 100644 --- a/src/frontend/linear.c +++ b/src/frontend/linear.c @@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "linear.h" diff --git a/src/frontend/misccoms.c b/src/frontend/misccoms.c index 636e4f3b7..cf2e110a1 100644 --- a/src/frontend/misccoms.c +++ b/src/frontend/misccoms.c @@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftehelp.h" #include "hlpdefs.h" #include "misccoms.h" @@ -14,6 +14,16 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group static void byemesg(void); +static int +hcomp(const void *a, const void *b) +{ + struct comm **c1 = (struct comm **) a; + struct comm **c2 = (struct comm **) b; + return (strcmp((*c1)->co_comname, (*c2)->co_comname)); +} + + + void com_help(wordlist *wl) { @@ -227,12 +237,6 @@ com_ghelp(wordlist *wl) return; } -int -hcomp(struct comm **c1, struct comm **c2) -{ - return (strcmp((*c1)->co_comname, (*c2)->co_comname)); -} - void com_quit(wordlist *wl) diff --git a/src/frontend/misccoms.h b/src/frontend/misccoms.h index 849f84c92..d478a25ab 100644 --- a/src/frontend/misccoms.h +++ b/src/frontend/misccoms.h @@ -9,7 +9,6 @@ void com_help(wordlist *wl); void com_ahelp(wordlist *wl); void com_ghelp(wordlist *wl); -int hcomp(struct comm **c1, struct comm **c2); void com_quit(wordlist *wl); void com_bug(wordlist *wl); void com_version(wordlist *wl); diff --git a/src/frontend/miscvars.c b/src/frontend/miscvars.c index eeb4c8a57..95da681bf 100644 --- a/src/frontend/miscvars.c +++ b/src/frontend/miscvars.c @@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "miscvars.h" diff --git a/src/frontend/mw_coms.c b/src/frontend/mw_coms.c index fd7fab110..217ce1b30 100644 --- a/src/frontend/mw_coms.c +++ b/src/frontend/mw_coms.c @@ -7,7 +7,7 @@ #include "ftedefs.h" #include "ftedev.h" #include "ftedebug.h" -#include "ftedata.h" +#include "dvec.h" #include "mw_coms.h" diff --git a/src/frontend/newcoms.c b/src/frontend/newcoms.c index 93ded1cc6..99e921867 100644 --- a/src/frontend/newcoms.c +++ b/src/frontend/newcoms.c @@ -10,7 +10,7 @@ Copyright 1992 Regents of the University of California. All rights reserved. #include "cpdefs.h" #include "ftedefs.h" #include "fteparse.h" -#include "ftedata.h" +#include "dvec.h" #include "newcoms.h" diff --git a/src/frontend/nutctab.c b/src/frontend/nutctab.c deleted file mode 100644 index cf0df5a8a..000000000 --- a/src/frontend/nutctab.c +++ /dev/null @@ -1,355 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Table of available commands. Note that they're sorted so that the commands - * that appear in the spiceinit file are at the top. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftehelp.h" -#include "nutctab.h" - - -/* Bool fields: stringargs, spiceonly, major */ - -struct comm nutcp_coms[] = { - { "let", com_let, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - arg_let, - "varname = expr : Assign vector variables." } , - { "reshape", com_reshape, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - arg_let, - "vector ... [ shape ] : change the dimensions of a vector." } , - { "define", com_define, FALSE, FALSE, TRUE, - { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[[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." } , - { "alias", com_alias, FALSE, FALSE, FALSE, - { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, - (int (*)()) NULL, - "[[word] alias] : Define an alias." } , - { "deftype", com_dftype, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "spec name pat ... : Redefine vector and plot types.\n" } , - { "plot", com_plot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, - arg_plot, - "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, - { "display", com_display, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, - arg_display, - ": Display vector status." } , - { "destroy", com_destroy, FALSE, FALSE, FALSE, - { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[plotname] ... : Throw away all the data in the plot." } , - { "setplot", com_splot, FALSE, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[plotname] : Change the current working plot." } , - { "setcirc", NULL, FALSE, TRUE, FALSE, - { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[circuit name] : Change the current circuit." } , - { "setscale", com_setscale, FALSE, FALSE, FALSE, - { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[vecname] : Change default scale of current working plot." } , - { "transpose", com_transpose, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Perform matrix transposition on multi-D vectors." } , - { "xgraph", com_xgraph, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file plotargs : Send plot to Xgraph-11." } , - { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file plotargs : Produce hardcopy plots." } , - { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "plotargs : Produce ascii plots." } , - { "write", com_write, FALSE, FALSE, TRUE, - { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file expr ... : Write data to a file." } , - { "compose", com_compose, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "var parm=val ... : Compose a vector." } , - { "unlet", com_unlet, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Undefine vectors." } , - { "print", com_print, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, - arg_print, - "[col] expr ... : Print vector values." } , - { "load", com_load, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, - arg_load, - "file ... : Load in data." } , - { "cross", com_cross, FALSE, FALSE, TRUE, - { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "vecname number [ vector ... ] : Make a vector in a strange way." } , - { "undefine", com_undefine, FALSE, FALSE, FALSE, - { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[func ...] : Undefine a user-definable function." } , - { "op", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.op line args] : Determine the operating point of the circuit." } , - { "tran", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "ac", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do an ac analysis." } , - { "dc", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.dc line args] : Do a dc analysis." } , - { "pz", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.pz line args] : Do a pole / zero analysis." } , - { "sens", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do a sensitivity analysis." } , - { "disto", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.disto line args] : Do an distortion analysis." } , - { "noise", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.noise line args] : Do a noise analysis." } , - { "listing", NULL, FALSE, TRUE, TRUE, - { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[logical] [physical] [deck] : Print the current circuit." } , - { "edit", NULL, FALSE, TRUE, TRUE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[filename] : Edit a spice deck and then load it in." } , - { "dump", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print a dump of the current circuit." } , - { "fourier", com_fourier, FALSE, FALSE, TRUE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "fund_freq vector ... : Do a fourier analysis of some data." } , - { "show", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs ... : parmspecs ... : Print out device parameters." } , - { "alter", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter device parameters." } , - { "altermod", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter model parameters." } , - { "resume", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue after a stop." } , - { "state", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "(unimplemented) : Print the state of the circuit." }, - { "stop", NULL, FALSE, TRUE, FALSE, - { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stop args] : Set a breakpoint." } , - { "trace", NULL, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Trace a node." } , - { "save", NULL, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Save a spice output." } , - { "iplot", NULL, FALSE, TRUE, TRUE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Incrementally plot a node." } , - { "status", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print the current breakpoints and traces." } , - { "delete", NULL, FALSE, TRUE, FALSE, - { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [break number ...] : Delete breakpoints and traces." } , - { "step", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Iterate number times, or one." } , - { "reset", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Terminate a simulation after a breakpoint (formerly 'end')." } , - { "run", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[rawfile] : Run the simulation as specified in the input file." } , - { "bug", com_bug, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report a %s bug." } , - { "newhelp", com_ahelp, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : help." }, - { "tutorial", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "help", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "oldhelp", com_help, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : Print help." } , - { "quit", com_quit, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, - (int (*)()) NULL, - ": Quit %s." } , - { "source", nutcom_source, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file : Source a %s file." } , - { "shift", com_shift, FALSE, FALSE, FALSE, - { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[var] [number] : Shift argv or the named list var to the left." } , - { "unset", com_unset, FALSE, FALSE, FALSE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Unset a variable." } , - { "unalias", com_unalias, FALSE, FALSE, FALSE, - { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "word ... : Undefine an alias." } , - { "history", com_history, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[-r] [number] : Print command history." } , - { "echo", com_echo, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stuff ...] : Print stuff." } , - { "shell", com_shell, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[args] : Fork a shell, or execute the command." } , - { "rusage", com_rusage, FALSE, FALSE, FALSE, - { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[resource ...] : Print current resource usage." } , - { "cd", com_chdir, FALSE, FALSE, FALSE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[directory] : Change working directory." } , - { "version", com_version, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[number] : Print the version number." } , - { "diff", com_diff, FALSE, FALSE, FALSE, - { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "plotname plotname [vec ...] : 'diff' two plots." } , - { "rehash", com_rehash, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Rebuild the unix command database." } , - { "while", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "repeat", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Repeat number times, or forever." } , - { "dowhile", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "foreach", NULL, FALSE, FALSE, FALSE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "variable value ... : Do once for each value." } , - { "if", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute if the condition is TRUE." } , - { "else", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Goes with if." } , - { "end", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": End a block." } , - { "break", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Break out of a block." } , - { "continue", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue a loop." } , - { "label", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Create someplace to go to." } , - { "goto", NULL, FALSE, FALSE, FALSE, - { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Go to a label." } , - { "cdump", com_cdump, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Dump the current control structures." } , - { "settype", com_stype, FALSE, FALSE, FALSE, - { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "type vec ... : Change the type of a vector." } , - { "strcmp", com_strcmp, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, - (int (*)()) NULL, - "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , - { "linearize", NULL, FALSE, TRUE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - " [ vec ... ] : Convert plot into one with linear scale." } , - - { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - NULL } - -} ; - diff --git a/src/frontend/nutctab.h b/src/frontend/nutctab.h deleted file mode 100644 index f94f5b947..000000000 --- a/src/frontend/nutctab.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for nutctab.c - * 1999 E. Rouat - ************/ - -#ifndef NUTCTAB_H_INCLUDED -#define NUTCTAB_H_INCLUDED - - - - -#endif diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 7b38dc68c..fe83755b8 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "nutinp.h" diff --git a/src/frontend/options.c b/src/frontend/options.c index 369166e57..b918dbbe8 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -13,7 +13,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteinp.h" #include "options.h" diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index db5de7c17..247f61ff3 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -13,8 +13,9 @@ Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" -#include "fteconst.h" +#include "dvec.h" +#include "plot.h" +#include "sim.h" #include "inpdefs.h" /* for INPtables */ #include "ifsim.h" #include "jobdefs.h" diff --git a/src/frontend/parse.c b/src/frontend/parse.c index 88cbf86a5..d59b1ae24 100644 --- a/src/frontend/parse.c +++ b/src/frontend/parse.c @@ -12,9 +12,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "cpdefs.h" #include "ftedefs.h" #include "fteparse.h" -#include "ftedata.h" +#include "dvec.h" #include "ftecmath.h" #include "parse.h" +#include "sim.h" /* static declarations */ diff --git a/src/frontend/plotcurv.c b/src/frontend/plotcurv.c index f34393d8c..3ece5fd69 100644 --- a/src/frontend/plotcurv.c +++ b/src/frontend/plotcurv.c @@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftegraph.h" #include "ftedbgra.h" #include "plotcurv.h" diff --git a/src/frontend/plotting/.cvsignore b/src/frontend/plotting/.cvsignore new file mode 100644 index 000000000..e440fafda --- /dev/null +++ b/src/frontend/plotting/.cvsignore @@ -0,0 +1,3 @@ +Makefile.in +Makefile +.deps diff --git a/src/frontend/plotting/Makefile.am b/src/frontend/plotting/Makefile.am new file mode 100644 index 000000000..f7585b8af --- /dev/null +++ b/src/frontend/plotting/Makefile.am @@ -0,0 +1,17 @@ +noinst_LIBRARIES = libplotting.a + +libplotting_a_SOURCES = \ + plotting.c \ + plotting.h \ + pvec.c \ + pvec.h \ + plot5.c \ + plot5.h \ + x11.c \ + x11.h \ + xgraph.c \ + xgraph.h + +INCLUDES = -I$(top_srcdir)/src/include @X_CFLAGS@ + +MAINTAINERCLEANFILES = Makefile.in diff --git a/src/frontend/plot5.c b/src/frontend/plotting/plot5.c similarity index 100% rename from src/frontend/plot5.c rename to src/frontend/plotting/plot5.c diff --git a/src/frontend/plot5.h b/src/frontend/plotting/plot5.h similarity index 100% rename from src/frontend/plot5.h rename to src/frontend/plotting/plot5.h diff --git a/src/frontend/plotting/plotting.c b/src/frontend/plotting/plotting.c new file mode 100644 index 000000000..761049958 --- /dev/null +++ b/src/frontend/plotting/plotting.c @@ -0,0 +1,16 @@ +#include + +#include "plotting.h" + +/* Where 'constants' go when defined on initialization. */ + +struct plot constantplot = { + "Constant values", "Sat Aug 16 10:55:15 PDT 1986", "constants", + "const", NULL, NULL, NULL, NULL, NULL, NULL, TRUE +} ; + +struct plot *plot_cur = &constantplot; +struct plot *plot_list = &constantplot; +int plotl_changed; /* TRUE after a load */ + +int plot_num = 1; diff --git a/src/frontend/plotting/plotting.h b/src/frontend/plotting/plotting.h new file mode 100644 index 000000000..30f7cba76 --- /dev/null +++ b/src/frontend/plotting/plotting.h @@ -0,0 +1,12 @@ +#ifndef _PLOTTING_H +#define _PLOTTING_H + +#include + +extern struct plot constantplot; +extern struct plot *plot_cur; +extern struct plot *plot_list; +extern int plotl_changed; +extern int plot_num; + +#endif diff --git a/src/frontend/plotting/pvec.c b/src/frontend/plotting/pvec.c new file mode 100644 index 000000000..2c5d70145 --- /dev/null +++ b/src/frontend/plotting/pvec.c @@ -0,0 +1,85 @@ +#include +#include +#include +#include + +#include "pvec.h" + +void +pvec(struct dvec *d) +{ + char buf[BSIZE_SP], buf2[BSIZE_SP]; + + sprintf(buf, " %-20s: %s, %s, %d long", + d->v_name, + ft_typenames(d->v_type), + isreal(d) ? "real" : "complex", + d->v_length); + if (d->v_flags & VF_MINGIVEN) { + sprintf(buf2, ", min = %g", d->v_minsignal); + strcat(buf, buf2); + } + if (d->v_flags & VF_MAXGIVEN) { + sprintf(buf2, ", max = %g", d->v_maxsignal); + strcat(buf, buf2); + } + switch (d->v_gridtype) { + case GRID_LOGLOG: + strcat(buf, ", grid = loglog"); + break; + + case GRID_XLOG: + strcat(buf, ", grid = xlog"); + break; + + case GRID_YLOG: + strcat(buf, ", grid = ylog"); + break; + + case GRID_POLAR: + strcat(buf, ", grid = polar"); + break; + + case GRID_SMITH: + strcat(buf, ", grid = smith (xformed)"); + break; + + case GRID_SMITHGRID: + strcat(buf, ", grid = smithgrid (not xformed)"); + break; + + default: + } + + switch (d->v_plottype) { + + case PLOT_COMB: + strcat(buf, ", plot = comb"); + break; + + case PLOT_POINT: + strcat(buf, ", plot = point"); + break; + + default: + } + if (d->v_defcolor) { + sprintf(buf2, ", color = %s", d->v_defcolor); + strcat(buf, buf2); + } + if (d->v_scale) { + sprintf(buf2, ", scale = %s", d->v_scale->v_name); + strcat(buf, buf2); + } + if (d->v_numdims > 1) { + sprintf(buf2, ", dims = [%s]", dimstring(d->v_dims, d->v_numdims)); + strcat(buf, buf2); + } + if (d->v_plot->pl_scale == d) { + strcat(buf, " [default scale]\n"); + } else { + strcat(buf, "\n"); + } + out_send(buf); + return; +} diff --git a/src/frontend/plotting/pvec.h b/src/frontend/plotting/pvec.h new file mode 100644 index 000000000..2b2ef883d --- /dev/null +++ b/src/frontend/plotting/pvec.h @@ -0,0 +1,8 @@ +#ifndef _PVEC_H +#define _PVEC_H + +#include + +void pvec(struct dvec *d); + +#endif diff --git a/src/frontend/x11.c b/src/frontend/plotting/x11.c similarity index 98% rename from src/frontend/x11.c rename to src/frontend/plotting/x11.c index 65e899140..f34e3ecf6 100644 --- a/src/frontend/x11.c +++ b/src/frontend/plotting/x11.c @@ -89,8 +89,6 @@ static int numdispplanes; extern void internalerror (char *message); extern void externalerror (char *message); -void initlinestyles (void); -void initcolors (GRAPH *graph); extern void PushGraphContext (GRAPH *graph); extern void SetColor (int colorid); extern void Text (char *text, int x, int y); @@ -98,11 +96,21 @@ extern void SaveText (GRAPH *graph, char *text, int x, int y); extern void PopGraphContext (void); void slopelocation (GRAPH *graph, int x0, int y0); void zoomin (GRAPH *graph); -void X_ScreentoData (GRAPH *graph, int x, int y, double *fx, double *fy); extern int DestroyGraph (int id); extern void gr_redraw (GRAPH *graph); extern void gr_resize (GRAPH *graph); + +int +errorhandler(Display *display, XErrorEvent *errorev) +{ + XGetErrorText(display, errorev->error_code, ErrorMessage, 1024); + externalerror(ErrorMessage); + return 0; +} + + + int X11_Init(void) { @@ -169,159 +177,6 @@ X11_Init(void) } -void -errorhandler(Display *display, XErrorEvent *errorev) -{ - XGetErrorText(display, errorev->error_code, ErrorMessage, 1024); - externalerror(ErrorMessage); -} - -/* Recover from bad NewViewPort call. */ -#define RECOVERNEWVIEWPORT() free((char *) graph);\ - graph = (GRAPH *) NULL; - /* need to do this or else DestroyGraph will free it again */ - -/* NewViewport is responsible for filling in graph->viewport */ -int -X11_NewViewport(GRAPH *graph) -{ - - char fontname[513]; /* who knows . . . */ - char *p, *q; - Cursor cursor; - XSetWindowAttributes w_attrs; - XGCValues gcvalues; - static Arg formargs[ ] = { - { XtNleft, (XtArgVal) XtChainLeft }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg bboxargs[ ] = { - { XtNfromHoriz, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtChainRight }, - { XtNright, (XtArgVal) XtChainRight } - }; - static Arg buttonargs[ ] = { - { XtNlabel, (XtArgVal) NULL }, - { XtNfromVert, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtRubber }, - { XtNright, (XtArgVal) XtRubber }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg viewargs[] = { - { XtNresizable, (XtArgVal) TRUE }, - { XtNwidth, (XtArgVal) 300 }, - { XtNheight, (XtArgVal) 300 }, - { XtNright, (XtArgVal) XtChainRight } - }; - int trys; - - graph->devdep = calloc(1, sizeof(X11devdep)); - - /* set up new shell */ - DEVDEP(graph).shell = XtCreateApplicationShell("shell", - topLevelShellWidgetClass, NULL, 0); - - /* set up form widget */ - DEVDEP(graph).form = XtCreateManagedWidget("form", - formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); - - /* set up viewport */ - DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, - DEVDEP(graph).form, viewargs, XtNumber(viewargs)); - XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, - handlebuttonev, graph); - XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, - handlekeypressed, graph); - XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, - resize, graph); - XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, - redraw, graph); - - /* set up button box */ - XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); - DEVDEP(graph).buttonbox = XtCreateManagedWidget("buttonbox", - boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); - - /* set up buttons */ - XtSetArg(buttonargs[0], XtNlabel, "quit"); - XtSetArg(bboxargs[1], XtNfromVert, NULL); - DEVDEP(graph).buttons[0] = XtCreateManagedWidget("quit", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, killwin, graph); - - XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); - XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); - DEVDEP(graph).buttons[1] = XtCreateManagedWidget("hardcopy", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, hardcopy, graph); - - /* set up fonts */ - if (!cp_getvar("font", VT_STRING, fontname)) { - (void) strcpy(fontname, DEF_FONT); - } - - for (p = fontname; *p && *p <= ' '; p++) - ; - if (p != fontname) { - for (q = fontname; *p; *q++ = *p++) - ; - *q = 0; - } - - trys = 1; - while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { - sprintf(ErrorMessage, "can't open font %s", fontname); - strcpy(fontname, "fixed"); - if (trys > 1) { - internalerror(ErrorMessage); - RECOVERNEWVIEWPORT(); - return(1); - } - trys += 1; - } - - graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - - DEVDEP(graph).font->min_bounds.lbearing + 1; - graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + - DEVDEP(graph).font->max_bounds.descent + 1; - - XtRealizeWidget(DEVDEP(graph).shell); - - DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); - DEVDEP(graph).isopen = 0; - w_attrs.bit_gravity = ForgetGravity; - XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, - &w_attrs); - /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ - gcvalues.font = DEVDEP(graph).font->fid; - gcvalues.line_width = MW_LINEWIDTH; - gcvalues.cap_style = CapNotLast; - gcvalues.function = GXcopy; - DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, - GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); - - /* should absolute.positions really be shell.pos? */ - graph->absolute.xpos = DEVDEP(graph).view->core.x; - graph->absolute.ypos = DEVDEP(graph).view->core.y; - graph->absolute.width = DEVDEP(graph).view->core.width; - graph->absolute.height = DEVDEP(graph).view->core.height; - - initlinestyles(); - initcolors(graph); - - /* set up cursor */ - cursor = XCreateFontCursor(display, XC_left_ptr); - XDefineCursor(display, DEVDEP(graph).window, cursor); - - return (0); -} - static void initlinestyles(void) { @@ -406,6 +261,199 @@ initcolors(GRAPH *graph) } } + +void +handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata) +{ + + XKeyEvent *keyev = (XKeyPressedEvent *) calldata; + GRAPH *graph = (GRAPH *) clientdata; + char text[4]; + int nbytes; + + nbytes = XLookupString(keyev, text, 4, NULL, NULL); + if (!nbytes) return; + /* write it */ + PushGraphContext(graph); + text[nbytes] = '\0'; + SetColor(1); + Text(text, keyev->x, graph->absolute.height - keyev->y); + /* save it */ + SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); + /* warp mouse so user can type in sequence */ + XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, + keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), + keyev->y); + PopGraphContext(); + +} + +void +handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) +{ + + XButtonEvent *buttonev = (XButtonEvent *) calldata; + + switch (buttonev->button) { + case Button1: + slopelocation((GRAPH *) clientdata, buttonev->x, buttonev->y); + break; + case Button3: + zoomin((GRAPH *) clientdata); + break; + } + +} + + +/* Recover from bad NewViewPort call. */ +#define RECOVERNEWVIEWPORT() free((char *) graph);\ + graph = (GRAPH *) NULL; + /* need to do this or else DestroyGraph will free it again */ + +/* NewViewport is responsible for filling in graph->viewport */ +int +X11_NewViewport(GRAPH *graph) +{ + + char fontname[513]; /* who knows . . . */ + char *p, *q; + Cursor cursor; + XSetWindowAttributes w_attrs; + XGCValues gcvalues; + static Arg formargs[ ] = { + { XtNleft, (XtArgVal) XtChainLeft }, + { XtNresizable, (XtArgVal) TRUE } + }; + static Arg bboxargs[ ] = { + { XtNfromHoriz, (XtArgVal) NULL }, + { XtNbottom, (XtArgVal) XtChainTop }, + { XtNtop, (XtArgVal) XtChainTop }, + { XtNleft, (XtArgVal) XtChainRight }, + { XtNright, (XtArgVal) XtChainRight } + }; + static Arg buttonargs[ ] = { + { XtNlabel, (XtArgVal) NULL }, + { XtNfromVert, (XtArgVal) NULL }, + { XtNbottom, (XtArgVal) XtChainTop }, + { XtNtop, (XtArgVal) XtChainTop }, + { XtNleft, (XtArgVal) XtRubber }, + { XtNright, (XtArgVal) XtRubber }, + { XtNresizable, (XtArgVal) TRUE } + }; + static Arg viewargs[] = { + { XtNresizable, (XtArgVal) TRUE }, + { XtNwidth, (XtArgVal) 300 }, + { XtNheight, (XtArgVal) 300 }, + { XtNright, (XtArgVal) XtChainRight } + }; + int trys; + + graph->devdep = calloc(1, sizeof(X11devdep)); + + /* set up new shell */ + DEVDEP(graph).shell = XtCreateApplicationShell("shell", + topLevelShellWidgetClass, NULL, 0); + + /* set up form widget */ + DEVDEP(graph).form = XtCreateManagedWidget("form", + formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); + + /* set up viewport */ + DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, + DEVDEP(graph).form, + viewargs, + XtNumber(viewargs)); + XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, + handlebuttonev, graph); + XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, + handlekeypressed, graph); + XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, + resize, graph); + XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, + redraw, graph); + + /* set up button box */ + XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); + DEVDEP(graph).buttonbox = XtCreateManagedWidget("buttonbox", + boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); + + /* set up buttons */ + XtSetArg(buttonargs[0], XtNlabel, "quit"); + XtSetArg(bboxargs[1], XtNfromVert, NULL); + DEVDEP(graph).buttons[0] = XtCreateManagedWidget("quit", + commandWidgetClass, DEVDEP(graph).buttonbox, + buttonargs, 1); + XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, killwin, graph); + + XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); + XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); + DEVDEP(graph).buttons[1] = XtCreateManagedWidget("hardcopy", + commandWidgetClass, DEVDEP(graph).buttonbox, + buttonargs, 1); + XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, hardcopy, graph); + + /* set up fonts */ + if (!cp_getvar("font", VT_STRING, fontname)) { + (void) strcpy(fontname, DEF_FONT); + } + + for (p = fontname; *p && *p <= ' '; p++) + ; + if (p != fontname) { + for (q = fontname; *p; *q++ = *p++) + ; + *q = 0; + } + + trys = 1; + while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { + sprintf(ErrorMessage, "can't open font %s", fontname); + strcpy(fontname, "fixed"); + if (trys > 1) { + internalerror(ErrorMessage); + RECOVERNEWVIEWPORT(); + return(1); + } + trys += 1; + } + + graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - + DEVDEP(graph).font->min_bounds.lbearing + 1; + graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + + DEVDEP(graph).font->max_bounds.descent + 1; + + XtRealizeWidget(DEVDEP(graph).shell); + + DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); + DEVDEP(graph).isopen = 0; + w_attrs.bit_gravity = ForgetGravity; + XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, + &w_attrs); + /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ + gcvalues.font = DEVDEP(graph).font->fid; + gcvalues.line_width = MW_LINEWIDTH; + gcvalues.cap_style = CapNotLast; + gcvalues.function = GXcopy; + DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, + GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); + + /* should absolute.positions really be shell.pos? */ + graph->absolute.xpos = DEVDEP(graph).view->core.x; + graph->absolute.ypos = DEVDEP(graph).view->core.y; + graph->absolute.width = DEVDEP(graph).view->core.width; + graph->absolute.height = DEVDEP(graph).view->core.height; + + initlinestyles(); + initcolors(graph); + + /* set up cursor */ + cursor = XCreateFontCursor(display, XC_left_ptr); + XDefineCursor(display, DEVDEP(graph).window, cursor); + + return (0); +} + /* This routine closes the X connection. It is not to be called for finishing a graph. */ void @@ -536,49 +584,41 @@ X11_Clear(void) } -void -handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata) +static void +X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) { + double lmin, lmax; - XKeyEvent *keyev = (XKeyPressedEvent *) calldata; - GRAPH *graph = (GRAPH *) clientdata; - char text[4]; - int nbytes; + if (graph->grid.gridtype == GRID_XLOG + || graph->grid.gridtype == GRID_LOGLOG) + { + lmin = log10(graph->datawindow.xmin); + lmax = log10(graph->datawindow.xmax); + *fx = exp(((x - graph->viewportxoff) + * (lmax - lmin) / graph->viewport.width + lmin) + * M_LN10); + } else { + *fx = (x - graph->viewportxoff) * graph->aspectratiox + + graph->datawindow.xmin; + } - nbytes = XLookupString(keyev, text, 4, NULL, NULL); - if (!nbytes) return; - /* write it */ - PushGraphContext(graph); - text[nbytes] = '\0'; - SetColor(1); - Text(text, keyev->x, graph->absolute.height - keyev->y); - /* save it */ - SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); - /* warp mouse so user can type in sequence */ - XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, - keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), - keyev->y); - PopGraphContext(); - -} - -void -handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) -{ - - XButtonEvent *buttonev = (XButtonEvent *) calldata; - - switch (buttonev->button) { - case Button1: - slopelocation((GRAPH *) clientdata, buttonev->x, buttonev->y); - break; - case Button3: - zoomin((GRAPH *) clientdata); - break; + if (graph->grid.gridtype == GRID_YLOG + || graph->grid.gridtype == GRID_LOGLOG) + { + lmin = log10(graph->datawindow.ymin); + lmax = log10(graph->datawindow.ymax); + *fy = exp(((graph->absolute.height - y - graph->viewportxoff) + * (lmax - lmin) / graph->viewport.height + lmin) + * M_LN10); + } else { + *fy = ((graph->absolute.height - y) - graph->viewportyoff) + * graph->aspectratioy + graph->datawindow.ymin; } } + + void slopelocation(GRAPH *graph, int x0, int y0) @@ -914,41 +954,6 @@ out: } -static -void -X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) -{ - double lmin, lmax; - - if (graph->grid.gridtype == GRID_XLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.xmin); - lmax = log10(graph->datawindow.xmax); - *fx = exp(((x - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.width + lmin) - * M_LN10); - } else { - *fx = (x - graph->viewportxoff) * graph->aspectratiox + - graph->datawindow.xmin; - } - - if (graph->grid.gridtype == GRID_YLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.ymin); - lmax = log10(graph->datawindow.ymax); - *fy = exp(((graph->absolute.height - y - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.height + lmin) - * M_LN10); - } else { - *fy = ((graph->absolute.height - y) - graph->viewportyoff) - * graph->aspectratioy + graph->datawindow.ymin; - } - -} - - static void linear_arc(int x0, int y0, int radius, double theta1, double theta2) /* x coordinate of center */ diff --git a/src/frontend/x11.h b/src/frontend/plotting/x11.h similarity index 85% rename from src/frontend/x11.h rename to src/frontend/plotting/x11.h index f9a6f1d5e..67d6e66c9 100644 --- a/src/frontend/x11.h +++ b/src/frontend/plotting/x11.h @@ -7,10 +7,7 @@ #define X11_H_INCLUDED int X11_Init(void); -void errorhandler(Display *display, XErrorEvent *errorev); int X11_NewViewport(GRAPH *graph); -void initlinestyles(void); -void initcolors(GRAPH *graph); void X11_Close(void); void X11_DrawLine(int x1, int y1, int x2, int y2); void X11_Arc(int x0, int y0, int radius, double theta1, double theta2); @@ -30,8 +27,6 @@ void killwin(Widget w, caddr_t client_data, caddr_t call_data); void redraw(Widget w, caddr_t client_data, caddr_t call_data); void resize(Widget w, caddr_t client_data, caddr_t call_data); void X11_Input(REQUEST *request, RESPONSE *response); -void X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy); - #endif diff --git a/src/frontend/xgraph.c b/src/frontend/plotting/xgraph.c similarity index 99% rename from src/frontend/xgraph.c rename to src/frontend/plotting/xgraph.c index 266b1f6f3..c24076718 100644 --- a/src/frontend/xgraph.c +++ b/src/frontend/plotting/xgraph.c @@ -10,7 +10,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "fteparse.h" #include "xgraph.h" diff --git a/src/frontend/xgraph.h b/src/frontend/plotting/xgraph.h similarity index 100% rename from src/frontend/xgraph.h rename to src/frontend/plotting/xgraph.h diff --git a/src/frontend/points.c b/src/frontend/points.c index cfe2ee74c..abf580e43 100644 --- a/src/frontend/points.c +++ b/src/frontend/points.c @@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftegraph.h" #include "ftedbgra.h" #include "points.h" diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index f580c5844..8c6e188e5 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -11,252 +11,16 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "cpdefs.h" #include "ftedefs.h" #include "fteparse.h" -#include "ftedata.h" +#include "dvec.h" +#include "sim.h" #include "postcoms.h" +#include "completion.h" /* static declarations */ -static void pvec(struct dvec *d); -static int dcomp(struct dvec **v1, struct dvec **v2); static void killplot(struct plot *pl); -void -com_let(wordlist *wl) -{ - char *p, *q, *s; - int indices[MAXDIMS]; - int numdims; - wordlist fake_wl; - int need_open; - int offset, length; - struct pnode *nn; - struct dvec *n, *t; - int i, cube; - int depth; - int newvec; - char *rhs; - - fake_wl.wl_next = NULL; - - if (!wl) { - com_display((wordlist *) NULL); - return; - } - - p = wl_flatten(wl); - - /* extract indices */ - numdims = 0; - if ((rhs =strchr(p, '='))) { - *rhs++ = 0; - } else { - fprintf(cp_err, "Error: bad let syntax\n"); - return; - } - if ((s =strchr(p, '['))) { - need_open = 0; - *s++ = 0; - while (!need_open || *s == '[') { - depth = 0; - if (need_open) - s++; - for (q = s; *q && (*q != ']' && (*q != ',' || depth > 0)); q++) { - switch (*q) { - case '[': - depth += 1; - break; - case ']': - depth -= 1; - break; - } - } - - if (depth != 0 || !*q) { - printf("syntax error specifyingstrchr\n"); - return; - } - - if (*q == ']') - need_open = 1; - else - need_open = 0; - if (*q) - *q++ = 0; - -/* MW. let[x,y] is not supported - we don't need this code - - * evaluate expression between s and q - fake_wl.wl_word = s; - nn = ft_getpnames(&fake_wl, TRUE); - t = ft_evaluate(nn); - - free_pnode(nn); - - if (!t) { - fprintf(cp_err, "Error: badstrchr.\n"); // MW. When t == NULL something is wrong - tfree(p); - return; - } - - if (!isreal(t) || t->v_link2 || t->v_length != 1 || !t->v_realdata) - { - fprintf(cp_err, "Error:strchr is not a scalar.\n"); - tfree(p); - - return; - } - j = t->v_realdata[0]; - * ignore sanity checks for now - - if (j < 0) { - printf("negativestrchr (%d) is not allowed\n", j); - tfree(p); - return; - } - - indices[numdims++] = j; - - - - - * MW. Next line does not hurt. I don't know what it is doing - */ - - for (s = q; *s && isspace(*s); s++) - ; - } - } - /* vector name at p */ - - for (q = p + strlen(p) - 1; *q <= ' ' && p <= q; q--) - ; - - *++q = 0; - - /* sanity check */ - if (eq(p, "all") ||strchr(p, '@')) { - fprintf(cp_err, "Error: bad variable name %s\n", p); - return; - } - - /* evaluate rhs */ - fake_wl.wl_word = rhs; - nn = ft_getpnames(&fake_wl, TRUE); - if (nn == NULL) { - /* XXX error message */ - tfree(p); - return; - } - t = ft_evaluate(nn); - if (!t) { - fprintf(cp_err, "Error: Can't evaluate %s\n", rhs); - tfree(p); - return; - } - - if (t->v_link2) - fprintf(cp_err, "Warning: extra wildcard values ignored\n"); - - n = vec_get(p); - - if (n) { - /* re-allocate? */ - /* vec_free(n); */ - newvec = 0; - } else { - if (numdims) { - fprintf(cp_err, "Can't assign into a subindex of a new vector\n"); - tfree(p); - return; - } - - /* create and assign a new vector */ - n = alloc(struct dvec); - ZERO(n, struct dvec); - n->v_name = copy(p); - n->v_type = t->v_type; - n->v_flags = (t->v_flags | VF_PERMANENT); - n->v_length = t->v_length; - - if (!t->v_numdims) { - n->v_numdims = 1; - n->v_dims[0] = n->v_length; - } else { - n->v_numdims = t->v_numdims; - for (i = 0; i < t->v_numdims; i++) - n->v_dims[i] = t->v_dims[i]; - } - - if (isreal(t)) - n->v_realdata = (double *) tmalloc(n->v_length * sizeof(double)); - else - n->v_compdata = (complex *) tmalloc(n->v_length * sizeof(complex)); - newvec = 1; - vec_new(n); - } - - /* fix-up dimensions */ - if (n->v_numdims < 1) { - n->v_numdims = 1; - n->v_dims[0] = n->v_length; - } - - /* Compare dimensions */ - offset = 0; - length = n->v_length; - - cube = 1; - for (i = n->v_numdims - 1; i >= numdims; i--) - cube *= n->v_dims[i]; - - for (i = numdims - 1; i >= 0; i--) { - offset += cube * indices[i]; - if (i < n->v_numdims) { - cube *= n->v_dims[i]; - length /= n->v_dims[i]; - } - } - - /* length is the size of the unit refered to */ - /* cube ends up being the length */ - - if (length > t->v_length) { - fprintf(cp_err, "left-hand expression is too small (need %d)\n", - length * cube); - if (newvec) - n->v_flags &= ~VF_PERMANENT; - tfree(p); - return; - } - if (isreal(t) != isreal(n)) { - fprintf(cp_err, - "Types of vectors are not the same (real vs. complex)\n"); - if (newvec) - n->v_flags &= ~VF_PERMANENT; - tfree(p); - return; - } else if (isreal(t)) { - bcopy((char *) t->v_realdata, (char *) (n->v_realdata + offset), - length * sizeof (double)); - } else { - bcopy((char *) t->v_compdata, (char *) (n->v_compdata + offset), - length * sizeof (complex)); - } - - n->v_minsignal = 0.0; /* How do these get reset ??? */ - n->v_maxsignal = 0.0; - - n->v_scale = t->v_scale; - - if (newvec) - cp_addkword(CT_VECTOR, n->v_name); - - /* XXXX Free t !?! */ - tfree(p); - return; -} - /* Undefine vectors. */ void @@ -708,173 +472,6 @@ com_transpose(wordlist *wl) } } -/* Set the default scale to the named vector. If no vector named, - * find and print the default scale. - */ - -void -com_setscale(wordlist *wl) -{ - struct dvec *d; - char *s; - - if (plot_cur) { - if (wl) { - s = cp_unquote(wl->wl_word); - d = vec_get(s); - if (d == NULL) - fprintf(cp_err, "Error: no such vector as %s.\n", - wl->wl_word); - else - plot_cur->pl_scale = d; - } else if (plot_cur->pl_scale) { - pvec(plot_cur->pl_scale); - } - } else { - fprintf(cp_err, "Error: no current plot.\n"); - } -} - - -/* Display vector status, etc. Note that this only displays stuff from the - * current plot, and you must do a setplot to see the rest of it. - */ - -void -com_display(wordlist *wl) -{ - struct dvec *d; - struct dvec **dvs; - int len = 0, i = 0; - bool b; - char *s; - - /* Maybe he wants to know about just a few vectors. */ - - out_init(); - while (wl) { - s = cp_unquote(wl->wl_word); - d = vec_get(s); - if (d == NULL) - fprintf(cp_err, "Error: no such vector as %s.\n", - wl->wl_word); - else - while (d) { - pvec(d); - d = d->v_link2; - } - if (wl->wl_next == NULL) - return; - wl = wl->wl_next; - } - if (plot_cur) - for (d = plot_cur->pl_dvecs; d; d = d->v_next) - len++; - if (len == 0) { - fprintf(cp_out, "There are no vectors currently active.\n"); - return; - } - out_printf("Here are the vectors currently active:\n\n"); - dvs = (struct dvec **) tmalloc(len * (sizeof (struct dvec *))); - for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++) - dvs[i] = d; - if (!cp_getvar("nosort", VT_BOOL, (char *) &b)) - qsort((char *) dvs, len, sizeof (struct dvec *), dcomp); - - out_printf("Title: %s\n", plot_cur->pl_title); - out_printf("Name: %s (%s)\nDate: %s\n\n", - plot_cur->pl_typename, plot_cur->pl_name, - plot_cur->pl_date); - for (i = 0; i < len; i++) { - d = dvs[i]; - pvec(d); - } - return; -} - -static void -pvec(struct dvec *d) -{ - char buf[BSIZE_SP], buf2[BSIZE_SP]; - - sprintf(buf, " %-20s: %s, %s, %d long", d->v_name, - ft_typenames(d->v_type), isreal(d) ? "real" : - "complex", d->v_length); - if (d->v_flags & VF_MINGIVEN) { - sprintf(buf2, ", min = %g", d->v_minsignal); - strcat(buf, buf2); - } - if (d->v_flags & VF_MAXGIVEN) { - sprintf(buf2, ", max = %g", d->v_maxsignal); - strcat(buf, buf2); - } - switch (d->v_gridtype) { - - case GRID_LOGLOG: - strcat(buf, ", grid = loglog"); - break; - - case GRID_XLOG: - strcat(buf, ", grid = xlog"); - break; - - case GRID_YLOG: - strcat(buf, ", grid = ylog"); - break; - - case GRID_POLAR: - strcat(buf, ", grid = polar"); - break; - - case GRID_SMITH: - strcat(buf, ", grid = smith (xformed)"); - break; - - case GRID_SMITHGRID: - strcat(buf, ", grid = smithgrid (not xformed)"); - break; - } - switch (d->v_plottype) { - - case PLOT_COMB: - strcat(buf, ", plot = comb"); - break; - - case PLOT_POINT: - strcat(buf, ", plot = point"); - break; - - } - if (d->v_defcolor) { - sprintf(buf2, ", color = %s", d->v_defcolor); - strcat(buf, buf2); - } - if (d->v_scale) { - sprintf(buf2, ", scale = %s", d->v_scale->v_name); - strcat(buf, buf2); - } - if (d->v_numdims > 1) { - sprintf(buf2, ", dims = [%s]", dimstring(d->v_dims, d->v_numdims)); - strcat(buf, buf2); - } - if (d->v_plot->pl_scale == d) { - strcat(buf, " [default scale]\n"); - } else { - strcat(buf, "\n"); - } - out_send(buf); - return; -} - - -/* For the sort in display. */ -static int -dcomp(struct dvec **v1, struct dvec **v2) -{ - return (strcmp((*v1)->v_name, (*v2)->v_name)); -} - - /* Take a set of vectors and form a new vector of the nth elements of each. */ void com_cross(wordlist *wl) diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index 8f96ac24e..e6ccac13f 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -11,7 +11,7 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "rawfile.h" @@ -303,7 +303,7 @@ raw_read(char *name) } else if (ciprefix("flags:", buf)) { s = buf; skip(s); - while (t = gettok(&s)) { + while ((t = gettok(&s))) { if (cieq(t, "real")) flags |= VF_REAL; else if (cieq(t, "complex")) @@ -453,7 +453,7 @@ raw_read(char *name) v->v_name = copy(buf2); } /* Now come the strange options... */ - while (t = gettok(&s)) { + while ((t = gettok(&s))) { if (ciprefix("min=", t)) { if (sscanf(t + 4, "%lf", &v->v_minsignal) != 1) diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 04547724a..5c4d0976d 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -12,9 +12,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ftedefs.h" #include "ftedev.h" #include "ftedebug.h" -#include "ftedata.h" +#include "dvec.h" #include "runcoms.h" +#include "completion.h" + /* static declarations */ static int dosim(char *what, wordlist *wl); diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index adef8c205..f3c2e159d 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -12,7 +12,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ftedefs.h" #include "ftedev.h" #include "ftedebug.h" -#include "ftedata.h" +#include "dvec.h" #include "runcoms2.h" diff --git a/src/frontend/shyu.c b/src/frontend/shyu.c index ebb364c40..f3a6d6a99 100644 --- a/src/frontend/shyu.c +++ b/src/frontend/shyu.c @@ -14,7 +14,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include "cpdefs.h" #include "ftedefs.h" #include "fteinp.h" -#include "fteconst.h" +#include "sim.h" #include "devdefs.h" #include "inpdefs.h" #include "iferrmsg.h" diff --git a/src/frontend/spcmdtab.c b/src/frontend/spcmdtab.c deleted file mode 100644 index 482441e96..000000000 --- a/src/frontend/spcmdtab.c +++ /dev/null @@ -1,381 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Table of available commands. Note that they're sorted so that the commands - * that appear in the spiceinit file are at the top. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftehelp.h" - - -/* Bool fields: stringargs, spiceonly, major */ - -struct comm spcp_coms[] = { - - { "let", com_let, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - arg_let, - "varname = expr : Assign vector variables." } , - { "reshape", com_reshape, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - arg_let, - "vector ... [ shape ] : change the dimensions of a vector." } , - { "define", com_define, FALSE, FALSE, TRUE, - { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[[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." } , - { "alias", com_alias, FALSE, FALSE, FALSE, - { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, - (int (*)()) NULL, - "[[word] alias] : Define an alias." } , - { "deftype", com_dftype, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "spec name pat ... : Redefine vector and plot types.\n" } , - { "plot", com_plot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, - arg_plot, - "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, - { "display", com_display, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, - arg_display, - ": Display vector status." } , - { "destroy", com_destroy, FALSE, FALSE, FALSE, - { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[plotname] ... : Throw away all the data in the plot." } , - { "setplot", com_splot, FALSE, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[plotname] : Change the current working plot." } , - { "setcirc", com_scirc, FALSE, TRUE, FALSE, - { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[circuit name] : Change the current circuit." } , - { "setscale", com_setscale, FALSE, FALSE, FALSE, - { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[vecname] : Change default scale of current working plot." } , - { "transpose", com_transpose, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Perform matrix transposition on multi-D vectors." } , - { "xgraph", com_xgraph, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file plotargs : Send plot to Xgraph-11." } , - { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file plotargs : Produce hardcopy plots." } , - { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "plotargs : Produce ascii plots." } , - { "write", com_write, FALSE, FALSE, TRUE, - { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file expr ... : Write data to a file." } , - { "compose", com_compose, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "var parm=val ... : Compose a vector." } , - { "unlet", com_unlet, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Undefine vectors." } , - { "print", com_print, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, - arg_print, - "[col] expr ... : Print vector values." } , - { "load", com_load, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, - arg_load, - "file ... : Load in data." } , - { "cross", com_cross, FALSE, FALSE, TRUE, - { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "vecname number [ vector ... ] : Make a vector in a strange way." } , - { "undefine", com_undefine, FALSE, FALSE, FALSE, - { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[func ...] : Undefine a user-definable function." } , - { "op", com_op, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.op line args] : Determine the operating point of the circuit." } , - { "tf", com_tf, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "tran", com_tran, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "ac", com_ac, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do an ac analysis." } , - { "dc", com_dc, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.dc line args] : Do a dc analysis." } , - { "pz", com_pz, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.pz line args] : Do a pole / zero analysis." } , - { "sens", com_sens, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.sens line args] : Do a sensitivity analysis." } , - { "disto", com_disto, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.disto line args] : Do an distortion analysis." } , - { "noise", com_noise, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.noise line args] : Do a noise analysis." } , - { "listing", com_listing, FALSE, TRUE, TRUE, - { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[logical] [physical] [deck] : Print the current circuit." } , - { "edit", com_edit, FALSE, TRUE, TRUE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[filename] : Edit a spice deck and then load it in." } , - { "dump", com_dump, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print a dump of the current circuit." } , - { "fourier", com_fourier, FALSE, FALSE, TRUE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "fund_freq vector ... : Do a fourier analysis of some data." } , - { "spec", com_spec, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 4, LOTS, - (int (*)()) NULL, - "start_freq stop_freq step_freq vector ... : Create a frequency domain plot." } , - { "show", com_show, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devices ... : parameters ... : Print out device summary." } , - { "showmod", com_showmod, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "models ... : parameters ... : Print out model summary." } , - { "alter", com_alter, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter device parameters." } , - { "altermod", com_altermod, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter model parameters." } , - { "resume", com_resume, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue after a stop." } , - { "state", com_state, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "(unimplemented) : Print the state of the circuit." }, - { "stop", com_stop, FALSE, TRUE, FALSE, - { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stop args] : Set a breakpoint." } , - { "trace", com_trce, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Trace a node." } , - { "save", com_save, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Save a spice output." } , - { "iplot", com_iplot, FALSE, TRUE, TRUE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Incrementally plot a node." } , - { "status", com_sttus, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print the current breakpoints and traces." } , - { "delete", com_delete, FALSE, TRUE, FALSE, - { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [break number ...] : Delete breakpoints and traces." } , - { "step", com_step, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Iterate number times, or one." } , - { "reset", com_rset, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Terminate a simulation after a breakpoint (formerly 'end')." } , - { "run", com_run, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[rawfile] : Run the simulation as specified in the input file." } , - { "aspice", com_aspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, 2, - (int (*)()) NULL, - "file [outfile] : Run a spice job asynchronously." } , - { "jobs", com_jobs, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report on asynchronous spice jobs." } , - { "rspice", com_rspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[input file] : Run a spice job remotely." } , - { "bug", com_bug, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report a %s bug." } , - { "where", com_where, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print last non-converging node or device" } , - { "newhelp", com_ahelp, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : help." }, - { "tutorial", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "help", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "oldhelp", com_help, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : Print help." } , - { "quit", com_quit, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, - (int (*)()) NULL, - ": Quit %s." } , - { "source", com_source, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file : Source a %s file." } , - { "shift", com_shift, FALSE, FALSE, FALSE, - { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[var] [number] : Shift argv or the named list var to the left." } , - { "unset", com_unset, FALSE, FALSE, FALSE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Unset a variable." } , - { "unalias", com_unalias, FALSE, FALSE, FALSE, - { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "word ... : Undefine an alias." } , - { "history", com_history, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[-r] [number] : Print command history." } , - { "echo", com_echo, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stuff ...] : Print stuff." } , - { "shell", com_shell, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[args] : Fork a shell, or execute the command." } , - { "rusage", com_rusage, FALSE, FALSE, FALSE, - { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[resource ...] : Print current resource usage." } , - { "cd", com_chdir, FALSE, FALSE, FALSE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[directory] : Change working directory." } , - { "version", com_version, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[number] : Print the version number." } , - { "diff", com_diff, FALSE, FALSE, FALSE, - { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "plotname plotname [vec ...] : 'diff' two plots." } , - { "rehash", com_rehash, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Rebuild the unix command database." } , - { "while", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "repeat", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Repeat number times, or forever." } , - { "dowhile", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "foreach", NULL, FALSE, FALSE, FALSE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "variable value ... : Do once for each value." } , - { "if", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute if the condition is TRUE." } , - { "else", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Goes with if." } , - { "end", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": End a block." } , - { "break", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Break out of a block." } , - { "continue", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue a loop." } , - { "label", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Create someplace to go to." } , - { "goto", NULL, FALSE, FALSE, FALSE, - { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Go to a label." } , - { "cdump", com_cdump, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Dump the current control structures." } , - { "settype", com_stype, FALSE, FALSE, FALSE, - { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "type vec ... : Change the type of a vector." } , - { "strcmp", com_strcmp, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, - (int (*)()) NULL, - "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , - { "linearize", com_linearize, FALSE, TRUE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - " [ vec ... ] : Convert plot into one with linear scale." } , - { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - NULL } -}; - diff --git a/src/frontend/spec.c b/src/frontend/spec.c index b78f369c7..c2b022a39 100644 --- a/src/frontend/spec.c +++ b/src/frontend/spec.c @@ -9,7 +9,9 @@ Author: 1994 Anthony E. Parker, Department of Electronics, Macquarie Uni. #include "ngspice.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" +#include "sim.h" + #include "spec.h" diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 0a3628822..b24c2f2d2 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -15,7 +15,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "cpdefs.h" #include "ftedefs.h" #include "fteinp.h" -#include "fteconst.h" #include "inpdefs.h" #include "iferrmsg.h" #include "ifsim.h" diff --git a/src/frontend/streams.h b/src/frontend/streams.h new file mode 100644 index 000000000..44bc27765 --- /dev/null +++ b/src/frontend/streams.h @@ -0,0 +1,8 @@ +#ifndef _STREAMS_H +#define _STREAMS_H + +extern FILE *cp_in; +extern FILE *cp_out; +extern FILE *cp_err; + +#endif diff --git a/src/frontend/testcommands.c b/src/frontend/testcommands.c new file mode 100644 index 000000000..da24b5edc --- /dev/null +++ b/src/frontend/testcommands.c @@ -0,0 +1,25 @@ +#include + +#include "commands.h" + + +void +print_struct_comm(struct comm coms[]) +{ + int i; + + for (i = 0; coms[i].co_comname != NULL; i++) { + printf("Command: %s\n" + "help: %s\n\n", + coms[i].co_comname, + coms[i].co_help); + } +} + +int +main(void) +{ + print_struct_comm(nutcp_coms); + print_struct_comm(spcp_coms); + return 0; +} diff --git a/src/frontend/typesdef.c b/src/frontend/typesdef.c index d4f7b4986..6592d4f12 100644 --- a/src/frontend/typesdef.c +++ b/src/frontend/typesdef.c @@ -10,7 +10,7 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "typesdef.h" diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index 380903428..91ea4b033 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -7,35 +7,138 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * Routines for dealing with the vector database. */ -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" +#include +#include +#include +#include +#include + #include "vectors.h" - -/* static declarations */ - -static struct dvec * findvec(char *word, struct plot *pl); -static struct dvec * sortvecs(struct dvec *d); -static int veccmp(struct dvec **d1, struct dvec **d2); -static int namecmp(char *s, char *t); +#include "completion.h" +#include "plotting/plotting.h" -/* Where 'constants' go when defined on initialization. */ +/* Find a named vector in a plot. We are careful to copy the vector if + * v_link2 is set, because otherwise we will get screwed up. */ +static struct dvec * +findvec(char *word, struct plot *pl) +{ + struct dvec *d, *newv = NULL, *end = NULL, *v; + char buf[BSIZE_SP]; -static struct plot constantplot = { - "Constant values", "Sat Aug 16 10:55:15 PDT 1986", "constants", - "const", NULL, NULL, NULL, NULL, NULL, NULL, TRUE -} ; + if (pl == NULL) + return (NULL); -struct plot *plot_cur = &constantplot; -struct plot *plot_list = &constantplot; -int plotl_changed; /* TRUE after a load */ + if (cieq(word, "all")) { + for (d = pl->pl_dvecs; d; d = d->v_next) { + if (d->v_flags & VF_PERMANENT) { + if (d->v_link2) { + v = vec_copy(d); + vec_new(v); + } else + v = d; + if (end) + end->v_link2 = v; + else + newv = v; + end = v; + } + } + return (newv); + } + + for (d = pl->pl_dvecs; d; d = d->v_next) + if (cieq(word, d->v_name) && (d->v_flags & VF_PERMANENT)) + break; + if (!d) { + (void) sprintf(buf, "v(%s)", word); + for (d = pl->pl_dvecs; d; d = d->v_next) + if (cieq(buf, d->v_name) && (d->v_flags & VF_PERMANENT)) + break; + } + if (d && d->v_link2) { + d = vec_copy(d); + vec_new(d); + } + + return (d); +} + + +/* If there are imbedded numeric strings, compare them numerically, not + * alphabetically. + */ +static int +namecmp(const void *a, const void *b) +{ + int i, j; + + char *s = (char *) a; + char *t = (char *) b; + for (;;) { + while ((*s == *t) && !isdigit(*s) && *s) + s++, t++; + if (!*s) + return (0); + if ((*s != *t) && (!isdigit(*s) || !isdigit(*t))) + return (*s - *t); + + /* The beginning of a number... Grab the two numbers and then + * compare them... */ + for (i = 0; isdigit(*s); s++) + i = i * 10 + *s - '0'; + for (j = 0; isdigit(*t); t++) + j = j * 10 + *t - '0'; + + if (i != j) + return (i - j); + } +} + + +static int +veccmp(const void *a, const void *b) +{ + int i; + struct dvec **d1 = (struct dvec **) a; + struct dvec **d2 = (struct dvec **) b; + + if ((i = namecmp((*d1)->v_plot->pl_typename, + (*d2)->v_plot->pl_typename)) != 0) + return (i); + return (namecmp((*d1)->v_name, (*d2)->v_name)); +} + + +/* Sort all the vectors in d, first by plot name and then by vector + * name. Do the right thing with numbers. */ +static struct dvec * +sortvecs(struct dvec *d) +{ + struct dvec **array, *t; + int i, j; + + for (t = d, i = 0; t; t = t->v_link2) + i++; + if (i < 2) + return (d); + array = (struct dvec **) tmalloc(i * sizeof (struct dvec *)); + for (t = d, i = 0; t; t = t->v_link2) + array[i++] = t; + + qsort((char *) array, i, sizeof (struct dvec *), veccmp); + + /* Now string everything back together... */ + for (j = 0; j < i - 1; j++) + array[j]->v_link2 = array[j + 1]; + array[j]->v_link2 = NULL; + d = array[0]; + tfree(array); + return (d); +} -int plot_num = 1; /* Load in a rawfile. */ - void ft_loadfile(char *file) { @@ -304,54 +407,6 @@ vec_get(char *word) return (sortvecs(d)); } -/* Find a named vector in a plot. We are careful to copy the vector - * if v_link2 is set, because otherwise we will get screwed up. - */ - -static struct dvec * -findvec(char *word, struct plot *pl) -{ - struct dvec *d, *newv = NULL, *end = NULL, *v; - char buf[BSIZE_SP]; - - if (pl == NULL) - return (NULL); - - if (cieq(word, "all")) { - for (d = pl->pl_dvecs; d; d = d->v_next) { - if (d->v_flags & VF_PERMANENT) { - if (d->v_link2) { - v = vec_copy(d); - vec_new(v); - } else - v = d; - if (end) - end->v_link2 = v; - else - newv = v; - end = v; - } - } - return (newv); - } - - for (d = pl->pl_dvecs; d; d = d->v_next) - if (cieq(word, d->v_name) && (d->v_flags & VF_PERMANENT)) - break; - if (!d) { - (void) sprintf(buf, "v(%s)", word); - for (d = pl->pl_dvecs; d; d = d->v_next) - if (cieq(buf, d->v_name) && (d->v_flags & VF_PERMANENT)) - break; - } - if (d && d->v_link2) { - d = vec_copy(d); - vec_new(d); - } - - return (d); -} - /* Execute the commands for a plot. This is done whenever a plot becomes * the current plot. */ @@ -615,75 +670,7 @@ vec_basename(struct dvec *v) return (copy(s)); } -/* Sort all the vectors in d, first by plot name and then by vector name. - * Do the right thing with numbers. - */ -static struct dvec * -sortvecs(struct dvec *d) -{ - struct dvec **array, *t; - int i, j; - - for (t = d, i = 0; t; t = t->v_link2) - i++; - if (i < 2) - return (d); - array = (struct dvec **) tmalloc(i * sizeof (struct dvec *)); - for (t = d, i = 0; t; t = t->v_link2) - array[i++] = t; - - qsort((char *) array, i, sizeof (struct dvec *), veccmp); - - /* Now string everything back together... */ - for (j = 0; j < i - 1; j++) - array[j]->v_link2 = array[j + 1]; - array[j]->v_link2 = NULL; - d = array[0]; - tfree(array); - return (d); -} - -static int -veccmp(struct dvec **d1, struct dvec **d2) -{ - int i; - - if ((i = namecmp((*d1)->v_plot->pl_typename, - (*d2)->v_plot->pl_typename)) != 0) - return (i); - return (namecmp((*d1)->v_name, (*d2)->v_name)); -} - -/* If there are imbedded numeric strings, compare them numerically, not - * alphabetically. - */ - -static int -namecmp(char *s, char *t) -{ - int i, j; - - for (;;) { - while ((*s == *t) && !isdigit(*s) && *s) - s++, t++; - if (!*s) - return (0); - if ((*s != *t) && (!isdigit(*s) || !isdigit(*t))) - return (*s - *t); - - /* The beginning of a number... Grab the two numbers - * and then compare them... - */ - for (i = 0; isdigit(*s); s++) - i = i * 10 + *s - '0'; - for (j = 0; isdigit(*t); t++) - j = j * 10 + *t - '0'; - - if (i != j) - return (i - j); - } -} /* Make a plot the current one. This gets called by cp_usrset() when one diff --git a/src/frontend/where.c b/src/frontend/where.c index b8d27ab23..cf66568ad 100644 --- a/src/frontend/where.c +++ b/src/frontend/where.c @@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftehelp.h" #include "hlpdefs.h" #include "where.h" diff --git a/src/include/bool.h b/src/include/bool.h new file mode 100644 index 000000000..a9d2b6aa3 --- /dev/null +++ b/src/include/bool.h @@ -0,0 +1,6 @@ +#ifndef _BOOL_H +#define _BOOL_H + +typedef int bool; + +#endif diff --git a/src/include/complex.h b/src/include/complex.h index 56edc681d..daacb5333 100644 --- a/src/include/complex.h +++ b/src/include/complex.h @@ -1,9 +1,22 @@ /* * Copyright (c) 1985 Thomas L. Quarles - * Modified: Paolo Nenzi 1999 + * Modified: Paolo Nenzi 1999, Arno W. Peters 2000 */ -#ifndef CMPLX -#define CMPLX "complex.h $Revision$ on $Date$ " +#ifndef _COMPLEX_H +#define _COMPLEX_H + + +/* Complex numbers. */ +struct _complex { /* IBM portability... */ + double cx_real; + double cx_imag; +} ; + +typedef struct _complex complex; + +#define realpart(cval) ((struct _complex *) (cval))->cx_real +#define imagpart(cval) ((struct _complex *) (cval))->cx_imag + /* header file containing definitions for complex functions * diff --git a/src/include/cpdefs.h b/src/include/cpdefs.h index f6b62f2d6..a9be20520 100644 --- a/src/include/cpdefs.h +++ b/src/include/cpdefs.h @@ -18,17 +18,38 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group /* Information about spice commands. */ struct comm { - char *co_comname; /* The name of the command. */ - void (*co_func) (); /* The function that handles the command. */ - bool co_stringargs; /* Collapse the arguments into a string. */ - bool co_spiceonly; /* These can't be used from nutmeg. */ - bool co_major; /* Is this a "major" command? */ - long co_cctypes[4]; /* Bitmasks for command completion. */ - unsigned int co_env;/* print help message on this environment mask */ - int co_minargs; /* minimum number of arguments required */ - int co_maxargs; /* maximum number of arguments allowed */ - int (*co_argfn) (); /* The fn that prompts the user. */ - char *co_help; /* When these are printed, printf(string, av[0]) .. */ + /* The name of the command. */ + char *co_comname; + + /* The function that handles the command. */ + void (*co_func) (wordlist *wl); + + /* Collapse the arguments into a string. */ + bool co_stringargs; + + /* These can't be used from nutmeg. */ + bool co_spiceonly; + + /* Is this a "major" command? */ + bool co_major; + + /* Bitmasks for command completion. */ + long co_cctypes[4]; + + /* print help message on this environment mask */ + unsigned int co_env; + + /* minimum number of arguments required */ + int co_minargs; + + /* maximum number of arguments allowed */ + int co_maxargs; + + /* The fn that prompts the user. */ + void (*co_argfn) (wordlist *wl, struct comm *command); + + /* When these are printed, printf(string, av[0]) .. */ + char *co_help; }; #define LOTS 1000 @@ -44,34 +65,13 @@ struct histent { struct histent *hi_prev; }; -/* Variables that are accessible to the parser via $varname expansions. - * If the type is VT_LIST the value is a pointer to a list of the elements. - */ -struct variable { - char va_type; - char *va_name; - union { - bool vV_bool; - int vV_num; - double vV_real; - char *vV_string; - struct variable *vV_list; - } va_V; - struct variable *va_next; /* Link. */ -} ; +/* FIXME: Split this file and adjust all callers to the new header files. */ +#if 0 +#warning "Please use a header file more specific than cpdef.h" +#endif +#include "variable.h" -#define va_bool va_V.vV_bool -#define va_num va_V.vV_num -#define va_real va_V.vV_real -#define va_string va_V.vV_string -#define va_vlist va_V.vV_list - -#define VT_BOOL 1 -#define VT_NUM 2 -#define VT_REAL 3 -#define VT_STRING 4 -#define VT_LIST 5 /* The values returned by cp_userset(). */ diff --git a/src/include/cpextern.h b/src/include/cpextern.h index 345b43aef..4c19050a6 100644 --- a/src/include/cpextern.h +++ b/src/include/cpextern.h @@ -10,6 +10,11 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #ifndef CPEXTERN_H #define CPEXTERN_H +#include "wordlist.h" +#include "bool.h" +#include "variable.h" + + /* alias.c */ extern struct alias *cp_aliases; @@ -18,6 +23,7 @@ extern void com_unalias(); extern void cp_paliases(); extern void cp_setalias(); extern void cp_unalias(); + extern wordlist *cp_doalias(); /* backquote.c */ diff --git a/src/include/cpstd.h b/src/include/cpstd.h index d1dd24e56..946544064 100644 --- a/src/include/cpstd.h +++ b/src/include/cpstd.h @@ -11,35 +11,20 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #ifndef _STD_H_ #define _STD_H_ -typedef int bool; - #ifndef FILE /* XXX Bogus */ # include #endif -/* Doubly linked lists of words. */ +/* FIXME: Split this file and adjust all callers to use new header files */ +#if 0 +#warning "Please use bool.h, wordlist.h or complex.h rather than cpstd.h" +#endif -struct wordlist { - char *wl_word; - struct wordlist *wl_next; - struct wordlist *wl_prev; -} ; - -typedef struct wordlist wordlist; - -/* Complex numbers. */ - -struct _complex { /* IBM portability... */ - double cx_real; - double cx_imag; -} ; - -typedef struct _complex complex; - -#define realpart(cval) ((struct _complex *) (cval))->cx_real -#define imagpart(cval) ((struct _complex *) (cval))->cx_imag +#include "bool.h" +#include "wordlist.h" +#include "complex.h" /* Externs defined in std.c */ diff --git a/src/include/dvec.h b/src/include/dvec.h new file mode 100644 index 000000000..c1ace9add --- /dev/null +++ b/src/include/dvec.h @@ -0,0 +1,65 @@ +#ifndef _DVEC_H +#define _DVEC_H + +#include "complex.h" +#include "grid.h" + + +/* Dvec flags. */ +enum dvec_flags { + VF_REAL = (1 << 0), /* The data is real. */ + VF_COMPLEX = (1 << 1), /* The data is complex. */ + VF_ACCUM = (1 << 2), /* writedata should save this vector. */ + VF_PLOT = (1 << 3), /* writedata should incrementally plot it. */ + VF_PRINT = (1 << 4), /* writedata should print this vector. */ + VF_MINGIVEN = (1 << 5), /* The v_minsignal value is valid. */ + VF_MAXGIVEN = (1 << 6), /* The v_maxsignal value is valid. */ + VF_PERMANENT = (1 << 7) /* Don't garbage collect this vector. */ +}; + + +/* Plot types. */ +typedef enum { + PLOT_LIN, PLOT_COMB, PLOT_POINT +} PLOTTYPE; + + +/* A (possibly multi-dimensional) data vector. The data is represented + * internally by a 1-d array. The number of dimensions and the size + * of each dimension is recorded, along with v_length, the total size of + * the array. If the dimensionality is 0 or 1, v_length is significant + * instead of v_numdims and v_dims, and the vector is handled in the old + * manner. + */ + +#define MAXDIMS 8 + +struct dvec { + char *v_name; /* Same as so_vname. */ + int v_type; /* Same as so_vtype. */ + short v_flags; /* Flags (a combination of VF_*). */ + double *v_realdata; /* Real data. */ + complex *v_compdata; /* Complex data. */ + double v_minsignal; /* Minimum value to plot. */ + double v_maxsignal; /* Maximum value to plot. */ + GRIDTYPE v_gridtype; /* One of GRID_*. */ + PLOTTYPE v_plottype; /* One of PLOT_*. */ + int v_length; /* Length of the vector. */ + int v_rlength; /* How much space we really have. */ + int v_outindex; /* Index if writedata is building the + vector. */ + int v_linestyle; /* What line style we are using. */ + int v_color; /* What color we are using. */ + char *v_defcolor; /* The name of a color to use. */ + int v_numdims; /* How many dims -- 0 = scalar (len = 1). */ + int v_dims[MAXDIMS]; /* The actual size in each dimension. */ + struct plot *v_plot; /* The plot structure (if it has one). */ + struct dvec *v_next; /* Link for list of plot vectors. */ + struct dvec *v_link2; /* Extra link for things like print. */ + struct dvec *v_scale; /* If this has a non-standard scale... */ +} ; + +#define isreal(v) ((v)->v_flags & VF_REAL) +#define iscomplex(v) ((v)->v_flags & VF_COMPLEX) + +#endif diff --git a/src/include/fteconst.h b/src/include/fteconst.h index 2b5dcc288..c6c6353e4 100644 --- a/src/include/fteconst.h +++ b/src/include/fteconst.h @@ -8,81 +8,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #ifndef _CONSTANTS_ #define _CONSTANTS_ -#define SV_NOTYPE 0 -#define SV_TIME 1 -#define SV_FREQUENCY 2 -#define SV_VOLTAGE 3 -#define SV_CURRENT 4 -#define SV_OUTPUT_N_DENS 5 -#define SV_OUTPUT_NOISE 6 -#define SV_INPUT_N_DENS 7 -#define SV_INPUT_NOISE 8 -#define SV_POLE 9 -#define SV_ZERO 10 -#define SV_SPARAM 11 - -/* Dvec flags. */ - -#define VF_REAL (1 << 0) /* The data is real. */ -#define VF_COMPLEX (1 << 1) /* The data is complex. */ -#define VF_ACCUM (1 << 2) /* writedata should save this vector. */ -#define VF_PLOT (1 << 3) /* writedata should incrementally plot it. */ -#define VF_PRINT (1 << 4) /* writedata should print this vector. */ -#define VF_MINGIVEN (1 << 5) /* The v_minsignal value is valid. */ -#define VF_MAXGIVEN (1 << 6) /* The v_maxsignal value is valid. */ -#define VF_PERMANENT (1 << 7) /* Don't garbage collect this vector. */ - -/* Grid types. */ - -/* -#define GRID_NONE 0 -#define GRID_LIN 1 -#define GRID_LOGLOG 2 -#define GRID_XLOG 3 -#define GRID_YLOG 4 -#define GRID_POLAR 5 -#define GRID_SMITH 6 -*/ - -/* SMITHGRID is only a smith grid, SMITH transforms the data */ -typedef enum { - GRID_NONE = 0, GRID_LIN = 1, GRID_LOGLOG = 2, GRID_XLOG = 3, - GRID_YLOG = 4, GRID_POLAR = 5, GRID_SMITH = 6, GRID_SMITHGRID = 7 -} GRIDTYPE; - -/* Plot types. */ - -/* -#define PLOT_LIN 0 -#define PLOT_COMB 1 -#define PLOT_POINT 2 -*/ - -typedef enum { - PLOT_LIN = 0, PLOT_COMB = 1, PLOT_POINT = 2 -} PLOTTYPE; - -/* The types for command completion keywords. Note that these constants - * are built into cmdtab.c, so DON'T change them unless you want to - * change all of the bitmasks in cp_coms. - * Note that this is spice- and nutmeg- dependent. - */ - -#define CT_FILENAME 0 -#define CT_CKTNAMES 2 -#define CT_COMMANDS 3 -#define CT_DBNUMS 4 -#define CT_DEVNAMES 5 -#define CT_LISTINGARGS 6 -#define CT_NODENAMES 7 -#define CT_PLOT 8 -#define CT_PLOTKEYWORDS 9 -#define CT_RUSEARGS 10 -#define CT_STOPARGS 11 -#define CT_UDFUNCS 12 -#define CT_VARIABLES 13 -#define CT_VECTOR 14 -#define CT_TYPENAMES 16 +/* FIXME: Adjust all callers to use new header files */ +#warning "Please use either sim.h, grid.h or plot.h instead of fteconst.h" +#include "sim.h" +#include "grid.h" +#include "plot.h" #endif diff --git a/src/include/ftedata.h b/src/include/ftedata.h index ff478cd84..48e498026 100644 --- a/src/include/ftedata.h +++ b/src/include/ftedata.h @@ -10,63 +10,10 @@ #define FTEdata_h #include "cpstd.h" /* for struct complex */ -#include "fteconst.h" -/* A (possibly multi-dimensional) data vector. The data is represented - * internally by a 1-d array. The number of dimensions and the size - * of each dimension is recorded, along with v_length, the total size of - * the array. If the dimensionality is 0 or 1, v_length is significant - * instead of v_numdims and v_dims, and the vector is handled in the old - * manner. - */ - -#define MAXDIMS 8 - -struct dvec { - char *v_name; /* Same as so_vname. */ - int v_type; /* Same as so_vtype. */ - short v_flags; /* Flags (a combination of VF_*). */ - double *v_realdata; /* Real data. */ - complex *v_compdata; /* Complex data. */ - double v_minsignal; /* Minimum value to plot. */ - double v_maxsignal; /* Maximum value to plot. */ - GRIDTYPE v_gridtype; /* One of GRID_*. */ - PLOTTYPE v_plottype; /* One of PLOT_*. */ - int v_length; /* Length of the vector. */ - int v_rlength; /* How much space we really have. */ - int v_outindex; /* Index if writedata is building the - vector. */ - int v_linestyle; /* What line style we are using. */ - int v_color; /* What color we are using. */ - char *v_defcolor; /* The name of a color to use. */ - int v_numdims; /* How many dims -- 0 = scalar (len = 1). */ - int v_dims[MAXDIMS]; /* The actual size in each dimension. */ - struct plot *v_plot; /* The plot structure (if it has one). */ - struct dvec *v_next; /* Link for list of plot vectors. */ - struct dvec *v_link2; /* Extra link for things like print. */ - struct dvec *v_scale; /* If this has a non-standard scale... */ -} ; - -#define isreal(v) ((v)->v_flags & VF_REAL) -#define iscomplex(v) ((v)->v_flags & VF_COMPLEX) - -/* The information for a particular set of vectors that come from one - * plot. - */ - -struct plot { - char *pl_title; /* The title card. */ - char *pl_date; /* Date. */ - char *pl_name; /* The plot name. */ - char *pl_typename; /* Tran1, op2, etc. */ - struct dvec *pl_dvecs; /* The data vectors in this plot. */ - struct dvec *pl_scale; /* The "scale" for the rest of the vectors. */ - struct plot *pl_next; /* List of plots. */ - wordlist *pl_commands; /* Commands to execute for this plot. */ - struct variable *pl_env;/* The 'environment' for this plot. */ - char *pl_ccom; /* The ccom struct for this plot. */ - bool pl_written; /* Some or all of the vecs have been saved. */ - int pl_ndims; /* Number of dimensions */ -} ; +/* FIXME: Adjust all callers to use the new header files. */ +#warning "Please use either dvec.h or plot.h instead of ftedata.h" +#include "dvec.h" +#include "plot.h" #endif /* FTEdata_h */ diff --git a/src/include/ftedev.h b/src/include/ftedev.h index 272cf02f8..1d4d9bd00 100644 --- a/src/include/ftedev.h +++ b/src/include/ftedev.h @@ -31,7 +31,7 @@ typedef struct { int (*MakeMenu)(); int (*MakeDialog)(); int (*Input)(); - int (*DatatoScreen)(); + void (*DatatoScreen)(); } DISPDEVICE; extern DISPDEVICE *dispdev; diff --git a/src/include/fteext.h b/src/include/fteext.h index 8c0489b87..c34416fb0 100644 --- a/src/include/fteext.h +++ b/src/include/fteext.h @@ -15,7 +15,8 @@ Modified: 1999 Paolo Nenzi /* needed to find out what the interface structures look like */ #include "ifsim.h" -#include "fteparse.h" +#include "dvec.h" +#include "plot.h" #include "cpdefs.h" #include "ftedefs.h" #include "fteinp.h" @@ -311,7 +312,6 @@ extern void com_ghelp(); extern void com_help(); extern void com_quit(); extern void com_version(); -extern int hcomp(); extern void com_where(); /* numparse.c */ diff --git a/src/include/ftegraph.h b/src/include/ftegraph.h index f5d73e2e8..3c8716a51 100644 --- a/src/include/ftegraph.h +++ b/src/include/ftegraph.h @@ -10,8 +10,10 @@ Author: 1988 Jeffrey M. Hsu #ifndef _GRAPH_H_ #define _GRAPH_H_ -#include "fteconst.h" -#include "ftedata.h" /* for struct dvec */ +#include "sim.h" +#include "grid.h" +#include "plot.h" +#include "dvec.h" /* for struct dvec */ /* Device-independent data structure for plots. */ diff --git a/src/include/fteparse.h b/src/include/fteparse.h index 160e1f4a2..179da7712 100644 --- a/src/include/fteparse.h +++ b/src/include/fteparse.h @@ -12,17 +12,15 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #define FTEPARSE -#include "ftedata.h" +#include "cpstd.h" +#include "dvec.h" +#include "plot.h" -struct pnode { - char *pn_name; /* If non-NULL, the name. */ - struct dvec *pn_value; /* Non-NULL in a terminal node. */ - struct func *pn_func; /* Non-NULL is a function. */ - struct op *pn_op; /* Operation if the above two NULL. */ - struct pnode *pn_left; /* Left branch or function argument. */ - struct pnode *pn_right; /* Right branch. */ - struct pnode *pn_next; /* For expression lists. */ -} ; +/* FIXME: Split this file and adjust all callers. */ +#if 0 +#warning "Please use a more specific header than fteparse.h" +#endif +#include "pnode.h" /* Operations. These should really be considered functions. */ @@ -36,8 +34,12 @@ struct op { /* The functions that are available. */ struct func { - char *fu_name; /* The print name of the function. */ - void *(*fu_func)(); /* The function. */ + /* The print name of the function. */ + char *fu_name; + + /* The function. */ + void *(*fu_func)(void *data, short int type, int length, + int *newlength, short int *newtype); } ; /* User-definable functions. The idea of ud_name is that the args are diff --git a/src/include/grid.h b/src/include/grid.h new file mode 100644 index 000000000..3de2b3a6d --- /dev/null +++ b/src/include/grid.h @@ -0,0 +1,12 @@ +#ifndef _GRID_H +#define _GRID_H + +/* Grid types. + + Note: SMITHGRID is only a smith grid, SMITH transforms the data */ +typedef enum { + GRID_NONE, GRID_LIN, GRID_LOGLOG, GRID_XLOG, + GRID_YLOG, GRID_POLAR, GRID_SMITH, GRID_SMITHGRID +} GRIDTYPE; + +#endif diff --git a/src/include/plot.h b/src/include/plot.h new file mode 100644 index 000000000..aa388a74e --- /dev/null +++ b/src/include/plot.h @@ -0,0 +1,27 @@ +#ifndef _PLOT_H +#define _PLOT_H + +#include "wordlist.h" +#include "bool.h" +#include "dvec.h" +#include "variable.h" + +/* The information for a particular set of vectors that come from one + * plot. */ +struct plot { + char *pl_title; /* The title card. */ + char *pl_date; /* Date. */ + char *pl_name; /* The plot name. */ + char *pl_typename; /* Tran1, op2, etc. */ + struct dvec *pl_dvecs; /* The data vectors in this plot. */ + struct dvec *pl_scale; /* The "scale" for the rest of the vectors. */ + struct plot *pl_next; /* List of plots. */ + wordlist *pl_commands; /* Commands to execute for this plot. */ + struct variable *pl_env; /* The 'environment' for this plot. */ + char *pl_ccom; /* The ccom struct for this plot. */ + bool pl_written; /* Some or all of the vecs have been saved. */ + int pl_ndims; /* Number of dimensions */ +} ; + + +#endif diff --git a/src/include/pnode.h b/src/include/pnode.h new file mode 100644 index 000000000..d965b588a --- /dev/null +++ b/src/include/pnode.h @@ -0,0 +1,14 @@ +#ifndef _PNODE_H +#define _PNODE_H + +struct pnode { + char *pn_name; /* If non-NULL, the name. */ + struct dvec *pn_value; /* Non-NULL in a terminal node. */ + struct func *pn_func; /* Non-NULL is a function. */ + struct op *pn_op; /* Operation if the above two NULL. */ + struct pnode *pn_left; /* Left branch or function argument. */ + struct pnode *pn_right; /* Right branch. */ + struct pnode *pn_next; /* For expression lists. */ +} ; + +#endif diff --git a/src/include/sim.h b/src/include/sim.h new file mode 100644 index 000000000..67c5f1400 --- /dev/null +++ b/src/include/sim.h @@ -0,0 +1,19 @@ +#ifndef _SIM_H +#define _SIM_H + +enum simulation_types { + SV_NOTYPE, + SV_TIME, + SV_FREQUENCY, + SV_VOLTAGE, + SV_CURRENT, + SV_OUTPUT_N_DENS, + SV_OUTPUT_NOISE, + SV_INPUT_N_DENS, + SV_INPUT_NOISE, + SV_POLE, + SV_ZERO, + SV_SPARAM +}; + +#endif diff --git a/src/include/variable.h b/src/include/variable.h new file mode 100644 index 000000000..0e5a47d36 --- /dev/null +++ b/src/include/variable.h @@ -0,0 +1,36 @@ +#ifndef _VARIABLE_H +#define _VARIABLE_H + +/* Variables that are accessible to the parser via $varname expansions. + * If the type is VT_LIST the value is a pointer to a list of the elements. + */ + +struct variable { + char va_type; + char *va_name; + union { + bool vV_bool; + int vV_num; + double vV_real; + char *vV_string; + struct variable *vV_list; + } va_V; + struct variable *va_next; /* Link. */ +} ; + +#define va_bool va_V.vV_bool +#define va_num va_V.vV_num +#define va_real va_V.vV_real +#define va_string va_V.vV_string +#define va_vlist va_V.vV_list + +enum vt_types { + VT_BOOL, + VT_NUM, + VT_REAL, + VT_STRING, + VT_LIST +}; + + +#endif diff --git a/src/include/wordlist.h b/src/include/wordlist.h new file mode 100644 index 000000000..73abb4482 --- /dev/null +++ b/src/include/wordlist.h @@ -0,0 +1,14 @@ +#ifndef _WORDLIST_H +#define _WORDLIST_H + + +/* Doubly linked lists of words. */ +struct wordlist { + char *wl_word; + struct wordlist *wl_next; + struct wordlist *wl_prev; +} ; + +typedef struct wordlist wordlist; + +#endif diff --git a/src/main.c b/src/main.c index 9c264b544..7365ed109 100644 --- a/src/main.c +++ b/src/main.c @@ -156,13 +156,13 @@ double CONSTvt0; double CONSTKoverQ; double CONSTe; IFfrontEnd *SPfrontEnd = NULL; - +int DEVmaxnum = 0; int SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator) { #ifdef SIMULATOR - SIMinfo.numDevices = num_devices(); + SIMinfo.numDevices = DEVmaxnum = num_devices(); SIMinfo.devices = devices_ptr(); #endif /* SIMULATOR */ diff --git a/src/maths/cmaths/cmath1.c b/src/maths/cmaths/cmath1.c index fd61677ff..54415a0b9 100644 --- a/src/maths/cmaths/cmath1.c +++ b/src/maths/cmaths/cmath1.c @@ -19,7 +19,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftecmath.h" #include "cmath1.h" diff --git a/src/maths/cmaths/cmath2.c b/src/maths/cmaths/cmath2.c index 4333867d1..a0c4cd323 100644 --- a/src/maths/cmaths/cmath2.c +++ b/src/maths/cmaths/cmath2.c @@ -18,7 +18,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftecmath.h" #include "cmath2.h" diff --git a/src/maths/cmaths/cmath3.c b/src/maths/cmaths/cmath3.c index db6b799d7..1cd3aa0ad 100644 --- a/src/maths/cmaths/cmath3.c +++ b/src/maths/cmaths/cmath3.c @@ -18,7 +18,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "dvec.h" #include "ftecmath.h" #include "cmath3.h" diff --git a/src/maths/cmaths/cmath4.c b/src/maths/cmaths/cmath4.c index 833d13560..ad7d1dfd8 100644 --- a/src/maths/cmaths/cmath4.c +++ b/src/maths/cmaths/cmath4.c @@ -15,11 +15,12 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * and return a char * that is cast to complex or double. */ -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "ftecmath.h" +#include +#include +#include +#include +#include + #include "cmath4.h" diff --git a/src/sconvert.c b/src/sconvert.c index 38774d0ed..49448180a 100644 --- a/src/sconvert.c +++ b/src/sconvert.c @@ -11,7 +11,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include #include "cpdefs.h" #include "ftedefs.h" -#include "ftedata.h" +#include "sim.h" #include "suffix.h" FILE *cp_in = 0;