summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/nl_errstr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/nl_errstr.h')
-rw-r--r--src/lib/netlist/nl_errstr.h67
1 files changed, 59 insertions, 8 deletions
diff --git a/src/lib/netlist/nl_errstr.h b/src/lib/netlist/nl_errstr.h
index b8f9340bad9..c65ff257846 100644
--- a/src/lib/netlist/nl_errstr.h
+++ b/src/lib/netlist/nl_errstr.h
@@ -8,13 +8,53 @@
#ifndef NL_ERRSTR_H_
#define NL_ERRSTR_H_
+#include "plib/pexception.h"
#include "plib/pfmtlog.h"
namespace netlist
{
- static constexpr const char sHINT_NO_DEACTIVATE[] = ".HINT_NO_DEACTIVATE"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
- static constexpr const char sHINT_NC[] = ".HINT_NC"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ static constexpr const char sHINT_NO_DEACTIVATE[]
+ = ".HINT_NO_DEACTIVATE"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ static constexpr const char sHINT_NC[]
+ = ".HINT_NC"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+
+ // -------------------------------------------------------------------------
+ // Exceptions
+ // -------------------------------------------------------------------------
+
+ /// \brief Generic netlist exception.
+ /// The exception is used in all events which are considered fatal.
+
+ class nl_exception : public plib::pexception
+ {
+ public:
+ /// \brief Constructor.
+ /// Allows a descriptive text to be passed to the exception
+
+ explicit nl_exception(const pstring &text //!< text to be passed
+ )
+ : plib::pexception(text)
+ {
+ }
+
+ /// \brief Constructor.
+ /// Allows to use \ref plib::pfmt logic to be used in exception
+
+ template <typename... Args>
+ explicit nl_exception(const pstring &fmt, //!< format to be used
+ Args &&...args //!< arguments to be passed
+ )
+ : plib::pexception(plib::pfmt(fmt)(std::forward<Args>(args)...))
+ {
+ }
+ };
+
+ // -------------------------------------------------------------------------
+ // Error messages
+ // -------------------------------------------------------------------------
+
+ // clang-format off
// nl_base.cpp
@@ -53,7 +93,7 @@ namespace netlist
PERRMSGV(MF_TT_LINE_WITHOUT_HEAD, 0, "TT_LINE found without TT_HEAD")
PERRMSGV(MF_LOCAL_SOURCE_NOT_FOUND_1, 1, "Local source not found: <{1}>")
PERRMSGV(MF_EXTERNAL_SOURCE_IS_LOCAL_1, 1, "External lib entry appears as a local one: <{1}>")
- PERRMSGV(MF_TRUTHTABLE_NOT_FOUND_1, 1, "Truthtable not found: <{1}>")
+ PERRMSGV(MF_TRUTHTABLE_NOT_FOUND_1, 1, "Truth table not found: <{1}>")
// nl_setup.cpp
@@ -99,7 +139,7 @@ namespace netlist
PERRMSGV(MW_CONNECTING_1_TO_ITSELF, 1, "Connecting net {1} to itself.")
PERRMSGV(MI_CONNECTING_1_TO_2_SAME_NET, 3, "Connecting terminals {1} and {2} which are already both on net {3}. "
"It is ok if you read this warning and it relates to pin which is connected internally to GND and the schematics "
- "show an external connection as well. Onde example is the CD4538. In other cases this warning may indicate "
+ "show an external connection as well. One example is the CD4538. In other cases this warning may indicate "
"an error in your netlist.")
PERRMSGV(ME_NC_PIN_1_WITH_CONNECTIONS, 1, "Found NC (not connected) terminal {1} with connections")
PERRMSGV(MI_ANALOG_OUTPUT_1_WITHOUT_CONNECTIONS,1, "Found analog output {1} without connections")
@@ -108,6 +148,7 @@ namespace netlist
PERRMSGV(MW_TERMINAL_1_WITHOUT_CONNECTIONS, 1, "Found terminal {1} without connections")
PERRMSGV(ME_TERMINAL_1_WITHOUT_NET, 1, "Found terminal {1} without a net")
+ PERRMSGV(ME_TERMINALS_1_2_WITHOUT_NET, 2, "Found terminals {1} and {2} without a net")
PERRMSGV(MF_TERMINALS_WITHOUT_NET, 0, "Found terminals without a net")
PERRMSGV(ME_TRISTATE_NO_PROXY_FOUND_2, 2,
"Tristate output {1} on device {2} is not connected to a proxy. You "
@@ -119,7 +160,7 @@ namespace netlist
"but has been forced to act as a logic output. Parameter "
" FORCE_TRISTATE_LOGIC for device {2} needs to be disabled!.")
- PERRMSGV(MI_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3, 3, "Found device {1} connected only to railterminals {2}/{3}."
+ PERRMSGV(MI_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3, 3, "Found device {1} connected only to rail terminals {2}/{3}."
" This may reflect the schematic - but as well be an error. Please review.")
PERRMSGV(MW_DATA_1_NOT_FOUND, 1, "unable to find data {1} in sources collection")
@@ -140,7 +181,7 @@ namespace netlist
// nld_matrix_solver.cpp
PERRMSGV(MF_UNHANDLED_ELEMENT_1_FOUND, 1, "setup_base:unhandled element <{1}> found")
- PERRMSGV(MF_FOUND_TERM_WITH_MISSING_OTHERNET, 1, "found term with missing othernet {1}")
+ PERRMSGV(MF_FOUND_TERM_WITH_MISSING_OTHERNET, 1, "found term with missing other net {1}")
PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_INVOCATION_3, 3, "NEWTON_LOOPS exceeded resolution invoked {1} times on net {2} at {3} us")
PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_ON_NET_2, 2, "NEWTON_LOOPS exceeded resolution failed on net {1} ... reschedule at {2} us")
@@ -186,9 +227,19 @@ namespace netlist
PERRMSGV(MF_FILE_OPEN_ERROR, 1, "Error opening file: {1}")
-
-
+ // clang-format on
} // namespace netlist
+// -------------------------------------------------------------------------
+// Asserts
+// -------------------------------------------------------------------------
+
+#define nl_assert(x) \
+ do \
+ { \
+ if (NL_DEBUG) \
+ passert_always(x); \
+ } while (0)
+#define nl_assert_always(x, msg) passert_always_msg(x, msg)
#endif // NL_ERRSTR_H_