112852Sgabeblack@google.com/*
212852Sgabeblack@google.com * Copyright 2018 Google, Inc.
312852Sgabeblack@google.com *
412852Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512852Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612852Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812852Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012852Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112852Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212852Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312852Sgabeblack@google.com * this software without specific prior written permission.
1412852Sgabeblack@google.com *
1512852Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612852Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712852Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812852Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912852Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012852Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112852Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212852Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312852Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412852Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512852Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612852Sgabeblack@google.com *
2712852Sgabeblack@google.com * Authors: Gabe Black
2812852Sgabeblack@google.com */
2912852Sgabeblack@google.com
3012852Sgabeblack@google.com#ifndef __SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
3112852Sgabeblack@google.com#define __SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
3212852Sgabeblack@google.com
3312852Sgabeblack@google.com#include <string>
3412852Sgabeblack@google.com
3512852Sgabeblack@google.comnamespace sc_dt
3612852Sgabeblack@google.com{
3712852Sgabeblack@google.com
3812852Sgabeblack@google.comtemplate <class T>
3912852Sgabeblack@google.comconst T
4012852Sgabeblack@google.comsc_abs(const T &a)
4112852Sgabeblack@google.com{
4212852Sgabeblack@google.com    // return ( a >= 0 ? a : -a );
4312852Sgabeblack@google.com    // the code below is functionaly the same as the code above; the
4412852Sgabeblack@google.com    // difference is that the code below works for all arithmetic
4512852Sgabeblack@google.com    // SystemC datatypes.
4612852Sgabeblack@google.com    T z(a);
4712852Sgabeblack@google.com    z = 0;
4812852Sgabeblack@google.com    if (a >= z) {
4912852Sgabeblack@google.com        return a;
5012852Sgabeblack@google.com    } else {
5112852Sgabeblack@google.com        T c(a);
5212852Sgabeblack@google.com        c = -a;
5312852Sgabeblack@google.com        return c;
5412852Sgabeblack@google.com    }
5512852Sgabeblack@google.com}
5612852Sgabeblack@google.com
5712852Sgabeblack@google.comtemplate <class T>
5812852Sgabeblack@google.comconst T sc_max(const T &a, const T &b) { return ((a >= b) ? a : b); }
5912852Sgabeblack@google.com
6012852Sgabeblack@google.comtemplate <class T>
6112852Sgabeblack@google.comconst T sc_min(const T &a, const T &b) { return ((a <= b) ? a : b); }
6212852Sgabeblack@google.com
6312852Sgabeblack@google.com} // namespace sc_dt
6412852Sgabeblack@google.com
6512852Sgabeblack@google.comnamespace sc_core
6612852Sgabeblack@google.com{
6712852Sgabeblack@google.com
6812852Sgabeblack@google.com#define IEEE_1666_SYSTEMC 201101L
6912852Sgabeblack@google.com
7012852Sgabeblack@google.com#define SC_VERSION_MAJOR 0
7112852Sgabeblack@google.com#define SC_VERSION_MINOR 1
7212852Sgabeblack@google.com#define SC_VERSION_PATCH 0
7312852Sgabeblack@google.com#define SC_VERSION_ORIGINATOR "gem5"
7412852Sgabeblack@google.com#define SC_VERSION_RELEASE_DATE "NA"
7512852Sgabeblack@google.com#define SC_VERSION_PRERELEASE "beta"
7612852Sgabeblack@google.com#define SC_IS_PRERELEASE true
7712852Sgabeblack@google.com#define SC_VERSION "0.1.0_beta-gem5"
7812852Sgabeblack@google.com#define SC_COPYRIGHT "Copyright 2018 Google, Inc."
7912852Sgabeblack@google.com
8012852Sgabeblack@google.comextern const unsigned int sc_version_major;
8112852Sgabeblack@google.comextern const unsigned int sc_version_minor;
8212852Sgabeblack@google.comextern const unsigned int sc_version_patch;
8312852Sgabeblack@google.comextern const std::string sc_version_originator;
8412852Sgabeblack@google.comextern const std::string sc_version_release_date;
8512852Sgabeblack@google.comextern const std::string sc_version_prerelease;
8612852Sgabeblack@google.comextern const bool sc_is_prerelease;
8712852Sgabeblack@google.comextern const std::string sc_version_string;
8812852Sgabeblack@google.comextern const std::string sc_copyright_string;
8912852Sgabeblack@google.com
9012852Sgabeblack@google.comstatic inline const char *
9112852Sgabeblack@google.comsc_release()
9212852Sgabeblack@google.com{
9312852Sgabeblack@google.com    return sc_version_string.c_str();
9412852Sgabeblack@google.com}
9512852Sgabeblack@google.comstatic inline const char *
9612852Sgabeblack@google.comsc_copyright()
9712852Sgabeblack@google.com{
9812852Sgabeblack@google.com    return sc_copyright_string.c_str();
9912852Sgabeblack@google.com}
10012852Sgabeblack@google.comconst char *sc_version();
10112852Sgabeblack@google.com
10212852Sgabeblack@google.com} // namespace sc_core
10312852Sgabeblack@google.com
10412852Sgabeblack@google.com#endif  //__SYSTEMC_EXT_UTIL_FUNCTIONS_HH__
105