Jspice3
bjt.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * This file defines the BJT data structures that are
10  * available to the next level(s) up the calling hierarchy
11  */
12 
13 #include "spice.h"
14 #include <stdio.h>
15 #include "bjtdefs.h"
16 #include "uflags.h"
17 
18 static IFparm BJTpTable[] = { /* parameters */
19  IOPU( "area", BJT_AREA, IF_REAL, "Area factor"),
20  IOPU( "off", BJT_OFF, IF_FLAG, "Device initially off"),
21  IOPAU("icvbe", BJT_IC_VBE, IF_REAL, "Initial B-E voltage"),
22  IOPAU("icvce", BJT_IC_VCE, IF_REAL, "Initial C-E voltage"),
23  IP( "ic", BJT_IC, IF_REALVEC, "Initial condition vector"),
24  IOPU( "temp", BJT_TEMP, IF_REAL, "instance temperature"),
25 
26  OPU( "ft", BJT_QUEST_FT, IF_REAL,"Frequency for unity gain"),
27 
28  OPU( "colnode", BJT_QUEST_COLNODE, IF_INTEGER,
29  "Number of collector node"),
30  OPU( "basenode", BJT_QUEST_BASENODE, IF_INTEGER,
31  "Number of base node"),
32  OPU( "emitnode", BJT_QUEST_EMITNODE, IF_INTEGER,
33  "Number of emitter node"),
34  OPU( "substnode", BJT_QUEST_SUBSTNODE, IF_INTEGER,
35  "Number of substrate node"),
36  OPU( "colprimenode", BJT_QUEST_COLPRIMENODE, IF_INTEGER,
37  "Internal collector node"),
38  OPU( "baseprimenode", BJT_QUEST_BASEPRIMENODE, IF_INTEGER,
39  "Internal base node"),
40  OPU( "emitprimenode", BJT_QUEST_EMITPRIMENODE, IF_INTEGER,
41  "Internal emitter node"),
42 
43  OP( "vbe", BJT_QUEST_VBE, IF_REAL,"B-E voltage"),
44  OP( "vbc", BJT_QUEST_VBC, IF_REAL,"B-C voltage"),
45  OP( "ic", BJT_QUEST_CC, IF_REAL,"Current at collector node"),
46  OPR("cc", BJT_QUEST_CC, IF_REAL,"Current at collector node"),
47  OP( "ib", BJT_QUEST_CB, IF_REAL,"Current at base node"),
48  OPR("cb", BJT_QUEST_CB, IF_REAL,"Current at base node"),
49  OP( "gpi", BJT_QUEST_GPI, IF_REAL,"Small signal input conductance - pi"),
50  OP( "gmu", BJT_QUEST_GMU, IF_REAL,"Small signal conductance - mu"),
51  OP( "gm", BJT_QUEST_GM, IF_REAL,"Small signal transconductance"),
52  OP( "go", BJT_QUEST_GO, IF_REAL,"Small signal output conductance"),
53  OPU("qbe", BJT_QUEST_QBE, IF_REAL,"Charge storage B-E junction"),
54  OPU("cqbe", BJT_QUEST_CQBE, IF_REAL,"Cap. due to charge storage in B-E jct."),
55  OPU("qbc", BJT_QUEST_QBC, IF_REAL,"Charge storage B-C junction"),
56  OPU("cqbc", BJT_QUEST_CQBC, IF_REAL,"Cap. due to charge storage in B-C jct."),
57  OPU("qcs", BJT_QUEST_QCS, IF_REAL,"Charge storage C-S junction"),
58  OPU("cqcs", BJT_QUEST_CQCS, IF_REAL,"Cap. due to charge storage in C-S jct."),
59  OPU("qbx", BJT_QUEST_QBX, IF_REAL,"Charge storage B-X junction"),
60  OPU("cqbx", BJT_QUEST_CQBX, IF_REAL,"Cap. due to charge storage in B-X jct."),
61  OP( "gx", BJT_QUEST_GX, IF_REAL,"Conductance from base to internal base"),
62  OPU("cexbc",BJT_QUEST_CEXBC,IF_REAL,"Total Capacitance in B-X junction"),
63  OPU("geqcb",BJT_QUEST_GEQCB,IF_REAL,"d(Ibe)/d(Vbc)"),
64  OPU("gccs", BJT_QUEST_GCCS, IF_REAL,"Internal C-S cap. equiv. cond."),
65  OPU("geqbx",BJT_QUEST_GEQBX,IF_REAL,"Internal C-B-base cap. equiv. cond."),
66  OP( "ie", BJT_QUEST_CE, IF_REAL,"Emitter current"),
67  OPR("ce", BJT_QUEST_CE, IF_REAL,"Emitter current"),
68  OPU("is", BJT_QUEST_CS, IF_REAL,"Substrate current"),
69  OPR("cs", BJT_QUEST_CS, IF_REAL,"Substrate current"),
70  OPU("p", BJT_QUEST_POWER,IF_REAL,"Power dissipation"),
71  OP( "cpi", BJT_QUEST_CPI, IF_REAL,"Internal base to emitter capactance"),
72  OP( "cmu", BJT_QUEST_CMU, IF_REAL,"Internal base to collector capactiance"),
73  OP( "cbx", BJT_QUEST_CBX, IF_REAL,"Base to collector capacitance"),
74  OP( "ccs", BJT_QUEST_CCS, IF_REAL,"Collector to substrate capacitance")
75 };
76 
77 static IFparm BJTmPTable[] = { /* model parameters */
78  IP ("npn", BJT_MOD_NPN, IF_FLAG, "NPN type device"),
79  IP ("pnp", BJT_MOD_PNP, IF_FLAG, "PNP type device"),
80  IOP( "is", BJT_MOD_IS, IF_REAL, "Saturation Current"),
81  IOP( "bf", BJT_MOD_BF, IF_REAL, "Ideal forward beta"),
82  IOP( "nf", BJT_MOD_NF, IF_REAL, "Forward emission coefficient"),
83  IOP( "vaf", BJT_MOD_VAF, IF_REAL, "Forward Early voltage"),
84  IOPR("va", BJT_MOD_VAF, IF_REAL, "Forward Early voltage"),
85  IOP( "ikf", BJT_MOD_IKF, IF_REAL, "Forward beta roll-off corner current"),
86  IOPR("ik", BJT_MOD_IKF, IF_REAL, "Forward beta roll-off corner current"),
87  IOP( "ise", BJT_MOD_ISE, IF_REAL, "B-E leakage saturation current"),
88  IOP( "ne", BJT_MOD_NE, IF_REAL, "B-E leakage emission coefficient"),
89  IOP( "br", BJT_MOD_BR, IF_REAL, "Ideal reverse beta"),
90  IOP( "nr", BJT_MOD_NR, IF_REAL, "Reverse emission coefficient"),
91  IOP( "var", BJT_MOD_VAR, IF_REAL, "Reverse Early voltage"),
92  IOPR("vb", BJT_MOD_VAR, IF_REAL, "Reverse Early voltage"),
93  IOP( "ikr", BJT_MOD_IKR, IF_REAL, "reverse beta roll-off corner current"),
94  IOP( "isc", BJT_MOD_ISC, IF_REAL, "B-C leakage saturation current"),
95  IOP( "nc", BJT_MOD_NC, IF_REAL, "B-C leakage emission coefficient"),
96  IOP( "rb", BJT_MOD_RB, IF_REAL, "Zero bias base resistance"),
97  IOP( "irb", BJT_MOD_IRB, IF_REAL, "Current for base resistance=(rb+rbm)/2"),
98  IOP( "rbm", BJT_MOD_RBM, IF_REAL, "Minimum base resistance"),
99  IOP( "re", BJT_MOD_RE, IF_REAL, "Emitter resistance"),
100  IOP( "rc", BJT_MOD_RC, IF_REAL, "Collector resistance"),
101  IOPA("cje", BJT_MOD_CJE, IF_REAL, "Zero bias B-E depletion capacitance"),
102  IOPA("vje", BJT_MOD_VJE, IF_REAL, "B-E built in potential"),
103  IOPR("pe", BJT_MOD_VJE, IF_REAL, "B-E built in potential"),
104  IOPA("mje", BJT_MOD_MJE, IF_REAL, "B-E junction grading coefficient"),
105  IOPR("me", BJT_MOD_MJE, IF_REAL, "B-E junction grading coefficient"),
106  IOPA("tf", BJT_MOD_TF, IF_REAL, "Ideal forward transit time"),
107  IOPA("xtf", BJT_MOD_XTF, IF_REAL, "Coefficient for bias dependence of TF"),
108  IOPA("vtf", BJT_MOD_VTF, IF_REAL, "Voltage giving VBC dependence of TF"),
109  IOPA("itf", BJT_MOD_ITF, IF_REAL, "High current dependence of TF"),
110  IOPA("ptf", BJT_MOD_PTF, IF_REAL, "Excess phase"),
111  IOPA("cjc", BJT_MOD_CJC, IF_REAL, "Zero bias B-C depletion capacitance"),
112  IOPA("vjc", BJT_MOD_VJC, IF_REAL, "B-C built in potential"),
113  IOPR("pc", BJT_MOD_VJC, IF_REAL, "B-C built in potential"),
114  IOPA("mjc", BJT_MOD_MJC, IF_REAL, "B-C junction grading coefficient"),
115  IOPR("mc", BJT_MOD_MJC, IF_REAL, "B-C junction grading coefficient"),
116  IOPA("xcjc",BJT_MOD_XCJC,IF_REAL, "Fraction of B-C cap to internal base"),
117  IOPA("tr", BJT_MOD_TR, IF_REAL, "Ideal reverse transit time"),
118  IOPA("cjs", BJT_MOD_CJS, IF_REAL, "Zero bias C-S capacitance"),
119  IOPA("ccs", BJT_MOD_CJS, IF_REAL, "Zero bias C-S capacitance"),
120  IOPA("vjs", BJT_MOD_VJS, IF_REAL, "Substrate junction built in potential"),
121  IOPR("ps", BJT_MOD_VJS, IF_REAL, "Substrate junction built in potential"),
122  IOPA("mjs", BJT_MOD_MJS, IF_REAL, "Substrate junction grading coefficient"),
123  IOPR("ms", BJT_MOD_MJS, IF_REAL, "Substrate junction grading coefficient"),
124  IOP( "xtb", BJT_MOD_XTB, IF_REAL, "Forward and reverse beta temp. exp."),
125  IOP( "eg", BJT_MOD_EG, IF_REAL, "Energy gap for IS temp. dependency"),
126  IOP( "xti", BJT_MOD_XTI, IF_REAL, "Temp. exponent for IS"),
127  IOP( "fc", BJT_MOD_FC, IF_REAL, "Forward bias junction fit parameter"),
128  IP( "tnom",BJT_MOD_TNOM,IF_REAL, "Parameter measurement temperature"),
129  IP( "kf", BJT_MOD_KF, IF_REAL, "Flicker Noise Coefficient"),
130  IP( "af", BJT_MOD_AF, IF_REAL, "Flicker Noise Exponent"),
131 
132  OPU( "invearlyvoltf", BJT_MOD_INVEARLYF, IF_REAL,
133  "Inverse early voltage:forward"),
134  OPU( "invearlyvoltr", BJT_MOD_INVEARLYR, IF_REAL,
135  "Inverse early voltage:reverse"),
136  OPU( "invrollofff", BJT_MOD_INVROLLOFFF, IF_REAL,
137  "Inverse roll off - forward"),
138  OPU( "invrolloffr", BJT_MOD_INVROLLOFFR, IF_REAL,
139  "Inverse roll off - reverse"),
140  OPU( "collectorconduct", BJT_MOD_COLCONDUCT, IF_REAL,
141  "Collector conductance"),
142  OPU( "emitterconduct", BJT_MOD_EMITTERCONDUCT,IF_REAL,
143  "Emitter conductance"),
144  OPU( "transtimevbcfact", BJT_MOD_TRANSVBCFACT, IF_REAL,
145  "Transit time VBC factor"),
146  OPU( "excessphasefactor",BJT_MOD_EXCESSPHASEFACTOR,IF_REAL,
147  "Excess phase fact."),
148  OP( "type",BJT_MOD_TYPE,IF_STRING, "NPN or PNP")
149 };
150 
151 static char *BJTnames[] = {
152  "collector",
153  "base",
154  "emitter",
155  "substrate"
156 };
157 
158 static char *BJTmodNames[] = {
159  "npn",
160  "pnp",
161  NULL
162 };
163 
164 static IFkeys BJTkeys[] = {
165  { 'q', NUMELEMS(BJTnames), BJTnames, 1, 0 },
166 };
167 
168 
169 static int BJTkSize = NUMELEMS(BJTkeys);
170 static int BJTpTSize = NUMELEMS(BJTpTable);
171 static int BJTmPTSize = NUMELEMS(BJTmPTable);
172 static int BJTiSize = sizeof(BJTinstance);
173 static int BJTmSize = sizeof(BJTmodel);
174 
175 
177  { "BJT",
178  "Bipolar Junction Transistor",
179 
180  &BJTkSize,
181  BJTkeys,
182  1,
183  BJTmodNames,
184  BJTparse,
185 
186  &BJTpTSize,
187  BJTpTable,
188 
189  &BJTmPTSize,
190  BJTmPTable
191  },
192 
193  BJTparam,
194  BJTmParam,
195  BJTload,
196  BJTsetup,
197  BJTsetup,
198  BJTtemp,
199  BJTtrunc,
200  NULL,
201  BJTacLoad,
202  NULL,
203  GENdestroy,
204  GENmDelete,
205  GENdelete,
206  BJTgetic,
207  BJTask,
208  BJTmAsk,
209  BJTpzLoad,
210  BJTconvTest,
211  BJTdisto,
212  BJTnoise,
213 
214  &BJTiSize,
215  &BJTmSize
216 };
int BJTmAsk()
#define BJT_QUEST_CQBE
Definition: bjtdefs.h:439
#define BJT_MOD_IS
Definition: bjtdefs.h:379
#define BJT_MOD_MJC
Definition: bjtdefs.h:407
#define BJT_MOD_EXCESSPHASEFACTOR
Definition: bjtdefs.h:467
#define BJT_MOD_EG
Definition: bjtdefs.h:414
#define BJT_MOD_XTB
Definition: bjtdefs.h:413
#define BJT_MOD_VJS
Definition: bjtdefs.h:411
#define BJT_MOD_TYPE
Definition: bjtdefs.h:468
#define BJT_QUEST_CQBX
Definition: bjtdefs.h:445
#define BJT_QUEST_GX
Definition: bjtdefs.h:446
#define BJT_MOD_TR
Definition: bjtdefs.h:409
#define IOP(a, b, c, d)
Definition: devdefs.h:120
#define BJT_AREA
Definition: bjtdefs.h:369
#define BJT_MOD_NPN
Definition: bjtdefs.h:377
#define BJT_QUEST_GEQBX
Definition: bjtdefs.h:450
static int BJTkSize
Definition: bjt.c:169
#define OPU(a, b, c, d)
Definition: uflags.h:65
#define NUMELEMS(ARRAY)
Definition: spice.h:157
#define BJT_MOD_NE
Definition: bjtdefs.h:385
#define BJT_QUEST_VBE
Definition: bjtdefs.h:430
#define BJT_MOD_INVEARLYF
Definition: bjtdefs.h:460
void BJTparse()
#define BJT_TEMP
Definition: bjtdefs.h:374
#define BJT_MOD_TNOM
Definition: bjtdefs.h:417
#define IOPR(a, b, c, d)
Definition: uflags.h:57
#define BJT_MOD_VJC
Definition: bjtdefs.h:406
#define BJT_QUEST_CEXBC
Definition: bjtdefs.h:447
#define BJT_MOD_TF
Definition: bjtdefs.h:400
#define BJT_QUEST_GMU
Definition: bjtdefs.h:435
#define BJT_QUEST_FT
Definition: bjtdefs.h:422
#define BJT_MOD_CJS
Definition: bjtdefs.h:410
SPICEdev BJTinfo
Definition: bjt.c:176
void GENdestroy()
#define BJT_MOD_EMITTERCONDUCT
Definition: bjtdefs.h:465
#define BJT_QUEST_GPI
Definition: bjtdefs.h:434
#define BJT_MOD_VAR
Definition: bjtdefs.h:388
static IFparm BJTpTable[]
Definition: bjt.c:18
int BJTtrunc()
#define BJT_QUEST_CE
Definition: bjtdefs.h:451
#define BJT_MOD_MJS
Definition: bjtdefs.h:412
#define BJT_MOD_FC
Definition: bjtdefs.h:416
int BJTparam()
int BJTpzLoad()
int BJTconvTest()
#define BJT_MOD_XTI
Definition: bjtdefs.h:415
#define BJT_QUEST_CB
Definition: bjtdefs.h:433
#define BJT_QUEST_BASEPRIMENODE
Definition: bjtdefs.h:428
#define BJT_MOD_NF
Definition: bjtdefs.h:381
static int BJTpTSize
Definition: bjt.c:170
#define BJT_MOD_KF
Definition: bjtdefs.h:419
#define BJT_MOD_RB
Definition: bjtdefs.h:392
#define BJT_QUEST_QBX
Definition: bjtdefs.h:444
int BJTmParam()
#define BJT_MOD_RE
Definition: bjtdefs.h:395
#define BJT_MOD_PTF
Definition: bjtdefs.h:404
#define BJT_QUEST_EMITNODE
Definition: bjtdefs.h:425
#define BJT_MOD_ITF
Definition: bjtdefs.h:403
#define BJT_QUEST_GEQCB
Definition: bjtdefs.h:448
#define BJT_MOD_COLCONDUCT
Definition: bjtdefs.h:464
int BJTask()
#define NULL
Definition: spdefs.h:121
struct sBJTinstance BJTinstance
#define BJT_QUEST_CQBC
Definition: bjtdefs.h:441
#define BJT_QUEST_BASENODE
Definition: bjtdefs.h:424
struct sBJTmodel BJTmodel
#define BJT_MOD_ISE
Definition: bjtdefs.h:384
#define BJT_MOD_XTF
Definition: bjtdefs.h:401
#define IF_INTEGER
Definition: ifsim.h:107
int BJTload()
#define BJT_QUEST_QCS
Definition: bjtdefs.h:442
#define BJT_MOD_IKF
Definition: bjtdefs.h:383
#define OPR(a, b, c, d)
Definition: uflags.h:66
#define BJT_MOD_CJC
Definition: bjtdefs.h:405
static int BJTmPTSize
Definition: bjt.c:171
#define BJT_MOD_IKR
Definition: bjtdefs.h:389
#define BJT_MOD_VJE
Definition: bjtdefs.h:398
#define BJT_MOD_XCJC
Definition: bjtdefs.h:408
static char * BJTnames[]
Definition: bjt.c:151
#define IOPA(a, b, c, d)
Definition: uflags.h:50
static char * BJTmodNames[]
Definition: bjt.c:158
static int BJTmSize
Definition: bjt.c:173
#define BJT_QUEST_COLNODE
Definition: bjtdefs.h:423
#define BJT_MOD_CJE
Definition: bjtdefs.h:397
#define BJT_QUEST_CCS
Definition: bjtdefs.h:457
Definition: ifsim.h:54
Definition: ifsim.h:267
#define BJT_MOD_RBM
Definition: bjtdefs.h:394
#define IF_REAL
Definition: ifsim.h:108
#define IP(a, b, c, d)
Definition: devdefs.h:118
static IFparm BJTmPTable[]
Definition: bjt.c:77
int BJTgetic()
#define BJT_MOD_AF
Definition: bjtdefs.h:418
#define BJT_QUEST_POWER
Definition: bjtdefs.h:453
#define BJT_MOD_INVEARLYR
Definition: bjtdefs.h:461
#define BJT_QUEST_CC
Definition: bjtdefs.h:432
#define BJT_QUEST_VBC
Definition: bjtdefs.h:431
#define IF_FLAG
Definition: ifsim.h:106
int GENmDelete()
#define IF_REALVEC
Definition: ifsim.h:125
int GENdelete()
int BJTacLoad()
#define BJT_QUEST_QBE
Definition: bjtdefs.h:438
int BJTtemp()
#define BJT_MOD_VAF
Definition: bjtdefs.h:382
#define BJT_OFF
Definition: bjtdefs.h:370
#define BJT_MOD_BF
Definition: bjtdefs.h:380
#define BJT_IC_VBE
Definition: bjtdefs.h:371
#define BJT_MOD_NR
Definition: bjtdefs.h:387
#define BJT_QUEST_QBC
Definition: bjtdefs.h:440
#define BJT_QUEST_SUBSTNODE
Definition: bjtdefs.h:426
#define BJT_QUEST_CPI
Definition: bjtdefs.h:454
#define BJT_MOD_VTF
Definition: bjtdefs.h:402
#define BJT_MOD_PNP
Definition: bjtdefs.h:378
#define BJT_QUEST_CQCS
Definition: bjtdefs.h:443
#define IOPAU(a, b, c, d)
Definition: uflags.h:51
#define BJT_MOD_INVROLLOFFR
Definition: bjtdefs.h:463
#define BJT_QUEST_CS
Definition: bjtdefs.h:452
#define BJT_MOD_TRANSVBCFACT
Definition: bjtdefs.h:466
#define BJT_MOD_BR
Definition: bjtdefs.h:386
#define BJT_QUEST_GO
Definition: bjtdefs.h:437
static IFkeys BJTkeys[]
Definition: bjt.c:164
#define BJT_MOD_INVROLLOFFF
Definition: bjtdefs.h:462
#define BJT_IC
Definition: bjtdefs.h:373
int BJTdisto()
#define BJT_MOD_NC
Definition: bjtdefs.h:391
int BJTnoise()
#define BJT_MOD_ISC
Definition: bjtdefs.h:390
#define BJT_QUEST_GM
Definition: bjtdefs.h:436
#define IF_STRING
Definition: ifsim.h:111
#define OP(a, b, c, d)
Definition: devdefs.h:119
#define BJT_QUEST_COLPRIMENODE
Definition: bjtdefs.h:427
#define BJT_MOD_IRB
Definition: bjtdefs.h:393
static int BJTiSize
Definition: bjt.c:172
#define BJT_MOD_RC
Definition: bjtdefs.h:396
#define BJT_MOD_MJE
Definition: bjtdefs.h:399
#define BJT_QUEST_CBX
Definition: bjtdefs.h:456
#define BJT_QUEST_GCCS
Definition: bjtdefs.h:449
int BJTsetup()
#define IOPU(a, b, c, d)
Definition: uflags.h:48
#define BJT_IC_VCE
Definition: bjtdefs.h:372
#define BJT_QUEST_EMITPRIMENODE
Definition: bjtdefs.h:429
#define BJT_QUEST_CMU
Definition: bjtdefs.h:455