summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-05-01 16:13:34 +0200
committer couriersud <couriersud@gmx.org>2020-05-01 16:13:34 +0200
commitf74ad44550857d68b10e00fa01130271492e8761 (patch)
tree295fca1e0c592108dcf71f9f25712c549d2e3ff5
parent40f8f99f9ae8a1dd709ef8e0cca488f533d22d41 (diff)
netlist: more magic number removal. (nw)
-rw-r--r--src/lib/netlist/analog/nld_generic_models.h12
-rw-r--r--src/lib/netlist/nltypes.h18
2 files changed, 23 insertions, 7 deletions
diff --git a/src/lib/netlist/analog/nld_generic_models.h b/src/lib/netlist/analog/nld_generic_models.h
index 52862643ea2..04ab9231791 100644
--- a/src/lib/netlist/analog/nld_generic_models.h
+++ b/src/lib/netlist/analog/nld_generic_models.h
@@ -211,25 +211,23 @@ namespace analog
{
public:
generic_diode(device_t &dev, const pstring &name)
- : m_Vd(dev, name + ".m_Vd", nlconst::magic(0.7))
+ : m_Vd(dev, name + ".m_Vd", nlconst::diode_start_voltage())
, m_Id(dev, name + ".m_Id", nlconst::zero())
- , m_G(dev, name + ".m_G", nlconst::magic(1e-15))
+ , m_G(dev, name + ".m_G", nlconst::cgminalt())
, m_Vt(nlconst::zero())
, m_Vmin(nlconst::zero()) // not used in MOS model
, m_Is(nlconst::zero())
, m_logIs(nlconst::zero())
- , m_gmin(nlconst::magic(1e-15))
+ , m_gmin(nlconst::cgminalt())
, m_VtInv(nlconst::zero())
, m_Vcrit(nlconst::zero())
{
set_param(
nlconst::np_Is()
, nlconst::one()
- , nlconst::magic(1e-15)
+ , nlconst::cgminalt()
, nlconst::T0());
- //m_name = name;
}
- //pstring m_name;
// Basic math
//
// I(V) = f(V)
@@ -318,7 +316,7 @@ namespace analog
m_VtInv = plib::reciprocal(m_Vt);
#if USE_TEXTBOOK_DIODE
- m_Vmin = nlconst::magic(-5.0) * m_Vt;
+ m_Vmin = nlconst::diode_min_cutoff_mult() * m_Vt;
// Vcrit : f(V) has smallest radius of curvature rho(V) == min(rho(v))
m_Vcrit = m_Vt * plib::log(m_Vt / m_Is / nlconst::sqrt2());
#else
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h
index 42ba576d0db..915abcafb11 100644
--- a/src/lib/netlist/nltypes.h
+++ b/src/lib/netlist/nltypes.h
@@ -33,8 +33,26 @@ namespace netlist
{
using BC = plib::constants<T>;
+ /// \brief constant startup gmin
+ ///
+ /// This should be used during object creation to initialize
+ /// conductivities with a reasonable value.
+ /// During reset, the object should than make use of exec().gmin()
+ /// to use the actual gmin() value.
static inline constexpr T cgmin() noexcept { return BC::magic(1e-9); } // NOLINT
+ // FIXME: Some objects used 1e-15 for initial gmin. Needs to be
+ // aligned with cgmin
+ static inline constexpr T cgminalt() noexcept { return BC::magic(1e-15); } // NOLINT
+
+ /// \brief Multiplier applied to VT in np diode models to determine range for constant model
+ ///
+ static inline constexpr T diode_min_cutoff_mult() noexcept { return BC::magic(-5.0); } // NOLINT
+
+ /// \brief Startup voltage used by np diode models
+ ///
+ static inline constexpr T diode_start_voltage() noexcept { return BC::magic(0.7); } // NOLINT
+
static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept
{ return n * temp * BC::k_b() / BC::Q_e(); }