summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/lib/netlist/.clang-tidy10
-rw-r--r--src/lib/netlist/analog/nld_bjt.cpp8
-rw-r--r--src/lib/netlist/analog/nld_mosfet.cpp8
-rw-r--r--src/lib/netlist/build/makefile4
-rw-r--r--src/lib/netlist/devices/nlid_proxy.cpp2
-rw-r--r--src/lib/netlist/nl_base.cpp6
-rw-r--r--src/lib/netlist/nl_base.h18
-rw-r--r--src/lib/netlist/nl_config.h24
-rwxr-xr-xsrc/lib/netlist/nl_setup.cpp53
-rw-r--r--src/lib/netlist/nl_setup.h17
-rw-r--r--src/lib/netlist/nltypes.h18
-rw-r--r--src/lib/netlist/plib/mat_cr.h9
-rw-r--r--src/lib/netlist/plib/pfunction.cpp12
-rw-r--r--src/lib/netlist/plib/pfunction.h4
-rw-r--r--src/lib/netlist/plib/pmath.h36
-rw-r--r--src/lib/netlist/plib/vector_ops.h6
-rw-r--r--src/lib/netlist/prg/nltool.cpp2
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.cpp13
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.h20
-rw-r--r--src/lib/netlist/solver/nld_ms_sor.h2
-rw-r--r--src/lib/netlist/tools/nl_convert.cpp32
-rwxr-xr-xsrc/lib/netlist/tools/nl_convert.h28
22 files changed, 186 insertions, 146 deletions
diff --git a/src/lib/netlist/.clang-tidy b/src/lib/netlist/.clang-tidy
new file mode 100644
index 00000000000..bda30e94e2e
--- /dev/null
+++ b/src/lib/netlist/.clang-tidy
@@ -0,0 +1,10 @@
+Checks: '-misc-non-private-member-variables-in-classes'
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+AnalyzeTemporaryDtors: true
+FormatStyle: none
+CheckOptions:
+ - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
+ value: '1'
+ - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
+ value: '1'
diff --git a/src/lib/netlist/analog/nld_bjt.cpp b/src/lib/netlist/analog/nld_bjt.cpp
index 09fc0bfa880..10f6b9dd1ee 100644
--- a/src/lib/netlist/analog/nld_bjt.cpp
+++ b/src/lib/netlist/analog/nld_bjt.cpp
@@ -13,21 +13,21 @@ namespace analog
{
public:
diode()
- : m_Is(nlconst::magic(1e-15))
- , m_VT(nlconst::magic(0.0258))
+ : m_Is(nlconst::np_Is())
+ , m_VT(nlconst::np_VT())
, m_VT_inv(plib::reciprocal(m_VT))
{}
diode(nl_fptype Is, nl_fptype n)
{
m_Is = Is;
- m_VT = nlconst::magic(0.0258) * n;
+ m_VT = nlconst::np_VT(n);
m_VT_inv = plib::reciprocal(m_VT);
}
void set(nl_fptype Is, nl_fptype n) noexcept
{
m_Is = Is;
- m_VT = nlconst::magic(0.0258) * n;
+ m_VT = nlconst::np_VT(n);
m_VT_inv = plib::reciprocal(m_VT);
}
nl_fptype I(nl_fptype V) const noexcept { return m_Is * plib::exp(V * m_VT_inv) - m_Is; }
diff --git a/src/lib/netlist/analog/nld_mosfet.cpp b/src/lib/netlist/analog/nld_mosfet.cpp
index a77348f9cd0..96853c7d265 100644
--- a/src/lib/netlist/analog/nld_mosfet.cpp
+++ b/src/lib/netlist/analog/nld_mosfet.cpp
@@ -397,7 +397,7 @@ namespace analog
else if (Vctrl <= 0)
{
Cgb = -Vctrl * m_CoxWL / m_phi;
- Cgs = Vctrl * m_CoxWL * nlconst::magic(4.0 / 3.0) / m_phi + nlconst::magic(2.0 / 3.0) * m_CoxWL;
+ Cgs = Vctrl * m_CoxWL * nlconst::fraction(4.0, 3.0) / m_phi + nlconst::two_thirds() * m_CoxWL;
Cgd = nlconst::zero();
}
else
@@ -408,7 +408,7 @@ namespace analog
if (Vdsat <= Vds)
{
Cgb = nlconst::zero();
- Cgs = nlconst::magic(2.0 / 3.0) * m_CoxWL;
+ Cgs = nlconst::two_thirds() * m_CoxWL;
Cgd = nlconst::zero();
}
else
@@ -417,8 +417,8 @@ namespace analog
const auto Sqr1(static_cast<nl_fptype>(plib::pow(Vdsat - Vds, 2)));
const auto Sqr2(static_cast<nl_fptype>(plib::pow(nlconst::two() * Vdsat - Vds, 2)));
Cgb = 0;
- Cgs = m_CoxWL * (nlconst::one() - Sqr1 / Sqr2) * nlconst::magic(2.0 / 3.0);
- Cgd = m_CoxWL * (nlconst::one() - Vdsat * Vdsat / Sqr2) * nlconst::magic(2.0 / 3.0);
+ Cgs = m_CoxWL * (nlconst::one() - Sqr1 / Sqr2) * nlconst::two_thirds();
+ Cgd = m_CoxWL * (nlconst::one() - Vdsat * Vdsat / Sqr2) * nlconst::two_thirds();
}
}
}
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile
index 89b790c176b..ffe834d5b15 100644
--- a/src/lib/netlist/build/makefile
+++ b/src/lib/netlist/build/makefile
@@ -16,9 +16,9 @@ TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast,
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory,
TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index,
TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast-downcast,
-TIDY_FLAGSX += -cppcoreguidelines-avoid-magic-numbers,
+#TIDY_FLAGSX += -cppcoreguidelines-avoid-magic-numbers,
TIDY_FLAGSX += -cppcoreguidelines-macro-usage,
-TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,
+#TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,
TIDY_FLAGSX += -bugprone-macro-parentheses,-misc-macro-parentheses,
TIDY_FLAGSX += -bugprone-too-small-loop-variable,
TIDY_FLAGSX += -modernize-use-trailing-return-type,
diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp
index f2cf50e7b91..389a70827e4 100644
--- a/src/lib/netlist/devices/nlid_proxy.cpp
+++ b/src/lib/netlist/devices/nlid_proxy.cpp
@@ -23,7 +23,7 @@ namespace netlist
, m_tp(nullptr)
, m_tn(nullptr)
{
- m_logic_family = inout_proxied->logic_family();
+ set_logic_family(inout_proxied->logic_family());
const std::vector<std::pair<pstring, pstring>> power_syms = { {"VCC", "VEE"}, {"VCC", "GND"}, {"VDD", "VSS"}};
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index e01bd8496a8..1268b7768a7 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -455,7 +455,7 @@ namespace netlist
index.push_back(i);
std::sort(index.begin(), index.end(),
- [&](size_t i1, size_t i2) { return m_state.m_devices[i1].second->m_stats->m_stat_total_time.total() < m_state.m_devices[i2].second->m_stats->m_stat_total_time.total(); });
+ [&](size_t i1, size_t i2) { return m_state.m_devices[i1].second->stats()->m_stat_total_time.total() < m_state.m_devices[i2].second->stats()->m_stat_total_time.total(); });
plib::pperftime_t<true>::type total_time(0);
plib::pperftime_t<true>::ctype total_count(0);
@@ -463,7 +463,7 @@ namespace netlist
for (auto & j : index)
{
auto *entry = m_state.m_devices[j].second.get();
- auto *stats = entry->m_stats.get();
+ auto *stats = entry->stats();
log().verbose("Device {1:20} : {2:12} {3:12} {4:15} {5:12}", entry->name(),
stats->m_stat_call_count(), stats->m_stat_total_time.count(),
stats->m_stat_total_time.total(), stats->m_stat_inc_active());
@@ -515,7 +515,7 @@ namespace netlist
for (auto &entry : m_state.m_devices)
{
auto *ep = entry.second.get();
- auto *stats = ep->m_stats.get();
+ auto *stats = ep->stats();
// Factor of 3 offers best performace increase
if (stats->m_stat_inc_active() > 3 * stats->m_stat_total_time.count()
&& stats->m_stat_inc_active() > trigger)
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index 8a63d724205..e43f6c239c9 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -311,6 +311,7 @@ namespace netlist
protected:
~logic_family_t() noexcept = default; // prohibit polymorphic destruction
+ private:
const logic_family_desc_t *m_logic_family;
};
@@ -642,7 +643,7 @@ namespace netlist
state_var_sig m_Q;
#else
- void set_copied_input(netlist_sig_t val) const noexcept { plib::unused_var(val); }
+ void set_copied_input(netlist_sig_t val) const noexcept { plib::unused_var(val); } // NOLINT: static means more message elsewhere
#endif
void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; }
@@ -1049,7 +1050,7 @@ namespace netlist
plib::pperfcount_t<true> m_stat_inc_active;
};
- unique_pool_ptr<stats_t> m_stats;
+ stats_t * stats() noexcept { return m_stats.get(); }
virtual void update() noexcept { }
virtual void reset() { }
@@ -1072,6 +1073,7 @@ namespace netlist
private:
bool m_hint_deactivate;
state_var_s32 m_active_outputs;
+ unique_pool_ptr<stats_t> m_stats;
};
// -----------------------------------------------------------------------------
@@ -1371,6 +1373,7 @@ namespace netlist
public:
using nets_collection_type = std::vector<owned_pool_ptr<detail::net_t>>;
+ using family_collection_type = std::unordered_map<pstring, plib::unique_ptr<logic_family_desc_t>>;
// need to preserve order of device creation ...
using devices_collection_type = std::vector<std::pair<pstring, owned_pool_ptr<core_device_t>>>;
@@ -1544,8 +1547,7 @@ namespace netlist
devices_collection_type & devices() noexcept { return m_devices; }
const devices_collection_type & devices() const noexcept { return m_devices; }
- // sole use is to manage lifetime of family objects
- std::unordered_map<pstring, plib::unique_ptr<logic_family_desc_t>> m_family_cache;
+ family_collection_type &family_cache() { return m_family_cache; }
template<typename T, typename... Args>
unique_pool_ptr<T> make_object(Args&&... args)
@@ -1590,6 +1592,8 @@ namespace netlist
nets_collection_type m_nets;
// sole use is to manage lifetime of net objects
devices_collection_type m_devices;
+ // sole use is to manage lifetime of family objects
+ family_collection_type m_family_cache;
bool m_extended_validation;
// dummy version
@@ -1628,8 +1632,8 @@ namespace netlist
}
public:
- logic_output_t m_Q;
- netlist_time m_inc;
+ logic_output_t m_Q; // NOLINT: needed in core
+ netlist_time m_inc; // NOLINT: needed in core
private:
param_fp_t m_freq;
};
@@ -2067,7 +2071,7 @@ namespace netlist
for (auto & p : m_list_active)
{
p.set_copied_input(sig);
- auto *stats = p.device().m_stats.get();
+ auto *stats(p.device().stats());
stats->m_stat_call_count.inc();
if ((p.terminal_state() & mask))
{
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index 15dfba489da..1025673ccf6 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -209,11 +209,11 @@ namespace netlist
template <>
struct fp_constants<long double>
{
- static inline constexpr long double DIODE_MAXDIFF() noexcept { return 1e100L; }
- static inline constexpr long double DIODE_MAXVOLT() noexcept { return 300.0L; }
+ static inline constexpr long double DIODE_MAXDIFF() noexcept { return 1e100L; } // NOLINT
+ static inline constexpr long double DIODE_MAXVOLT() noexcept { return 300.0L; } // NOLINT
- static inline constexpr long double TIMESTEP_MAXDIFF() noexcept { return 1e100L; }
- static inline constexpr long double TIMESTEP_MINDIV() noexcept { return 1e-60L; }
+ static inline constexpr long double TIMESTEP_MAXDIFF() noexcept { return 1e100L; } // NOLINT
+ static inline constexpr long double TIMESTEP_MINDIV() noexcept { return 1e-60L; } // NOLINT
static inline constexpr const char * name() noexcept { return "long double"; }
static inline constexpr const char * suffix() noexcept { return "L"; }
@@ -224,11 +224,11 @@ namespace netlist
template <>
struct fp_constants<double>
{
- static inline constexpr double DIODE_MAXDIFF() noexcept { return 1e100; }
- static inline constexpr double DIODE_MAXVOLT() noexcept { return 300.0; }
+ static inline constexpr double DIODE_MAXDIFF() noexcept { return 1e100; } // NOLINT
+ static inline constexpr double DIODE_MAXVOLT() noexcept { return 300.0; } // NOLINT
- static inline constexpr double TIMESTEP_MAXDIFF() noexcept { return 1e100; }
- static inline constexpr double TIMESTEP_MINDIV() noexcept { return 1e-60; }
+ static inline constexpr double TIMESTEP_MAXDIFF() noexcept { return 1e100; } // NOLINT
+ static inline constexpr double TIMESTEP_MINDIV() noexcept { return 1e-60; } // NOLINT
static inline constexpr const char * name() noexcept { return "double"; }
static inline constexpr const char * suffix() noexcept { return ""; }
@@ -239,11 +239,11 @@ namespace netlist
template <>
struct fp_constants<float>
{
- static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; }
- static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; }
+ static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; } // NOLINT
+ static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; } // NOLINT
- static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; }
- static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; }
+ static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; } // NOLINT
+ static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; } // NOLINT
static inline constexpr const char * name() noexcept { return "float"; }
static inline constexpr const char * suffix() noexcept { return "f"; }
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index 58f2aeee202..737c113018e 100755
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -329,6 +329,19 @@ namespace netlist
}
// ----------------------------------------------------------------------------------------
+ // Sources
+ // ----------------------------------------------------------------------------------------
+
+ plib::psource_t::stream_ptr nlparse_t::get_data_stream(const pstring &name)
+ {
+ auto strm = m_sources.get_stream<source_data_t>(name);
+ if (strm)
+ return strm;
+ log().warning(MW_DATA_1_NOT_FOUND(name));
+ return plib::psource_t::stream_ptr(nullptr);
+ }
+
+ // ----------------------------------------------------------------------------------------
// setup_t
// ----------------------------------------------------------------------------------------
@@ -1179,46 +1192,32 @@ unique_pool_ptr<devices::nld_base_a_to_d_proxy> logic_family_std_proxy_t::create
const logic_family_desc_t *setup_t::family_from_model(const pstring &model)
{
- if (m_models.value_str(model, "TYPE") == "TTL")
+ if (models().value_str(model, "TYPE") == "TTL")
return family_TTL();
- if (m_models.value_str(model, "TYPE") == "CD4XXX")
+ if (models().value_str(model, "TYPE") == "CD4XXX")
return family_CD4XXX();
- auto it = m_nlstate.m_family_cache.find(model);
- if (it != m_nlstate.m_family_cache.end())
+ auto it = m_nlstate.family_cache().find(model);
+ if (it != m_nlstate.family_cache().end())
return it->second.get();
auto ret = plib::make_unique<logic_family_std_proxy_t>();
- ret->m_low_thresh_PCNT = m_models.value(model, "IVL");
- ret->m_high_thresh_PCNT = m_models.value(model, "IVH");
- ret->m_low_VO = m_models.value(model, "OVL");
- ret->m_high_VO = m_models. value(model, "OVH");
- ret->m_R_low = m_models.value(model, "ORL");
- ret->m_R_high = m_models.value(model, "ORH");
+ ret->m_low_thresh_PCNT = models().value(model, "IVL");
+ ret->m_high_thresh_PCNT = models().value(model, "IVH");
+ ret->m_low_VO = models().value(model, "OVL");
+ ret->m_high_VO = models(). value(model, "OVH");
+ ret->m_R_low = models().value(model, "ORL");
+ ret->m_R_high = models().value(model, "ORH");
auto *retp = ret.get();
- m_nlstate.m_family_cache.emplace(model, std::move(ret));
+ m_nlstate.family_cache().emplace(model, std::move(ret));
return retp;
}
// ----------------------------------------------------------------------------------------
-// Sources
-// ----------------------------------------------------------------------------------------
-
-plib::psource_t::stream_ptr setup_t::get_data_stream(const pstring &name)
-{
- auto strm = m_sources.get_stream<source_data_t>(name);
- if (strm)
- return strm;
- log().warning(MW_DATA_1_NOT_FOUND(name));
- return plib::psource_t::stream_ptr(nullptr);
-}
-
-
-// ----------------------------------------------------------------------------------------
// Device handling
// ----------------------------------------------------------------------------------------
@@ -1271,8 +1270,8 @@ void setup_t::prepare_to_run()
// set default model parameters
- m_models.register_model(plib::pfmt("NMOS_DEFAULT _(CAPMOD={1})")(m_netlist_params->m_mos_capmodel()));
- m_models.register_model(plib::pfmt("PMOS_DEFAULT _(CAPMOD={1})")(m_netlist_params->m_mos_capmodel()));
+ models().register_model(plib::pfmt("NMOS_DEFAULT _(CAPMOD={1})")(m_netlist_params->m_mos_capmodel()));
+ models().register_model(plib::pfmt("PMOS_DEFAULT _(CAPMOD={1})")(m_netlist_params->m_mos_capmodel()));
// create devices
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index 0dfc7d97a4a..42fb4f26dfc 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -338,17 +338,13 @@ namespace netlist
models_t &models() noexcept { return m_models; }
const models_t &models() const noexcept { return m_models; }
+ plib::psource_t::stream_ptr get_data_stream(const pstring &name);
+
protected:
- models_t m_models;
- std::stack<pstring> m_namespace_stack;
std::unordered_map<pstring, pstring> m_alias;
std::vector<link_t> m_links;
std::unordered_map<pstring, pstring> m_param_values;
- plib::psource_collection_t<> m_sources;
-
- factory::list_t m_factory;
-
// need to preserve order of device creation ...
std::vector<std::pair<pstring, factory::element_t *>> m_device_factory;
@@ -356,6 +352,10 @@ namespace netlist
private:
plib::ppreprocessor::defines_map_type m_defines;
plib::psource_collection_t<> m_includes;
+ models_t m_models;
+ std::stack<pstring> m_namespace_stack;
+ plib::psource_collection_t<> m_sources;
+ factory::list_t m_factory;
setup_t &m_setup;
log_type &m_log;
@@ -403,11 +403,6 @@ namespace netlist
void register_dynamic_log_devices(const std::vector<pstring> &loglist);
void resolve_inputs();
- plib::psource_t::stream_ptr get_data_stream(const pstring &name);
-
- factory::list_t &factory() { return m_factory; }
- const factory::list_t &factory() const { return m_factory; }
-
// helper - also used by nltool
pstring resolve_alias(const pstring &name) const;
pstring de_alias(const pstring &alias) const;
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h
index ed6a4dcf6b0..cc0dac87f05 100644
--- a/src/lib/netlist/nltypes.h
+++ b/src/lib/netlist/nltypes.h
@@ -26,9 +26,23 @@
namespace netlist
{
- /// \brief plib::constants struct specialized for nl_fptype.
+ /// \brief Constants and const calculations for the library
///
- struct nlconst : public plib::constants<nl_fptype>
+ template<typename T>
+ struct nlconst_base : public plib::constants<T>
+ {
+ using BC = plib::constants<T>;
+
+ static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept
+ { return n * temp * BC::k_b() / BC::Q_e(); }
+
+ static inline constexpr T np_Is() noexcept
+ { return static_cast<T>(1e-15); } // NOLINT
+ };
+
+ /// \brief nlconst_base struct specialized for nl_fptype.
+ ///
+ struct nlconst : public nlconst_base<nl_fptype>
{
};
diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h
index 11c0444fac5..9dc5cc7b1f5 100644
--- a/src/lib/netlist/plib/mat_cr.h
+++ b/src/lib/netlist/plib/mat_cr.h
@@ -43,11 +43,16 @@ namespace plib
FILL_INFINITY = 9999999
};
+ // FIXME: these should be private
+ // NOLINTNEXTLINE
parray<index_type, N> diag; // diagonal index pointer n
+ // NOLINTNEXTLINE
parray<index_type, Np1> row_idx; // row index pointer n + 1
+ // NOLINTNEXTLINE
parray<index_type, NSQ> col_idx; // column index array nz_num, initially (n * n)
+ // NOLINTNEXTLINE
parray<value_type, NSQ> A; // Matrix elements nz_num, initially (n * n)
-
+ // NOLINTNEXTLINE
std::size_t nz_num;
explicit pmatrix_cr_t(std::size_t n)
@@ -237,6 +242,8 @@ namespace plib
}
protected:
+ // FIXME: this should be private
+ // NOLINTNEXTLINE
parray<std::vector<index_type>, N > nzbd; // Support for gaussian elimination
private:
//parray<C, N < 0 ? -N * (N-1) / 2 : N * (N+1) / 2 > nzbd; // Support for gaussian elimination
diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp
index b5b4dd779c5..292bd9bb9c6 100644
--- a/src/lib/netlist/plib/pfunction.cpp
+++ b/src/lib/netlist/plib/pfunction.cpp
@@ -14,6 +14,8 @@
namespace plib {
+ static constexpr const std::size_t MAX_STACK = 32;
+
template <typename NT>
void pfunction<NT>::compile(const pstring &expr, const inputs_container &inputs) noexcept(false)
{
@@ -86,6 +88,8 @@ namespace plib {
}
if (stk < 1)
throw pexception(plib::pfmt("pfunction: stack underflow on token <{1}> in <{2}>")(cmd)(expr));
+ if (stk >= static_cast<int>(MAX_STACK))
+ throw pexception(plib::pfmt("pfunction: stack overflow on token <{1}> in <{2}>")(cmd)(expr));
m_precompiled.push_back(rc);
}
if (stk != 1)
@@ -242,8 +246,8 @@ namespace plib {
std::uint16_t lsb = lfsr & 1;
lfsr >>= 1;
if (lsb)
- lfsr ^= 0xB400U; // taps 15, 13, 12, 10
- return static_cast<NT>(lfsr) / static_cast<NT>(0xffffU);
+ lfsr ^= 0xB400U; // NOLINT: taps 15, 13, 12, 10
+ return static_cast<NT>(lfsr) / static_cast<NT>(0xffffU); // NOLINT
}
template <typename NT>
@@ -253,7 +257,7 @@ namespace plib {
std::uint16_t lsb = lfsr & 1;
lfsr >>= 1;
if (lsb)
- lfsr ^= 0xB400U; // taps 15, 13, 12, 10
+ lfsr ^= 0xB400U; // NOLINT: taps 15, 13, 12, 10
return static_cast<NT>(lfsr);
}
@@ -269,7 +273,7 @@ namespace plib {
template <typename NT>
NT pfunction<NT>::evaluate(const values_container &values) noexcept
{
- std::array<value_type, 20> stack = { plib::constants<value_type>::zero() };
+ std::array<value_type, MAX_STACK> stack = { plib::constants<value_type>::zero() };
unsigned ptr = 0;
stack[0] = plib::constants<value_type>::zero();
for (auto &rc : m_precompiled)
diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h
index 364d7c8745c..e5c1417bb7f 100644
--- a/src/lib/netlist/plib/pfunction.h
+++ b/src/lib/netlist/plib/pfunction.h
@@ -65,7 +65,7 @@ namespace plib {
///
///
pfunction(const pstring &name, const void *owner, state_manager_t &state_manager)
- : m_lfsr(0xace1U)
+ : m_lfsr(0xace1U) // NOLINT
{
state_manager.save_item(owner, m_lfsr, name + ".lfsr");
}
@@ -73,7 +73,7 @@ namespace plib {
/// \brief Constructor without state saving support
///
pfunction()
- : m_lfsr(0xace1U)
+ : m_lfsr(0xace1U) // NOLINT
{
}
diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h
index 819d51159a4..1271707a228 100644
--- a/src/lib/netlist/plib/pmath.h
+++ b/src/lib/netlist/plib/pmath.h
@@ -32,42 +32,45 @@ namespace plib
template <typename T>
struct constants
{
- static inline constexpr T zero() noexcept { return static_cast<T>(0); }
- static inline constexpr T half() noexcept { return static_cast<T>(0.5); }
- static inline constexpr T one() noexcept { return static_cast<T>(1); }
- static inline constexpr T two() noexcept { return static_cast<T>(2); }
- static inline constexpr T three() noexcept { return static_cast<T>(3); }
- static inline constexpr T four() noexcept { return static_cast<T>(4); }
- static inline constexpr T sqrt2() noexcept { return static_cast<T>(1.414213562373095048801688724209L); }
- static inline constexpr T pi() noexcept { return static_cast<T>(3.14159265358979323846264338327950L); }
+ static inline constexpr T zero() noexcept { return static_cast<T>(0); } // NOLINT
+ static inline constexpr T half() noexcept { return static_cast<T>(0.5); } // NOLINT
+ static inline constexpr T one() noexcept { return static_cast<T>(1); } // NOLINT
+ static inline constexpr T two() noexcept { return static_cast<T>(2); } // NOLINT
+ static inline constexpr T three() noexcept { return static_cast<T>(3); } // NOLINT
+ static inline constexpr T four() noexcept { return static_cast<T>(4); } // NOLINT
+ static inline constexpr T hundred()noexcept { return static_cast<T>(100); } // NOLINT
+ static inline constexpr T sqrt2() noexcept { return static_cast<T>(1.414213562373095048801688724209L); } // NOLINT
+ static inline constexpr T pi() noexcept { return static_cast<T>(3.14159265358979323846264338327950L); } // NOLINT
+ static inline constexpr T one_thirds() noexcept { return fraction(one(), three()); }
+ static inline constexpr T two_thirds() noexcept { return fraction(two(), three()); }
/// \brief Electric constant of vacuum
///
- static inline constexpr T eps_0() noexcept { return static_cast<T>(8.854187817e-12); }
+ static inline constexpr T eps_0() noexcept { return static_cast<T>(8.854187817e-12); } // NOLINT
// \brief Relative permittivity of Silicon dioxide
///
- static inline constexpr T eps_SiO2() noexcept { return static_cast<T>(3.9); }
+ static inline constexpr T eps_SiO2() noexcept { return static_cast<T>(3.9); } // NOLINT
/// \brief Relative permittivity of Silicon
///
- static inline constexpr T eps_Si() noexcept { return static_cast<T>(11.7); }
+ static inline constexpr T eps_Si() noexcept { return static_cast<T>(11.7); } // NOLINT
/// \brief Boltzmann constant
///
- static inline constexpr T k_b() noexcept { return static_cast<T>(1.38064852e-23); }
+ static inline constexpr T k_b() noexcept { return static_cast<T>(1.38064852e-23); } // NOLINT
/// \brief room temperature (gives VT = 0.02585 at T=300)
///
- static inline constexpr T T0() noexcept { return static_cast<T>(300); }
+ static inline constexpr T T0() noexcept { return static_cast<T>(300); } // NOLINT
/// \brief Elementary charge
///
- static inline constexpr T Q_e() noexcept { return static_cast<T>(1.6021765314e-19); }
+ static inline constexpr T Q_e() noexcept { return static_cast<T>(1.6021765314e-19); } // NOLINT
/// \brief Intrinsic carrier concentration in 1/m^3 of Silicon
///
- static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); }
+ static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); } // NOLINT
/// \brief clearly identify magic numbers in code
///
@@ -77,6 +80,9 @@ namespace plib
///
template <typename V>
static inline constexpr T magic(V &&v) noexcept { return static_cast<T>(v); }
+
+ template <typename V>
+ static inline constexpr T fraction(V &&v1, V &&v2) noexcept { return static_cast<T>(v1 / v2); }
};
/// \brief typesafe reciprocal function
diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h
index 71cb540fcc9..6d20b9213a7 100644
--- a/src/lib/netlist/plib/vector_ops.h
+++ b/src/lib/netlist/plib/vector_ops.h
@@ -44,13 +44,13 @@ namespace plib
template<typename T, typename V1, typename V2>
T vec_mult(const std::size_t n, const V1 & v1, const V2 & v2 ) noexcept
{
- using b8 = std::array<T, 8>;
+ using b8 = std::array<T, 8>; // NOLINT
PALIGNAS_VECTOROPT() b8 value = {0};
for (std::size_t i = 0; i < n ; i++ )
{
- value[i & 7] += v1[i] * v2[i];
+ value[i & 7] += v1[i] * v2[i]; // NOLINT
}
- return value[0] + value[1] + value[2] + value[3] + value[4] + value[5] + value[6] + value[7];
+ return value[0] + value[1] + value[2] + value[3] + value[4] + value[5] + value[6] + value[7]; // NOLINT
}
template<typename T, typename VT>
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index b9225c3b640..78ab39463df 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -506,7 +506,7 @@ void tool_app_t::run()
auto emutime(t.as_seconds<nl_fptype>());
pout("{1:f} seconds emulation took {2:f} real time ==> {3:5.2f}%\n",
(ttr - nlstart).as_fp<nl_fptype>(), emutime,
- (ttr - nlstart).as_fp<nl_fptype>() / emutime * netlist::nlconst::magic(100.0));
+ (ttr - nlstart).as_fp<nl_fptype>() / emutime * netlist::nlconst::hundred());
}
void tool_app_t::validate()
diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp
index a84e958cca5..cbb9f138a4a 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.cpp
+++ b/src/lib/netlist/solver/nld_matrix_solver.cpp
@@ -415,17 +415,6 @@ namespace solver
m_last_step = netlist_time_ext::zero();
}
- void matrix_solver_t::update() noexcept
- {
- const netlist_time new_timestep = solve(exec().time());
- update_inputs();
-
- if (m_params.m_dynamic_ts && (timestep_device_count() != 0) && new_timestep > netlist_time::zero())
- {
- m_Q_sync.net().toggle_and_push_to_queue(new_timestep);
- }
- }
-
void matrix_solver_t::step(netlist_time delta) noexcept
{
const auto dd(delta.as_fp<nl_fptype>());
@@ -597,7 +586,7 @@ namespace solver
this->m_stat_calculations,
static_cast<nl_fptype>(this->m_stat_calculations) / this->exec().time().as_fp<nl_fptype>(),
this->m_iterative_fail,
- nlconst::magic(100.0) * static_cast<nl_fptype>(this->m_iterative_fail)
+ nlconst::hundred() * static_cast<nl_fptype>(this->m_iterative_fail)
/ static_cast<nl_fptype>(this->m_stat_calculations),
static_cast<nl_fptype>(this->m_iterative_total) / static_cast<nl_fptype>(this->m_stat_calculations));
}
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h
index ec7bf9f9727..fbf5653c883 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.h
+++ b/src/lib/netlist/solver/nld_matrix_solver.h
@@ -226,13 +226,27 @@ namespace solver
{
// We only need to update the net first if this is a time stepping net
if (timestep_device_count() > 0)
- solve_now();
+ {
+ const netlist_time new_timestep = solve(exec().time());
+ plib::unused_var(new_timestep);
+ update_inputs();
+ }
f();
m_Q_sync.net().toggle_and_push_to_queue(delay);
}
// netdevice functions
- NETLIB_UPDATEI();
+ NETLIB_UPDATEI()
+ {
+ const netlist_time new_timestep = solve(exec().time());
+ update_inputs();
+
+ if (m_params.m_dynamic_ts && (timestep_device_count() != 0) && new_timestep > netlist_time::zero())
+ {
+ m_Q_sync.net().toggle_and_push_to_queue(new_timestep);
+ }
+ }
+
NETLIB_RESETI();
virtual void log_stats();
@@ -495,7 +509,7 @@ namespace solver
m_h_n_m_1[k] = hn;
m_DD_n_m_1[k] = DD_n;
if (plib::abs(DD2) > fp_constants<nl_fptype>::TIMESTEP_MINDIV()) // avoid div-by-zero
- new_net_timestep = plib::sqrt(m_params.m_dynamic_lte / plib::abs(nlconst::magic(0.5)*DD2));
+ new_net_timestep = plib::sqrt(m_params.m_dynamic_lte / plib::abs(nlconst::half()*DD2));
else
new_net_timestep = m_params.m_max_timestep;
diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h
index 5ab282b4c33..a253f160c4a 100644
--- a/src/lib/netlist/solver/nld_ms_sor.h
+++ b/src/lib/netlist/solver/nld_ms_sor.h
@@ -98,7 +98,7 @@ namespace solver
for (std::size_t i = 0; i < term_count; i++)
gabs_t = gabs_t + plib::abs(go[i]);
- gabs_t *= nlconst::magic(0.5); // derived by try and error
+ gabs_t *= nlconst::half(); // derived by try and error
if (gabs_t <= gtot_t)
{
w[k] = ws / static_cast<float_type>(gtot_t);
diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp
index afbbedfcfbb..9ccd56301f4 100644
--- a/src/lib/netlist/tools/nl_convert.cpp
+++ b/src/lib/netlist/tools/nl_convert.cpp
@@ -65,22 +65,22 @@ nl_convert_base_t::nl_convert_base_t()
{
m_buf.imbue(std::locale::classic());
m_units = {
- {"T", "{1}e12", 1.0e12 },
- {"G", "{1}e9", 1.0e9 },
- {"MEG", "RES_M({1})", 1.0e6 },
- {"k", "RES_K({1})", 1.0e3 }, // eagle
- {"K", "RES_K({1})", 1.0e3 },
- {"", "{1}", 1.0e0 },
- {"M", "{1}e-3", 1.0e-3 },
- {"u", "CAP_U({1})", 1.0e-6 }, // eagle
- {"U", "CAP_U({1})", 1.0e-6 },
- {"μ", "CAP_U({1})", 1.0e-6 },
- {"N", "CAP_N({1})", 1.0e-9 },
- {"pF", "CAP_P({1})", 1.0e-12},
- {"P", "CAP_P({1})", 1.0e-12},
- {"F", "{1}e-15", 1.0e-15},
-
- {"MIL", "{1}", 25.4e-6}
+ {"T", "{1}e12", 1.0e12 }, // NOLINT
+ {"G", "{1}e9", 1.0e9 }, // NOLINT
+ {"MEG", "RES_M({1})", 1.0e6 }, // NOLINT
+ {"k", "RES_K({1})", 1.0e3 }, // NOLINT: eagle
+ {"K", "RES_K({1})", 1.0e3 }, // NOLINT
+ {"", "{1}", 1.0e0 }, // NOLINT
+ {"M", "{1}e-3", 1.0e-3 }, // NOLINT
+ {"u", "CAP_U({1})", 1.0e-6 }, // NOLINT: eagle
+ {"U", "CAP_U({1})", 1.0e-6 }, // NOLINT
+ {"μ", "CAP_U({1})", 1.0e-6 }, // NOLINT
+ {"N", "CAP_N({1})", 1.0e-9 }, // NOLINT
+ {"pF", "CAP_P({1})", 1.0e-12}, // NOLINT
+ {"P", "CAP_P({1})", 1.0e-12}, // NOLINT
+ {"F", "{1}e-15", 1.0e-15}, // NOLINT
+
+ {"MIL", "{1}", 25.4e-6} // NOLINT
};
dev_map =
diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h
index f46c4ab9fae..30daa5c4556 100755
--- a/src/lib/netlist/tools/nl_convert.h
+++ b/src/lib/netlist/tools/nl_convert.h
@@ -209,11 +209,10 @@ public:
public:
tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &&strm);
- token_id_t m_tok_ADD;
- token_id_t m_tok_VALUE;
- token_id_t m_tok_SIGNAL;
- token_id_t m_tok_SEMICOLON;
-
+ token_id_t m_tok_ADD; // NOLINT
+ token_id_t m_tok_VALUE; // NOLINT
+ token_id_t m_tok_SIGNAL; // NOLINT
+ token_id_t m_tok_SEMICOLON; // NOLINT
protected:
void verror(const pstring &msg) override;
@@ -242,16 +241,15 @@ public:
public:
tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &&strm);
- token_id_t m_tok_HEA;
- token_id_t m_tok_APP;
- token_id_t m_tok_TIM;
- token_id_t m_tok_TYP;
- token_id_t m_tok_ADDC;
- token_id_t m_tok_ATTC;
- token_id_t m_tok_NET;
- token_id_t m_tok_TER;
- token_id_t m_tok_END;
-
+ token_id_t m_tok_HEA; // NOLINT
+ token_id_t m_tok_APP; // NOLINT
+ token_id_t m_tok_TIM; // NOLINT
+ token_id_t m_tok_TYP; // NOLINT
+ token_id_t m_tok_ADDC; // NOLINT
+ token_id_t m_tok_ATTC; // NOLINT
+ token_id_t m_tok_NET; // NOLINT
+ token_id_t m_tok_TER; // NOLINT
+ token_id_t m_tok_END; // NOLINT
protected:
void verror(const pstring &msg) override;