Browse Source

* src/Makefile.am src/main.c src/sconvert.c


			
			
				pre-master-46
			
			
		
arno 26 years ago
parent
commit
8696a52e89
  1. 4
      src/Makefile.am
  2. 1
      src/analysis/cktdisto.c
  3. 1
      src/analysis/cktnoise.c
  4. 1
      src/analysis/noisean.c
  5. 1
      src/frontend/.cvsignore
  6. 36
      src/frontend/Makefile.am
  7. 5
      src/frontend/README
  8. 2
      src/frontend/agraf.c
  9. 2
      src/frontend/aspice.c
  10. 3
      src/frontend/breakp.c
  11. 2
      src/frontend/breakp2.c
  12. 2
      src/frontend/circuits.c
  13. 130
      src/frontend/com_compose.c
  14. 10
      src/frontend/com_compose.h
  15. 77
      src/frontend/com_display.c
  16. 8
      src/frontend/com_display.h
  17. 206
      src/frontend/com_let.c
  18. 8
      src/frontend/com_let.h
  19. 33
      src/frontend/com_setscale.c
  20. 9
      src/frontend/com_setscale.h
  21. 744
      src/frontend/commands.c
  22. 11
      src/frontend/commands.h
  23. 25
      src/frontend/completion.h
  24. 12
      src/frontend/compose.h
  25. 3
      src/frontend/cpitf.c
  26. 2
      src/frontend/debugcom.c
  27. 5
      src/frontend/define.c
  28. 4
      src/frontend/diff.c
  29. 2
      src/frontend/dimens.c
  30. 8
      src/frontend/display.c
  31. 4
      src/frontend/doplot.c
  32. 5
      src/frontend/dotcards.c
  33. 445
      src/frontend/evaluate.c
  34. 2
      src/frontend/fourier.c
  35. 4
      src/frontend/graf.c
  36. 2
      src/frontend/grid.c
  37. 4
      src/frontend/inp.c
  38. 2
      src/frontend/inpcom.c
  39. 18
      src/frontend/interp.c
  40. 2
      src/frontend/linear.c
  41. 18
      src/frontend/misccoms.c
  42. 1
      src/frontend/misccoms.h
  43. 2
      src/frontend/miscvars.c
  44. 2
      src/frontend/mw_coms.c
  45. 2
      src/frontend/newcoms.c
  46. 355
      src/frontend/nutctab.c
  47. 12
      src/frontend/nutctab.h
  48. 2
      src/frontend/nutinp.c
  49. 2
      src/frontend/options.c
  50. 5
      src/frontend/outitf.c
  51. 3
      src/frontend/parse.c
  52. 2
      src/frontend/plotcurv.c
  53. 3
      src/frontend/plotting/.cvsignore
  54. 17
      src/frontend/plotting/Makefile.am
  55. 0
      src/frontend/plotting/plot5.c
  56. 0
      src/frontend/plotting/plot5.h
  57. 16
      src/frontend/plotting/plotting.c
  58. 12
      src/frontend/plotting/plotting.h
  59. 85
      src/frontend/plotting/pvec.c
  60. 8
      src/frontend/plotting/pvec.h
  61. 327
      src/frontend/plotting/x11.c
  62. 5
      src/frontend/plotting/x11.h
  63. 2
      src/frontend/plotting/xgraph.c
  64. 0
      src/frontend/plotting/xgraph.h
  65. 2
      src/frontend/points.c
  66. 409
      src/frontend/postcoms.c
  67. 6
      src/frontend/rawfile.c
  68. 4
      src/frontend/runcoms.c
  69. 2
      src/frontend/runcoms2.c
  70. 2
      src/frontend/shyu.c
  71. 381
      src/frontend/spcmdtab.c
  72. 4
      src/frontend/spec.c
  73. 1
      src/frontend/spiceif.c
  74. 8
      src/frontend/streams.h
  75. 25
      src/frontend/testcommands.c
  76. 2
      src/frontend/typesdef.c
  77. 257
      src/frontend/vectors.c
  78. 2
      src/frontend/where.c
  79. 6
      src/include/bool.h
  80. 19
      src/include/complex.h
  81. 74
      src/include/cpdefs.h
  82. 6
      src/include/cpextern.h
  83. 29
      src/include/cpstd.h
  84. 65
      src/include/dvec.h
  85. 80
      src/include/fteconst.h
  86. 61
      src/include/ftedata.h
  87. 2
      src/include/ftedev.h
  88. 4
      src/include/fteext.h
  89. 6
      src/include/ftegraph.h
  90. 28
      src/include/fteparse.h
  91. 12
      src/include/grid.h
  92. 27
      src/include/plot.h
  93. 14
      src/include/pnode.h
  94. 19
      src/include/sim.h
  95. 36
      src/include/variable.h
  96. 14
      src/include/wordlist.h
  97. 4
      src/main.c
  98. 2
      src/maths/cmaths/cmath1.c
  99. 2
      src/maths/cmaths/cmath2.c
  100. 2
      src/maths/cmaths/cmath3.c

4
src/Makefile.am

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in ## 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 bin_PROGRAMS = ngspice nutmeg help sconvert proc2mod multidec makeidx
@ -67,6 +67,7 @@ ngspice_SOURCES = \
ngspice_LDADD = \ ngspice_LDADD = \
spice.o \ spice.o \
frontend/libfte.a \ frontend/libfte.a \
frontend/plotting/libplotting.a \
devices/libdev.a \ devices/libdev.a \
$(DYNAMIC_DEVICELIBS) \ $(DYNAMIC_DEVICELIBS) \
analysis/libckt.a \ analysis/libckt.a \
@ -92,6 +93,7 @@ nutmeg_SOURCES = \
nutmeg_LDADD = \ nutmeg_LDADD = \
frontend/libfte.a \ frontend/libfte.a \
frontend/plotting/libplotting.a \
parser/libparser.a \ parser/libparser.a \
hlp/libhlp.a \ hlp/libhlp.a \
maths/cmaths/libcmaths.a \ maths/cmaths/libcmaths.a \

