diff options
author | Gabe Black <gabeblack@google.com> | 2018-10-07 05:23:49 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-10-16 01:12:58 +0000 |
commit | e07f7efb75f0f7322d752608eb1cb1e1145b4a98 (patch) | |
tree | c70d86ba3130636fd8c6ff3c0d159727b81932c8 /src/systemc/channel | |
parent | 3420f0e223888bf70cd502efb5a534e651891b5c (diff) | |
download | gem5-e07f7efb75f0f7322d752608eb1cb1e1145b4a98.tar.xz |
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>
Diffstat (limited to 'src/systemc/channel')
-rw-r--r-- | src/systemc/channel/SConscript | 1 | ||||
-rw-r--r-- | src/systemc/channel/messages.cc | 120 | ||||
-rw-r--r-- | src/systemc/channel/sc_clock.cc | 7 | ||||
-rw-r--r-- | src/systemc/channel/sc_inout_resolved.cc | 4 | ||||
-rw-r--r-- | src/systemc/channel/sc_semaphore.cc | 4 | ||||
-rw-r--r-- | src/systemc/channel/sc_signal.cc | 4 |
6 files changed, 131 insertions, 9 deletions
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<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 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<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 59191be4e..9bace3964 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 @@ 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 <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 @@ 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<T> cannot have more than one driver", + SC_REPORT_ERROR(sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, ss.str().c_str()); } |