Xyce  6.1
N_DEV_MOSFET2.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_MOSFET2.h,v $
27 //
28 // Purpose : Level 2 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.55.2.1 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:20:11 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_MOSFET2_h
48 #define Xyce_N_DEV_MOSFET2_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 MOSFET2 {
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 2";}
70  static const char *deviceTypeName() {return "M level 2";}
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  // iterator reference to the model which owns this instance.
143  // Getters and setters
145  {
146  return model_;
147  }
148 
149 private:
150  static std::vector< std::vector<int> > jacStamp_DC_SC;
151  static std::vector< std::vector<int> > jacStamp_DC;
152  static std::vector< std::vector<int> > jacStamp_SC;
153  static std::vector< std::vector<int> > jacStamp;
154 
155  static std::vector<int> jacMap_DC_SC;
156  static std::vector<int> jacMap_DC;
157  static std::vector<int> jacMap_SC;
158  static std::vector<int> jacMap;
159 
160  static std::vector< std::vector<int> > jacMap2_DC_SC;
161  static std::vector< std::vector<int> > jacMap2_DC;
162  static std::vector< std::vector<int> > jacMap2_SC;
163  static std::vector< std::vector<int> > jacMap2;
164 
165 
166  Model & model_; //< Owning model
167 
168  // instance variables ripped -- bleeding and without anesthetic -- from
169  // 3f5, with obvious modifications to names (remove MOS1 prefix)
170  int states; // index into state table for this device
171  int dNode; // number of the gate node of the mosfet
172  int gNode; // number of the gate node of the mosfet
173  int sNode; // number of the source node of the mosfet
174  int bNode; // number of the bulk node of the mosfet
175  int dNodePrime; // number of the internal drain node of the mosfet
176  int sNodePrime; // number of the internal source node of the mosfet
177 
178 
179  bool OFF; // device initialized OFF (vbs=vgs=vds=0)
180 
181  double l; // the length of the channel region
182  double w; // the width of the channel region
183  double drainArea; // the area of the drain diffusion
184  double sourceArea; // the area of the source diffusion
185  double drainSquares; // the length of the drain in squares
186  double sourceSquares; // the length of the source in squares
189  double sourceConductance; //conductance of source(or 0):set in setup
190  double drainConductance; //conductance of drain(or 0):set in setup
191  double temp; // operating temperature of this instance
192  double numberParallel; // number simulated parallel mosfets
193 
194  double tTransconductance; // temperature corrected transconductance
195  double tSurfMob; // temperature corrected surface mobility
196  double tPhi; // temperature corrected Phi
197  double tVto; // temperature corrected Vto
198  double tSatCur; // temperature corrected saturation Cur.
199  double tSatCurDens; // temperature corrected saturation Cur. density
200  double tCbd; // temperature corrected B-D Capacitance
201  double tCbs; // temperature corrected B-S Capacitance
202  double tCj; // temperature corrected Bulk bottom Capacitance
203  double tCjsw; // temperature corrected Bulk side Capacitance
204  double tBulkPot; // temperature corrected Bulk potential
205  double tDepCap; // temperature adjusted transition point in
206  // the cureve matching Fc * Vj
207  double tVbi; // temperature adjusted Vbi
208 
209  double icVBS; // initial condition B-S voltage
210  double icVDS; // initial condition D-S voltage
211  double icVGS; // initial condition G-S voltage
212  double von;
213  double vdsat;
214  double sourceVcrit; // vcrit for pos. vds
215  double drainVcrit; // vcrit for neg. vds
216  double cd;
217  double cbs;
218  double cbd;
219  double gmbs;
220  double gm;
221  double gds;
222  double gbd;
223  double gbs;
224  double capbd;
225  double capbs;
226  double Cbd;
227  double Cbdsw;
228  double Cbs;
229  double Cbssw;
230  double f2d;
231  double f3d;
232  double f4d;
233  double f2s;
234  double f3s;
235  double f4s;
236  int mode; // device mode : 1 = normal, -1 = inverse
237  double mode_low;
238  double mode_high;
239 
240  bool limitedFlag; // for convergence testing.
241  bool IC_GIVEN;
242 
243  //end of 3f5 outtakes
244 
245  ////////////////////////////////////////////////////////////////////
246  // these are intermediate variables added to the instance class instead
247  // of leaving them to be calculated repeatedly in the load function
248 
249  // some caluclated quantities
251  double DrainSatCur;
252  double SourceSatCur;
256  double OxideCap;
257 
258  // Solution variables and intermediate quantities
259  // drain,source,gate, bulk, drainprime and sourceprime voltages
260  double Vd;
261  double Vs;
262  double Vg;
263  double Vb;
264  double Vdp;
265  double Vsp;
266  // voltage drops between pairs of nodes
267  double Vddp; // drain-drain'
268  double Vssp; // source-source'
269  double Vbsp; // bulk-source'
270  double Vbdp; // bulk-drain'
271  double Vgsp; // gate-source'
272  double Vgdp; // gate-drain'
273  double Vgb; //gate-bulk
274  double Vdpsp; //drop across channel
275 
276  // the gate-drain voltage drop isn't actually a state variable, but it
277  // is calculated at the same time and in the same manner as the state
278  // vars. So here we go, sticking it in the instance class.
279  double vgd;
280 
281  // Some stuff from mos1temp that were local vars but used elsewhere
282  double vt; // set in updateTemperature to CONSTKoverQ*temp
283 
284 
285  // the variables capgs, capgd and capgb are the raw output of
286  // qmeyer. They get massaged into total capacitances in
287  // updateIntermediateVars, and get used in updatePrimaryState to get
288  // charges on the capacitors.
289 
290  double Capgs; // total gate-source capacitance
291  double Capgd; // total gate-drain capacitance
292  double Capgb; // total gate-bulk capacitance
293 
294  // current through source and drain resistors
295  double Isource;
296  double Idrain;
297 
298  double cdrain; // the channel current shouldn't be a local variable in */
299  // updateIntermediateVars!
300 
301  // these are calculated in loadRHS and used in the jacobian load
302  double Gm,Gmbs; // we do this so we don't really need the xnrm/xrev vars
303  double revsum; // described in comments at the end of
304  double nrmsum; // updateIntermediateVars (uIVB in remaining comments)
305  double cdreq;
306 
307  // end of intermediate variables that aren't state variables
308  ////////////////////////////
309  //
310  // vector indices
311  int li_Drain;
315  int li_Gate;
316  int li_Bulk;
317 
318  ////////////////////////////////////////////////////////////////////
319  // The following verbatim from Level=2, which has the same jacobian
320  // structure
321  ////////////////////////////////////////////////////////////////////
322  // Jacobian matrix indices:
323  // This is a 6x6 matrix block, of which 22 entries are nonzero:
324  //
325  // ---------------------------------------------------------
326  // | #NZ | | |
327  // | entries | | V_d V_g V_s V_b V_d' V_s' |
328  // ---------------------------------------------------------
329  // | 2 | KCL_d | a b |
330  // | 4 | KCL_g | c d e f |
331  // | 2 | KCL_s | g h |
332  // | 4 | KCL_b | i j k l |
333  // | 5 | KCL_d'| m n o p q |
334  // | 5 | KCL_s'| r s t u v |
335  // ---------------------------------------------------------
336  // 22 total
337 
338  ////////////////////////////////////////////////////////////////////
339  // Offset variables corresponding to the above declared indices.
340 
341  // Jacobian Matrix Offset:
342 
343  // V_d Row:
346 
347  // V_g Row:
352 
353  // V_s Row:
356 
357  // V_b Row:
362 
363  // V_d' Row:
369 
370  // V_s' Row:
376 
377  // Jacobian Matrix Pointers:
378 
379 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
380  // F-vector pointers:
381  // V_d Row:
382  double * f_DrainEquDrainNodePtr; // a
384 
385  // V_g Row:
386  double * f_GateEquGateNodePtr; // c
387  double * f_GateEquBulkNodePtr; // d
390 
391  // V_s Row:
394 
395  // V_b Row:
396  double * f_BulkEquGateNodePtr; // i
397  double * f_BulkEquBulkNodePtr; // j
400 
401  // V_d' Row:
407 
408  // V_s' Row:
414 
415  // Q-vector pointers:
416  // V_d Row:
417  double * q_DrainEquDrainNodePtr; // a
419 
420  // V_g Row:
421  double * q_GateEquGateNodePtr; // c
422  double * q_GateEquBulkNodePtr; // d
425 
426  // V_s Row:
429 
430  // V_b Row:
431  double * q_BulkEquGateNodePtr; // i
432  double * q_BulkEquBulkNodePtr; // j
435 
436  // V_d' Row:
442 
443  // V_s' Row:
449 #endif
450  ////////////////////////////////////////////////////////////////////
451  // 3f5 State Variables & related quantities:
452  // voltage drops
453  double vbd;
454  double vbs;
455  double vgs;
456  double vds;
457 
458  // "original" versions of various voltage drop variables:
459  double vgs_orig;
460  double vds_orig;
461  double vbs_orig;
462  double vbd_orig;
463  double vgd_orig;
464 
465  // "old" versions of various voltage drop variables:
466  double vgs_old;
467  double vds_old;
468  double vbs_old;
469  double vbd_old;
470  double vgd_old;
471 
472  // int newtonIter; // the Device class now has this, manager sets it.
473 
474  // meyer capacitances
475  //gate-source capacitor
476  double capgs; //value
477  double qgs; // charge
478  // gate-drain capacitor
479  double capgd; //value
480  double qgd; //charge
481  //gate-bulk capacitor
482  double capgb; //value
483  double qgb; //charge
484 
485  // diode capacitances
486  double qbd; // bulk-drain capacitor charge
487  double qbs; // bulk-source capacitor charge
488 
489  // indices into the state vector.
495 
496  // place in store vec for lead currents.
501 
505 
509 
512 
513  int blockHomotopyID; // For homotopy
514  double randomPerturb; // For homotopy
515 };
516 
517 
518 //-----------------------------------------------------------------------------
519 // Class : Model
520 // Purpose :
521 // Special Notes :
522 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
523 // Creation Date : 3/16/00
524 //-----------------------------------------------------------------------------
525 class Model : public DeviceModel
526 {
527  typedef std::vector<Instance *> InstanceVector;
528 
529  friend class ParametricData<Model>;
530  friend class Instance;
531  friend class Traits;friend class Master;
532 
533 public:
534  Model(
535  const Configuration & configuration,
536  const ModelBlock & MB,
537  const FactoryBlock & factory_block);
538  ~Model();
539 
540 private:
541  Model();
542  Model(const Model &);
543  Model &operator=(const Model &);
544 
545 public:
546  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
547 
548  virtual std::ostream &printOutInstances(std::ostream &os) const;
549 
550  bool processParams ();
551  bool processInstanceParams ();
552 
553 
554 public:
555  void addInstance(Instance *instance)
556  {
557  instanceContainer.push_back(instance);
558  }
559 
560 private:
561  std::vector<Instance*> instanceContainer;
562 
563 private:
564 
565  int dtype; // device type : 1 = nmos, -1 = pmos
566  double model_l; // the length of the channel region
567  double model_w; // the width of the channel region
568  double tnom; // temperature at which parameters measured
569  double latDiff;
570  double jctSatCurDensity; // input - use tSatCurDens
571  double jctSatCur; // input - use tSatCur instead
575  double transconductance; // input - use tTransconductance
580  double vt0; // input - use tVto
581  double capBD; // input - use tCbs
582  double capBS; // input - use tCbd
583  double bulkCapFactor; // input - use tCj
584  double sideWallCapFactor; // input - use tCjsw
585  double bulkJctPotential; // input - use tBulkPot
589  double phi; // input - use tPhi
590  double gamma;
591  double lambda;
593  int gateType;
596  double surfaceMobility; // input - use tSurfMob
598  double fNcoef;
599  double fNexp;
600 
601  bool capBDGiven ;
602  bool capBSGiven ;
605 
606  // These variables were used as temporaries in mos1temp, but since
607  // the calculations in mos1temp are split between the model block
608  // constructor and the function updateTemperature, we need them to be
609  // model variables.
610 
611  double fact1;
612  double vtnom;
613  double egfet1;
614  double pbfact1;
615 
616  // level-2 vars
617  double xd;
620  double critField;
621  double critFieldExp;
622  double maxDriftVel;
624  double narrowFactor;
625 };
626 
627 //-----------------------------------------------------------------------------
628 // Function : Instance:isConverged ()
629 // Purpose : Return whether a MOSFET device has done something that
630 // should be interpreted as invalidating other convergence
631 // tests
632 // In case of mos1, just do it if the limiter function
633 // pnjlim changed anything.
634 // This actually agrees with how the Check flag
635 // is used in Spice3F5 mos1load.c
636 // Special Notes :
637 // Scope : public
638 // Creator : Tom Russo, SNL, Component Information and Models
639 // Creation Date : 03/22/05
640 //-----------------------------------------------------------------------------
642 {
643  return (!limitedFlag);
644 }
645 
646 //-----------------------------------------------------------------------------
647 // Class : Master
648 // Purpose :
649 // Special Notes :
650 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
651 // Creation Date : 11/26/08
652 //-----------------------------------------------------------------------------
653 class Master : public DeviceMaster<Traits>
654 {
655  friend class Instance;
656  friend class Model;
657 
658 public:
660  const Configuration & configuration,
661  const FactoryBlock & factory_block,
662  const SolverState & ss1,
663  const DeviceOptions & do1)
664  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
665  {}
666 
667  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
668 
669  // new DAE stuff:
670  // new DAE load functions, residual:
671  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
672 
673  // new DAE load functions, Jacobian:
674  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
675 };
676 
677 void registerDevice();
678 
679 } // namespace MOSFET2
680 } // namespace Device
681 } // namespace Xyce
682 
683 #endif
684 
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
void getNoiseSources(Xyce::Analysis::NoiseData &noiseData)
const std::vector< std::vector< int > > & jacobianStamp() const
virtual std::ostream & printOutInstances(std::ostream &os) const
bool updateTemperature(const double &temp_tmp)
static const char * deviceTypeName()
Definition: N_DEV_MOSFET2.h:70
Instance & operator=(const Instance &)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Pure virtual class to augment a linear system.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
std::vector< Instance * > InstanceVector
std::vector< Instance * > instanceContainer
Model & operator=(const Model &)
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.
DeviceMaster instantiates a device as described by the device traits T.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
static std::vector< int > jacMap_DC
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
static void loadModelParameters(ParametricData< Model > &model_parameters)
static std::vector< std::vector< int > > jacStamp_DC
static std::vector< std::vector< int > > jacStamp_SC
static std::vector< std::vector< int > > jacStamp
static std::vector< int > jacMap
static std::vector< std::vector< int > > jacMap2_DC
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
static std::vector< int > jacMap_SC
static std::vector< int > jacMap_DC_SC
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void setupNoiseSources(Xyce::Analysis::NoiseData &noiseData)
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
static std::vector< std::vector< int > > jacMap2
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_MOSFET2.C:70
Class Configuration contains device configuration data.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
static std::vector< std::vector< int > > jacMap2_SC
static std::vector< std::vector< int > > jacStamp_DC_SC
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.
bool processInstanceParams()
processInstanceParams
void addInstance(Instance *instance)
bool processParams()
processParams
static std::vector< std::vector< int > > jacMap2_DC_SC
static const char * name()
Definition: N_DEV_MOSFET2.h:69