Browse Source

'option' command

pre-master-46
h_vogt 16 years ago
parent
commit
79831ac331
  1. 41
      src/frontend/commands.c
  2. 50
      src/frontend/inp.c
  3. 26
      src/frontend/options.c
  4. 3
      src/include/fteext.h

41
src/frontend/commands.c

@ -71,9 +71,29 @@
/* gtri - end - wbk - add include files */ /* gtri - end - wbk - add include files */
#endif #endif
/* for the definition and decription of struct comm see cpdef.h */
/* Information about spice commands (strucct comm). */
/* The name of the command. */
// char *co_comname;
/* The function that handles the command. */
// void (*co_func) (wordlist *wl);
/* 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;
/* Bool fields: stringargs, spiceonly, major */
/* Bool fields: spiceonly, major */
struct comm spcp_coms[] = { struct comm spcp_coms[] = {
{ "let", com_let, FALSE, TRUE, { "let", com_let, FALSE, TRUE,
@ -93,12 +113,13 @@ struct comm spcp_coms[] = {
arg_set, arg_set,
"[option] [option = value] ... : Set a variable." } , "[option] [option = value] ... : Set a variable." } ,
#ifdef EXPERIMENTAL_CODE
/* PN support for altering options in interactive mode */ /* PN support for altering options in interactive mode */
{ "option", com_option, TRUE, TRUE, { "option", com_option, TRUE, TRUE,
{ 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS,
arg_set, arg_set,
"[option] [option = value] ... : Set a simulator option." } , "[option] [option = value] ... : Set a simulator option." } ,
#ifdef EXPERIMENTAL_CODE
{ "savesnap", com_savesnap, FALSE, TRUE, { "savesnap", com_savesnap, FALSE, TRUE,
{ 1, 040000, 040000, 040000 }, E_DEFHMASK, 1, 1, { 1, 040000, 040000, 040000 }, E_DEFHMASK, 1, 1,
NULL, NULL,
@ -499,7 +520,7 @@ struct comm spcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3,
NULL, NULL,
"varname s1 s2 : Set $varname to strcmp(s1, s2)." } , "varname s1 s2 : Set $varname to strcmp(s1, s2)." } ,
{ "linearize", com_linearize, TRUE, FALSE,
{ "linearize", com_linearize, FALSE, FALSE,
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS,
NULL, NULL,
" [ vec ... ] : Convert plot into one with linear scale." } , " [ vec ... ] : Convert plot into one with linear scale." } ,
@ -509,7 +530,7 @@ struct comm spcp_coms[] = {
}; };
/* Bool fields: stringargs, spiceonly, major */
/* Bool fields: spiceonly, major */
struct comm nutcp_coms[] = { struct comm nutcp_coms[] = {
{ "let", com_let, FALSE, TRUE, { "let", com_let, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS,
@ -664,10 +685,18 @@ struct comm nutcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0,
NULL, NULL,
": Print a dump of the current circuit." } , ": Print a dump of the current circuit." } ,
{ "fft", com_fft, FALSE, TRUE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 1, LOTS,
NULL,
"vector ... : Create a frequency domain plot with FFT." } ,
{ "fourier", com_fourier, FALSE, TRUE, { "fourier", com_fourier, FALSE, TRUE,
{ 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS,
NULL, NULL,
"fund_freq vector ... : Do a fourier analysis of some data." } , "fund_freq vector ... : Do a fourier analysis of some data." } ,
{ "spec", com_spec, FALSE, TRUE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 4, LOTS,
NULL,
"start_freq stop_freq step_freq vector ... : Create a frequency domain plot." } ,
{ "show", NULL, TRUE, FALSE, { "show", NULL, TRUE, FALSE,
{ 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS,
NULL, NULL,
@ -857,7 +886,7 @@ struct comm nutcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3,
NULL, NULL,
"varname s1 s2 : Set $varname to strcmp(s1, s2)." } , "varname s1 s2 : Set $varname to strcmp(s1, s2)." } ,
{ "linearize", NULL, TRUE, FALSE,
{ "linearize", NULL, FALSE, FALSE,
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS,
NULL, NULL,
" [ vec ... ] : Convert plot into one with linear scale." } , " [ vec ... ] : Convert plot into one with linear scale." } ,

50
src/frontend/inp.c

@ -49,6 +49,7 @@ $Id$
/* static declarations */ /* static declarations */
static char * upper(register char *string); static char * upper(register char *string);
static bool doedit(char *filename); static bool doedit(char *filename);
static struct line *com_options = NULL;
void line_free_x(struct line * deck, bool recurse); void line_free_x(struct line * deck, bool recurse);
@ -371,7 +372,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
* many problems with matching the first word on the line. */ * many problems with matching the first word on the line. */
ld = deck; ld = deck;
if (comfile) { if (comfile) {
/* This is easy. */
/* Process each command, except 'option' which is assembled
in a list and ingnored here */
for (dd = deck; dd; dd = ld) { for (dd = deck; dd; dd = ld) {
ld = dd->li_next; ld = dd->li_next;
if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#')) if ((dd->li_line[0] == '*') && (dd->li_line[1] != '#'))
@ -379,6 +381,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
if (!ciprefix(".control", dd->li_line) && !ciprefix(".endc", dd->li_line)) { if (!ciprefix(".control", dd->li_line) && !ciprefix(".endc", dd->li_line)) {
if (dd->li_line[0] == '*') if (dd->li_line[0] == '*')
cp_evloop(dd->li_line + 2); cp_evloop(dd->li_line + 2);
/* option line stored but not processed */
else if (ciprefix("option", dd->li_line))
{
com_options = inp_getoptsc(dd->li_line, com_options);
}
else else
cp_evloop(dd->li_line); cp_evloop(dd->li_line);
} }
@ -548,6 +555,26 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
(void) fclose(fdo); (void) fclose(fdo);
} }
/*merge the two option line structs*/
if (!options && com_options)
options = com_options;
else if (options && com_options) {
/* move to end of options
struct line* tmp_options = options;
while (tmp_options) {
if (!tmp_options->li_next) break;
tmp_options = tmp_options->li_next;
}
tmp_options->li_next = com_options;*/
/* move to end of com_options */
struct line* tmp_options = com_options;
while (tmp_options) {
if (!tmp_options->li_next) break;
tmp_options = tmp_options->li_next;
}
tmp_options->li_next = options;
}
/* now load deck into ft_curckt -- the current circuit. */ /* now load deck into ft_curckt -- the current circuit. */
inp_dodeck(deck, tt, wl_first, FALSE, options, filename); inp_dodeck(deck, tt, wl_first, FALSE, options, filename);
@ -702,6 +729,7 @@ inp_dodeck(
is needed because we need the scale info BEFORE building the circuit is needed because we need the scale info BEFORE building the circuit
and seems there is no other way to do this. */ and seems there is no other way to do this. */
if (!noparse) { if (!noparse) {
struct line* opt_beg = options;
for (; options; options = options->li_next) { for (; options; options = options->li_next) {
for (s = options->li_line; *s && !isspace(*s); s++) for (s = options->li_line; *s && !isspace(*s); s++)
; ;
@ -723,19 +751,20 @@ inp_dodeck(
for (eev = ct->ci_vars; eev; eev = eev->va_next) { for (eev = ct->ci_vars; eev; eev = eev->va_next) {
switch (eev->va_type) { switch (eev->va_type) {
case VT_BOOL: case VT_BOOL:
break;
break;
case VT_NUM: case VT_NUM:
break;
break;
case VT_REAL: case VT_REAL:
if ( strcmp("scale",eev->va_name)==0 ){ if ( strcmp("scale",eev->va_name)==0 ){
cp_vset("scale", VT_REAL, (char*) &eev->va_real ); cp_vset("scale", VT_REAL, (char*) &eev->va_real );
printf("Scale set\n"); printf("Scale set\n");
} }
break;
break;
case VT_STRING: case VT_STRING:
break;
} /* switch . . . */
break;
} /* switch . . . */
} }
options = opt_beg; // back to the beginning
} /* if (!noparse) . . . */ } /* if (!noparse) . . . */
/*---------------------------------------------------- /*----------------------------------------------------
@ -751,7 +780,7 @@ inp_dodeck(
out_init(); out_init();
/*---------------------------------------------------- /*----------------------------------------------------
* Now run throuh the deck and look to see if there are
* Now run through the deck and look to see if there are
* errors on any line. * errors on any line.
*---------------------------------------------------*/ *---------------------------------------------------*/
for (dd = deck; dd; dd = dd->li_next) { for (dd = deck; dd; dd = dd->li_next) {
@ -838,7 +867,7 @@ inp_dodeck(
ct->ci_filename = NULL; ct->ci_filename = NULL;
if (!noparse) { if (!noparse) {
for (; options; options = options->li_next) {
/* for (; options; options = options->li_next) {
for (s = options->li_line; *s && !isspace(*s); s++) for (s = options->li_line; *s && !isspace(*s); s++)
; ;
@ -855,6 +884,7 @@ inp_dodeck(
while (eev->va_next) while (eev->va_next)
eev = eev->va_next; eev = eev->va_next;
} }
*/
for (eev = ct->ci_vars; eev; eev = eev->va_next) { for (eev = ct->ci_vars; eev; eev = eev->va_next) {
one = 1; one = 1;
switch (eev->va_type) { switch (eev->va_type) {
@ -874,9 +904,9 @@ inp_dodeck(
if_option(ct->ci_ckt, eev->va_name, if_option(ct->ci_ckt, eev->va_name,
eev->va_type, eev->va_string); eev->va_type, eev->va_string);
break; break;
} /* switch . . . */
} // switch . . .
} }
} /* if (!noparse) . . . */
} // if (!noparse) . . .
/* add title of deck to data base */ /* add title of deck to data base */
cp_addkword(CT_CKTNAMES, tt); cp_addkword(CT_CKTNAMES, tt);

26
src/frontend/options.c

@ -206,6 +206,32 @@ inp_getopts(struct line *deck)
return (opts); return (opts);
} }
/* Extract the option lines from a comfile (spinit, .spiceinit) */
struct line *
inp_getoptsc(char *in_line, struct line *com_options)
{
struct line *next = NULL;
char* line;
line = (char*)tmalloc(strlen(in_line) + 3);
/* option -> .options */
/* skip option */
gettok(&in_line);
sprintf(line, ".options %s", in_line);
next = (struct line*)tmalloc(sizeof(struct line));
next->li_line = line;
next->li_linenum = 0;
next->li_error = NULL;
next->li_actual = NULL;
/* put new line in front */
if (com_options != NULL)
next->li_next = com_options;
return next;
}
static void setdb(char *str); static void setdb(char *str);
/* The one variable that we consider read-only so far is plots. The ones /* The one variable that we consider read-only so far is plots. The ones

3
src/include/fteext.h

@ -337,6 +337,7 @@ extern bool ft_controldb;
extern bool ft_asyncdb; extern bool ft_asyncdb;
extern char *ft_setkwords[]; extern char *ft_setkwords[];
extern struct line *inp_getopts(struct line *deck); extern struct line *inp_getopts(struct line *deck);
extern struct line *inp_getoptsc(char *in_line, struct line *com_options);
extern struct variable *cp_enqvar(char *word); extern struct variable *cp_enqvar(char *word);
extern bool ft_ngdebug; extern bool ft_ngdebug;
@ -375,7 +376,7 @@ extern void raw_write(char *name, struct plot *pl, bool app, bool binary);
extern struct plot *raw_read(char *name); extern struct plot *raw_read(char *name);
/* meas.c */ /* meas.c */
extern void do_measure(char *what, bool chk_only);
extern bool do_measure(char *what, bool chk_only);
extern bool check_autostop(char *what); extern bool check_autostop(char *what);
extern void com_meas(wordlist *wl); extern void com_meas(wordlist *wl);

Loading…
Cancel
Save