diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index e548c2bd4..f532a3f63 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -449,6 +449,7 @@ struct card *insert_new_line( x->linenum_orig = linenum_orig; x->level = card ? card->level : NULL; x->linesource = lineinfo; + x->compmod = 0; if (card) card->nextcard = x; @@ -950,7 +951,7 @@ void inp_get_w_l_x(struct card* card) { continue; } /* only subcircuit invocations */ - if (*curr_line != 'x' || (!newcompat.hs && !newcompat.spe)) { + if (*curr_line != 'x' || (!newcompat.hs && !newcompat.spe) || card->compmod > 0) { continue; } @@ -1430,6 +1431,47 @@ static struct inp_read_t inp_read(FILE* fp, int call_depth, const char* dir_name struct card* newcard; + struct compat tmpcomp; + bool compset = FALSE; + + /* special treatment of special .inc commands */ + if (ciprefix(".incpslt", buffer)) { + compset = TRUE; + /* save the current compatibility status */ + tmpcomp.isset = newcompat.isset; /* at least one mode is set */ + tmpcomp.hs = newcompat.hs; /* HSPICE */ + tmpcomp.s3 = newcompat.s3; /* spice3 */ + tmpcomp.ll = newcompat.ll; /* all */ + tmpcomp.ps = newcompat.ps; /* PSPICE */ + tmpcomp.lt = newcompat.lt; /* LTSPICE */ + tmpcomp.ki = newcompat.ki; /* KiCad */ + tmpcomp.a = newcompat.a; /* whole netlist */ + tmpcomp.spe = newcompat.spe; /* spectre */ + tmpcomp.eg = newcompat.eg; /* EAGLE */ + tmpcomp.mc = newcompat.mc; /* to be set for 'make check' */ + tmpcomp.xs = newcompat.xs; /* XSPICE */ + /* save the new comptmode */ + newcompat.isset = TRUE; /* at least one mode is set */ + if (ciprefix(".incpslt", buffer)) { + newcompat.hs = FALSE; + newcompat.ps = TRUE; + newcompat.lt = TRUE; + } + else { + newcompat.hs = TRUE; + newcompat.ps = FALSE; + newcompat.lt = FALSE; + } + newcompat.s3 = FALSE; + newcompat.ll = FALSE; + newcompat.ki = FALSE; + newcompat.a = FALSE; + newcompat.spe = FALSE; + newcompat.eg = FALSE; + newcompat.mc = FALSE; + newcompat.xs = FALSE; + } + inp_stripcomments_line(buffer, FALSE, TRUE); s = skip_non_ws(buffer); /* advance past non-space chars */ @@ -1507,10 +1549,15 @@ static struct inp_read_t inp_read(FILE* fp, int call_depth, const char* dir_name char* tmpstr = copy(nexttok(buffer)); wl_append_word(&sourceinfo, &sourceinfo, tmpstr); - /* Add source of netlist data, for use in verbose error messages */ + /* Add source of netlist data, for use in verbose error messages. + Set the compatibility mode flag to 1, if pslt is read. */ for (tmpcard = newcard; tmpcard; tmpcard = tmpcard->nextcard) { /* skip *include */ tmpcard->linesource = tmpstr; + if (compset) + tmpcard->compmod = 1; + else + tmpcard->compmod = 0; } if (newcard) { @@ -1533,6 +1580,23 @@ static struct inp_read_t inp_read(FILE* fp, int call_depth, const char* dir_name /* Fix the buffer up a bit. */ (void)memcpy(buffer + 1, "end of: ", 8); + + if (compset) { + /* restore the previous compatibility status */ + newcompat.isset = tmpcomp.isset; /* at least one mode is set */ + newcompat.hs = tmpcomp.hs; /* HSPICE */ + newcompat.s3 = tmpcomp.s3; /* spice3 */ + newcompat.ll = tmpcomp.ll; /* all */ + newcompat.ps = tmpcomp.ps; /* PSPICE */ + newcompat.lt = tmpcomp.lt; /* LTSPICE */ + newcompat.ki = tmpcomp.ki; /* KiCad */ + newcompat.a = tmpcomp.a; /* whole netlist */ + newcompat.spe = tmpcomp.spe; /* spectre */ + newcompat.eg = tmpcomp.eg; /* EAGLE */ + newcompat.mc = tmpcomp.mc; /* to be set for 'make check' */ + newcompat.xs = tmpcomp.xs; /* XSPICE */ + } + } /* end of .include handling */ /* loop through 'buffer' until end is reached. Make all letters lower @@ -3704,7 +3768,7 @@ static void inp_fix_for_numparam( inp_change_quotes(c->line); - if (!newcompat.hs && !newcompat.s3) + if ((!newcompat.hs && !newcompat.s3) || c->compmod > 0) if (ciprefix(".subckt", c->line) || ciprefix("x", c->line)) { /* remove params: */ char *str_ptr = strstr(c->line, "params:"); @@ -4038,7 +4102,7 @@ static int inp_fix_subckt_multiplier(struct names *subckt_w_params, /* no 'm' for model cards */ if (ciprefix(".model", curr_line)) continue; - if (newcompat.hs) { + if (newcompat.hs && card->compmod == 0) { /* if there is already an m=xx in the instance line, multiply it with the new m */ char* mult = strstr(curr_line, " m="); if (mult) { diff --git a/src/frontend/options.c b/src/frontend/options.c index 777f1c5a6..0b54881ba 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -256,6 +256,7 @@ inp_getoptsc(char *line, struct card *options) next->linenum = 0; next->error = NULL; next->actualLine = NULL; + next->compmod = 0; /* put new line in front */ next->nextcard = options; diff --git a/src/frontend/shyu.c b/src/frontend/shyu.c index c8436c64c..c59c63341 100644 --- a/src/frontend/shyu.c +++ b/src/frontend/shyu.c @@ -51,6 +51,7 @@ if_sens_run(CKTcircuit *ckt, wordlist *args, INPtables *tab) deck.error = NULL; deck.linenum = 0; deck.linenum_orig = 0; + deck.compmod = 0; deck.line = buf; current = &deck; diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 83d589d3a..c56c37609 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -248,6 +248,7 @@ if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab) deck.nextcard = deck.actualLine = NULL; deck.error = NULL; deck.linenum = 0; + deck.compmod = 0; deck.line = buf; /*CDHW Delete any previous special task CDHW*/ diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 218502222..4cb7be417 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -847,6 +847,7 @@ struct card * inp_deckcopy(struct card *deck) { } d->linenum = deck->linenum; d->linenum_orig = deck->linenum_orig; + d->compmod = deck->compmod; d->linesource = deck->linesource; d->w = deck->w; d->l = deck->l; @@ -897,6 +898,7 @@ struct card *inp_deckcopy_oc(struct card * deck) d->l = deck->l; d->nf = deck->nf; d->linenum_orig = deck->linenum_orig; + d->compmod = deck->compmod; d->linesource = deck->linesource; d->linenum = i++; d->line = copy(deck->line); @@ -957,6 +959,7 @@ struct card* inp_deckcopy_ln(struct card* deck) d->linenum_orig = deck->linenum_orig; d->linesource = deck->linesource; d->linenum = deck->linenum; + d->compmod = deck->compmod; d->line = copy(deck->line); if (deck->error) { d->error = copy(deck->error); diff --git a/src/include/ngspice/inpdefs.h b/src/include/ngspice/inpdefs.h index 36203bc11..d61bb5469 100644 --- a/src/include/ngspice/inpdefs.h +++ b/src/include/ngspice/inpdefs.h @@ -86,6 +86,7 @@ struct card { float w; float l; float nf; + int compmod; }; /* structure used to save models in after they are read during pass 1 */