diff --git a/ChangeLog b/ChangeLog
index 0963ceb0f..ebfc2d502 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
+2003-12-31 Paolo Nenzi
+
+ * src/spicelib/devices/mes/*: Added parallel multiplier.
+
+ * tests/mes, tests/mes/subth.cir: added test netlist for mes devices.
+
2003-12-30 Paolo Nenzi
- * src/spicelibe/devices/hfet2/*: Added parallel multipler and "dtemp"
+ * src/spicelibe/devices/hfet2/*: Added parallel multiplier and "dtemp"
parameters. Added pole-zero analysis and parallel code switches.
* src/spicelib/devices/jfet/jfetpzld.c: gspr and gdpr were initialized
diff --git a/DEVICES b/DEVICES
index 29287717b..94a694f0f 100644
--- a/DEVICES
+++ b/DEVICES
@@ -241,7 +241,17 @@ HFET2 - HFET Level 2 (Ytterdal)
***************************************************************************
MES - MESfet model
- Initial release
+ Initial Release.
+ Ver: N/A
+ Class: Z
+ Level: 1
+ Status:
+
+
+ Enhancements over the original model:
+
+ - Parallel multiplier
+ - Alan Gillespie junction diodes implementation
MESA - MESA model
Initial release. TO BE TESTED
diff --git a/src/spicelib/devices/mes/mes.c b/src/spicelib/devices/mes/mes.c
index 45c4bed16..3ed97929c 100644
--- a/src/spicelib/devices/mes/mes.c
+++ b/src/spicelib/devices/mes/mes.c
@@ -4,7 +4,6 @@ Author: 1987 Thomas L. Quarles
**********/
#include "ngspice.h"
-#include
#include "ifsim.h"
#include "devdefs.h"
#include "mesdefs.h"
@@ -13,6 +12,7 @@ Author: 1987 Thomas L. Quarles
IFparm MESpTable[] = { /* parameters */
OPU("off", MES_OFF, IF_FLAG ,"Device initially off"),
IOPU("area", MES_AREA, IF_REAL ,"Area factor"),
+ IOPU("m", MES_AREA, IF_REAL ,"Parallel Multiplier"),
IOPAU("icvds", MES_IC_VDS, IF_REAL ,"Initial D-S voltage"),
IOPAU("icvgs", MES_IC_VGS, IF_REAL ,"Initial G-S voltage"),
OPU("dnode", MES_DRAINNODE, IF_INTEGER,"Number of drain node"),
diff --git a/src/spicelib/devices/mes/mesacl.c b/src/spicelib/devices/mes/mesacl.c
index 8cc25d8c9..3e08dcaca 100644
--- a/src/spicelib/devices/mes/mesacl.c
+++ b/src/spicelib/devices/mes/mesacl.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -14,9 +13,7 @@ Author: 1985 S. Hwang
int
-MESacLoad(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
+MESacLoad(GENmodel *inModel, CKTcircuit *ckt)
{
MESmodel *model = (MESmodel*)inModel;
MESinstance *here;
@@ -29,12 +26,16 @@ MESacLoad(inModel,ckt)
double ggd;
double xgd;
+ double m;
+
for( ; model != NULL; model = model->MESnextModel ) {
for( here = model->MESinstances; here != NULL;
here = here->MESnextInstance) {
if (here->MESowner != ARCHme) continue;
+ m = here->MESm;
+
gdpr=model->MESdrainConduct * here->MESarea;
gspr=model->MESsourceConduct * here->MESarea;
gm= *(ckt->CKTstate0 + here->MESgm) ;
@@ -43,28 +44,28 @@ MESacLoad(inModel,ckt)
xgs= *(ckt->CKTstate0 + here->MESqgs) * ckt->CKTomega ;
ggd= *(ckt->CKTstate0 + here->MESggd) ;
xgd= *(ckt->CKTstate0 + here->MESqgd) * ckt->CKTomega ;
- *(here->MESdrainDrainPtr ) += gdpr;
- *(here->MESgateGatePtr ) += ggd+ggs;
- *(here->MESgateGatePtr +1) += xgd+xgs;
- *(here->MESsourceSourcePtr ) += gspr;
- *(here->MESdrainPrimeDrainPrimePtr ) += gdpr+gds+ggd;
- *(here->MESdrainPrimeDrainPrimePtr +1) += xgd;
- *(here->MESsourcePrimeSourcePrimePtr ) += gspr+gds+gm+ggs;
- *(here->MESsourcePrimeSourcePrimePtr +1) += xgs;
- *(here->MESdrainDrainPrimePtr ) -= gdpr;
- *(here->MESgateDrainPrimePtr ) -= ggd;
- *(here->MESgateDrainPrimePtr +1) -= xgd;
- *(here->MESgateSourcePrimePtr ) -= ggs;
- *(here->MESgateSourcePrimePtr +1) -= xgs;
- *(here->MESsourceSourcePrimePtr ) -= gspr;
- *(here->MESdrainPrimeDrainPtr ) -= gdpr;
- *(here->MESdrainPrimeGatePtr ) += (-ggd+gm);
- *(here->MESdrainPrimeGatePtr +1) -= xgd;
- *(here->MESdrainPrimeSourcePrimePtr ) += (-gds-gm);
- *(here->MESsourcePrimeGatePtr ) += (-ggs-gm);
- *(here->MESsourcePrimeGatePtr +1) -= xgs;
- *(here->MESsourcePrimeSourcePtr ) -= gspr;
- *(here->MESsourcePrimeDrainPrimePtr ) -= gds;
+ *(here->MESdrainDrainPtr ) += m * (gdpr);
+ *(here->MESgateGatePtr ) += m * (ggd+ggs);
+ *(here->MESgateGatePtr +1) += m * (xgd+xgs);
+ *(here->MESsourceSourcePtr ) += m * (gspr);
+ *(here->MESdrainPrimeDrainPrimePtr ) += m * (gdpr+gds+ggd);
+ *(here->MESdrainPrimeDrainPrimePtr +1) += m * (xgd);
+ *(here->MESsourcePrimeSourcePrimePtr ) += m * (gspr+gds+gm+ggs);
+ *(here->MESsourcePrimeSourcePrimePtr +1) += m * (xgs);
+ *(here->MESdrainDrainPrimePtr ) -= m * (gdpr);
+ *(here->MESgateDrainPrimePtr ) -= m * (ggd);
+ *(here->MESgateDrainPrimePtr +1) -= m * (xgd);
+ *(here->MESgateSourcePrimePtr ) -= m * (ggs);
+ *(here->MESgateSourcePrimePtr +1) -= m * (xgs);
+ *(here->MESsourceSourcePrimePtr ) -= m * (gspr);
+ *(here->MESdrainPrimeDrainPtr ) -= m * (gdpr);
+ *(here->MESdrainPrimeGatePtr ) += m * (-ggd+gm);
+ *(here->MESdrainPrimeGatePtr +1) -= m * (xgd);
+ *(here->MESdrainPrimeSourcePrimePtr ) += m * (-gds-gm);
+ *(here->MESsourcePrimeGatePtr ) += m * (-ggs-gm);
+ *(here->MESsourcePrimeGatePtr +1) -= m * (xgs);
+ *(here->MESsourcePrimeSourcePtr ) -= m * (gspr);
+ *(here->MESsourcePrimeDrainPrimePtr ) -= m * (gds);
}
}
diff --git a/src/spicelib/devices/mes/mesask.c b/src/spicelib/devices/mes/mesask.c
index 7db5a5ad0..678ca082d 100644
--- a/src/spicelib/devices/mes/mesask.c
+++ b/src/spicelib/devices/mes/mesask.c
@@ -6,7 +6,6 @@ Author: 1987 Thomas L. Quarles
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "devdefs.h"
#include "ifsim.h"
@@ -17,18 +16,14 @@ Author: 1987 Thomas L. Quarles
/* ARGSUSED */
int
-MESask(ckt,inst,which,value,select)
- CKTcircuit *ckt;
- GENinstance *inst;
- int which;
- IFvalue *value;
- IFvalue *select;
+MESask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
{
MESinstance *here = (MESinstance*)inst;
static char *msg = "Current and power not available in ac analysis";
switch(which) {
case MES_AREA:
value->rValue = here->MESarea;
+ value->rValue *= here->MESm;
return (OK);
case MES_IC_VDS:
value->rValue = here->MESicVDS;
@@ -59,36 +54,47 @@ MESask(ckt,inst,which,value,select)
return (OK);
case MES_CG:
value->rValue = *(ckt->CKTstate0 + here->MEScg);
+ value->rValue *= here->MESm;
return (OK);
case MES_CD:
value->rValue = *(ckt->CKTstate0 + here->MEScd);
+ value->rValue *= here->MESm;
return (OK);
case MES_CGD:
value->rValue = *(ckt->CKTstate0 + here->MEScgd);
+ value->rValue *= here->MESm;
return (OK);
case MES_GM:
value->rValue = *(ckt->CKTstate0 + here->MESgm);
+ value->rValue *= here->MESm;
return (OK);
case MES_GDS:
value->rValue = *(ckt->CKTstate0 + here->MESgds);
+ value->rValue *= here->MESm;
return (OK);
case MES_GGS:
value->rValue = *(ckt->CKTstate0 + here->MESggs);
+ value->rValue *= here->MESm;
return (OK);
case MES_GGD:
value->rValue = *(ckt->CKTstate0 + here->MESggd);
+ value->rValue *= here->MESm;
return (OK);
case MES_QGS:
value->rValue = *(ckt->CKTstate0 + here->MESqgs);
+ value->rValue *= here->MESm;
return (OK);
case MES_CQGS:
value->rValue = *(ckt->CKTstate0 + here->MEScqgs);
+ value->rValue *= here->MESm;
return (OK);
case MES_QGD:
value->rValue = *(ckt->CKTstate0 + here->MESqgd);
+ value->rValue *= here->MESm;
return (OK);
case MES_CQGD:
value->rValue = *(ckt->CKTstate0 + here->MEScqgd);
+ value->rValue *= here->MESm;
return (OK);
case MES_CS :
if (ckt->CKTcurrentAnalysis & DOING_AC) {
@@ -99,6 +105,7 @@ MESask(ckt,inst,which,value,select)
} else {
value->rValue = -*(ckt->CKTstate0 + here->MEScd);
value->rValue -= *(ckt->CKTstate0 + here->MEScg);
+ value->rValue *= here->MESm;
}
return(OK);
case MES_POWER :
@@ -115,6 +122,7 @@ MESask(ckt,inst,which,value,select)
value->rValue -= (*(ckt->CKTstate0+here->MEScd) +
*(ckt->CKTstate0 + here->MEScg)) *
*(ckt->CKTrhsOld + here->MESsourceNode);
+ value->rValue *= here->MESm;
}
return(OK);
default:
diff --git a/src/spicelib/devices/mes/mesdefs.h b/src/spicelib/devices/mes/mesdefs.h
index 1133fc6fe..03ef899e8 100644
--- a/src/spicelib/devices/mes/mesdefs.h
+++ b/src/spicelib/devices/mes/mesdefs.h
@@ -33,6 +33,7 @@ typedef struct sMESinstance {
int MESsourcePrimeNode; /* number of internal source node of mesfet */
double MESarea; /* area factor for the mesfet */
+ double MESm; /* Parallel multiplier */
double MESicVDS; /* initial condition voltage D-S*/
double MESicVGS; /* initial condition voltage G-S*/
double *MESdrainDrainPrimePtr; /* pointer to sparse matrix at
@@ -67,7 +68,8 @@ typedef struct sMESinstance {
* (source prime,source prime) */
int MESoff; /* 'off' flag for mesfet */
- unsigned MESareaGiven : 1; /* flag to indicate area was specified */
+ unsigned MESareaGiven : 1; /* flag to indicate area was specified */
+ unsigned MESmGiven : 1; /* flag to indicate multiplier specified*/
unsigned MESicVDSGiven : 1; /* initial condition given flag for V D-S*/
unsigned MESicVGSGiven : 1; /* initial condition given flag for V G-S*/
@@ -224,6 +226,7 @@ typedef struct sMESmodel { /* model structure for a mesfet */
#define MES_OFF 5
#define MES_CS 6
#define MES_POWER 7
+#define MES_M 8
/* model parameters */
#define MES_MOD_VTO 101
diff --git a/src/spicelib/devices/mes/mesdel.c b/src/spicelib/devices/mes/mesdel.c
index b788dca18..5729a833f 100644
--- a/src/spicelib/devices/mes/mesdel.c
+++ b/src/spicelib/devices/mes/mesdel.c
@@ -6,17 +6,13 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "mesdefs.h"
#include "sperror.h"
#include "suffix.h"
int
-MESdelete(inModel,name,inst)
- GENmodel *inModel;
- IFuid name;
- GENinstance **inst;
+MESdelete(GENmodel *inModel, IFuid name, GENinstance **inst)
{
MESmodel *model = (MESmodel*)inModel;
MESinstance **fast = (MESinstance**)inst;
diff --git a/src/spicelib/devices/mes/mesdest.c b/src/spicelib/devices/mes/mesdest.c
index 6ce9cf95c..32b7dae9a 100644
--- a/src/spicelib/devices/mes/mesdest.c
+++ b/src/spicelib/devices/mes/mesdest.c
@@ -6,14 +6,12 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "mesdefs.h"
#include "suffix.h"
void
-MESdestroy(inModel)
- GENmodel **inModel;
+MESdestroy(GENmodel **inModel)
{
MESmodel **model = (MESmodel**)inModel;
MESinstance *here;
diff --git a/src/spicelib/devices/mes/mesdisto.c b/src/spicelib/devices/mes/mesdisto.c
index bd02a9cdc..10862ac4a 100644
--- a/src/spicelib/devices/mes/mesdisto.c
+++ b/src/spicelib/devices/mes/mesdisto.c
@@ -4,7 +4,6 @@ Author: 1988 Jaijeet S Roychowdhury
**********/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -12,11 +11,7 @@ Author: 1988 Jaijeet S Roychowdhury
#include "suffix.h"
int
-MESdisto(mode,genmodel,ckt)
- GENmodel *genmodel;
- CKTcircuit *ckt;
- int mode;
-
+MESdisto(int mode,GENmodel *genmodel, CKTcircuit *ckt)
/* assuming here that ckt->CKTomega has been initialised to
* the correct value
*/
diff --git a/src/spicelib/devices/mes/mesdset.c b/src/spicelib/devices/mes/mesdset.c
index c92398018..0a2078eb4 100644
--- a/src/spicelib/devices/mes/mesdset.c
+++ b/src/spicelib/devices/mes/mesdset.c
@@ -4,7 +4,6 @@ Author: 1988 Jaijeet Roychowdhury
**********/
#include "ngspice.h"
-#include
#include "devdefs.h"
#include "cktdefs.h"
#include "mesdefs.h"
@@ -14,9 +13,7 @@ Author: 1988 Jaijeet Roychowdhury
#include "suffix.h"
int
-MESdSetup(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
+MESdSetup(GENmodel *inModel, CKTcircuit *ckt)
/* actually load the current resistance value into the
* sparse matrix previously provided
*/
@@ -68,10 +65,10 @@ MESdSetup(inModel,ckt)
/*
* dc model parameters
*/
- beta = model->MESbeta * here->MESarea;
- gdpr = model->MESdrainConduct * here->MESarea;
- gspr = model->MESsourceConduct * here->MESarea;
- csat = model->MESgateSatCurrent * here->MESarea;
+ beta = model->MESbeta * here->MESm * here->MESarea;
+ gdpr = model->MESdrainConduct * here->MESm * here->MESarea;
+ gspr = model->MESsourceConduct * here->MESm * here->MESarea;
+ csat = model->MESgateSatCurrent * here->MESm * here->MESarea;
vcrit = model->MESvcrit;
vto = model->MESthreshold;
/*
@@ -229,8 +226,8 @@ d_p.d3_pqr = 0.0;
* charge storage elements
*/
{ /* code block */
-czgs = model->MEScapGS * here->MESarea;
-czgd = model->MEScapGD * here->MESarea;
+czgs = model->MEScapGS * here->MESm * here->MESarea;
+czgd = model->MEScapGD * here->MESm * here->MESarea;
phib = model->MESgatePotential;
vcap = 1 / model->MESalpha;
diff --git a/src/spicelib/devices/mes/mesext.h b/src/spicelib/devices/mes/mesext.h
index 0a9a9005b..7ff419573 100644
--- a/src/spicelib/devices/mes/mesext.h
+++ b/src/spicelib/devices/mes/mesext.h
@@ -4,7 +4,6 @@ Author: 1985 S. Hwang
Modified: 2000 AlansFixes
**********/
-#ifdef __STDC__
extern int MESacLoad(GENmodel*,CKTcircuit*);
extern int MESask(CKTcircuit*,GENinstance*,int,IFvalue*,IFvalue*);
extern int MESdelete(GENmodel*,IFuid,GENinstance**);
@@ -22,25 +21,5 @@ extern int MEStemp(GENmodel*,CKTcircuit*);
extern int MEStrunc(GENmodel*,CKTcircuit*,double*);
extern int MESdisto(int,GENmodel*,CKTcircuit*);
extern int MESnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*);
-
extern int MESdSetup(GENmodel*,CKTcircuit*);
-#else /* stdc */
-extern int MESacLoad();
-extern int MESask();
-extern int MESdelete();
-extern void MESdestroy();
-extern int MESgetic();
-extern int MESload();
-extern int MESmAsk();
-extern int MESmDelete();
-extern int MESmParam();
-extern int MESparam();
-extern int MESpzLoad();
-extern int MESsetup();
-extern int MESunsetup();
-extern int MEStemp();
-extern int MEStrunc();
-extern int MESdisto();
-extern int MESnoise();
-#endif /* stdc */
diff --git a/src/spicelib/devices/mes/mesgetic.c b/src/spicelib/devices/mes/mesgetic.c
index 6cd90f9e2..63b183d6a 100644
--- a/src/spicelib/devices/mes/mesgetic.c
+++ b/src/spicelib/devices/mes/mesgetic.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -14,9 +13,7 @@ Author: 1985 S. Hwang
int
-MESgetic(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
+MESgetic(GENmodel *inModel, CKTcircuit *ckt)
{
MESmodel *model = (MESmodel*)inModel;
MESinstance *here;
diff --git a/src/spicelib/devices/mes/mesload.c b/src/spicelib/devices/mes/mesload.c
index 0e81c0fe6..5ee3b0172 100644
--- a/src/spicelib/devices/mes/mesload.c
+++ b/src/spicelib/devices/mes/mesload.c
@@ -5,7 +5,6 @@ Modified: 2000 AlansFixes
**********/
#include "ngspice.h"
-#include
#include "devdefs.h"
#include "cktdefs.h"
#include "mesdefs.h"
@@ -15,17 +14,12 @@ Modified: 2000 AlansFixes
#include "suffix.h"
/* forward declaraction of our helper function */
-#ifdef __STDC__
+
static double qggnew(double,double,double,double,double,double,double,
double*,double*);
-#else /* stdc */
-static double qggnew();
-#endif /* stdc */
int
-MESload(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
+MESload(GENmodel *inModel, CKTcircuit *ckt)
/* actually load the current resistance value into the
* sparse matrix previously provided
*/
@@ -86,6 +80,8 @@ MESload(inModel,ckt)
int ichk1;
int error;
+ double m;
+
/* loop through all the models */
for( ; model != NULL; model = model->MESnextModel ) {
@@ -429,32 +425,35 @@ MESload(inModel,ckt)
* load current vector
*/
load:
+
+ m = here->MESm;
+
ceqgd=model->MEStype*(cgd-ggd*vgd);
ceqgs=model->MEStype*((cg-cgd)-ggs*vgs);
cdreq=model->MEStype*((cd+cgd)-gds*vds-gm*vgs);
- *(ckt->CKTrhs + here->MESgateNode) += (-ceqgs-ceqgd);
+ *(ckt->CKTrhs + here->MESgateNode) += m * (-ceqgs-ceqgd);
*(ckt->CKTrhs + here->MESdrainPrimeNode) +=
- (-cdreq+ceqgd);
+ m * (-cdreq+ceqgd);
*(ckt->CKTrhs + here->MESsourcePrimeNode) +=
- (cdreq+ceqgs);
+ m * (cdreq+ceqgs);
/*
* load y matrix
*/
- *(here->MESdrainDrainPrimePtr) += (-gdpr);
- *(here->MESgateDrainPrimePtr) += (-ggd);
- *(here->MESgateSourcePrimePtr) += (-ggs);
- *(here->MESsourceSourcePrimePtr) += (-gspr);
- *(here->MESdrainPrimeDrainPtr) += (-gdpr);
- *(here->MESdrainPrimeGatePtr) += (gm-ggd);
- *(here->MESdrainPrimeSourcePrimePtr) += (-gds-gm);
- *(here->MESsourcePrimeGatePtr) += (-ggs-gm);
- *(here->MESsourcePrimeSourcePtr) += (-gspr);
- *(here->MESsourcePrimeDrainPrimePtr) += (-gds);
- *(here->MESdrainDrainPtr) += (gdpr);
- *(here->MESgateGatePtr) += (ggd+ggs);
- *(here->MESsourceSourcePtr) += (gspr);
- *(here->MESdrainPrimeDrainPrimePtr) += (gdpr+gds+ggd);
- *(here->MESsourcePrimeSourcePrimePtr) += (gspr+gds+gm+ggs);
+ *(here->MESdrainDrainPrimePtr) += m * (-gdpr);
+ *(here->MESgateDrainPrimePtr) += m * (-ggd);
+ *(here->MESgateSourcePrimePtr) += m * (-ggs);
+ *(here->MESsourceSourcePrimePtr) += m * (-gspr);
+ *(here->MESdrainPrimeDrainPtr) += m * (-gdpr);
+ *(here->MESdrainPrimeGatePtr) += m * (gm-ggd);
+ *(here->MESdrainPrimeSourcePrimePtr) += m * (-gds-gm);
+ *(here->MESsourcePrimeGatePtr) += m * (-ggs-gm);
+ *(here->MESsourcePrimeSourcePtr) += m * (-gspr);
+ *(here->MESsourcePrimeDrainPrimePtr) += m * (-gds);
+ *(here->MESdrainDrainPtr) += m * (gdpr);
+ *(here->MESgateGatePtr) += m * (ggd+ggs);
+ *(here->MESsourceSourcePtr) += m * (gspr);
+ *(here->MESdrainPrimeDrainPrimePtr) += m * (gdpr+gds+ggd);
+ *(here->MESsourcePrimeSourcePrimePtr) += m * (gspr+gds+gm+ggs);
}
}
return(OK);
diff --git a/src/spicelib/devices/mes/mesmask.c b/src/spicelib/devices/mes/mesmask.c
index 75c2eaadb..32521f5cc 100644
--- a/src/spicelib/devices/mes/mesmask.c
+++ b/src/spicelib/devices/mes/mesmask.c
@@ -6,7 +6,6 @@ Author: 1987 Thomas L. Quarles
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "devdefs.h"
#include "ifsim.h"
@@ -17,11 +16,7 @@ Author: 1987 Thomas L. Quarles
/* ARGSUSED */
int
-MESmAsk(ckt,inst,which,value)
- CKTcircuit *ckt;
- GENmodel *inst;
- int which;
- IFvalue *value;
+MESmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value)
{
MESmodel *here = (MESmodel*)inst;
switch(which) {
diff --git a/src/spicelib/devices/mes/mesmdel.c b/src/spicelib/devices/mes/mesmdel.c
index 1e02314ae..5191200d5 100644
--- a/src/spicelib/devices/mes/mesmdel.c
+++ b/src/spicelib/devices/mes/mesmdel.c
@@ -6,17 +6,13 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "mesdefs.h"
#include "sperror.h"
#include "suffix.h"
int
-MESmDelete(inModel,modname,kill)
- GENmodel **inModel;
- IFuid modname;
- GENmodel *kill;
+MESmDelete(GENmodel **inModel, IFuid modname, GENmodel *kill)
{
MESmodel **model = (MESmodel**)inModel;
MESmodel *modfast = (MESmodel*)kill;
diff --git a/src/spicelib/devices/mes/mesmpar.c b/src/spicelib/devices/mes/mesmpar.c
index 3bea7f5a1..73c2a4ebd 100644
--- a/src/spicelib/devices/mes/mesmpar.c
+++ b/src/spicelib/devices/mes/mesmpar.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "ifsim.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -14,10 +13,7 @@ Author: 1985 S. Hwang
int
-MESmParam(param,value,inModel)
- int param;
- IFvalue *value;
- GENmodel *inModel;
+MESmParam(int param, IFvalue *value, GENmodel *inModel)
{
MESmodel *model = (MESmodel*)inModel;
switch(param) {
diff --git a/src/spicelib/devices/mes/mesnoise.c b/src/spicelib/devices/mes/mesnoise.c
index d715068de..701222146 100644
--- a/src/spicelib/devices/mes/mesnoise.c
+++ b/src/spicelib/devices/mes/mesnoise.c
@@ -4,7 +4,6 @@ Author: 1987 Gary W. Ng
**********/
#include "ngspice.h"
-#include
#include "mesdefs.h"
#include "cktdefs.h"
#include "iferrmsg.h"
@@ -24,13 +23,8 @@ extern void NevalSrc();
extern double Nintegrate();
int
-MESnoise (mode, operation, genmodel, ckt, data, OnDens)
- int mode;
- int operation;
- GENmodel *genmodel;
- CKTcircuit *ckt;
- Ndata *data;
- double *OnDens;
+MESnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *data,
+ double *OnDens)
{
MESmodel *firstModel = (MESmodel *) genmodel;
MESmodel *model;
@@ -122,21 +116,21 @@ if (!data->namelist) return(E_NOMEM);
case N_DENS:
NevalSrc(&noizDens[MESRDNOIZ],&lnNdens[MESRDNOIZ],
ckt,THERMNOISE,inst->MESdrainPrimeNode,inst->MESdrainNode,
- model->MESdrainConduct * inst->MESarea);
+ model->MESdrainConduct * inst->MESarea * inst->MESm);
NevalSrc(&noizDens[MESRSNOIZ],&lnNdens[MESRSNOIZ],
ckt,THERMNOISE,inst->MESsourcePrimeNode,inst->MESsourceNode,
- model->MESsourceConduct * inst->MESarea);
+ model->MESsourceConduct * inst->MESarea * inst->MESm);
NevalSrc(&noizDens[MESIDNOIZ],&lnNdens[MESIDNOIZ],
ckt,THERMNOISE,inst->MESdrainPrimeNode,
inst->MESsourcePrimeNode,
- (2.0/3.0 * fabs(*(ckt->CKTstate0 + inst->MESgm))));
+ (2.0/3.0 * inst->MESm * fabs(*(ckt->CKTstate0 + inst->MESgm))));
NevalSrc(&noizDens[MESFLNOIZ],(double*)NULL,ckt,
N_GAIN,inst->MESdrainPrimeNode, inst->MESsourcePrimeNode,
(double)0.0);
- noizDens[MESFLNOIZ] *= model->MESfNcoef *
+ noizDens[MESFLNOIZ] *= inst->MESm * model->MESfNcoef *
exp(model->MESfNexp *
log(MAX(fabs(*(ckt->CKTstate0 + inst->MEScd)),N_MINLOG))) /
data->freq;
diff --git a/src/spicelib/devices/mes/mesparam.c b/src/spicelib/devices/mes/mesparam.c
index 5db8da5c9..2848a2d3d 100644
--- a/src/spicelib/devices/mes/mesparam.c
+++ b/src/spicelib/devices/mes/mesparam.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "ifsim.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -15,11 +14,7 @@ Author: 1985 S. Hwang
/* ARGSUSED */
int
-MESparam(param,value,inst,select)
- int param;
- IFvalue *value;
- GENinstance *inst;
- IFvalue *select;
+MESparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
{
MESinstance *here = (MESinstance*)inst;
switch(param) {
@@ -27,6 +22,10 @@ MESparam(param,value,inst,select)
here->MESarea = value->rValue;
here->MESareaGiven = TRUE;
break;
+ case MES_M:
+ here->MESm = value->rValue;
+ here->MESmGiven = TRUE;
+ break;
case MES_IC_VDS:
here->MESicVDS = value->rValue;
here->MESicVDSGiven = TRUE;
diff --git a/src/spicelib/devices/mes/mespzld.c b/src/spicelib/devices/mes/mespzld.c
index 7ebe2175c..23976b8ab 100644
--- a/src/spicelib/devices/mes/mespzld.c
+++ b/src/spicelib/devices/mes/mespzld.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -15,10 +14,7 @@ Author: 1985 S. Hwang
int
-MESpzLoad(inModel,ckt,s)
- GENmodel *inModel;
- CKTcircuit *ckt;
- SPcomplex *s;
+MESpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
{
MESmodel *model = (MESmodel*)inModel;
MESinstance *here;
@@ -31,12 +27,16 @@ MESpzLoad(inModel,ckt,s)
double ggd;
double xgd;
+ double m;
+
for( ; model != NULL; model = model->MESnextModel ) {
for( here = model->MESinstances; here != NULL;
here = here->MESnextInstance) {
if (here->MESowner != ARCHme) continue;
+ m = here->MESm;
+
gdpr=model->MESdrainConduct * here->MESarea;
gspr=model->MESsourceConduct * here->MESarea;
gm= *(ckt->CKTstate0 + here->MESgm) ;
@@ -45,35 +45,36 @@ MESpzLoad(inModel,ckt,s)
xgs= *(ckt->CKTstate0 + here->MESqgs) ;
ggd= *(ckt->CKTstate0 + here->MESggd) ;
xgd= *(ckt->CKTstate0 + here->MESqgd) ;
- *(here->MESdrainDrainPtr ) += gdpr;
- *(here->MESgateGatePtr ) += ggd+ggs;
- *(here->MESgateGatePtr ) += (xgd+xgs)*s->real;
- *(here->MESgateGatePtr +1) += (xgd+xgs)*s->imag;
- *(here->MESsourceSourcePtr ) += gspr;
- *(here->MESdrainPrimeDrainPrimePtr ) += gdpr+gds+ggd;
- *(here->MESdrainPrimeDrainPrimePtr ) += xgd*s->real;
- *(here->MESdrainPrimeDrainPrimePtr +1) += xgd*s->imag;
- *(here->MESsourcePrimeSourcePrimePtr ) += gspr+gds+gm+ggs;
- *(here->MESsourcePrimeSourcePrimePtr ) += xgs*s->real;
- *(here->MESsourcePrimeSourcePrimePtr +1) += xgs*s->imag;
- *(here->MESdrainDrainPrimePtr ) -= gdpr;
- *(here->MESgateDrainPrimePtr ) -= ggd;
- *(here->MESgateDrainPrimePtr ) -= xgd*s->real;
- *(here->MESgateDrainPrimePtr +1) -= xgd*s->imag;
- *(here->MESgateSourcePrimePtr ) -= ggs;
- *(here->MESgateSourcePrimePtr ) -= xgs*s->real;
- *(here->MESgateSourcePrimePtr +1) -= xgs*s->imag;
- *(here->MESsourceSourcePrimePtr ) -= gspr;
- *(here->MESdrainPrimeDrainPtr ) -= gdpr;
- *(here->MESdrainPrimeGatePtr ) += (-ggd+gm);
- *(here->MESdrainPrimeGatePtr ) -= xgd*s->real;
- *(here->MESdrainPrimeGatePtr +1) -= xgd*s->imag;
- *(here->MESdrainPrimeSourcePrimePtr ) += (-gds-gm);
- *(here->MESsourcePrimeGatePtr ) += (-ggs-gm);
- *(here->MESsourcePrimeGatePtr ) -= xgs*s->real;
- *(here->MESsourcePrimeGatePtr +1) -= xgs*s->imag;
- *(here->MESsourcePrimeSourcePtr ) -= gspr;
- *(here->MESsourcePrimeDrainPrimePtr ) -= gds;
+
+ *(here->MESdrainDrainPtr ) += m * gdpr;
+ *(here->MESgateGatePtr ) += m * ggd+ggs;
+ *(here->MESgateGatePtr ) += m * (xgd+xgs)*s->real;
+ *(here->MESgateGatePtr +1) += m * (xgd+xgs)*s->imag;
+ *(here->MESsourceSourcePtr ) += m * gspr;
+ *(here->MESdrainPrimeDrainPrimePtr ) += m * gdpr+gds+ggd;
+ *(here->MESdrainPrimeDrainPrimePtr ) += m * xgd*s->real;
+ *(here->MESdrainPrimeDrainPrimePtr +1) += m * xgd*s->imag;
+ *(here->MESsourcePrimeSourcePrimePtr ) += m * gspr+gds+gm+ggs;
+ *(here->MESsourcePrimeSourcePrimePtr ) += m * xgs*s->real;
+ *(here->MESsourcePrimeSourcePrimePtr +1) += m * xgs*s->imag;
+ *(here->MESdrainDrainPrimePtr ) -= m * gdpr;
+ *(here->MESgateDrainPrimePtr ) -= m * ggd;
+ *(here->MESgateDrainPrimePtr ) -= m * xgd*s->real;
+ *(here->MESgateDrainPrimePtr +1) -= m * xgd*s->imag;
+ *(here->MESgateSourcePrimePtr ) -= m * ggs;
+ *(here->MESgateSourcePrimePtr ) -= m * xgs*s->real;
+ *(here->MESgateSourcePrimePtr +1) -= m * xgs*s->imag;
+ *(here->MESsourceSourcePrimePtr ) -= m * gspr;
+ *(here->MESdrainPrimeDrainPtr ) -= m * gdpr;
+ *(here->MESdrainPrimeGatePtr ) += m * (-ggd+gm);
+ *(here->MESdrainPrimeGatePtr ) -= m * xgd*s->real;
+ *(here->MESdrainPrimeGatePtr +1) -= m * xgd*s->imag;
+ *(here->MESdrainPrimeSourcePrimePtr ) += m * (-gds-gm);
+ *(here->MESsourcePrimeGatePtr ) += m * (-ggs-gm);
+ *(here->MESsourcePrimeGatePtr ) -= m * xgs*s->real;
+ *(here->MESsourcePrimeGatePtr +1) -= m * xgs*s->imag;
+ *(here->MESsourcePrimeSourcePtr ) -= m * gspr;
+ *(here->MESsourcePrimeDrainPrimePtr ) -= m * gds;
}
}
diff --git a/src/spicelib/devices/mes/messetup.c b/src/spicelib/devices/mes/messetup.c
index b3ddd4bfd..ed63af719 100644
--- a/src/spicelib/devices/mes/messetup.c
+++ b/src/spicelib/devices/mes/messetup.c
@@ -5,7 +5,6 @@ Modified: 2000 AlansFixes
**********/
#include "ngspice.h"
-#include
#include "smpdefs.h"
#include "cktdefs.h"
#include "mesdefs.h"
@@ -14,11 +13,7 @@ Modified: 2000 AlansFixes
#include "suffix.h"
int
-MESsetup(matrix,inModel,ckt,states)
- SMPmatrix *matrix;
- GENmodel *inModel;
- CKTcircuit *ckt;
- int *states;
+MESsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
/* load the diode structure with those pointers needed later
* for fast matrix loading
*/
@@ -83,7 +78,10 @@ MESsetup(matrix,inModel,ckt,states)
if (here->MESowner != ARCHme) goto matrixpointers;
if(!here->MESareaGiven) {
- here->MESarea = 1;
+ here->MESarea = 1.0;
+ }
+ if(!here->MESmGiven) {
+ here->MESm = 1.0;
}
here->MESstate = *states;
*states += MESnumStates;
@@ -163,9 +161,7 @@ if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\
}
int
-MESunsetup(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
+MESunsetup(GENmodel *inModel, CKTcircuit *ckt)
{
MESmodel *model;
MESinstance *here;
diff --git a/src/spicelib/devices/mes/mestemp.c b/src/spicelib/devices/mes/mestemp.c
index 285eb32db..f2c56ecd4 100644
--- a/src/spicelib/devices/mes/mestemp.c
+++ b/src/spicelib/devices/mes/mestemp.c
@@ -4,7 +4,6 @@ Author: 1985 S. Hwang
**********/
#include "ngspice.h"
-#include
#include "smpdefs.h"
#include "cktdefs.h"
#include "mesdefs.h"
@@ -14,10 +13,8 @@ Author: 1985 S. Hwang
/* ARGSUSED */
int
-MEStemp(inModel,ckt)
- GENmodel *inModel;
- CKTcircuit *ckt;
- /* load the diode structure with those pointers needed later
+MEStemp(GENmodel *inModel, CKTcircuit *ckt)
+ /* load the mes structure with those pointers needed later
* for fast matrix loading
*/
{
diff --git a/src/spicelib/devices/mes/mestrunc.c b/src/spicelib/devices/mes/mestrunc.c
index 2f7ff8e97..4b62e7c84 100644
--- a/src/spicelib/devices/mes/mestrunc.c
+++ b/src/spicelib/devices/mes/mestrunc.c
@@ -6,7 +6,6 @@ Author: 1985 S. Hwang
*/
#include "ngspice.h"
-#include
#include "cktdefs.h"
#include "mesdefs.h"
#include "sperror.h"
@@ -14,10 +13,7 @@ Author: 1985 S. Hwang
int
-MEStrunc(inModel,ckt,timeStep)
- GENmodel *inModel;
- CKTcircuit *ckt;
- double *timeStep;
+MEStrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
{
MESmodel *model = (MESmodel*)inModel;
MESinstance *here;
diff --git a/tests/mes/subth.cir b/tests/mes/subth.cir
new file mode 100644
index 000000000..9277a3e82
--- /dev/null
+++ b/tests/mes/subth.cir
@@ -0,0 +1,17 @@
+Mesfet subthreshold characteristics
+
+Vds 1 0
+vids 1 2 dc 0
+Vgs 3 0 dc 0
+
+z1 2 3 0 mesmod area=1.4
+
+.model mesmod nmf level=1 rd=46 rs=46 vt0=-1.3
++ lambda=0.03 alpha=3 beta=1.4e-3
+* z1 2 3 0 lev2 l=1u w=20u
+* .model lev2 nmf level=2 d=0.12u mu=0.23 vs=1.8e5
+*+ m=3.3 vto=-1.3 eta=1.82 lambda=0.044 sigma0=0.09
+*+ vsigma=0.1 vsigmat=0.9 rdi=46 rsi=46 delta=5
+*+ nd=2.1e23
+
+.end