systemc: Switch to using predefined messages for channels.

Create and use predefined messages for channels which match the ones
Accellera uses.

Change-Id: I179214838bbd83604e50225926cdc6b5b1b16923
Reviewed-on: https://gem5-review.googlesource.com/c/13330
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
diff --git a/src/systemc/channel/SConscript b/src/systemc/channel/SConscript
index fe79737..30ae76a 100644
--- a/src/systemc/channel/SConscript
+++ b/src/systemc/channel/SConscript
@@ -28,6 +28,7 @@
 Import('*')
 
 if env['USE_SYSTEMC']:
+    Source('messages.cc')
     Source('sc_clock.cc')
     Source('sc_event_queue.cc')
     Source('sc_in_resolved.cc')
diff --git a/src/systemc/channel/messages.cc b/src/systemc/channel/messages.cc
new file mode 100644
index 0000000..7bbda59
--- /dev/null
+++ b/src/systemc/channel/messages.cc
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2018 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#include "systemc/ext/channel/messages.hh"
+#include "systemc/utils/report.hh"
+
+namespace sc_core
+{
+
+const char SC_ID_PORT_OUTSIDE_MODULE_[] = "port specified outside of module";
+const char SC_ID_CLOCK_PERIOD_ZERO_[] = "sc_clock period is zero";
+const char SC_ID_CLOCK_HIGH_TIME_ZERO_[] = "sc_clock high time is zero";
+const char SC_ID_CLOCK_LOW_TIME_ZERO_[] = "sc_clock low time is zero";
+const char SC_ID_MORE_THAN_ONE_FIFO_READER_[] =
+    "sc_fifo<T> cannot have more than one reader";
+const char SC_ID_MORE_THAN_ONE_FIFO_WRITER_[] =
+    "sc_fifo<T> cannot have more than one writer";
+const char SC_ID_INVALID_FIFO_SIZE_[] =
+    "sc_fifo<T> must have a size of at least 1";
+const char SC_ID_BIND_IF_TO_PORT_[] = "bind interface to port failed";
+const char SC_ID_BIND_PORT_TO_PORT_[] = "bind parent port to port failed";
+const char SC_ID_COMPLETE_BINDING_[] = "complete binding failed";
+const char SC_ID_INSERT_PORT_[] = "insert port failed";
+const char SC_ID_REMOVE_PORT_[] = "remove port failed";
+const char SC_ID_GET_IF_[] = "get interface failed";
+const char SC_ID_INSERT_PRIM_CHANNEL_[] = "insert primitive channel failed";
+const char SC_ID_REMOVE_PRIM_CHANNEL_[] = "remove primitive channel failed";
+const char SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_[] =
+    "sc_signal<T> cannot have more than one driver";
+const char SC_ID_NO_DEFAULT_EVENT_[] = "channel doesn't have a default event";
+const char SC_ID_RESOLVED_PORT_NOT_BOUND_[] =
+    "resolved port not bound to resolved signal";
+const char SC_ID_FIND_EVENT_[] = "find event failed";
+const char SC_ID_INVALID_SEMAPHORE_VALUE_[] =
+    "sc_semaphore requires an initial value >= 0";
+const char SC_ID_SC_EXPORT_HAS_NO_INTERFACE_[] =
+    "sc_export instance has no interface";
+const char SC_ID_INSERT_EXPORT_[] = "insert sc_export failed";
+const char SC_ID_EXPORT_OUTSIDE_MODULE_[] =
+    "sc_export specified outside of module";
+const char SC_ID_SC_EXPORT_NOT_REGISTERED_[] =
+    "remove sc_export failed, sc_export not registered";
+const char SC_ID_SC_EXPORT_NOT_BOUND_AFTER_CONSTRUCTION_[] =
+    "sc_export instance not bound to interface at end of construction";
+const char SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_[] =
+    "attempt to write the value of an sc_clock instance";
+const char SC_ID_SC_EXPORT_ALREADY_BOUND_[] =
+    "sc_export instance already bound";
+const char SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_[] =
+    "attempted specalized signal operation on non-specialized signal";
+const char SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_[] =
+    "attempted to bind sc_clock instance to sc_inout or sc_out";
+const char SC_ID_NO_ASYNC_UPDATE_[] =
+    "this build has no asynchronous update support";
+
+namespace
+{
+
+sc_gem5::DefaultReportMessages predefinedMessages{
+    {100, SC_ID_PORT_OUTSIDE_MODULE_},
+    {101, SC_ID_CLOCK_PERIOD_ZERO_},
+    {102, SC_ID_CLOCK_HIGH_TIME_ZERO_},
+    {103, SC_ID_CLOCK_LOW_TIME_ZERO_},
+    {104, SC_ID_MORE_THAN_ONE_FIFO_READER_},
+    {105, SC_ID_MORE_THAN_ONE_FIFO_WRITER_},
+    {106, SC_ID_INVALID_FIFO_SIZE_},
+    {107, SC_ID_BIND_IF_TO_PORT_},
+    {108, SC_ID_BIND_PORT_TO_PORT_},
+    {109, SC_ID_COMPLETE_BINDING_},
+    {110, SC_ID_INSERT_PORT_},
+    {111, SC_ID_REMOVE_PORT_},
+    {112, SC_ID_GET_IF_},
+    {113, SC_ID_INSERT_PRIM_CHANNEL_},
+    {114, SC_ID_REMOVE_PRIM_CHANNEL_},
+    {115, SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_},
+    {116, SC_ID_NO_DEFAULT_EVENT_},
+    {117, SC_ID_RESOLVED_PORT_NOT_BOUND_},
+    {118, SC_ID_FIND_EVENT_},
+    {119, SC_ID_INVALID_SEMAPHORE_VALUE_},
+    {120, SC_ID_SC_EXPORT_HAS_NO_INTERFACE_},
+    {121, SC_ID_INSERT_EXPORT_},
+    {122, SC_ID_EXPORT_OUTSIDE_MODULE_},
+    {123, SC_ID_SC_EXPORT_NOT_REGISTERED_},
+    {124, SC_ID_SC_EXPORT_NOT_BOUND_AFTER_CONSTRUCTION_},
+    {125, SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_},
+    {126, SC_ID_SC_EXPORT_ALREADY_BOUND_},
+    {127, SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_},
+    {128, SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_},
+    {129, SC_ID_NO_ASYNC_UPDATE_}
+};
+
+} // anonymous namespace
+
+} // namespace sc_core
diff --git a/src/systemc/channel/sc_clock.cc b/src/systemc/channel/sc_clock.cc
index 898e7b8..7ab86ee 100644
--- a/src/systemc/channel/sc_clock.cc
+++ b/src/systemc/channel/sc_clock.cc
@@ -35,6 +35,7 @@
 #include "systemc/core/process_types.hh"
 #include "systemc/core/sched_event.hh"
 #include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/channel/sc_clock.hh"
 #include "systemc/ext/core/sc_main.hh"
 #include "systemc/ext/core/sc_module.hh" // for sc_gen_unique_name
