Jspice3
mospzld.c File Reference
#include "spice.h"
#include <stdio.h>
#include "mosdefs.h"
#include "sperror.h"
Include dependency graph for mospzld.c:

Go to the source code of this file.

Functions

int MOSpzLoad (GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
 

Function Documentation

int MOSpzLoad ( GENmodel inModel,
CKTcircuit ckt,
SPcomplex s 
)

Definition at line 15 of file mospzld.c.

20 {
21  MOSmodel *model = (MOSmodel *)inModel;
22  MOSinstance *here;
23  int xnrm;
24  int xrev;
25  double xgs;
26  double xgd;
27  double xgb;
28  double xbd;
29  double xbs;
30  double capgs;
31  double capgd;
32  double capgb;
33 
34  for ( ; model != NULL; model = model->MOSnextModel) {
35  for (here = model->MOSinstances; here!= NULL;
36  here = here->MOSnextInstance) {
37 
38  if (here->MOSmode < 0) {
39  xnrm=0;
40  xrev=1;
41  }
42  else {
43  xnrm=1;
44  xrev=0;
45  }
46  /*
47  * meyer's model parameters
48  */
49  capgs = ( 2* *(ckt->CKTstate0+here->MOScapgs)+
51  capgd = ( 2* *(ckt->CKTstate0+here->MOScapgd)+
52  here->MOSgateDrainOverlapCap );
53  capgb = ( 2* *(ckt->CKTstate0+here->MOScapgb)+
54  here->MOSgateBulkOverlapCap );
55  xgs = capgs;
56  xgd = capgd;
57  xgb = capgb;
58  xbd = here->MOScapbd;
59  xbs = here->MOScapbs;
60  /* printf("mos: xgs=%g, xgd=%g, xgb=%g, xbd=%g, xbs=%g\n",
61  xgs,xgd,xgb,xbd,xbs); */
62  /*
63  * load matrix
64  */
65 
66  *(here->MOSGgPtr ) += (xgd+xgs+xgb)*s->real;
67  *(here->MOSGgPtr +1) += (xgd+xgs+xgb)*s->imag;
68  *(here->MOSBbPtr ) += (xgb+xbd+xbs)*s->real;
69  *(here->MOSBbPtr +1) += (xgb+xbd+xbs)*s->imag;
70  *(here->MOSDPdpPtr ) += (xgd+xbd)*s->real;
71  *(here->MOSDPdpPtr +1) += (xgd+xbd)*s->imag;
72  *(here->MOSSPspPtr ) += (xgs+xbs)*s->real;
73  *(here->MOSSPspPtr +1) += (xgs+xbs)*s->imag;
74  *(here->MOSGbPtr ) -= xgb*s->real;
75  *(here->MOSGbPtr +1) -= xgb*s->imag;
76  *(here->MOSGdpPtr ) -= xgd*s->real;
77  *(here->MOSGdpPtr +1) -= xgd*s->imag;
78  *(here->MOSGspPtr ) -= xgs*s->real;
79  *(here->MOSGspPtr +1) -= xgs*s->imag;
80  *(here->MOSBgPtr ) -= xgb*s->real;
81  *(here->MOSBgPtr +1) -= xgb*s->imag;
82  *(here->MOSBdpPtr ) -= xbd*s->real;
83  *(here->MOSBdpPtr +1) -= xbd*s->imag;
84  *(here->MOSBspPtr ) -= xbs*s->real;
85  *(here->MOSBspPtr +1) -= xbs*s->imag;
86  *(here->MOSDPgPtr ) -= xgd*s->real;
87  *(here->MOSDPgPtr +1) -= xgd*s->imag;
88  *(here->MOSDPbPtr ) -= xbd*s->real;
89  *(here->MOSDPbPtr +1) -= xbd*s->imag;
90  *(here->MOSSPgPtr ) -= xgs*s->real;
91  *(here->MOSSPgPtr +1) -= xgs*s->imag;
92  *(here->MOSSPbPtr ) -= xbs*s->real;
93  *(here->MOSSPbPtr +1) -= xbs*s->imag;
94 
95  *(here->MOSDdPtr) += here->MOSdrainConductance;
96  *(here->MOSSsPtr) += here->MOSsourceConductance;
97  *(here->MOSBbPtr) += here->MOSgbd+here->MOSgbs;
98 
99  *(here->MOSDPdpPtr) += here->MOSdrainConductance+
100  here->MOSgds+here->MOSgbd+
101  xrev*(here->MOSgm+here->MOSgmbs);
102 
103  *(here->MOSSPspPtr) += here->MOSsourceConductance+
104  here->MOSgds+here->MOSgbs+
105  xnrm*(here->MOSgm+here->MOSgmbs);
106 
107  *(here->MOSDdpPtr) -= here->MOSdrainConductance;
108  *(here->MOSSspPtr) -= here->MOSsourceConductance;
109  *(here->MOSBdpPtr) -= here->MOSgbd;
110  *(here->MOSBspPtr) -= here->MOSgbs;
111  *(here->MOSDPdPtr) -= here->MOSdrainConductance;
112  *(here->MOSDPgPtr) += (xnrm-xrev)*here->MOSgm;
113  *(here->MOSDPbPtr) += -here->MOSgbd+(xnrm-xrev)*here->MOSgmbs;
114  *(here->MOSDPspPtr) -= here->MOSgds+
115  xnrm*(here->MOSgm+here->MOSgmbs);
116 
117  *(here->MOSSPgPtr) -= (xnrm-xrev)*here->MOSgm;
118  *(here->MOSSPsPtr) -= here->MOSsourceConductance;
119  *(here->MOSSPbPtr) -= here->MOSgbs+(xnrm-xrev)*here->MOSgmbs;
120  *(here->MOSSPdpPtr) -= here->MOSgds+
121  xrev*(here->MOSgm+here->MOSgmbs);
122  }
123  }
124  return (OK);
125 }
struct sMOSmodel * MOSnextModel
Definition: mosdefs.h:274
double MOSgateBulkOverlapCap
Definition: mosdefs.h:94
MOSinstance * MOSinstances
Definition: mosdefs.h:276
double * MOSDPdpPtr
Definition: mosdefs.h:106
double MOSgm
Definition: mosdefs.h:74
double * MOSSPbPtr
Definition: mosdefs.h:139
double MOSgmbs
Definition: mosdefs.h:73
double * MOSBspPtr
Definition: mosdefs.h:122
double * MOSSsPtr
Definition: mosdefs.h:102
double * MOSSspPtr
Definition: mosdefs.h:118
double * MOSGspPtr
Definition: mosdefs.h:116
double * MOSSPgPtr
Definition: mosdefs.h:133
double MOSgds
Definition: mosdefs.h:75
double MOScapbd
Definition: mosdefs.h:78
double * MOSDPbPtr
Definition: mosdefs.h:137
double real
Definition: complex.h:13
double * MOSSPspPtr
Definition: mosdefs.h:108
double * MOSSPsPtr
Definition: mosdefs.h:135
double MOSgateSourceOverlapCap
Definition: mosdefs.h:92
double * MOSDdPtr
Definition: mosdefs.h:98
#define OK
Definition: iferrmsg.h:17
double * MOSGbPtr
Definition: mosdefs.h:112
double MOSgbs
Definition: mosdefs.h:77
#define NULL
Definition: spdefs.h:121
double MOSgbd
Definition: mosdefs.h:76
double * MOSSPdpPtr
Definition: mosdefs.h:141
double * MOSBdpPtr
Definition: mosdefs.h:120
double * MOSGgPtr
Definition: mosdefs.h:100
double * MOSGdpPtr
Definition: mosdefs.h:114
double * MOSDPgPtr
Definition: mosdefs.h:130
static char model[32]
Definition: subckt.c:76
int MOSmode
Definition: mosdefs.h:32
double * MOSBgPtr
Definition: mosdefs.h:128
double imag
Definition: complex.h:14
double MOSgateDrainOverlapCap
Definition: mosdefs.h:93
double * MOSDPspPtr
Definition: mosdefs.h:124
double MOSsourceConductance
Definition: mosdefs.h:42
double MOScapbs
Definition: mosdefs.h:79
struct sMOSinstance * MOSnextInstance
Definition: mosdefs.h:20
double * MOSDPdPtr
Definition: mosdefs.h:126
double * MOSBbPtr
Definition: mosdefs.h:104
double * MOSDdpPtr
Definition: mosdefs.h:110
double MOSdrainConductance
Definition: mosdefs.h:43