From 9f66aca9d4be71efe7cd7c92b36f19c89b9fa0df Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 5 Nov 2016 15:41:06 +0100 Subject: [PATCH] tail, better in CKTcircuit, oh no, needs to access symboltab --- src/frontend/inp.c | 43 ++++++++++++++++---------------- src/include/ngspice/cktdefs.h | 3 ++- src/spicelib/analysis/cktdojob.c | 3 ++- src/spicelib/analysis/dctrcurv.c | 9 ++++--- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 40e240927..889524e5c 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -56,7 +56,7 @@ static struct line *mc_deck = NULL; static void cktislinear(CKTcircuit *ckt, struct line *deck); static void dotifeval(struct line *deck); static int inp_parse_temper(struct line *deck); -static void inp_parse_temper_trees(void); +static void inp_parse_temper_trees(struct circ *ckt); static wordlist *inp_savecurrents(struct line *deck, struct line *options, wordlist *wl, wordlist *controls); @@ -67,6 +67,13 @@ void create_circbyline(char *line); extern bool ft_batchmode; +/* List of all expressions found in .model lines */ +static struct pt_temper *modtlist = NULL; + +/* List of all expressions found in device instance lines */ +static struct pt_temper *devtlist = NULL; + + /* * create an unique artificial *unusable* FILE ptr * meant to be used with Xprintf() only to eventually @@ -820,10 +827,12 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) fclose(fdo); } + ft_curckt->devtlist = devtlist; + ft_curckt->modtlist = modtlist; /* Now the circuit is defined, so generate the parse trees */ - inp_parse_temper_trees(); + inp_parse_temper_trees(ft_curckt); /* Get the actual data for model and device instance parameters */ - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); /* linked list dbs is used to store the "save" or .save data (defined in breakp2.c), (When controls are executed later on, also stores TRACE, IPLOT, and STOP data) */ @@ -1643,12 +1652,6 @@ dotifeval(struct line *deck) } -/* List of all expressions found in .model lines */ -static struct pt_temper *modtlist = NULL; - -/* List of all expressions found in device instance lines */ -static struct pt_temper *devtlist = NULL; - /* Evaluate expressions containing 'temper' keyword, found in .model lines or device instance lines. @@ -1812,21 +1815,19 @@ inp_parse_temper(struct line *card) static void -inp_parse_temper_trees(void) +inp_parse_temper_trees(struct circ *circ) { struct pt_temper *d; - for(d = devtlist; d; d = d->next) { + for(d = circ->devtlist; d; d = d->next) { char *expression = d->expression; - INPgetTree(&expression, &d->pt, ft_curckt->ci_ckt, NULL); + INPgetTree(&expression, &d->pt, circ->ci_ckt, NULL); } - ft_curckt->devtlist = devtlist; - for(d = modtlist; d; d = d->next) { + for(d = circ->modtlist; d; d = d->next) { char *expression = d->expression; - INPgetTree(&expression, &d->pt, ft_curckt->ci_ckt, NULL); + INPgetTree(&expression, &d->pt, circ->ci_ckt, NULL); } - ft_curckt->modtlist = modtlist; } /* set modtlist and devtlist. Called from com_scirc(), when another circuit is selected */ @@ -1864,12 +1865,12 @@ rem_tlist(struct circ *circ) } void -inp_evaluate_temper(void) +inp_evaluate_temper(struct circ *circ) { struct pt_temper *d; double result; - for(d = devtlist; d; d = d->next) { + for(d = circ->devtlist; d; d = d->next) { IFeval((IFparseTree *) d->pt, 1e-12, &result, NULL, NULL); if (d->wlend->wl_word) tfree(d->wlend->wl_word); @@ -1877,12 +1878,12 @@ inp_evaluate_temper(void) com_alter(d->wl); } - for(d = modtlist; d; d = d->next) { + for(d = circ->modtlist; d; d = d->next) { char *name = d->wl->wl_word; - INPretrieve(&name, ft_curckt->ci_symtab); + INPretrieve(&name, circ->ci_symtab); /* only evaluate models which have been entered into the hash table ckt->MODnameHash */ - if (ft_sim->findModel (ft_curckt->ci_ckt, name) == NULL) + if (ft_sim->findModel (circ->ci_ckt, name) == NULL) continue; IFeval((IFparseTree *) d->pt, 1e-12, &result, NULL, NULL); if (d->wlend->wl_word) diff --git a/src/include/ngspice/cktdefs.h b/src/include/ngspice/cktdefs.h index 7dd736618..90d2aed4a 100644 --- a/src/include/ngspice/cktdefs.h +++ b/src/include/ngspice/cktdefs.h @@ -448,6 +448,7 @@ extern int NIpred(CKTcircuit *ckt); extern IFfrontEnd *SPfrontEnd; extern bool expr_w_temper; -extern void inp_evaluate_temper(void); +struct circ; +extern void inp_evaluate_temper(struct circ *ckt); #endif diff --git a/src/spicelib/analysis/cktdojob.c b/src/spicelib/analysis/cktdojob.c index 145162495..2d1f8ba52 100644 --- a/src/spicelib/analysis/cktdojob.c +++ b/src/spicelib/analysis/cktdojob.c @@ -9,6 +9,7 @@ Modified: 2000 AlansFixes #include "ngspice/sperror.h" #include "ngspice/trandefs.h" #include "ngspice/cpextern.h" +#include "ngspice/fteext.h" #include "analysis.h" @@ -114,7 +115,7 @@ CKTdoJob(CKTcircuit *ckt, int reset, TSKtask *task) /* call altermod and alter on device and model parameters assembled in devtlist and modtlist (if using temper) because we have a new temperature */ - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); error = 0; diff --git a/src/spicelib/analysis/dctrcurv.c b/src/spicelib/analysis/dctrcurv.c index 98a0a5e41..a292360f5 100644 --- a/src/spicelib/analysis/dctrcurv.c +++ b/src/spicelib/analysis/dctrcurv.c @@ -13,6 +13,7 @@ Modified: 1999 Paolo Nenzi #include "ngspice/cktdefs.h" #include "ngspice/const.h" #include "ngspice/sperror.h" +#include "ngspice/fteext.h" #ifdef XSPICE #include "ngspice/evt.h" @@ -143,7 +144,7 @@ DCtrCurv(CKTcircuit *ckt, int restart) job->TRCVvSave[i] = ckt->CKTtemp; /* Saves the old circuit temperature */ job->TRCVvType[i] = TEMP_CODE; /* Set the sweep type code */ ckt->CKTtemp = job->TRCVvStart[i] + CONSTCtoK; /* Set the new circuit temp */ - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); CKTtemp(ckt); goto found; } @@ -275,7 +276,7 @@ DCtrCurv(CKTcircuit *ckt, int restart) job->TRCVvStart[i]; } else if (job->TRCVvType[i] == TEMP_CODE) { ckt->CKTtemp = job->TRCVvStart[i] + CONSTCtoK; - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); CKTtemp(ckt); } else if (job->TRCVvType[i] == rcode) { ((RESinstance *)(job->TRCVvElt[i]))->RESresist = @@ -468,7 +469,7 @@ DCtrCurv(CKTcircuit *ckt, int restart) DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt); } else if (job->TRCVvType[i] == TEMP_CODE) { /* temperature */ ckt->CKTtemp += job->TRCVvStep[i]; - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); CKTtemp(ckt); } @@ -505,7 +506,7 @@ DCtrCurv(CKTcircuit *ckt, int restart) DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt); } else if (job->TRCVvType[i] == TEMP_CODE) { ckt->CKTtemp = job->TRCVvSave[i]; - inp_evaluate_temper(); + inp_evaluate_temper(ft_curckt); CKTtemp(ckt); }