@@ -113,21 +114,21 @@
         std::string msg =
             "increase the period: clock '" +
             std::string(name) + "'";
-        SC_REPORT_ERROR("(E101) sc_clock period is zero", msg.c_str());
+        SC_REPORT_ERROR(SC_ID_CLOCK_PERIOD_ZERO_, msg.c_str());
     }
 
     if (duty_cycle * period == SC_ZERO_TIME) {
         std::string msg =
             "increase the period or increase the duty cycle: clock '" +
             std::string(name) + "'";
-        SC_REPORT_ERROR("(E102) sc_clock high time is zero", msg.c_str());
+        SC_REPORT_ERROR(SC_ID_CLOCK_HIGH_TIME_ZERO_, msg.c_str());
     }
 
     if (duty_cycle * period == period) {
         std::string msg =
             "increase the period or decrease the duty cycle: clock '" +
             std::string(name) + "'";
-        SC_REPORT_ERROR("(E103) sc_clock low time is zero", msg.c_str());
+        SC_REPORT_ERROR(SC_ID_CLOCK_LOW_TIME_ZERO_, msg.c_str());
     }
 
     _gem5UpEdge = new ::sc_gem5::ClockTick(this, true, period);
diff --git a/src/systemc/channel/sc_inout_resolved.cc b/src/systemc/channel/sc_inout_resolved.cc
index 2f3dd18..3310e23 100644
--- a/src/systemc/channel/sc_inout_resolved.cc
+++ b/src/systemc/channel/sc_inout_resolved.cc
@@ -28,6 +28,7 @@
  */
 
 #include "base/logging.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/channel/sc_inout_resolved.hh"
 #include "systemc/ext/channel/sc_signal_resolved.hh"
 #include "systemc/ext/utils/sc_report_handler.hh"
@@ -49,8 +50,7 @@
     sc_inout<sc_dt::sc_logic>::end_of_elaboration();
     if (!dynamic_cast<sc_signal_resolved *>(get_interface())) {
         std::string msg = csprintf("port '%s' (%s)", name(), kind());
-        SC_REPORT_ERROR("(E117) resolved port not bound to resolved signal",
-                msg.c_str());
+        SC_REPORT_ERROR(SC_ID_RESOLVED_PORT_NOT_BOUND_, msg.c_str());
     }
 }
 
diff --git a/src/systemc/channel/sc_semaphore.cc b/src/systemc/channel/sc_semaphore.cc
index 59191be..9bace39 100644
--- a/src/systemc/channel/sc_semaphore.cc
+++ b/src/systemc/channel/sc_semaphore.cc
@@ -30,6 +30,7 @@
 #include <string>
 
 #include "base/logging.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/channel/sc_semaphore.hh"
 #include "systemc/ext/core/sc_module.hh" // for sc_gen_unique_name
 #include "systemc/ext/utils/sc_report_handler.hh"
