Jspice3
diodset.c File Reference
#include "spice.h"
#include <stdio.h>
#include "util.h"
#include "diodefs.h"
#include "distodef.h"
#include "const.h"
#include "sperror.h"
#include "distoext.h"
Include dependency graph for diodset.c:

Go to the source code of this file.

Macros

#define P33   .333333333
 

Functions

int DIOdSetup (DIOmodel *model, CKTcircuit *ckt)
 

Macro Definition Documentation

#define P33   .333333333

Definition at line 17 of file diodset.c.

Function Documentation

int DIOdSetup ( DIOmodel model,
CKTcircuit ckt 
)

Definition at line 20 of file diodset.c.

27 {
28  DIOinstance *here;
29  double arg;
30  double csat; /* area-scaled saturation current */
31  double czero;
32  double czof2;
33  double evd;
34  double evrev;
35  double gd;
36  double sarg;
37  double vd; /* current diode voltage */
38  double vt; /* K t / Q */
39  double vte;
40  double g2,g3;
41  double cdiff2,cdiff3;
42  double cjunc1,cjunc2,cjunc3;
43 
44  /* loop through all the diode models */
45  for ( ; model != NULL; model = model->DIOnextModel) {
46 
47  /* loop through all the instances of the model */
48  for (here = model->DIOinstances; here != NULL;
49  here = here->DIOnextInstance) {
50  /*
51  * this routine loads diodes for dc and transient analyses.
52  */
53 
54  csat = here->DIOtSatCur; /* includes area dependence */
55  vt = CONSTKoverQ * here->DIOtemp;
56  vte = model->DIOemissionCoeff * vt;
57  vd = *(ckt->CKTrhsOld + here->DIOposPrimeNode) -
58  *(ckt->CKTrhsOld + here->DIOnegNode);
59 
60  /*
61  * compute derivatives
62  */
63 
64  if (vd >= -5*vte) {
65  evd = exp(vd/vte);
66  gd = csat*evd/vte + ckt->CKTgmin;
67  g2 = 0.5*(gd - ckt->CKTgmin)/vte;
68  g3 = P33*g2/vte;
69  cdiff2 = g2*model->DIOtransitTime;
70  cdiff3 = g3*model->DIOtransitTime;
71  }
72  else if (!here->DIOtBrkdwnV || (vd >= -here->DIOtBrkdwnV)) {
73  /* off */
74  /*
75  * gd = -csat/vd + ckt->CKTgmin;
76  */
77  g2 = 0.0;
78  g3 = 0.0;
79  cdiff2 = 0.0;
80  cdiff3 = 0.0;
81  }
82  else {
83  /* reverse breakdown */
84  /* why using csat instead of breakdowncurrent? */
85  evrev = exp(-(here->DIOtBrkdwnV + vd)/vt);
86  /*
87  * cd = -csat*(evrev - 1 + here->DIOtBrkdwnV/vt);
88  * gd = csat*evrev/vt;
89  */
90  /* should there be a minus here above? */
91  g2 = -.5*gd/vt;
92  g3 = -P33*g2/vt;
93  cdiff2 = 0.0;
94  cdiff3 = 0.0;
95  }
96  /*
97  * junction charge storage elements
98  */
99  cjunc1 = 0.0;
100  cjunc2 = 0.0;
101  cjunc3 = 0.0;
102  czero = here->DIOtJctCap*here->DIOarea;
103  if (czero != 0.0) {
104  if (vd < here->DIOtDepCap){
105  arg = 1 - vd/model->DIOjunctionPot;
106  sarg = exp(-model->DIOgradingCoeff*log(arg));
107  /* the expression for depletion charge:
108  * model->DIOjunctionPot*czero*
109  * (1-arg*sarg)/(1-model->DIOgradingCoeff);
110  */
111  cjunc1 = czero*sarg;
112  cjunc2 = .5*cjunc1*model->DIOgradingCoeff/
113  (model->DIOjunctionPot*arg);
114  cjunc3 = P33*cjunc2*(model->DIOgradingCoeff + 1)/
115  (model->DIOjunctionPot*arg);
116  }
117  else {
118  czof2 = czero/model->DIOf2;
119  /* depletion charge equation:
120  * czero*here->DIOtF1+czof2*
121  * (model->DIOf3*(vd-here->DIOtDepCap)+
122  * (model->DIOgradingCoeff/(model->DIOjunctionPot+
123  * model->DIOjunctionPot))*(vd*vd-here->DIOtDepCap*
124  * here->DIOtDepCap));
125  */
126  cjunc2 = .5*czof2/
127  model->DIOjunctionPot*model->DIOgradingCoeff;
128  }
129  }
130 
131  /*
132  * store small-signal parameters
133  */
134  here->id_x2 = g2;
135  here->id_x3 = g3;
136  here->cdif_x2 = cdiff2;
137  here->cdif_x3 = cdiff3;
138  here->cjnc_x2 = cjunc2;
139  here->cjnc_x3 = cjunc3;
140  }
141  }
142  return(OK);
143 }
double DIOtBrkdwnV
Definition: diodefs.h:58
struct sDIOinstance * DIOnextInstance
Definition: diodefs.h:20
double CONSTKoverQ
Definition: main.c:915
double DIOtransitTime
Definition: diodefs.h:145
double DIOtSatCur
Definition: diodefs.h:55
double DIOtemp
Definition: diodefs.h:50
#define OK
Definition: iferrmsg.h:17
double * CKTrhsOld
Definition: cktdefs.h:98
DIOinstance * DIOinstances
Definition: diodefs.h:121
#define NULL
Definition: spdefs.h:121
double DIOemissionCoeff
Definition: diodefs.h:144
int DIOposPrimeNode
Definition: diodefs.h:26
struct sDIOmodel * DIOnextModel
Definition: diodefs.h:119
double DIOf2
Definition: diodefs.h:154
int DIOnegNode
Definition: diodefs.h:25
double DIOjunctionPot
Definition: diodefs.h:147
double CKTgmin
Definition: cktdefs.h:190
#define P33
Definition: diodset.c:17
double DIOarea
Definition: diodefs.h:48
double DIOtJctCap
Definition: diodefs.h:52
double DIOgradingCoeff
Definition: diodefs.h:148