1
src/analysis/cktdisto.c

@ -13,7 +13,6 @@ Author: 1988 Jaijeet S Roychowdhury
#include "devdefs.h" #include "devdefs.h"
#include "vsrc/vsrcdefs.h" #include "vsrc/vsrcdefs.h"
#include "isrc/isrcdefs.h" #include "isrc/isrcdefs.h"
#include "fteconst.h"
#include "iferrmsg.h" #include "iferrmsg.h"
#include "distodef.h" #include "distodef.h"
#include "sperror.h" #include "sperror.h"

1
src/analysis/cktnoise.c

@ -16,7 +16,6 @@ Author: 1987 Gary W. Ng
#include <stdio.h> #include <stdio.h>
#include "cktdefs.h" #include "cktdefs.h"
#include "devdefs.h" #include "devdefs.h"
#include "fteconst.h"
#include "iferrmsg.h" #include "iferrmsg.h"
#include "noisedef.h" #include "noisedef.h"
#include "sperror.h" #include "sperror.h"

1
src/analysis/noisean.c

@ -13,7 +13,6 @@ Author: 1987 Gary W. Ng
#include <stdio.h> #include <stdio.h>
#include "acdefs.h" #include "acdefs.h"
#include "cktdefs.h" #include "cktdefs.h"
#include "fteconst.h"
#include "iferrmsg.h" #include "iferrmsg.h"
#include "noisedef.h" #include "noisedef.h"
#include "sperror.h" #include "sperror.h"

1
src/frontend/.cvsignore

@ -1,3 +1,4 @@
Makefile.in Makefile.in
Makefile Makefile
.deps .deps
.libs

36
src/frontend/Makefile.am

@ -1,8 +1,21 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
SUBDIRS = plotting
noinst_LIBRARIES = libfte.a noinst_LIBRARIES = libfte.a
libfte_a_SOURCES = \ libfte_a_SOURCES = \
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.c \
agraf.h \ agraf.h \
arg.c \ arg.c \
@ -17,8 +30,6 @@ libfte_a_SOURCES = \
circuits.h \ circuits.h \
clip.c \ clip.c \
clip.h \ clip.h \
compose.c \
compose.h \
cpitf.c \ cpitf.c \
cpitf.h \ cpitf.h \
debugcom.c \ debugcom.c \
@ -67,8 +78,6 @@ libfte_a_SOURCES = \
mw_coms.h \ mw_coms.h \
newcoms.c \ newcoms.c \
newcoms.h \ newcoms.h \
nutctab.c \
nutctab.h \
nutinp.c \ nutinp.c \
nutinp.h \ nutinp.h \
nutmegif.c \ nutmegif.c \
@ -79,8 +88,6 @@ libfte_a_SOURCES = \
outitf.h \ outitf.h \
parse.c \ parse.c \
parse.h \ parse.h \
plot5.c \
plot5.h \
plotcurv.c \ plotcurv.c \
plotcurv.h \ plotcurv.h \
points.c \ points.c \
@ -103,7 +110,6 @@ libfte_a_SOURCES = \
signal_handler.h\ signal_handler.h\
spec.c \ spec.c \
spec.h \ spec.h \
spcmdtab.c \
spiceif.c \ spiceif.c \
spiceif.h \ spiceif.h \
subckt.c \ subckt.c \
@ -113,13 +119,17 @@ libfte_a_SOURCES = \
vectors.c \ vectors.c \
vectors.h \ vectors.h \
where.c \ where.c \
where.h \
x11.c \
x11.h \
xgraph.c \
xgraph.h
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@ INCLUDES = -I$(top_srcdir)/src/include @X_CFLAGS@

5
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.

2
src/frontend/agraf.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "agraf.h" #include "agraf.h"

2
src/frontend/aspice.c

@ -31,7 +31,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include <signal.h> #include <signal.h>
#include "fteinp.h" #include "fteinp.h"
#include "ftedata.h"
#include "dvec.h"
#ifndef SEEK_SET #ifndef SEEK_SET

3
src/frontend/breakp.c

@ -10,10 +10,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "breakp.h" #include "breakp.h"
#include "completion.h"
static bool satisfied(struct dbcomm *d, struct plot *plot); static bool satisfied(struct dbcomm *d, struct plot *plot);
static void printcond(struct dbcomm *d, FILE *fp); static void printcond(struct dbcomm *d, FILE *fp);

2
src/frontend/breakp2.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "breakp2.h" #include "breakp2.h"

2
src/frontend/circuits.c

@ -9,7 +9,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "circuits.h" #include "circuits.h"