@@ -46,8 +47,7 @@
 {
     if (value < 0) {
         std::string msg = "semaphore '" + std::string(name()) + "'";
-        SC_REPORT_ERROR("(E119) sc_semaphore requires an initial value >= 0",
-                msg.c_str());
+        SC_REPORT_ERROR(SC_ID_INVALID_SEMAPHORE_VALUE_, msg.c_str());
     }
 }
 
diff --git a/src/systemc/channel/sc_signal.cc b/src/systemc/channel/sc_signal.cc
index 14ee8a6..e3a3cf5 100644
--- a/src/systemc/channel/sc_signal.cc
+++ b/src/systemc/channel/sc_signal.cc
@@ -30,6 +30,7 @@
 #include <sstream>
 
 #include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/channel/sc_signal.hh"
 #include "systemc/ext/core/sc_main.hh"
 
@@ -85,8 +86,7 @@
         ss << "\n conflicting write in delta cycle " <<
             sc_core::sc_delta_count();
     }
-    SC_REPORT_ERROR(
-            "(E115) sc_signal<T> cannot have more than one driver",
+    SC_REPORT_ERROR(sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_,
             ss.str().c_str());
 }
 
diff --git a/src/systemc/core/port.cc b/src/systemc/core/port.cc
index e8a7832..109d9df 100644
--- a/src/systemc/core/port.cc
+++ b/src/systemc/core/port.cc
@@ -32,6 +32,7 @@
 #include "base/logging.hh"
 #include "systemc/core/process.hh"
 #include "systemc/core/sensitivity.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/channel/sc_signal_in_if.hh"
 
 namespace sc_gem5
@@ -129,23 +130,23 @@
         std::ostringstream ss;
         ss << size() << " binds exceeds maximum of " << maxSize() <<
             " allowed";
