From 43c6cad7dd2133a4597a909a24c7d4fbee7e6e05 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 17 Mar 2019 15:09:49 +0100 Subject: netlist: Add UJT example for 2N6027. --- nl_examples/2N6027.cpp | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 nl_examples/2N6027.cpp (limited to 'nl_examples/2N6027.cpp') diff --git a/nl_examples/2N6027.cpp b/nl_examples/2N6027.cpp new file mode 100644 index 00000000000..47903706cb2 --- /dev/null +++ b/nl_examples/2N6027.cpp @@ -0,0 +1,101 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud + +#include "netlist/devices/net_lib.h" + +/* + * Run with + * ./nltool -t 1 -f nl_examples/2N6027.cpp -l PUT.A -l PUT.K -l PUT.G -v + */ + +/* ---------------------------------------------------------------------------- + * Library section header START + * ---------------------------------------------------------------------------*/ + +#ifndef __PLIB_PREPROCESSOR__ + +#define PUT_2N6027(_name) \ + NET_REGISTER_DEV(G501534_DIP, _name) + +//NETLIST_EXTERNAL(ex2N6027) +NETLIST_EXTERNAL(loc_lib) + +#endif + +/* ---------------------------------------------------------------------------- + * Library section header END + * ---------------------------------------------------------------------------*/ + +NETLIST_START(ex2N6027) + + /* This is a circuit pushing the solvers to the limits + * 50,000 maximum NR loops. + */ + SOLVER(Solver, 48000) + PARAM(Solver.ACCURACY, 1e-5) + PARAM(Solver.DYNAMIC_TS, 1) + PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-9) + PARAM(Solver.NR_LOOPS, 50000) + PARAM(Solver.METHOD, "MAT_CR") + + LOCAL_SOURCE(loc_lib) + INCLUDE(loc_lib) + + ANALOG_INPUT(VB, 10) + + PUT_2N6027(PUT) + + // Figure 3 from datasheet + RES(R1, RES_K(510)) + RES(R2, RES_K(16)) + RES(R3, RES_K(27)) + RES(R4, 20) + CAP(C, CAP_U(0.1)) + + NET_C(VB, R1.1, R2.1) + NET_C(R1.2, C.1, PUT.A) + NET_C(PUT.K, R4.1) + NET_C(PUT.G, R2.2, R3.1) + + NET_C(GND, C.2, R4.2, R3.2) + +NETLIST_END() + + +NETLIST_START(PUT_2N6027) + + NET_MODEL("2N6027_NPN NPN(IS=5E-15 VAF=100 IKF=0.3 ISE=1.85E-12 NE=1.45 RE=0.15 RC=0.15 CJE=7E-10 TF=0.6E-8 CJC=2.2E-10 TR=4.76E-8 XTB=3)") + NET_MODEL("2N6027_PNP PNP(IS=2E-15 VAF=100 IKF=0.3 ISE=1.90E-12 NE=1.5 RE=0.15 RC=0.15 CJE=7E-10 TF=1.6E-8 CJC=2.2E-10 TR=5.1E-8 XTB=3)") + + QBJT_EB(Q1, "2N6027_NPN") + QBJT_EB(Q2, "2N6027_PNP") + + /* The netlist transistor model currently doesn't support + * BE and BC capacitances. + * Adding those here significantly reduces NR loops. + * FIXME: Needs to be removed when added to the + * transistor EB model. + */ +#if 1 + CAP(CJE1, CAP_N(1)) + CAP(CJE2, CAP_N(1)) + + NET_C(CJE1.1, Q1.B) + NET_C(CJE1.2, Q1.E) + NET_C(CJE2.1, Q2.B) + NET_C(CJE2.2, Q2.E) +#endif + NET_C(Q1.C, Q2.B) + NET_C(Q1.B, Q2.C) + + ALIAS(G, Q2.B) + ALIAS(A, Q2.E) + ALIAS(K, Q1.E) + +NETLIST_END() + +NETLIST_START(loc_lib) + + LOCAL_LIB_ENTRY(PUT_2N6027) + +NETLIST_END() -- cgit v1.2.3-70-g09d2 From 46762510c99c323de1e9c432d841da65b5a28857 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 17 Mar 2019 23:41:57 +0100 Subject: netlist: Added B-E and B-C capacitance to EB model. [Couriersud] Despite the overhead - two devices more per transistor - this addition significantly reduces computing time on switching conditions by reducing the needed Newton-Raphson loops dramatically. --- nl_examples/2N6027.cpp | 2 +- src/lib/netlist/analog/nld_bjt.cpp | 59 +++++++++++++++++++++++++++++--------- src/lib/netlist/macro/nlm_base.cpp | 4 +-- src/lib/netlist/plib/palloc.h | 6 ++++ 4 files changed, 55 insertions(+), 16 deletions(-) (limited to 'nl_examples/2N6027.cpp') diff --git a/nl_examples/2N6027.cpp b/nl_examples/2N6027.cpp index 47903706cb2..8b414317087 100644 --- a/nl_examples/2N6027.cpp +++ b/nl_examples/2N6027.cpp @@ -76,7 +76,7 @@ NETLIST_START(PUT_2N6027) * FIXME: Needs to be removed when added to the * transistor EB model. */ -#if 1 +#if 0 CAP(CJE1, CAP_N(1)) CAP(CJE2, CAP_N(1)) diff --git a/src/lib/netlist/analog/nld_bjt.cpp b/src/lib/netlist/analog/nld_bjt.cpp index 0f50a9103fb..c2cfbd9faca 100644 --- a/src/lib/netlist/analog/nld_bjt.cpp +++ b/src/lib/netlist/analog/nld_bjt.cpp @@ -73,7 +73,7 @@ private: * | | RBM | minimum base resistance at high currents | | RB | 10 | * | * | | RE | emitter resistance | | 0 | 1 | * | * | | RC | collector resistance | | 0 | 10 | * | - * | | CJE | B-E zero-bias depletion capacitance | F | 0 | 2pF | * | + * | Y | CJE | B-E zero-bias depletion capacitance | F | 0 | 2pF | * | * | | VJE | B-E built-in potential | V | 0.75 | 0.6 | | * | | MJE | B-E junction exponential factor | - | 0.33 | 0.33 | | * | | TF | ideal forward transit time | sec | 0 | 0.1ns | | @@ -81,7 +81,7 @@ private: * | | VTF | voltage describing VBC dependence of TF | V | infinite | | | * | | ITF | high-current parameter for effect on TF | A | 0 | | * | * | | PTF | excess phase at freq=1.0/(TF*2PI) Hz | deg | 0 | | | - * | | CJC | B-C zero-bias depletion capacitance | F | 0 | 2pF | * | + * | Y | CJC | B-C zero-bias depletion capacitance | F | 0 | 2pF | * | * | | VJC | B-C built-in potential | V | 0.75 | 0.5 | | * | | MJC | B-C junction exponential factor | - | 0.33 | 0.5 | | * | | XCJC | fraction of B-C depletion capacitance connected to internal base node | - | 1 | | | @@ -95,25 +95,31 @@ private: * | | KF | flicker-noise coefficient | - | 0 | | | * | | AF | flicker-noise exponent | - | 1 | | | * | | FC | coefficient for forward-bias depletion capacitance formula | - | 0.5 | | | - * | | TNOM | Parameter measurement temperature | C | 27 | 50 | | */ + * | | TNOM | Parameter measurement temperature | C | 27 | 50 | | + * */ class bjt_model_t : public param_model_t { public: bjt_model_t(device_t &device, const pstring &name, const pstring &val) : param_model_t(device, name, val) - , m_IS(*this, "IS") - , m_BF(*this, "BF") - , m_NF(*this, "NF") - , m_BR(*this, "BR") - , m_NR(*this, "NR") + , m_IS (*this, "IS") + , m_BF (*this, "BF") + , m_NF (*this, "NF") + , m_BR (*this, "BR") + , m_NR (*this, "NR") + , m_CJE(*this, "CJE") + , m_CJC(*this, "CJC") {} - value_t m_IS; //!< transport saturation current - value_t m_BF; //!< ideal maximum forward beta - value_t m_NF; //!< forward current emission coefficient - value_t m_BR; //!< ideal maximum reverse beta - value_t m_NR; //!< reverse current emission coefficient + value_t m_IS; //!< transport saturation current + value_t m_BF; //!< ideal maximum forward beta + value_t m_NF; //!< forward current emission coefficient + value_t m_BR; //!< ideal maximum reverse beta + value_t m_NR; //!< reverse current emission coefficient + value_t m_CJE; //!< B-E zero-bias depletion capacitance + value_t m_CJC; //!< B-C zero-bias depletion capacitance + }; // Have a common start for transistors @@ -250,6 +256,19 @@ public: connect(m_D_EB.m_P, m_D_EC.m_P); connect(m_D_EB.m_N, m_D_CB.m_N); connect(m_D_CB.m_P, m_D_EC.m_N); + + if (m_model.m_CJE > 0.0) + { + register_sub("m_CJE", m_CJE); + connect("B", "m_CJE.1"); + connect("E", "m_CJE.2"); + } + if (m_model.m_CJC > 0.0) + { + register_sub("m_CJC", m_CJC); + connect("B", "m_CJC.1"); + connect("C", "m_CJC.2"); + } } protected: @@ -270,6 +289,9 @@ private: nl_double m_alpha_f; nl_double m_alpha_r; + NETLIB_SUBXX(analog, C) m_CJE; + NETLIB_SUBXX(analog, C) m_CJC; + }; @@ -376,6 +398,17 @@ NETLIB_UPDATE(QBJT_EB) NETLIB_RESET(QBJT_EB) { NETLIB_NAME(Q)::reset(); + if (m_CJE) + { + m_CJE->reset(); + m_CJE->m_C.setTo(m_model.m_CJE); + } + if (m_CJC) + { + m_CJC->reset(); + m_CJC->m_C.setTo(m_model.m_CJC); + } + } NETLIB_UPDATE_TERMINALS(QBJT_EB) diff --git a/src/lib/netlist/macro/nlm_base.cpp b/src/lib/netlist/macro/nlm_base.cpp index 86f5a2f941c..6d4d3c252b4 100644 --- a/src/lib/netlist/macro/nlm_base.cpp +++ b/src/lib/netlist/macro/nlm_base.cpp @@ -32,8 +32,8 @@ NETLIST_END() * ---------------------------------------------------------------------------*/ static NETLIST_START(bjt_models) - NET_MODEL("NPN _(IS=1e-15 BF=100 NF=1 BR=1 NR=1)") - NET_MODEL("PNP _(IS=1e-15 BF=100 NF=1 BR=1 NR=1)") + NET_MODEL("NPN _(IS=1e-15 BF=100 NF=1 BR=1 NR=1 CJE=0 CJC=0)") + NET_MODEL("PNP _(IS=1e-15 BF=100 NF=1 BR=1 NR=1 CJE=0 CJC=0)") NET_MODEL("2SA1015 PNP(Is=295.1E-18 Xti=3 Eg=1.11 Vaf=100 Bf=110 Xtb=1.5 Br=10.45 Rc=15 Cjc=66.2p Mjc=1.054 Vjc=.75 Fc=.5 Cje=5p Mje=.3333 Vje=.75 Tr=10n Tf=1.661n VCEO=45V ICrating=150M MFG=Toshiba)") NET_MODEL("2SC1815 NPN(Is=2.04f Xti=3 Eg=1.11 Vaf=6 Bf=400 Ikf=20m Xtb=1.5 Br=3.377 Rc=1 Cjc=1p Mjc=.3333 Vjc=.75 Fc=.5 Cje=25p Mje=.3333 Vje=.75 Tr=450n Tf=20n Itf=0 Vtf=0 Xtf=0 VCEO=45V ICrating=150M MFG=Toshiba)") diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 830ce3ec525..d0e69ed13ec 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -147,6 +147,12 @@ namespace plib { m_is_owned = false; m_ptr = nullptr; } + + /** + * \brief Return @c true if the stored pointer is not null. + */ + explicit operator bool() const noexcept { return m_ptr != nullptr; } + pointer release() { pointer tmp = m_ptr; -- cgit v1.2.3-70-g09d2