130
src/frontend/compose.c → 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 <ngspice.h>
#include <complex.h>
#include <dvec.h>
#include <bool.h>
#include <sim.h>
#include <pnode.h>
#include <fteext.h>
/*
* 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"
/* 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;
}
#include "ngspice.h"
#include "cpdefs.h"
#include "ftedefs.h"
#include "ftedata.h"
#include "fteparse.h"
#include "compose.h"
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 ...' /* The general syntax is 'compose name parm = val ...'
@ -47,7 +88,10 @@ static void dimxpand(struct dvec *v, int *newdims, double *data);
void void
com_compose(wordlist *wl) 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 center;
double span; double span;
double mean, sd; double mean, sd;
@ -66,9 +110,10 @@ com_compose(wordlist *wl)
char *resname, *s, *var, *val; char *resname, *s, *var, *val;
double *td, tt; 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; bool realflag = TRUE;
int dims[MAXDIMS]; int dims[MAXDIMS];
struct dvec *result, *vecs = NULL, *v, *lv = NULL; struct dvec *result, *vecs = NULL, *v, *lv = NULL;
@ -435,50 +480,3 @@ com_compose(wordlist *wl)
cp_addkword(CT_VECTOR, result->v_name); cp_addkword(CT_VECTOR, result->v_name);
return; 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;
}

10
src/frontend/com_compose.h

@ -0,0 +1,10 @@
#ifndef _COM_COMPOSE_H
#define _COM_COMPOSE_H
#include <wordlist.h>
void com_compose(wordlist *wl);
#endif

77
src/frontend/com_display.c

@ -0,0 +1,77 @@
#include <ngspice.h>
#include <bool.h>
#include <variable.h>
#include <fteext.h>
#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;
}

8
src/frontend/com_display.h

@ -0,0 +1,8 @@
#ifndef _COM_DISPLAY_H
#define _COM_DISPLAY_H
#include <wordlist.h>
void com_display(wordlist *wl);
#endif

206
src/frontend/com_let.c

@ -0,0 +1,206 @@
#include <stddef.h>
#include <dvec.h>
#include <ngspice.h>
#include <fteext.h>
#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;
}

8
src/frontend/com_let.h

@ -0,0 +1,8 @@
#ifndef _COM_LET_H
#define _COM_LET_H
#include <wordlist.h>
void com_let(wordlist *wl);
#endif

33
src/frontend/com_setscale.c

@ -0,0 +1,33 @@
#include <ngspice.h>
#include <dvec.h>
#include <cpextern.h>
#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");
}
}

9
src/frontend/com_setscale.h

@ -0,0 +1,9 @@
#ifndef _COM_SETSCALE_H
#define _COM_SETSCALE_H
#include <wordlist.h>
void com_setscale(wordlist *wl);
#endif

744
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 <ngspice.h>
#include <ftedefs.h>
#include <ftehelp.h>
#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 }
} ;

11
src/frontend/commands.h

@ -0,0 +1,11 @@
#ifndef _COMMANDS_H
#define _COMMANDS_H
#include <cpdefs.h>
extern struct comm spcp_coms[];
extern struct comm nutcp_coms[];
#endif

25
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

12
src/frontend/compose.h

@ -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

3
src/frontend/cpitf.c

@ -6,10 +6,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "cpitf.h" #include "cpitf.h"
#include "completion.h"
/* Set some standard variables and aliases, etc, and init the ccom stuff. */ /* Set some standard variables and aliases, etc, and init the ccom stuff. */

2
src/frontend/debugcom.c

@ -11,7 +11,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "debugcom.h" #include "debugcom.h"

5
src/frontend/define.c

@ -17,10 +17,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "define.h" #include "define.h"
#include "completion.h"
/* static declarations */ /* static declarations */
static void savetree(struct pnode *pn); static void savetree(struct pnode *pn);
@ -439,7 +440,7 @@ com_undefine(wordlist *wlist)
*/ */
void void
ft_pnode(struct pn *pn)
ft_pnode(struct pnode *pn)
{ {
prtree1(pn, cp_err); prtree1(pn, cp_err);
} }

4
src/frontend/diff.c

@ -10,8 +10,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftecmath.h" #include "ftecmath.h"
#include "sim.h"
#include "diff.h" #include "diff.h"

2
src/frontend/dimens.c

@ -8,7 +8,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
*/ */
#include "ngspice.h" #include "ngspice.h"
#include "ftedata.h" /* For MAXDIMS */
#include "dvec.h" /* For MAXDIMS */
#include "dimens.h" #include "dimens.h"

8
src/frontend/display.c

@ -15,8 +15,8 @@ Copyright 1990 Regents of the University of California. All rights reserved.
/* static declarations */ /* 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 nop(void);
static int nodev(void); static int nodev(void);
@ -230,7 +230,7 @@ void Update(void)
/* note: screen coordinates are relative to window /* note: screen coordinates are relative to window
so need to add viewport offsets */ so need to add viewport offsets */
static int
static void
gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny) 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) gen_Input(REQUEST *request, RESPONSE *response)
{ {

4
src/frontend/doplot.c

@ -11,10 +11,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "fteinput.h" #include "fteinput.h"
#include "ftedbgra.h" #include "ftedbgra.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "fteconst.h"
#include "plot.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedev.h" #include "ftedev.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "fteext.h" #include "fteext.h"
#include "doplot.h" #include "doplot.h"

5
src/frontend/dotcards.c

@ -10,10 +10,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "dotcards.h"
#include <sim.h>
#include "dotcards.h"
/* Extract all the .save lines */ /* Extract all the .save lines */

445
src/frontend/evaluate.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "ftecmath.h" #include "ftecmath.h"
#include <setjmp.h> #include <setjmp.h>
@ -22,9 +22,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
static RETSIGTYPE sig_matherr(void); static RETSIGTYPE sig_matherr(void);
static struct dvec * apply_func(struct func *func, struct pnode *arg); static struct dvec * apply_func(struct func *func, struct pnode *arg);
static char * mkcname(char what, char *v1, char *v2); 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. /* We are careful here to catch SIGILL and recognise them as math errors.
@ -81,8 +78,226 @@ ft_evaluate(struct pnode *node)
return (d); 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 * struct dvec *
op_plus(struct pnode *arg1, struct pnode *arg2) 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); (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") if (eq(func->fu_name, "interpolate")
|| eq(func->fu_name, "deriv")) /* Ack */ || 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_length, &len, &type,
v->v_plot, plot_cur, v->v_dims[0])); v->v_plot, plot_cur, v->v_dims[0]));
} else { } else {
#endif
data = ((*func->fu_func) ((isreal(v) ? (void *) data = ((*func->fu_func) ((isreal(v) ? (void *)
v->v_realdata : v->v_realdata :
(void *) v->v_compdata), (void *) v->v_compdata),
(short) (isreal(v) ? VF_REAL : (short) (isreal(v) ? VF_REAL :
VF_COMPLEX), VF_COMPLEX),
v->v_length, &len, &type)); v->v_length, &len, &type));
#if 0
} }
#endif
/* Back to normal */ /* Back to normal */
(void) signal(SIGILL, SIG_DFL); (void) signal(SIGILL, SIG_DFL);
@ -586,215 +809,3 @@ mkcname(char what, char *v1, char *v2)
return (s); 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);
}