-        portBase->report_error(
-                "(E109) complete binding failed", ss.str().c_str());
+        portBase->report_error(sc_core::SC_ID_COMPLETE_BINDING_,
+                ss.str().c_str());
     }
 
     switch (portBase->_portPolicy()) {
       case sc_core::SC_ONE_OR_MORE_BOUND:
         if (size() == 0)
-            portBase->report_error(
-                    "(E109) complete binding failed", "port not bound");
+            portBase->report_error(sc_core::SC_ID_COMPLETE_BINDING_,
+                    "port not bound");
         break;
       case sc_core::SC_ALL_BOUND:
         if (size() < maxSize() || size() < 1) {
             std::stringstream ss;
             ss << size() << " actual binds is less than required " <<
                 maxSize();
-            portBase->report_error(
-                    "(E109) complete binding failed", ss.str().c_str());
+            portBase->report_error(sc_core::SC_ID_COMPLETE_BINDING_,
+                    ss.str().c_str());
         }
         break;
       case sc_core::SC_ZERO_OR_MORE_BOUND:
diff --git a/src/systemc/core/sc_export.cc b/src/systemc/core/sc_export.cc
index 9123a25..a2cee31 100644
--- a/src/systemc/core/sc_export.cc
+++ b/src/systemc/core/sc_export.cc
@@ -30,6 +30,7 @@
 #include "base/logging.hh"
 #include "systemc/core/module.hh"
 #include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/core/sc_export.hh"
 #include "systemc/ext/core/sc_main.hh"
 
@@ -57,21 +58,17 @@
 sc_export_base::sc_export_base(const char *n) : sc_object(n)
 {
     if (sc_is_running()) {
-        reportError("(E121) insert sc_export failed", "simulation running",
+        reportError(SC_ID_INSERT_EXPORT_, "simulation running",
                 name(), kind());
     }
-    if (::sc_gem5::scheduler.elaborationDone()) {
-        reportError("(E121) insert sc_export failed", "elaboration done",
-                name(), kind());
-    }
+    if (::sc_gem5::scheduler.elaborationDone())
+        reportError(SC_ID_INSERT_EXPORT_, "elaboration done", name(), kind());
 
     auto m = sc_gem5::pickParentModule();
-    if (!m) {
-        reportError("(E122) sc_export specified outside of module",
-                nullptr, name(), kind());
-    } else {
+    if (!m)
+        reportError(SC_ID_EXPORT_OUTSIDE_MODULE_, nullptr, name(), kind());
+    else
         m->exports.push_back(this);
-    }
 }
 sc_export_base::~sc_export_base() {}
 
diff --git a/src/systemc/core/sc_interface.cc b/src/systemc/core/sc_interface.cc
index 93aff67..88b4487 100644
--- a/src/systemc/core/sc_interface.cc
+++ b/src/systemc/core/sc_interface.cc
@@ -28,6 +28,7 @@
  */
 
 #include "base/logging.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/core/sc_event.hh"
 #include "systemc/ext/core/sc_interface.hh"
 #include "systemc/ext/utils/sc_report_handler.hh"
@@ -40,7 +41,7 @@
 const sc_event &
 sc_interface::default_event() const
 {
-    SC_REPORT_WARNING("(W116) channel doesn't have a default event", "");
+    SC_REPORT_WARNING(SC_ID_NO_DEFAULT_EVENT_, "");
     static sc_gem5::InternalScEvent dummy;
     return dummy;
 }
diff --git a/src/systemc/core/sc_port.cc b/src/systemc/core/sc_port.cc
index 60911f8..69fe6f5 100644
--- a/src/systemc/core/sc_port.cc
+++ b/src/systemc/core/sc_port.cc
@@ -33,6 +33,7 @@
 #include "systemc/core/module.hh"
 #include "systemc/core/port.hh"
 #include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/core/sc_main.hh"
 #include "systemc/ext/core/sc_port.hh"
 
@@ -61,21 +62,19 @@
     sc_object(n), _gem5Port(nullptr)
 {
     if (sc_is_running()) {
-        reportError("(E110) insert port failed", "simulation running",
+        reportError(SC_ID_INSERT_PORT_, "simulation running",
                 name(), kind());
     }
     if (::sc_gem5::scheduler.elaborationDone()) {
-        reportError("(E110) insert port failed", "elaboration done",
+        reportError(SC_ID_INSERT_PORT_, "elaboration done",
                 name(), kind());
     }
 
     auto m = sc_gem5::pickParentModule();
-    if (!m) {
-        reportError("(E100) port specified outside of module",
-                nullptr, name(), kind());
-    } else {
+    if (!m)
+        reportError(SC_ID_PORT_OUTSIDE_MODULE_, nullptr, name(), kind());
+    else
         m->ports.push_back(this);
-    }
     _gem5Port = new ::sc_gem5::Port(this, max_size);
 }
 
diff --git a/src/systemc/core/sc_prim.cc b/src/systemc/core/sc_prim.cc
index 099e5d8..5dacc7f 100644
--- a/src/systemc/core/sc_prim.cc
+++ b/src/systemc/core/sc_prim.cc
@@ -30,6 +30,7 @@
 #include "base/logging.hh"
 #include "systemc/core/channel.hh"
 #include "systemc/core/scheduler.hh"
+#include "systemc/ext/channel/messages.hh"
 #include "systemc/ext/core/sc_main.hh"
 #include "systemc/ext/core/sc_prim.hh"
 
@@ -46,12 +47,10 @@
 sc_prim_channel::sc_prim_channel() : _gem5_channel(nullptr)
 {
     if (sc_is_running()) {
-        SC_REPORT_ERROR("(E113) insert primitive channel failed",
-                "simulation running");
+        SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "simulation running");
     }
     if (::sc_gem5::scheduler.elaborationDone()) {
-        SC_REPORT_ERROR("(E113) insert primitive channel failed",
-                "elaboration done");
+        SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "elaboration done");
     }
     _gem5_channel = new sc_gem5::Channel(this);
 }
@@ -60,12 +59,10 @@
     sc_object(_name), _gem5_channel(nullptr)
 {
     if (sc_is_running()) {
-        SC_REPORT_ERROR("(E113) insert primitive channel failed",
-                "simulation running");
+        SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "simulation running");
     }
     if (::sc_gem5::scheduler.elaborationDone()) {
-        SC_REPORT_ERROR("(E113) insert primitive channel failed",
-                "elaboration done");
+        SC_REPORT_ERROR(SC_ID_INSERT_PRIM_CHANNEL_, "elaboration done");
     }
     _gem5_channel = new sc_gem5::Channel(this);
 }
diff --git a/src/systemc/ext/channel/_channel.hh b/src/systemc/ext/channel/_channel.hh
index d95cfc2..390ea15 100644
--- a/src/systemc/ext/channel/_channel.hh
+++ b/src/systemc/ext/channel/_channel.hh
@@ -30,6 +30,7 @@
 #ifndef __SYSTEMC_EXT_CHANNEL__CHANNEL_HH__
 #define __SYSTEMC_EXT_CHANNEL__CHANNEL_HH__
 
+#include "messages.hh"
 #include "sc_buffer.hh"
 #include "sc_clock.hh"
 #include "sc_event_queue.hh"
diff --git a/src/systemc/ext/channel/_using.hh b/src/systemc/ext/channel/_using.hh
index e582ea2..e59cde3 100644
--- a/src/systemc/ext/channel/_using.hh
+++ b/src/systemc/ext/channel/_using.hh
@@ -97,4 +97,35 @@
 
 using sc_core::sc_signal_rv;
 
+using sc_core::SC_ID_PORT_OUTSIDE_MODULE_;
+using sc_core::SC_ID_CLOCK_PERIOD_ZERO_;
+using sc_core::SC_ID_CLOCK_HIGH_TIME_ZERO_;
+using sc_core::SC_ID_CLOCK_LOW_TIME_ZERO_;
+using sc_core::SC_ID_MORE_THAN_ONE_FIFO_READER_;
+using sc_core::SC_ID_MORE_THAN_ONE_FIFO_WRITER_;
+using sc_core::SC_ID_INVALID_FIFO_SIZE_;
+using sc_core::SC_ID_BIND_IF_TO_PORT_;
+using sc_core::SC_ID_BIND_PORT_TO_PORT_;
+using sc_core::SC_ID_COMPLETE_BINDING_;
+using sc_core::SC_ID_INSERT_PORT_;
+using sc_core::SC_ID_REMOVE_PORT_;
+using sc_core::SC_ID_GET_IF_;
+using sc_core::SC_ID_INSERT_PRIM_CHANNEL_;
+using sc_core::SC_ID_REMOVE_PRIM_CHANNEL_;
+using sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_;
+using sc_core::SC_ID_NO_DEFAULT_EVENT_;
+using sc_core::SC_ID_RESOLVED_PORT_NOT_BOUND_;
+using sc_core::SC_ID_FIND_EVENT_;
+using sc_core::SC_ID_INVALID_SEMAPHORE_VALUE_;
+using sc_core::SC_ID_SC_EXPORT_HAS_NO_INTERFACE_;
+using sc_core::SC_ID_INSERT_EXPORT_;
+using sc_core::SC_ID_EXPORT_OUTSIDE_MODULE_;
+using sc_core::SC_ID_SC_EXPORT_NOT_REGISTERED_;
+using sc_core::SC_ID_SC_EXPORT_NOT_BOUND_AFTER_CONSTRUCTION_;
+using sc_core::SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_;
+using sc_core::SC_ID_SC_EXPORT_ALREADY_BOUND_;
+using sc_core::SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_;
+using sc_core::SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_;
+using sc_core::SC_ID_NO_ASYNC_UPDATE_;
+
 #endif  //__SYSTEMC_EXT_CHANNEL__USING_HH__
diff --git a/src/systemc/ext/channel/messages.hh b/src/systemc/ext/channel/messages.hh
new file mode 100644
index 0000000..fe36f46
--- /dev/null
+++ b/src/systemc/ext/channel/messages.hh
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2018 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#ifndef __SYSTEMC_EXT_CHANNEL_MESSAGES_HH__
+#define __SYSTEMC_EXT_CHANNEL_MESSAGES_HH__
+
+namespace sc_core
+{
+
+extern const char SC_ID_PORT_OUTSIDE_MODULE_[];
+extern const char SC_ID_CLOCK_PERIOD_ZERO_[];
+extern const char SC_ID_CLOCK_HIGH_TIME_ZERO_[];
+extern const char SC_ID_CLOCK_LOW_TIME_ZERO_[];
+extern const char SC_ID_MORE_THAN_ONE_FIFO_READER_[];
+extern const char SC_ID_MORE_THAN_ONE_FIFO_WRITER_[];
+extern const char SC_ID_INVALID_FIFO_SIZE_[];
+extern const char SC_ID_BIND_IF_TO_PORT_[];
+extern const char SC_ID_BIND_PORT_TO_PORT_[];
+extern const char SC_ID_COMPLETE_BINDING_[];
+extern const char SC_ID_INSERT_PORT_[];
+extern const char SC_ID_REMOVE_PORT_[];
+extern const char SC_ID_GET_IF_[];
+extern const char SC_ID_INSERT_PRIM_CHANNEL_[];
+extern const char SC_ID_REMOVE_PRIM_CHANNEL_[];
+extern const char SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_[];
+extern const char SC_ID_NO_DEFAULT_EVENT_[];
+extern const char SC_ID_RESOLVED_PORT_NOT_BOUND_[];
+extern const char SC_ID_FIND_EVENT_[];
+extern const char SC_ID_INVALID_SEMAPHORE_VALUE_[];
+extern const char SC_ID_SC_EXPORT_HAS_NO_INTERFACE_[];
+extern const char SC_ID_INSERT_EXPORT_[];
+extern const char SC_ID_EXPORT_OUTSIDE_MODULE_[];
+extern const char SC_ID_SC_EXPORT_NOT_REGISTERED_[];
+extern const char SC_ID_SC_EXPORT_NOT_BOUND_AFTER_CONSTRUCTION_[];
+extern const char SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_[];
+extern const char SC_ID_SC_EXPORT_ALREADY_BOUND_[];
+extern const char SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_[];
+extern const char SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_[];
+extern const char SC_ID_NO_ASYNC_UPDATE_[];
+
+} // namespace sc_core
+
+#endif  // __SYSTEMC_EXT_CHANNEL_MESSAGES_HH__
diff --git a/src/systemc/ext/channel/sc_fifo.hh b/src/systemc/ext/channel/sc_fifo.hh
index a1c454a..0c83f66 100644
--- a/src/systemc/ext/channel/sc_fifo.hh
+++ b/src/systemc/ext/channel/sc_fifo.hh
@@ -36,6 +36,7 @@
 #include "../core/sc_module.hh" // for sc_gen_unique_name
 #include "../core/sc_prim.hh"
 #include "../utils/sc_report_handler.hh"
+#include "messages.hh"
 #include "sc_fifo_in_if.hh"
 #include "sc_fifo_out_if.hh"
 
@@ -69,22 +70,16 @@
         std::string tn(iface_type_name);
         if (tn == typeid(sc_fifo_in_if<T>).name() ||
                 tn == typeid(sc_fifo_blocking_in_if<T>).name()) {
-            if (_reader) {
-                SC_REPORT_ERROR(
-                        "(E104) sc_fifo<T> cannot have more than one reader",
-                        "");
-            }
+            if (_reader)
+                SC_REPORT_ERROR(SC_ID_MORE_THAN_ONE_FIFO_READER_, "");
             _reader = &port;
         } else if (tn == typeid(sc_fifo_out_if<T>).name() ||
                 tn == typeid(sc_fifo_blocking_out_if<T>).name()) {
-            if (_writer) {
-                SC_REPORT_ERROR(
-                        "(E105) sc_fifo<T> cannot have more than one writer",
-                        "");
-            }
+            if (_writer)
+                SC_REPORT_ERROR(SC_ID_MORE_THAN_ONE_FIFO_WRITER_, "");
             _writer = &port;
         } else {
-            SC_REPORT_ERROR("(E107) bind interface to port failed",
+            SC_REPORT_ERROR(SC_ID_BIND_IF_TO_PORT_,
                     "sc_fifo<T> port not recognized");
         }
     }
diff --git a/src/systemc/ext/channel/sc_in_rv.hh b/src/systemc/ext/channel/sc_in_rv.hh
index 278b958..b963bfd 100644
--- a/src/systemc/ext/channel/sc_in_rv.hh
+++ b/src/systemc/ext/channel/sc_in_rv.hh
@@ -32,6 +32,7 @@
 
 #include <sstream>
 
+#include "messages.hh"
 #include "sc_in.hh"
 #include "sc_signal_rv.hh"
 
@@ -61,9 +62,7 @@
         if (!dynamic_cast<sc_signal_rv<W> *>(this->get_interface())) {
             std::ostringstream ss;
             ss << "port '" << this->name() << "' (" << this->kind() << ")";
-            SC_REPORT_ERROR(
-                    "(E117) resolved port not bound to resolved signal",
-                    ss.str().c_str());
+            SC_REPORT_ERROR(SC_ID_RESOLVED_PORT_NOT_BOUND_, ss.str().c_str());
         }
     }
 
