From e07f7efb75f0f7322d752608eb1cb1e1145b4a98 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 7 Oct 2018 05:23:49 -0700 Subject: [PATCH] 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 Maintainer: Gabe Black --- src/systemc/channel/SConscript | 1 + src/systemc/channel/messages.cc | 120 ++++++++++++++++++ src/systemc/channel/sc_clock.cc | 7 +- src/systemc/channel/sc_inout_resolved.cc | 4 +- src/systemc/channel/sc_semaphore.cc | 4 +- src/systemc/channel/sc_signal.cc | 4 +- src/systemc/core/port.cc | 13 +- src/systemc/core/sc_export.cc | 17 +-- src/systemc/core/sc_interface.cc | 3 +- src/systemc/core/sc_port.cc | 13 +- src/systemc/core/sc_prim.cc | 13 +- src/systemc/ext/channel/_channel.hh | 1 + src/systemc/ext/channel/_using.hh | 31 +++++ src/systemc/ext/channel/messages.hh | 69 ++++++++++ src/systemc/ext/channel/sc_fifo.hh | 17 +-- src/systemc/ext/channel/sc_in_rv.hh | 5 +- src/systemc/ext/channel/sc_inout_rv.hh | 5 +- src/systemc/ext/core/sc_event.hh | 3 +- src/systemc/ext/core/sc_export.hh | 21 ++- src/systemc/ext/core/sc_port.hh | 13 +- .../specialized_signals/scx_signal_int.h | 12 +- .../specialized_signals/scx_signal_signed.h | 21 +-- .../specialized_signals/scx_signal_uint.h | 12 +- .../specialized_signals/scx_signal_unsigned.h | 21 +-- .../check_writer/test16/expected_returncode | 1 - src/systemc/utils/sc_report_handler.cc | 22 ++++ 26 files changed, 330 insertions(+), 123 deletions(-) create mode 100644 src/systemc/channel/messages.cc create mode 100644 src/systemc/ext/channel/messages.hh delete mode 100644 src/systemc/tests/systemc/communication/sc_signal/check_writer/test16/expected_returncode diff --git a/src/systemc/channel/SConscript b/src/systemc/channel/SConscript index fe7973770..30ae76ab4 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 000000000..7bbda59c4 --- /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 cannot have more than one reader"; +const char SC_ID_MORE_THAN_ONE_FIFO_WRITER_[] = + "sc_fifo cannot have more than one writer"; +const char SC_ID_INVALID_FIFO_SIZE_[] = + "sc_fifo 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 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 898e7b866..7ab86eeb8 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 @@ sc_clock::sc_clock(const char *name, const sc_time &period, 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 2f3dd1883..3310e23de 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_resolved::end_of_elaboration() sc_inout::end_of_elaboration(); if (!dynamic_cast(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 59191be4e..9bace3964 100644 --- a/src/systemc/channel/sc_semaphore.cc +++ b/src/systemc/channel/sc_semaphore.cc @@ -30,6 +30,7 @@ #include #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 @@ sc_semaphore::sc_semaphore(const char *_name, int value) : { 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 14ee8a6e4..e3a3cf575 100644 --- a/src/systemc/channel/sc_signal.cc +++ b/src/systemc/channel/sc_signal.cc @@ -30,6 +30,7 @@ #include #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 @@ reportSignalError(ScSignalBase *sig, sc_core::sc_object *first, ss << "\n conflicting write in delta cycle " << sc_core::sc_delta_count(); } - SC_REPORT_ERROR( - "(E115) sc_signal 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 e8a783231..109d9df93 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 @@ Port::finalize() 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 9123a2553..a2cee316c 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 @@ reportError(const char *id, const char *add_msg, sc_export_base::sc_export_base(const char *n) : sc_object(n) { if (sc_is_running()) { - reportError("(E121) insert sc_export failed", "simulation running", - name(), kind()); - } - if (::sc_gem5::scheduler.elaborationDone()) { - reportError("(E121) insert sc_export failed", "elaboration done", + reportError(SC_ID_INSERT_EXPORT_, "simulation running", 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 93aff6712..88b448742 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 @@ void sc_interface::register_port(sc_port_base &, const char *) {} 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 60911f8e1..69fe6f579 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_port_base::sc_port_base(const char *n, int max_size, sc_port_policy p) : 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 099e5d8bf..5dacc7f2f 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 @@ namespace sc_core 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_prim_channel::sc_prim_channel(const char *_name) : 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 d95cfc244..390ea15a6 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 e582ea282..e59cde355 100644 --- a/src/systemc/ext/channel/_using.hh +++ b/src/systemc/ext/channel/_using.hh @@ -97,4 +97,35 @@ using sc_core::sc_signal_resolved; 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 000000000..fe36f467c --- /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 a1c454a8f..0c83f6692 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 @@ class sc_fifo : public sc_fifo_in_if, std::string tn(iface_type_name); if (tn == typeid(sc_fifo_in_if).name() || tn == typeid(sc_fifo_blocking_in_if).name()) { - if (_reader) { - SC_REPORT_ERROR( - "(E104) sc_fifo 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).name() || tn == typeid(sc_fifo_blocking_out_if).name()) { - if (_writer) { - SC_REPORT_ERROR( - "(E105) sc_fifo 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 port not recognized"); } } diff --git a/src/systemc/ext/channel/sc_in_rv.hh b/src/systemc/ext/channel/sc_in_rv.hh index 278b95864..b963bfdfc 100644 --- a/src/systemc/ext/channel/sc_in_rv.hh +++ b/src/systemc/ext/channel/sc_in_rv.hh @@ -32,6 +32,7 @@ #include +#include "messages.hh" #include "sc_in.hh" #include "sc_signal_rv.hh" @@ -61,9 +62,7 @@ class sc_in_rv : public sc_in> if (!dynamic_cast *>(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 54f54ff7c..d91a48b78 100644 --- a/src/systemc/ext/channel/sc_inout_rv.hh +++ b/src/systemc/ext/channel/sc_inout_rv.hh @@ -33,6 +33,7 @@ #include #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 @@ class sc_inout_rv : public sc_inout> if (!dynamic_cast *>(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 90fd41f2a..56ee24f76 100644 --- a/src/systemc/ext/core/sc_event.hh +++ b/src/systemc/ext/core/sc_event.hh @@ -35,6 +35,7 @@ #include #include +#include "../channel/messages.hh" #include "../utils/sc_report_handler.hh" #include "sc_port.hh" #include "sc_time.hh" @@ -247,7 +248,7 @@ class sc_event_finder_t : public sc_event_finder 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(iface)->*_method)(); diff --git a/src/systemc/ext/core/sc_export.hh b/src/systemc/ext/core/sc_export.hh index e36e34ae9..100ce66db 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 @@ class sc_export : public sc_export_base 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 @@ class sc_export : public sc_export_base 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 aa9a322b8..c4160bafe 100644 --- a/src/systemc/ext/core/sc_port.hh +++ b/src/systemc/ext/core/sc_port.hh @@ -33,6 +33,7 @@ #include #include +#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 @@ class sc_port_b : public sc_port_base 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 @@ class sc_port_b : public sc_port_base 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 @@ class sc_port_b : public sc_port_base 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 @@ class sc_port_b : public sc_port_base 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 @@ class sc_port_b : public sc_port_base _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 @@ class sc_port_b : public sc_port_base 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 050521de0..b853acd18 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_vpool sc_int_sigref::m_pool(8); 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 bb48cecb3..baa6dd9ac 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_vpool sc_signed_sigref::m_pool(8); 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 acc4a4219..a0ad01b45 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_vpool sc_uint_sigref::m_pool(8); 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 a356d44bd..7cfc409c1 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_vpool sc_unsigned_sigref::m_pool(8); //------------------------------------------------------------------------------ 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 d00491fd7..000000000 --- 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 1b725cc0f..a2b915ed1 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 @@ sc_report_handler::report(sc_severity severity, const char *msg_type, 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_report_handler::set_actions(sc_severity severity, sc_actions actions) 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_actions 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 @@ sc_report_handler::stop_after(sc_severity severity, int limit) 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 @@ int 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 @@ sc_report_handler::get_count(sc_severity severity) 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]; } -- 2.30.2