summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2017-01-17 23:29:19 +0100
committer couriersud <couriersud@gmx.org>2017-01-20 22:20:35 +0100
commit167d8405ec0bec4937ab84c44b63f7102eea56c7 (patch)
treea802c4a59040b089fc30dbbb2dbfd91402cecdb4
parentda169d7fe01c123ddc232415d19faff08196f2fc (diff)
Converted warnings and fatal log messages to constants.
Also refactored some code to ease the exercise. (nw)
-rw-r--r--src/lib/netlist/analog/nld_opamps.cpp4
-rw-r--r--src/lib/netlist/devices/nld_mm5837.cpp4
-rw-r--r--src/lib/netlist/devices/nlid_proxy.cpp4
-rw-r--r--src/lib/netlist/devices/nlid_proxy.h2
-rw-r--r--src/lib/netlist/nl_base.cpp26
-rw-r--r--src/lib/netlist/nl_base.h90
-rw-r--r--src/lib/netlist/nl_errstr.h77
-rw-r--r--src/lib/netlist/nl_parser.cpp25
-rw-r--r--src/lib/netlist/nl_parser.h2
-rw-r--r--src/lib/netlist/nl_setup.cpp98
-rw-r--r--src/lib/netlist/nl_setup.h2
-rw-r--r--src/lib/netlist/plib/pfmtlog.h2
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.cpp8
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.h12
-rw-r--r--src/lib/netlist/solver/nld_ms_direct.h3
-rw-r--r--src/lib/netlist/solver/nld_ms_direct_lu.h6
-rw-r--r--src/lib/netlist/solver/nld_ms_sm.h3
-rw-r--r--src/lib/netlist/solver/nld_ms_w.h3
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp22
19 files changed, 234 insertions, 159 deletions
diff --git a/src/lib/netlist/analog/nld_opamps.cpp b/src/lib/netlist/analog/nld_opamps.cpp
index ff64516186b..35908442781 100644
--- a/src/lib/netlist/analog/nld_opamps.cpp
+++ b/src/lib/netlist/analog/nld_opamps.cpp
@@ -8,7 +8,7 @@
#include "devices/net_lib.h"
#include "nld_opamps.h"
-
+#include "nl_errstr.h"
namespace netlist
{
@@ -100,7 +100,7 @@ namespace netlist
connect("EBUF.IP", "RP1.1");
}
else
- netlist().log().fatal("Unknown opamp type: {1}", m_type);
+ log().fatal(MF_1_UNKNOWN_OPAMP_TYPE, m_type);
}
diff --git a/src/lib/netlist/devices/nld_mm5837.cpp b/src/lib/netlist/devices/nld_mm5837.cpp
index 7650538997b..256ced2d2a7 100644
--- a/src/lib/netlist/devices/nld_mm5837.cpp
+++ b/src/lib/netlist/devices/nld_mm5837.cpp
@@ -72,7 +72,7 @@ namespace netlist
m_RV.set(NL_FCONST(1.0) / R_LOW, 0.0, 0.0);
m_inc = netlist_time::from_double(1.0 / m_FREQ());
if (m_FREQ() < 24000 || m_FREQ() > 56000)
- netlist().log().warning("MM5837: Frequency outside of specs.", m_FREQ());
+ log().warning(MW_1_FREQUENCY_OUTSIDE_OF_SPECS_1, m_FREQ());
m_shift = 0x1ffff;
m_is_timestep = m_RV.m_P.net().solver()->is_timestep();
@@ -82,7 +82,7 @@ namespace netlist
{
m_inc = netlist_time::from_double(1.0 / m_FREQ());
if (m_FREQ() < 24000 || m_FREQ() > 56000)
- netlist().log().warning("MM5837: Frequency outside of specs.", m_FREQ());
+ log().warning(MW_1_FREQUENCY_OUTSIDE_OF_SPECS_1, m_FREQ());
}
NETLIB_UPDATE(MM5837_dip)
diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp
index 0b08327070c..5f1db5c8179 100644
--- a/src/lib/netlist/devices/nlid_proxy.cpp
+++ b/src/lib/netlist/devices/nlid_proxy.cpp
@@ -121,9 +121,9 @@ namespace netlist
}
}
if (!f)
- netlist().log().warning("D/A Proxy: Found no valid combination of power terminals on device {1}", out_proxied->device().name());
+ log().warning(MW_1_NO_POWER_TERMINALS_ON_DEVICE_1, out_proxied->device().name());
else
- netlist().log().warning("D/A Proxy: Found power terminals on device {1}", out_proxied->device().name());
+ log().verbose("D/A Proxy: Found power terminals on device {1}", out_proxied->device().name());
#if (0)
printf("%s %s\n", out_proxied->name().c_str(), out_proxied->device().name().c_str());
auto x = netlist().setup().find_terminal(out_proxied->name(), detail::device_object_t::type_t::OUTPUT, false);
diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h
index 77a8d52026c..f52e8f61907 100644
--- a/src/lib/netlist/devices/nlid_proxy.h
+++ b/src/lib/netlist/devices/nlid_proxy.h
@@ -127,7 +127,7 @@ namespace netlist
analog::NETLIB_SUB(twoterm) m_RV;
state_var<int> m_last_state;
bool m_is_timestep;
- };
+};
} //namespace devices
} // namespace netlist
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index 3e000cb5a08..9542e111a7a 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -600,6 +600,21 @@ void netlist_t::print_stats() const
}
}
+core_device_t *netlist_t::pget_single_device(const char *classname, bool (*cc)(core_device_t *))
+{
+ core_device_t *ret = nullptr;
+ for (auto &d : m_devices)
+ {
+ if (cc(d.get()))
+ {
+ if (ret != nullptr)
+ this->log().fatal(MF_1_MORE_THAN_ONE_1_DEVICE_FOUND, classname);
+ else
+ ret = d.get();
+ }
+ }
+ return ret;
+}
// ----------------------------------------------------------------------------------------
@@ -651,6 +666,11 @@ void core_device_t::set_delegate_pointer()
#endif
}
+plib::plog_base<NL_DEBUG> &core_device_t::log()
+{
+ return netlist().log();
+}
+
// ----------------------------------------------------------------------------------------
// device_t
// ----------------------------------------------------------------------------------------
@@ -698,7 +718,7 @@ void device_t::connect(const pstring &t1, const pstring &t2)
void device_t::connect_post_start(detail::core_terminal_t &t1, detail::core_terminal_t &t2)
{
if (!setup().connect(t1, t2))
- netlist().log().fatal(MF_2_ERROR_CONNECTING_1_TO_2, t1.name(), t2.name());
+ log().fatal(MF_2_ERROR_CONNECTING_1_TO_2, t1.name(), t2.name());
}
@@ -1174,7 +1194,7 @@ param_ptr_t::~param_ptr_t()
void param_model_t::changed()
{
- netlist().log().fatal("Models can not be changed at runtime");
+ netlist().log().fatal(MF_1_MODEL_1_CAN_NOT_BE_CHANGED_AT_RUNTIME, name());
m_map.clear();
}
@@ -1201,8 +1221,6 @@ std::unique_ptr<plib::pistream> param_data_t::stream()
return device().netlist().setup().get_data_stream(Value());
}
-
-
namespace devices
{
// ----------------------------------------------------------------------------------------
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index dfaa5a8fbba..3007a202d58 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -990,7 +990,7 @@ namespace netlist
/* hide this */
void setTo(const pstring &param) = delete;
model_map_t m_map;
- };
+};
class param_data_t : public param_str_t
@@ -1004,6 +1004,28 @@ namespace netlist
};
// -----------------------------------------------------------------------------
+ // rom parameter
+ // -----------------------------------------------------------------------------
+
+ template <typename ST, std::size_t AW, std::size_t DW>
+ class param_rom_t final: public param_data_t
+ {
+ public:
+
+ param_rom_t(device_t &device, const pstring name);
+
+ const ST & operator[] (std::size_t n) { return m_data[n]; }
+ protected:
+ virtual void changed() override
+ {
+ stream()->read(&m_data[0],1<<AW);
+ }
+
+ private:
+ ST m_data[1 << AW];
+ };
+
+ // -----------------------------------------------------------------------------
// core_device_t
// -----------------------------------------------------------------------------
@@ -1069,6 +1091,8 @@ namespace netlist
#endif
}
+ plib::plog_base<NL_DEBUG> &log();
+
public:
virtual void timestep(ATTR_UNUSED const nl_double st) { }
virtual void update_terminals() { }
@@ -1230,22 +1254,16 @@ namespace netlist
return tmp;
}
- template<class device_class>
- device_class *get_single_device(const char *classname)
+ template<class C>
+ static bool check_class(core_device_t *p)
{
- device_class *ret = nullptr;
- for (auto &d : m_devices)
- {
- device_class *dev = dynamic_cast<device_class *>(d.get());
- if (dev != nullptr)
- {
- if (ret != nullptr)
- this->log().fatal("more than one {1} device found", classname);
- else
- ret = dev;
- }
- }
- return ret;
+ return dynamic_cast<C *>(p) != nullptr;
+ }
+
+ template<class C>
+ C *get_single_device(const char *classname)
+ {
+ return dynamic_cast<C *>(pget_single_device(classname, check_class<C>));
}
/* logging and name */
@@ -1278,6 +1296,9 @@ namespace netlist
void print_stats() const;
private:
+
+ core_device_t *pget_single_device(const char *classname, bool (*cc)(core_device_t *));
+
/* mostly rw */
netlist_time m_time;
detail::queue_t m_queue;
@@ -1326,38 +1347,19 @@ namespace netlist
};
// -----------------------------------------------------------------------------
- // rom parameter
+ // inline implementations
// -----------------------------------------------------------------------------
template <typename ST, std::size_t AW, std::size_t DW>
- class param_rom_t final: public param_data_t
+ inline param_rom_t<ST, AW, DW>::param_rom_t(device_t &device, const pstring name)
+ : param_data_t(device, name)
{
- public:
-
- param_rom_t(device_t &device, const pstring name)
- : param_data_t(device, name)
- {
- auto f = stream();
- if (f != nullptr)
- f->read(&m_data[0],1<<AW);
- else
- device.netlist().log().warning("Rom {1} not found", Value());
- }
-
- const ST & operator[] (std::size_t n) { return m_data[n]; }
-
- protected:
- virtual void changed() override
- {
- stream()->read(&m_data[0],1<<AW);
- }
- private:
- ST m_data[1 << AW];
- };
-
- // -----------------------------------------------------------------------------
- // inline implementations
- // -----------------------------------------------------------------------------
+ auto f = stream();
+ if (f != nullptr)
+ f->read(&m_data[0],1<<AW);
+ else
+ device.netlist().log().warning("Rom {1} not found", Value());
+ }
inline bool detail::core_terminal_t::is_logic() const NL_NOEXCEPT
{
diff --git a/src/lib/netlist/nl_errstr.h b/src/lib/netlist/nl_errstr.h
index 563e33dd93f..47311183127 100644
--- a/src/lib/netlist/nl_errstr.h
+++ b/src/lib/netlist/nl_errstr.h
@@ -17,12 +17,85 @@
#define MF_2_REMOVE_TERMINAL_1_FROM_NET_2 "Can not remove terminal {1} from net {2}."
#define MF_1_UNKNOWN_PARAM_TYPE "Can not determine param_type for {1}"
#define MF_2_ERROR_CONNECTING_1_TO_2 "Error connecting {1} to {2}"
-#define MF_0_NO_SOLVER "No solver found for this netlist although analog elements are present\n"
+#define MF_0_NO_SOLVER "No solver found for this netlist although analog elements are present"
// nl_factory.cpp
#define MF_1_FACTORY_ALREADY_CONTAINS_1 "factory already contains {1}"
#define MF_1_CLASS_1_NOT_FOUND "Class <{1}> not found!"
+// nld_opamps.cpp
-#endif /* NLBASE_H_ */
+#define MF_1_UNKNOWN_OPAMP_TYPE "Unknown opamp type: {1}"
+
+// nld_matrix_solver.cpp
+
+#define MF_1_UNHANDLED_ELEMENT_1_FOUND "setup_base:unhandled element <{1}> found"
+#define MF_1_FOUND_TERM_WITH_MISSING_OTHERNET "found term with missing othernet {1}"
+
+#define MW_1_NEWTON_LOOPS_EXCEEDED_ON_NET_1 "NEWTON_LOOPS exceeded on net {1}... reschedule"
+
+// nld_solver.cpp
+
+#define MF_1_UNKNOWN_SOLVER_TYPE "Unknown solver type: {1}"
+#define MF_1_NETGROUP_SIZE_EXCEEDED_1 "Encountered netgroup with > {1} nets"
+
+#define MW_1_NO_SPECIFIC_SOLVER "No specific solver found for netlist of size {1}"
+
+// nl_base.cpp
+
+#define MF_1_MODEL_1_CAN_NOT_BE_CHANGED_AT_RUNTIME "Model {1} can not be changed at runtime"
+#define MF_1_MORE_THAN_ONE_1_DEVICE_FOUND "more than one {1} device found"
+
+// nl_parser.cpp
+
+#define MF_0_UNEXPECTED_NETLIST_END "Unexpected NETLIST_END"
+#define MF_0_UNEXPECTED_NETLIST_START "Unexpected NETLIST_START"
+
+// nl_setup.cpp
+
+//#define MF_1_CLASS_1_NOT_FOUND "Class {1} not found!"
+#define MF_1_UNABLE_TO_PARSE_MODEL_1 "Unable to parse model: {1}"
+#define MF_1_MODEL_ALREADY_EXISTS_1 "Model already exists: {1}"
+#define MF_1_ADDING_ALIAS_1_TO_ALIAS_LIST "Error adding alias {1} to alias list"
+#define MF_1_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1 "You must pass an equal number of pins to DIPPINS {1}"
+#define MF_1_UNKNOWN_OBJECT_TYPE_1 "Unknown object type {1}"
+#define MF_2_INVALID_NUMBER_CONVERSION_1_2 "Invalid number conversion {1} : {2}"
+#define MF_1_ADDING_PARAMETER_1_TO_PARAMETER_LIST "Error adding parameter {1} to parameter list"
+#define MF_2_ADDING_1_2_TO_TERMINAL_LIST "Error adding {1} {2} to terminal list"
+#define MF_2_NET_C_NEEDS_AT_LEAST_2_TERMINAL "You must pass at least 2 terminals to NET_C"
+#define MF_1_FOUND_NO_OCCURRENCE_OF_1 "Found no occurrence of {1}"
+#define MF_2_TERMINAL_1_2_NOT_FOUND "terminal {1}({2}) not found!"
+#define MF_2_OBJECT_1_2_WRONG_TYPE "object {1}({2}) found but wrong type"
+#define MF_2_PARAMETER_1_2_NOT_FOUND "parameter {1}({2}) not found!"
+#define MF_2_CONNECTING_1_TO_2 "Error connecting {1} to {2}"
+#define MF_2_MERGE_RAIL_NETS_1_AND_2 "Trying to merge two rail nets: {1} and {2}"
+#define MF_1_OBJECT_INPUT_TYPE_1 "Unable to determine input type of {1}"
+#define MF_1_OBJECT_OUTPUT_TYPE_1 "Unable to determine output type of {1}"
+#define MF_1_INPUT_1_ALREADY_CONNECTED "Input {1} already connected"
+#define MF_0_LINK_TRIES_EXCEEDED "Error connecting -- bailing out"
+#define MF_1_MODEL_NOT_FOUND "Model {1} not found"
+#define MF_1_MODEL_ERROR_1 "Model error {1}"
+#define MF_1_MODEL_ERROR_ON_PAIR_1 "Model error on pair {1}"
+#define MF_2_MODEL_PARAMETERS_NOT_UPPERCASE_1_2 "model parameters should be uppercase:{1} {2}"
+#define MF_2_ENTITY_1_NOT_FOUND_IN_MODEL_2 "Entity {1} not found in model {2}"
+#define MF_1_UNKNOWN_NUMBER_FACTOR_IN_1 "Unknown number factor in: {1}"
+#define MF_1_NOT_FOUND_IN_SOURCE_COLLECTION "unable to find {1} in source collection"
+
+#define MW_3_OVERWRITING_PARAM_1_OLD_2_NEW_3 "Overwriting {1} old <{2}> new <{3}>"
+#define MW_1_CONNECTING_1_TO_ITSELF "Connecting {1} to itself. This may be right, though"
+#define MW_1_DUMMY_1_WITHOUT_CONNECTIONS "Found dummy terminal {1} without connections"
+#define MW_1_TERMINAL_1_WITHOUT_CONNECTIONS "Found terminal {1} without connections"
+#define MW_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3 "Found device {1} connected only to railterminals {2}/{3}. Will be removed"
+#define MW_1_DATA_1_NOT_FOUND "unable to find data named {1} in source collection"
+
+// nld_mm5837.cpp
+
+#define MW_1_FREQUENCY_OUTSIDE_OF_SPECS_1 "MM5837: Frequency outside of specs: {1}"
+
+// nlid_proxy.cpp
+
+#define MW_1_NO_POWER_TERMINALS_ON_DEVICE_1 "D/A Proxy: Found no valid combination of power terminals on device {1}"
+
+
+#endif /* NL_ERRSTR_H_ */
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp
index 365054fc7d0..15f185ea712 100644
--- a/src/lib/netlist/nl_parser.cpp
+++ b/src/lib/netlist/nl_parser.cpp
@@ -7,6 +7,7 @@
#include "nl_parser.h"
#include "nl_factory.h"
+#include "nl_errstr.h"
#include "devices/nld_truthtable.h"
namespace netlist
@@ -68,14 +69,13 @@ bool parser_t::parse(const pstring nlname)
if (token.is_type(ENDOFFILE))
{
return false;
- //error("EOF while searching for <{1}>", nlname);
}
if (token.is(m_tok_NETLIST_END))
{
require_token(m_tok_param_left);
if (!in_nl)
- error("Unexpected NETLIST_END");
+ error (MF_0_UNEXPECTED_NETLIST_END);
else
{
in_nl = false;
@@ -85,7 +85,7 @@ bool parser_t::parse(const pstring nlname)
else if (token.is(m_tok_NETLIST_START))
{
if (in_nl)
- error("Unexpected NETLIST_START");
+ error (MF_0_UNEXPECTED_NETLIST_START);
require_token(m_tok_param_left);
token_t name = get_token();
require_token(m_tok_param_right);
@@ -415,7 +415,6 @@ nl_double parser_t::eval_param(const token_t tok)
for (i=1; i<6;i++)
if (tok.str().equals(macs[i]))
f = i;
-#if 1
if (f>0)
{
require_token(m_tok_param_left);
@@ -431,22 +430,6 @@ nl_double parser_t::eval_param(const token_t tok)
}
return ret * facs[f];
-#else
- if (f>0)
- {
- require_token(m_tok_param_left);
- val = get_identifier();
- }
- else
- val = tok.str();
-
- ret = val.as_double(&e);
-
- if (e)
- fatal("Error with parameter ...\n");
- if (f>0)
- require_token(m_tok_param_right);
- return ret * facs[f];
-#endif
}
+
}
diff --git a/src/lib/netlist/nl_parser.h b/src/lib/netlist/nl_parser.h
index a023a7cbbab..c767ba65306 100644
--- a/src/lib/netlist/nl_parser.h
+++ b/src/lib/netlist/nl_parser.h
@@ -72,7 +72,7 @@ namespace netlist
setup_t &m_setup;
const char *m_buf;
- };
+};
}
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index cf090c68dbe..1b0835d8cdc 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -80,7 +80,7 @@ void setup_t::register_dev(const pstring &classname, const pstring &name)
{
auto f = factory().factory_by_name(classname);
if (f == nullptr)
- log().fatal("Class {1} not found!\n", classname);
+ log().fatal(MF_1_CLASS_1_NOT_FOUND, classname);
/* make sure we parse macro library entries */
f->macro_actions(netlist(), name);
m_device_factory.push_back(std::pair<pstring, factory::element_t *>(build_fqn(name), f));
@@ -101,17 +101,17 @@ void setup_t::register_model(const pstring &model_in)
{
auto pos = model_in.find(" ");
if (pos == model_in.end())
- log().fatal("Unable to parse model: {1}", model_in);
+ log().fatal(MF_1_UNABLE_TO_PARSE_MODEL_1, model_in);
pstring model = model_in.left(pos).trim().ucase();
pstring def = model_in.substr(pos + 1).trim();
if (!m_models.insert({model, def}).second)
- log().fatal("Model already exists: {1}", model_in);
+ log().fatal(MF_1_MODEL_ALREADY_EXISTS_1, model_in);
}
void setup_t::register_alias_nofqn(const pstring &alias, const pstring &out)
{
if (!m_alias.insert({alias, out}).second)
- log().fatal("Error adding alias {1} to alias list\n", alias);
+ log().fatal(MF_1_ADDING_ALIAS_1_TO_ALIAS_LIST, alias);
}
void setup_t::register_alias(const pstring &alias, const pstring &out)
@@ -125,7 +125,8 @@ void setup_t::register_dippins_arr(const pstring &terms)
{
plib::pstring_vector_t list(terms,", ");
if (list.size() == 0 || (list.size() % 2) == 1)
- log().fatal("You must pass an equal number of pins to DIPPINS {1}" , build_fqn(""));
+ log().fatal(MF_1_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1,
+ build_fqn(""));
std::size_t n = list.size();
for (std::size_t i = 0; i < n / 2; i++)
{
@@ -148,7 +149,7 @@ pstring setup_t::objtype_as_str(detail::device_object_t &in) const
return "PARAM";
}
// FIXME: noreturn
- log().fatal("Unknown object type {1}\n", static_cast<unsigned>(in.type()));
+ log().fatal(MF_1_UNKNOWN_OBJECT_TYPE_1, static_cast<unsigned>(in.type()));
return "Error";
}
@@ -168,7 +169,7 @@ double setup_t::get_initial_param_val(const pstring name, const double def)
{
double vald = 0;
if (sscanf(i->second.c_str(), "%lf", &vald) != 1)
- log().fatal("Invalid number conversion {1} : {2}\n", name, i->second);
+ log().fatal(MF_2_INVALID_NUMBER_CONVERSION_1_2, name, i->second);
return vald;
}
else
@@ -182,7 +183,7 @@ int setup_t::get_initial_param_val(const pstring name, const int def)
{
double vald = 0;
if (sscanf(i->second.c_str(), "%lf", &vald) != 1)
- log().fatal("Invalid number conversion {1} : {2}\n", name, i->second);
+ log().fatal(MF_2_INVALID_NUMBER_CONVERSION_1_2, name, i->second);
return static_cast<int>(vald);
}
else
@@ -192,13 +193,14 @@ int setup_t::get_initial_param_val(const pstring name, const int def)
void setup_t::register_param(pstring name, param_t &param)
{
if (!m_params.insert({param.name(), param_ref_t(param.name(), param.device(), param)}).second)
- log().fatal("Error adding parameter {1} to parameter list\n", name);
+ log().fatal(MF_1_ADDING_PARAMETER_1_TO_PARAMETER_LIST, name);
}
void setup_t::register_term(detail::core_terminal_t &term)
{
if (!m_terminals.insert({term.name(), &term}).second)
- log().fatal("Error adding {1} {2} to terminal list\n", objtype_as_str(term), term.name());
+ log().fatal(MF_2_ADDING_1_2_TO_TERMINAL_LIST, objtype_as_str(term),
+ term.name());
log().debug("{1} {2}\n", objtype_as_str(term), term.name());
}
@@ -206,7 +208,7 @@ void setup_t::register_link_arr(const pstring &terms)
{
plib::pstring_vector_t list(terms,", ");
if (list.size() < 2)
- log().fatal("You must pass at least 2 terminals to NET_C");
+ log().fatal(MF_2_NET_C_NEEDS_AT_LEAST_2_TERMINAL);
for (std::size_t i = 1; i < list.size(); i++)
{
register_link(list[0], list[i]);
@@ -243,7 +245,7 @@ void setup_t::remove_connections(const pstring pin)
link++;
}
if (!found)
- log().fatal("remove_connections: found no occurrence of {1}\n", pin);
+ log().fatal(MF_1_FOUND_NO_OCCURRENCE_OF_1, pin);
}
@@ -272,7 +274,7 @@ void setup_t::register_frontier(const pstring attach, const double r_IN, const d
}
}
if (!found)
- log().fatal("Frontier setup: found no occurrence of {1}\n", attach);
+ log().fatal(MF_1_FOUND_NO_OCCURRENCE_OF_1, attach);
register_link(attach, frontier_name + ".Q");
}
@@ -290,11 +292,13 @@ void setup_t::register_param(const pstring &param, const pstring &value)
if (idx == m_param_values.end())
{
if (!m_param_values.insert({fqn, value}).second)
- log().fatal("Unexpected error adding parameter {1} to parameter list\n", param);
+ log().fatal(MF_1_ADDING_PARAMETER_1_TO_PARAMETER_LIST,
+ param);
}
else
{
- log().warning("Overwriting {1} old <{2}> new <{3}>\n", fqn, idx->second, value);
+ log().warning(MW_3_OVERWRITING_PARAM_1_OLD_2_NEW_3, fqn, idx->second,
+ value);
m_param_values[fqn] = value;
}
}
@@ -329,7 +333,7 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in, bool
detail::core_terminal_t *term = (ret == m_terminals.end() ? nullptr : ret->second);
if (term == nullptr && required)
- log().fatal("terminal {1}({2}) not found!\n", terminal_in, tname);
+ log().fatal(MF_2_TERMINAL_1_2_NOT_FOUND, terminal_in, tname);
if (term != nullptr)
log().debug("Found input {1}\n", tname);
return term;
@@ -347,14 +351,14 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in,
ret = m_terminals.find(tname + ".Q");
}
if (ret == m_terminals.end() && required)
- log().fatal("terminal {1}({2}) not found!\n", terminal_in, tname);
+ log().fatal(MF_2_TERMINAL_1_2_NOT_FOUND, terminal_in, tname);
detail::core_terminal_t *term = (ret == m_terminals.end() ? nullptr : ret->second);
if (term != nullptr && term->type() != atype)
{
if (required)
- log().fatal("object {1}({2}) found but wrong type\n", terminal_in, tname);
+ log().fatal(MF_2_OBJECT_1_2_WRONG_TYPE, terminal_in, tname);
else
term = nullptr;
}
@@ -371,7 +375,7 @@ param_t *setup_t::find_param(const pstring &param_in, bool required) const
const pstring &outname = resolve_alias(param_in_fqn);
auto ret = m_params.find(outname);
if (ret == m_params.end() && required)
- log().fatal("parameter {1}({2}) not found!\n", param_in_fqn, outname);
+ log().fatal(MF_2_PARAMETER_1_2_NOT_FOUND, param_in_fqn, outname);
if (ret != m_params.end())
log().debug("Found parameter {1}\n", outname);
return (ret == m_params.end() ? nullptr : &ret->second.m_param);
@@ -401,7 +405,8 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(detail::core_terminal_t &out)
{
p->clear_net(); // de-link from all nets ...
if (!connect(new_proxy->proxy_term(), *p))
- log().fatal("Error connecting {1} to {2}\n", new_proxy->proxy_term().name(), (*p).name());
+ log().fatal(MF_2_CONNECTING_1_TO_2,
+ new_proxy->proxy_term().name(), (*p).name());
}
out.net().m_core_terms.clear(); // clear the list
@@ -444,7 +449,8 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
{
p->clear_net(); // de-link from all nets ...
if (!connect(ret->proxy_term(), *p))
- log().fatal("Error connecting {1} to {2}\n", ret->proxy_term().name(), (*p).name());
+ log().fatal(MF_2_CONNECTING_1_TO_2,
+ ret->proxy_term().name(), (*p).name());
}
inp.net().m_core_terms.clear(); // clear the list
}
@@ -463,19 +469,20 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
{
- netlist().log().debug("merging nets ...\n");
+ log().debug("merging nets ...\n");
if (&othernet == &thisnet)
{
- netlist().log().warning("Connecting {1} to itself. This may be right, though\n", thisnet.name());
+ log().warning(MW_1_CONNECTING_1_TO_ITSELF, thisnet.name());
return; // Nothing to do
}
if (thisnet.isRailNet() && othernet.isRailNet())
- netlist().log().fatal("Trying to merge two rail nets: {1} and {2}\n", thisnet.name(), othernet.name());
+ log().fatal(MF_2_MERGE_RAIL_NETS_1_AND_2,
+ thisnet.name(), othernet.name());
if (othernet.isRailNet())
{
- netlist().log().debug("othernet is railnet\n");
+ log().debug("othernet is railnet\n");
merge_nets(othernet, thisnet);
}
else
@@ -519,7 +526,7 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
}
else if (inp.is_logic())
{
- netlist().log().verbose("connect terminal {1} (in, {2}) to {3}\n", inp.name(), pstring(inp.is_analog() ? "analog" : inp.is_logic() ? "logic" : "?"), term.name());
+ log().verbose("connect terminal {1} (in, {2}) to {3}\n", inp.name(), pstring(inp.is_analog() ? "analog" : inp.is_logic() ? "logic" : "?"), term.name());
auto proxy = get_a_d_proxy(inp);
//out.net().register_con(proxy->proxy_term());
@@ -528,7 +535,7 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
}
else
{
- log().fatal("Netlist: Severe Error");
+ log().fatal(MF_1_OBJECT_INPUT_TYPE_1, inp.name());
}
}
@@ -552,7 +559,7 @@ void setup_t::connect_terminal_output(terminal_t &in, detail::core_terminal_t &o
}
else
{
- log().fatal("Netlist: Severe Error");
+ log().fatal(MF_1_OBJECT_OUTPUT_TYPE_1, out.name());
}
}
@@ -644,13 +651,13 @@ bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t
if (t1.is_type(detail::core_terminal_t::OUTPUT) && t2.is_type(detail::core_terminal_t::INPUT))
{
if (t2.has_net() && t2.net().isRailNet())
- log().fatal("Input {1} already connected\n", t2.name());
+ log().fatal(MF_1_INPUT_1_ALREADY_CONNECTED, t2.name());
connect_input_output(t2, t1);
}
else if (t1.is_type(detail::core_terminal_t::INPUT) && t2.is_type(detail::core_terminal_t::OUTPUT))
{
if (t1.has_net() && t1.net().isRailNet())
- log().fatal("Input {1} already connected\n", t1.name());
+ log().fatal(MF_1_INPUT_1_ALREADY_CONNECTED, t1.name());
connect_input_output(t1, t2);
}
else if (t1.is_type(detail::core_terminal_t::OUTPUT) && t2.is_type(detail::core_terminal_t::TERMINAL))
@@ -712,9 +719,9 @@ void setup_t::resolve_inputs()
if (tries == 0)
{
for (auto & link : m_links)
- log().warning("Error connecting {1} to {2}\n", link.first, link.second);
+ log().warning(MF_2_CONNECTING_1_TO_2, link.first, link.second);
- log().fatal("Error connecting -- bailing out\n");
+ log().fatal(MF_0_LINK_TRIES_EXCEEDED);
}
log().verbose("deleting empty nets ...");
@@ -741,12 +748,13 @@ void setup_t::resolve_inputs()
{
detail::core_terminal_t *term = i.second;
if (!term->has_net() && dynamic_cast< devices::NETLIB_NAME(dummy_input) *>(&term->device()) != nullptr)
- log().warning("Found dummy terminal {1} without connections", term->name());
+ log().warning(MW_1_DUMMY_1_WITHOUT_CONNECTIONS, term->name());
else if (!term->has_net())
errstr += plib::pfmt("Found terminal {1} without a net\n")(term->name());
else if (term->net().num_cons() == 0)
- log().warning("Found terminal {1} without connections", term->name());
+ log().warning(MW_1_TERMINAL_1_WITHOUT_CONNECTIONS, term->name());
}
+ //FIXME: error string handling
if (errstr != "")
log().fatal("{1}", errstr);
@@ -756,7 +764,7 @@ void setup_t::resolve_inputs()
{
if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
{
- log().warning("Found device {1} connected only to railterminals {2}/{3}. Will be removed",
+ log().warning(MW_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3,
t->name(), t->m_N.net().name(), t->m_P.net().name());
t->m_N.net().remove_terminal(t->m_N);
t->m_P.net().remove_terminal(t->m_P);
@@ -821,7 +829,7 @@ void setup_t::model_parse(const pstring &model_in, model_map_t &map)
key = model.ucase();
auto i = m_models.find(key);
if (i == m_models.end())
- log().fatal("Model {1} not found\n", model);
+ log().fatal(MF_1_MODEL_NOT_FOUND, model);
model = i->second;
}
pstring xmodel = model.left(pos);
@@ -834,12 +842,12 @@ void setup_t::model_parse(const pstring &model_in, model_map_t &map)
if (i != m_models.end())
model_parse(xmodel, map);
else
- log().fatal("Model doesn't exist: <{1}>\n", model_in);
+ log().fatal(MF_1_MODEL_NOT_FOUND, model_in);
}
pstring remainder=model.substr(pos+1).trim();
if (!remainder.endsWith(")"))
- log().fatal("Model error {1}\n", model);
+ log().fatal(MF_1_MODEL_ERROR_1, model);
// FIMXE: Not optimal
remainder = remainder.left(remainder.begin() + (remainder.len() - 1));
@@ -848,7 +856,7 @@ void setup_t::model_parse(const pstring &model_in, model_map_t &map)
{
auto pose = pe.find("=");
if (pose == pe.end())
- log().fatal("Model error on pair {1}\n", model);
+ log().fatal(MF_1_MODEL_ERROR_ON_PAIR_1, model);
map[pe.left(pose).ucase()] = pe.substr(pose+1);
}
}
@@ -858,9 +866,10 @@ const pstring setup_t::model_value_str(model_map_t &map, const pstring &entity)
pstring ret;
if (entity != entity.ucase())
- log().fatal("model parameters should be uppercase:{1} {2}\n", entity, model_string(map));
+ log().fatal(MF_2_MODEL_PARAMETERS_NOT_UPPERCASE_1_2, entity,
+ model_string(map));
if (map.find(entity) == map.end())
- log().fatal("Entity {1} not found in model {2}\n", entity, model_string(map));
+ log().fatal(MF_2_ENTITY_1_NOT_FOUND_IN_MODEL_2, entity, model_string(map));
else
ret = map[entity];
@@ -885,7 +894,7 @@ nl_double setup_t::model_value(model_map_t &map, const pstring &entity)
case 'a': factor = 1e-18; break;
default:
if (*p < '0' || *p > '9')
- nl_exception(plib::pfmt("Unknown number factor in: {1}")(entity));
+ log().fatal(MF_1_UNKNOWN_NUMBER_FACTOR_IN_1, entity);
}
if (factor != NL_FCONST(1.0))
tmp = tmp.left(tmp.begin() + (tmp.len() - 1));
@@ -909,7 +918,7 @@ void setup_t::include(const pstring &netlist_name)
if (source->parse(netlist_name))
return;
}
- log().fatal("unable to find {1} in source collection", netlist_name);
+ log().fatal(MF_1_NOT_FOUND_IN_SOURCE_COLLECTION, netlist_name);
}
std::unique_ptr<plib::pistream> setup_t::get_data_stream(const pstring name)
@@ -923,8 +932,7 @@ std::unique_ptr<plib::pistream> setup_t::get_data_stream(const pstring name)
return strm;
}
}
- //log().fatal("unable to find data named {1} in source collection", name);
- log().warning("unable to find data named {1} in source collection", name);
+ log().warning(MW_1_DATA_1_NOT_FOUND, name);
return std::unique_ptr<plib::pistream>(nullptr);
}
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index 1ce715a9fdf..2d4f75dc4af 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -315,7 +315,7 @@ namespace netlist
unsigned m_proxy_cnt;
unsigned m_frontier_cnt;
- };
+};
// ----------------------------------------------------------------------------------------
// base sources
diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h
index c5369109b81..56690853a0d 100644
--- a/src/lib/netlist/plib/pfmtlog.h
+++ b/src/lib/netlist/plib/pfmtlog.h
@@ -237,7 +237,7 @@ public:
bool is_enabled() const { return m_enabled; }
protected:
- virtual void vdowrite(const pstring &ls) const {}
+ virtual void vdowrite(const pstring &ls) const = 0;
private:
bool m_enabled;
diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp
index a27301a754d..051fa10a253 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.cpp
+++ b/src/lib/netlist/solver/nld_matrix_solver.cpp
@@ -100,6 +100,7 @@ matrix_solver_t::~matrix_solver_t()
void matrix_solver_t::setup_base(analog_net_t::list_t &nets)
{
+
log().debug("New solver setup\n");
m_nets.clear();
@@ -164,7 +165,8 @@ void matrix_solver_t::setup_base(analog_net_t::list_t &nets)
break;
case terminal_t::OUTPUT:
case terminal_t::PARAM:
- log().fatal("unhandled element found\n");
+ log().fatal(MF_1_UNHANDLED_ELEMENT_1_FOUND,
+ p->name());
break;
}
}
@@ -423,7 +425,7 @@ void matrix_solver_t::solve_base()
// reschedule ....
if (this_resched > 1 && !m_Q_sync.net().is_queued())
{
- log().warning("NEWTON_LOOPS exceeded on net {1}... reschedule", this->name());
+ log().warning(MW_1_NEWTON_LOOPS_EXCEEDED_ON_NET_1, this->name());
m_Q_sync.net().toggle_new_Q();
m_Q_sync.net().reschedule_in_queue(m_params.m_nr_recalc_delay);
}
@@ -479,7 +481,7 @@ void matrix_solver_t::add_term(std::size_t k, terminal_t *term)
else // if (ot<0)
{
m_rails_temp[k]->add(term, ot, true);
- log().fatal("found term with missing othernet {1}\n", term->name());
+ log().fatal(MF_1_FOUND_TERM_WITH_MISSING_OTHERNET, term->name());
}
}
}
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h
index 522b157eafb..fb3b044ee47 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.h
+++ b/src/lib/netlist/solver/nld_matrix_solver.h
@@ -8,11 +8,8 @@
#ifndef NLD_MATRIX_SOLVER_H_
#define NLD_MATRIX_SOLVER_H_
-#include <type_traits>
-
-//#include "solver/nld_solver.h"
#include "nl_base.h"
-#include "plib/pstream.h"
+#include "nl_errstr.h"
namespace netlist
{
@@ -110,7 +107,10 @@ public:
virtual ~matrix_solver_t();
- void setup(analog_net_t::list_t &nets) { vsetup(nets); }
+ void setup(analog_net_t::list_t &nets)
+ {
+ vsetup(nets);
+ }
void solve_base();
@@ -133,8 +133,6 @@ public:
public:
int get_net_idx(detail::net_t *net);
- plib::plog_base<NL_DEBUG> &log() { return netlist().log(); }
-
virtual void log_stats();
virtual void create_solver_code(plib::postream &strm)
diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h
index 5b4a33ce66e..a5ee5bbf8c1 100644
--- a/src/lib/netlist/solver/nld_ms_direct.h
+++ b/src/lib/netlist/solver/nld_ms_direct.h
@@ -195,9 +195,6 @@ matrix_solver_direct_t<m_N, storage_N>::~matrix_solver_direct_t()
template <unsigned m_N, unsigned storage_N>
void matrix_solver_direct_t<m_N, storage_N>::vsetup(analog_net_t::list_t &nets)
{
- if (m_dim < nets.size())
- log().fatal("Dimension {1} less than {2}", m_dim, nets.size());
-
matrix_solver_t::setup_base(nets);
/* add RHS element */
diff --git a/src/lib/netlist/solver/nld_ms_direct_lu.h b/src/lib/netlist/solver/nld_ms_direct_lu.h
index f71982f8eb4..c5ebb5f197a 100644
--- a/src/lib/netlist/solver/nld_ms_direct_lu.h
+++ b/src/lib/netlist/solver/nld_ms_direct_lu.h
@@ -345,10 +345,10 @@ void matrix_solver_direct_t<m_N, storage_N>::vsetup(analog_net_t::list_t &nets)
if(0)
for (unsigned k = 0; k < N(); k++)
{
- netlist().log("{1:3}: ", k);
+ log("{1:3}: ", k);
for (unsigned j = 0; j < m_terms[k]->m_nzrd.size(); j++)
- netlist().log(" {1:3}", m_terms[k]->m_nzrd[j]);
- netlist().log("\n");
+ log(" {1:3}", m_terms[k]->m_nzrd[j]);
+ log("\n");
}
/*
diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h
index 2f3597f3a89..089d93cb025 100644
--- a/src/lib/netlist/solver/nld_ms_sm.h
+++ b/src/lib/netlist/solver/nld_ms_sm.h
@@ -122,9 +122,6 @@ matrix_solver_sm_t<m_N, storage_N>::~matrix_solver_sm_t()
template <unsigned m_N, unsigned storage_N>
void matrix_solver_sm_t<m_N, storage_N>::vsetup(analog_net_t::list_t &nets)
{
- if (m_dim < nets.size())
- log().fatal("Dimension {1} less than {2}", m_dim, nets.size());
-
matrix_solver_t::setup_base(nets);
netlist().save(*this, m_last_RHS, "m_last_RHS");
diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h
index e644ce40085..a0850fe5157 100644
--- a/src/lib/netlist/solver/nld_ms_w.h
+++ b/src/lib/netlist/solver/nld_ms_w.h
@@ -131,9 +131,6 @@ matrix_solver_w_t<m_N, storage_N>::~matrix_solver_w_t()
template <unsigned m_N, unsigned storage_N>
void matrix_solver_w_t<m_N, storage_N>::vsetup(analog_net_t::list_t &nets)
{
- if (m_dim < nets.size())
- log().fatal("Dimension {1} less than {2}", m_dim, nets.size());
-
matrix_solver_t::setup_base(nets);
netlist().save(*this, m_last_RHS, "m_last_RHS");
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index 5ea6bc2e993..d1f3bcc4eb8 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -187,7 +187,7 @@ std::unique_ptr<matrix_solver_t> NETLIB_NAME(solver)::create_solver(unsigned siz
}
else
{
- netlist().log().fatal("Unknown solver type: {1}\n", m_method());
+ log().fatal(MF_1_UNKNOWN_SOLVER_TYPE, m_method());
return nullptr;
}
}
@@ -281,7 +281,7 @@ void NETLIB_NAME(solver)::post_start()
else
m_params.m_log_stats = m_log_stats();
- netlist().log().verbose("Scanning net groups ...");
+ log().verbose("Scanning net groups ...");
// determine net groups
net_splitter splitter;
@@ -289,7 +289,7 @@ void NETLIB_NAME(solver)::post_start()
splitter.run(netlist());
// setup the solvers
- netlist().log().verbose("Found {1} net groups in {2} nets\n", splitter.groups.size(), netlist().m_nets.size());
+ log().verbose("Found {1} net groups in {2} nets\n", splitter.groups.size(), netlist().m_nets.size());
for (auto & grp : splitter.groups)
{
std::unique_ptr<matrix_solver_t> ms;
@@ -347,7 +347,7 @@ void NETLIB_NAME(solver)::post_start()
#endif
#endif
default:
- netlist().log().warning("No specific solver found for netlist of size {1}", net_count);
+ log().warning(MW_1_NO_SPECIFIC_SOLVER, net_count);
if (net_count <= 16)
{
ms = create_solver<0,16>(net_count, use_specific);
@@ -368,7 +368,7 @@ void NETLIB_NAME(solver)::post_start()
}
else
{
- netlist().log().fatal("Encountered netgroup with > 128 nets");
+ log().fatal(MF_1_NETGROUP_SIZE_EXCEEDED_1, 128);
ms = nullptr; /* tease compilers */
}
@@ -379,16 +379,16 @@ void NETLIB_NAME(solver)::post_start()
ms->set_delegate_pointer();
ms->setup(grp);
- netlist().log().verbose("Solver {1}", ms->name());
- netlist().log().verbose(" ==> {2} nets", grp.size());
- netlist().log().verbose(" has {1} elements", ms->has_dynamic_devices() ? "dynamic" : "no dynamic");
- netlist().log().verbose(" has {1} elements", ms->has_timestep_devices() ? "timestep" : "no timestep");
+ log().verbose("Solver {1}", ms->name());
+ log().verbose(" ==> {2} nets", grp.size());
+ log().verbose(" has {1} elements", ms->has_dynamic_devices() ? "dynamic" : "no dynamic");
+ log().verbose(" has {1} elements", ms->has_timestep_devices() ? "timestep" : "no timestep");
for (auto &n : grp)
{
- netlist().log().verbose("Net {1}", n->name());
+ log().verbose("Net {1}", n->name());
for (const auto &pcore : n->m_core_terms)
{
- netlist().log().verbose(" {1}", pcore->name());
+ log().verbose(" {1}", pcore->name());
}
}