diff --git a/src/systemc/ext/channel/sc_inout_rv.hh b/src/systemc/ext/channel/sc_inout_rv.hh
index 54f54ff..d91a48b 100644
--- a/src/systemc/ext/channel/sc_inout_rv.hh
+++ b/src/systemc/ext/channel/sc_inout_rv.hh
@@ -33,6 +33,7 @@
 #include <sstream>
 
 #include "../core/sc_port.hh"
+#include "messages.hh"
 #include "sc_signal_in_if.hh"
 #include "sc_signal_inout_if.hh"
 #include "sc_signal_rv.hh"
@@ -94,9 +95,7 @@
         if (!dynamic_cast<sc_signal_rv<W> *>(this->get_interface())) {
             std::ostringstream ss;
             ss << "port '" << this->name() << "' (" << this->kind() << ")";
-            SC_REPORT_ERROR(
-                    "(E117) resolved port not bound to resolved signal",
-                    ss.str().c_str());
+            SC_REPORT_ERROR(SC_ID_RESOLVED_PORT_NOT_BOUND_, ss.str().c_str());
         }
     }
 
diff --git a/src/systemc/ext/core/sc_event.hh b/src/systemc/ext/core/sc_event.hh
index 90fd41f..56ee24f 100644
--- a/src/systemc/ext/core/sc_event.hh
+++ b/src/systemc/ext/core/sc_event.hh
@@ -35,6 +35,7 @@
 #include <sstream>
 #include <vector>
 
