From 6edd684020f0de0d637d759ef0df25fff2f9968d Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 7 Mar 2017 21:21:42 +0100 Subject: [PATCH] inp2m.c, #7/9c, rewrite valid_numnodes() using model_numnodes() --- src/spicelib/parser/inp2m.c | 48 +++++-------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/spicelib/parser/inp2m.c b/src/spicelib/parser/inp2m.c index 8a395d16b..df32cc8f4 100644 --- a/src/spicelib/parser/inp2m.c +++ b/src/spicelib/parser/inp2m.c @@ -38,48 +38,12 @@ model_numnodes(int type) static bool valid_numnodes(int numnodes, INPmodel *thismodel, card *current) { - bool valid; - - switch (numnodes) { - case 7: - valid = - thismodel->INPmodType == INPtypelook("B4SOI") || - thismodel->INPmodType == INPtypelook("B3SOIPD") || - thismodel->INPmodType == INPtypelook("B3SOIFD") || - thismodel->INPmodType == INPtypelook("B3SOIDD"); - if (!valid) - LITERR ("only level 55-58: B3SOI(PD|FD|DD) and B4SOI can have 7 nodes"); - return valid; - - case 6: - valid = - thismodel->INPmodType == INPtypelook("B4SOI") || - thismodel->INPmodType == INPtypelook("B3SOIPD") || - thismodel->INPmodType == INPtypelook("B3SOIFD") || - thismodel->INPmodType == INPtypelook("B3SOIDD") || - thismodel->INPmodType == INPtypelook("HiSIMHV1") || - thismodel->INPmodType == INPtypelook("HiSIMHV2") || - thismodel->INPmodType == INPtypelook("SOI3"); - if (!valid) - LITERR ("only level 55-58,61,62: B3SOI(PD|FD|DD), B4SOI, STAG (SOI3) and HiSIMHV can have 6 nodes"); - return valid; - - case 5: - valid = - thismodel->INPmodType == INPtypelook("B4SOI") || - thismodel->INPmodType == INPtypelook("B3SOIPD") || - thismodel->INPmodType == INPtypelook("B3SOIFD") || - thismodel->INPmodType == INPtypelook("B3SOIDD") || - thismodel->INPmodType == INPtypelook("HiSIMHV1") || - thismodel->INPmodType == INPtypelook("HiSIMHV2") || - thismodel->INPmodType == INPtypelook("SOI3"); - if (!valid) - LITERR ("only level 55-58,61,62: B3SOI(PD|FD|DD), B4SOI, STAG (SOI3) and HiSIMHV can have 5 nodes"); - return valid; - - default: - return TRUE; - } + bool valid = model_numnodes(thismodel->INPmodType) >= numnodes; + + if (!valid) + LITERR ("too much nodes connected to instance"); + + return valid; }