2
src/frontend/fourier.c

@ -12,7 +12,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "sperror.h" #include "sperror.h"
#include "const.h" #include "const.h"

4
src/frontend/graf.c

@ -13,9 +13,9 @@ Author: 1988 Jeffrey M. Hsu
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" /* for VT_ */ #include "cpdefs.h" /* for VT_ */
#include "cpextern.h" #include "cpextern.h"
#include "fteconst.h"
#include "plot.h"
#include "ftedebug.h" /* for iplot */ #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 "ftedefs.h" /* for FTEextern.h and IPOINT{MIN,MAX} */
#include "fteinput.h" #include "fteinput.h"
#include "ftegraph.h" #include "ftegraph.h"

2
src/frontend/grid.c

@ -11,7 +11,7 @@ Copyright 1990 Regents of the University of California. All rights reserved.
#include "ftegraph.h" #include "ftegraph.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "grid.h" #include "grid.h"

4
src/frontend/inp.c

@ -12,11 +12,11 @@ Author: 1985 Wayne A. Christopher
#include "cpdefs.h" #include "cpdefs.h"
#include "inpdefs.h" #include "inpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "inp.h" #include "inp.h"
#include "completion.h"
/* static declarations */ /* static declarations */
static char * upper(register char *string); static char * upper(register char *string);

2
src/frontend/inpcom.c

@ -11,7 +11,7 @@ Author: 1985 Wayne A. Christopher
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "inpcom.h" #include "inpcom.h"

18
src/frontend/interp.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "interp.h" #include "interp.h"
@ -24,7 +24,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
/* static declarations */ /* static declarations */
static int putinterval(double *poly, int degree, double *nvec, int last, double *nscale, static int putinterval(double *poly, int degree, double *nvec, int last, double *nscale,
int nlen, double oval, int sign); int nlen, double oval, int sign);
static void printmat(char *name, double *mat, int m, int n);
bool bool
@ -260,21 +259,6 @@ putinterval(double *poly, int degree, double *nvec, int last, double *nscale, in
return (end); 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 double
ft_peval(double x, double *coeffs, int degree) ft_peval(double x, double *coeffs, int degree)

2
src/frontend/linear.c

@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "linear.h" #include "linear.h"

18
src/frontend/misccoms.c

@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftehelp.h" #include "ftehelp.h"
#include "hlpdefs.h" #include "hlpdefs.h"
#include "misccoms.h" #include "misccoms.h"
@ -14,6 +14,16 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
static void byemesg(void); 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 void
com_help(wordlist *wl) com_help(wordlist *wl)
{ {
@ -227,12 +237,6 @@ com_ghelp(wordlist *wl)
return; return;
} }
int
hcomp(struct comm **c1, struct comm **c2)
{
return (strcmp((*c1)->co_comname, (*c2)->co_comname));
}
void void
com_quit(wordlist *wl) com_quit(wordlist *wl)

1
src/frontend/misccoms.h

@ -9,7 +9,6 @@
void com_help(wordlist *wl); void com_help(wordlist *wl);
void com_ahelp(wordlist *wl); void com_ahelp(wordlist *wl);
void com_ghelp(wordlist *wl); void com_ghelp(wordlist *wl);
int hcomp(struct comm **c1, struct comm **c2);
void com_quit(wordlist *wl); void com_quit(wordlist *wl);
void com_bug(wordlist *wl); void com_bug(wordlist *wl);
void com_version(wordlist *wl); void com_version(wordlist *wl);

2
src/frontend/miscvars.c

@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "miscvars.h" #include "miscvars.h"

2
src/frontend/mw_coms.c

@ -7,7 +7,7 @@
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedev.h" #include "ftedev.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "ftedata.h"
#include "dvec.h"
#include "mw_coms.h" #include "mw_coms.h"

2
src/frontend/newcoms.c

@ -10,7 +10,7 @@ Copyright 1992 Regents of the University of California. All rights reserved.
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteparse.h" #include "fteparse.h"
#include "ftedata.h"
#include "dvec.h"
#include "newcoms.h" #include "newcoms.h"

355
src/frontend/nutctab.c

@ -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 }
} ;

12
src/frontend/nutctab.h

@ -1,12 +0,0 @@
/*************
* Header file for nutctab.c
* 1999 E. Rouat
************/
#ifndef NUTCTAB_H_INCLUDED
#define NUTCTAB_H_INCLUDED
#endif