+#include "../channel/messages.hh"
 #include "../utils/sc_report_handler.hh"
 #include "sc_port.hh"
 #include "sc_time.hh"
@@ -247,7 +248,7 @@
             std::ostringstream ss;
             ss << "port is not bound: port '" << _port->name() << "' (" <<
                 _port->kind() << ")";
-            SC_REPORT_ERROR("(E118) find event failed", ss.str().c_str());
+            SC_REPORT_ERROR(SC_ID_FIND_EVENT_, ss.str().c_str());
             return none;
         }
         return (const_cast<IF *>(iface)->*_method)();
diff --git a/src/systemc/ext/core/sc_export.hh b/src/systemc/ext/core/sc_export.hh
index e36e34a..100ce66 100644
--- a/src/systemc/ext/core/sc_export.hh
+++ b/src/systemc/ext/core/sc_export.hh
@@ -30,6 +30,7 @@
 #ifndef __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
 #define __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
 
+#include "../channel/messages.hh"
 #include "../utils/sc_report_handler.hh"
 #include "sc_module.hh" // for sc_gen_unique_name
 #include "sc_object.hh"
@@ -76,17 +77,15 @@
     bind(IF &i)
     {
         if (interface) {
-            SC_REPORT_ERROR("(E126) sc_export instance already bound", name());
+            SC_REPORT_ERROR(SC_ID_SC_EXPORT_ALREADY_BOUND_, name());
             return;
         }
         interface = &i;
     }
     operator IF & ()
     {
-        if (!interface) {
-            SC_REPORT_ERROR("(E120) sc_export instance has no interface",
-                    name());
-        }
+        if (!interface)
+            SC_REPORT_ERROR(SC_ID_SC_EXPORT_HAS_NO_INTERFACE_, name());
         return *interface;
     }
     operator const IF & () const { return *interface; }
