微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > RFIC设计学习交流 > veriloga 的Bjt如何使用 ? 那可以宣告npn pnp ?

veriloga 的Bjt如何使用 ? 那可以宣告npn pnp ?

时间:10-02 整理:3721RD 点击:

veriloga 的Bjt如何使用
? 那可以宣告npn
pnp?


bjt.v file
/*Copyright 2002-2005 Tiburon Design Automation, Inc. All rights reserved.This software has been provided pursuant to a License Agreementcontaining restrictions on its use.This software containsvaluable trade secrets and proprietary information ofTiburon Design Automation, Inc. and is protected by law.It maynot be copied or distributed in any form or medium, disclosedto third parties, reverse engineered or used in any manner notprovided for in said License Agreement except with the priorwritten authorization from Tiburon Design Automation, Inc.Verilog-A definition of SPICE Gummel-Poon$RCSfile: bjt.va,v $ $Revision: 1.11 $ $Date: 2006/07/04 07:02:14 $*/`include "constants.vams" `include "disciplines.vams" `include "compact.vams"`define INCLUDE_LEAD_INDUCTANCE //`define INCLUDE_DELAY `define USE_EXCESS_PHASE // `define THREE_TERMINALS`define PI_SQ_242.43170840742// = 24 / pi / pi `define PI_SQ_144 14.5902504445// = 144 / pi / pi`define ZERO_TO_INF(paramValue, varName, infinity) \if (paramValue == 0.0) \varName = infinity;\else \varName = paramValue`ifdef THREE_TERMINALS module bjt_va(c,b,e); `else module bjt_va(c,b,e,s); `endif// %%DEVICE_CLASS=BJT4(NPN,PNP)%%`ifdef THREE_TERMINALSinout c,b,e; `elseinout c,b,e,s; `endifelectrical c,b,e,s;electrical ci,bi,ei;`define max_arg 80analog function realexp_soft;input x;realx;beginif (x < `max_arg)exp_soft = exp(x);elseexp_soft = (x + 1 - `max_arg) * exp(`max_arg);endendfunction//Ordering of parameters is basically the same as SPICEparameter real Area = 1 from (0.0:inf]; // Area scaling factorparameter real Temp = `NOT_GIVEN;// Device temperature override [C]parameter real Is = 1e-16 from (0.0:inf]; // Transport saturation current [A]parameter real Bf = 100 from (0.0:inf]; // Ideal max fwd betaparameter real Nf = 1.0 from (0.0:inf]; // Forward current emission coeffparameter real Vaf = 1e9 from [0.0:inf]; // Forward early voltage [v]parameter real Ikf = 1e9 from (0.0:inf]; // Forward beta high-current roll-off [A]parameter real Ise = 0 from [0.0:inf]; // B-E leakage current [A]parameter real Ne = 1.5 from (0.0:inf]; // B-E p-n leakage emission coeffparameter real Br = 1.0 from (0.0:inf]; // Ideal max rev betaparameter real Nr = 1.0 from (0.0:inf]; // Reverse current emission coeffparameter real Var = 1e9 from [0.0:inf]; // Forward Early voltage [v]parameter real Ikr = 1e9 from (0.0:inf]; // Reverse beta high-current roll-off [A]parameter real Isc = 0 from [0.0:inf]; // B-C leakage current [A]parameter real Nc = 2.0 from (0.0:inf]; // B-C p-n leakage emission coeffparameter real Rb = 0.0 from [0.0:inf]; // Zero-bias maximum base resistance [Ohm]parameter real Irb = 1e9 from [0.0:inf]; // Current where Rb falls halfway [A]parameter real Rbm = Rb from [0.0:inf]; // Zero-bias minimum base res (def=Rb) [Ohm]parameter real Re = 0.0 from [0.0:inf]; // Emitter ohmic resistance [Ohm]parameter real Rc = 0.0 from [0.0:inf]; // Collector ohmic resistance [Ohm]parameter real Cje = 0.0 from [0.0:inf]; // B-E zero-bias p-n cap [F]parameter real Vje = 0.75 from [0.0:inf]; // B-E built-in potential [v]parameter real Mje = 0.33 from (0.0:inf]; // B-E p-n grading factorparameter real Cjc = 0.0 from [0.0:inf]; // B-C zero-bias p-n cap [F]parameter real Vjc = 0.75 from [0.0:inf]; // B-C built-in potential [v]parameter real Mjc = 0.33 from (0.0:inf]; // B-C p-n grading factorparameter real Xcjc = 1.0 from [0.0:inf]; // Fraction of Cjc connected to Rbparameter real Cjs = 0.0 from [0.0:inf]; // C-S zero-bias p-n cap [F]parameter real Vjs = 0.75 from [0.0:1e9]; // Substrate built-in potential [v]parameter real Mjs = 0.0 from [0.0:inf]; // Substrate p-n grading factorparameter real Fc = 0.5 from (0.0:inf]; // Forward bias depletion cap coeff.parameter real Xtf = 0.0 from [0.0:inf]; // Transit time bias coeffparameter real Tf = 0.0 from [0.0:inf]; // Ideal forward transit time parameter real Vtf = 1e9 from [0.0:inf]; // Transit time dependency on Vbe [v]parameter real Itf = 0 from [0.0:inf]; // Transit time dependence on Ic [A]parameter real Ptf = 0.0 from [0.0:inf]; // Excess phase at 1/(2*pi*TF), degreesparameter real Tr = 0.0 from [0.0:inf]; // Ideal reverse transit time parameter real Kf = 0 from [0.0:inf]; // Flicker noise coeffparameter real Af = 1 from (0.0:inf]; // Flicker noise exponentparameter real Iss = 0 from [0.0:inf]; // Unused: Substrate P-N staturation current [A]parameter real Ns = 1.0 from (0.0:inf]; // Unused: Substrate p-n emission coeffparameter real Nk = 0.5 from (0.0:inf]; // High current roll-off coeffparameter real Tnom = `DEFAULT_TNOM from (-`P_CELSIUS0:inf); // Param meas temp [C]parameter real Eg = 1.11 from [0.0:inf]; // Bandgap voltage [eV]parameter real Xtb = 0.0 from [0.0:inf]; // Fwd and rev beta temp coeffparameter real Xti = 3.0 from [0.0:inf]; // IS temperature effect exponentparameter integer RbModel= 1 from [0:1]; // MDS=0 SPICE/LIBRA=1// The following parameters are ignored but are used to allow easy// use in some simulators.parameter real Imax= 1e3; // Ignored!parameter real Ab= 0; // Ignored!parameter real Fb= 0; // Ignored!parameter real Ffe= 0; // Ignored!parameter integer Lateral= 0; // Ignored!parameter integer Approxqb= 0; // Ignored!parameter integer Mode= 0; // Ignored!parameter integer Noise= 0; // Ignored!`ifdef INCLUDE_DELAYparameter real Delay = 0 from [0.0:inf]; // delay of Ice(Vbe) `endifparameter integer NPN = 1 from [0:1];parameter integer PNP = 0 from [0:1];`ifdef INCLUDE_LEAD_INDUCTANCEparameter real Lb = 0 from [0:inf]; // Base inductance [H]parameter real Lc = 0 from [0:inf]; // Collector inductance [H]parameter real Le = 0 from [0:inf]; // Emitter inductance [H] `endifreal Vbe, Vbi, Vt, Vbcx, Vbci, Vcs;real Ib, Ibe1, Ibe2, Ibc1, Ibc2, i_rb, Ic, rb;real vaf, var, vtf, Vtn;real Kq1, Kq2, Kqb;real Qje, Qbe, Qbc, Qjcx, Qjs;real x, tanx, Type;real tff, t0, t1, t2, t3;real T, EG_T, IS_T, ISE_T, ISC_T, BF_T, BR_T;real T_NOM;real Cjc_1, Cjc_2, Cjc0, Qjc0, Qjc, fcpe, fcpc;real Cje_1, Cje_2, Cje0, Qje0, vdiff;real Cjs_1, Cjs0, Qjs0;real T0, T1, Jrb, Ib_Jrb;real ratioT; `ifdef USE_EXCESS_PHASEreal Delay; `endifanalog function real IS_of_T;input IS, ratioT, EG, Vth, XTI;realIS, ratioT, EG, Vth, XTI;beginIS_of_T = IS * exp((ratioT - 1) * EG / Vth)* pow(ratioT, XTI);endendfunction // IS_Tanalog function real I_of_T;input IS, ratioT, EG, N, Vth, XTI, XTB;realIS, ratioT, EG, N, Vth, XTI, XTB;beginI_of_T = IS / pow(ratioT, XTB) * exp( ( ratioT - 1)* EG / (N * Vth)) * pow(ratioT, XTI/N);endendfunction // I_of_Tanalog function real B_of_T;input B, ratioT, XTB;real B, ratioT, XTB;beginB_of_T = B * pow(ratioT, XTB);endendfunction // B_of_Tanalog function real EG_of_T;input T;real T;beginEG_of_T = 1.16- 0.000702 * T * T / (T + 1108);endendfunction // EG_of_Tanalog beginif (Temp == `NOT_GIVEN)T = $temperature;elseT = Temp + `P_CELSIUS0;Vt = $vt(T);// Some simulators use allow variables to 0 to mean inf`ZERO_TO_INF(Vaf, vaf, 1.0e9);`ZERO_TO_INF(Var, var, 1.0e9);`ZERO_TO_INF(Vtf, vtf, 1.0e9);T_NOM = Tnom + `P_CELSIUS0;ratioT = T / T_NOM;EG_T = EG_of_T(T);IS_T = IS_of_T(Is, ratioT, EG_T, Vt, Xti);ISE_T = I_of_T(Ise, ratioT, EG_T, Ne, Vt, Xti, Xtb);ISC_T = I_of_T(Isc, ratioT, EG_T, Nc, Vt, Xti, Xtb);BF_T = B_of_T(Bf, ratioT, Xtb);BR_T = B_of_T(Br, ratioT, Xtb);`SET_TYPE(NPN,PNP,Type);if (Type == 0)Type = 1;Vbe = Type * V(bi, ei);Vbci = Type * V(bi, ci);Vbcx = Type * V(b, ci);Vcs = Type * V(ci, s);Vbi = Type * V(b, bi);Vtn = Vt * Nf;if (Vbe > -5 * Vtn) beginIbe1 = IS_T* (exp_soft(Vbe / (Nf * Vt)) - 1);Ibe2 = ISE_T * (exp_soft(Vbe / (Ne * Vt)) - 1);endelse beginIbe1 = - IS_T + `SPICE_GMIN * Vbe;Ibe2 = - ISE_T;endVtn = Vt * Nc;if (Vbci > -5 * Vtn) beginIbc1 = IS_T* (exp_soft(Vbci / (Nr * Vt)) - 1);Ibc2 = ISC_T * (exp_soft(Vbci / (Nc * Vt)) - 1);endelse beginIbc1 = - IS_T + `SPICE_GMIN * Vbci;Ibc2 = - ISC_T;endKq1 = 1 / (1 - Vbci / vaf - Vbe / var);Kq2 = Ibe1 / Ikf + Ibc1 / Ikr;Kqb = Kq1 * (1 + pow(1 + 4 * Kq2, Nk)) / 2;if (Irb == 1e9 || Irb == 0) beginrb = (Rbm + (Rb - Rbm) / Kqb) / Area;endelse beginIb = Area * (Ibe1/BF_T + Ibe2 + Ibc1/BR_T + Ibc2);if (Ib >= 0) beginJrb = Area * Irb;Ib_Jrb = Ib / Jrb;Ib_Jrb = max(Ib_Jrb, 1e-9);if (RbModel == 0) beginT0 = pow(Ib_Jrb, 0.852);T1= 1.0+3.0*T0;rb=Rbm + (Rb - Rbm)/sqrt(T1);endelse beginT0 = sqrt(1.0 + `PI_SQ_144 * Ib_Jrb);T1 =`PI_SQ_24 * sqrt(Ib_Jrb);x = (-1.0 + T0) / T1;tanx = tan(x);rb = (Rbm + 3.0 * (Rb - Rbm) * (tanx - x) /(x * tanx * tanx)) / Area;endendelserb = Rb / Area;endif (rb)i_rb = Vbi / rb;// Base-emitter diffusionif (Ibe1 + Itf != 0.0) begint0 = Ibe1 / (Ibe1 + Itf);tff = Tf * (1 + Xtf * t0 * t0 * exp_soft(Vbci / (1.44 * vtf)));endelsetff = 0.0;t3 = 1 - Fc;// Calc base-emitter junction capacitanceCje0 = Cje;if (Mje == 1.0) beginCje_1 = Cje0 / t3;Cje_2 = 1.0 / (Vje * t3);Qje0 = Cje0 * Vje* (0.5 + ln(Vje * t3));endelse beginCje_1 = Cje0/pow(t3, Mje);Cje_2 = Mje / (Vje * t3);Qje0= Cje_1 / (2.0 * Cje_2) * (1.0 + Mje) / (1.0 - Mje);endfcpe = Fc * Vje;if (Vbe <= fcpe)beginvdiff = Vje - Vbe;if (Mje == 1.0)Qje = -Cje0 * Vje * ln(vdiff);else if (Mje == 0.5)Qje = -2.0 * vdiff * Cje0 / sqrt(vdiff / Vje);elseQje = -Cje0 * pow(vdiff / Vje, -Mje) * vdiff / (1.0 - Mje);Qje = Qje + Qje0;endelse begint1 = 1.0 + Cje_2 * (Vbe - fcpe);Qje = Cje_1 * t1 * t1 / (2.0 * Cje_2);endQbe = tff * Ibe1 / Kqb + Qje;// Intrinsic base-collector junction capacitanceCjc0 = Cjc;if (Mjc == 1.0) beginCjc_1 = Cjc0 / t3;Cjc_2 = 1.0 / (Vjc * t3);Qjc0= Cjc0 * Vjc * (0.5 + ln(Vjc * t3));endelse beginCjc_1 = Cjc0 / pow(t3, Mjc);Cjc_2 = Mjc / (Vjc * t3);Qjc0= Cjc_1 / (2.0 * Cjc_2) * (1.0 + Mjc) / (1.0 - Mjc);endfcpc = Fc * Vjc;if (Vbci <= fcpc) beginvdiff = Vjc - Vbci;if (Mjc == 1.0)Qjc = -ln(vdiff) * Cjc0 * Vjc;else if (Mjc == 0.5)Qjc = -2.0 * vdiff * Cjc0 / sqrt(vdiff / Vjc);elseQjc = -Cjc0 * pow(vdiff / Vjc, -Mjc) * vdiff / (1.0 - Mjc);Qjc = Qjc + Qjc0;endelse begint1 = 1.0 + Cjc_2 * (Vbci - fcpc);Qjc = Cjc_1 * t1 * t1 / (2.0 * Cjc_2);endQjc = Qjc * Xcjc;// Calc external base-collector junction capacitanceif (Vbcx <= fcpc) beginvdiff = Vjc - Vbcx;if (Mjc == 1.0)Qjcx = -Cjc0 * Vjc *ln(vdiff);else if (Mjc == 0.5)Qjcx = -2.0 * vdiff * Cjc0 / sqrt(vdiff / Vjc);elseQjcx = -Cjc0 * pow(vdiff / Vjc, -Mjc) * vdiff / (1.0 - Mjc);Qjcx = Qjcx + Qjc0;endelse begint1 = 1.0 + Cjc_2 * (Vbcx - fcpc);Qjcx = Cjc_1 * t1 * t1 / (2.0 * Cjc_2);endQjcx = Qjcx * (1.0 - Xcjc) * Area;Qbc = Tr * Ibc1 + Qjc;// Calc substrate junction capacitanceCjs0 = Cjs;Cjs_1 = 0.0;Qjs0 = 0.0;if (Mjs == 1.0) beginCjs_1 = 1.0 / Vjs;Qjs0 = -Cjs0 * Vjs * (0.5 + ln(Vjs));endelse if (Mjs != 0.0) beginCjs_1 = Mjs / Vjs;Qjs0 = -Cjs0 / (2.0 * Cjs_1) * (1.0 + Mjs) / (1.0 - Mjs);endif ( Mjs == 0.0)Qjs = Cjs0 * Vcs;else if (Vcs >= 0.0) begin // (Rev bias)t1 = Vjs + Vcs;if (Mjs == 1.0) begint2 = Cjs0 * Vjs;Qjs = t2 * ln(t1);endelse if (Mjs == 0.5)Qjs = 2.0 * t1 * Cjs0 / sqrt(t1 / Vjs);elseQjs = Cjs0 * pow(t1 / Vjs, -Mjs) * t1 / (1.0 - Mjs);Qjs = Qjs + Qjs0;endelse begin // (Fwd bias)t1 = 1.0 - Cjs_1 * Vcs;Qjs = -Cjs0 * t1 * t1 / (2.0 * Cjs_1);endQjs = Qjs * Area;// Branch contributionsI(bi, ei) <+ Type * Area * (Ibe1/BF_T + ddt(Qbe) + Ibe2);I(bi, ci) <+ Type * Area * (Ibc1/BR_T + ddt(Qbc) + Ibc2);I(b, ci) <+ Type * ddt(Qjcx);I(ci, s) <+ Type * ddt(Qjs);`ifdef THREE_TERMINALSV(s) <+ 0.0; `endif`ifdef INCLUDE_DELAYI(ci, ei) <+ Type * Area * ((absdelay(Ibe1, Delay) - Ibc1) / Kqb);`else `ifdef USE_EXCESS_PHASEDelay = Ptf * Tf * `M_PI / 180;I(ci, ei) <+ Type * Area * ((absdelay(Ibe1, Delay) - Ibc1) / Kqb);`elseI(ci, ei) <+ Type * Area * ((Ibe1 - Ibc1) / Kqb);`endif `endif`ifdef INCLUDE_LEAD_INDUCTANCEV(b, bi) <+ I(b, bi) * rb + Lb * ddt(I(b,bi));V(c, ci) <+ I(c, ci) * (Rc / Area) + Lc * ddt(I(c, ci));V(e, ei) <+ white_noise(4 * `P_K * T * (Re / Area), "Re");V(c, ci) <+ white_noise(4 * `P_K * T * (Rc / Area), "Rc");V(e, ei) <+ I(e, ei) * (Re / Area) + Le * ddt(I(e, ei));`elseV(b, bi) <+ I(b, bi) * rb;// Formulating parasitics in this manner allows for// automatic branch reduction if R=0:if (Rc > 0.0) beginI(c, ci) <+ V(c, ci) / (Rc / Area);I(c, ci) <+ white_noise(4 * `P_K * T / (Rc / Area), "Rc");endelseV(c, ci) <+ 0.0;if (Re > 0.0) beginI(e, ei) <+ V(e, ei) / (Re / Area);I(e, ei) <+ white_noise(4 * `P_K * T / (Re / Area), "Re");endelseV(e, ei) <+ 0.0; `endif// base noiseV(b, bi) <+ white_noise(4 * `P_K * T * rb, "Rb");// Shot and flicker noiseif (Af > 0 && Kf > 0)I(bi, ei) <+ flicker_noise(Kf * pow(Area * abs(i_rb), Af), 1.0,"flicker");I(bi,ei) <+ white_noise(2 * `P_Q * abs(i_rb), "shot");Ic = Ibe1 / Kqb - Ibc1 / Kqb - Ibc1 / Br - Ibc2;I(ci, ei) <+ white_noise(2 * `P_Q * Area * abs(Ic), "shot");end endmodule==

应该和普通的单元调用一样
bjt #(.NPN(1),.PNP(0),...) bjt_instance_name

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top