2
src/frontend/nutinp.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "nutinp.h" #include "nutinp.h"

2
src/frontend/options.c

@ -13,7 +13,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteinp.h" #include "fteinp.h"
#include "options.h" #include "options.h"

5
src/frontend/outitf.c

@ -13,8 +13,9 @@ Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.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 "inpdefs.h" /* for INPtables */
#include "ifsim.h" #include "ifsim.h"
#include "jobdefs.h" #include "jobdefs.h"

3
src/frontend/parse.c

@ -12,9 +12,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteparse.h" #include "fteparse.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftecmath.h" #include "ftecmath.h"
#include "parse.h" #include "parse.h"
#include "sim.h"
/* static declarations */ /* static declarations */

2
src/frontend/plotcurv.c

@ -10,7 +10,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftegraph.h" #include "ftegraph.h"
#include "ftedbgra.h" #include "ftedbgra.h"
#include "plotcurv.h" #include "plotcurv.h"

3
src/frontend/plotting/.cvsignore

@ -0,0 +1,3 @@
Makefile.in
Makefile
.deps

17
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

0
src/frontend/plot5.c → src/frontend/plotting/plot5.c

0
src/frontend/plot5.h → src/frontend/plotting/plot5.h

16
src/frontend/plotting/plotting.c

@ -0,0 +1,16 @@
#include <ngspice.h>
#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;

12
src/frontend/plotting/plotting.h

@ -0,0 +1,12 @@
#ifndef _PLOTTING_H
#define _PLOTTING_H
#include <plot.h>
extern struct plot constantplot;
extern struct plot *plot_cur;
extern struct plot *plot_list;
extern int plotl_changed;
extern int plot_num;
#endif

85
src/frontend/plotting/pvec.c

@ -0,0 +1,85 @@
#include <ngspice.h>
#include <dvec.h>
#include <plot.h>
#include <fteext.h>
#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;
}

8
src/frontend/plotting/pvec.h

@ -0,0 +1,8 @@
#ifndef _PVEC_H
#define _PVEC_H
#include <dvec.h>
void pvec(struct dvec *d);
#endif

327
src/frontend/x11.c → src/frontend/plotting/x11.c

