From 27d93293f9577c1d16d31be8c0aecf194b173271 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 11 Mar 2017 20:00:04 +0100 Subject: [PATCH] inp2q.c, #5/23, rewrite using a new function model_numnodes() --- src/spicelib/parser/inp2q.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/spicelib/parser/inp2q.c b/src/spicelib/parser/inp2q.c index 3cb9df73b..8620f7331 100644 --- a/src/spicelib/parser/inp2q.c +++ b/src/spicelib/parser/inp2q.c @@ -11,6 +11,23 @@ Modified: 2001 Paolo Nenzi (Cider Integration) #include "ngspice/fteext.h" #include "inpxx.h" + +static int +model_numnodes(int type) +{ +#ifdef ADMS + if (type == INPtypelook("hicum0") || + type == INPtypelook("hicum2") || + type == INPtypelook("bjt504t")) + return 5; +#else + NG_IGNORE(type); +#endif + + return 4; +} + + void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode) { @@ -88,10 +105,7 @@ void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode) fprintf(stderr, "%s\nPlease check model, level or number of terminals!\n", current->error); controlled_exit(EXIT_BAD); } - if (thismodel->INPmodType == INPtypelook("hicum0") || - thismodel->INPmodType == INPtypelook("hicum2") || - thismodel->INPmodType == INPtypelook("bjt504t")) - { + if (5 == model_numnodes(thismodel->INPmodType)) { node5 = gnode; /* 4-terminal adms device - thermal node to ground */ nname5 = copy("0"); INPtermInsert(ckt, &nname5, tab, &node5); @@ -132,16 +146,11 @@ void INP2Q(CKTcircuit *ckt, INPtables * tab, card * current, CKTnode *gnode) LITERR("incorrect model type"); return; } -#ifdef ADMS - if (nodeflag > 4 && - !(thismodel->INPmodType == INPtypelook("hicum0") || - thismodel->INPmodType == INPtypelook("hicum2") || - thismodel->INPmodType == INPtypelook("bjt504t"))) + if (nodeflag > 4 && 4 == model_numnodes(thismodel->INPmodType)) { LITERR("Too much nodes for this model type"); return; } -#endif type = thismodel->INPmodType; mdfast = thismodel->INPmodfast; } else {