From c9f83ec94ba1d7de0cfc46a9a23af2f9e04450e8 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 8 Oct 2018 19:01:38 -0700 Subject: systemc: Switch to using predefined messages for datatypes. Create and use predefined messages for datatypes which match the ones Accellera uses. Change-Id: I92dd52f62462b864264217bb81f3ff1dcec020bf Reviewed-on: https://gem5-review.googlesource.com/c/13331 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/ext/dt/int/_int.hh | 1 + src/systemc/ext/dt/int/_using.hh | 5 +++++ src/systemc/ext/dt/int/messages.hh | 43 ++++++++++++++++++++++++++++++++++++ src/systemc/ext/dt/int/sc_nbutils.hh | 6 +++-- 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/systemc/ext/dt/int/messages.hh (limited to 'src/systemc/ext/dt/int') diff --git a/src/systemc/ext/dt/int/_int.hh b/src/systemc/ext/dt/int/_int.hh index dfbcf6ebd..ad08a2408 100644 --- a/src/systemc/ext/dt/int/_int.hh +++ b/src/systemc/ext/dt/int/_int.hh @@ -30,6 +30,7 @@ #ifndef __SYSTEMC_EXT_CORE_DT_INT__INT_HH__ #define __SYSTEMC_EXT_CORE_DT_INT__INT_HH__ +#include "messages.hh" #include "sc_bigint.hh" #include "sc_biguint.hh" #include "sc_int.hh" diff --git a/src/systemc/ext/dt/int/_using.hh b/src/systemc/ext/dt/int/_using.hh index 82f64dd25..27840e82e 100644 --- a/src/systemc/ext/dt/int/_using.hh +++ b/src/systemc/ext/dt/int/_using.hh @@ -61,4 +61,9 @@ using sc_dt::sc_uint_base; using sc_dt::sc_unsigned; using sc_dt::uint64; +using sc_core::SC_ID_INIT_FAILED_; +using sc_core::SC_ID_ASSIGNMENT_FAILED_; +using sc_core::SC_ID_OPERATION_FAILED_; +using sc_core::SC_ID_CONVERSION_FAILED_; + #endif //__SYSTEMC_EXT_DT_INT__USING_HH__ diff --git a/src/systemc/ext/dt/int/messages.hh b/src/systemc/ext/dt/int/messages.hh new file mode 100644 index 000000000..85537ab8a --- /dev/null +++ b/src/systemc/ext/dt/int/messages.hh @@ -0,0 +1,43 @@ +/* + * 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_DT_INT_MESSAGES_HH__ +#define __SYSTEMC_EXT_DT_INT_MESSAGES_HH__ + +namespace sc_core +{ + +extern const char SC_ID_INIT_FAILED_[]; +extern const char SC_ID_ASSIGNMENT_FAILED_[]; +extern const char SC_ID_OPERATION_FAILED_[]; +extern const char SC_ID_CONVERSION_FAILED_[]; + +}; + +#endif // __SYSTEMC_EXT_DT_INT_MESSAGES_HH__ diff --git a/src/systemc/ext/dt/int/sc_nbutils.hh b/src/systemc/ext/dt/int/sc_nbutils.hh index 0d3a15cc6..3d7259503 100644 --- a/src/systemc/ext/dt/int/sc_nbutils.hh +++ b/src/systemc/ext/dt/int/sc_nbutils.hh @@ -69,6 +69,8 @@ #include #include "../../utils/sc_report_handler.hh" +#include "../bit/messages.hh" +#include "messages.hh" #include "sc_nbdefs.hh" namespace sc_dt @@ -520,7 +522,7 @@ inline void div_by_zero(Type s) { if (s == 0) { - SC_REPORT_ERROR("operation failed", + SC_REPORT_ERROR(sc_core::SC_ID_OPERATION_FAILED_, "div_by_zero(Type) : division by zero"); sc_core::sc_abort(); // can't recover from here } @@ -822,7 +824,7 @@ is_bad_double(double v) { // Windows throws exception. if (is_nan(v) || is_inf(v)) - SC_REPORT_ERROR("(E204) value is not valid", + SC_REPORT_ERROR(sc_core::SC_ID_VALUE_NOT_VALID_, "is_bad_double(double v) : " "v is not finite - NaN or Inf"); } -- cgit v1.2.3