From 2e9a51f2f76a9e134b401ffd57c0f131e26fb82d Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 28 Dec 2020 16:29:21 +0100 Subject: [PATCH] Each model is checked only once (not the same model check for every instance). Add model comparison warning to file. --- src/spicelib/devices/bsim4/b4check.c | 30 ++++++++++++++------ src/spicelib/devices/bsim4v5/b4v5check.c | 35 ++++++++++++++++++------ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/spicelib/devices/bsim4/b4check.c b/src/spicelib/devices/bsim4/b4check.c index 6ae37084a..a01bce5a8 100644 --- a/src/spicelib/devices/bsim4/b4check.c +++ b/src/spicelib/devices/bsim4/b4check.c @@ -87,15 +87,34 @@ CKTcircuit *ckt) FILE *fplog; wordlist* wl, *wlstart; - pParam = here->pParam; - if (cp_getvar("ng_nomodcheck", CP_BOOL, NULL, 0)) return(0); + static char modname[BSIZE_SP]; + size_t mlen = strlen(model->BSIM4modName); + + if (mlen < BSIZE_SP) { + /* Check the model named model->BSIM4modName only once, + because BSIM4checkModel() is called for each instance. */ + if (!strncmp(modname, model->BSIM4modName, mlen)) + return(0); + strcpy(modname, model->BSIM4modName); + } + + pParam = here->pParam; + wl = wlstart = TMALLOC(wordlist, 1); wl->wl_prev = NULL; wl->wl_next = NULL; - wl->wl_word = tprintf("\nChecking parameters for BSIM 4.7 model %s\n", model->BSIM4modName); + wl->wl_word = tprintf("\nChecking parameters for BSIM 4.8 model %s\n", model->BSIM4modName); + + if ((strcmp(model->BSIM4version, "4.8.1")) && (strncmp(model->BSIM4version, "4.81", 4)) && (strncmp(model->BSIM4version, "4.8", 3))) + { + printf("Warning: This model supports BSIM4 version 4.8\n"); + printf("You specified a wrong version number. Working now with BSIM4.8.1\n"); + wl_append_word(&wl, &wl, tprintf("Warning: This model supports BSIM4 version 4.8\n")); + wl_append_word(&wl, &wl, tprintf("You specified a wrong version number. Working now with BSIM4.8.1.\n")); + } if ((here->BSIM4rgateMod == 2) || (here->BSIM4rgateMod == 3)) { if ((here->BSIM4trnqsMod == 1) || (here->BSIM4acnqsMod == 1)) { @@ -928,11 +947,6 @@ CKTcircuit *ckt) wl_free(wlstart); - if ((strcmp(model->BSIM4version, "4.8.1")) && (strncmp(model->BSIM4version, "4.81", 4)) && (strncmp(model->BSIM4version, "4.8", 3))) - { - printf("Warning: This model is BSIM4.8.1; you specified a wrong version number '%s'.\n", model->BSIM4version); - } - return(Fatal_Flag); } diff --git a/src/spicelib/devices/bsim4v5/b4v5check.c b/src/spicelib/devices/bsim4v5/b4v5check.c index 65ae3d5ac..a4ac8dbc2 100644 --- a/src/spicelib/devices/bsim4v5/b4v5check.c +++ b/src/spicelib/devices/bsim4v5/b4v5check.c @@ -26,8 +26,6 @@ #include "ngspice/wordlist.h" #include "ngspice/cpextern.h" - - /* Check for correctness of the BSIM4.5 parameters: If parameter excursions are found, put the warning or error message into a wordlist. Only then open a file bsim4v5.out and print the data into the file. */ @@ -42,16 +40,40 @@ CKTcircuit *ckt) FILE *fplog; wordlist* wl, *wlstart; - pParam = here->pParam; - if (cp_getvar("ng_nomodcheck", CP_BOOL, NULL, 0)) return(0); + static char modname[BSIZE_SP]; + size_t mlen = strlen(model->BSIM4v5modName); + + if (mlen < BSIZE_SP) { + /* Check the model named model->BSIM4v5modName only once, + because BSIM4v5checkModel() is called for each instance. */ + if (!strncmp(modname, model->BSIM4v5modName, mlen)) + return(0); + strcpy(modname, model->BSIM4v5modName); + } + + pParam = here->pParam; + wl = wlstart = TMALLOC(wordlist, 1); wl->wl_prev = NULL; wl->wl_next = NULL; wl->wl_word = tprintf("\nChecking parameters for BSIM 4.5 model %s\n", model->BSIM4v5modName); + if ((strcmp(model->BSIM4v5version, "4.5.0")) && (strncmp(model->BSIM4v5version, "4.50", 4)) && (strncmp(model->BSIM4v5version, "4.5", 3)) + && (strcmp(model->BSIM4v5version, "4.4.0")) && (strncmp(model->BSIM4v5version, "4.40", 4)) && (strncmp(model->BSIM4v5version, "4.4", 3)) + && (strcmp(model->BSIM4v5version, "4.3.0")) && (strncmp(model->BSIM4v5version, "4.30", 4)) && (strncmp(model->BSIM4v5version, "4.3", 3)) + && (strcmp(model->BSIM4v5version, "4.2.0")) && (strncmp(model->BSIM4v5version, "4.20", 4)) && (strncmp(model->BSIM4v5version, "4.2", 3)) + && (strcmp(model->BSIM4v5version, "4.1.0")) && (strncmp(model->BSIM4v5version, "4.10", 4)) && (strncmp(model->BSIM4v5version, "4.1", 3)) + && (strcmp(model->BSIM4v5version, "4.0.0")) && (strncmp(model->BSIM4v5version, "4.00", 4)) && (strncmp(model->BSIM4v5version, "4.0", 3))) + { + printf("Warning: This model supports BSIM4 versions 4.0, 4.1, 4.2, 4.3, 4.4, 4.5\n"); + printf("You specified a wrong version number. Working now with BSIM4v5\n"); + wl_append_word(&wl, &wl, tprintf("Warning: This model supports BSIM4 versions 4.0, 4.1, 4.2, 4.3, 4.4, 4.5\n")); + wl_append_word(&wl, &wl, tprintf("You specified a wrong version number. Working now with BSIM4v5.\n")); + } + if ((here->BSIM4v5rgateMod == 2) || (here->BSIM4v5rgateMod == 3)) { if ((here->BSIM4v5trnqsMod == 1) || (here->BSIM4v5acnqsMod == 1)) { wl_append_word(&wl, &wl, tprintf("Warning: You've selected both Rg and charge deficit NQS; select one only.\n")); @@ -768,11 +790,6 @@ CKTcircuit *ckt) wl_free(wlstart); - if ((strcmp(model->BSIM4v5version, "4.5.0")) && (strncmp(model->BSIM4v5version, "4.50", 4)) && (strncmp(model->BSIM4v5version, "4.5", 3))) - { - printf("Warning: This model is BSIM4.5.0; you specified a wrong version number '%s'.\n", model->BSIM4v5version); - } - return(Fatal_Flag); }