1 /**********
2 Copyright 1990 Regents of the University of California.  All rights reserved.
3 Author: 1985 Thomas L. Quarles
4 Modified: 2000 AlansFixes
5 **********/
6 /*
7  */
8 
9 #include "ngspice/ngspice.h"
10 #include "ngspice/const.h"
11 #include "ngspice/ifsim.h"
12 #include "mos3defs.h"
13 #include "ngspice/sperror.h"
14 #include "ngspice/suffix.h"
15 #include "ngspice/fteext.h"
16 
17 
18 /* ARGSUSED */
19 int
MOS3param(int param,IFvalue * value,GENinstance * inst,IFvalue * select)20 MOS3param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
21 {
22     double scale;
23 
24     MOS3instance *here = (MOS3instance *)inst;
25 
26     NG_IGNORE(select);
27 
28     if (!cp_getvar("scale", CP_REAL, &scale, 0))
29         scale = 1;
30 
31     switch (param) {
32         case MOS3_M:
33             here->MOS3m = value->rValue;
34             here->MOS3mGiven = TRUE;
35             break;
36         case MOS3_W:
37             here->MOS3w = value->rValue * scale;
38             here->MOS3wGiven = TRUE;
39             break;
40         case MOS3_L:
41             here->MOS3l = value->rValue * scale;
42             here->MOS3lGiven = TRUE;
43             break;
44         case MOS3_AS:
45             here->MOS3sourceArea = value->rValue * scale * scale;
46             here->MOS3sourceAreaGiven = TRUE;
47             break;
48         case MOS3_AD:
49             here->MOS3drainArea = value->rValue * scale * scale;
50             here->MOS3drainAreaGiven = TRUE;
51             break;
52         case MOS3_PS:
53             here->MOS3sourcePerimiter = value->rValue * scale;
54             here->MOS3sourcePerimiterGiven = TRUE;
55             break;
56         case MOS3_PD:
57             here->MOS3drainPerimiter = value->rValue * scale;
58             here->MOS3drainPerimiterGiven = TRUE;
59             break;
60         case MOS3_NRS:
61             here->MOS3sourceSquares = value->rValue;
62             here->MOS3sourceSquaresGiven = TRUE;
63             break;
64         case MOS3_NRD:
65             here->MOS3drainSquares = value->rValue;
66             here->MOS3drainSquaresGiven = TRUE;
67             break;
68         case MOS3_OFF:
69             here->MOS3off = (value->iValue != 0);
70             break;
71         case MOS3_IC_VBS:
72             here->MOS3icVBS = value->rValue;
73             here->MOS3icVBSGiven = TRUE;
74             break;
75         case MOS3_IC_VDS:
76             here->MOS3icVDS = value->rValue;
77             here->MOS3icVDSGiven = TRUE;
78             break;
79         case MOS3_IC_VGS:
80             here->MOS3icVGS = value->rValue;
81             here->MOS3icVGSGiven = TRUE;
82             break;
83         case MOS3_TEMP:
84             here->MOS3temp = value->rValue+CONSTCtoK;
85             here->MOS3tempGiven = TRUE;
86             break;
87         case MOS3_DTEMP:
88             here->MOS3dtemp = value->rValue;
89             here->MOS3dtempGiven = TRUE;
90             break;
91         case MOS3_IC:
92             /* FALLTHROUGH added to suppress GCC warning due to
93              * -Wimplicit-fallthrough flag */
94             switch (value->v.numValue) {
95                 case 3:
96                     here->MOS3icVBS = *(value->v.vec.rVec+2);
97                     here->MOS3icVBSGiven = TRUE;
98                     /* FALLTHROUGH */
99                 case 2:
100                     here->MOS3icVGS = *(value->v.vec.rVec+1);
101                     here->MOS3icVGSGiven = TRUE;
102                     /* FALLTHROUGH */
103                 case 1:
104                     here->MOS3icVDS = *(value->v.vec.rVec);
105                     here->MOS3icVDSGiven = TRUE;
106                     break;
107                 default:
108                     return(E_BADPARM);
109             }
110             break;
111         case MOS3_L_SENS:
112             if(value->iValue) {
113                 here->MOS3senParmNo = 1;
114                 here->MOS3sens_l = 1;
115             }
116             break;
117         case MOS3_W_SENS:
118             if(value->iValue) {
119                 here->MOS3senParmNo = 1;
120                 here->MOS3sens_w = 1;
121             }
122             break;
123         default:
124             return(E_BADPARM);
125     }
126     return(OK);
127 }
128