Xyce  6.1
N_DEV_MOSFET3.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_MOSFET3.h,v $
27 //
28 // Purpose : Level 3 Metal-oxide-semiconductor field effect transistor
29 // (MOSFET) classes.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
34 //
35 // Creation Date : 02/28/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.125 $
41 //
42 // Revision Date : $Date: 2015/04/08 19:18:24 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_MOSFET3_h
48 #define Xyce_N_DEV_MOSFET3_h
49 
50 // ---------- Xyce Includes ----------
51 #include <N_DEV_Configuration.h>
52 #include <N_DEV_DeviceMaster.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceModel.h>
55 #include <N_DEV_DeviceBlock.h>
56 
57 #include <N_DEV_MOSFET1.h>
58 
59 namespace Xyce {
60 namespace Device {
61 namespace MOSFET3 {
62 
63 // ---------- Forward Declarations -------
64 class Model;
65 class Instance;
66 
67 struct Traits : public DeviceTraits<Model, Instance, MOSFET1::Traits>
68 {
69  static const char *name() {return "MOSFET level 3";}
70  static const char *deviceTypeName() {return "M level 3";}
71  static int numNodes() {return 4;}
72  static bool modelRequired() {return true;}
73  static bool isLinearDevice() {return false;}
74 
75  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
76  static void loadModelParameters(ParametricData<Model> &model_parameters);
77  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
78 };
79 
80 //-----------------------------------------------------------------------------
81 // Class : Instance
82 // Purpose :
83 // Special Notes :
84 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
85 // Creation Date : 3/16/00
86 //-----------------------------------------------------------------------------
87 class Instance : public DeviceInstance
88 {
89  friend class ParametricData<Instance>;
90  friend class Model;
91  friend class Traits;friend class Master;
92 
93 public:
94 
95  Instance(
96  const Configuration & configuration,
97  const InstanceBlock & IB,
98  Model & Miter,
99  const FactoryBlock & factory_block);
100 
101  ~Instance();
102 
103 private:
104  Instance(const Instance &);
105  Instance &operator=(const Instance &);
106 
107 public:
108  void registerLIDs( const std::vector<int> & intLIDVecRef,
109  const std::vector<int> & extLIDVecRef );
110  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
111  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef);
112 
113  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
114 
115  const std::vector< std::vector<int> > & jacobianStamp() const;
116  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
117 
118  bool processParams ();
119 
120  bool updateTemperature(const double & temp_tmp);
121  bool updateIntermediateVars ();
122  bool updatePrimaryState ();
123 
124  int getNumNoiseSources () const;
125  void setupNoiseSources (Xyce::Analysis::NoiseData & noiseData);
126  void getNoiseSources (Xyce::Analysis::NoiseData & noiseData);
127 
128  // load functions, residual:
129  bool loadDAEQVector ();
130  bool loadDAEFVector ();
131 
132  // load functions, Jacobian:
133  bool loadDAEdQdx ();
134  bool loadDAEdFdx ();
135 
136  void setupPointers();
137 
138  // Additional Public Declarations
139  inline bool isConverged();
140 
141 public:
142  // Getters and setters
144  {
145  return model_;
146  }
147 
148 private:
149  static std::vector< std::vector<int> > jacStamp_DC_SC;
150  static std::vector< std::vector<int> > jacStamp_DC;
151  static std::vector< std::vector<int> > jacStamp_SC;
152  static std::vector< std::vector<int> > jacStamp;
153 
154  static std::vector<int> jacMap_DC_SC;
155  static std::vector<int> jacMap_DC;
156  static std::vector<int> jacMap_SC;
157  static std::vector<int> jacMap;
158 
159  static std::vector< std::vector<int> > jacMap2_DC_SC;
160  static std::vector< std::vector<int> > jacMap2_DC;
161  static std::vector< std::vector<int> > jacMap2_SC;
162  static std::vector< std::vector<int> > jacMap2;
163 
164 
165  Model & model_; //< Owning model
166 
167 protected:
168 private:
169  // instance variables ripped -- bleeding and without anesthetic -- from
170  // 3f5, with obvious modifications to names (remove MOS3 prefix)
171  int states; // index into state table for this device
172  int dNode; // number of the gate node of the mosfet
173  int gNode; // number of the gate node of the mosfet
174  int sNode; // number of the source node of the mosfet
175  int bNode; // number of the bulk node of the mosfet
176  int dNodePrime; // number of the internal drain node of the mosfet
177  int sNodePrime; // number of the internal source node of the mosfet
178 
179 
180  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
181 
182  double l; // the length of the channel region
183  double w; // the width of the channel region
184  double drainArea; // the area of the drain diffusion
185  double sourceArea; // the area of the source diffusion
186  double drainSquares; // the length of the drain in squares
187  double sourceSquares; // the length of the source in squares
190  double sourceConductance; //conductance of source(or 0):set in setup
191  double drainConductance; //conductance of drain(or 0):set in setup
192  double temp; // operating temperature of this instance
193  double numberParallel; // number simulated parallel mosfets
194 
195  double tTransconductance; // temperature corrected transconductance
196  double tSurfMob; // temperature corrected surface mobility
197  double tPhi; // temperature corrected Phi
198  double tVto; // temperature corrected Vto
199  double tSatCur; // temperature corrected saturation Cur.
200  double tSatCurDens; // temperature corrected saturation Cur. density
201  double tCbd; // temperature corrected B-D Capacitance
202  double tCbs; // temperature corrected B-S Capacitance
203  double tCj; // temperature corrected Bulk bottom Capacitance
204  double tCjsw; // temperature corrected Bulk side Capacitance
205  double tBulkPot; // temperature corrected Bulk potential
206  double tDepCap; // temperature adjusted transition point in
207  // the cureve matching Fc * Vj
208  double tVbi; // temperature adjusted Vbi
209 
210  double icVBS; // initial condition B-S voltage
211  double icVDS; // initial condition D-S voltage
212  double icVGS; // initial condition G-S voltage
213  double von;
214  double vdsat;
215  double sourceVcrit; // vcrit for pos. vds
216  double drainVcrit; // vcrit for neg. vds
217  double cd;
218  double cbs;
219  double cbd;
220  double gmbs;
221  double gm;
222  double gds;
223  double gbd;
224  double gbs;
225  double capbd;
226  double capbs;
227  double Cbd;
228  double Cbdsw;
229  double Cbs;
230  double Cbssw;
231  double f2d;
232  double f3d;
233  double f4d;
234  double f2s;
235  double f3s;
236  double f4s;
237  int mode; // device mode : 1 = normal, -1 = inverse
238  double mode_low;
239  double mode_high;
240 
241  bool limitedFlag; // for convergence testing.
242 
243  bool IC_GIVEN;
244 
245  //end of 3f5 outtakes
246 
247  ////////////////////////////////////////////////////////////////////
248  // these are intermediate variables added to the instance class instead
249  // of leaving them to be calculated repeatedly in the load function
250 
251  // some caluclated quantities
253  double DrainSatCur;
254  double SourceSatCur;
258  double OxideCap;
259 
260  // Solution variables and intermediate quantities
261  // drain,source,gate, bulk, drainprime and sourceprime voltages
262  double Vd;
263  double Vs;
264  double Vg;
265  double Vb;
266  double Vdp;
267  double Vsp;
268  // voltage drops between pairs of nodes
269  double Vddp; // drain-drain'
270  double Vssp; // source-source'
271  double Vbsp; // bulk-source'
272  double Vbdp; // bulk-drain'
273  double Vgsp; // gate-source'
274  double Vgdp; // gate-drain'
275  double Vgb; //gate-bulk
276  double Vdpsp; //drop across channel
277 
278  // the gate-drain voltage drop isn't actually a state variable, but it
279  // is calculated at the same time and in the same manner as the state
280  // vars. So here we go, sticking it in the instance class.
281  double vgd;
282 
283  // Some stuff from mos3temp that were local vars but used elsewhere
284  double vt; // set in updateTemperature to CONSTKoverQ*temp
285 
286 
287  // the variables capgs, capgd and capgb are the raw output of
288  // qmeyer. They get massaged into total capacitances in
289  // updateIntermediateVars, and get used in updatePrimaryState to get
290  // charges on the capacitors.
291 
292  double Capgs; // total gate-source capacitance
293  double Capgd; // total gate-drain capacitance
294  double Capgb; // total gate-bulk capacitance
295 
296  // current through source and drain resistors
297  double Isource;
298  double Idrain;
299 
300  double cdrain; // the channel current shouldn't be a local variable in */
301  // updateIntermediateVars!
302 
303  // these are calculated in loadRHS and used in the jacobian load
304  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
305  double revsum; // described in comments at the end of
306  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
307  double cdreq;
308 
309  // end of intermediate variables that aren't state variables
310  ////////////////////////////
311  //
312  // vector indices
313  int li_Drain;
317  int li_Gate;
318  int li_Bulk;
319 
320  ////////////////////////////////////////////////////////////////////
321  // The following verbatim from Level=1, which has the same jacobian
322  // structure
323  ////////////////////////////////////////////////////////////////////
324  // Jacobian matrix indices:
325  // This is a 6x6 matrix block, of which 22 entries are nonzero:
326  //
327  // ---------------------------------------------------------
328  // | #NZ | | |
329  // | entries | | V_d V_g V_s V_b V_d' V_s' |
330  // ---------------------------------------------------------
331  // | 2 | KCL_d | a b |
332  // | 4 | KCL_g | c d e f |
333  // | 2 | KCL_s | g h |
334  // | 4 | KCL_b | i j k l |
335  // | 5 | KCL_d'| m n o p q |
336  // | 5 | KCL_s'| r s t u v |
337  // ---------------------------------------------------------
338  // 22 total
339 
340  ////////////////////////////////////////////////////////////////////
341  // Offset variables corresponding to the above declared indices.
342 
343  // Jacobian Matrix Offset:
344 
345  // V_d Row:
348 
349  // V_g Row:
354 
355  // V_s Row:
358 
359  // V_b Row:
364 
365  // V_d' Row:
371 
372  // V_s' Row:
378 
379  // Jacobian Matrix Pointers:
380 
381 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
382  // F-vector pointers:
383  // V_d Row:
384  double * f_DrainEquDrainNodePtr; // a
386 
387  // V_g Row:
388  double * f_GateEquGateNodePtr; // c
389  double * f_GateEquBulkNodePtr; // d
392 
393  // V_s Row:
396 
397  // V_b Row:
398  double * f_BulkEquGateNodePtr; // i
399  double * f_BulkEquBulkNodePtr; // j
402 
403  // V_d' Row:
409 
410  // V_s' Row:
416 
417  // Q-vector pointers:
418  // V_d Row:
419  double * q_DrainEquDrainNodePtr; // a
421 
422  // V_g Row:
423  double * q_GateEquGateNodePtr; // c
424  double * q_GateEquBulkNodePtr; // d
427 
428  // V_s Row:
431 
432  // V_b Row:
433  double * q_BulkEquGateNodePtr; // i
434  double * q_BulkEquBulkNodePtr; // j
437 
438  // V_d' Row:
444 
445  // V_s' Row:
451 #endif
452 
453  ////////////////////////////////////////////////////////////////////
454  // 3f5 State Variables & related quantities:
455  // voltage drops
456  double vbd;
457  double vbs;
458  double vgs;
459  double vds;
460 
461  // "original" versions of various voltage drop variables:
462  double vgs_orig;
463  double vds_orig;
464  double vbs_orig;
465  double vbd_orig;
466  double vgd_orig;
467 
468  // "old" versions of various voltage drop variables:
469  double vgs_old;
470  double vds_old;
471  double vbs_old;
472  double vbd_old;
473  double vgd_old;
474 
475 
476  // meyer capacitances
477  //gate-source capacitor
478  double capgs; //value
479  double qgs; // charge
480  // gate-drain capacitor
481  double capgd; //value
482  double qgd; //charge
483  //gate-bulk capacitor
484  double capgb; //value
485  double qgb; //charge
486 
487  // diode capacitances
488  double qbd; // bulk-drain capacitor charge
489  double qbs; // bulk-source capacitor charge
490 
491  // indices into the state vector.
497 
498  // place in store vec for lead currents.
503 
507 
511 
514 
515  int blockHomotopyID; // For homotopy
516  double randomPerturb; // For homotopy
517 };
518 
519 
520 //-----------------------------------------------------------------------------
521 // Class : Model
522 // Purpose :
523 // Special Notes :
524 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
525 // Creation Date : 3/16/00
526 //-----------------------------------------------------------------------------
527 class Model : public DeviceModel
528 {
529  typedef std::vector<Instance *> InstanceVector;
530 
531  friend class ParametricData<Model>;
532  friend class Instance;
533  friend class Traits;friend class Master;
534 
535 public:
536  Model(
537  const Configuration & configuration,
538  const ModelBlock & MB,
539  const FactoryBlock & factory_block);
540  ~Model();
541 
542 private:
543  Model();
544  Model(const Model &);
545  Model &operator=(const Model &);
546 
547 public:
548  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
549 
550  virtual std::ostream &printOutInstances(std::ostream &os) const;
551 
552  bool processParams ();
553  bool processInstanceParams ();
554 
555 
556 public:
557  void addInstance(Instance *instance)
558  {
559  instanceContainer.push_back(instance);
560  }
561 
562 private:
563  std::vector<Instance*> instanceContainer;
564 
565 private:
566 
567  int dtype; // device type : 1 = nmos, -1 = pmos
568  double model_l; // the length of the channel region
569  double model_w; // the width of the channel region
570  double tnom; // temperature at which parameters measured
571  double latDiff;
572  double jctSatCurDensity; // input - use tSatCurDens
573  double jctSatCur; // input - use tSatCur instead
577  double transconductance; // input - use tTransconductance
582  double vt0; // input - use tVto
583  double capBD; // input - use tCbs
584  double capBS; // input - use tCbd
585  double bulkCapFactor; // input - use tCj
586  double sideWallCapFactor; // input - use tCjsw
587  double bulkJctPotential; // input - use tBulkPot
591  double phi; // input - use tPhi
592  double gamma;
594  int gateType;
597  double surfaceMobility; // input - use tSurfMob
599  double eta;
601  double coeffDepLayWidth; // xd
602  double narrowFactor; // delta
603  double delta; // input delta
604  double fastSurfaceStateDensity; // nfs
605  double theta; // theta
606  double maxDriftVel; // vmax
607  double alpha; // alpha
608  double kappa; // kappa
609  double fNcoef;
610  double fNexp;
611 
612  bool capBDGiven ;
613  bool capBSGiven ;
616 
617  // These variables were used as temporaries in mos3temp, but since
618  // the calculations in mos3temp are split between the model block
619  // constructor and the function updateTemperature, we need them to be
620  // model variables.
621 
622  double fact1;
623  double vtnom;
624  double egfet1;
625  double pbfact1;
626 };
627 
628 //-----------------------------------------------------------------------------
629 // Function : Instance:isConverged ()
630 // Purpose : Return whether a MOSFET device has done something that
631 // should be interpreted as invalidating other convergence
632 // tests
633 // In case of mos3, just do it if the limiter function
634 // pnjlim changed anything.
635 // This actually agrees with how the Check flag
636 // is used in Spice3F5 mos3load.c
637 // Special Notes :
638 // Scope : public
639 // Creator : Tom Russo, SNL, Component Information and Models
640 // Creation Date : 03/22/05
641 //-----------------------------------------------------------------------------
643 {
644  return (!limitedFlag);
645 }
646 
647 //-----------------------------------------------------------------------------
648 // Class : Master
649 // Purpose :
650 // Special Notes :
651 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
652 // Creation Date : 11/26/08
653 //-----------------------------------------------------------------------------
654 class Master : public DeviceMaster<Traits>
655 {
656 public:
658  const Configuration & configuration,
659  const FactoryBlock & factory_block,
660  const SolverState & ss1,
661  const DeviceOptions & do1)
662  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
663  {}
664 
665  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
666 
667  // new DAE stuff:
668  // new DAE load functions, residual:
669  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
670 
671  // new DAE load functions, Jacobian:
672  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
673 
674  friend class Instance;
675  friend class Model;
676 };
677 
678 void registerDevice();
679 
680 } // namespace MOSFET3
681 } // namespace Device
682 } // namespace Xyce
683 
684 #endif
static std::vector< std::vector< int > > jacStamp
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
static const char * deviceTypeName()
Definition: N_DEV_MOSFET3.h:70
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
static std::vector< std::vector< int > > jacMap2_DC_SC
Pure virtual class to augment a linear system.
std::vector< Instance * > instanceContainer
static std::vector< std::vector< int > > jacStamp_DC
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
static void loadModelParameters(ParametricData< Model > &model_parameters)
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
void getNoiseSources(Xyce::Analysis::NoiseData &noiseData)
std::vector< Instance * > InstanceVector
Model & operator=(const Model &)
static const char * name()
Definition: N_DEV_MOSFET3.h:69
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
DeviceMaster instantiates a device as described by the device traits T.
bool processParams()
processParams
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual std::ostream & printOutInstances(std::ostream &os) const
void addInstance(Instance *instance)
static std::vector< std::vector< int > > jacStamp_DC_SC
bool updateTemperature(const double &temp_tmp)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static std::vector< std::vector< int > > jacMap2
static std::vector< int > jacMap
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
Class Configuration contains device configuration data.
void setupNoiseSources(Xyce::Analysis::NoiseData &noiseData)
static std::vector< int > jacMap_SC
static std::vector< std::vector< int > > jacStamp_SC
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
static std::vector< int > jacMap_DC_SC
Instance & operator=(const Instance &)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static std::vector< int > jacMap_DC
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
const std::vector< std::vector< int > > & jacobianStamp() const
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
static std::vector< std::vector< int > > jacMap2_SC
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_MOSFET3.C:76
static std::vector< std::vector< int > > jacMap2_DC
bool processInstanceParams()
processInstanceParams