@ -89,8 +89,6 @@ static int numdispplanes;
extern void internalerror (char *message); extern void internalerror (char *message);
extern void externalerror (char *message); extern void externalerror (char *message);
void initlinestyles (void);
void initcolors (GRAPH *graph);
extern void PushGraphContext (GRAPH *graph); extern void PushGraphContext (GRAPH *graph);
extern void SetColor (int colorid); extern void SetColor (int colorid);
extern void Text (char *text, int x, int y); 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); extern void PopGraphContext (void);
void slopelocation (GRAPH *graph, int x0, int y0); void slopelocation (GRAPH *graph, int x0, int y0);
void zoomin (GRAPH *graph); void zoomin (GRAPH *graph);
void X_ScreentoData (GRAPH *graph, int x, int y, double *fx, double *fy);
extern int DestroyGraph (int id); extern int DestroyGraph (int id);
extern void gr_redraw (GRAPH *graph); extern void gr_redraw (GRAPH *graph);
extern void gr_resize (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 int
X11_Init(void) X11_Init(void)
{ {
@ -169,13 +177,135 @@ X11_Init(void)
} }
void
errorhandler(Display *display, XErrorEvent *errorev)
static void
initlinestyles(void)
{ {
XGetErrorText(display, errorev->error_code, ErrorMessage, 1024);
int i;
if (numdispplanes > 1) {
/* Dotted lines are a distraction when we have colors. */
for (i = 2; i < NUMLINESTYLES; i++) {
xlinestyles[i] = xlinestyles[0];
}
}
}
static void
initcolors(GRAPH *graph)
{
int i;
static char *colornames[] = { "black", /* white */
"white", "red", "blue",
"orange", "green", "pink",
"brown", "khaki", "plum",
"orchid", "violet", "maroon",
"turquoise", "sienna", "coral",
"cyan", "magenta", "gold",
"yellow", ""
};
XColor visualcolor, exactcolor;
char buf[BSIZE_SP], colorstring[BSIZE_SP];
int xmaxcolors = NUMCOLORS; /* note: can we get rid of this? */
if (numdispplanes == 1) {
/* black and white */
xmaxcolors = 2;
graph->colors[0] = DEVDEP(graph).view->core.background_pixel;
if (graph->colors[0] == WhitePixel(display, DefaultScreen(display)))
graph->colors[1] = BlackPixel(display, DefaultScreen(display));
else
graph->colors[1] = WhitePixel(display, DefaultScreen(display));
} else {
if (numdispplanes < NXPLANES)
xmaxcolors = 1 << numdispplanes;
for (i = 0; i < xmaxcolors; i++) {
(void) sprintf(buf, "color%d", i);
if (!cp_getvar(buf, VT_STRING, colorstring))
(void) strcpy(colorstring, colornames[i]);
if (!XAllocNamedColor(display,
DefaultColormap(display, DefaultScreen(display)),
colorstring, &visualcolor, &exactcolor)) {
(void) sprintf(ErrorMessage,
"can't get color %s\n", colorstring);
externalerror(ErrorMessage); externalerror(ErrorMessage);
graph->colors[i] = i ? BlackPixel(display,
DefaultScreen(display))
: WhitePixel(display, DefaultScreen(display));
continue;
}
graph->colors[i] = visualcolor.pixel;
/* MW. I don't need this, everyone must know what he is doing
if (i > 0 &&
graph->colors[i] == DEVDEP(graph).view->core.background_pixel) {
graph->colors[i] = graph->colors[0];
} */
}
/* MW. Set Beackgroound here */
XSetWindowBackground(display, DEVDEP(graph).window, graph->colors[0]);
/* if (graph->colors[0] != DEVDEP(graph).view->core.background_pixel) {
graph->colors[0] = DEVDEP(graph).view->core.background_pixel;
} */
}
for (i = xmaxcolors; i < NUMCOLORS; i++) {
graph->colors[i] = graph->colors[i + 1 - xmaxcolors];
}
}
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. */ /* Recover from bad NewViewPort call. */
#define RECOVERNEWVIEWPORT() free((char *) graph);\ #define RECOVERNEWVIEWPORT() free((char *) graph);\
graph = (GRAPH *) NULL; graph = (GRAPH *) NULL;
@ -231,7 +361,9 @@ X11_NewViewport(GRAPH *graph)
/* set up viewport */ /* set up viewport */
DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass,
DEVDEP(graph).form, viewargs, XtNumber(viewargs));
DEVDEP(graph).form,
viewargs,
XtNumber(viewargs));
XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE,
handlebuttonev, graph); handlebuttonev, graph);
XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE,
@ -322,90 +454,6 @@ X11_NewViewport(GRAPH *graph)
return (0); return (0);
} }
static void
initlinestyles(void)
{
int i;
if (numdispplanes > 1) {
/* Dotted lines are a distraction when we have colors. */
for (i = 2; i < NUMLINESTYLES; i++) {
xlinestyles[i] = xlinestyles[0];
}
}
}
static void
initcolors(GRAPH *graph)
{
int i;
static char *colornames[] = { "black", /* white */
"white", "red", "blue",
"orange", "green", "pink",
"brown", "khaki", "plum",
"orchid", "violet", "maroon",
"turquoise", "sienna", "coral",
"cyan", "magenta", "gold",
"yellow", ""
};
XColor visualcolor, exactcolor;
char buf[BSIZE_SP], colorstring[BSIZE_SP];
int xmaxcolors = NUMCOLORS; /* note: can we get rid of this? */
if (numdispplanes == 1) {
/* black and white */
xmaxcolors = 2;
graph->colors[0] = DEVDEP(graph).view->core.background_pixel;
if (graph->colors[0] == WhitePixel(display, DefaultScreen(display)))
graph->colors[1] = BlackPixel(display, DefaultScreen(display));
else
graph->colors[1] = WhitePixel(display, DefaultScreen(display));
} else {
if (numdispplanes < NXPLANES)
xmaxcolors = 1 << numdispplanes;
for (i = 0; i < xmaxcolors; i++) {
(void) sprintf(buf, "color%d", i);
if (!cp_getvar(buf, VT_STRING, colorstring))
(void) strcpy(colorstring, colornames[i]);
if (!XAllocNamedColor(display,
DefaultColormap(display, DefaultScreen(display)),
colorstring, &visualcolor, &exactcolor)) {
(void) sprintf(ErrorMessage,
"can't get color %s\n", colorstring);
externalerror(ErrorMessage);
graph->colors[i] = i ? BlackPixel(display,
DefaultScreen(display))
: WhitePixel(display, DefaultScreen(display));
continue;
}
graph->colors[i] = visualcolor.pixel;
/* MW. I don't need this, everyone must know what he is doing
if (i > 0 &&
graph->colors[i] == DEVDEP(graph).view->core.background_pixel) {
graph->colors[i] = graph->colors[0];
} */
}
/* MW. Set Beackgroound here */
XSetWindowBackground(display, DEVDEP(graph).window, graph->colors[0]);
/* if (graph->colors[0] != DEVDEP(graph).view->core.background_pixel) {
graph->colors[0] = DEVDEP(graph).view->core.background_pixel;
} */
}
for (i = xmaxcolors; i < NUMCOLORS; i++) {
graph->colors[i] = graph->colors[i + 1 - xmaxcolors];
}
}
/* This routine closes the X connection. /* This routine closes the X connection.
It is not to be called for finishing a graph. */ It is not to be called for finishing a graph. */
void void
@ -536,48 +584,40 @@ 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();
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
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;
}
}
void void
slopelocation(GRAPH *graph, int x0, int y0) 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 static void
linear_arc(int x0, int y0, int radius, double theta1, double theta2) linear_arc(int x0, int y0, int radius, double theta1, double theta2)
/* x coordinate of center */ /* x coordinate of center */

5
src/frontend/x11.h → src/frontend/plotting/x11.h

@ -7,10 +7,7 @@
#define X11_H_INCLUDED #define X11_H_INCLUDED
int X11_Init(void); int X11_Init(void);
void errorhandler(Display *display, XErrorEvent *errorev);
int X11_NewViewport(GRAPH *graph); int X11_NewViewport(GRAPH *graph);
void initlinestyles(void);
void initcolors(GRAPH *graph);
void X11_Close(void); void X11_Close(void);
void X11_DrawLine(int x1, int y1, int x2, int y2); void X11_DrawLine(int x1, int y1, int x2, int y2);
void X11_Arc(int x0, int y0, int radius, double theta1, double theta2); 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 redraw(Widget w, caddr_t client_data, caddr_t call_data);
void resize(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 X11_Input(REQUEST *request, RESPONSE *response);
void X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy);
#endif #endif

2
src/frontend/xgraph.c → src/frontend/plotting/xgraph.c

@ -10,7 +10,7 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "fteparse.h" #include "fteparse.h"
#include "xgraph.h" #include "xgraph.h"

0
src/frontend/xgraph.h → src/frontend/plotting/xgraph.h

