在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2452|回复: 3

[求助] veriloga 的Bjt如何使用 ? 那可以宣告npn pnp ?

[复制链接]
发表于 2016-9-8 09:47:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x

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 Agreement  containing restrictions on its use.  This software contains  valuable trade secrets and proprietary information of   Tiburon Design Automation, Inc. and is protected by law.  It may   not be copied or distributed in any form or medium, disclosed   to third parties, reverse engineered or used in any manner not   provided for in said License Agreement except with the prior   written 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_24    2.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_TERMINALS     inout c,b,e; `else     inout c,b,e,s; `endif     electrical c,b,e,s;     electrical ci,bi,ei;  `define max_arg 80        Analog function real  exp_soft;          input x;          real  x;          begin              if (x < `max_arg)                  exp_soft = exp(x);              else                  exp_soft = (x + 1 - `max_arg) * exp(`max_arg);          end      endfunction       //Ordering of parameters is basically the same as SPICE     parameter real Area = 1 from (0.0:inf]; // Area scaling factor     parameter 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 beta     parameter real Nf = 1.0 from (0.0:inf]; // Forward current emission coeff     parameter 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 coeff     parameter real Br = 1.0 from (0.0:inf]; // Ideal max rev beta     parameter real Nr = 1.0 from (0.0:inf]; // Reverse current emission coeff     parameter 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 coeff     parameter 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 factor     parameter 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 factor     parameter real Xcjc = 1.0 from [0.0:inf]; // Fraction of Cjc connected to Rb     parameter 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 factor     parameter 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 coeff      parameter 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), degrees     parameter real Tr = 0.0 from [0.0:inf]; // Ideal reverse transit time      parameter real Kf = 0 from [0.0:inf]; // Flicker noise coeff     parameter real Af = 1 from (0.0:inf]; // Flicker noise exponent     parameter 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 coeff     parameter real Nk = 0.5 from (0.0:inf]; // High current roll-off coeff     parameter 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 coeff      parameter real Xti = 3.0 from [0.0:inf]; // IS temperature effect exponent     parameter 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_DELAY             parameter real Delay = 0 from [0.0:inf]; // delay of Ice(Vbe) `endif          parameter integer NPN = 1 from [0:1];      parameter integer PNP = 0 from [0:1];      `ifdef INCLUDE_LEAD_INDUCTANCE     parameter 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] `endif      real 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_PHASE     real Delay; `endif      analog function real IS_of_T;        input IS, ratioT, EG, Vth, XTI;        real  IS, ratioT, EG, Vth, XTI;        begin            IS_of_T = IS * exp((ratioT - 1) * EG / Vth)                         * pow(ratioT, XTI);        end     endfunction // IS_T               analog function real I_of_T;         input IS, ratioT, EG, N, Vth, XTI, XTB;         real  IS, ratioT, EG, N, Vth, XTI, XTB;         begin             I_of_T = IS / pow(ratioT, XTB) * exp( ( ratioT - 1)                        * EG / (N * Vth)) * pow(ratioT, XTI/N);         end     endfunction // I_of_T       analog function real B_of_T;         input B, ratioT, XTB;         real B, ratioT, XTB;         begin             B_of_T = B * pow(ratioT, XTB);         end     endfunction // B_of_T       analog function real EG_of_T;         input T;         real T;         begin             EG_of_T = 1.16- 0.000702 * T * T / (T + 1108);         end     endfunction // EG_of_T       analog begin           if (Temp == `NOT_GIVEN)             T = $temperature;         else             T = 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) begin              Ibe1 = IS_T  * (exp_soft(Vbe / (Nf * Vt)) - 1);             Ibe2 = ISE_T * (exp_soft(Vbe / (Ne * Vt)) - 1);         end         else begin             Ibe1 = - IS_T + `SPICE_GMIN * Vbe;             Ibe2 = - ISE_T;         end            Vtn = Vt * Nc;         if (Vbci > -5 * Vtn) begin             Ibc1 = IS_T  * (exp_soft(Vbci / (Nr * Vt)) - 1);             Ibc2 = ISC_T * (exp_soft(Vbci / (Nc * Vt)) - 1);         end         else begin             Ibc1 = - IS_T + `SPICE_GMIN * Vbci;             Ibc2 = - ISC_T;          end                    Kq1 = 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) begin             rb = (Rbm + (Rb - Rbm) / Kqb) / Area;            end         else begin             Ib = Area * (Ibe1/BF_T + Ibe2 + Ibc1/BR_T + Ibc2);             if (Ib >= 0) begin                 Jrb = Area * Irb;                 Ib_Jrb = Ib / Jrb;                 Ib_Jrb = max(Ib_Jrb, 1e-9);                 if (RbModel == 0) begin                      T0 = pow(Ib_Jrb, 0.852);                      T1  = 1.0+3.0*T0;                      rb  =  Rbm + (Rb - Rbm)/sqrt(T1);                 end                 else begin                     T0 = 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;                 end             end             else                 rb = Rb / Area;         end          if (rb)             i_rb = Vbi / rb;          // Base-emitter diffusion         if (Ibe1 + Itf != 0.0) begin              t0 = Ibe1 / (Ibe1 + Itf);               tff = Tf * (1 + Xtf * t0 * t0 * exp_soft(Vbci / (1.44 * vtf)));             end          else             tff = 0.0;          t3 = 1 - Fc;          // Calc base-emitter junction capacitance         Cje0 = Cje;         if (Mje == 1.0) begin             Cje_1 = Cje0 / t3;             Cje_2 = 1.0 / (Vje * t3);             Qje0 = Cje0 * Vje* (0.5 + ln(Vje * t3));         end          else begin             Cje_1 = Cje0/pow(t3, Mje);             Cje_2 = Mje / (Vje * t3);             Qje0  = Cje_1 / (2.0 * Cje_2) * (1.0 + Mje) / (1.0 - Mje);         end          fcpe = Fc * Vje;         if (Vbe <= fcpe)  begin             vdiff = Vje - Vbe;             if (Mje == 1.0)                  Qje = -Cje0 * Vje * ln(vdiff);             else if (Mje == 0.5)                  Qje = -2.0 * vdiff * Cje0 / sqrt(vdiff / Vje);             else                  Qje = -Cje0 * pow(vdiff / Vje, -Mje) * vdiff / (1.0 - Mje);              Qje = Qje + Qje0;         end          else begin             t1 = 1.0 + Cje_2 * (Vbe - fcpe);             Qje = Cje_1 * t1 * t1 / (2.0 * Cje_2);         end          Qbe = tff * Ibe1 / Kqb + Qje;           // Intrinsic base-collector junction capacitance          Cjc0 = Cjc;         if (Mjc == 1.0) begin             Cjc_1 = Cjc0 / t3;             Cjc_2 = 1.0 / (Vjc * t3);             Qjc0  = Cjc0 * Vjc * (0.5 + ln(Vjc * t3));         end          else begin             Cjc_1 = Cjc0 / pow(t3, Mjc);             Cjc_2 = Mjc / (Vjc * t3);             Qjc0  = Cjc_1 / (2.0 * Cjc_2) * (1.0 + Mjc) / (1.0 - Mjc);         end          fcpc = Fc * Vjc;         if (Vbci <= fcpc) begin             vdiff = Vjc - Vbci;             if (Mjc == 1.0)                  Qjc = -ln(vdiff) * Cjc0 * Vjc;             else if (Mjc == 0.5)                  Qjc = -2.0 * vdiff * Cjc0 / sqrt(vdiff / Vjc);             else                 Qjc = -Cjc0 * pow(vdiff / Vjc, -Mjc) * vdiff / (1.0 - Mjc);             Qjc = Qjc + Qjc0;         end          else begin             t1 = 1.0 + Cjc_2 * (Vbci - fcpc);             Qjc = Cjc_1 * t1 * t1 / (2.0 * Cjc_2);         end          Qjc = Qjc * Xcjc;          // Calc external base-collector junction capacitance          if (Vbcx <= fcpc) begin             vdiff = Vjc - Vbcx;             if (Mjc == 1.0)                  Qjcx = -Cjc0 * Vjc *ln(vdiff);             else if (Mjc == 0.5)                  Qjcx = -2.0 * vdiff * Cjc0 / sqrt(vdiff / Vjc);             else                  Qjcx = -Cjc0 * pow(vdiff / Vjc, -Mjc) * vdiff / (1.0 - Mjc);             Qjcx = Qjcx + Qjc0;         end          else begin             t1 = 1.0 + Cjc_2 * (Vbcx - fcpc);             Qjcx = Cjc_1 * t1 * t1 / (2.0 * Cjc_2);         end          Qjcx = Qjcx * (1.0 - Xcjc) * Area;          Qbc = Tr * Ibc1 + Qjc;          // Calc substrate junction capacitance          Cjs0 = Cjs;         Cjs_1 = 0.0;         Qjs0 = 0.0;         if (Mjs == 1.0) begin             Cjs_1 = 1.0 / Vjs;             Qjs0 = -Cjs0 * Vjs * (0.5 + ln(Vjs));         end          else if (Mjs != 0.0) begin             Cjs_1 = Mjs / Vjs;             Qjs0 = -Cjs0 / (2.0 * Cjs_1) * (1.0 + Mjs) / (1.0 - Mjs);         end           if ( Mjs == 0.0)              Qjs = Cjs0 * Vcs;         else if (Vcs >= 0.0) begin // (Rev bias)             t1 = Vjs + Vcs;             if (Mjs == 1.0) begin                 t2 = Cjs0 * Vjs;                 Qjs = t2 * ln(t1);             end              else if (Mjs == 0.5)                  Qjs = 2.0 * t1 * Cjs0 / sqrt(t1 / Vjs);             else                  Qjs = Cjs0 * pow(t1 / Vjs, -Mjs) * t1 / (1.0 - Mjs);              Qjs = Qjs + Qjs0;         end          else begin // (Fwd bias)             t1 = 1.0 - Cjs_1 * Vcs;             Qjs = -Cjs0 * t1 * t1 / (2.0 * Cjs_1);         end          Qjs = Qjs * Area;          // Branch contributions         I(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_TERMINALS         V(s) <+ 0.0; `endif           `ifdef INCLUDE_DELAY         I(ci, ei) <+ Type * Area * ((absdelay(Ibe1, Delay) - Ibc1) / Kqb);      `else `ifdef USE_EXCESS_PHASE         Delay = Ptf * Tf * `M_PI / 180;         I(ci, ei) <+ Type * Area * ((absdelay(Ibe1, Delay) - Ibc1) / Kqb);      `else         I(ci, ei) <+ Type * Area * ((Ibe1 - Ibc1) / Kqb);      `endif `endif  `ifdef INCLUDE_LEAD_INDUCTANCE         V(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));   `else         V(b, bi) <+ I(b, bi) * rb;          // Formulating parasitics in this manner allows for          // automatic branch reduction if R=0:         if (Rc > 0.0) begin             I(c, ci) <+ V(c, ci) / (Rc / Area);               I(c, ci) <+ white_noise(4 * `P_K * T / (Rc / Area), "Rc");         end         else             V(c, ci) <+ 0.0;          if (Re > 0.0) begin             I(e, ei) <+ V(e, ei) / (Re / Area);               I(e, ei) <+ white_noise(4 * `P_K * T / (Re / Area), "Re");         end         else             V(e, ei) <+ 0.0; `endif         // base noise         V(b, bi) <+ white_noise(4 * `P_K * T * rb, "Rb");                                    // Shot and flicker noise         if (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  ==
发表于 2016-9-9 16:02:47 | 显示全部楼层
应该和普通的单元调用一样
bjt #(.NPN(1),.PNP(0),...) bjt_instance_name
发表于 2020-8-18 18:43:43 | 显示全部楼层
Thanks for sharing.
发表于 2020-8-20 10:17:05 | 显示全部楼层
Thanks for sharing
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-27 20:52 , Processed in 0.029467 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表