From 82b0bc070f5e0c79defd8b935f6cf952a73743ff Mon Sep 17 00:00:00 2001 From: dwarning Date: Sat, 14 Mar 2015 00:29:55 +0100 Subject: [PATCH] sorting parameter for resistor setup and temperature update routines --- src/spicelib/devices/res/ressetup.c | 34 +++++++++++++++++++++++++++-- src/spicelib/devices/res/restemp.c | 32 --------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/spicelib/devices/res/ressetup.c b/src/spicelib/devices/res/ressetup.c index 0077f3750..25e9cc202 100644 --- a/src/spicelib/devices/res/ressetup.c +++ b/src/spicelib/devices/res/ressetup.c @@ -25,6 +25,18 @@ RESsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit*ckt, int *state) /* loop through all the resistor models */ for( ; model != NULL; model = model->RESnextModel ) { + /* Default Value Processing for Resistor Models */ + if(!model->REStnomGiven) model->REStnom = ckt->CKTnomTemp; + if(!model->RESsheetResGiven) model->RESsheetRes = 0.0; + if(!model->RESdefWidthGiven) model->RESdefWidth = 10e-6; /*M*/ + if(!model->RESdefLengthGiven) model->RESdefLength = 10e-6; + if(!model->REStc1Given) model->REStempCoeff1 = 0.0; + if(!model->REStc2Given) model->REStempCoeff2 = 0.0; + if(!model->RESnarrowGiven) model->RESnarrow = 0.0; + if(!model->RESshortGiven) model->RESshort = 0.0; + if(!model->RESfNcoefGiven) model->RESfNcoef = 0.0; + if(!model->RESfNexpGiven) model->RESfNexp = 1.0; + if(!model->RESbv_maxGiven) model->RESbv_max = 1e99; @@ -32,8 +44,26 @@ RESsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit*ckt, int *state) for (here = model->RESinstances; here != NULL ; here=here->RESnextInstance) { - if(!here->RESmGiven) - here->RESm = 1.0; + if(!here->RESwidthGiven) here->RESwidth = model->RESdefWidth; + if(!here->RESlengthGiven) here->RESlength = model->RESdefLength; + if(!here->RESscaleGiven) here->RESscale = 1.0; + if(!here->RESmGiven) here->RESm = 1.0; + if(!here->RESnoisyGiven) here->RESnoisy = 1; + if(!here->RESresGiven) { + if(here->RESlength * here->RESwidth * model->RESsheetRes > 0.0) { + here->RESresist = model->RESsheetRes * (here->RESlength - + model->RESshort) / (here->RESwidth - model->RESnarrow); + } else { + if(model->RESresGiven) { + here->RESresist = model->RESres; + } else { + SPfrontEnd->IFerrorf (ERR_WARNING, + "%s: resistance to low, set to 1 mOhm", here->RESname); + here->RESresist = 1e-03; + } + } + } + if(!here->RESbv_maxGiven) here->RESbv_max = model->RESbv_max; diff --git a/src/spicelib/devices/res/restemp.c b/src/spicelib/devices/res/restemp.c index 3f5cdb8ba..a0f8c925c 100644 --- a/src/spicelib/devices/res/restemp.c +++ b/src/spicelib/devices/res/restemp.c @@ -29,18 +29,6 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt) /* loop through all the resistor models */ for( ; model != NULL; model = model->RESnextModel ) { - /* Default Value Processing for Resistor Models */ - if(!model->REStnomGiven) model->REStnom = ckt->CKTnomTemp; - if(!model->RESsheetResGiven) model->RESsheetRes = 0.0; - if(!model->RESdefWidthGiven) model->RESdefWidth = 10e-6; /*M*/ - if(!model->RESdefLengthGiven) model->RESdefLength = 10e-6; - if(!model->REStc1Given) model->REStempCoeff1 = 0.0; - if(!model->REStc2Given) model->REStempCoeff2 = 0.0; - if(!model->RESnarrowGiven) model->RESnarrow = 0.0; - if(!model->RESshortGiven) model->RESshort = 0.0; - if(!model->RESfNcoefGiven) model->RESfNcoef = 0.0; - if(!model->RESfNexpGiven) model->RESfNexp = 1.0; - /* loop through all the instances of the model */ for (here = model->RESinstances; here != NULL ; here=here->RESnextInstance) { @@ -56,26 +44,6 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt) printf("%s: Instance temperature specified, dtemp ignored\n", here->RESname); } - if(!here->RESwidthGiven) here->RESwidth = model->RESdefWidth; - if(!here->RESlengthGiven) here->RESlength = model->RESdefLength; - if(!here->RESscaleGiven) here->RESscale = 1.0; - if(!here->RESmGiven) here->RESm = 1.0; - if(!here->RESnoisyGiven) here->RESnoisy = 1; - if(!here->RESresGiven) { - if(here->RESlength * here->RESwidth * model->RESsheetRes > 0.0) { - here->RESresist = model->RESsheetRes * (here->RESlength - - model->RESshort) / (here->RESwidth - model->RESnarrow); - } else { - if(model->RESresGiven) { - here->RESresist = model->RESres; - } else { - SPfrontEnd->IFerrorf (ERR_WARNING, - "%s: resistance to low, set to 1 mOhm", here->RESname); - here->RESresist = 1e-03; - } - } - } - difference = (here->REStemp + here->RESdtemp) - model->REStnom; /* instance parameters tc1 and tc2 will override