@@ -94,19 +93,15 @@
     IF *
     operator -> ()
     {
-        if (!interface) {
-            SC_REPORT_ERROR("(E120) sc_export instance has no interface",
-                    name());
-        }
+        if (!interface)
+            SC_REPORT_ERROR(SC_ID_SC_EXPORT_HAS_NO_INTERFACE_, name());
         return interface;
     }
     const IF *
     operator -> () const
     {
-        if (!interface) {
-            SC_REPORT_ERROR("(E120) sc_export instance has no interface",
-                    name());
-        }
+        if (!interface)
+            SC_REPORT_ERROR(SC_ID_SC_EXPORT_HAS_NO_INTERFACE_, name());
         return interface;
     }
 
diff --git a/src/systemc/ext/core/sc_port.hh b/src/systemc/ext/core/sc_port.hh
index aa9a322..c4160ba 100644
--- a/src/systemc/ext/core/sc_port.hh
+++ b/src/systemc/ext/core/sc_port.hh
@@ -33,6 +33,7 @@
 #include <typeinfo>
 #include <vector>
 
+#include "../channel/messages.hh"
 #include "../utils/sc_report_handler.hh"
 #include "sc_module.hh" // for sc_gen_unique_name
 #include "sc_object.hh"
@@ -129,7 +130,7 @@
     operator -> ()
     {
         if (_interfaces.empty()) {
-            report_error("(E112) get interface failed", "port is not bound");
+            report_error(SC_ID_GET_IF_, "port is not bound");
             sc_abort();
         }
         return _interfaces[0];
@@ -138,7 +139,7 @@
     operator -> () const
     {
         if (_interfaces.empty()) {
-            report_error("(E112) get interface failed", "port is not bound");
+            report_error(SC_ID_GET_IF_, "port is not bound");
             sc_abort();
         }
         return _interfaces[0];
@@ -148,7 +149,7 @@
     operator [] (int n)
     {
         if (n < 0 || n >= size()) {
-            report_error("(E112) get interface failed", "index out of range");
+            report_error(SC_ID_GET_IF_, "index out of range");
             return NULL;
         }
         return _interfaces[n];
@@ -157,7 +158,7 @@
     operator [] (int n) const
     {
         if (n < 0 || n >= size()) {
-            report_error("(E112) get interface failed", "index out of range");
+            report_error(SC_ID_GET_IF_, "index out of range");
             return NULL;
         }
         return _interfaces[n];
@@ -219,7 +220,7 @@
     _gem5Interface(int n) const
     {
         if (n < 0 || n >= size()) {
-            report_error("(E112) get interface failed", "index out of range");
+            report_error(SC_ID_GET_IF_, "index out of range");
             return NULL;
         }
         return _interfaces[n];
@@ -231,7 +232,7 @@
         sc_assert(interface);
         for (int i = 0; i < _interfaces.size(); i++) {
             if (interface == _interfaces[i]) {
-                report_error("(E107) bind interface to port failed",
+                report_error(SC_ID_BIND_IF_TO_PORT_,
                         "interface already bound to port");
             }
         }
diff --git a/src/systemc/tests/include/specialized_signals/scx_signal_int.h b/src/systemc/tests/include/specialized_signals/scx_signal_int.h
index 050521d..b853acd 100644
--- a/src/systemc/tests/include/specialized_signals/scx_signal_int.h
+++ b/src/systemc/tests/include/specialized_signals/scx_signal_int.h
@@ -1556,26 +1556,22 @@
 
 sc_dt::sc_int_base* sc_int_part_if::part_read_target()
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_dt::uint64 sc_int_part_if::read_part( int /*left*/, int /*right*/ ) const
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_int_sigref& sc_int_part_if::select_part( int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return *(sc_int_sigref*)0;
 }
 void sc_int_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 
 
diff --git a/src/systemc/tests/include/specialized_signals/scx_signal_signed.h b/src/systemc/tests/include/specialized_signals/scx_signal_signed.h
index bb48cec..baa6dd9 100644
--- a/src/systemc/tests/include/specialized_signals/scx_signal_signed.h
+++ b/src/systemc/tests/include/specialized_signals/scx_signal_signed.h
@@ -1744,43 +1744,36 @@
 
 sc_signed* sc_signed_part_if::part_read_target()
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_signed sc_signed_part_if::read_part( int /*left*/, int /*right*/ ) const
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return sc_signed(1);
 }
 sc_signed_sigref& sc_signed_part_if::select_part( int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return *(sc_signed_sigref*)0;
 }
 void sc_signed_part_if::write_part( int64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_signed_part_if::write_part( uint64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_signed_part_if::write_part(
     const sc_signed& v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_signed_part_if::write_part(
     const sc_unsigned& v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 
 
diff --git a/src/systemc/tests/include/specialized_signals/scx_signal_uint.h b/src/systemc/tests/include/specialized_signals/scx_signal_uint.h
index acc4a42..a0ad01b 100644
--- a/src/systemc/tests/include/specialized_signals/scx_signal_uint.h
+++ b/src/systemc/tests/include/specialized_signals/scx_signal_uint.h
@@ -1604,26 +1604,22 @@
 
 sc_dt::sc_uint_base* sc_uint_part_if::part_read_target()
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_dt::uint64 sc_uint_part_if::read_part( int /*left*/, int /*right*/ ) const
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_uint_sigref& sc_uint_part_if::select_part( int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return *(sc_uint_sigref*)0;
 }
 void sc_uint_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 
 //------------------------------------------------------------------------------
diff --git a/src/systemc/tests/include/specialized_signals/scx_signal_unsigned.h b/src/systemc/tests/include/specialized_signals/scx_signal_unsigned.h
index a356d44..7cfc409 100644
--- a/src/systemc/tests/include/specialized_signals/scx_signal_unsigned.h
+++ b/src/systemc/tests/include/specialized_signals/scx_signal_unsigned.h
@@ -1743,43 +1743,36 @@
 //------------------------------------------------------------------------------
 sc_dt::sc_unsigned* sc_unsigned_part_if::part_read_target()
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return 0;
 }
 sc_dt::sc_unsigned sc_unsigned_part_if::read_part( int /*left*/, int /*right*/ ) const
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return sc_dt::sc_unsigned(1);
 }
 sc_unsigned_sigref& sc_unsigned_part_if::select_part(int /*left*/, int /*right*/)
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
     return *(sc_unsigned_sigref*)0;
 }
 void sc_unsigned_part_if::write_part( sc_dt::int64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_unsigned_part_if::write_part( sc_dt::uint64 v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_unsigned_part_if::write_part(
     const sc_dt::sc_signed& v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 void sc_unsigned_part_if::write_part(
     const sc_dt::sc_unsigned& v, int /*left*/, int /*right*/ )
 {
-    SC_REPORT_ERROR( "attempted specalized signal operation on "
-            "non-specialized signal", "int" );
+    SC_REPORT_ERROR( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, "int" );
 }
 
 
diff --git a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/expected_returncode b/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/expected_returncode
deleted file mode 100644
index d00491f..0000000
--- a/src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/expected_returncode
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/src/systemc/utils/sc_report_handler.cc b/src/systemc/utils/sc_report_handler.cc
index 1b725cc..a2b915e 100644
--- a/src/systemc/utils/sc_report_handler.cc
+++ b/src/systemc/utils/sc_report_handler.cc
@@ -36,6 +36,7 @@
 #include "systemc/core/process.hh"
 #include "systemc/core/scheduler.hh"
 #include "systemc/ext/core/sc_main.hh"
+#include "systemc/ext/utils/messages.hh"
 #include "systemc/ext/utils/sc_report_handler.hh"
 #include "systemc/utils/report.hh"
 
@@ -62,6 +63,9 @@
                           const char *msg, int verbosity, const char *file,
                           int line)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     if (severity == SC_INFO && verbosity > sc_gem5::reportVerbosityLevel)
         return;
 
@@ -127,6 +131,9 @@
 sc_actions
 sc_report_handler::set_actions(const char *msg_type, sc_actions actions)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
     sc_actions previous = info.actions;
     info.actions = actions;
@@ -137,6 +144,9 @@
 sc_report_handler::set_actions(
         const char *msg_type, sc_severity severity, sc_actions actions)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
     sc_actions previous = info.sevActions[severity];
     info.sevActions[severity] = actions;
@@ -155,6 +165,9 @@
 int
 sc_report_handler::stop_after(const char *msg_type, int limit)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
     int previous = info.limit;
     info.limit = limit;
@@ -165,6 +178,9 @@
 sc_report_handler::stop_after(
         const char *msg_type, sc_severity severity, int limit)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
     int previous = info.sevLimits[severity];
     info.sevLimits[severity] = limit;
@@ -180,12 +196,18 @@
 int
 sc_report_handler::get_count(const char *msg_type)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     return sc_gem5::reportMsgInfoMap[msg_type].count;
 }
 
 int
 sc_report_handler::get_count(const char *msg_type, sc_severity severity)
 {
+    if (!msg_type)
+        msg_type = SC_ID_UNKNOWN_ERROR_;
+
     return sc_gem5::reportMsgInfoMap[msg_type].sevCounts[severity];
 }