2
src/frontend/points.c

@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftegraph.h" #include "ftegraph.h"
#include "ftedbgra.h" #include "ftedbgra.h"
#include "points.h" #include "points.h"

409
src/frontend/postcoms.c

@ -11,252 +11,16 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteparse.h" #include "fteparse.h"
#include "ftedata.h"
#include "dvec.h"
#include "sim.h"
#include "postcoms.h" #include "postcoms.h"
#include "completion.h"
/* static declarations */ /* static declarations */
static void pvec(struct dvec *d);
static int dcomp(struct dvec **v1, struct dvec **v2);
static void killplot(struct plot *pl); 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. */ /* Undefine vectors. */
void 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. */ /* Take a set of vectors and form a new vector of the nth elements of each. */
void void
com_cross(wordlist *wl) com_cross(wordlist *wl)

6
src/frontend/rawfile.c

@ -11,7 +11,7 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "rawfile.h" #include "rawfile.h"
@ -303,7 +303,7 @@ raw_read(char *name)
} else if (ciprefix("flags:", buf)) { } else if (ciprefix("flags:", buf)) {
s = buf; s = buf;
skip(s); skip(s);
while (t = gettok(&s)) {
while ((t = gettok(&s))) {
if (cieq(t, "real")) if (cieq(t, "real"))
flags |= VF_REAL; flags |= VF_REAL;
else if (cieq(t, "complex")) else if (cieq(t, "complex"))
@ -453,7 +453,7 @@ raw_read(char *name)
v->v_name = copy(buf2); v->v_name = copy(buf2);
} }
/* Now come the strange options... */ /* Now come the strange options... */
while (t = gettok(&s)) {
while ((t = gettok(&s))) {
if (ciprefix("min=", t)) { if (ciprefix("min=", t)) {
if (sscanf(t + 4, "%lf", if (sscanf(t + 4, "%lf",
&v->v_minsignal) != 1) &v->v_minsignal) != 1)

4
src/frontend/runcoms.c

@ -12,9 +12,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedev.h" #include "ftedev.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "ftedata.h"
#include "dvec.h"
#include "runcoms.h" #include "runcoms.h"
#include "completion.h"
/* static declarations */ /* static declarations */
static int dosim(char *what, wordlist *wl); static int dosim(char *what, wordlist *wl);

2
src/frontend/runcoms2.c

@ -12,7 +12,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedev.h" #include "ftedev.h"
#include "ftedebug.h" #include "ftedebug.h"
#include "ftedata.h"
#include "dvec.h"
#include "runcoms2.h" #include "runcoms2.h"

2
src/frontend/shyu.c

@ -14,7 +14,7 @@ Copyright 1990 Regents of the University of California. All rights reserved.
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteinp.h" #include "fteinp.h"
#include "fteconst.h"
#include "sim.h"
#include "devdefs.h" #include "devdefs.h"
#include "inpdefs.h" #include "inpdefs.h"
#include "iferrmsg.h" #include "iferrmsg.h"

381
src/frontend/spcmdtab.c

@ -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 }
};

4
src/frontend/spec.c

@ -9,7 +9,9 @@ Author: 1994 Anthony E. Parker, Department of Electronics, Macquarie Uni.
#include "ngspice.h" #include "ngspice.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "sim.h"
#include "spec.h" #include "spec.h"

1
src/frontend/spiceif.c

@ -15,7 +15,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteinp.h" #include "fteinp.h"
#include "fteconst.h"
#include "inpdefs.h" #include "inpdefs.h"
#include "iferrmsg.h" #include "iferrmsg.h"
#include "ifsim.h" #include "ifsim.h"

8
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

25
src/frontend/testcommands.c

@ -0,0 +1,25 @@
#include <stdio.h>
#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;
}

2
src/frontend/typesdef.c

@ -10,7 +10,7 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "typesdef.h" #include "typesdef.h"

257
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. * Routines for dealing with the vector database.
*/ */
#include "ngspice.h"
#include "cpdefs.h"
#include "ftedefs.h"
#include "ftedata.h"
#include <ngspice.h>
#include <cpdefs.h>
#include <ftedefs.h>
#include <dvec.h>
#include <sim.h>
#include "vectors.h" #include "vectors.h"
#include "completion.h"
#include "plotting/plotting.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);
/* 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);
/* Where 'constants' go when defined on initialization. */
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);
}
static struct plot constantplot = {
"Constant values", "Sat Aug 16 10:55:15 PDT 1986", "constants",
"const", NULL, NULL, NULL, NULL, NULL, NULL, TRUE
} ;
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);
}
struct plot *plot_cur = &constantplot;
struct plot *plot_list = &constantplot;
int plotl_changed; /* TRUE after a load */
int plot_num = 1;
/* If there are imbedded numeric strings, compare them numerically, not
* alphabetically.
*/
static int
namecmp(const void *a, const void *b)
{
int i, j;
/* Load in a rawfile. */
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);
}
/* Load in a rawfile. */
void void
ft_loadfile(char *file) ft_loadfile(char *file)
{ {
@ -304,54 +407,6 @@ vec_get(char *word)
return (sortvecs(d)); 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 /* Execute the commands for a plot. This is done whenever a plot becomes
* the current plot. * the current plot.
*/ */
@ -615,75 +670,7 @@ vec_basename(struct dvec *v)
return (copy(s)); 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 /* Make a plot the current one. This gets called by cp_usrset() when one

2
src/frontend/where.c

@ -6,7 +6,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftehelp.h" #include "ftehelp.h"
#include "hlpdefs.h" #include "hlpdefs.h"
#include "where.h" #include "where.h"

6
src/include/bool.h

@ -0,0 +1,6 @@
#ifndef _BOOL_H
#define _BOOL_H
typedef int bool;
#endif

19
src/include/complex.h

@ -1,9 +1,22 @@
/* /*
* Copyright (c) 1985 Thomas L. Quarles * 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 /* header file containing definitions for complex functions
* *

74
src/include/cpdefs.h

@ -18,17 +18,38 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
/* Information about spice commands. */ /* Information about spice commands. */
struct comm { 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 #define LOTS 1000
@ -44,34 +65,13 @@ struct histent {
struct histent *hi_prev; 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(). */ /* The values returned by cp_userset(). */

6
src/include/cpextern.h

@ -10,6 +10,11 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
#ifndef CPEXTERN_H #ifndef CPEXTERN_H
#define CPEXTERN_H #define CPEXTERN_H
#include "wordlist.h"
#include "bool.h"
#include "variable.h"
/* alias.c */ /* alias.c */
extern struct alias *cp_aliases; extern struct alias *cp_aliases;
@ -18,6 +23,7 @@ extern void com_unalias();
extern void cp_paliases(); extern void cp_paliases();
extern void cp_setalias(); extern void cp_setalias();
extern void cp_unalias(); extern void cp_unalias();
extern wordlist *cp_doalias(); extern wordlist *cp_doalias();
/* backquote.c */ /* backquote.c */

29
src/include/cpstd.h

@ -11,35 +11,20 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
#ifndef _STD_H_ #ifndef _STD_H_
#define _STD_H_ #define _STD_H_
typedef int bool;
#ifndef FILE #ifndef FILE
/* XXX Bogus */ /* XXX Bogus */
# include <stdio.h> # include <stdio.h>
#endif #endif
/* Doubly linked lists of words. */
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;
/* 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
#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 */ /* Externs defined in std.c */

65
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

80
src/include/fteconst.h

@ -8,81 +8,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#ifndef _CONSTANTS_ #ifndef _CONSTANTS_
#define _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 #endif

61
src/include/ftedata.h

@ -10,63 +10,10 @@
#define FTEdata_h #define FTEdata_h
#include "cpstd.h" /* for struct complex */ #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 */ #endif /* FTEdata_h */

2
src/include/ftedev.h

@ -31,7 +31,7 @@ typedef struct {
int (*MakeMenu)(); int (*MakeMenu)();
int (*MakeDialog)(); int (*MakeDialog)();
int (*Input)(); int (*Input)();
int (*DatatoScreen)();
void (*DatatoScreen)();
} DISPDEVICE; } DISPDEVICE;
extern DISPDEVICE *dispdev; extern DISPDEVICE *dispdev;

4
src/include/fteext.h

@ -15,7 +15,8 @@ Modified: 1999 Paolo Nenzi
/* needed to find out what the interface structures look like */ /* needed to find out what the interface structures look like */
#include "ifsim.h" #include "ifsim.h"
#include "fteparse.h"
#include "dvec.h"
#include "plot.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "fteinp.h" #include "fteinp.h"
@ -311,7 +312,6 @@ extern void com_ghelp();
extern void com_help(); extern void com_help();
extern void com_quit(); extern void com_quit();
extern void com_version(); extern void com_version();
extern int hcomp();
extern void com_where(); extern void com_where();
/* numparse.c */ /* numparse.c */

6
src/include/ftegraph.h

@ -10,8 +10,10 @@ Author: 1988 Jeffrey M. Hsu
#ifndef _GRAPH_H_ #ifndef _GRAPH_H_
#define _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. */ /* Device-independent data structure for plots. */

28
src/include/fteparse.h

@ -12,17 +12,15 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#define FTEPARSE #define FTEPARSE
#include "ftedata.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. */
} ;
#include "cpstd.h"
#include "dvec.h"
#include "plot.h"
/* 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. */ /* Operations. These should really be considered functions. */
@ -36,8 +34,12 @@ struct op {
/* The functions that are available. */ /* The functions that are available. */
struct func { 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 /* User-definable functions. The idea of ud_name is that the args are

12
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

27
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

14
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

19
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

36
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

14
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

4
src/main.c

@ -156,13 +156,13 @@ double CONSTvt0;
double CONSTKoverQ; double CONSTKoverQ;
double CONSTe; double CONSTe;
IFfrontEnd *SPfrontEnd = NULL; IFfrontEnd *SPfrontEnd = NULL;
int DEVmaxnum = 0;
int SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator) int SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator)
{ {
#ifdef SIMULATOR #ifdef SIMULATOR
SIMinfo.numDevices = num_devices();
SIMinfo.numDevices = DEVmaxnum = num_devices();
SIMinfo.devices = devices_ptr(); SIMinfo.devices = devices_ptr();
#endif /* SIMULATOR */ #endif /* SIMULATOR */

2
src/maths/cmaths/cmath1.c

@ -19,7 +19,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftecmath.h" #include "ftecmath.h"
#include "cmath1.h" #include "cmath1.h"

2
src/maths/cmaths/cmath2.c

@ -18,7 +18,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftecmath.h" #include "ftecmath.h"
#include "cmath2.h" #include "cmath2.h"

2
src/maths/cmaths/cmath3.c

@ -18,7 +18,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice.h" #include "ngspice.h"
#include "cpdefs.h" #include "cpdefs.h"
#include "ftedefs.h" #include "ftedefs.h"
#include "ftedata.h"
#include "dvec.h"
#include "ftecmath.h" #include "ftecmath.h"
#include "cmath3.h" #include "cmath3.h"

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save