summaryrefslogtreecommitdiff
path: root/src/systemc/ext/dt
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/ext/dt')
-rw-r--r--src/systemc/ext/dt/_dt.hh9
-rw-r--r--src/systemc/ext/dt/_using.hh9
-rw-r--r--src/systemc/ext/dt/bit/_bit.hh42
-rw-r--r--src/systemc/ext/dt/bit/_using.hh45
-rw-r--r--src/systemc/ext/dt/bit/sc_bit.hh381
-rw-r--r--src/systemc/ext/dt/bit/sc_bit_proxies.hh3419
-rw-r--r--src/systemc/ext/dt/bit/sc_bv.hh208
-rw-r--r--src/systemc/ext/dt/bit/sc_bv_base.hh282
-rw-r--r--src/systemc/ext/dt/bit/sc_logic.hh381
-rw-r--r--src/systemc/ext/dt/bit/sc_lv.hh205
-rw-r--r--src/systemc/ext/dt/bit/sc_lv_base.hh1589
-rw-r--r--src/systemc/ext/dt/bit/sc_proxy.hh1394
-rw-r--r--src/systemc/ext/dt/fx/_fx.hh53
-rw-r--r--src/systemc/ext/dt/fx/_using.hh76
-rw-r--r--src/systemc/ext/dt/fx/sc_context.hh281
-rw-r--r--src/systemc/ext/dt/fx/sc_fix.hh1343
-rw-r--r--src/systemc/ext/dt/fx/sc_fixed.hh586
-rw-r--r--src/systemc/ext/dt/fx/sc_fxcast_switch.hh159
-rw-r--r--src/systemc/ext/dt/fx/sc_fxdefs.hh283
-rw-r--r--src/systemc/ext/dt/fx/sc_fxnum.hh4370
-rw-r--r--src/systemc/ext/dt/fx/sc_fxnum_observer.hh175
-rw-r--r--src/systemc/ext/dt/fx/sc_fxtype_params.hh265
-rw-r--r--src/systemc/ext/dt/fx/sc_fxval.hh1943
-rw-r--r--src/systemc/ext/dt/fx/sc_fxval_observer.hh178
-rw-r--r--src/systemc/ext/dt/fx/sc_ufix.hh1354
-rw-r--r--src/systemc/ext/dt/fx/sc_ufixed.hh585
-rw-r--r--src/systemc/ext/dt/fx/scfx_ieee.hh613
-rw-r--r--src/systemc/ext/dt/fx/scfx_mant.hh415
-rw-r--r--src/systemc/ext/dt/fx/scfx_other_defs.hh324
-rw-r--r--src/systemc/ext/dt/fx/scfx_params.hh182
-rw-r--r--src/systemc/ext/dt/fx/scfx_pow10.hh86
-rw-r--r--src/systemc/ext/dt/fx/scfx_rep.hh724
-rw-r--r--src/systemc/ext/dt/fx/scfx_string.hh199
-rw-r--r--src/systemc/ext/dt/fx/scfx_utils.hh493
-rw-r--r--src/systemc/ext/dt/int/_int.hh17
-rw-r--r--src/systemc/ext/dt/int/_using.hh41
-rw-r--r--src/systemc/ext/dt/int/sc_bigint.hh284
-rw-r--r--src/systemc/ext/dt/int/sc_biguint.hh284
-rw-r--r--src/systemc/ext/dt/int/sc_int.hh381
-rw-r--r--src/systemc/ext/dt/int/sc_int_base.hh1386
-rw-r--r--src/systemc/ext/dt/int/sc_length_param.hh192
-rw-r--r--src/systemc/ext/dt/int/sc_nbdefs.hh88
-rw-r--r--src/systemc/ext/dt/int/sc_nbexterns.hh108
-rw-r--r--src/systemc/ext/dt/int/sc_nbutils.hh832
-rw-r--r--src/systemc/ext/dt/int/sc_signed.hh2504
-rw-r--r--src/systemc/ext/dt/int/sc_uint.hh382
-rw-r--r--src/systemc/ext/dt/int/sc_uint_base.hh1258
-rw-r--r--src/systemc/ext/dt/int/sc_unsigned.hh2195
-rw-r--r--src/systemc/ext/dt/misc/_misc.hh36
-rw-r--r--src/systemc/ext/dt/misc/_using.hh35
-rw-r--r--src/systemc/ext/dt/misc/sc_concatref.hh806
-rw-r--r--src/systemc/ext/dt/misc/sc_value_base.hh123
-rw-r--r--src/systemc/ext/dt/sc_mempool.hh100
-rw-r--r--src/systemc/ext/dt/sc_temporary.hh227
54 files changed, 33885 insertions, 45 deletions
diff --git a/src/systemc/ext/dt/_dt.hh b/src/systemc/ext/dt/_dt.hh
index f141e8591..5f21341d9 100644
--- a/src/systemc/ext/dt/_dt.hh
+++ b/src/systemc/ext/dt/_dt.hh
@@ -27,9 +27,12 @@
* Authors: Gabe Black
*/
-#ifndef __SYSTEMC_EXT_CORE__DT_HH__
-#define __SYSTEMC_EXT_CORE__DT_HH__
+#ifndef __SYSTEMC_EXT_DT__DT_HH__
+#define __SYSTEMC_EXT_DT__DT_HH__
+#include "bit/_bit.hh"
+#include "fx/_fx.hh"
#include "int/_int.hh"
+#include "misc/_misc.hh"
-#endif //__SYSTEMC_EXT_CORE__DT_HH__
+#endif //__SYSTEMC_EXT_DT__DT_HH__
diff --git a/src/systemc/ext/dt/_using.hh b/src/systemc/ext/dt/_using.hh
index b410cc27b..18b78f179 100644
--- a/src/systemc/ext/dt/_using.hh
+++ b/src/systemc/ext/dt/_using.hh
@@ -27,9 +27,12 @@
* Authors: Gabe Black
*/
-#ifndef __SYSTEMC_EXT_CORE__USING_HH__
-#define __SYSTEMC_EXT_CORE__USING_HH__
+#ifndef __SYSTEMC_EXT_DT__USING_HH__
+#define __SYSTEMC_EXT_DT__USING_HH__
+#include "bit/_using.hh"
+#include "fx/_using.hh"
#include "int/_using.hh"
+#include "misc/_using.hh"
-#endif //__SYSTEMC_EXT_CORE__USING_HH__
+#endif //__SYSTEMC_EXT_DT__USING_HH__
diff --git a/src/systemc/ext/dt/bit/_bit.hh b/src/systemc/ext/dt/bit/_bit.hh
new file mode 100644
index 000000000..b549e2828
--- /dev/null
+++ b/src/systemc/ext/dt/bit/_bit.hh
@@ -0,0 +1,42 @@
+/*
+ * 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_BIT__BIT_HH__
+#define __SYSTEMC_EXT_DT_BIT__BIT_HH__
+
+#include "sc_bit.hh"
+#include "sc_bit_proxies.hh"
+#include "sc_bv.hh"
+#include "sc_bv_base.hh"
+#include "sc_logic.hh"
+#include "sc_lv.hh"
+#include "sc_lv_base.hh"
+#include "sc_proxy.hh"
+
+#endif //__SYSTEMC_EXT_DT_BIT__BIT_HH__
diff --git a/src/systemc/ext/dt/bit/_using.hh b/src/systemc/ext/dt/bit/_using.hh
new file mode 100644
index 000000000..8bc747957
--- /dev/null
+++ b/src/systemc/ext/dt/bit/_using.hh
@@ -0,0 +1,45 @@
+/*
+ * 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_BIT__USING_HH__
+#define __SYSTEMC_EXT_DT_BIT__USING_HH__
+
+#include "_bit.hh"
+
+using sc_dt::SC_LOGIC_0;
+using sc_dt::SC_LOGIC_1;
+using sc_dt::SC_LOGIC_X;
+using sc_dt::SC_LOGIC_Z;
+using sc_dt::sc_bit;
+using sc_dt::sc_bv;
+using sc_dt::sc_bv_base;
+using sc_dt::sc_lv;
+using sc_dt::sc_lv_base;
+
+#endif //__SYSTEMC_EXT_DT_BIT__USING_HH__
diff --git a/src/systemc/ext/dt/bit/sc_bit.hh b/src/systemc/ext/dt/bit/sc_bit.hh
new file mode 100644
index 000000000..f4000a226
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_bit.hh
@@ -0,0 +1,381 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_bit.h -- Bit class.
+
+ Original Author: Stan Y. Liao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_bit.h,v $
+// Revision 1.2 2011/08/07 18:54:19 acg
+// Philipp A. Hartmann: remove friend function declarations that implement
+// code, and clean up how bit and logic operators are defined in general.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.6 2006/05/08 17:49:59 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.5 2006/04/12 20:17:52 acg
+// Andy Goodrich: enabled deprecation message for sc_bit.
+//
+// Revision 1.4 2006/01/24 20:50:55 acg
+// Andy Goodrich: added warnings indicating that sc_bit is deprecated and that
+// the C bool data type should be used in its place.
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_BIT_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_BIT_HH__
+
+#include <iostream>
+
+#include "../int/sc_nbdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_bit;
+
+// forward class declarations
+class sc_logic;
+
+extern void sc_deprecated_sc_bit();
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_bit
+//
+// Bit class.
+// Note: VSIA compatibility indicated.
+// ----------------------------------------------------------------------------
+
+class sc_bit
+{
+ // support methods
+
+ static void invalid_value(char);
+ static void invalid_value(int);
+
+ static bool
+ to_value(char c)
+ {
+ if (c != '0' && c != '1') {
+ invalid_value(c);
+ }
+ return (c == '0' ? false : true);
+ }
+
+ static bool
+ to_value(int i)
+ {
+ if (i != 0 && i != 1) {
+ invalid_value(i);
+ }
+ return (i == 0 ? false : true);
+ }
+ static bool to_value(bool b) { return b; }
+
+#define DEFN_TO_VALUE_T(tp) \
+ static bool to_value(tp i) { return to_value((int)i); }
+
+ DEFN_TO_VALUE_T(unsigned)
+ DEFN_TO_VALUE_T(long)
+ DEFN_TO_VALUE_T(unsigned long)
+ DEFN_TO_VALUE_T(int64)
+ DEFN_TO_VALUE_T(uint64)
+
+#undef DEFN_TO_VALUE_T
+
+ public:
+ // constructors
+ // MANDATORY
+ sc_bit() : m_val(false) { sc_deprecated_sc_bit(); }
+
+#define DEFN_CTOR_T(tp) \
+ explicit sc_bit(tp a) : m_val(to_value(a)) { sc_deprecated_sc_bit(); }
+
+ DEFN_CTOR_T(bool)
+ DEFN_CTOR_T(char)
+ DEFN_CTOR_T(int)
+ DEFN_CTOR_T(unsigned)
+ DEFN_CTOR_T(long)
+ DEFN_CTOR_T(unsigned long)
+ DEFN_CTOR_T(int64)
+ DEFN_CTOR_T(uint64)
+
+#undef DEFN_CTOR_T
+
+ explicit sc_bit(const sc_logic &a); // non-VSIA
+
+ // copy constructor
+ // MANDATORY
+ sc_bit(const sc_bit &a) : m_val(a.m_val) {}
+
+ // destructor
+ // MANDATORY
+ ~sc_bit() {}
+
+ // assignment operators
+ // MANDATORY
+ sc_bit &
+ operator = (const sc_bit &b)
+ {
+ m_val = b.m_val;
+ return *this;
+ }
+
+#define DEFN_ASN_OP_T(op, tp) \
+ sc_bit &operator op(tp b) { return (*this op sc_bit(b)); }
+#define DEFN_ASN_OP(op) \
+ DEFN_ASN_OP_T(op,int) \
+ DEFN_ASN_OP_T(op,bool) \
+ DEFN_ASN_OP_T(op,char)
+
+ DEFN_ASN_OP(=)
+ DEFN_ASN_OP_T(=,int64)
+ DEFN_ASN_OP_T(=,uint64)
+ DEFN_ASN_OP_T(=,long)
+ DEFN_ASN_OP_T(=,unsigned long)
+
+ sc_bit &operator = (const sc_logic &b); // non-VSIA
+
+ // bitwise assignment operators
+ sc_bit &
+ operator &= (const sc_bit &b)
+ {
+ m_val = (m_val && b.m_val);
+ return *this;
+ }
+
+ sc_bit &
+ operator |= (const sc_bit &b)
+ {
+ m_val = (m_val || b.m_val);
+ return *this;
+ }
+
+ sc_bit &
+ operator ^= (const sc_bit &b)
+ {
+ m_val = (m_val != b.m_val);
+ return *this;
+ }
+
+ DEFN_ASN_OP(&=)
+ DEFN_ASN_OP(|=)
+ DEFN_ASN_OP(^=)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+ // conversions
+ // MANDATORY
+
+ // implicit conversion to bool
+ operator bool () const { return m_val; }
+
+ // non-VSIA
+ bool operator ! () const { return !m_val; }
+
+
+ // explicit conversions - non-VSIA
+ bool to_bool() const { return m_val; }
+ char to_char() const { return (m_val ? '1' : '0'); }
+
+ // relational operators and functions
+ // MANDATORY
+ friend bool operator == (const sc_bit &a, const sc_bit &b);
+ friend bool operator != (const sc_bit &a, const sc_bit &b);
+
+ // bitwise operators and functions
+
+ // bitwise complement
+ // MANDATORY
+ friend const sc_bit operator ~ (const sc_bit &a);
+
+ // RECOMMENDED
+ sc_bit &
+ b_not()
+ {
+ m_val = (!m_val);
+ return *this;
+ }
+
+ // binary bit-wise operations
+ friend const sc_bit operator | (const sc_bit &a, const sc_bit &b);
+ friend const sc_bit operator & (const sc_bit &a, const sc_bit &b);
+ friend const sc_bit operator ^ (const sc_bit &a, const sc_bit &b);
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_bool(); }
+ void scan(::std::istream & =::std::cin);
+
+ private:
+ bool m_val;
+};
+
+// ----------------------------------------------------------------------------
+// relational operators and functions
+
+#define DEFN_BIN_FUN_T(ret,fun,tp) \
+ inline ret fun(const sc_bit& a, tp b) { return fun(a, sc_bit(b)); } \
+ inline ret fun(tp b, const sc_bit &a) { return fun(sc_bit(a), b); }
+
+#define DEFN_BIN_FUN(ret,fun) \
+ DEFN_BIN_FUN_T(ret,fun,bool) \
+ DEFN_BIN_FUN_T(ret,fun,char) \
+ DEFN_BIN_FUN_T(ret,fun,int)
+
+// MANDATORY
+inline bool
+operator == (const sc_bit &a, const sc_bit &b)
+{
+ return (a.m_val == b.m_val);
+}
+
+inline bool
+operator != (const sc_bit &a, const sc_bit &b)
+{
+ return (a.m_val != b.m_val);
+}
+
+DEFN_BIN_FUN(bool, operator ==)
+DEFN_BIN_FUN(bool, operator !=)
+
+// OPTIONAL
+
+inline bool equal(const sc_bit &a, const sc_bit &b) { return (a == b); }
+
+inline bool not_equal(const sc_bit &a, const sc_bit &b) { return (a != b); }
+
+DEFN_BIN_FUN(bool,equal)
+DEFN_BIN_FUN(bool,not_equal)
+
+// ----------------------------------------------------------------------------
+// bitwise operators and functions
+
+// bitwise complement
+
+// MANDATORY
+inline const sc_bit operator ~ (const sc_bit &a) { return sc_bit(!a.m_val); }
+
+// OPTIONAL
+inline const sc_bit b_not(const sc_bit &a) { return (~a); }
+
+// RECOMMENDED
+inline void b_not(sc_bit &r, const sc_bit &a) { r = (~a); }
+
+// binary bit-wise operations
+// MANDATORY
+inline const sc_bit
+operator & (const sc_bit &a, const sc_bit &b)
+{
+ return sc_bit(a.m_val && b.m_val);
+}
+
+inline const sc_bit
+operator | (const sc_bit &a, const sc_bit &b)
+{
+ return sc_bit(a.m_val || b.m_val);
+}
+
+inline const sc_bit
+operator ^ (const sc_bit &a, const sc_bit &b)
+{
+ return sc_bit(a.m_val != b.m_val);
+}
+
+DEFN_BIN_FUN(const sc_bit,operator&)
+DEFN_BIN_FUN(const sc_bit,operator|)
+DEFN_BIN_FUN(const sc_bit,operator^)
+
+// OPTIONAL
+inline const sc_bit b_and(const sc_bit &a, const sc_bit &b) { return a & b; }
+inline const sc_bit b_or(const sc_bit &a, const sc_bit &b) { return a | b; }
+inline const sc_bit b_xor(const sc_bit &a, const sc_bit &b) { return a ^ b; }
+
+DEFN_BIN_FUN(const sc_bit,b_and)
+DEFN_BIN_FUN(const sc_bit,b_or)
+DEFN_BIN_FUN(const sc_bit,b_xor)
+
+// RECOMMENDED
+
+#define DEFN_TRN_FUN_T(fun,tp) \
+ inline void \
+ fun(sc_bit &r, const sc_bit &a, tp b) \
+ { r = fun(a, sc_bit(b)); } \
+ inline void \
+ fun(sc_bit &r, tp a, const sc_bit &b) \
+ { r = fun(sc_bit(a), b); }
+
+#define DEFN_TRN_FUN(fun) \
+ inline void \
+ fun(sc_bit &r, const sc_bit &a, const sc_bit &b) { r = fun(a , b); } \
+ DEFN_TRN_FUN_T(fun, int) \
+ DEFN_TRN_FUN_T(fun, bool) \
+ DEFN_TRN_FUN_T(fun, char)
+
+ DEFN_TRN_FUN(b_and)
+ DEFN_TRN_FUN(b_or)
+ DEFN_TRN_FUN(b_xor)
+
+#undef DEFN_BIN_FUN_T
+#undef DEFN_BIN_FUN
+#undef DEFN_TRN_FUN_T
+#undef DEFN_TRN_FUN
+
+
+// ----------------------------------------------------------------------------
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_bit &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_bit &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_BIT_HH__
diff --git a/src/systemc/ext/dt/bit/sc_bit_proxies.hh b/src/systemc/ext/dt/bit/sc_bit_proxies.hh
new file mode 100644
index 000000000..0eec8aac0
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_bit_proxies.hh
@@ -0,0 +1,3419 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_bit_proxies.h -- Proxy classes for vector data types.
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ CHANGE LOG AT THE END OF THE FILE
+ *****************************************************************************/
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
+
+#include <iostream>
+
+#include "sc_proxy.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <class X, class Traits>
+class sc_bitref_conv_r;
+template <class X>
+class sc_bitref_r;
+template <class X>
+class sc_bitref;
+template <class X>
+class sc_subref_r;
+template <class X>
+class sc_subref;
+template <class X, class Y>
+class sc_concref_r;
+template <class X, class Y>
+class sc_concref;
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref_conv_r<T>
+//
+// Proxy class for sc_proxy bit selection (r-value only, boolean conversion).
+// ----------------------------------------------------------------------------
+template <class T, class Traits=typename T::traits_type>
+class sc_bitref_conv_r { /* empty by default */ };
+
+// specialization for bit-vector based sc_proxy classes
+template<typename T>
+class sc_bitref_conv_r<T, sc_proxy_traits<sc_bv_base> >
+{
+ public:
+#if __cplusplus >= 201103L // explicit operator needs C++11
+ // explicit conversion to bool
+ explicit operator bool() const
+ {
+ return static_cast<const sc_bitref_r<T> &>(*this).to_bool();
+ }
+#endif
+
+ // explicit (negating) conversion to bool
+ bool
+ operator ! () const
+ {
+ return !static_cast<const sc_bitref_r<T> &>(*this).to_bool();
+ }
+};
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref_r<T>
+//
+// Proxy class for sc_proxy bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+template <class T>
+class sc_bitref_r : public sc_bitref_conv_r<T>
+{
+ friend class sc_bv_base;
+ friend class sc_lv_base;
+
+ public:
+ // typedefs
+ typedef typename T::traits_type traits_type;
+ typedef typename traits_type::bit_type bit_type;
+ typedef typename traits_type::value_type value_type;
+
+ // constructor
+ sc_bitref_r(const T &obj_, int index_) :
+ m_obj(const_cast<T &>(obj_)), m_index(index_)
+ {}
+
+ // copy constructor
+ sc_bitref_r(const sc_bitref_r<T> &a) : m_obj(a.m_obj), m_index(a.m_index)
+ {}
+
+ // cloning
+ sc_bitref_r<T> *clone() const { return new sc_bitref_r<T>(*this); }
+
+ // bitwise operators and functions
+
+ // bitwise complement
+ bit_type
+ operator ~ () const
+ {
+ return bit_type(sc_logic::not_table[value()]);
+ }
+
+ // implicit conversion to bit_type
+ operator bit_type() const { return bit_type(m_obj.get_bit(m_index)); }
+
+ // explicit conversions
+ value_type value() const { return m_obj.get_bit(m_index); }
+ bool is_01() const { return sc_logic(value()).is_01(); }
+ bool to_bool() const { return sc_logic(value()).to_bool(); }
+ char to_char() const { return sc_logic(value()).to_char(); }
+
+ // common methods
+ int length() const { return 1; }
+ int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
+
+ value_type get_bit(int n) const;
+
+ sc_digit get_word(int i) const;
+ sc_digit get_cword(int i) const;
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_char(); }
+
+ protected:
+ T &m_obj;
+ int m_index;
+
+ private:
+ // Disabled
+ sc_bitref_r();
+ sc_bitref_r<T> &operator = (const sc_bitref_r<T> &);
+};
+
+// bitwise operators and functions
+
+// bitwise and
+template <class T1, class T2>
+inline sc_logic operator & (
+ const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
+
+
+// bitwise or
+template <class T1, class T2>
+inline sc_logic operator | (
+ const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
+
+// bitwise xor
+template <class T1, class T2>
+inline sc_logic operator ^ (
+ const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
+
+// relational operators and functions
+template <class T1, class T2>
+inline bool operator == (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
+
+template <class T1, class T2>
+inline bool operator != (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
+
+// r-value concatenation operators and functions
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_bitref_r<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_bitref_r<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > operator , (
+ sc_bitref_r<T1>, sc_concref_r<T2,T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
+ sc_bitref_r<T1>, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref_r<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ const char *, sc_bitref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref_r<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ const sc_logic &, sc_bitref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref_r<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ bool, sc_bitref_r<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_bitref_r<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
+ sc_bitref_r<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > concat(
+ sc_bitref_r<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> concat(
+ sc_bitref_r<T1>, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
+ sc_bitref_r<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
+ const char *, sc_bitref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
+ sc_bitref_r<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
+ const sc_logic &, sc_bitref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
+ sc_bitref_r<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
+ bool, sc_bitref_r<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_bitref_r<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_bitref<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_bitref_r<T1>, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_bitref<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > operator , (
+ sc_bitref_r<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > operator , (
+ sc_bitref<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
+ sc_bitref<T1>, const sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
+ sc_bitref_r<T1>, sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ const char *, sc_bitref<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ const sc_logic &, sc_bitref<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
+ sc_bitref<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
+ bool, sc_bitref<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_bitref_r<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_bitref<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
+ sc_bitref_r<T1>, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
+ sc_bitref<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > concat(
+ sc_bitref_r<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > concat(
+ sc_bitref<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> concat(
+ sc_bitref<T1>, const sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2> concat(
+ sc_bitref_r<T1>, sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
+ sc_bitref<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
+ const char *, sc_bitref<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
+ sc_bitref<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
+ const sc_logic &, sc_bitref<T>);
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(sc_bitref<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(bool, sc_bitref<T>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref<X>
+//
+// Proxy class for sc_proxy bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+template <class X>
+class sc_bitref : public sc_bitref_r<X>
+{
+ friend class sc_bv_base;
+ friend class sc_lv_base;
+
+ public:
+ typedef typename sc_bitref_r<X>::value_type value_type;
+
+ // constructor
+ sc_bitref(X &obj_, int index_) : sc_bitref_r<X>(obj_, index_) {}
+
+ // copy constructor
+ sc_bitref(const sc_bitref<X> &a) : sc_bitref_r<X>(a) {}
+
+ // cloning
+ sc_bitref<X> *clone() const { return new sc_bitref<X>(*this); }
+
+ // assignment operators
+ sc_bitref<X> &operator = (const sc_bitref_r<X> &a);
+ sc_bitref<X> &operator = (const sc_bitref<X> &a);
+
+ sc_bitref<X> &
+ operator = (const sc_logic &a)
+ {
+ this->m_obj.set_bit(this->m_index, a.value());
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator = (sc_logic_value_t v)
+ {
+ *this = sc_logic(v);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator = (bool a)
+ {
+ *this = sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator = (char a)
+ {
+ *this = sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator = (int a)
+ {
+ *this = sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator = (const sc_bit &a)
+ {
+ *this = sc_logic(a);
+ return *this;
+ }
+
+ // bitwise assignment operators
+ sc_bitref<X> &operator &= (const sc_bitref_r<X> &a);
+ sc_bitref<X> &operator &= (const sc_logic &a);
+
+ sc_bitref<X> &
+ operator &= (sc_logic_value_t v)
+ {
+ *this &= sc_logic(v);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator &= (bool a)
+ {
+ *this &= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator &= (char a)
+ {
+ *this &= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator &= (int a)
+ {
+ *this &= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &operator |= (const sc_bitref_r<X> &a);
+ sc_bitref<X> &operator |= (const sc_logic &a);
+
+ sc_bitref<X> &
+ operator |= (sc_logic_value_t v)
+ {
+ *this |= sc_logic(v);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator |= (bool a)
+ {
+ *this |= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator |= (char a)
+ {
+ *this |= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator |= (int a)
+ {
+ *this |= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &operator ^= (const sc_bitref_r<X> &a);
+ sc_bitref<X> &operator ^= (const sc_logic &a);
+
+ sc_bitref<X> &
+ operator ^= (sc_logic_value_t v)
+ {
+ *this ^= sc_logic(v);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator ^= (bool a)
+ {
+ *this ^= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator ^= (char a)
+ {
+ *this ^= sc_logic(a);
+ return *this;
+ }
+
+ sc_bitref<X> &
+ operator ^= (int a)
+ {
+ *this ^= sc_logic(a);
+ return *this;
+ }
+
+ // bitwise operators and functions
+
+ // bitwise complement
+ sc_bitref<X> &b_not();
+
+ // common methods
+ void set_bit(int n, value_type value);
+
+ void set_word(int i, sc_digit w);
+ void set_cword(int i, sc_digit w);
+
+ void clean_tail() { this->m_obj.clean_tail(); }
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ private:
+ // Disabled
+ sc_bitref();
+};
+
+
+// l-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_bitref<T2> > operator , (
+ sc_bitref<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_subref<T2> > operator , (
+ sc_bitref<T1>, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> > operator , (
+ sc_bitref<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, T2> operator , (
+ sc_bitref<T1>, sc_proxy<T2> &);
+
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_bitref<T2> > concat(
+ sc_bitref<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_subref<T2> > concat(
+ sc_bitref<T1>, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_bitref<T1>, sc_concref<T2,T3> > concat(
+ sc_bitref<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, T2> concat(sc_bitref<T1>, sc_proxy<T2> &);
+
+
+template <class T>
+::std::istream &operator >> (::std::istream &, sc_bitref<T>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref_r<X>
+//
+// Proxy class for sc_proxy part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+template <class X>
+class sc_subref_r : public sc_proxy<sc_subref_r<X> >
+{
+ void check_bounds();
+
+ public:
+ typedef typename sc_proxy<sc_subref_r<X> >::value_type value_type;
+
+ // constructor
+ sc_subref_r(const X &obj_, int hi_, int lo_) :
+ m_obj(const_cast<X &>(obj_)), m_hi(hi_), m_lo(lo_), m_len(0)
+ { check_bounds(); }
+
+ // copy constructor
+ sc_subref_r(const sc_subref_r<X> &a) :
+ m_obj(a.m_obj), m_hi(a.m_hi), m_lo(a.m_lo), m_len(a.m_len)
+ {}
+
+ // cloning
+ sc_subref_r<X> *clone() const { return new sc_subref_r<X>(*this); }
+
+ // common methods
+ int length() const { return m_len; }
+
+ int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
+
+ value_type get_bit(int n) const;
+ void set_bit(int n, value_type value);
+
+ sc_digit get_word(int i) const;
+ void set_word(int i, sc_digit w);
+
+ sc_digit get_cword(int i) const;
+ void set_cword(int i, sc_digit w);
+
+ void clean_tail() { m_obj.clean_tail(); }
+
+ // other methods
+ bool is_01() const;
+ bool reversed() const { return m_lo > m_hi; }
+
+ protected:
+ X &m_obj;
+ int m_hi;
+ int m_lo;
+ int m_len;
+
+ private:
+ // Disabled
+ sc_subref_r();
+ sc_subref_r<X> &operator = (const sc_subref_r<X> &);
+};
+
+
+// r-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_subref_r<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_subref_r<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2,T3> > operator , (
+ sc_subref_r<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> operator , (
+ sc_subref_r<T1>, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>,sc_lv_base> operator , (
+ sc_subref_r<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
+ const char *, sc_subref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
+ sc_subref_r<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
+ const sc_logic &, sc_subref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base> operator , (
+ sc_subref_r<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> > operator , (
+ bool, sc_subref_r<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_subref_r<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
+ sc_subref_r<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
+ sc_subref_r<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> concat(
+ sc_subref_r<T1>, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
+ sc_subref_r<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base,sc_subref_r<T> > concat(
+ const char *, sc_subref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
+ sc_subref_r<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
+ const sc_logic &, sc_subref_r<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base> concat(sc_subref_r<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> > concat(bool, sc_subref_r<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_subref_r<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
+ sc_subref<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_subref_r<T1>, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
+ sc_subref<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > operator , (
+ sc_subref_r<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > operator , (
+ sc_subref<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> operator , (
+ sc_subref<T1>, const sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> operator , (
+ sc_subref_r<T1>, sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
+ sc_subref<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
+ const char *, sc_subref<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
+ sc_subref<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
+ const sc_logic &, sc_subref<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base> operator , (
+ sc_subref<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> > operator , (
+ bool, sc_subref<T>);
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_subref_r<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
+ sc_subref<T1>, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
+ sc_subref_r<T1>, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
+ sc_subref<T1>, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
+ sc_subref_r<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
+ sc_subref<T1>, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> concat(
+ sc_subref<T1>, const sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2> concat(
+ sc_subref_r<T1>, sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
+ sc_subref<T>, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
+ const char *, sc_subref<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
+ sc_subref<T>, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
+ const sc_logic &, sc_subref<T>);
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base> concat(sc_subref<T>, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> > concat(bool, sc_subref<T>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref<X>
+//
+// Proxy class for sc_proxy part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+template <class X>
+class sc_subref : public sc_subref_r<X>
+{
+ public:
+ // typedefs
+ typedef sc_subref_r<X> base_type;
+
+ // constructor
+ sc_subref(X &obj_, int hi_, int lo_) : sc_subref_r<X>(obj_, hi_, lo_) {}
+
+ // copy constructor
+ sc_subref(const sc_subref<X> &a) : sc_subref_r<X>(a) {}
+
+ // cloning
+ sc_subref<X> *clone() const { return new sc_subref<X>(*this); }
+
+ // assignment operators
+ template <class Y>
+ sc_subref<X> &
+ operator = (const sc_proxy<Y> &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &operator = (const sc_subref_r<X> &a);
+ sc_subref<X> &operator = (const sc_subref<X> &a);
+
+ sc_subref<X> &
+ operator = (const char *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const bool *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const sc_logic *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const sc_unsigned &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const sc_signed &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const sc_uint_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (const sc_int_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (unsigned long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (unsigned int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (uint64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_subref<X> &
+ operator = (int64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ // other methods
+ void scan(::std::istream & =::std::cin);
+
+ private:
+ // Disabled
+ sc_subref();
+};
+
+
+// l-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_bitref<T2> > operator , (
+ sc_subref<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_subref<T2> > operator , (
+ sc_subref<T1>, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_subref<T1>, sc_concref<T2, T3> > operator , (
+ sc_subref<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, T2> operator , (
+ sc_subref<T1>, sc_proxy<T2> &);
+
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_bitref<T2> > concat(
+ sc_subref<T1>, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_subref<T2> > concat(
+ sc_subref<T1>, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_subref<T1>, sc_concref<T2, T3> > concat(
+ sc_subref<T1>, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, T2> concat(sc_subref<T1>, sc_proxy<T2> &);
+
+
+template <class T>
+inline ::std::istream &operator >> (::std::istream &, sc_subref<T>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concref_r<X,Y>
+//
+// Proxy class for sc_proxy concatenation (r-value only).
+// ----------------------------------------------------------------------------
+
+template <class X, class Y>
+class sc_concref_r : public sc_proxy<sc_concref_r<X, Y> >
+{
+ public:
+ typedef typename sc_proxy<sc_concref_r<X, Y> >::value_type value_type;
+
+ // constructor
+ sc_concref_r(const X &left_, const Y &right_, int delete_=0) :
+ m_left(const_cast<X &>(left_)), m_right(const_cast<Y &>(right_)),
+ m_delete(delete_), m_refs(*new int(1))
+ {}
+
+ // copy constructor
+ sc_concref_r(const sc_concref_r<X, Y> &a) :
+ m_left(a.m_left), m_right(a.m_right),
+ m_delete(a.m_delete), m_refs(a.m_refs)
+ { ++ m_refs; }
+
+ // destructor
+ virtual ~sc_concref_r();
+
+ // cloning
+ sc_concref_r<X, Y> *clone() const { return new sc_concref_r<X, Y>(*this); }
+
+ // common methods
+ int length() const { return (m_left.length() + m_right.length()); }
+
+ int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
+
+ value_type get_bit(int n) const;
+ void set_bit(int n, value_type value);
+
+ sc_digit get_word(int i) const;
+ void set_word(int i, sc_digit w);
+
+ sc_digit get_cword(int i) const;
+ void set_cword(int i, sc_digit w);
+
+ void clean_tail() { m_left.clean_tail(); m_right.clean_tail(); }
+
+ // other methods
+ bool is_01() const { return (m_left.is_01() && m_right.is_01()); }
+
+ protected:
+ X &m_left;
+ Y &m_right;
+ mutable int m_delete;
+ int &m_refs;
+
+ private:
+ // Disabled
+ sc_concref_r();
+ sc_concref_r<X, Y> &operator = (const sc_concref_r<X, Y> &);
+};
+
+
+// r-value concatenation operators and functions
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> > operator , (
+ sc_concref_r<T1, T2>, sc_bitref_r<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
+ sc_concref_r<T1, T2>, sc_subref_r<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
+ sc_concref_r<T1, T2>, sc_concref_r<T3, T4>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
+ sc_concref_r<T1, T2>, const sc_proxy<T3> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
+ sc_concref_r<T1, T2>, const char *);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
+ const char *, sc_concref_r<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
+ sc_concref_r<T1, T2>, const sc_logic &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
+ const sc_logic &, sc_concref_r<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> operator , (
+ sc_concref_r<T1, T2>, bool);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > operator , (
+ bool, sc_concref_r<T1, T2>);
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
+ sc_concref_r<T1, T2>, sc_bitref_r<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
+ sc_concref_r<T1, T2>, sc_subref_r<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
+ sc_concref_r<T1, T2>, sc_concref_r<T3, T4>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
+ sc_concref_r<T1, T2>, const sc_proxy<T3> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
+ sc_concref_r<T1, T2>, const char *);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
+ const char *, sc_concref_r<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
+ sc_concref_r<T1, T2>, const sc_logic &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
+ const sc_logic &, sc_concref_r<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> concat(
+ sc_concref_r<T1, T2>, bool);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > concat(
+ bool, sc_concref_r<T1, T2>);
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > operator , (
+ sc_concref_r<T1, T2>, sc_bitref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > operator , (
+ sc_concref<T1, T2>, sc_bitref_r<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
+ sc_concref_r<T1, T2>, sc_subref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
+ sc_concref<T1, T2>, sc_subref_r<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
+ sc_concref_r<T1, T2>, sc_concref<T3, T4>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
+ sc_concref<T1, T2>, sc_concref_r<T3, T4>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
+ sc_concref<T1, T2>, const sc_proxy<T3> &);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
+ sc_concref_r<T1, T2>, sc_proxy<T3> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
+ sc_concref<T1, T2>, const char *);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
+ const char *, sc_concref<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
+ sc_concref<T1, T2>, const sc_logic &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
+ const sc_logic &, sc_concref<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> operator , (
+ sc_concref<T1, T2>, bool);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > operator , (
+ bool, sc_concref<T1, T2>);
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
+ sc_concref_r<T1, T2>, sc_bitref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
+ sc_concref<T1, T2>, sc_bitref_r<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
+ sc_concref_r<T1, T2>, sc_subref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
+ sc_concref<T1, T2>, sc_subref_r<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
+ sc_concref_r<T1, T2>, sc_concref<T3, T4>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
+ sc_concref<T1, T2>, sc_concref_r<T3, T4> );
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
+ sc_concref<T1, T2>, const sc_proxy<T3> &);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
+ sc_concref_r<T1, T2>, sc_proxy<T3> &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
+ sc_concref<T1, T2>, const char *);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
+ const char *, sc_concref<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
+ sc_concref<T1, T2>, const sc_logic &);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
+ const sc_logic &, sc_concref<T1, T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> concat(
+ sc_concref<T1, T2>, bool);
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > concat(
+ bool, sc_concref<T1, T2>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concref<X,Y>
+//
+// Proxy class for sc_proxy concatenation (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+template <class X, class Y>
+class sc_concref : public sc_concref_r<X, Y>
+{
+ public:
+ // typedefs
+ typedef sc_concref_r<X, Y> base_type;
+
+ // constructor
+ sc_concref(X &left_, Y &right_, int delete_=0) :
+ sc_concref_r<X, Y>(left_, right_, delete_)
+ {}
+
+ // copy constructor
+ sc_concref(const sc_concref<X, Y> &a) : sc_concref_r<X, Y>(a) {}
+
+ // cloning
+ sc_concref<X, Y> *clone() const { return new sc_concref<X, Y>(*this); }
+
+ // assignment operators
+ template <class Z>
+ sc_concref<X, Y> &
+ operator = (const sc_proxy<Z> &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_concref<X, Y> &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const char *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const bool *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_logic *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_unsigned &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_signed &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_uint_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (const sc_int_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (unsigned long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (unsigned int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (uint64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_concref<X, Y> &
+ operator = (int64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ // other methods
+ void scan(::std::istream & =::std::cin);
+
+ private:
+ // Disabled
+ sc_concref();
+};
+
+
+// l-value concatenation operators and functions
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> > operator , (
+ sc_concref<T1, T2>, sc_bitref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_subref<T3> > operator , (
+ sc_concref<T1, T2>, sc_subref<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> > operator , (
+ sc_concref<T1, T2>, sc_concref<T3, T4>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, T3> operator , (
+ sc_concref<T1, T2>, sc_proxy<T3> &);
+
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> > concat(
+ sc_concref<T1, T2>, sc_bitref<T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_subref<T3> > concat(
+ sc_concref<T1, T2>, sc_subref<T3>);
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> > concat(
+ sc_concref<T1, T2>, sc_concref<T3, T4>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, T3> concat(
+ sc_concref<T1, T2>, sc_proxy<T3> &);
+
+
+template <class T1, class T2>
+inline ::std::istream &operator >> (::std::istream &, sc_concref<T1, T2>);
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy<T>
+//
+// Base class template for bit/logic vector classes.
+// (Barton/Nackmann implementation)
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
+ const sc_proxy<T1> &, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > operator , (
+ const sc_proxy<T1> &, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
+ const sc_proxy<T1> &, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> operator , (
+ const sc_proxy<T1> &, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> operator , (
+ const sc_proxy<T> &, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base,T> operator , (
+ const char *, const sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> operator , (
+ const sc_proxy<T> &, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> operator , (
+ const sc_logic &, const sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base> operator , (const sc_proxy<T> &, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T> operator , (bool, const sc_proxy<T> &);
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > concat(
+ const sc_proxy<T1> &, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > concat(
+ const sc_proxy<T1> &, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
+ const sc_proxy<T1> &, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> concat(const sc_proxy<T1> &, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> concat(const sc_proxy<T> &, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> concat(const char *, const sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> concat(
+ const sc_proxy<T> &, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> concat(
+ const sc_logic &, const sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base> concat(const sc_proxy<T> &, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T> concat(bool, const sc_proxy<T> &);
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
+ const sc_proxy<T1> &, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
+ sc_proxy<T1> &, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > operator , (
+ const sc_proxy<T1> &, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > operator , (
+ sc_proxy<T1> &, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
+ const sc_proxy<T1> &, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
+ sc_proxy<T1> &, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> operator , (const sc_proxy<T1> &, sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> operator , (sc_proxy<T1> &, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> operator , (sc_proxy<T> &, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> operator , (const char *, sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> operator , (
+ sc_proxy<T> &, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> operator , (
+ const sc_logic &, sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base> operator , (sc_proxy<T> &, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T> operator , (bool, sc_proxy<T> &);
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > concat(
+ const sc_proxy<T1> &, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> > concat(
+ sc_proxy<T1> &, sc_bitref_r<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > concat(
+ const sc_proxy<T1> &, sc_subref<T2>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> > concat(
+ sc_proxy<T1> &, sc_subref_r<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
+ const sc_proxy<T1> &, sc_concref<T2, T3>);
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
+ sc_proxy<T1> &, sc_concref_r<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> concat(const sc_proxy<T1> &, sc_proxy<T2> &);
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2> concat(sc_proxy<T1> &, const sc_proxy<T2> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> concat(sc_proxy<T> &, const char *);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> concat(const char *, sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base> concat(sc_proxy<T> &, const sc_logic &);
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T> concat(const sc_logic &, sc_proxy<T> &);
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base> concat(sc_proxy<T> &, bool);
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T> concat(bool, sc_proxy<T> &);
+
+
+// l-value concatenation operators and functions
+template <class T1, class T2>
+inline sc_concref<T1,sc_bitref<T2> > operator , (
+ sc_proxy<T1> &, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_subref<T2> > operator , (
+ sc_proxy<T1> &, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<T1, sc_concref<T2, T3> > operator , (
+ sc_proxy<T1> &, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<T1, T2> operator , (sc_proxy<T1> &, sc_proxy<T2> &);
+
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_bitref<T2> > concat(sc_proxy<T1> &, sc_bitref<T2>);
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_subref<T2> > concat(sc_proxy<T1> &, sc_subref<T2>);
+
+template <class T1, class T2, class T3>
+inline sc_concref<T1, sc_concref<T2, T3> > concat(
+ sc_proxy<T1> &, sc_concref<T2, T3>);
+
+template <class T1, class T2>
+inline sc_concref<T1, T2> concat(sc_proxy<T1> &, sc_proxy<T2> &);
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref_r<T>
+//
+// Proxy class for sc_proxy bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// bitwise operators and functions
+
+// bitwise and
+template <class T1, class T2>
+inline sc_logic
+operator & (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
+{
+ return sc_logic(sc_logic::and_table[a.value()][b.value()]);
+}
+
+// bitwise or
+template <class T1, class T2>
+inline sc_logic
+operator | (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
+{
+ return sc_logic(sc_logic::or_table[a.value()][b.value()]);
+}
+
+// bitwise xor
+template <class T1, class T2>
+inline sc_logic
+operator ^ (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
+{
+ return sc_logic(sc_logic::xor_table[a.value()][b.value()]);
+}
+
+// relational operators and functions
+template <class T1, class T2>
+inline bool
+operator == (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
+{
+ return ((int)a.value() == b.value());
+}
+
+template <class T1, class T2>
+inline bool
+operator != (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
+{
+ return ((int)a.value() != b.value());
+}
+
+// common methods
+template <class T>
+inline typename sc_bitref_r<T>::value_type
+sc_bitref_r<T>::get_bit(int n) const
+{
+ if (n == 0) {
+ return m_obj.get_bit(m_index);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ return Log_0;
+ }
+}
+
+template <class T>
+inline sc_digit
+sc_bitref_r<T>::get_word(int n) const
+{
+ if (n == 0) {
+ return (get_bit(n) & SC_DIGIT_ONE);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ return 0;
+ }
+}
+
+template <class T>
+inline sc_digit
+sc_bitref_r<T>::get_cword(int n) const
+{
+ if (n == 0) {
+ return ((get_bit(n) & SC_DIGIT_TWO) >> 1);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ return 0;
+ }
+}
+
+// r-value concatenation operators and functions
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_bitref_r<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+operator , (sc_bitref_r<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_bitref_r<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+operator , (sc_bitref_r<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline
+sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+concat(sc_bitref_r<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+concat(sc_bitref_r<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_bitref_r<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+concat(sc_bitref_r<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_bitref_r<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_bitref<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+operator , (sc_bitref_r<T1> a, sc_subref<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+operator , (sc_bitref<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_bitref_r<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_bitref<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+operator , (sc_bitref<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+operator , (sc_bitref_r<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+concat(sc_bitref_r<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
+concat(sc_bitref<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+concat(sc_bitref_r<T1> a, sc_subref<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
+concat(sc_bitref<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_bitref_r<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_bitref<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+concat(sc_bitref<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bitref_r<T1>, T2>
+concat(sc_bitref_r<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_bitref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref<X>
+//
+// Proxy class for sc_proxy bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator = (const sc_bitref_r<X> &a)
+{
+ this->m_obj.set_bit(this->m_index, a.value());
+ return *this;
+}
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator = (const sc_bitref<X> &a)
+{
+ if (&a != this) {
+ this->m_obj.set_bit(this->m_index, a.value());
+ }
+ return *this;
+}
+
+
+// bitwise assignment operators
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator &= (const sc_bitref_r<X> &a)
+{
+ if (&a != this) {
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::and_table[this->value()][a.value()]);
+ }
+ return *this;
+}
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator &= (const sc_logic &a)
+{
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::and_table[this->value()][a.value()]);
+ return *this;
+}
+
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator |= (const sc_bitref_r<X> &a)
+{
+ if (&a != this) {
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::or_table[this->value()][a.value()]);
+ }
+ return *this;
+}
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator |= (const sc_logic &a)
+{
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::or_table[this->value()][a.value()]);
+ return *this;
+}
+
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator ^= (const sc_bitref_r<X> &a)
+{
+ if (&a != this) {
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::xor_table[this->value()][a.value()]);
+ }
+ return *this;
+}
+
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::operator ^= (const sc_logic &a)
+{
+ this->m_obj.set_bit(
+ this->m_index, sc_logic::xor_table[this->value()][a.value()]);
+ return *this;
+}
+
+// bitwise operators and functions
+
+// bitwise complement
+template <class X>
+inline sc_bitref<X> &
+sc_bitref<X>::b_not()
+{
+ this->m_obj.set_bit(this->m_index, sc_logic::not_table[this->value()]);
+ return *this;
+}
+
+// common methods
+template <class X>
+inline void
+sc_bitref<X>::set_bit(int n, value_type value)
+{
+ if (n == 0) {
+ this->m_obj.set_bit(this->m_index, value);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+}
+
+template <class X>
+inline void
+sc_bitref<X>::set_word(int n, sc_digit w)
+{
+ unsigned int bi = this->m_index % (8 * sizeof(sc_digit));
+ sc_digit temp;
+ unsigned int wi = this->m_index / (8 * sizeof(sc_digit));
+ if (n == 0) {
+ temp = this->m_obj.get_word(wi);
+ temp = (temp & ~(1 << bi)) | ((w & 1) << bi);
+ this->m_obj.set_word(wi, temp);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+}
+
+template <class X>
+inline void
+sc_bitref<X>::set_cword(int n, sc_digit w)
+{
+ unsigned int bi = this->m_index % (8 * sizeof(sc_digit));
+ sc_digit temp;
+ unsigned int wi = this->m_index / (8 * sizeof(sc_digit));
+ if (n == 0) {
+ temp = this->m_obj.get_cword(wi);
+ temp = (temp & ~(1 << bi)) | ((w & 1) << bi);
+ this->m_obj.set_cword(wi, temp);
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+}
+
+// other methods
+template <class X>
+inline void
+sc_bitref<X>::scan(::std::istream &is)
+{
+ char c;
+ is >> c;
+ *this = c;
+}
+
+// l-value concatenation operators and functions
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_bitref<T2> >
+operator , (sc_bitref<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_bitref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_subref<T2> >
+operator , (sc_bitref<T1> a, sc_subref<T2> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_subref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >
+operator , (sc_bitref<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, T2>
+operator , (sc_bitref<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref<sc_bitref<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_bitref<T2> >
+concat(sc_bitref<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_bitref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, sc_subref<T2> >
+concat(sc_bitref<T1> a, sc_subref<T2> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_subref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >
+concat(sc_bitref<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref<sc_bitref<T1>, sc_concref<T2,T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_bitref<T1>, T2>
+concat(sc_bitref<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref<sc_bitref<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+template <class X>
+inline ::std::istream &
+operator >> (::std::istream &is, sc_bitref<X> a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref_r<X>
+//
+// Proxy class for sc_proxy part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+template <class X>
+inline void
+sc_subref_r<X>::check_bounds()
+{
+ int len = m_obj.length();
+ if (m_hi < 0 || m_hi >= len || m_lo < 0 || m_lo >= len) {
+ SC_REPORT_ERROR("out of bounds", 0);
+ sc_core::sc_abort(); // can't recover from here
+ }
+ if (reversed()) {
+ m_len = m_lo - m_hi + 1;
+ } else {
+ m_len = m_hi - m_lo + 1;
+ }
+}
+
+// common methods
+template <class X>
+inline typename sc_subref_r<X>::value_type
+sc_subref_r<X>::get_bit(int n) const
+{
+ if (reversed()) {
+ return m_obj.get_bit(m_lo - n);
+ } else {
+ return m_obj.get_bit(m_lo + n);
+ }
+}
+
+template <class X>
+inline void
+sc_subref_r<X>::set_bit(int n, value_type value)
+{
+ if (reversed()) {
+ m_obj.set_bit(m_lo - n, value);
+ } else {
+ m_obj.set_bit(m_lo + n, value);
+ }
+}
+
+template <class X>
+inline sc_digit
+sc_subref_r<X>::get_word(int i) const
+{
+ int n1 = 0;
+ int n2 = 0;
+ sc_digit result = 0;
+ int k = 0;
+ if (reversed()) {
+ n1 = m_lo - i * SC_DIGIT_SIZE;
+ n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
+ for (int n = n1; n > n2; n--) {
+ result |= (m_obj[n].value() & SC_DIGIT_ONE) << k++;
+ }
+ } else {
+ n1 = m_lo + i * SC_DIGIT_SIZE;
+ n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
+ for (int n = n1; n < n2; n++) {
+ result |= (m_obj[n].value() & SC_DIGIT_ONE) << k++;
+ }
+ }
+ return result;
+}
+
+template <class X>
+inline void
+sc_subref_r<X>::set_word(int i, sc_digit w)
+{
+ int n1 = 0;
+ int n2 = 0;
+ int k = 0;
+ if (reversed()) {
+ n1 = m_lo - i * SC_DIGIT_SIZE;
+ n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
+ for (int n = n1; n > n2; n--) {
+ m_obj.set_bit(n, value_type(
+ ((w >> k++) & SC_DIGIT_ONE) |
+ (m_obj[n].value() & SC_DIGIT_TWO)));
+ }
+ } else {
+ n1 = m_lo + i * SC_DIGIT_SIZE;
+ n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
+ for (int n = n1; n < n2; n++) {
+ m_obj.set_bit(n, value_type(
+ ((w >> k++) & SC_DIGIT_ONE) |
+ (m_obj[n].value() & SC_DIGIT_TWO)));
+ }
+ }
+}
+
+
+template <class X>
+inline sc_digit
+sc_subref_r<X>::get_cword(int i) const
+{
+ int n1 = 0;
+ int n2 = 0;
+ sc_digit result = 0;
+ int k = 0;
+ if (reversed()) {
+ n1 = m_lo - i * SC_DIGIT_SIZE;
+ n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
+ for (int n = n1; n > n2; n--) {
+ result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k++;
+ }
+ } else {
+ n1 = m_lo + i * SC_DIGIT_SIZE;
+ n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
+ for (int n = n1; n < n2; n++) {
+ result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k++;
+ }
+ }
+ return result;
+}
+
+template <class X>
+inline void
+sc_subref_r<X>::set_cword(int i, sc_digit w)
+{
+ int n1 = 0;
+ int n2 = 0;
+ int k = 0;
+ if (reversed()) {
+ n1 = m_lo - i * SC_DIGIT_SIZE;
+ n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
+ for (int n = n1; n > n2; n--) {
+ m_obj.set_bit(n, value_type(
+ (((w >> k++) & SC_DIGIT_ONE) << 1) |
+ (m_obj[n].value() & SC_DIGIT_ONE)));
+ }
+ } else {
+ n1 = m_lo + i * SC_DIGIT_SIZE;
+ n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
+ for (int n = n1; n < n2; n++) {
+ m_obj.set_bit(n, value_type(
+ (((w >> k++) & SC_DIGIT_ONE) << 1) |
+ (m_obj[n].value() & SC_DIGIT_ONE)));
+ }
+ }
+}
+
+// other methods
+template <class X>
+inline bool
+sc_subref_r<X>::is_01() const
+{
+ int sz = size();
+ for (int i = 0; i < sz; ++i) {
+ if (get_cword(i) != SC_DIGIT_ZERO) {
+ return false;
+ }
+ }
+ return true;
+}
+
+// r-value concatenation operators and functions
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_subref_r<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+operator , (sc_subref_r<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_subref_r<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+operator , (sc_subref_r<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+concat(sc_subref_r<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+concat(sc_subref_r<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_subref_r<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+concat(sc_subref_r<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_subref_r<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+operator , (sc_subref<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+operator , (sc_subref_r<T1> a, sc_subref<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+operator , (sc_subref<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline
+sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_subref_r<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+operator , (sc_subref<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+operator , (sc_subref<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+operator , (sc_subref_r<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+concat(sc_subref_r<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
+concat(sc_subref<T1> a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+concat(sc_subref_r<T1> a, sc_subref<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
+concat(sc_subref<T1> a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_subref_r<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
+concat(sc_subref<T1> a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+concat(sc_subref<T1> a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_subref_r<T1>, T2>
+concat(sc_subref_r<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref<X>
+//
+// Proxy class for sc_proxy part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+// sc_subref<X>::operator = ( const sc_subref_r<X>& ) in sc_lv_base.h
+// sc_subref<X>::operator = ( const sc_subref<X>& ) in sc_lv_base.h
+
+// other methods
+template <class T>
+inline void
+sc_subref<T>::scan(::std::istream &is)
+{
+ std::string s;
+ is >> s;
+ *this = s.c_str();
+}
+
+// l-value concatenation operators and functions
+template <class T1, class T2>
+inline
+sc_concref<sc_subref<T1>, sc_bitref<T2> >
+operator , (sc_subref<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref<sc_subref<T1>, sc_bitref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_subref<T2> >
+operator , (sc_subref<T1> a, sc_subref<T2> b)
+{
+ return sc_concref<sc_subref<T1>, sc_subref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_subref<T1>, sc_concref<T2,T3> >
+operator , (sc_subref<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref<sc_subref<T1>, sc_concref<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, T2>
+operator , (sc_subref<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref<sc_subref<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_bitref<T2> >
+concat(sc_subref<T1> a, sc_bitref<T2> b)
+{
+ return sc_concref<sc_subref<T1>, sc_bitref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, sc_subref<T2> >
+concat(sc_subref<T1> a, sc_subref<T2> b)
+{
+ return sc_concref<sc_subref<T1>, sc_subref<T2> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_subref<T1>, sc_concref<T2, T3> >
+concat(sc_subref<T1> a, sc_concref<T2, T3> b)
+{
+ return sc_concref<sc_subref<T1>, sc_concref<T2, T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref<sc_subref<T1>, T2>
+concat(sc_subref<T1> a, sc_proxy<T2> &b)
+{
+ return sc_concref<sc_subref<T1>, T2>(*a.clone(), b.back_cast(), 1);
+}
+
+template <class X>
+inline ::std::istream &
+operator >> (::std::istream &is, sc_subref<X> a)
+{
+ a.scan(is);
+ return is;
+}
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concref_r<X,Y>
+//
+// Proxy class for sc_proxy concatenation (r-value only).
+// ----------------------------------------------------------------------------
+
+// destructor
+template <class X, class Y>
+inline sc_concref_r<X, Y>::~sc_concref_r()
+{
+ if (--m_refs == 0) {
+ delete &m_refs;
+ if (m_delete == 0) {
+ return;
+ }
+ if (m_delete & 1) {
+ delete &m_left;
+ }
+ if (m_delete & 2) {
+ delete &m_right;
+ }
+ }
+}
+
+// common methods
+template <class X, class Y>
+inline typename sc_concref_r<X, Y>::value_type
+sc_concref_r<X, Y>::get_bit(int n) const
+{
+ int r_len = m_right.length();
+ if (n < r_len) {
+ return value_type(m_right.get_bit(n));
+ } else if (n < r_len + m_left.length()) {
+ return value_type(m_left.get_bit(n - r_len));
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ return Log_0;
+ }
+}
+
+template <class X, class Y>
+inline void
+sc_concref_r<X, Y>::set_bit(int n, value_type v)
+{
+ int r_len = m_right.length();
+ if (n < r_len) {
+ m_right.set_bit(n, typename Y::value_type(v));
+ } else if (n < r_len + m_left.length()) {
+ m_left.set_bit(n - r_len, typename X::value_type(v));
+ } else {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+}
+
+template <class X, class Y>
+inline sc_digit
+sc_concref_r<X, Y>::get_word(int i) const
+{
+ if (i < 0 || i >= size()) {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+ // 0 <= i < size()
+ Y &r = m_right;
+ int r_len = r.length();
+ int border = r_len / SC_DIGIT_SIZE;
+ if (i < border) {
+ return r.get_word(i);
+ }
+ // border <= i < size()
+ X& l = m_left;
+ int shift = r_len % SC_DIGIT_SIZE;
+ int j = i - border;
+ if (shift == 0) {
+ return l.get_word(j);
+ }
+ // border <= i < size() && shift != 0
+ int nshift = SC_DIGIT_SIZE - shift;
+ if (i == border) {
+ sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
+ return ((r.get_word(i) & rl_mask) | (l.get_word(0) << shift));
+ }
+ // border < i < size() && shift != 0
+ if (j < l.size())
+ return ((l.get_word(j - 1) >> nshift) | (l.get_word(j) << shift));
+ else
+ return (l.get_word(j - 1) >> nshift);
+}
+
+template <class X, class Y>
+inline void
+sc_concref_r<X, Y>::set_word(int i, sc_digit w)
+{
+ if (i < 0 || i >= size()) {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+ // 0 <= i < size()
+ Y &r = m_right;
+ int r_len = r.length();
+ int border = r_len / SC_DIGIT_SIZE;
+ if (i < border) {
+ r.set_word(i, w);
+ return;
+ }
+ // border <= i < size()
+ X &l = m_left;
+ int shift = r_len % SC_DIGIT_SIZE;
+ int j = i - border;
+ if (shift == 0) {
+ l.set_word(j, w);
+ return;
+ }
+ // border <= i < size() && shift != 0
+ int nshift = SC_DIGIT_SIZE - shift;
+ sc_digit lh_mask = ~SC_DIGIT_ZERO << nshift;
+ if (i == border) {
+ sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
+ r.set_word(i, w & rl_mask);
+ l.set_word(0, (l.get_word(0) & lh_mask) | (w >> shift));
+ return;
+ }
+ // border < i < size() && shift != 0
+ sc_digit ll_mask = ~SC_DIGIT_ZERO >> shift;
+ l.set_word(j - 1, (l.get_word(j - 1) & ll_mask) | (w << nshift));
+ if (j < l.size())
+ l.set_word(j, (l.get_word(j) & lh_mask) | (w >> shift));
+}
+
+template <class X, class Y>
+inline sc_digit
+sc_concref_r<X, Y>::get_cword(int i) const
+{
+ if (i < 0 || i >= size()) {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+ // 0 <= i < size()
+ Y &r = m_right;
+ int r_len = r.length();
+ int border = r_len / SC_DIGIT_SIZE;
+ if (i < border) {
+ return r.get_cword(i);
+ }
+ // border <= i < size()
+ X &l = m_left;
+ int shift = r_len % SC_DIGIT_SIZE;
+ int j = i - border;
+ if (shift == 0) {
+ return l.get_cword(j);
+ }
+ // border <= i < size() && shift != 0
+ int nshift = SC_DIGIT_SIZE - shift;
+ if (i == border) {
+ sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
+ return ((r.get_cword(i) & rl_mask) | (l.get_cword(0) << shift));
+ }
+ // border < i < size() && shift != 0
+ if (j < l.size())
+ return ((l.get_cword(j - 1) >> nshift) | (l.get_cword(j) << shift));
+ else
+ return (l.get_cword( j - 1 ) >> nshift);
+}
+
+template <class X, class Y>
+inline void
+sc_concref_r<X, Y>::set_cword(int i, sc_digit w)
+{
+ if (i < 0 || i >= size()) {
+ SC_REPORT_ERROR("out of bounds", 0);
+ }
+ // 0 <= i < size()
+ Y &r = m_right;
+ int r_len = r.length();
+ int border = r_len / SC_DIGIT_SIZE;
+ if (i < border) {
+ r.set_cword(i, w);
+ return;
+ }
+ // border <= i < size()
+ X &l = m_left;
+ int shift = r_len % SC_DIGIT_SIZE;
+ int j = i - border;
+ if (shift == 0) {
+ l.set_cword(j, w);
+ return;
+ }
+ // border <= i < size() && shift != 0
+ int nshift = SC_DIGIT_SIZE - shift;
+ sc_digit lh_mask = ~SC_DIGIT_ZERO << nshift;
+ if (i == border) {
+ sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
+ r.set_cword(i, w & rl_mask);
+ l.set_cword(0, (l.get_cword(0) & lh_mask) | (w >> shift));
+ return;
+ }
+ // border < i < size() && shift != 0
+ sc_digit ll_mask = ~SC_DIGIT_ZERO >> shift;
+ l.set_cword(j - 1, (l.get_cword(j - 1) & ll_mask) | (w << nshift));
+ if (j < l.size())
+ l.set_cword(j, (l.get_cword(j) & lh_mask) | (w >> shift));
+}
+
+// r-value concatenation operators and functions
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> >
+operator , (sc_concref_r<T1, T2> a, sc_bitref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+operator , (sc_concref_r<T1, T2> a, sc_subref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+operator , (sc_concref_r<T1, T2> a, sc_concref_r<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>,sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+operator , (sc_concref_r<T1, T2> a, const sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
+concat(sc_concref_r<T1, T2> a, sc_bitref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+concat(sc_concref_r<T1, T2> a, sc_subref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+concat(sc_concref_r<T1, T2> a, sc_concref_r<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+concat(sc_concref_r<T1, T2> a, const sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
+operator , (sc_concref_r<T1, T2> a, sc_bitref<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
+operator , (sc_concref<T1, T2> a, sc_bitref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline
+sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+operator , (sc_concref_r<T1, T2> a, sc_subref<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+operator , (sc_concref<T1, T2> a, sc_subref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+operator , (sc_concref_r<T1, T2> a, sc_concref<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+operator , (sc_concref<T1, T2> a, sc_concref_r<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+operator , (sc_concref<T1, T2> a, const sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+operator , (sc_concref_r<T1, T2> a, sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
+concat(sc_concref_r<T1, T2> a, sc_bitref<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
+concat(sc_concref<T1, T2> a, sc_bitref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+concat(sc_concref_r<T1, T2> a, sc_subref<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
+concat(sc_concref<T1, T2> a, sc_subref_r<T3> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+concat(sc_concref_r<T1, T2> a, sc_concref<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
+concat(sc_concref<T1, T2> a, sc_concref_r<T3, T4> b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+concat(sc_concref<T1, T2> a, const sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<sc_concref_r<T1, T2>, T3>
+concat(sc_concref_r<T1, T2> a, sc_proxy<T3> &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concref<X,Y>
+//
+// Proxy class for sc_proxy concatenation (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// other methods
+template <class T1, class T2>
+inline void
+sc_concref<T1, T2>::scan(::std::istream &is)
+{
+ std::string s;
+ is >> s;
+ *this = s.c_str();
+}
+
+// l-value concatenation operators and functions
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >
+operator , (sc_concref<T1, T2> a, sc_bitref<T3> b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_subref<T3> >
+operator , (sc_concref<T1, T2> a, sc_subref<T3>b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_subref<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >
+operator , (sc_concref<T1, T2> a, sc_concref<T3, T4> b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, T3>
+operator , (sc_concref<T1, T2> a, sc_proxy<T3> &b)
+{
+ return sc_concref<sc_concref<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >
+concat(sc_concref<T1, T2> a, sc_bitref<T3> b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, sc_subref<T3> >
+concat(sc_concref<T1, T2> a, sc_subref<T3> b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_subref<T3> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >
+concat(sc_concref<T1, T2> a, sc_concref<T3, T4> b)
+{
+ return sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >(
+ *a.clone(), *b.clone(), 3);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<sc_concref<T1, T2>, T3>
+concat(sc_concref<T1, T2> a, sc_proxy<T3> &b)
+{
+ return sc_concref<sc_concref<T1, T2>, T3>(
+ *a.clone(), b.back_cast(), 1);
+}
+
+template <class X, class Y>
+inline ::std::istream &
+operator >> (::std::istream &is, sc_concref<X, Y> a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy<T>
+//
+// Base class template for bit/logic vector classes.
+// (Barton/Nackmann implementation)
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+operator , (const sc_proxy<T1> &a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+operator , (const sc_proxy<T1> &a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+operator , (const sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+operator , (const sc_proxy<T1> &a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+concat(const sc_proxy<T1> &a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+concat(const sc_proxy<T1> &a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+concat(const sc_proxy<T1> &a, sc_concref_r<T2, T3> b )
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+concat(const sc_proxy<T1> &a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+operator , (const sc_proxy<T1> &a, sc_bitref<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+operator , (sc_proxy<T1> &a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+operator , (const sc_proxy<T1> &a, sc_subref<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+operator , (sc_proxy<T1> &a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+operator , (const sc_proxy<T1> &a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+operator , (sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+operator , (const sc_proxy<T1> &a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+operator , (sc_proxy<T1> &a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+concat(const sc_proxy<T1> &a, sc_bitref<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_bitref_r<T2> >
+concat(sc_proxy<T1> &a, sc_bitref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+concat(const sc_proxy<T1> &a, sc_subref<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, sc_subref_r<T2> >
+concat(sc_proxy<T1> &a, sc_subref_r<T2> b)
+{
+ return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+concat(const sc_proxy<T1> &a, sc_concref<T2, T3> b)
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref_r<T1, sc_concref_r<T2, T3> >
+concat(sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
+{
+ return sc_concref_r<T1, sc_concref_r<T2, T3> >(
+ a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+concat(const sc_proxy<T1> &a, sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+template <class T1, class T2>
+inline sc_concref_r<T1, T2>
+concat(sc_proxy<T1> &a, const sc_proxy<T2> &b)
+{
+ return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+
+// l-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_bitref<T2> >
+operator , (sc_proxy<T1> &a, sc_bitref<T2> b)
+{
+ return sc_concref<T1, sc_bitref<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_subref<T2> >
+operator , (sc_proxy<T1> &a, sc_subref<T2> b)
+{
+ return sc_concref<T1, sc_subref<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<T1, sc_concref<T2, T3> >
+operator , (sc_proxy<T1> &a, sc_concref<T2, T3> b)
+{
+ return sc_concref<T1, sc_concref<T2, T3> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref<T1, T2>
+operator , (sc_proxy<T1> &a, sc_proxy<T2> &b)
+{
+ return sc_concref<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_bitref<T2> >
+concat(sc_proxy<T1> &a, sc_bitref<T2> b)
+{
+ return sc_concref<T1, sc_bitref<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref<T1, sc_subref<T2> >
+concat(sc_proxy<T1> &a, sc_subref<T2> b)
+{
+ return sc_concref<T1, sc_subref<T2> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2, class T3>
+inline sc_concref<T1, sc_concref<T2, T3> >
+concat(sc_proxy<T1> &a, sc_concref<T2, T3> b)
+{
+ return sc_concref<T1, sc_concref<T2, T3> >(a.back_cast(), *b.clone(), 2);
+}
+
+template <class T1, class T2>
+inline sc_concref<T1, T2>
+concat(sc_proxy<T1> &a, sc_proxy<T2> &b)
+{
+ return sc_concref<T1, T2>(a.back_cast(), b.back_cast());
+}
+
+} // namespace sc_dt
+
+// $Log: sc_bit_proxies.h,v $
+// Revision 1.10 2011/09/05 21:19:53 acg
+// Philipp A. Hartmann: added parentheses to expressions to eliminate
+// compiler warnings.
+//
+// Revision 1.9 2011/09/01 15:03:42 acg
+// Philipp A. Hartmann: add parentheses to eliminate compiler warnings.
+//
+// Revision 1.8 2011/08/29 18:04:32 acg
+// Philipp A. Hartmann: miscellaneous clean ups.
+//
+// Revision 1.7 2011/08/24 22:05:40 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.6 2010/02/22 14:25:43 acg
+// Andy Goodrich: removed 'mutable' directive from references, since it
+// is not a legal C++ construct.
+//
+// Revision 1.5 2009/02/28 00:26:14 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.4 2007/03/14 17:48:37 acg
+// Andy Goodrich: fixed bug.
+//
+// Revision 1.3 2007/01/18 19:29:18 acg
+// Andy Goodrich: fixed bug in concatenations of bit selects on sc_lv and
+// sc_bv types. The offending code was in sc_bitref<X>::set_word and
+// sc_bitref<X>::get_word. These methods were not writing the bit they
+// represented, but rather writing an entire word whose index was the
+// index of the bit they represented. This not only did not write the
+// correct bit, but clobbered a word that might not even be in the
+// variable the reference was for.
+//
+// Revision 1.2 2007/01/17 22:45:08 acg
+// Andy Goodrich: fixed sc_bitref<X>::set_bit().
+//
+// Revision 1.1.1.1 2006/12/15 20:31:36 acg
+// SystemC 2.2
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
diff --git a/src/systemc/ext/dt/bit/sc_bv.hh b/src/systemc/ext/dt/bit/sc_bv.hh
new file mode 100644
index 000000000..8b48b0984
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_bv.hh
@@ -0,0 +1,208 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_bv.h -- Arbitrary size bit vector class.
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_bv.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_BV_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_BV_HH__
+
+#include "sc_bv_base.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_bv;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bv<W>
+//
+// Arbitrary size bit vector class.
+// ----------------------------------------------------------------------------
+
+template <int W>
+class sc_bv : public sc_bv_base
+{
+ public:
+ // constructors
+ sc_bv() :sc_bv_base(W) {}
+
+ explicit sc_bv(bool init_value) : sc_bv_base(init_value, W) {}
+
+ explicit sc_bv(char init_value) : sc_bv_base((init_value != '0'), W) {}
+
+ sc_bv(const char *a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const bool *a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const sc_logic *a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const sc_unsigned &a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const sc_signed &a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const sc_uint_base &a) : sc_bv_base(W)
+ {
+ sc_bv_base::operator = (a);
+ }
+ sc_bv(const sc_int_base &a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(unsigned long a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(long a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(unsigned int a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(int a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(uint64 a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(int64 a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+
+ template <class X>
+ sc_bv(const sc_proxy<X> &a) : sc_bv_base(W) { sc_bv_base::operator = (a); }
+ sc_bv(const sc_bv<W> &a) : sc_bv_base(a) {}
+
+ // assignment operators
+ template <class X>
+ sc_bv<W> &
+ operator = (const sc_proxy<X> &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_bv<W> &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const char *a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const bool *a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_logic *a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_unsigned &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_signed &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_uint_base &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (const sc_int_base &a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (unsigned long a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (long a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (unsigned int a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (int a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (uint64 a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+
+ sc_bv<W> &
+ operator = (int64 a)
+ {
+ sc_bv_base::operator = (a);
+ return *this;
+ }
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_BV_HH__
diff --git a/src/systemc/ext/dt/bit/sc_bv_base.hh b/src/systemc/ext/dt/bit/sc_bv_base.hh
new file mode 100644
index 000000000..8aac78d37
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_bv_base.hh
@@ -0,0 +1,282 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_bv_base.h -- Arbitrary size bit vector class.
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_bv_base.h,v $
+// Revision 1.3 2011/08/26 22:32:00 acg
+// Torsten Maehne: added parentheses to make opearator ordering more obvious.
+//
+// Revision 1.2 2011/08/15 16:43:24 acg
+// Torsten Maehne: changes to remove unused argument warnings.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_BV_BASE_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_BV_BASE_HH__
+
+#include "../int/sc_length_param.hh"
+#include "sc_bit_proxies.hh"
+#include "sc_proxy.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_bv_base;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_bv_base
+//
+// Arbitrary size bit vector base class.
+// ----------------------------------------------------------------------------
+
+class sc_bv_base : public sc_proxy<sc_bv_base>
+{
+ friend class sc_lv_base;
+
+ void init(int length_, bool init_value=false);
+ void assign_from_string(const std::string &);
+
+ public:
+ // typedefs
+ typedef sc_proxy<sc_bv_base> base_type;
+ typedef base_type::value_type value_type;
+
+ // constructors
+ explicit sc_bv_base(int length_=sc_length_param().len()) :
+ m_len(0), m_size(0), m_data(0)
+ {
+ init(length_);
+ }
+
+ explicit sc_bv_base(bool a, int length_=sc_length_param().len()) :
+ m_len(0), m_size(0), m_data(0)
+ {
+ init(length_, a);
+ }
+
+ sc_bv_base(const char *a);
+ sc_bv_base(const char *a, int length_);
+
+ template <class X>
+ sc_bv_base(const sc_proxy<X> &a) : m_len(0), m_size(0), m_data(0)
+ {
+ init(a.back_cast().length());
+ base_type::assign_(a);
+ }
+
+ sc_bv_base(const sc_bv_base &a);
+
+ // destructor
+ virtual ~sc_bv_base() { delete [] m_data; }
+
+ // assignment operators
+ template <class X>
+ sc_bv_base &
+ operator = (const sc_proxy<X> &a)
+ {
+ assign_p_(*this, a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_bv_base &a)
+ {
+ assign_p_(*this, a);
+ return *this;
+ }
+
+ sc_bv_base &operator = (const char *a);
+
+ sc_bv_base &
+ operator = (const bool *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_logic *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_unsigned &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_signed &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_uint_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (const sc_int_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (unsigned long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (unsigned int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (uint64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_bv_base &
+ operator = (int64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ // common methods
+ int length() const { return m_len; }
+ int size() const { return m_size; }
+
+ value_type get_bit(int i) const;
+ void set_bit(int i, value_type value);
+
+ sc_digit get_word(int i) const { return m_data[i]; }
+
+ void set_word(int i, sc_digit w) { m_data[i] = w; }
+
+ sc_digit get_cword(int /*i*/) const { return SC_DIGIT_ZERO; }
+
+ void set_cword(int i, sc_digit w);
+
+ void clean_tail();
+
+ // other methods
+ bool is_01() const { return true; }
+
+ protected:
+ int m_len; // length in bits
+ int m_size; // size of data array
+ sc_digit *m_data; // data array
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// common methods
+inline sc_bv_base::value_type
+sc_bv_base::get_bit(int i) const
+{
+ int wi = i / SC_DIGIT_SIZE;
+ int bi = i % SC_DIGIT_SIZE;
+ return value_type((m_data[wi] >> bi) & SC_DIGIT_ONE);
+}
+
+inline void
+sc_bv_base::set_bit(int i, value_type value)
+{
+ int wi = i / SC_DIGIT_SIZE;
+ int bi = i % SC_DIGIT_SIZE;
+ sc_digit mask = SC_DIGIT_ONE << bi;
+ m_data[wi] |= mask; // set bit to 1
+ m_data[wi] &= value << bi | ~mask;
+}
+
+inline void
+sc_bv_base::set_cword(int /*i*/, sc_digit w)
+{
+ if (w) {
+ SC_REPORT_WARNING("sc_bv cannot contain values X and Z", 0);
+ }
+}
+
+inline void
+sc_bv_base::clean_tail()
+{
+ int wi = m_size - 1;
+ int bi = m_len % SC_DIGIT_SIZE;
+ if (bi != 0)
+ m_data[wi] &= ~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - bi);
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_BV_BASE_HH__
diff --git a/src/systemc/ext/dt/bit/sc_logic.hh b/src/systemc/ext/dt/bit/sc_logic.hh
new file mode 100644
index 000000000..184e763b5
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_logic.hh
@@ -0,0 +1,381 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_logic.h -- C++ implementation of logic type. Behaves
+ pretty much the same way as HDLs except with 4 values.
+
+ Original Author: Stan Y. Liao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_logic.h,v $
+// Revision 1.3 2011/08/07 18:54:19 acg
+// Philipp A. Hartmann: remove friend function declarations that implement
+// code, and clean up how bit and logic operators are defined in general.
+//
+// Revision 1.2 2011/01/25 20:50:37 acg
+// Andy Goodrich: changes for IEEE 1666 2011.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.5 2006/12/02 21:00:57 acg
+// Andy Goodrich: fixes for concatenation support.
+//
+// Revision 1.4 2006/05/08 17:49:59 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_LOGIC_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_LOGIC_HH__
+
+#include <cstdio>
+#include <iostream>
+
+#include "../sc_mempool.hh"
+#include "sc_bit.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_logic;
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_logic_value_t
+//
+// Enumeration of values for sc_logic.
+// ----------------------------------------------------------------------------
+
+enum sc_logic_value_t
+{
+ Log_0 = 0,
+ Log_1,
+ Log_Z,
+ Log_X
+};
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_logic
+//
+// Four-valued logic type.
+// ----------------------------------------------------------------------------
+
+class sc_logic
+{
+ private:
+ // support methods
+ static void invalid_value(sc_logic_value_t);
+ static void invalid_value(char);
+ static void invalid_value(int);
+
+ static sc_logic_value_t
+ to_value(sc_logic_value_t v)
+ {
+ if (v < Log_0 || v > Log_X) {
+ invalid_value(v);
+ // may continue, if suppressed
+ v = Log_X;
+ }
+ return v;
+ }
+
+ static sc_logic_value_t to_value(bool b) { return (b ? Log_1 : Log_0); }
+
+ static sc_logic_value_t
+ to_value(char c)
+ {
+ unsigned int index = (int)c;
+ if (index > 127) {
+ invalid_value(c);
+ // may continue, if suppressed
+ index = 127; // aka Log_X
+ }
+ return char_to_logic[index];
+ }
+
+ static sc_logic_value_t
+ to_value(int i)
+ {
+ if (i < Log_0 || i > Log_X) {
+ invalid_value(i);
+ // may continue, if suppressed
+ i = Log_X;
+ }
+ return sc_logic_value_t(i);
+ }
+
+ void invalid_01() const;
+
+ public:
+ // conversion tables
+ static const sc_logic_value_t char_to_logic[128];
+ static const char logic_to_char[4];
+ static const sc_logic_value_t and_table[4][4];
+ static const sc_logic_value_t or_table[4][4];
+ static const sc_logic_value_t xor_table[4][4];
+ static const sc_logic_value_t not_table[4];
+
+ // constructors
+ sc_logic() : m_val(Log_X) {}
+ sc_logic(const sc_logic &a) : m_val(a.m_val) {}
+ sc_logic(sc_logic_value_t v) : m_val(to_value(v)) {}
+ explicit sc_logic(bool a) : m_val(to_value(a)) {}
+ explicit sc_logic(char a) : m_val(to_value(a)) {}
+ explicit sc_logic(int a) : m_val(to_value(a)) {}
+ explicit sc_logic(const sc_bit &a) : m_val(to_value(a.to_bool())) {}
+
+ // destructor
+ ~sc_logic() {}
+
+ // (bitwise) assignment operators
+#define DEFN_ASN_OP_T(op,tp) \
+ sc_logic & \
+ operator op (tp v) \
+ { \
+ *this op sc_logic(v); \
+ return *this; \
+ }
+
+#define DEFN_ASN_OP(op) \
+ DEFN_ASN_OP_T(op, sc_logic_value_t) \
+ DEFN_ASN_OP_T(op, bool) \
+ DEFN_ASN_OP_T(op, char) \
+ DEFN_ASN_OP_T(op, int) \
+ DEFN_ASN_OP_T(op, const sc_bit &)
+
+ sc_logic &
+ operator = (const sc_logic &a)
+ {
+ m_val = a.m_val;
+ return *this;
+ }
+
+ sc_logic &
+ operator &= (const sc_logic &b)
+ {
+ m_val = and_table[m_val][b.m_val];
+ return *this;
+ }
+
+ sc_logic &
+ operator |= (const sc_logic &b)
+ {
+ m_val = or_table[m_val][b.m_val];
+ return *this;
+ }
+
+ sc_logic &
+ operator ^= (const sc_logic &b)
+ {
+ m_val = xor_table[m_val][b.m_val];
+ return *this;
+ }
+
+ DEFN_ASN_OP(=)
+ DEFN_ASN_OP(&=)
+ DEFN_ASN_OP(|=)
+ DEFN_ASN_OP(^=)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+ // bitwise operators and functions
+ friend const sc_logic operator & (const sc_logic &, const sc_logic &);
+ friend const sc_logic operator | (const sc_logic &, const sc_logic &);
+ friend const sc_logic operator ^ (const sc_logic &, const sc_logic &);
+
+ // relational operators
+ friend bool operator == (const sc_logic &, const sc_logic &);
+ friend bool operator != (const sc_logic &, const sc_logic &);
+
+ // bitwise complement
+ const sc_logic operator ~ () const { return sc_logic(not_table[m_val]); }
+ sc_logic &
+ b_not()
+ {
+ m_val = not_table[m_val];
+ return *this;
+ }
+
+ // explicit conversions
+ sc_logic_value_t value() const { return m_val; }
+
+ bool is_01() const { return ((int)m_val == Log_0 || (int)m_val == Log_1); }
+ bool
+ to_bool() const
+ {
+ if (!is_01()) {
+ invalid_01();
+ }
+ return ((int)m_val != Log_0);
+ }
+
+ char to_char() const { return logic_to_char[m_val]; }
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_char(); }
+ void scan(::std::istream &is=::std::cin);
+
+ // memory (de)allocation
+ // placement new
+ static void *operator new (std::size_t, void *p) { return p; }
+ static void *
+ operator new (std::size_t sz)
+ {
+ return sc_core::sc_mempool::allocate(sz);
+ }
+ static void
+ operator delete (void *p, std::size_t sz)
+ {
+ sc_core::sc_mempool::release(p, sz);
+ }
+ static void *
+ operator new [] (std::size_t sz)
+ {
+ return sc_core::sc_mempool::allocate(sz);
+ }
+ static void
+ operator delete [] (void *p, std::size_t sz)
+ {
+ sc_core::sc_mempool::release(p, sz);
+ }
+
+ private:
+ sc_logic_value_t m_val;
+
+ private:
+ // Disabled
+ explicit sc_logic(const char *);
+ sc_logic &operator = (const char *);
+};
+
+// ----------------------------------------------------------------------------
+
+// bitwise operators
+inline const sc_logic
+operator & (const sc_logic &a, const sc_logic &b)
+{
+ return sc_logic(sc_logic::and_table[a.m_val][b.m_val]);
+}
+
+inline const sc_logic
+operator | (const sc_logic &a, const sc_logic &b)
+{
+ return sc_logic(sc_logic::or_table[a.m_val][b.m_val]);
+}
+
+inline const sc_logic
+operator ^ (const sc_logic &a, const sc_logic &b)
+{
+ return sc_logic(sc_logic::xor_table[a.m_val][b.m_val]);
+}
+
+#define DEFN_BIN_OP_T(ret,op,tp) \
+ inline ret \
+ operator op (const sc_logic &a, tp b) \
+ { \
+ return (a op sc_logic(b)); \
+ } \
+ inline ret \
+ operator op (tp a, const sc_logic &b) \
+ { \
+ return (sc_logic(a) op b); \
+ }
+
+#define DEFN_BIN_OP(ret, op) \
+ DEFN_BIN_OP_T(ret, op, sc_logic_value_t) \
+ DEFN_BIN_OP_T(ret, op, bool) \
+ DEFN_BIN_OP_T(ret, op, char) \
+ DEFN_BIN_OP_T(ret, op, int)
+
+DEFN_BIN_OP(const sc_logic, &)
+DEFN_BIN_OP(const sc_logic, |)
+DEFN_BIN_OP(const sc_logic, ^)
+
+// relational operators and functions
+
+inline bool
+operator == (const sc_logic &a, const sc_logic &b)
+{
+ return ((int)a.m_val == b.m_val);
+}
+
+inline bool
+operator != (const sc_logic &a, const sc_logic &b)
+{
+ return ((int)a.m_val != b.m_val);
+}
+
+DEFN_BIN_OP(bool, ==)
+DEFN_BIN_OP(bool, !=)
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP
+
+// ----------------------------------------------------------------------------
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_logic &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_logic &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+extern const sc_logic SC_LOGIC_0;
+extern const sc_logic SC_LOGIC_1;
+extern const sc_logic SC_LOGIC_Z;
+extern const sc_logic SC_LOGIC_X;
+
+// #ifdef SC_DT_DEPRECATED
+extern const sc_logic sc_logic_0;
+extern const sc_logic sc_logic_1;
+extern const sc_logic sc_logic_Z;
+extern const sc_logic sc_logic_X;
+// #endif
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_LOGIC_HH__
diff --git a/src/systemc/ext/dt/bit/sc_lv.hh b/src/systemc/ext/dt/bit/sc_lv.hh
new file mode 100644
index 000000000..cab58df25
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_lv.hh
@@ -0,0 +1,205 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_lv.h -- Arbitrary size logic vector class.
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_lv.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_LV_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_LV_HH__
+
+#include "sc_lv_base.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_lv;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_lv<W>
+//
+// Arbitrary size logic vector class.
+// ----------------------------------------------------------------------------
+
+template <int W>
+class sc_lv : public sc_lv_base
+{
+ public:
+ // constructors
+ sc_lv() : sc_lv_base(W) {}
+ explicit sc_lv(const sc_logic &init_value) : sc_lv_base(init_value, W) {}
+ explicit sc_lv(bool init_value) : sc_lv_base(sc_logic(init_value), W) {}
+ explicit sc_lv(char init_value) : sc_lv_base(sc_logic(init_value), W) {}
+ sc_lv(const char *a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const bool *a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const sc_logic *a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const sc_unsigned &a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const sc_signed &a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const sc_uint_base &a) : sc_lv_base(W)
+ {
+ sc_lv_base::operator = (a);
+ }
+ sc_lv(const sc_int_base &a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(unsigned long a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(long a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(unsigned int a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(int a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(uint64 a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(int64 a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ template <class X>
+ sc_lv(const sc_proxy<X> &a) : sc_lv_base(W) { sc_lv_base::operator = (a); }
+ sc_lv(const sc_lv<W> &a) : sc_lv_base(a) {}
+
+ // assignment operators
+ template <class X>
+ sc_lv<W> &
+ operator = (const sc_proxy<X> &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_lv<W> &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const char *a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const bool *a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_logic *a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_unsigned &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_signed &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_uint_base &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (const sc_int_base &a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (unsigned long a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (long a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (unsigned int a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (int a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (uint64 a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+
+ sc_lv<W> &
+ operator = (int64 a)
+ {
+ sc_lv_base::operator = (a);
+ return *this;
+ }
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_LV_HH__
diff --git a/src/systemc/ext/dt/bit/sc_lv_base.hh b/src/systemc/ext/dt/bit/sc_lv_base.hh
new file mode 100644
index 000000000..b7aa1a966
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_lv_base.hh
@@ -0,0 +1,1589 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_lv_base.h -- Arbitrary size logic vector class.
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+ Andy Goodrich, Forte Design Systems
+ Fixed bug in clean_tail for sizes that are modulo 32, which caused
+ zeroing of values.
+
+ *****************************************************************************/
+
+// $Log: sc_lv_base.h,v $
+// Revision 1.4 2011/08/26 22:32:00 acg
+// Torsten Maehne: added parentheses to make opearator ordering more obvious.
+//
+// Revision 1.3 2010/01/27 19:41:29 acg
+// Andy Goodrich: fix 8 instances of sc_concref constructor invocations
+// that failed to indicate that their arguments should be freed when the
+// object was freed.
+//
+// Revision 1.2 2009/02/28 00:26:14 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.2 2007/03/14 17:47:49 acg
+// Andy Goodrich: Formatting.
+//
+// Revision 1.1.1.1 2006/12/15 20:31:36 acg
+// SystemC 2.2
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_LV_BASE_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_LV_BASE_HH__
+
+#include "../int/sc_length_param.hh"
+#include "sc_bv_base.hh"
+#include "sc_logic.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_lv_base;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_lv_base
+//
+// Arbitrary size logic vector base class.
+// ----------------------------------------------------------------------------
+
+class sc_lv_base : public sc_proxy<sc_lv_base>
+{
+ friend class sc_bv_base;
+
+ void init(int length_, const sc_logic &init_value=SC_LOGIC_X);
+ void assign_from_string(const std::string &);
+
+ public:
+ // typedefs
+ typedef sc_proxy<sc_lv_base> base_type;
+ typedef base_type::value_type value_type;
+
+ // constructors
+ explicit sc_lv_base(int length_=sc_length_param().len()) :
+ m_len(0), m_size(0), m_data(0), m_ctrl(0)
+ {
+ init(length_);
+ }
+
+ explicit sc_lv_base(
+ const sc_logic &a, int length_=sc_length_param().len()) :
+ m_len(0), m_size(0), m_data(0), m_ctrl(0)
+ {
+ init(length_, a);
+ }
+
+ sc_lv_base(const char *a);
+ sc_lv_base(const char *a, int length_);
+
+ template <class X>
+ sc_lv_base(const sc_proxy<X> &a) :
+ m_len(0), m_size(0), m_data(0), m_ctrl(0)
+ {
+ init(a.back_cast().length());
+ base_type::assign_(a);
+ }
+
+ sc_lv_base(const sc_lv_base &a);
+
+ // destructor
+ virtual ~sc_lv_base() { delete [] m_data; }
+
+ // assignment operators
+ template <class X>
+ sc_lv_base &
+ operator = (const sc_proxy<X> &a)
+ {
+ assign_p_(*this, a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_lv_base &a)
+ {
+ assign_p_(*this, a);
+ return *this;
+ }
+
+ sc_lv_base &operator = (const char *a);
+
+ sc_lv_base &
+ operator = (const bool *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_logic *a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_unsigned &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_signed &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_uint_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (const sc_int_base &a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (unsigned long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (long a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (unsigned int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (int a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (uint64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ sc_lv_base &
+ operator = (int64 a)
+ {
+ base_type::assign_(a);
+ return *this;
+ }
+
+ // common methods
+ int length() const { return m_len; }
+ int size() const { return m_size; }
+
+ value_type get_bit(int i) const;
+ void set_bit(int i, value_type value);
+
+ sc_digit get_word(int wi) const { return m_data[wi]; }
+
+ // note the test for out of range access here. this is necessary
+ // because of the hair-brained way concatenations are set up.
+ // an extend_sign on a concatenation uses the whole length of
+ // the concatenation to determine how many words to set.
+ void
+ set_word(int wi, sc_digit w)
+ {
+ sc_assert(wi < m_size);
+ m_data[wi] = w;
+ }
+
+ sc_digit get_cword(int wi) const { return m_ctrl[wi]; }
+
+ void
+ set_cword(int wi, sc_digit w)
+ {
+ sc_assert(wi < m_size);
+ m_ctrl[wi] = w;
+ }
+ void clean_tail();
+
+ // other methods
+ bool is_01() const;
+
+ protected:
+ int m_len; // length in bits
+ int m_size; // size of the data array
+ sc_digit *m_data; // data array
+ sc_digit *m_ctrl; // dito (control part)
+};
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline sc_lv_base::value_type
+sc_lv_base::get_bit(int i) const
+{
+ int wi = i / SC_DIGIT_SIZE;
+ int bi = i % SC_DIGIT_SIZE;
+ return value_type(((m_data[wi] >> bi) & SC_DIGIT_ONE) |
+ (((m_ctrl[wi] >> bi) << 1) & SC_DIGIT_TWO));
+}
+
+inline void
+sc_lv_base::set_bit(int i, value_type value)
+{
+ int wi = i / SC_DIGIT_SIZE; // word index
+ int bi = i % SC_DIGIT_SIZE; // bit index
+ sc_digit mask = SC_DIGIT_ONE << bi;
+ m_data[wi] |= mask; // set bit to 1
+ m_ctrl[wi] |= mask; // set bit to 1
+ m_data[wi] &= value << bi | ~mask;
+ m_ctrl[wi] &= value >> 1 << bi | ~mask;
+}
+
+inline void
+sc_lv_base::clean_tail()
+{
+ int wi = m_size - 1;
+ int bi = m_len % SC_DIGIT_SIZE;
+ sc_digit mask = ~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - bi);
+ if (mask) {
+ m_data[wi] &= mask;
+ m_ctrl[wi] &= mask;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy
+//
+// Base class template for bit/logic vector classes.
+// (Barton/Nackmann implementation)
+// ----------------------------------------------------------------------------
+
+// bitwise operators and functions
+
+// bitwise complement
+template <class X>
+inline const sc_lv_base
+sc_proxy<X>::operator ~ () const
+{
+ sc_lv_base a(back_cast());
+ return a.b_not();
+}
+
+// bitwise and
+template <class X, class Y>
+inline X &
+operator &= (sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ X &x = px.back_cast();
+ sc_lv_base a(x.length());
+ a = py.back_cast();
+ return b_and_assign_(x, a);
+}
+
+#define DEFN_BITWISE_AND_ASN_OP_T(tp) \
+template <class X> \
+inline X & \
+sc_proxy<X>::operator &= (tp b) \
+{ \
+ X &x = back_cast(); \
+ sc_lv_base a(x.length()); \
+ a = b; \
+ return b_and_assign_(x, a); \
+}
+
+DEFN_BITWISE_AND_ASN_OP_T(const char *)
+DEFN_BITWISE_AND_ASN_OP_T(const bool *)
+DEFN_BITWISE_AND_ASN_OP_T(const sc_logic *)
+DEFN_BITWISE_AND_ASN_OP_T(const sc_unsigned &)
+DEFN_BITWISE_AND_ASN_OP_T(const sc_signed &)
+DEFN_BITWISE_AND_ASN_OP_T(unsigned long)
+DEFN_BITWISE_AND_ASN_OP_T(long)
+DEFN_BITWISE_AND_ASN_OP_T(uint64)
+DEFN_BITWISE_AND_ASN_OP_T(int64)
+
+#undef DEFN_BITWISE_AND_ASN_OP_T
+
+template <class X, class Y>
+inline const sc_lv_base
+operator & (const sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ sc_lv_base a(px.back_cast());
+ return (a &= py.back_cast());
+}
+
+#define DEFN_BITWISE_AND_OP_T_A(tp) \
+template <class X> \
+inline const sc_lv_base \
+sc_proxy<X>::operator & (tp b) const \
+{ \
+ sc_lv_base a(back_cast()); \
+ return (a &= b); \
+}
+
+DEFN_BITWISE_AND_OP_T_A(const char *)
+DEFN_BITWISE_AND_OP_T_A(const bool *)
+DEFN_BITWISE_AND_OP_T_A(const sc_logic *)
+DEFN_BITWISE_AND_OP_T_A(const sc_unsigned &)
+DEFN_BITWISE_AND_OP_T_A(const sc_signed &)
+DEFN_BITWISE_AND_OP_T_A(const sc_uint_base &)
+DEFN_BITWISE_AND_OP_T_A(const sc_int_base &)
+DEFN_BITWISE_AND_OP_T_A(unsigned long)
+DEFN_BITWISE_AND_OP_T_A(long)
+DEFN_BITWISE_AND_OP_T_A(unsigned int)
+DEFN_BITWISE_AND_OP_T_A(int)
+DEFN_BITWISE_AND_OP_T_A(uint64)
+DEFN_BITWISE_AND_OP_T_A(int64)
+
+#undef DEFN_BITWISE_AND_OP_T_A
+
+#define DEFN_BITWISE_AND_OP_T_B(tp) \
+template <class X> \
+inline const sc_lv_base \
+operator & (tp b, const sc_proxy<X> &px) \
+{ \
+ return (px & b); \
+}
+
+DEFN_BITWISE_AND_OP_T_B(const char *)
+DEFN_BITWISE_AND_OP_T_B(const bool *)
+DEFN_BITWISE_AND_OP_T_B(const sc_logic *)
+DEFN_BITWISE_AND_OP_T_B(const sc_unsigned &)
+DEFN_BITWISE_AND_OP_T_B(const sc_signed &)
+DEFN_BITWISE_AND_OP_T_B(const sc_uint_base &)
+DEFN_BITWISE_AND_OP_T_B(const sc_int_base &)
+DEFN_BITWISE_AND_OP_T_B(unsigned long)
+DEFN_BITWISE_AND_OP_T_B(long)
+DEFN_BITWISE_AND_OP_T_B(unsigned int)
+DEFN_BITWISE_AND_OP_T_B(int)
+DEFN_BITWISE_AND_OP_T_B(uint64)
+DEFN_BITWISE_AND_OP_T_B(int64)
+
+#undef DEFN_BITWISE_AND_OP_T_B
+
+// bitwise or
+template <class X, class Y>
+inline X &
+operator |= (sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ X &x = px.back_cast();
+ sc_lv_base a(x.length());
+ a = py.back_cast();
+ return b_or_assign_(x, a);
+}
+
+#define DEFN_BITWISE_OR_ASN_OP_T(tp) \
+template <class X> \
+inline X & \
+sc_proxy<X>::operator |= (tp b) \
+{ \
+ X &x = back_cast(); \
+ sc_lv_base a(x.length()); \
+ a = b; \
+ return b_or_assign_(x, a); \
+}
+
+DEFN_BITWISE_OR_ASN_OP_T(const char *)
+DEFN_BITWISE_OR_ASN_OP_T(const bool *)
+DEFN_BITWISE_OR_ASN_OP_T(const sc_logic *)
+DEFN_BITWISE_OR_ASN_OP_T(const sc_unsigned &)
+DEFN_BITWISE_OR_ASN_OP_T(const sc_signed &)
+DEFN_BITWISE_OR_ASN_OP_T(unsigned long)
+DEFN_BITWISE_OR_ASN_OP_T(long)
+DEFN_BITWISE_OR_ASN_OP_T(uint64)
+DEFN_BITWISE_OR_ASN_OP_T(int64)
+
+#undef DEFN_BITWISE_OR_ASN_OP_T
+
+template <class X, class Y>
+inline const sc_lv_base
+operator | (const sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ sc_lv_base a(px.back_cast());
+ return (a |= py.back_cast());
+}
+
+#define DEFN_BITWISE_OR_OP_T_A(tp) \
+template <class X> \
+inline const sc_lv_base \
+sc_proxy<X>::operator | (tp b) const \
+{ \
+ sc_lv_base a(back_cast()); \
+ return (a |= b); \
+}
+
+DEFN_BITWISE_OR_OP_T_A(const char *)
+DEFN_BITWISE_OR_OP_T_A(const bool *)
+DEFN_BITWISE_OR_OP_T_A(const sc_logic *)
+DEFN_BITWISE_OR_OP_T_A(const sc_unsigned &)
+DEFN_BITWISE_OR_OP_T_A(const sc_signed &)
+DEFN_BITWISE_OR_OP_T_A(const sc_uint_base &)
+DEFN_BITWISE_OR_OP_T_A(const sc_int_base &)
+DEFN_BITWISE_OR_OP_T_A(unsigned long)
+DEFN_BITWISE_OR_OP_T_A(long)
+DEFN_BITWISE_OR_OP_T_A(unsigned int)
+DEFN_BITWISE_OR_OP_T_A(int)
+DEFN_BITWISE_OR_OP_T_A(uint64)
+DEFN_BITWISE_OR_OP_T_A(int64)
+
+#undef DEFN_BITWISE_OR_OP_T_A
+
+#define DEFN_BITWISE_OR_OP_T_B(tp) \
+template <class X> \
+inline const sc_lv_base \
+operator | (tp b, const sc_proxy<X> &px) \
+{ \
+ return (px | b); \
+}
+
+DEFN_BITWISE_OR_OP_T_B(const char *)
+DEFN_BITWISE_OR_OP_T_B(const bool *)
+DEFN_BITWISE_OR_OP_T_B(const sc_logic *)
+DEFN_BITWISE_OR_OP_T_B(const sc_unsigned &)
+DEFN_BITWISE_OR_OP_T_B(const sc_signed &)
+DEFN_BITWISE_OR_OP_T_B(const sc_uint_base &)
+DEFN_BITWISE_OR_OP_T_B(const sc_int_base &)
+DEFN_BITWISE_OR_OP_T_B(unsigned long)
+DEFN_BITWISE_OR_OP_T_B(long)
+DEFN_BITWISE_OR_OP_T_B(unsigned int)
+DEFN_BITWISE_OR_OP_T_B(int)
+DEFN_BITWISE_OR_OP_T_B(uint64)
+DEFN_BITWISE_OR_OP_T_B(int64)
+
+#undef DEFN_BITWISE_OR_OP_T_B
+
+// bitwise xor
+template <class X, class Y>
+inline X &
+operator ^= (sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ X &x = px.back_cast();
+ sc_lv_base a(x.length());
+ a = py.back_cast();
+ return b_xor_assign_(x, a);
+}
+
+#define DEFN_BITWISE_XOR_ASN_OP_T(tp) \
+template <class X> \
+inline X & \
+sc_proxy<X>::operator ^= (tp b) \
+{ \
+ X &x = back_cast(); \
+ sc_lv_base a(x.length()); \
+ a = b; \
+ return b_xor_assign_(x, a); \
+}
+
+DEFN_BITWISE_XOR_ASN_OP_T(const char *)
+DEFN_BITWISE_XOR_ASN_OP_T(const bool *)
+DEFN_BITWISE_XOR_ASN_OP_T(const sc_logic *)
+DEFN_BITWISE_XOR_ASN_OP_T(const sc_unsigned &)
+DEFN_BITWISE_XOR_ASN_OP_T(const sc_signed &)
+DEFN_BITWISE_XOR_ASN_OP_T(unsigned long)
+DEFN_BITWISE_XOR_ASN_OP_T(long)
+DEFN_BITWISE_XOR_ASN_OP_T(uint64)
+DEFN_BITWISE_XOR_ASN_OP_T(int64)
+
+#undef DEFN_BITWISE_XOR_ASN_OP_T
+
+template <class X, class Y>
+inline const sc_lv_base
+operator ^ (const sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ sc_lv_base a(px.back_cast());
+ return (a ^= py.back_cast());
+}
+
+#define DEFN_BITWISE_XOR_OP_T_A(tp) \
+template <class X> \
+inline const sc_lv_base \
+sc_proxy<X>::operator ^ (tp b) const \
+{ \
+ sc_lv_base a(back_cast()); \
+ return (a ^= b); \
+}
+
+DEFN_BITWISE_XOR_OP_T_A(const char *)
+DEFN_BITWISE_XOR_OP_T_A(const bool *)
+DEFN_BITWISE_XOR_OP_T_A(const sc_logic *)
+DEFN_BITWISE_XOR_OP_T_A(const sc_unsigned &)
+DEFN_BITWISE_XOR_OP_T_A(const sc_signed &)
+DEFN_BITWISE_XOR_OP_T_A(const sc_uint_base &)
+DEFN_BITWISE_XOR_OP_T_A(const sc_int_base &)
+DEFN_BITWISE_XOR_OP_T_A(unsigned long)
+DEFN_BITWISE_XOR_OP_T_A(long)
+DEFN_BITWISE_XOR_OP_T_A(unsigned int)
+DEFN_BITWISE_XOR_OP_T_A(int)
+DEFN_BITWISE_XOR_OP_T_A(uint64)
+DEFN_BITWISE_XOR_OP_T_A(int64)
+
+#undef DEFN_BITWISE_XOR_OP_T_A
+
+#define DEFN_BITWISE_XOR_OP_T_B(tp) \
+template <class X> \
+inline const sc_lv_base \
+operator ^ (tp b, const sc_proxy<X> &px) \
+{ \
+ return (px ^ b); \
+}
+
+DEFN_BITWISE_XOR_OP_T_B(const char *)
+DEFN_BITWISE_XOR_OP_T_B(const bool *)
+DEFN_BITWISE_XOR_OP_T_B(const sc_logic *)
+DEFN_BITWISE_XOR_OP_T_B(const sc_unsigned &)
+DEFN_BITWISE_XOR_OP_T_B(const sc_signed &)
+DEFN_BITWISE_XOR_OP_T_B(const sc_uint_base &)
+DEFN_BITWISE_XOR_OP_T_B(const sc_int_base &)
+DEFN_BITWISE_XOR_OP_T_B(unsigned long)
+DEFN_BITWISE_XOR_OP_T_B(long)
+DEFN_BITWISE_XOR_OP_T_B(unsigned int)
+DEFN_BITWISE_XOR_OP_T_B(int)
+DEFN_BITWISE_XOR_OP_T_B(uint64)
+DEFN_BITWISE_XOR_OP_T_B(int64)
+
+#undef DEFN_BITWISE_XOR_OP_T_B
+
+// bitwise left shift
+template <class X>
+inline const sc_lv_base
+sc_proxy<X>::operator << (int n) const
+{
+ sc_lv_base a(back_cast().length() + n);
+ a = back_cast();
+ return (a <<= n);
+}
+
+// bitwise right shift
+template <class X>
+inline const sc_lv_base
+sc_proxy<X>::operator >> (int n) const
+{
+ sc_lv_base a(back_cast());
+ return (a >>= n);
+}
+
+// bitwise left rotate
+template <class X>
+inline X &
+sc_proxy<X>::lrotate(int n)
+{
+ X &x = back_cast();
+ if (n < 0) {
+ sc_proxy_out_of_bounds("left rotate operation is only allowed with "
+ "positive rotate values, rotate value = ", n);
+ return x;
+ }
+ int len = x.length();
+ n %= len;
+ // x = (x << n) | (x >> (len - n));
+ sc_lv_base a(x << n);
+ sc_lv_base b(x >> (len - n));
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ x.set_word(i, a.get_word(i) | b.get_word(i));
+ x.set_cword(i, a.get_cword(i) | b.get_cword(i));
+ }
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline const sc_lv_base
+lrotate(const sc_proxy<X> &x, int n)
+{
+ sc_lv_base a(x.back_cast());
+ return a.lrotate(n);
+}
+
+// bitwise right rotate
+template <class X>
+inline X &
+sc_proxy<X>::rrotate(int n)
+{
+ X &x = back_cast();
+ if (n < 0 ) {
+ sc_proxy_out_of_bounds("right rotate operation is only allowed with "
+ "positive rotate values, rotate value = ", n);
+ return x;
+ }
+ int len = x.length();
+ n %= len;
+ // x = (x >> n) | (x << (len - n));
+ sc_lv_base a(x >> n);
+ sc_lv_base b(x << (len - n));
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ x.set_word(i, a.get_word(i) | b.get_word(i));
+ x.set_cword(i, a.get_cword(i) | b.get_cword(i));
+ }
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline const sc_lv_base
+rrotate(const sc_proxy<X> &x, int n)
+{
+ sc_lv_base a(x.back_cast());
+ return a.rrotate(n);
+}
+
+// bitwise reverse
+template <class X>
+inline const sc_lv_base
+reverse(const sc_proxy<X> &x)
+{
+ sc_lv_base a(x.back_cast());
+ return a.reverse();
+}
+
+// relational operators
+template <class X, class Y>
+inline bool
+operator == (const sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ const X &x = px.back_cast();
+ const Y &y = py.back_cast();
+ int x_len = x.length();
+ int y_len = y.length();
+ if (x_len != y_len) {
+ return false;
+ }
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ if (x.get_word(i) != y.get_word(i) ||
+ x.get_cword(i) != y.get_cword(i)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+#define DEFN_REL_OP_T(tp) \
+template <class X> \
+inline bool \
+sc_proxy<X>::operator == (tp b) const \
+{ \
+ const X &x = back_cast(); \
+ sc_lv_base y(x.length()); \
+ y = b; \
+ return (x == y); \
+}
+
+DEFN_REL_OP_T(const char *)
+DEFN_REL_OP_T(const bool *)
+DEFN_REL_OP_T(const sc_logic *)
+DEFN_REL_OP_T(const sc_unsigned &)
+DEFN_REL_OP_T(const sc_signed &)
+DEFN_REL_OP_T(const sc_uint_base &)
+DEFN_REL_OP_T(const sc_int_base &)
+DEFN_REL_OP_T(unsigned long)
+DEFN_REL_OP_T(long)
+DEFN_REL_OP_T(unsigned int)
+DEFN_REL_OP_T(int)
+DEFN_REL_OP_T(uint64)
+DEFN_REL_OP_T(int64)
+
+#undef DEFN_REL_OP_T
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bitref_r<X>
+//
+// Proxy class for sc_proxy bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+operator , (sc_bitref_r<T> a, const char *b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+operator , (const char *a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+operator , (sc_bitref_r<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+operator , (const sc_logic &a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base,sc_bitref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_bv_base>
+operator , (sc_bitref_r<T> a, bool b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_bitref_r<T> >
+operator , (bool a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_bitref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+concat(sc_bitref_r<T> a, const char *b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+concat(const char *a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+concat(sc_bitref_r<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+concat(const sc_logic &a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_bv_base>
+concat(sc_bitref_r<T> a, bool b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_bitref_r<T> >
+concat(bool a, sc_bitref_r<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_bitref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+operator , (sc_bitref<T> a, const char *b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+operator , (const char *a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+operator , (sc_bitref<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+operator , (const sc_logic &a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_bv_base>
+operator , (sc_bitref<T> a, bool b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_bitref_r<T> >
+operator , (bool a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_bitref_r<T> > (
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+concat(sc_bitref<T> a, const char *b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+concat(const char *a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_lv_base>
+concat(sc_bitref<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_bitref_r<T> >
+concat(const sc_logic &a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_bitref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bitref_r<T>, sc_bv_base>
+concat(sc_bitref<T> a, bool b)
+{
+ return sc_concref_r<sc_bitref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_bitref_r<T> >
+concat(bool a, sc_bitref<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_bitref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref_r<X>
+//
+// Proxy class for sc_proxy part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+operator , (sc_subref_r<T> a, const char *b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+operator , (const char *a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+operator , (sc_subref_r<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+operator , (const sc_logic &a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base>
+operator , (sc_subref_r<T> a, bool b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> >
+operator , (bool a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_subref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+concat(sc_subref_r<T> a, const char *b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+concat(const char *a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+concat(sc_subref_r<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+concat(const sc_logic &a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base>
+concat(sc_subref_r<T> a, bool b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> >
+concat(bool a, sc_subref_r<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_subref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+operator , (sc_subref<T> a, const char *b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+operator , (const char *a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+operator , (sc_subref<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+operator , (const sc_logic &a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base>
+operator , (sc_subref<T> a, bool b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> >
+operator , (bool a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_subref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+concat(sc_subref<T> a, const char *b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+concat(const char *a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_lv_base>
+concat(sc_subref<T> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, sc_subref_r<T> >
+concat(const sc_logic &a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_lv_base, sc_subref_r<T> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_subref_r<T>, sc_bv_base>
+concat(sc_subref<T> a, bool b)
+{
+ return sc_concref_r<sc_subref_r<T>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, sc_subref_r<T> >
+concat(bool a, sc_subref<T> b)
+{
+ return sc_concref_r<sc_bv_base, sc_subref_r<T> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_subref<X>
+//
+// Proxy class for sc_proxy part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+template <class X>
+inline sc_subref<X> &
+sc_subref<X>::operator = (const sc_subref_r<X> &b)
+{
+ sc_lv_base t(b); // (partial) self assignment protection
+ int len = sc_min(this->length(), t.length());
+ if (!this->reversed()) {
+ for (int i = len - 1; i >= 0; --i) {
+ this->m_obj.set_bit(this->m_lo + i, t[i].value());
+ }
+ } else {
+ for (int i = len - 1; i >= 0; --i) {
+ this->m_obj.set_bit(this->m_lo - i, t[i].value());
+ }
+ }
+ return *this;
+}
+
+template <class X>
+inline sc_subref<X> &
+sc_subref<X>::operator = (const sc_subref<X> &b)
+{
+ sc_lv_base t(b); // (partial) self assignment protection
+ int len = sc_min(this->length(), t.length());
+ if (!this->reversed()) {
+ for (int i = len - 1; i >= 0; --i) {
+ this->m_obj.set_bit(this->m_lo + i, t[i].value());
+ }
+ } else {
+ for (int i = len - 1; i >= 0; --i) {
+ this->m_obj.set_bit(this->m_lo - i, t[i].value());
+ }
+ }
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concref_r<X,Y>
+//
+// Proxy class for sc_proxy concatenation (r-value only).
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+operator , (sc_concref_r<T1, T2> a, const char *b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+operator , (const char *a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+operator , (sc_concref_r<T1, T2> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+operator , (const sc_logic &a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>
+operator , (sc_concref_r<T1, T2> a, bool b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >
+operator , (bool a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+concat(sc_concref_r<T1, T2> a, const char *b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+concat(const char *a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+concat(sc_concref_r<T1, T2> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+concat(const sc_logic &a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>
+concat(sc_concref_r<T1, T2> a, bool b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >
+concat(bool a, sc_concref_r<T1, T2> b)
+{
+ return sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+operator , (sc_concref<T1, T2> a, const char *b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+operator , (const char *a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+operator , (sc_concref<T1, T2> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+operator , (const sc_logic &a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>
+operator , (sc_concref<T1, T2> a, bool b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >
+operator , (bool a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+concat(sc_concref<T1, T2> a, const char *b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+concat(const char *a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>
+concat(sc_concref<T1, T2> a, const sc_logic &b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base>(
+ *a.clone(), *new sc_lv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >
+concat(const sc_logic &a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> >(
+ *new sc_lv_base(a, 1), *b.clone(), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>
+concat(sc_concref<T1, T2> a, bool b)
+{
+ return sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base>(
+ *a.clone(), *new sc_bv_base(b, 1), 3);
+}
+
+template <class T1, class T2>
+inline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >
+concat(bool a, sc_concref<T1, T2> b)
+{
+ return sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> >(
+ *new sc_bv_base(a, 1), *b.clone(), 3);
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy<T>
+//
+// Base class template for bit/logic vector classes.
+// (Barton/Nackmann implementation)
+// ----------------------------------------------------------------------------
+
+// r-value concatenation operators and functions
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+operator , (const sc_proxy<T> &a, const char *b)
+{
+ return sc_concref_r<T, sc_lv_base>(a.back_cast(), *new sc_lv_base(b), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+operator , (const char *a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(*new sc_lv_base(a), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+operator , (const sc_proxy<T> &a, const sc_logic &b)
+{
+ return sc_concref_r<T, sc_lv_base>(
+ a.back_cast(), *new sc_lv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+operator , (const sc_logic &a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(
+ *new sc_lv_base(a, 1), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base>
+operator , (const sc_proxy<T> &a, bool b)
+{
+ return sc_concref_r<T, sc_bv_base>(
+ a.back_cast(), *new sc_bv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T>
+operator , (bool a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_bv_base, T>(
+ *new sc_bv_base(a, 1), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+concat(const sc_proxy<T> &a, const char *b)
+{
+ return sc_concref_r<T, sc_lv_base>(a.back_cast(), *new sc_lv_base(b), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+concat(const char *a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(*new sc_lv_base(a), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+concat(const sc_proxy<T> &a, const sc_logic &b)
+{
+ return sc_concref_r<T, sc_lv_base>(
+ a.back_cast(), *new sc_lv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+concat(const sc_logic &a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(
+ *new sc_lv_base(a, 1), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base>
+concat(const sc_proxy<T> &a, bool b)
+{
+ return sc_concref_r<T, sc_bv_base>(
+ a.back_cast(), *new sc_bv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T>
+concat(bool a, const sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_bv_base, T>(
+ *new sc_bv_base(a, 1), b.back_cast(), 1);
+}
+
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+operator , (sc_proxy<T> &a, const char *b)
+{
+ return sc_concref_r<T, sc_lv_base>(a.back_cast(), *new sc_lv_base(b), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+operator , (const char *a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(*new sc_lv_base(a), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+operator , (sc_proxy<T> &a, const sc_logic &b)
+{
+ return sc_concref_r<T, sc_lv_base>(
+ a.back_cast(), *new sc_lv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+operator , (const sc_logic &a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(
+ *new sc_lv_base(a, 1), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base>
+operator , (sc_proxy<T> &a, bool b)
+{
+ return sc_concref_r<T, sc_bv_base>(
+ a.back_cast(), *new sc_bv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T>
+operator , (bool a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_bv_base, T>(
+ *new sc_bv_base(a, 1), b.back_cast(), 1);
+}
+
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+concat(sc_proxy<T> &a, const char *b)
+{
+ return sc_concref_r<T, sc_lv_base>(a.back_cast(), *new sc_lv_base(b), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+concat(const char *a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(*new sc_lv_base(a), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_lv_base>
+concat(sc_proxy<T> &a, const sc_logic &b)
+{
+ return sc_concref_r<T, sc_lv_base>(
+ a.back_cast(), *new sc_lv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_lv_base, T>
+concat(const sc_logic &a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_lv_base, T>(
+ *new sc_lv_base(a, 1), b.back_cast(), 1);
+}
+
+template <class T>
+inline sc_concref_r<T, sc_bv_base>
+concat(sc_proxy<T> &a, bool b)
+{
+ return sc_concref_r<T, sc_bv_base>(
+ a.back_cast(), *new sc_bv_base(b, 1), 2);
+}
+
+template <class T>
+inline sc_concref_r<sc_bv_base, T>
+concat(bool a, sc_proxy<T> &b)
+{
+ return sc_concref_r<sc_bv_base, T>(
+ *new sc_bv_base(a, 1), b.back_cast(), 1);
+}
+
+// extern template instantiations
+extern template class sc_proxy<sc_lv_base>;
+extern template class sc_proxy<sc_bv_base>;
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_LV_BASE_HH__
diff --git a/src/systemc/ext/dt/bit/sc_proxy.hh b/src/systemc/ext/dt/bit/sc_proxy.hh
new file mode 100644
index 000000000..cf7bcbfc9
--- /dev/null
+++ b/src/systemc/ext/dt/bit/sc_proxy.hh
@@ -0,0 +1,1394 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_proxy.h -- Proxy base class for vector data types.
+
+ This class is created for several purposes:
+ 1) hiding operators from the global namespace that would be
+ otherwise found by Koenig lookup
+ 2) avoiding repeating the same operations in every class
+ including proxies that could also be achieved by common
+ base class, but this method allows
+ 3) improve performance by using non-virtual functions
+
+ Original Author: Gene Bushuyev, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_proxy.h,v $
+// Revision 1.3 2010/12/07 20:09:07 acg
+// Andy Goodrich: Fix for returning enough data
+//
+// Revision 1.2 2009/02/28 00:26:14 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.1.1.1 2006/12/15 20:31:36 acg
+// SystemC 2.2
+//
+// Revision 1.3 2006/01/13 18:53:53 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
+#define __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
+
+#include <iostream>
+
+#include "../../utils/functions.hh"
+#include "../int/sc_int_base.hh"
+#include "../int/sc_signed.hh"
+#include "../int/sc_uint_base.hh"
+#include "../int/sc_unsigned.hh"
+#include "sc_bit.hh"
+#include "sc_logic.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <class X>
+class sc_proxy;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+template <class X>
+class sc_bitref_r;
+template <class X>
+class sc_bitref;
+template <class X>
+class sc_subref_r;
+template <class X>
+class sc_subref;
+template <class X, class Y>
+class sc_concref_r;
+template <class X, class Y>
+class sc_concref;
+
+const int SC_DIGIT_SIZE = BITS_PER_BYTE * sizeof(sc_digit);
+
+const sc_digit SC_DIGIT_ZERO = (sc_digit)0;
+const sc_digit SC_DIGIT_ONE = (sc_digit)1;
+const sc_digit SC_DIGIT_TWO = (sc_digit)2;
+
+void sc_proxy_out_of_bounds(const char *msg=NULL, int64 val=0);
+
+// assignment functions; forward declarations
+
+template <class X, class Y>
+inline void assign_p_(sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+// Vector types that are not derived from sc_proxy must have a length()
+// function and an operator [].
+
+template <class X, class T>
+inline void assign_v_(sc_proxy<X> &px, const T &a);
+
+// other functions; forward declarations
+const std::string convert_to_bin(const char *s);
+const std::string convert_to_fmt(const std::string &s, sc_numrep numrep, bool);
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy_traits
+//
+// Template traits helper to select the correct bit/value/vector_types for
+// sc_proxy-based vector classes.
+//
+// All types derived from/based on a bit-vector contain typedef to a plain
+// bool, all others point to the sc_logic_value_t/sc_logic/sc_lv_base types.
+// ----------------------------------------------------------------------------
+
+template <typename X>
+struct sc_proxy_traits;
+
+template <>
+struct sc_proxy_traits<sc_bv_base>
+{
+ typedef sc_proxy_traits<sc_bv_base> traits_type;
+ typedef bool value_type;
+ typedef sc_logic bit_type; // sc_logic needed for mixed expressions
+ typedef sc_bv_base vector_type;
+};
+
+template <>
+struct sc_proxy_traits<sc_lv_base>
+{
+ typedef sc_proxy_traits<sc_lv_base> traits_type;
+ typedef sc_logic_value_t value_type;
+ typedef sc_logic bit_type;
+ typedef sc_lv_base vector_type;
+};
+
+template <typename X>
+struct sc_proxy_traits<sc_bitref_r<X> > : sc_proxy_traits<X> {};
+
+template <typename X>
+struct sc_proxy_traits<sc_bitref<X> > : sc_proxy_traits<X> {};
+
+template <typename X>
+struct sc_proxy_traits<sc_subref_r<X> > : sc_proxy_traits<X> {};
+
+template <typename X>
+struct sc_proxy_traits<sc_subref<X> > : sc_proxy_traits<X> {};
+
+template <typename X>
+struct sc_proxy_traits<sc_proxy<X> > : sc_proxy_traits<X> {};
+
+
+template <typename X, typename Y>
+struct sc_mixed_proxy_traits_helper : sc_proxy_traits<sc_lv_base>
+{}; // logic vector by default
+
+template <typename X>
+struct sc_mixed_proxy_traits_helper<X, X> : X {};
+
+template <typename X, typename Y>
+struct sc_proxy_traits<sc_concref_r<X, Y> > :
+ sc_mixed_proxy_traits_helper<
+ typename X::traits_type, typename Y::traits_type>
+{};
+
+template <typename X, typename Y>
+struct sc_proxy_traits<sc_concref<X, Y> > :
+ sc_mixed_proxy_traits_helper<
+ typename X::traits_type, typename Y::traits_type>
+{};
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_proxy
+//
+// Base class template for bit/logic vector classes.
+// (Barton/Nackmann implementation)
+// ----------------------------------------------------------------------------
+
+template <class X>
+class sc_proxy // #### : public sc_value_base
+{
+ public:
+ typedef typename sc_proxy_traits<X>::traits_type traits_type;
+ typedef typename traits_type::bit_type bit_type;
+ typedef typename traits_type::value_type value_type;
+
+ // virtual destructor
+ virtual ~sc_proxy() {}
+
+ // casts
+ X &back_cast() { return static_cast<X &>(*this); }
+
+ const X &back_cast() const { return static_cast<const X &>(*this); }
+
+ // assignment operators
+ template <class Y>
+ X &
+ assign_(const sc_proxy<Y> &a)
+ {
+ assign_p_(*this, a);
+ return back_cast();
+ }
+
+ X &assign_(const char *a);
+ X &assign_(const bool *a);
+ X &assign_(const sc_logic *a);
+
+ X &
+ assign_(const sc_unsigned &a)
+ {
+ assign_v_(*this, a);
+ return back_cast();
+ }
+
+ X &
+ assign_(const sc_signed &a)
+ {
+ assign_v_(*this, a);
+ return back_cast();
+ }
+
+ X &assign_(const sc_uint_base &a) { return assign_((uint64)a); }
+ X &assign_(const sc_int_base &a) { return assign_((int64)a); }
+ X &assign_(unsigned int a);
+ X &assign_(int a);
+ X &assign_(unsigned long a);
+ X &assign_(long a);
+ X &assign_(uint64 a);
+ X &assign_(int64 a);
+
+ // bitwise operators and functions
+
+ // bitwise complement
+ X &b_not();
+
+ const sc_lv_base operator ~ () const;
+
+ // bitwise and
+ X &operator &= (const char *b);
+ X &operator &= (const bool *b);
+ X &operator &= (const sc_logic *b);
+ X &operator &= (const sc_unsigned &b);
+ X &operator &= (const sc_signed &b);
+ X &operator &= (const sc_uint_base &b) { return operator &= ((uint64)b); }
+ X &operator &= (const sc_int_base &b) { return operator &= ((int64)b); }
+ X &operator &= (unsigned long b);
+ X &operator &= (long b);
+ X &operator &= (unsigned int b) { return operator &= ((unsigned long)b); }
+ X &operator &= (int b) { return operator &= ((long)b); }
+ X &operator &= (uint64 b);
+ X &operator &= (int64 b);
+
+ const sc_lv_base operator & (const char *b) const;
+ const sc_lv_base operator & (const bool *b) const;
+ const sc_lv_base operator & (const sc_logic *b) const;
+ const sc_lv_base operator & (const sc_unsigned &b) const;
+ const sc_lv_base operator & (const sc_signed &b) const;
+ const sc_lv_base operator & (const sc_uint_base &b) const;
+ const sc_lv_base operator & (const sc_int_base &b) const;
+ const sc_lv_base operator & (unsigned long b) const;
+ const sc_lv_base operator & (long b) const;
+ const sc_lv_base operator & (unsigned int b) const;
+ const sc_lv_base operator & (int b) const;
+ const sc_lv_base operator & (uint64 b) const;
+ const sc_lv_base operator & (int64 b) const;
+
+ // bitwise or
+ X &operator |= (const char *b);
+ X &operator |= (const bool *b);
+ X &operator |= (const sc_logic *b);
+ X &operator |= (const sc_unsigned &b);
+ X &operator |= (const sc_signed &b);
+ X &operator |= (const sc_uint_base &b) { return operator |= ((uint64)b); }
+ X &operator |= (const sc_int_base &b) { return operator |= ((int64)b); }
+ X &operator |= (unsigned long b);
+ X &operator |= (long b);
+ X &operator |= (unsigned int b) { return operator |= ((unsigned long)b); }
+ X &operator |= (int b) { return operator |= ((long)b); }
+ X &operator |= (uint64 b);
+ X &operator |= (int64 b);
+
+ const sc_lv_base operator | (const char *b) const;
+ const sc_lv_base operator | (const bool *b) const;
+ const sc_lv_base operator | (const sc_logic *b) const;
+ const sc_lv_base operator | (const sc_unsigned &b) const;
+ const sc_lv_base operator | (const sc_signed &b) const;
+ const sc_lv_base operator | (const sc_uint_base &b) const;
+ const sc_lv_base operator | (const sc_int_base &b) const;
+ const sc_lv_base operator | (unsigned long b) const;
+ const sc_lv_base operator | (long b) const;
+ const sc_lv_base operator | (unsigned int b) const;
+ const sc_lv_base operator | (int b) const;
+ const sc_lv_base operator | (uint64 b) const;
+ const sc_lv_base operator | (int64 b) const;
+
+ // bitwise xor
+ X &operator ^= (const char *b);
+ X &operator ^= (const bool *b);
+ X &operator ^= (const sc_logic *b);
+ X &operator ^= (const sc_unsigned &b);
+ X &operator ^= (const sc_signed &b);
+ X &operator ^= (const sc_uint_base &b) { return operator ^= ((uint64)b); }
+ X &operator ^= (const sc_int_base &b) { return operator ^= ((int64)b); }
+ X &operator ^= (unsigned long b);
+ X &operator ^= (long b);
+ X &operator ^= (unsigned int b) { return operator ^= ((unsigned long)b); }
+ X &operator ^= (int b) { return operator ^= ((long)b); }
+ X &operator ^= (uint64 b);
+ X &operator ^= (int64 b);
+
+ const sc_lv_base operator ^ (const char *b) const;
+ const sc_lv_base operator ^ (const bool *b) const;
+ const sc_lv_base operator ^ (const sc_logic *b) const;
+ const sc_lv_base operator ^ (const sc_unsigned &b) const;
+ const sc_lv_base operator ^ (const sc_signed &b) const;
+ const sc_lv_base operator ^ (const sc_uint_base &b) const;
+ const sc_lv_base operator ^ (const sc_int_base &b) const;
+ const sc_lv_base operator ^ (unsigned long b) const;
+ const sc_lv_base operator ^ (long b) const;
+ const sc_lv_base operator ^ (unsigned int b) const;
+ const sc_lv_base operator ^ (int b) const;
+ const sc_lv_base operator ^ (uint64 b) const;
+ const sc_lv_base operator ^ (int64 b) const;
+
+ // bitwise left shift
+ X &operator <<= (int n);
+ const sc_lv_base operator << (int n) const;
+
+ // bitwise right shift
+ X &operator >>= (int n);
+ const sc_lv_base operator >> (int n) const;
+
+ // bitwise left rotate
+ X &lrotate(int n);
+
+ // bitwise right rotate
+ X &rrotate(int n);
+
+ // bitwise reverse
+ X &reverse();
+
+ // bit selection
+ sc_bitref<X> operator [] (int i) { return sc_bitref<X>(back_cast(), i); }
+ sc_bitref_r<X>
+ operator [] (int i) const
+ {
+ return sc_bitref_r<X>(back_cast(), i);
+ }
+ sc_bitref<X> bit(int i) { return sc_bitref<X>(back_cast(), i); }
+ sc_bitref_r<X> bit(int i) const { return sc_bitref_r<X>(back_cast(), i); }
+
+ // part selection
+ sc_subref<X>
+ operator () (int hi, int lo)
+ {
+ return sc_subref<X>(back_cast(), hi, lo);
+ }
+ sc_subref_r<X>
+ operator () (int hi, int lo) const
+ {
+ return sc_subref_r<X>(back_cast(), hi, lo);
+ }
+ sc_subref<X>
+ range(int hi, int lo)
+ {
+ return sc_subref<X>(back_cast(), hi, lo);
+ }
+ sc_subref_r<X>
+ range(int hi, int lo) const
+ {
+ return sc_subref_r<X>(back_cast(), hi, lo);
+ }
+
+ // reduce functions
+ value_type and_reduce() const;
+ value_type
+ nand_reduce() const
+ {
+ return sc_logic::not_table[and_reduce()];
+ }
+ value_type or_reduce() const;
+ value_type nor_reduce() const { return sc_logic::not_table[or_reduce()]; }
+ value_type xor_reduce() const;
+ value_type
+ xnor_reduce() const
+ {
+ return sc_logic::not_table[xor_reduce()];
+ }
+
+ // relational operators
+ bool operator == (const char *b) const;
+ bool operator == (const bool *b) const;
+ bool operator == (const sc_logic *b) const;
+ bool operator == (const sc_unsigned &b) const;
+ bool operator == (const sc_signed &b) const;
+ bool operator == (const sc_uint_base &b) const;
+ bool operator == (const sc_int_base &b) const;
+ bool operator == (unsigned long b) const;
+ bool operator == (long b) const;
+ bool operator == (unsigned int b) const;
+ bool operator == (int b) const;
+ bool operator == (uint64 b) const;
+ bool operator == (int64 b) const;
+
+ // explicit conversions to character string
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+
+ // explicit conversions
+ inline int64 to_int64() const { return to_anything_signed(); }
+ inline uint64 to_uint64() const;
+ int to_int() const { return (int)to_anything_signed(); }
+
+ unsigned int
+ to_uint() const
+ {
+ return (unsigned int)to_anything_unsigned();
+ }
+
+ long to_long() const { return (long)to_anything_signed(); }
+
+ unsigned long
+ to_ulong() const
+ {
+ return (unsigned long)to_anything_unsigned();
+ }
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ // The test below will force printing in binary if decimal is
+ // specified.
+ if (sc_io_base(os, SC_DEC) == SC_DEC)
+ os << to_string();
+ else
+ os << to_string(sc_io_base(os, SC_BIN), sc_io_show_base(os));
+ }
+
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ void check_bounds(int n) const; // check if bit n accessible
+ void check_wbounds(int n) const; // check if word n accessible
+
+ sc_digit to_anything_unsigned() const;
+ int64 to_anything_signed() const;
+};
+
+
+// ----------------------------------------------------------------------------
+
+// bitwise operators and functions
+
+// bitwise and
+
+template <class X, class Y>
+inline X &operator &= (sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+
+template <class X, class Y>
+inline const sc_lv_base operator & (
+ const sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+
+#define DECL_BITWISE_AND_OP_T(tp) \
+template <class X> \
+inline const sc_lv_base operator & (tp b, const sc_proxy<X> &px);
+
+DECL_BITWISE_AND_OP_T(const char *)
+DECL_BITWISE_AND_OP_T(const bool *)
+DECL_BITWISE_AND_OP_T(const sc_logic *)
+DECL_BITWISE_AND_OP_T(const sc_unsigned &)
+DECL_BITWISE_AND_OP_T(const sc_signed &)
+DECL_BITWISE_AND_OP_T(const sc_uint_base &)
+DECL_BITWISE_AND_OP_T(const sc_int_base &)
+DECL_BITWISE_AND_OP_T(unsigned long)
+DECL_BITWISE_AND_OP_T(long)
+DECL_BITWISE_AND_OP_T(unsigned int)
+DECL_BITWISE_AND_OP_T(int)
+DECL_BITWISE_AND_OP_T(uint64)
+DECL_BITWISE_AND_OP_T(int64)
+
+#undef DECL_BITWISE_AND_OP_T
+
+// bitwise or
+template <class X, class Y>
+inline X &operator |= (sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+template <class X, class Y>
+inline const sc_lv_base operator | (
+ const sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+
+#define DECL_BITWISE_OR_OP_T(tp) \
+template <class X> \
+inline const sc_lv_base operator | (tp a, const sc_proxy<X> &px);
+
+DECL_BITWISE_OR_OP_T(const char *)
+DECL_BITWISE_OR_OP_T(const bool *)
+DECL_BITWISE_OR_OP_T(const sc_logic *)
+DECL_BITWISE_OR_OP_T(const sc_unsigned &)
+DECL_BITWISE_OR_OP_T(const sc_signed &)
+DECL_BITWISE_OR_OP_T(const sc_uint_base &)
+DECL_BITWISE_OR_OP_T(const sc_int_base &)
+DECL_BITWISE_OR_OP_T(unsigned long)
+DECL_BITWISE_OR_OP_T(long)
+DECL_BITWISE_OR_OP_T(unsigned int)
+DECL_BITWISE_OR_OP_T(int)
+DECL_BITWISE_OR_OP_T(uint64)
+DECL_BITWISE_OR_OP_T(int64)
+
+#undef DECL_BITWISE_OR_OP_T
+
+// bitwise xor
+template <class X, class Y>
+inline X &operator ^= (sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+template <class X, class Y>
+inline const sc_lv_base operator ^ (
+ const sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+#define DECL_BITWISE_XOR_OP_T(tp) \
+template <class X> \
+inline const sc_lv_base operator ^ (tp a, const sc_proxy<X> &px);
+
+DECL_BITWISE_XOR_OP_T(const char *)
+DECL_BITWISE_XOR_OP_T(const bool *)
+DECL_BITWISE_XOR_OP_T(const sc_logic *)
+DECL_BITWISE_XOR_OP_T(const sc_unsigned &)
+DECL_BITWISE_XOR_OP_T(const sc_signed &)
+DECL_BITWISE_XOR_OP_T(const sc_uint_base &)
+DECL_BITWISE_XOR_OP_T(const sc_int_base &)
+DECL_BITWISE_XOR_OP_T(unsigned long)
+DECL_BITWISE_XOR_OP_T(long)
+DECL_BITWISE_XOR_OP_T(unsigned int)
+DECL_BITWISE_XOR_OP_T(int)
+DECL_BITWISE_XOR_OP_T(uint64)
+DECL_BITWISE_XOR_OP_T(int64)
+
+#undef DECL_BITWISE_XOR_OP_T
+
+// relational operators
+template <class X, class Y>
+inline bool operator == (const sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+template <class X, class Y>
+inline bool operator != (const sc_proxy<X> &px, const sc_proxy<Y> &py);
+
+#define DECL_REL_OP_T(tp) \
+template <class X> \
+inline bool operator == (tp b, const sc_proxy<X> &px); \
+ \
+template <class X> \
+inline bool operator != (const sc_proxy<X> &px, tp b); \
+ \
+template <class X> \
+inline bool operator != (tp b, const sc_proxy<X> &px);
+
+DECL_REL_OP_T(const char *)
+DECL_REL_OP_T(const bool *)
+DECL_REL_OP_T(const sc_logic *)
+DECL_REL_OP_T(const sc_unsigned &)
+DECL_REL_OP_T(const sc_signed &)
+DECL_REL_OP_T(const sc_uint_base &)
+DECL_REL_OP_T(const sc_int_base &)
+DECL_REL_OP_T(unsigned long)
+DECL_REL_OP_T(long)
+DECL_REL_OP_T(unsigned int)
+DECL_REL_OP_T(int)
+DECL_REL_OP_T(uint64)
+DECL_REL_OP_T(int64)
+
+#undef DECL_REL_OP_T
+
+// l-value concatenation
+
+// Due to the fact that temporary objects cannot be passed to non-const
+// references, we have to enumerate, use call by value, and use dynamic
+// memory allocation (and deallocation).
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+template <class X>
+inline void
+get_words_(const X &x, int wi, sc_digit &x_dw, sc_digit &x_cw)
+{
+ x_dw = x.get_word(wi);
+ x_cw = x.get_cword(wi);
+}
+
+template <class X>
+inline void
+set_words_(X &x, int wi, sc_digit x_dw, sc_digit x_cw)
+{
+ x.set_word(wi, x_dw);
+ x.set_cword(wi, x_cw);
+}
+
+template <class X>
+inline void
+extend_sign_w_(X &x, int wi, bool sign)
+{
+ int sz = x.size();
+ unsigned int sgn = (sign ? ~SC_DIGIT_ZERO : SC_DIGIT_ZERO);
+ for (int i = wi; i < sz; ++i) {
+ set_words_(x, i, sgn, SC_DIGIT_ZERO);
+ }
+}
+
+// assignment functions
+template <class X, class Y>
+inline void
+assign_p_(sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ if ((void *)&px != (void *)&py) {
+ X &x = px.back_cast();
+ const Y &y = py.back_cast();
+ int sz = x.size();
+ int min_sz = sc_min(sz, y.size());
+ int i = 0;
+ for (; i < min_sz; ++i) {
+ set_words_(x, i, y.get_word(i), y.get_cword(i));
+ }
+ // extend with zeros
+ extend_sign_w_(x, i, false);
+ x.clean_tail();
+ }
+}
+
+// Vector types that are not derived from sc_proxy, sc_int_base,
+// sc_uint_base, sc_signed, or sc_unsigned, must have a length()
+// function and an operator []. The vector argument type must support
+// accessing bits that are beyond the msb. The vector argument type
+// decides what to do there (e.g. sign extension or zero padding).
+
+template <class X, class T>
+inline void
+assign_v_(sc_proxy<X> &px, const T &a)
+{
+ X &x = px.back_cast();
+ int i;
+ int len_x = x.length();
+ int len_a = a.length();
+ if (len_a > len_x)
+ len_a = len_x;
+ for (i = 0; i < len_a; ++i) {
+ x.set_bit(i, sc_logic_value_t((bool)a[i]));
+ }
+ for (; i < len_x; ++i) {
+ x.set_bit(i, sc_logic_value_t(false));
+ }
+}
+
+template <class X>
+inline void
+assign_v_(sc_proxy<X> &px, const sc_int_base &a)
+{
+ X &x = px.back_cast();
+ int i;
+ bool sign = a < 0;
+ int len_x = x.length();
+ int len_a = a.length();
+ if ( len_a > len_x ) len_a = len_x;
+ for (i = 0; i < len_a; ++i) {
+ x.set_bit(i, sc_logic_value_t((bool)a[i]));
+ }
+ for (; i < len_x; ++i) {
+ x.set_bit(i, sc_logic_value_t(sign));
+ }
+}
+
+template <class X>
+inline void
+assign_v_(sc_proxy<X> &px, const sc_signed &a)
+{
+ X &x = px.back_cast();
+ int i;
+ bool sign = a < 0;
+ int len_x = x.length();
+ int len_a = a.length();
+ if (len_a > len_x)
+ len_a = len_x;
+ for (i = 0; i < len_a; ++i) {
+ x.set_bit(i, sc_logic_value_t((bool)a[i]));
+ }
+ for (; i < len_x; ++i) {
+ x.set_bit(i, sc_logic_value_t(sign));
+ }
+}
+
+template <class X>
+inline void
+assign_v_(sc_proxy<X> &px, const sc_uint_base &a)
+{
+ X &x = px.back_cast();
+ int i;
+ int len_x = x.length();
+ int len_a = a.length();
+ if (len_a > len_x)
+ len_a = len_x;
+ for (i = 0; i < len_a; ++i) {
+ x.set_bit(i, sc_logic_value_t((bool)a[i]));
+ }
+ for (; i < len_x; ++i) {
+ x.set_bit(i, sc_logic_value_t(false));
+ }
+}
+
+template <class X>
+inline void
+assign_v_(sc_proxy<X> &px, const sc_unsigned &a)
+{
+ X &x = px.back_cast();
+ int i;
+ int len_x = x.length();
+ int len_a = a.length();
+ if (len_a > len_x)
+ len_a = len_x;
+ for (i = 0; i < len_a; ++i) {
+ x.set_bit(i, sc_logic_value_t((bool)a[i]));
+ }
+ for (; i < len_x; ++i) {
+ x.set_bit(i, sc_logic_value_t(false));
+ }
+}
+
+// assignment operators
+template <class X>
+inline X &
+sc_proxy<X>::assign_(const char *a)
+{
+ X &x = back_cast();
+ std::string s = convert_to_bin(a);
+ int len = x.length();
+ int s_len = s.length() - 1;
+ int min_len = sc_min(len, s_len);
+ int i = 0;
+ for (; i < min_len; ++i) {
+ char c = s[s_len - i - 1];
+ x.set_bit(i, sc_logic::char_to_logic[(int)c]);
+ }
+ // if formatted, fill the rest with sign(s), otherwise fill with zeros
+ sc_logic_value_t fill = (s[s_len] == 'F' ? sc_logic_value_t(s[0] - '0')
+ : sc_logic_value_t(0));
+ for (; i < len; ++i) {
+ x.set_bit(i, fill);
+ }
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(const bool *a)
+{
+ // the length of 'a' must be larger than or equal to the length of 'this'
+ X &x = back_cast();
+ int len = x.length();
+ for (int i = 0; i < len; ++i) {
+ x.set_bit(i, sc_logic_value_t(a[i]));
+ }
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(const sc_logic *a)
+{
+ // the length of 'a' must be larger than or equal to the length of 'this'
+ X &x = back_cast();
+ int len = x.length();
+ for (int i = 0; i < len; ++i) {
+ x.set_bit(i, a[i].value());
+ }
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(unsigned int a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, (sc_digit)a, SC_DIGIT_ZERO);
+ // extend with zeros
+ extend_sign_w_(x, 1, false);
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(int a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, (sc_digit)a, SC_DIGIT_ZERO);
+ // extend with sign(a)
+ extend_sign_w_(x, 1, (a < 0));
+ x.clean_tail();
+ return x;
+}
+
+#if defined(SC_LONG_64)
+template <class X>
+inline X &
+sc_proxy<X>::assign_(unsigned long a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, ((sc_digit)a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO);
+ if (x.size() > 1) {
+ set_words_(x, 1, ((sc_digit)(a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
+ SC_DIGIT_ZERO);
+ // extend with zeros
+ extend_sign_w_(x, 2, false);
+ }
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(long a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, ((sc_digit)a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO);
+ if (x.size() > 1) {
+ set_words_(x, 1,
+ ((sc_digit)((uint64)a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
+ SC_DIGIT_ZERO);
+ // extend with sign(a)
+ extend_sign_w_(x, 2, (a < 0));
+ }
+ x.clean_tail();
+ return x;
+}
+
+#else
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(unsigned long a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, (sc_digit)a, SC_DIGIT_ZERO);
+ // extend with zeros
+ extend_sign_w_(x, 1, false);
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(long a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, (sc_digit)a, SC_DIGIT_ZERO);
+ // extend with sign(a)
+ extend_sign_w_(x, 1, (a < 0));
+ x.clean_tail();
+ return x;
+}
+
+#endif
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(uint64 a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, ((sc_digit)a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO);
+ if (x.size() > 1) {
+ set_words_(x, 1, ((sc_digit) (a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
+ SC_DIGIT_ZERO );
+ // extend with zeros
+ extend_sign_w_(x, 2, false);
+ }
+ x.clean_tail();
+ return x;
+}
+
+template <class X>
+inline X &
+sc_proxy<X>::assign_(int64 a)
+{
+ X &x = back_cast();
+ set_words_(x, 0, ((sc_digit)a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO);
+ if (x.size() > 1) {
+ set_words_(x, 1,
+ ((sc_digit)((uint64)a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
+ SC_DIGIT_ZERO );
+ // extend with sign(a)
+ extend_sign_w_(x, 2, (a < 0));
+ }
+ x.clean_tail();
+ return x;
+}
+
+// bitwise operators and functions
+
+// bitwise complement
+template <class X>
+inline X &
+sc_proxy<X>::b_not()
+{
+ X &x = back_cast();
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ sc_digit x_dw, x_cw;
+ get_words_(x, i, x_dw, x_cw);
+ x.set_word(i, x_cw | ~x_dw);
+ }
+ x.clean_tail();
+ return x;
+}
+
+// bitwise and
+template <class X, class Y>
+inline X &
+b_and_assign_(sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ X &x = px.back_cast();
+ const Y &y = py.back_cast();
+ sc_assert(x.length() == y.length());
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ sc_digit x_dw, x_cw, y_dw, y_cw;
+ get_words_(x, i, x_dw, x_cw);
+ get_words_(y, i, y_dw, y_cw);
+ sc_digit cw = (x_dw & y_cw) | (x_cw & y_dw) | (x_cw & y_cw);
+ sc_digit dw = cw | (x_dw & y_dw);
+ set_words_(x, i, dw, cw);
+ }
+ // tail cleaning not needed
+ return x;
+}
+
+// bitwise or
+template <class X, class Y>
+inline X &
+b_or_assign_(sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ X &x = px.back_cast();
+ const Y &y = py.back_cast();
+ sc_assert(x.length() == y.length());
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ sc_digit x_dw, x_cw, y_dw, y_cw;
+ get_words_(x, i, x_dw, x_cw);
+ get_words_(y, i, y_dw, y_cw);
+ sc_digit cw = (x_cw & y_cw) | (x_cw & ~y_dw) | (~x_dw & y_cw);
+ sc_digit dw = cw | x_dw | y_dw;
+ set_words_(x, i, dw, cw);
+ }
+ // tail cleaning not needed
+ return x;
+}
+
+// bitwise xor
+template <class X, class Y>
+inline X &
+b_xor_assign_(sc_proxy<X> &a, const sc_proxy<Y> &b)
+{
+ X &x = a.back_cast();
+ const Y &y = b.back_cast();
+ sc_assert(x.length() == y.length());
+ int sz = x.size();
+ for (int i = 0; i < sz; ++i) {
+ sc_digit x_dw, x_cw, y_dw, y_cw;
+ get_words_(x, i, x_dw, x_cw);
+ get_words_(y, i, y_dw, y_cw);
+ sc_digit cw = x_cw | y_cw;
+ sc_digit dw = cw | (x_dw ^ y_dw);
+ set_words_( x, i, dw, cw );
+ }
+ // tail cleaning not needed
+ return x;
+}
+
+// bitwise left shift
+template <class X>
+inline X &
+sc_proxy<X>::operator <<= (int n)
+{
+ X &x = back_cast();
+ if (n < 0) {
+ sc_proxy_out_of_bounds("left shift operation is only allowed with "
+ "positive shift values, shift value = ", n);
+ return x;
+ }
+ if (n >= x.length()) {
+ extend_sign_w_(x, 0, false);
+ // no tail cleaning needed
+ return x;
+ }
+ int sz = x.size();
+ int wn = n / SC_DIGIT_SIZE;
+ int bn = n % SC_DIGIT_SIZE;
+ if (wn != 0) {
+ // shift words
+ int i = sz - 1;
+ for (; i >= wn; --i) {
+ set_words_(x, i, x.get_word(i - wn), x.get_cword(i - wn));
+ }
+ for (; i >= 0; --i) {
+ set_words_(x, i, SC_DIGIT_ZERO, SC_DIGIT_ZERO);
+ }
+ }
+ if (bn != 0) {
+ // shift bits
+ for (int i = sz - 1; i >= 1; --i) {
+ sc_digit x_dw, x_cw;
+ get_words_(x, i, x_dw, x_cw);
+ x_dw <<= bn;
+ x_dw |= x.get_word(i - 1) >> (SC_DIGIT_SIZE - bn);
+ x_cw <<= bn;
+ x_cw |= x.get_cword(i - 1) >> (SC_DIGIT_SIZE - bn);
+ set_words_(x, i, x_dw, x_cw);
+ }
+ sc_digit x_dw, x_cw;
+ get_words_(x, 0, x_dw, x_cw);
+ x_dw <<= bn;
+ x_cw <<= bn;
+ set_words_(x, 0, x_dw, x_cw);
+ }
+ x.clean_tail();
+ return x;
+}
+
+// bitwise right shift
+template <class X>
+inline X &
+sc_proxy<X>::operator >>= (int n)
+{
+ X &x = back_cast();
+ if (n < 0) {
+ sc_proxy_out_of_bounds("right shift operation is only allowed with "
+ "positive shift values, shift value = ", n);
+ return x;
+ }
+ if (n >= x.length()) {
+ extend_sign_w_(x, 0, false);
+ // no tail cleaning needed
+ return x;
+ }
+ int sz = x.size();
+ int wn = n / SC_DIGIT_SIZE;
+ int bn = n % SC_DIGIT_SIZE;
+ if (wn != 0) {
+ // shift words
+ int i = 0;
+ for (; i < (sz - wn); ++i) {
+ set_words_(x, i, x.get_word(i + wn), x.get_cword(i + wn));
+ }
+ for (; i < sz; ++i) {
+ set_words_(x, i, SC_DIGIT_ZERO, SC_DIGIT_ZERO);
+ }
+ }
+ if (bn != 0) {
+ // shift bits
+ for (int i = 0; i < (sz - 1); ++i) {
+ sc_digit x_dw, x_cw;
+ get_words_(x, i, x_dw, x_cw);
+ x_dw >>= bn;
+ x_dw |= x.get_word(i + 1) << (SC_DIGIT_SIZE - bn);
+ x_cw >>= bn;
+ x_cw |= x.get_cword(i + 1) << (SC_DIGIT_SIZE - bn);
+ set_words_(x, i, x_dw, x_cw);
+ }
+ sc_digit x_dw, x_cw;
+ get_words_(x, sz - 1, x_dw, x_cw);
+ x_dw >>= bn;
+ x_cw >>= bn;
+ set_words_(x, sz - 1, x_dw, x_cw);
+ }
+ x.clean_tail();
+ return x;
+}
+
+// bitwise left rotate
+template <class X>
+inline const sc_lv_base lrotate(const sc_proxy<X> &x, int n);
+
+// bitwise right rotate
+template <class X>
+inline const sc_lv_base rrotate(const sc_proxy<X>& x, int n);
+
+// bitwise reverse
+template <class X>
+inline X &
+sc_proxy<X>::reverse()
+{
+ X &x = back_cast();
+ int len = x.length();
+ int half_len = len / 2;
+ for (int i = 0, j = len - 1; i < half_len; ++ i, --j) {
+ value_type t = x.get_bit(i);
+ x.set_bit(i, x.get_bit(j));
+ x.set_bit(j, t);
+ }
+ return x;
+}
+
+template <class X>
+inline const sc_lv_base reverse(const sc_proxy<X> &a);
+
+// reduce functions
+template <class X>
+inline typename sc_proxy<X>::value_type
+sc_proxy<X>::and_reduce() const
+{
+ const X &x = back_cast();
+ value_type result = value_type(1);
+ int len = x.length();
+ for (int i = 0; i < len; ++i) {
+ result = sc_logic::and_table[result][x.get_bit(i)];
+ }
+ return result;
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+sc_proxy<X>::or_reduce() const
+{
+ const X &x = back_cast();
+ value_type result = value_type(0);
+ int len = x.length();
+ for (int i = 0; i < len; ++i) {
+ result = sc_logic::or_table[result][x.get_bit(i)];
+ }
+ return result;
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+sc_proxy<X>::xor_reduce() const
+{
+ const X &x = back_cast();
+ value_type result = value_type(0);
+ int len = x.length();
+ for (int i = 0; i < len; ++i) {
+ result = sc_logic::xor_table[result][x.get_bit(i)];
+ }
+ return result;
+}
+
+// relational operators
+template <class X, class Y>
+inline bool
+operator != (const sc_proxy<X> &px, const sc_proxy<Y> &py)
+{
+ return !(px == py);
+}
+
+
+#define DEFN_REL_OP_T(tp) \
+template <class X> \
+inline bool operator == (tp b, const sc_proxy<X> &px) { return (px == b); } \
+ \
+template <class X> \
+inline bool operator != (const sc_proxy<X> &px, tp b) { return !(px == b); } \
+ \
+template <class X> \
+inline bool operator != (tp b, const sc_proxy<X> &px) { return !(px == b); }
+
+DEFN_REL_OP_T(const char *)
+DEFN_REL_OP_T(const bool *)
+DEFN_REL_OP_T(const sc_logic *)
+DEFN_REL_OP_T(const sc_unsigned &)
+DEFN_REL_OP_T(const sc_signed &)
+DEFN_REL_OP_T(const sc_uint_base &)
+DEFN_REL_OP_T(const sc_int_base &)
+DEFN_REL_OP_T(unsigned long)
+DEFN_REL_OP_T(long)
+DEFN_REL_OP_T(unsigned int)
+DEFN_REL_OP_T(int)
+DEFN_REL_OP_T(uint64)
+DEFN_REL_OP_T(int64)
+
+#undef DEFN_REL_OP_T
+
+// explicit conversions to character string
+template <class X>
+inline const std::string
+sc_proxy<X>::to_string() const
+{
+ const X &x = back_cast();
+ int len = x.length();
+ std::string s; // (len + 1);
+ for (int i = 0; i < len; ++i) {
+ s += sc_logic::logic_to_char[x.get_bit(len - i - 1)];
+ }
+ return s;
+}
+
+template <class X>
+inline const std::string
+sc_proxy<X>::to_string(sc_numrep numrep) const
+{
+ return convert_to_fmt(to_string(), numrep, true);
+}
+
+template <class X>
+inline const std::string
+sc_proxy<X>::to_string(sc_numrep numrep, bool w_prefix) const
+{
+ return convert_to_fmt(to_string(), numrep, w_prefix);
+}
+
+// other methods
+template <class X>
+inline void
+sc_proxy<X>::scan(::std::istream &is)
+{
+ std::string s;
+ is >> s;
+ back_cast() = s.c_str();
+}
+
+template <class X>
+inline void
+sc_proxy<X>::check_bounds(int n) const // check if bit n accessible
+{
+ if (n < 0 || n >= back_cast().length()) {
+ sc_proxy_out_of_bounds(NULL, n);
+ sc_core::sc_abort(); // can't recover from here
+ }
+}
+
+template <class X>
+inline void
+sc_proxy<X>::check_wbounds(int n) const // check if word n accessible
+{
+ if (n < 0 || n >= back_cast().size()) {
+ sc_proxy_out_of_bounds(NULL, n);
+ sc_core::sc_abort(); // can't recover from here
+ }
+}
+
+template <class X>
+inline sc_digit
+sc_proxy<X>::to_anything_unsigned() const
+{
+ // only 0 word is returned
+ // can't convert logic values other than 0 and 1
+ const X &x = back_cast();
+ int len = x.length();
+ if (x.get_cword(0) != SC_DIGIT_ZERO) {
+ SC_REPORT_WARNING("vector contains 4-value logic", 0);
+ }
+ sc_digit w = x.get_word(0);
+ if (len >= SC_DIGIT_SIZE) {
+ return w;
+ }
+ return (w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)));
+}
+
+template <class X>
+inline uint64
+sc_proxy<X>::to_uint64() const
+{
+ // words 1 and 0 returned.
+ // can't convert logic values other than 0 and 1
+ const X &x = back_cast();
+ int len = x.length();
+ if (x.get_cword(0) != SC_DIGIT_ZERO) {
+ SC_REPORT_WARNING("vector contains 4-value logic", 0);
+ }
+ uint64 w = x.get_word(0);
+ if (len > SC_DIGIT_SIZE) {
+ if (x.get_cword(1) != SC_DIGIT_ZERO) {
+ SC_REPORT_WARNING("vector contains 4-value logic", 0);
+ }
+ uint64 w1 = x.get_word(1);
+ w = w | (w1 << SC_DIGIT_SIZE);
+ return w;
+ } else if (len == SC_DIGIT_SIZE) {
+ return w;
+ } else {
+ return (w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)));
+ }
+}
+
+template <class X>
+inline int64
+sc_proxy<X>::to_anything_signed() const
+{
+ const X &x = back_cast();
+ int len = x.length();
+ int64 w = 0;
+
+ if (len > SC_DIGIT_SIZE) {
+ if (x.get_cword(1) != SC_DIGIT_ZERO)
+ SC_REPORT_WARNING("vector contains 4-value logic", 0);
+ w = x.get_word(1);
+ }
+ if (x.get_cword(0) != SC_DIGIT_ZERO)
+ SC_REPORT_WARNING("vector contains 4-value logic", 0);
+ w = (w << SC_DIGIT_SIZE) | x.get_word(0);
+ if (len >= 64) {
+ return w;
+ }
+
+ uint64 zero = 0;
+ value_type sgn = x.get_bit(len - 1);
+ if (sgn == 0) {
+ return (int64)(w & (~zero >> (64 - len)));
+ } else {
+ return (int64)(w | (~zero << len));
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+
+// functional notation for the reduce methods
+template <class X>
+inline typename sc_proxy<X>::value_type
+and_reduce(const sc_proxy<X> &a)
+{
+ return a.and_reduce();
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+nand_reduce(const sc_proxy<X> &a)
+{
+ return a.nand_reduce();
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+or_reduce(const sc_proxy<X> &a)
+{
+ return a.or_reduce();
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+nor_reduce(const sc_proxy<X> &a)
+{
+ return a.nor_reduce();
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+xor_reduce(const sc_proxy<X> &a)
+{
+ return a.xor_reduce();
+}
+
+template <class X>
+inline typename sc_proxy<X>::value_type
+xnor_reduce(const sc_proxy<X> &a)
+{
+ return a.xnor_reduce();
+}
+
+// ----------------------------------------------------------------------------
+
+template <class X>
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_proxy<X> &a)
+{
+ a.print(os);
+ return os;
+}
+
+template <class X>
+inline ::std::istream &
+operator >> (::std::istream &is, sc_proxy<X> &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_BIT_SC_PROXY_HH__
diff --git a/src/systemc/ext/dt/fx/_fx.hh b/src/systemc/ext/dt/fx/_fx.hh
new file mode 100644
index 000000000..e21acb657
--- /dev/null
+++ b/src/systemc/ext/dt/fx/_fx.hh
@@ -0,0 +1,53 @@
+/*
+ * 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_CORE_DT_FX__FX_HH__
+#define __SYSTEMC_EXT_CORE_DT_FX__FX_HH__
+
+#include "sc_context.hh"
+#include "sc_fix.hh"
+#include "sc_fixed.hh"
+#include "sc_fxcast_switch.hh"
+#include "sc_fxdefs.hh"
+#include "sc_fxnum.hh"
+#include "sc_fxnum_observer.hh"
+#include "sc_fxtype_params.hh"
+#include "sc_fxval.hh"
+#include "sc_fxval_observer.hh"
+#include "sc_ufix.hh"
+#include "sc_ufixed.hh"
+#include "scfx_ieee.hh"
+#include "scfx_mant.hh"
+#include "scfx_other_defs.hh"
+#include "scfx_params.hh"
+#include "scfx_pow10.hh"
+#include "scfx_rep.hh"
+#include "scfx_utils.hh"
+
+#endif //__SYSTEMC_EXT_CORE_DT_FX__FX_HH__
diff --git a/src/systemc/ext/dt/fx/_using.hh b/src/systemc/ext/dt/fx/_using.hh
new file mode 100644
index 000000000..d6b17f386
--- /dev/null
+++ b/src/systemc/ext/dt/fx/_using.hh
@@ -0,0 +1,76 @@
+/*
+ * 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_FX__USING_HH__
+#define __SYSTEMC_EXT_DT_FX__USING_HH__
+
+#include "_fx.hh"
+
+using sc_dt::sc_fxnum;
+using sc_dt::sc_fxnum_bitref;
+using sc_dt::sc_fxnum_fast;
+using sc_dt::sc_fix;
+using sc_dt::sc_fix_fast;
+using sc_dt::sc_ufix;
+using sc_dt::sc_ufix_fast;
+using sc_dt::sc_fixed;
+using sc_dt::sc_fixed_fast;
+using sc_dt::sc_ufixed;
+using sc_dt::sc_ufixed_fast;
+using sc_dt::sc_fxval;
+using sc_dt::sc_fxval_fast;
+using sc_dt::sc_fxcast_switch;
+using sc_dt::sc_fxcast_context;
+using sc_dt::sc_fxtype_params;
+using sc_dt::sc_fxtype_context;
+using sc_dt::sc_q_mode;
+using sc_dt::SC_RND;
+using sc_dt::SC_RND_ZERO;
+using sc_dt::SC_RND_MIN_INF;
+using sc_dt::SC_RND_INF;
+using sc_dt::SC_RND_CONV;
+using sc_dt::SC_TRN;
+using sc_dt::SC_TRN_ZERO;
+using sc_dt::sc_o_mode;
+using sc_dt::SC_SAT;
+using sc_dt::SC_SAT_ZERO;
+using sc_dt::SC_SAT_SYM;
+using sc_dt::SC_WRAP;
+using sc_dt::SC_WRAP_SM;
+using sc_dt::sc_switch;
+using sc_dt::SC_OFF;
+using sc_dt::SC_ON;
+using sc_dt::sc_fmt;
+using sc_dt::SC_F;
+using sc_dt::SC_E;
+using sc_dt::sc_context_begin;
+using sc_dt::SC_NOW;
+using sc_dt::SC_LATER;
+
+#endif //__SYSTEMC_EXT_DT_FX__USING_HH__
diff --git a/src/systemc/ext/dt/fx/sc_context.hh b/src/systemc/ext/dt/fx/sc_context.hh
new file mode 100644
index 000000000..075d38401
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_context.hh
@@ -0,0 +1,281 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_context.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_context.h,v $
+// Revision 1.2 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.5 2006/05/26 20:36:52 acg
+// Andy Goodrich: added a using for sc_core::default_ptr_hash_fn to keep HP
+// aCC happy.
+//
+// Revision 1.4 2006/03/21 00:00:31 acg
+// Andy Goodrich: changed name of sc_get_current_process_base() to be
+// sc_get_current_process_b() since its returning an sc_process_b instance.
+//
+// Revision 1.3 2006/01/13 18:53:57 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_CONTEXT_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_CONTEXT_HH__
+
+#include <map>
+
+#include "../../core/sc_process_handle.hh"
+#include "../../utils/sc_report_handler.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_without_context;
+template <class T>
+class sc_global;
+template <class T>
+class sc_context;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_without_context
+//
+// Empty class that is used for its type only.
+// ----------------------------------------------------------------------------
+
+class sc_without_context {};
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_global
+//
+// Template global variable class; singleton; co-routine safe.
+// ----------------------------------------------------------------------------
+
+template <class T>
+class sc_global
+{
+ sc_global();
+ void update();
+
+ public:
+ static sc_global<T>* instance();
+ const T*& value_ptr();
+
+ private:
+ static sc_global<T> *m_instance;
+
+ std::map<void *, const T *> m_map;
+ void *m_proc; // context (current process or NULL)
+ const T *m_value_ptr;
+};
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_context_begin
+//
+// Enumeration of context begin options.
+// ----------------------------------------------------------------------------
+
+enum sc_context_begin
+{
+ SC_NOW,
+ SC_LATER
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_context
+//
+// Template context class; co-routine safe.
+// ----------------------------------------------------------------------------
+
+template <class T>
+class sc_context
+{
+ // disabled
+ sc_context(const sc_context<T> &);
+ void *operator new(std::size_t);
+
+ public:
+ explicit sc_context(const T &, sc_context_begin=SC_NOW);
+ ~sc_context();
+
+ void begin();
+ void end();
+
+ static const T &default_value();
+ const T &value() const;
+
+ private:
+ sc_context &operator = (const sc_context &) /* = delete */;
+
+ const T m_value;
+ const T *&m_def_value_ptr;
+ const T *m_old_value_ptr;
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_global
+//
+// Template global variable class; singleton; co-routine safe.
+// ----------------------------------------------------------------------------
+
+template <class T>
+sc_global<T> *sc_global<T>::m_instance = 0;
+
+template <class T>
+inline sc_global<T>::sc_global() : m_map(),
+ // use &m_instance as unique "non-process" key (NULL denotes 'sc_main'
+ // context)
+ m_proc(&m_instance), m_value_ptr(0)
+{}
+
+
+template <class T>
+inline void
+sc_global<T>::update()
+{
+ void *p = (::sc_gem5::Process *)sc_core::sc_get_current_process_handle();
+ if (p != m_proc) {
+ const T *vp = m_map[p];
+ if (vp == 0) {
+ vp = new T(sc_without_context());
+ m_map.emplace(p, vp);
+ }
+ m_proc = p;
+ m_value_ptr = vp;
+ }
+}
+
+
+template <class T>
+inline sc_global<T> *
+sc_global<T>::instance()
+{
+ if (m_instance == 0) {
+ m_instance = new sc_global<T>;
+ }
+ return m_instance;
+}
+
+
+template <class T>
+inline const T *&
+sc_global<T>::value_ptr()
+{
+ update();
+ return m_value_ptr;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_context
+//
+// Template context class; co-routine safe.
+// ----------------------------------------------------------------------------
+
+template <class T>
+inline sc_context<T>::sc_context(const T &value_, sc_context_begin begin_) :
+ m_value(value_),
+ m_def_value_ptr(sc_global<T>::instance()->value_ptr()),
+ m_old_value_ptr(0)
+{
+ if (begin_ == SC_NOW) {
+ m_old_value_ptr = m_def_value_ptr;
+ m_def_value_ptr = &m_value;
+ }
+}
+
+template <class T>
+inline sc_context<T>::~sc_context()
+{
+ if (m_old_value_ptr != 0) {
+ m_def_value_ptr = m_old_value_ptr;
+ m_old_value_ptr = 0;
+ }
+}
+
+
+template <class T>
+inline void
+sc_context<T>::begin()
+{
+ if (m_old_value_ptr == 0) {
+ m_old_value_ptr = m_def_value_ptr;
+ m_def_value_ptr = &m_value;
+ } else {
+ SC_REPORT_ERROR("context begin failed", 0);
+ }
+}
+
+template <class T>
+inline void
+sc_context<T>::end()
+{
+ if (m_old_value_ptr != 0) {
+ m_def_value_ptr = m_old_value_ptr;
+ m_old_value_ptr = 0;
+ } else {
+ SC_REPORT_ERROR("context end failed", 0);
+ }
+}
+
+
+template <class T>
+inline const T &
+sc_context<T>::default_value()
+{
+ return *sc_global<T>::instance()->value_ptr();
+}
+
+template <class T>
+inline const T &
+sc_context<T>::value() const
+{
+ return m_value;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_CONTEXT_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fix.hh b/src/systemc/ext/dt/fx/sc_fix.hh
new file mode 100644
index 000000000..094322578
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fix.hh
@@ -0,0 +1,1343 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fix.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fix.h,v $
+// Revision 1.2 2011/01/19 18:57:40 acg
+// Andy Goodrich: changes for IEEE_1666_2011.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:57 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
+
+#include "sc_fxnum.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fix;
+class sc_fix_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fix
+//
+// "Unconstrained" signed fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_fix : public sc_fxnum
+{
+ public:
+ // constructors
+ explicit sc_fix(sc_fxnum_observer * =0);
+ sc_fix(int, int, sc_fxnum_observer * =0);
+ sc_fix(sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
+ sc_fix(sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
+ sc_fix(int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
+ sc_fix(int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
+ explicit sc_fix(const sc_fxcast_switch &, sc_fxnum_observer * =0);
+ sc_fix(int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+ sc_fix(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_fix(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_fix(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_fix(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ explicit sc_fix(const sc_fxtype_params &, sc_fxnum_observer * =0);
+ sc_fix(const sc_fxtype_params &, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T(tp) \
+ sc_fix(tp, int, int, sc_fxnum_observer * =0); \
+ sc_fix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
+ sc_fix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
+ sc_fix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
+ sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
+ sc_fix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_fix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_fix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_fix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_fix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_fix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
+ sc_fix(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_fix(tp, sc_fxnum_observer * =0); \
+ DECL_CTORS_T(tp)
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_fix(tp, sc_fxnum_observer * =0); \
+ DECL_CTORS_T(tp)
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_fix(const sc_fix &);
+
+ // unary bitwise operators
+ const sc_fix operator ~ () const;
+
+ // unary bitwise functions
+ friend void b_not(sc_fix &, const sc_fix &);
+
+ // binary bitwise operators
+ friend const sc_fix operator & (const sc_fix &, const sc_fix &);
+ friend const sc_fix operator & (const sc_fix &, const sc_fix_fast &);
+ friend const sc_fix operator & (const sc_fix_fast &, const sc_fix &);
+ friend const sc_fix operator | (const sc_fix &, const sc_fix &);
+ friend const sc_fix operator | (const sc_fix &, const sc_fix_fast &);
+ friend const sc_fix operator | (const sc_fix_fast &, const sc_fix &);
+ friend const sc_fix operator ^ (const sc_fix &, const sc_fix &);
+ friend const sc_fix operator ^ (const sc_fix &, const sc_fix_fast &);
+ friend const sc_fix operator ^ (const sc_fix_fast&, const sc_fix &);
+
+ // binary bitwise functions
+ friend void b_and(sc_fix &, const sc_fix &, const sc_fix &);
+ friend void b_and(sc_fix &, const sc_fix &, const sc_fix_fast &);
+ friend void b_and(sc_fix &, const sc_fix_fast &, const sc_fix &);
+ friend void b_or(sc_fix &, const sc_fix &, const sc_fix &);
+ friend void b_or(sc_fix &, const sc_fix &, const sc_fix_fast &);
+ friend void b_or(sc_fix &, const sc_fix_fast &, const sc_fix &);
+ friend void b_xor(sc_fix &, const sc_fix &, const sc_fix &);
+ friend void b_xor(sc_fix &, const sc_fix &, const sc_fix_fast &);
+ friend void b_xor(sc_fix &, const sc_fix_fast &, const sc_fix &);
+
+ // assignment operators
+ sc_fix &operator = (const sc_fix &);
+
+#define DECL_ASN_OP_T(op, tp) sc_fix &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_fix &)
+ DECL_ASN_OP_T(&=, const sc_fix_fast &)
+ DECL_ASN_OP_T(|=, const sc_fix &)
+ DECL_ASN_OP_T(|=, const sc_fix_fast &)
+ DECL_ASN_OP_T(^=, const sc_fix &)
+ DECL_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_fix& operator ++ ();
+ sc_fix& operator -- ();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fix_fast
+//
+// "Unconstrained" signed fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_fix_fast : public sc_fxnum_fast
+{
+ public:
+ // constructors
+ explicit sc_fix_fast(sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, sc_fxnum_fast_observer * =0);
+ sc_fix_fast(sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
+ sc_fix_fast(sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, sc_q_mode, sc_o_mode, int,
+ sc_fxnum_fast_observer * =0);
+ explicit sc_fix_fast(const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ explicit sc_fix_fast(const sc_fxtype_params &,
+ sc_fxnum_fast_observer * =0);
+ sc_fix_fast(const sc_fxtype_params &, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T(tp) \
+ sc_fix_fast(tp, int, int, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, int, int, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * = 0); \
+ sc_fix_fast(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * = 0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
+ DECL_CTORS_T(tp)
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
+ DECL_CTORS_T(tp)
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_fix_fast(const sc_fix_fast &);
+
+ // unary bitwise operators
+ const sc_fix_fast operator ~ () const;
+
+ // unary bitwise functions
+ friend void b_not(sc_fix_fast &, const sc_fix_fast &);
+
+ // binary bitwise operators
+ friend const sc_fix_fast operator & (
+ const sc_fix_fast &, const sc_fix_fast &);
+ friend const sc_fix_fast operator ^ (
+ const sc_fix_fast &, const sc_fix_fast &);
+ friend const sc_fix_fast operator | (
+ const sc_fix_fast &, const sc_fix_fast &);
+
+ // binary bitwise functions
+ friend void b_and(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
+ friend void b_or(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
+ friend void b_xor(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
+
+ // assignment operators
+ sc_fix_fast &operator = (const sc_fix_fast &);
+
+#define DECL_ASN_OP_T(op,tp) sc_fix_fast &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_fix &)
+ DECL_ASN_OP_T(&=, const sc_fix_fast &)
+ DECL_ASN_OP_T(|=, const sc_fix &)
+ DECL_ASN_OP_T(|=, const sc_fix_fast &)
+ DECL_ASN_OP_T(^=, const sc_fix &)
+ DECL_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_fix_fast& operator ++ ();
+ sc_fix_fast& operator -- ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fix
+//
+// "Unconstrained" signed fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+// constructors
+inline sc_fix::sc_fix(sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om, nb), SC_TC_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_observer* observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix::sc_fix(const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw,
+ observer_)
+{}
+
+inline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw,
+ observer_)
+{}
+
+inline sc_fix::sc_fix(const sc_fxtype_params &type_params_,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum( type_params_, SC_TC_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix::sc_fix(const sc_fxtype_params &type_params_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(type_params_, SC_TC_, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T_A(tp) \
+inline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
+{}
+
+#define DEFN_CTORS_T_B(tp) \
+inline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, a.type_params(), SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, a.type_params(), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T_A(int)
+DEFN_CTORS_T_A(unsigned int)
+DEFN_CTORS_T_A(long)
+DEFN_CTORS_T_A(unsigned long)
+DEFN_CTORS_T_A(float)
+DEFN_CTORS_T_A(double)
+DEFN_CTORS_T_A(const char *)
+DEFN_CTORS_T_A(const sc_fxval &)
+DEFN_CTORS_T_A(const sc_fxval_fast &)
+DEFN_CTORS_T_B(const sc_fxnum &)
+DEFN_CTORS_T_B(const sc_fxnum_fast &)
+
+DEFN_CTORS_T_A(int64)
+DEFN_CTORS_T_A(uint64)
+DEFN_CTORS_T_A(const sc_int_base &)
+DEFN_CTORS_T_A(const sc_uint_base &)
+DEFN_CTORS_T_A(const sc_signed &)
+DEFN_CTORS_T_A(const sc_unsigned &)
+
+#undef DEFN_CTORS_T_A
+#undef DEFN_CTORS_T_B
+
+// copy constructor
+inline sc_fix::sc_fix(const sc_fix &a) :
+ sc_fxnum(a, a.type_params(), SC_TC_, sc_fxcast_switch(), 0)
+{}
+
+// unary bitwise operators
+inline const sc_fix sc_fix::operator ~ () const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ int iwl_c = iwl();
+ int wl_c = wl();
+ sc_fix c(wl_c, iwl_c);
+ for (int i = iwl_c - wl_c; i < iwl_c; ++i)
+ c.set_bit(i, !get_bit(i));
+ return sc_fix(c, wl_c, iwl_c);
+}
+
+// unary bitwise functions
+inline void
+b_not(sc_fix &c, const sc_fix &a)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ int iwl_c = c.iwl();
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
+ c.set_bit(i, !a.get_bit(i));
+ c.cast();
+ SC_FXNUM_OBSERVER_WRITE_(c)
+}
+
+// binary bitwise operators
+#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
+inline const sc_fix \
+operator op (const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_a = a.iwl(); \
+ int iwl_b = b.iwl(); \
+ int iwl_c = sc_max(iwl_a, iwl_b); \
+ int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
+ sc_fix c(iwl_c + fwl_c, iwl_c); \
+ for (int i = -fwl_c; i < iwl_c; ++ i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ return sc_fix(c, iwl_c + fwl_c, iwl_c); \
+}
+
+DEFN_BIN_OP_T(&, &&, sc_fix, sc_fix)
+DEFN_BIN_OP_T(&, &&, sc_fix, sc_fix_fast)
+DEFN_BIN_OP_T(&, &&, sc_fix_fast, sc_fix)
+
+DEFN_BIN_OP_T(|, ||, sc_fix, sc_fix)
+DEFN_BIN_OP_T(|, ||, sc_fix, sc_fix_fast)
+DEFN_BIN_OP_T(|, ||, sc_fix_fast, sc_fix)
+
+DEFN_BIN_OP_T(^, !=, sc_fix, sc_fix)
+DEFN_BIN_OP_T(^, !=, sc_fix, sc_fix_fast)
+DEFN_BIN_OP_T(^, !=, sc_fix_fast, sc_fix)
+
+#undef DEFN_BIN_OP_T
+
+// binary bitwise functions
+#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
+inline void \
+fnc (sc_fix &c, const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_c = c.iwl(); \
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+}
+
+DEFN_BIN_FNC_T(b_and, &&, sc_fix, sc_fix)
+DEFN_BIN_FNC_T(b_and, &&, sc_fix, sc_fix_fast)
+DEFN_BIN_FNC_T(b_and, &&, sc_fix_fast, sc_fix)
+
+DEFN_BIN_FNC_T(b_or, ||, sc_fix, sc_fix)
+DEFN_BIN_FNC_T(b_or, ||, sc_fix, sc_fix_fast)
+DEFN_BIN_FNC_T(b_or, ||, sc_fix_fast, sc_fix)
+
+DEFN_BIN_FNC_T(b_xor, !=, sc_fix, sc_fix)
+DEFN_BIN_FNC_T(b_xor, !=, sc_fix, sc_fix_fast)
+DEFN_BIN_FNC_T(b_xor, !=, sc_fix_fast, sc_fix)
+
+#undef DEFN_BIN_FNC_T
+
+// assignment operators
+inline
+sc_fix &
+sc_fix::operator = (const sc_fix &a)
+{
+ sc_fxnum::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fix & \
+sc_fix::operator op (tp a) \
+{ \
+ sc_fxnum::operator op(a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+#define DEFN_ASN_OP_T(op, op2, tp) \
+inline sc_fix & \
+sc_fix::operator op (const tp &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(*this) \
+ b.observer_read(); \
+ int iwl_c = iwl(); \
+ for (int i = iwl_c - wl(); i < iwl_c; ++i) \
+ set_bit(i, get_bit(i) op2 b.get_bit(i)); \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(&=, &&, sc_fix)
+DEFN_ASN_OP_T(&=, &&, sc_fix_fast)
+DEFN_ASN_OP_T(|=, ||, sc_fix)
+DEFN_ASN_OP_T(|=, ||, sc_fix_fast)
+DEFN_ASN_OP_T(^=, !=, sc_fix)
+DEFN_ASN_OP_T(^=, !=, sc_fix_fast)
+
+#undef DEFN_ASN_OP_T
+
+// auto-increment and auto-decrement
+inline const sc_fxval
+sc_fix::operator ++ (int)
+{
+ return sc_fxval(sc_fxnum::operator ++ (0));
+}
+
+inline const sc_fxval
+sc_fix::operator -- (int)
+{
+ return sc_fxval(sc_fxnum::operator -- (0));
+}
+
+inline sc_fix &
+sc_fix::operator ++ ()
+{
+ sc_fxnum::operator ++ ();
+ return *this;
+}
+
+inline sc_fix &
+sc_fix::operator -- ()
+{
+ sc_fxnum::operator -- ();
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fix_fast
+//
+// "Unconstrained" signed fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+// constructors
+inline sc_fix_fast::sc_fix_fast(sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(), SC_TC_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_TC_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ int nb, sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw,
+ observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ int nb, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw,
+ observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(const sc_fxtype_params &type_params_,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(type_params_, SC_TC_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_fix_fast::sc_fix_fast(const sc_fxtype_params &type_params_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(type_params_, SC_TC_, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T_A(tp) \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_ ) : \
+ sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
+ observer_ ) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_ ) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, \
+ observer_ ) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, \
+ observer_ ) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_) \
+{}
+
+#define DEFN_CTORS_T_B(tp) \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, a.type_params(), SC_TC_, sc_fxcast_switch(), \
+ observer_ ) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
+ SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
+ SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, a.type_params(), SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
+ SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
+ SC_TC_, cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
+ sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_ ) \
+{}
+
+DEFN_CTORS_T_A(int)
+DEFN_CTORS_T_A(unsigned int)
+DEFN_CTORS_T_A(long)
+DEFN_CTORS_T_A(unsigned long)
+DEFN_CTORS_T_A(float)
+DEFN_CTORS_T_A(double)
+DEFN_CTORS_T_A(const char *)
+DEFN_CTORS_T_A(const sc_fxval &)
+DEFN_CTORS_T_A(const sc_fxval_fast &)
+DEFN_CTORS_T_B(const sc_fxnum &)
+DEFN_CTORS_T_B(const sc_fxnum_fast &)
+
+DEFN_CTORS_T_A(int64)
+DEFN_CTORS_T_A(uint64)
+DEFN_CTORS_T_A(const sc_int_base &)
+DEFN_CTORS_T_A(const sc_uint_base &)
+DEFN_CTORS_T_A(const sc_signed &)
+DEFN_CTORS_T_A(const sc_unsigned &)
+
+#undef DEFN_CTORS_T_A
+#undef DEFN_CTORS_T_B
+
+// copy constructor
+inline sc_fix_fast::sc_fix_fast(const sc_fix_fast &a) :
+ sc_fxnum_fast(a, a.type_params(), SC_TC_, sc_fxcast_switch(), 0)
+{}
+
+// unary bitwise operators
+inline const sc_fix_fast
+sc_fix_fast::operator ~ () const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ int iwl_c = iwl();
+ int wl_c = wl();
+ sc_fix_fast c(wl_c, iwl_c);
+ for (int i = iwl_c - wl_c; i < iwl_c; ++i)
+ c.set_bit(i, !get_bit(i));
+ return sc_fix_fast(c, wl_c, iwl_c);
+}
+
+// unary bitwise functions
+inline void
+b_not(sc_fix_fast &c, const sc_fix_fast &a)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ int iwl_c = c.iwl();
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
+ c.set_bit(i, !a.get_bit(i));
+ c.cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c)
+}
+
+// binary bitwise operators
+#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
+inline const sc_fix_fast \
+operator op (const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_a = a.iwl(); \
+ int iwl_b = b.iwl(); \
+ int iwl_c = sc_max(iwl_a, iwl_b); \
+ int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
+ sc_fix_fast c(iwl_c + fwl_c, iwl_c); \
+ for (int i = -fwl_c; i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ return sc_fix_fast(c, iwl_c + fwl_c, iwl_c); \
+}
+
+DEFN_BIN_OP_T(&, &&, sc_fix_fast, sc_fix_fast)
+DEFN_BIN_OP_T(|, ||, sc_fix_fast, sc_fix_fast)
+DEFN_BIN_OP_T(^, !=, sc_fix_fast, sc_fix_fast)
+
+#undef DEFN_BIN_OP_T
+
+// binary bitwise functions
+#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
+inline void \
+fnc(sc_fix_fast &c, const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_c = c.iwl(); \
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+}
+
+DEFN_BIN_FNC_T(b_and, &&, sc_fix_fast, sc_fix_fast)
+DEFN_BIN_FNC_T(b_or, ||, sc_fix_fast, sc_fix_fast)
+DEFN_BIN_FNC_T(b_xor, !=, sc_fix_fast, sc_fix_fast)
+
+#undef DEFN_BIN_FNC_T
+
+// assignment operators
+inline sc_fix_fast &
+sc_fix_fast::operator = (const sc_fix_fast &a)
+{
+ sc_fxnum_fast::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fix_fast & \
+sc_fix_fast::operator op (tp a) \
+{ \
+ sc_fxnum_fast::operator op(a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+#define DEFN_ASN_OP_T(op, op2, tp) \
+inline sc_fix_fast & \
+sc_fix_fast::operator op (const tp &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(*this) \
+ b.observer_read(); \
+ int iwl_c = iwl(); \
+ for (int i = iwl_c - wl(); i < iwl_c; ++i) \
+ set_bit(i, get_bit(i) op2 b.get_bit(i)); \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(&=, &&, sc_fix)
+DEFN_ASN_OP_T(&=, &&, sc_fix_fast)
+DEFN_ASN_OP_T(|=, ||, sc_fix)
+DEFN_ASN_OP_T(|=, ||, sc_fix_fast)
+DEFN_ASN_OP_T(^=, !=, sc_fix)
+DEFN_ASN_OP_T(^=, !=, sc_fix_fast)
+
+#undef DEFN_ASN_OP_T
+
+// auto-increment and auto-decrement
+inline const sc_fxval_fast
+sc_fix_fast::operator ++ (int)
+{
+ return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
+}
+
+inline const sc_fxval_fast
+sc_fix_fast::operator -- (int)
+{
+ return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
+}
+
+inline sc_fix_fast &
+sc_fix_fast::operator ++ ()
+{
+ sc_fxnum_fast::operator ++ ();
+ return *this;
+}
+
+inline sc_fix_fast &
+sc_fix_fast::operator -- ()
+{
+ sc_fxnum_fast::operator -- ();
+ return *this;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fixed.hh b/src/systemc/ext/dt/fx/sc_fixed.hh
new file mode 100644
index 000000000..2f8e7a52e
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fixed.hh
@@ -0,0 +1,586 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fixed.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fixed.h,v $
+// Revision 1.2 2011/01/19 18:57:40 acg
+// Andy Goodrich: changes for IEEE_1666_2011.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:57 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__
+
+#include "sc_fix.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+class sc_fixed;
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+class sc_fixed_fast;
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_fixed
+//
+// "Constrained" signed fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I,
+ sc_q_mode Q=SC_DEFAULT_Q_MODE_,
+ sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_>
+class sc_fixed : public sc_fix
+{
+ public:
+ // constructors
+ explicit sc_fixed(sc_fxnum_observer * =0);
+ explicit sc_fixed(const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_fixed(tp, sc_fxnum_observer * =0); \
+ sc_fixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_fixed(tp, sc_fxnum_observer * =0); \
+ sc_fixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base&)
+ DECL_CTORS_T_B(const sc_uint_base&)
+ DECL_CTORS_T_B(const sc_signed&)
+ DECL_CTORS_T_B(const sc_unsigned&)
+
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_fixed(const sc_fixed<W, I, Q, O, N> &);
+
+ // assignment operators
+ sc_fixed &operator = (const sc_fixed<W, I, Q, O, N> &);
+
+#define DECL_ASN_OP_T(op, tp) sc_fixed &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base&) \
+ DECL_ASN_OP_T(op, const sc_uint_base&) \
+ DECL_ASN_OP_T(op, const sc_signed&) \
+ DECL_ASN_OP_T(op, const sc_unsigned&)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_fix &)
+ DECL_ASN_OP_T(&=, const sc_fix_fast &)
+ DECL_ASN_OP_T(|=, const sc_fix &)
+ DECL_ASN_OP_T(|=, const sc_fix_fast &)
+ DECL_ASN_OP_T(^=, const sc_fix &)
+ DECL_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_fixed & operator ++ ();
+ sc_fixed & operator -- ();
+};
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_fixed_fast
+//
+// "Constrained" signed fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I,
+ sc_q_mode Q=SC_DEFAULT_Q_MODE_,
+ sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_>
+class sc_fixed_fast : public sc_fix_fast
+{
+ public:
+ // constructors
+ explicit sc_fixed_fast(sc_fxnum_fast_observer * =0);
+ explicit sc_fixed_fast(const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_fixed_fast(tp, sc_fxnum_fast_observer * =0); \
+ sc_fixed_fast(tp, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_fixed_fast(tp, sc_fxnum_fast_observer * =0); \
+ sc_fixed_fast(tp, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0);
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_fixed_fast(const sc_fixed_fast<W, I, Q, O, N> &);
+
+ // assignment operators
+ sc_fixed_fast &operator = (const sc_fixed_fast<W, I, Q, O, N> &);
+
+#define DECL_ASN_OP_T(op, tp) sc_fixed_fast &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_fix &)
+ DECL_ASN_OP_T(&=, const sc_fix_fast &)
+ DECL_ASN_OP_T(|=, const sc_fix &)
+ DECL_ASN_OP_T(|=, const sc_fix_fast &)
+ DECL_ASN_OP_T(^=, const sc_fix &)
+ DECL_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_fixed_fast& operator ++ ();
+ sc_fixed_fast& operator -- ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_fixed
+//
+// "Constrained" signed fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N>::sc_fixed(sc_fxnum_observer *observer_) :
+ sc_fix(W, I, Q, O, N, observer_)
+{}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N>::sc_fixed(
+ const sc_fxcast_switch &cast_sw, sc_fxnum_observer *observer_) :
+ sc_fix(W, I, Q, O, N, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T(tp) \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed<W, I, Q, O, N>::sc_fixed( \
+ tp a, sc_fxnum_observer* observer_) : \
+ sc_fix(a, W, I, Q, O, N, observer_) \
+{} \
+ \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed<W, I, Q, O, N>::sc_fixed( \
+ tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fix(a, W, I, Q, O, N, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T(int)
+DEFN_CTORS_T(unsigned int)
+DEFN_CTORS_T(long)
+DEFN_CTORS_T(unsigned long)
+DEFN_CTORS_T(float)
+DEFN_CTORS_T(double)
+DEFN_CTORS_T(const char *)
+DEFN_CTORS_T(const sc_fxval &)
+DEFN_CTORS_T(const sc_fxval_fast &)
+DEFN_CTORS_T(const sc_fxnum &)
+DEFN_CTORS_T(const sc_fxnum_fast &)
+
+DEFN_CTORS_T(int64)
+DEFN_CTORS_T(uint64)
+DEFN_CTORS_T(const sc_int_base &)
+DEFN_CTORS_T(const sc_uint_base &)
+DEFN_CTORS_T(const sc_signed &)
+DEFN_CTORS_T(const sc_unsigned &)
+
+#undef DEFN_CTORS_T
+
+// copy constructor
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N>::sc_fixed(const sc_fixed<W, I, Q, O, N> &a) :
+ sc_fix(a, W, I, Q, O, N)
+{}
+
+// assignment operators
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N> &
+sc_fixed<W, I, Q, O, N>::operator = (const sc_fixed<W, I, Q, O, N> &a)
+{
+ sc_fix::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed<W, I, Q, O, N> & \
+sc_fixed<W, I, Q, O, N>::operator op (tp a) \
+{ \
+ sc_fix::operator op (a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+DEFN_ASN_OP_T(&=, const sc_fix &)
+DEFN_ASN_OP_T(&=, const sc_fix_fast &)
+DEFN_ASN_OP_T(|=, const sc_fix &)
+DEFN_ASN_OP_T(|=, const sc_fix_fast &)
+DEFN_ASN_OP_T(^=, const sc_fix &)
+DEFN_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+// auto-increment and auto-decrement
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval
+sc_fixed<W, I, Q, O, N>::operator ++ (int)
+{
+ return sc_fxval(sc_fix::operator ++ (0));
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval
+sc_fixed<W, I, Q, O, N>::operator -- (int)
+{
+ return sc_fxval(sc_fix::operator -- (0));
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N> &
+sc_fixed<W, I, Q, O, N>::operator ++ ()
+{
+ sc_fix::operator ++ ();
+ return *this;
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed<W, I, Q, O, N> &
+sc_fixed<W, I, Q, O, N>::operator -- ()
+{
+ sc_fix::operator -- ();
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_fixed_fast
+//
+// "Constrained" signed fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast(
+ sc_fxnum_fast_observer *observer_) :
+ sc_fix_fast(W, I, Q, O, N, observer_)
+{}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast(
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
+ sc_fix_fast(W, I, Q, O, N, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T(tp) \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( \
+ tp a, sc_fxnum_fast_observer *observer_) : \
+ sc_fix_fast(a, W, I, Q, O, N, observer_) \
+{} \
+ \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( \
+ tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fix_fast(a, W, I, Q, O, N, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T(int)
+DEFN_CTORS_T(unsigned int)
+DEFN_CTORS_T(long)
+DEFN_CTORS_T(unsigned long)
+DEFN_CTORS_T(float)
+DEFN_CTORS_T(double)
+DEFN_CTORS_T(const char *)
+DEFN_CTORS_T(const sc_fxval &)
+DEFN_CTORS_T(const sc_fxval_fast &)
+DEFN_CTORS_T(const sc_fxnum &)
+DEFN_CTORS_T(const sc_fxnum_fast &)
+
+DEFN_CTORS_T(int64)
+DEFN_CTORS_T(uint64)
+DEFN_CTORS_T(const sc_int_base &)
+DEFN_CTORS_T(const sc_uint_base &)
+DEFN_CTORS_T(const sc_signed &)
+DEFN_CTORS_T(const sc_unsigned &)
+
+#undef DEFN_CTORS_T
+
+// copy constructor
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast(
+ const sc_fixed_fast<W, I, Q, O, N> &a) : sc_fix_fast(a, W, I, Q, O, N)
+{}
+
+// assignment operators
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N> &
+sc_fixed_fast<W, I, Q, O, N>::operator = (
+ const sc_fixed_fast<W, I, Q, O, N> &a)
+{
+ sc_fix_fast::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_fixed_fast<W, I, Q, O, N> & \
+sc_fixed_fast<W, I, Q, O, N>::operator op (tp a) \
+{ \
+ sc_fix_fast::operator op (a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+DEFN_ASN_OP_T(&=, const sc_fix &)
+DEFN_ASN_OP_T(&=, const sc_fix_fast &)
+DEFN_ASN_OP_T(|=, const sc_fix &)
+DEFN_ASN_OP_T(|=, const sc_fix_fast &)
+DEFN_ASN_OP_T(^=, const sc_fix &)
+DEFN_ASN_OP_T(^=, const sc_fix_fast &)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+// auto-increment and auto-decrement
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval_fast
+sc_fixed_fast<W, I, Q, O, N>::operator ++ (int)
+{
+ return sc_fxval_fast(sc_fix_fast::operator ++ (0));
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval_fast
+sc_fixed_fast<W, I, Q, O, N>::operator -- (int)
+{
+ return sc_fxval_fast(sc_fix_fast::operator -- (0));
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N> &
+sc_fixed_fast<W, I, Q, O, N>::operator ++ ()
+{
+ sc_fix_fast::operator ++ ();
+ return *this;
+}
+
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_fixed_fast<W, I, Q, O, N> &
+sc_fixed_fast<W, I, Q, O, N>::operator -- ()
+{
+ sc_fix_fast::operator -- ();
+ return *this;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxcast_switch.hh b/src/systemc/ext/dt/fx/sc_fxcast_switch.hh
new file mode 100644
index 000000000..c1c6c153c
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxcast_switch.hh
@@ -0,0 +1,159 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxcast_switch.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxcast_switch.h,v $
+// Revision 1.2 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:57 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_HH__
+
+#include <iostream>
+
+#include "sc_context.hh"
+#include "sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxcast_switch;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxcast_switch
+//
+// Fixed-point cast switch class.
+// ----------------------------------------------------------------------------
+
+class sc_fxcast_switch
+{
+ public:
+ sc_fxcast_switch();
+ sc_fxcast_switch(sc_switch);
+ sc_fxcast_switch(const sc_fxcast_switch &);
+ explicit sc_fxcast_switch(sc_without_context);
+
+ sc_fxcast_switch &operator = (const sc_fxcast_switch &);
+
+ friend bool operator == (const sc_fxcast_switch &,
+ const sc_fxcast_switch &);
+ friend bool operator != (const sc_fxcast_switch &,
+ const sc_fxcast_switch &);
+
+ const std::string to_string() const;
+
+ void print(::std::ostream & =::std::cout) const;
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ sc_switch m_sw;
+};
+
+} // namespace sc_dt
+
+// ----------------------------------------------------------------------------
+// TYPEDEF : sc_fxcast_context
+//
+// Context type for the fixed-point cast switch parameter.
+// ----------------------------------------------------------------------------
+
+namespace sc_dt
+{
+
+extern template class sc_global<sc_fxcast_switch>;
+extern template class sc_context<sc_fxcast_switch>;
+
+typedef sc_context<sc_fxcast_switch> sc_fxcast_context;
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline sc_fxcast_switch::sc_fxcast_switch() : m_sw()
+{
+ *this = sc_fxcast_context::default_value();
+}
+
+inline sc_fxcast_switch::sc_fxcast_switch(sc_switch sw_) : m_sw( sw_ ) {}
+
+inline sc_fxcast_switch::sc_fxcast_switch(const sc_fxcast_switch &a) :
+ m_sw(a.m_sw)
+{}
+
+inline sc_fxcast_switch::sc_fxcast_switch(sc_without_context) :
+ m_sw(SC_DEFAULT_CAST_SWITCH_)
+{}
+
+inline sc_fxcast_switch &
+sc_fxcast_switch::operator = (const sc_fxcast_switch &a)
+{
+ if (&a != this) {
+ m_sw = a.m_sw;
+ }
+ return *this;
+}
+
+inline bool
+operator == (const sc_fxcast_switch &a, const sc_fxcast_switch &b)
+{
+ return (a.m_sw == b.m_sw);
+}
+
+inline bool
+operator != (const sc_fxcast_switch &a, const sc_fxcast_switch &b)
+{
+ return (a.m_sw != b.m_sw);
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxcast_switch &a)
+{
+ a.print(os);
+ return os;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXCAST_SWITCH_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxdefs.hh b/src/systemc/ext/dt/fx/sc_fxdefs.hh
new file mode 100644
index 000000000..0d76df6e2
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxdefs.hh
@@ -0,0 +1,283 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxdefs.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxdefs.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:57 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXDEFS_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXDEFS_HH__
+
+#include "../../utils/sc_report_handler.hh"
+#include "../int/sc_nbutils.hh"
+
+namespace sc_dt
+{
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_enc
+//
+// Enumeration of sign encodings.
+// ----------------------------------------------------------------------------
+
+enum sc_enc
+{
+ SC_TC_, // two's complement
+ SC_US_ // unsigned
+};
+
+const std::string to_string(sc_enc);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_enc enc)
+{
+ return os << to_string(enc);
+}
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_q_mode
+//
+// Enumeration of quantization modes.
+// ----------------------------------------------------------------------------
+
+enum sc_q_mode
+{
+ SC_RND, // rounding to plus infinity
+ SC_RND_ZERO, // rounding to zero
+ SC_RND_MIN_INF, // rounding to minus infinity
+ SC_RND_INF, // rounding to infinity
+ SC_RND_CONV, // convergent rounding
+ SC_TRN, // truncation
+ SC_TRN_ZERO // truncation to zero
+};
+
+const std::string to_string(sc_q_mode);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_q_mode q_mode)
+{
+ return os << to_string(q_mode);
+}
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_o_mode
+//
+// Enumeration of overflow modes.
+// ----------------------------------------------------------------------------
+
+enum sc_o_mode
+{
+ SC_SAT, // saturation
+ SC_SAT_ZERO, // saturation to zero
+ SC_SAT_SYM, // symmetrical saturation
+ SC_WRAP, // wrap-around (*)
+ SC_WRAP_SM // sign magnitude wrap-around (*)
+};
+
+// (*) uses the number of saturated bits argument, see the documentation.
+
+const std::string to_string( sc_o_mode );
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_o_mode o_mode)
+{
+ return os << to_string(o_mode);
+}
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_switch
+//
+// Enumeration of switch states.
+// ----------------------------------------------------------------------------
+
+enum sc_switch
+{
+ SC_OFF,
+ SC_ON
+};
+
+const std::string to_string(sc_switch);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_switch sw)
+{
+ return os << to_string(sw);
+}
+
+
+// ----------------------------------------------------------------------------
+// ENUM : sc_fmt
+//
+// Enumeration of formats for character string conversion.
+// ----------------------------------------------------------------------------
+
+enum sc_fmt
+{
+ SC_F, // fixed
+ SC_E // scientific
+};
+
+const std::string to_string(sc_fmt);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_fmt fmt)
+{
+ return os << to_string(fmt);
+}
+
+
+// ----------------------------------------------------------------------------
+// Built-in & default fixed-point type parameter values.
+// ----------------------------------------------------------------------------
+
+const int SC_BUILTIN_WL_ = 32;
+const int SC_BUILTIN_IWL_ = 32;
+const sc_q_mode SC_BUILTIN_Q_MODE_ = SC_TRN;
+const sc_o_mode SC_BUILTIN_O_MODE_ = SC_WRAP;
+const int SC_BUILTIN_N_BITS_ = 0;
+
+const int SC_DEFAULT_WL_ = SC_BUILTIN_WL_;
+const int SC_DEFAULT_IWL_ = SC_BUILTIN_IWL_;
+const sc_q_mode SC_DEFAULT_Q_MODE_ = SC_BUILTIN_Q_MODE_;
+const sc_o_mode SC_DEFAULT_O_MODE_ = SC_BUILTIN_O_MODE_;
+const int SC_DEFAULT_N_BITS_ = SC_BUILTIN_N_BITS_;
+
+
+// ----------------------------------------------------------------------------
+// Built-in & default fixed-point cast switch parameter values.
+// ----------------------------------------------------------------------------
+
+const sc_switch SC_BUILTIN_CAST_SWITCH_ = SC_ON;
+const sc_switch SC_DEFAULT_CAST_SWITCH_ = SC_BUILTIN_CAST_SWITCH_;
+
+
+// ----------------------------------------------------------------------------
+// Built-in & default fixed-point value type parameter values.
+// ----------------------------------------------------------------------------
+
+const int SC_BUILTIN_DIV_WL_ = 64;
+const int SC_BUILTIN_CTE_WL_ = 64;
+const int SC_BUILTIN_MAX_WL_ = 1024;
+
+
+#if defined(SC_FXDIV_WL) && (SC_FXDIV_WL > 0)
+const int SC_DEFAULT_DIV_WL_ = SC_FXDIV_WL;
+#else
+const int SC_DEFAULT_DIV_WL_ = SC_BUILTIN_DIV_WL_;
+#endif
+
+#if defined(SC_FXCTE_WL) && (SC_FXCTE_WL > 0)
+const int SC_DEFAULT_CTE_WL_ = SC_FXCTE_WL;
+#else
+const int SC_DEFAULT_CTE_WL_ = SC_BUILTIN_CTE_WL_;
+#endif
+
+#if defined(SC_FXMAX_WL) && (SC_FXMAX_WL > 0 || SC_FXMAX_WL == -1)
+const int SC_DEFAULT_MAX_WL_ = SC_FXMAX_WL;
+#else
+const int SC_DEFAULT_MAX_WL_ = SC_BUILTIN_MAX_WL_;
+#endif
+
+
+// ----------------------------------------------------------------------------
+// Dedicated error reporting and checking.
+// ----------------------------------------------------------------------------
+
+#define SC_ERROR_IF_IMPL_(cnd, id, msg) \
+ do { \
+ if (cnd) { \
+ SC_REPORT_ERROR(id, msg); \
+ sc_core::sc_abort(); /* can't recover from here */ \
+ } \
+ } while ( false )
+
+#ifdef DEBUG_SYSTEMC
+# define SC_ASSERT_(cnd, msg) \
+ SC_ERROR_IF_IMPL_(!(cnd), "internal error", msg)
+#else
+# define SC_ASSERT_(cnd, msg) (void(0))
+#endif
+
+#define SC_ERROR_IF_(cnd,id) SC_ERROR_IF_IMPL_(cnd, id, 0)
+
+#define SC_CHECK_WL_(wl) SC_ERROR_IF_((wl) <= 0, \
+ "total wordlength <= 0 is not valid")
+
+#define SC_CHECK_N_BITS_(n_bits) \
+ SC_ERROR_IF_((n_bits) < 0, "number of bits < 0 is not valid")
+
+#define SC_CHECK_DIV_WL_(div_wl) \
+ SC_ERROR_IF_((div_wl) <= 0, "division wordlength <= 0 is not valid")
+
+#define SC_CHECK_CTE_WL_(cte_wl) \
+ SC_ERROR_IF_((cte_wl) <= 0, "constant wordlength <= 0 is not valid")
+
+#define SC_CHECK_MAX_WL_(max_wl) \
+ SC_ERROR_IF_((max_wl) <= 0 && (max_wl) != -1, \
+ "maximum wordlength <= 0 and != -1 is not valid")
+
+
+// ----------------------------------------------------------------------------
+// Generic observer macros.
+// ----------------------------------------------------------------------------
+
+#define SC_OBSERVER_(object, observer_type, event) \
+{ \
+ if ((object).observer() != 0) { \
+ observer_type observer = (object).lock_observer(); \
+ observer->event((object)); \
+ (object).unlock_observer(observer); \
+ } \
+}
+
+#define SC_OBSERVER_DEFAULT_(observer_type) \
+{ \
+ if (m_observer == 0 && observer_type::default_observer != 0) \
+ m_observer = (*observer_type::default_observer)(); \
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXDEFS_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxnum.hh b/src/systemc/ext/dt/fx/sc_fxnum.hh
new file mode 100644
index 000000000..1138646f3
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxnum.hh
@@ -0,0 +1,4370 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxnum.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxnum.h,v $
+// Revision 1.5 2011/08/29 18:04:32 acg
+// Philipp A. Hartmann: miscellaneous clean ups.
+//
+// Revision 1.4 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.3 2011/01/19 18:57:40 acg
+// Andy Goodrich: changes for IEEE_1666_2011.
+//
+// Revision 1.2 2009/03/09 17:26:46 acg
+// Andy Goodrich: removed ; from namespace { }
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
+
+#include <iostream>
+
+#include "../bit/sc_lv_base.hh"
+#include "sc_fxnum_observer.hh"
+#include "sc_fxval.hh"
+#include "scfx_params.hh"
+
+namespace sc_core
+{
+
+class vcd_sc_fxnum_trace;
+class vcd_sc_fxnum_fast_trace;
+class wif_sc_fxnum_trace;
+class wif_sc_fxnum_fast_trace;
+
+} // namespace sc_core
+
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxnum_bitref;
+class sc_fxnum_fast_bitref;
+class sc_fxnum_subref;
+class sc_fxnum_fast_subref;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_bitref
+//
+// Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_bitref
+{
+ friend class sc_fxnum;
+ friend class sc_fxnum_fast_bitref;
+
+ bool get() const;
+ void set(bool);
+
+ // constructor
+ sc_fxnum_bitref(sc_fxnum &, int);
+
+ public:
+ // copy constructor
+ sc_fxnum_bitref(const sc_fxnum_bitref &);
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) \
+ sc_fxnum_bitref &operator op (tp);
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
+ DECL_ASN_OP_T(op, const sc_bit &) \
+ DECL_ASN_OP_T(op, bool)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(&=)
+ DECL_ASN_OP(|=)
+ DECL_ASN_OP(^=)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP
+
+ // implicit conversion
+ operator bool() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ sc_fxnum &m_num;
+ int m_idx;
+
+ private:
+ // disabled
+ sc_fxnum_bitref();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_bitref
+//
+// Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_fast_bitref
+{
+ friend class sc_fxnum_fast;
+ friend class sc_fxnum_bitref;
+
+ bool get() const;
+ void set(bool);
+
+ // constructor
+ sc_fxnum_fast_bitref(sc_fxnum_fast &, int);
+
+ public:
+ // copy constructor
+ sc_fxnum_fast_bitref(const sc_fxnum_fast_bitref &);
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast_bitref &operator op (tp);
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
+ DECL_ASN_OP_T(op, const sc_bit &) \
+ DECL_ASN_OP_T(op, bool)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(&=)
+ DECL_ASN_OP(|=)
+ DECL_ASN_OP(^=)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP
+
+ // implicit conversion
+ operator bool() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ sc_fxnum_fast &m_num;
+ int m_idx;
+
+ private:
+ // Disabled
+ sc_fxnum_fast_bitref();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_subref
+//
+// Proxy class for part-selection in class sc_fxnum,
+// behaves like sc_bv_base.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_subref
+{
+ friend class sc_fxnum;
+ friend class sc_fxnum_fast_subref;
+
+ bool get() const;
+ bool set();
+
+ // constructor
+ sc_fxnum_subref(sc_fxnum &, int, int);
+
+ public:
+ // copy constructor
+ sc_fxnum_subref(const sc_fxnum_subref &);
+
+ // destructor
+ ~sc_fxnum_subref();
+
+ // assignment operators
+#define DECL_ASN_OP_T(tp) \
+ sc_fxnum_subref &operator = (tp);
+
+ DECL_ASN_OP_T(const sc_fxnum_subref &)
+ DECL_ASN_OP_T(const sc_fxnum_fast_subref &)
+ DECL_ASN_OP_T(const sc_bv_base &)
+ DECL_ASN_OP_T(const sc_lv_base &)
+ DECL_ASN_OP_T(const char *)
+ DECL_ASN_OP_T(const bool *)
+ DECL_ASN_OP_T(const sc_signed &)
+ DECL_ASN_OP_T(const sc_unsigned &)
+ DECL_ASN_OP_T(const sc_int_base &)
+ DECL_ASN_OP_T(const sc_uint_base &)
+ DECL_ASN_OP_T(int64)
+ DECL_ASN_OP_T(uint64)
+ DECL_ASN_OP_T(int)
+ DECL_ASN_OP_T(unsigned int)
+ DECL_ASN_OP_T(long)
+ DECL_ASN_OP_T(unsigned long)
+ DECL_ASN_OP_T(char)
+
+#undef DECL_ASN_OP_T
+
+#define DECL_ASN_OP_T_A(op, tp) \
+ sc_fxnum_subref &operator op ## = (tp);
+
+#define DECL_ASN_OP_A(op) \
+ DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
+ DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
+ DECL_ASN_OP_T_A(op, const sc_bv_base &) \
+ DECL_ASN_OP_T_A(op, const sc_lv_base &)
+
+ DECL_ASN_OP_A( &)
+ DECL_ASN_OP_A(|)
+ DECL_ASN_OP_A(^)
+
+#undef DECL_ASN_OP_T_A
+#undef DECL_ASN_OP_A
+
+ // relational operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxnum_subref &, tp); \
+ friend bool operator op (tp, const sc_fxnum_subref &);
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxnum_subref &, \
+ const sc_fxnum_subref &); \
+ friend bool operator op (const sc_fxnum_subref &, \
+ const sc_fxnum_fast_subref &); \
+ DECL_REL_OP_T(op, const sc_bv_base &) \
+ DECL_REL_OP_T(op, const sc_lv_base &) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_T(op, const bool *) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &) \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long)
+
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP
+
+ // reduce functions
+ bool and_reduce() const;
+ bool nand_reduce() const;
+ bool or_reduce() const;
+ bool nor_reduce() const;
+ bool xor_reduce() const;
+ bool xnor_reduce() const;
+
+ // query parameter
+ int length() const;
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+
+ // implicit conversion
+ operator sc_bv_base() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ sc_fxnum &m_num;
+ int m_from;
+ int m_to;
+
+ sc_bv_base &m_bv;
+
+ private:
+ // Disabled
+ sc_fxnum_subref();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_subref
+//
+// Proxy class for part-selection in class sc_fxnum_fast,
+// behaves like sc_bv_base.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_fast_subref
+{
+ friend class sc_fxnum_fast;
+ friend class sc_fxnum_subref;
+
+ bool get() const;
+ bool set();
+
+ // constructor
+ sc_fxnum_fast_subref(sc_fxnum_fast &, int, int);
+
+ public:
+ // copy constructor
+ sc_fxnum_fast_subref(const sc_fxnum_fast_subref &);
+
+ // destructor
+ ~sc_fxnum_fast_subref();
+
+ // assignment operators
+#define DECL_ASN_OP_T(tp) \
+ sc_fxnum_fast_subref &operator = (tp);
+
+ DECL_ASN_OP_T(const sc_fxnum_subref &)
+ DECL_ASN_OP_T(const sc_fxnum_fast_subref &)
+ DECL_ASN_OP_T(const sc_bv_base &)
+ DECL_ASN_OP_T(const sc_lv_base &)
+ DECL_ASN_OP_T(const char *)
+ DECL_ASN_OP_T(const bool *)
+ DECL_ASN_OP_T(const sc_signed &)
+ DECL_ASN_OP_T(const sc_unsigned &)
+ DECL_ASN_OP_T(const sc_int_base &)
+ DECL_ASN_OP_T(const sc_uint_base &)
+ DECL_ASN_OP_T(int64)
+ DECL_ASN_OP_T(uint64)
+ DECL_ASN_OP_T(int)
+ DECL_ASN_OP_T(unsigned int)
+ DECL_ASN_OP_T(long)
+ DECL_ASN_OP_T(unsigned long)
+ DECL_ASN_OP_T(char)
+
+#undef DECL_ASN_OP_T
+
+#define DECL_ASN_OP_T_A(op, tp) sc_fxnum_fast_subref &operator op ## = (tp);
+
+#define DECL_ASN_OP_A(op) \
+ DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
+ DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
+ DECL_ASN_OP_T_A(op, const sc_bv_base &) \
+ DECL_ASN_OP_T_A(op, const sc_lv_base &)
+
+ DECL_ASN_OP_A(&)
+ DECL_ASN_OP_A(|)
+ DECL_ASN_OP_A(^)
+
+#undef DECL_ASN_OP_T_A
+#undef DECL_ASN_OP_A
+
+ // relational operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxnum_fast_subref &, tp); \
+ friend bool operator op (tp, const sc_fxnum_fast_subref &);
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxnum_fast_subref &, \
+ const sc_fxnum_fast_subref &); \
+ friend bool operator op (const sc_fxnum_fast_subref &, \
+ const sc_fxnum_subref &); \
+ DECL_REL_OP_T(op, const sc_bv_base &) \
+ DECL_REL_OP_T(op, const sc_lv_base &) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_T(op, const bool *) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &) \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long)
+
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP
+
+ // reduce functions
+ bool and_reduce() const;
+ bool nand_reduce() const;
+ bool or_reduce() const;
+ bool nor_reduce() const;
+ bool xor_reduce() const;
+ bool xnor_reduce() const;
+
+ // query parameter
+ int length() const;
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+
+ // implicit conversion
+ operator sc_bv_base() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ sc_fxnum_fast &m_num;
+ int m_from;
+ int m_to;
+
+ sc_bv_base &m_bv;
+
+ private:
+ // Disabled
+ sc_fxnum_fast_subref();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum
+//
+// Base class for the fixed-point types; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum
+{
+ friend class sc_fxval;
+
+ friend class sc_fxnum_bitref;
+ friend class sc_fxnum_subref;
+ friend class sc_fxnum_fast_bitref;
+ friend class sc_fxnum_fast_subref;
+
+ friend class sc_core::vcd_sc_fxnum_trace;
+ friend class sc_core::wif_sc_fxnum_trace;
+
+ protected:
+ sc_fxnum_observer *observer() const;
+
+ void cast();
+
+ // constructors
+ sc_fxnum(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &,
+ sc_fxnum_observer *);
+
+#define DECL_CTOR_T(tp) \
+ sc_fxnum(tp, const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, \
+ sc_fxnum_observer *);
+
+ DECL_CTOR_T(int)
+ DECL_CTOR_T(unsigned int)
+ DECL_CTOR_T(long)
+ DECL_CTOR_T(unsigned long)
+ DECL_CTOR_T(float)
+ DECL_CTOR_T(double)
+ DECL_CTOR_T(const char *)
+ DECL_CTOR_T(const sc_fxval &)
+ DECL_CTOR_T(const sc_fxval_fast &)
+ DECL_CTOR_T(const sc_fxnum &)
+ DECL_CTOR_T(const sc_fxnum_fast &)
+
+ DECL_CTOR_T(int64)
+ DECL_CTOR_T(uint64)
+ DECL_CTOR_T(const sc_int_base &)
+ DECL_CTOR_T(const sc_uint_base &)
+ DECL_CTOR_T(const sc_signed &)
+ DECL_CTOR_T(const sc_unsigned &)
+
+#undef DECL_CTOR_T
+
+ ~sc_fxnum();
+
+ // internal use only;
+ const scfx_rep *get_rep() const;
+
+ public:
+ // unary operators
+ const sc_fxval operator - () const;
+ const sc_fxval operator + () const;
+
+ // unary functions
+ friend void neg(sc_fxval &, const sc_fxnum &);
+ friend void neg(sc_fxnum &, const sc_fxnum &);
+
+ // binary operators
+#define DECL_BIN_OP_T(op, tp) \
+ friend const sc_fxval operator op (const sc_fxnum &, tp); \
+ friend const sc_fxval operator op (tp, const sc_fxnum &);
+
+#define DECL_BIN_OP_OTHER(op) \
+ DECL_BIN_OP_T(op, int64) \
+ DECL_BIN_OP_T(op, uint64) \
+ DECL_BIN_OP_T(op, const sc_int_base &) \
+ DECL_BIN_OP_T(op, const sc_uint_base &) \
+ DECL_BIN_OP_T(op, const sc_signed &) \
+ DECL_BIN_OP_T(op, const sc_unsigned &)
+
+#define DECL_BIN_OP(op, dummy) \
+ friend const sc_fxval operator op (const sc_fxnum &, const sc_fxnum &); \
+ DECL_BIN_OP_T(op, int) \
+ DECL_BIN_OP_T(op, unsigned int) \
+ DECL_BIN_OP_T(op, long) \
+ DECL_BIN_OP_T(op, unsigned long) \
+ DECL_BIN_OP_T(op, float) \
+ DECL_BIN_OP_T(op, double) \
+ DECL_BIN_OP_T(op, const char *) \
+ DECL_BIN_OP_T(op, const sc_fxval &) \
+ DECL_BIN_OP_T(op, const sc_fxval_fast &) \
+ DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP(*, mult)
+ DECL_BIN_OP(+, add)
+ DECL_BIN_OP(-, sub)
+// don't use macros
+// DECL_BIN_OP(/, div)
+ friend const sc_fxval operator / (const sc_fxnum &, const sc_fxnum &);
+ DECL_BIN_OP_T(/, int)
+ DECL_BIN_OP_T(/, unsigned int)
+ DECL_BIN_OP_T(/, long)
+ DECL_BIN_OP_T(/, unsigned long)
+ DECL_BIN_OP_T(/, float)
+ DECL_BIN_OP_T(/, double)
+ DECL_BIN_OP_T(/, const char *)
+ DECL_BIN_OP_T(/, const sc_fxval &)
+ DECL_BIN_OP_T(/, const sc_fxval_fast &)
+ DECL_BIN_OP_T(/, const sc_fxnum_fast &)
+// DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP_T(/, int64)
+ DECL_BIN_OP_T(/, uint64)
+ DECL_BIN_OP_T(/, const sc_int_base &)
+ DECL_BIN_OP_T(/, const sc_uint_base &)
+ DECL_BIN_OP_T(/, const sc_signed &)
+ DECL_BIN_OP_T(/, const sc_unsigned &)
+
+#undef DECL_BIN_OP_T
+#undef DECL_BIN_OP_OTHER
+#undef DECL_BIN_OP
+
+ friend const sc_fxval operator << (const sc_fxnum &, int);
+ friend const sc_fxval operator >> (const sc_fxnum &, int);
+
+ // binary functions
+#define DECL_BIN_FNC_T(fnc, tp) \
+ friend void fnc (sc_fxval &, const sc_fxnum &, tp); \
+ friend void fnc (sc_fxval &, tp, const sc_fxnum &); \
+ friend void fnc (sc_fxnum &, const sc_fxnum &, tp); \
+ friend void fnc (sc_fxnum &, tp, const sc_fxnum &);
+
+#define DECL_BIN_FNC_OTHER(fnc) \
+ DECL_BIN_FNC_T(fnc, int64) \
+ DECL_BIN_FNC_T(fnc, uint64) \
+ DECL_BIN_FNC_T(fnc, const sc_int_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_signed &) \
+ DECL_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DECL_BIN_FNC(fnc) \
+ friend void fnc (sc_fxval &, const sc_fxnum &, const sc_fxnum &); \
+ friend void fnc (sc_fxnum &, const sc_fxnum &, const sc_fxnum &); \
+ DECL_BIN_FNC_T(fnc, int) \
+ DECL_BIN_FNC_T(fnc, unsigned int) \
+ DECL_BIN_FNC_T(fnc, long) \
+ DECL_BIN_FNC_T(fnc, unsigned long) \
+ DECL_BIN_FNC_T(fnc, float) \
+ DECL_BIN_FNC_T(fnc, double) \
+ DECL_BIN_FNC_T(fnc, const char *) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
+ DECL_BIN_FNC_OTHER(fnc)
+
+ DECL_BIN_FNC(mult)
+ DECL_BIN_FNC(div)
+ DECL_BIN_FNC(add)
+ DECL_BIN_FNC(sub)
+
+#undef DECL_BIN_FNC_T
+#undef DECL_BIN_FNC_OTHER
+#undef DECL_BIN_FNC
+
+ friend void lshift(sc_fxval &, const sc_fxnum &, int);
+ friend void rshift(sc_fxval &, const sc_fxnum &, int);
+ friend void lshift(sc_fxnum &, const sc_fxnum &, int);
+ friend void rshift(sc_fxnum &, const sc_fxnum &, int);
+
+ // relational (including equality) operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxnum &, tp); \
+ friend bool operator op (tp, const sc_fxnum &);
+
+#define DECL_REL_OP_OTHER(op) \
+ DECL_REL_OP_T(op, int64) \
+ DECL_REL_OP_T(op, uint64) \
+ DECL_REL_OP_T(op, const sc_int_base &) \
+ DECL_REL_OP_T(op, const sc_uint_base &) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &)
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxnum &, const sc_fxnum &); \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long) \
+ DECL_REL_OP_T(op, float) \
+ DECL_REL_OP_T(op, double) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_T(op, const sc_fxval &) \
+ DECL_REL_OP_T(op, const sc_fxval_fast &) \
+ DECL_REL_OP_T(op, const sc_fxnum_fast &) \
+ DECL_REL_OP_OTHER(op)
+
+ DECL_REL_OP(<)
+ DECL_REL_OP(<=)
+ DECL_REL_OP(>)
+ DECL_REL_OP(>=)
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP_OTHER
+#undef DECL_REL_OP
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) \
+ sc_fxnum &operator op(tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_fxnum &operator ++ ();
+ sc_fxnum &operator -- ();
+
+ // bit selection
+ const sc_fxnum_bitref operator [] (int) const;
+ sc_fxnum_bitref operator [] (int);
+
+ const sc_fxnum_bitref bit(int) const;
+ sc_fxnum_bitref bit(int);
+
+ // part selection
+ const sc_fxnum_subref operator () (int, int) const;
+ sc_fxnum_subref operator () (int, int);
+
+ const sc_fxnum_subref range(int, int) const;
+ sc_fxnum_subref range(int, int);
+
+ const sc_fxnum_subref operator () () const;
+ sc_fxnum_subref operator () ();
+
+ const sc_fxnum_subref range() const;
+ sc_fxnum_subref range();
+
+ // implicit conversion
+ operator double() const; // necessary evil!
+
+ // explicit conversion to primitive types
+ short to_short() const;
+ unsigned short to_ushort() const;
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ float to_float() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+ const std::string to_string(sc_fmt) const;
+ const std::string to_string(sc_numrep, sc_fmt) const;
+ const std::string to_string(sc_numrep, bool, sc_fmt) const;
+
+ const std::string to_dec() const;
+ const std::string to_bin() const;
+ const std::string to_oct() const;
+ const std::string to_hex() const;
+
+ // query value
+ bool is_neg() const;
+ bool is_zero() const;
+
+ // internal use only;
+ bool is_normal() const;
+
+ bool quantization_flag() const;
+ bool overflow_flag() const;
+
+ const sc_fxval value() const;
+
+ // query parameters
+ int wl() const;
+ int iwl() const;
+ sc_q_mode q_mode() const;
+ sc_o_mode o_mode() const;
+ int n_bits() const;
+
+ const sc_fxtype_params &type_params() const;
+
+ const sc_fxcast_switch &cast_switch() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ // internal use only;
+ void observer_read() const;
+
+ // internal use only;
+ bool get_bit(int) const;
+
+ protected:
+ bool set_bit(int, bool);
+
+ bool get_slice(int, int, sc_bv_base &) const;
+ bool set_slice(int, int, const sc_bv_base &);
+
+ sc_fxnum_observer *lock_observer() const;
+ void unlock_observer(sc_fxnum_observer *) const;
+
+ private:
+ scfx_rep *m_rep;
+
+ scfx_params m_params;
+ bool m_q_flag;
+ bool m_o_flag;
+
+ mutable sc_fxnum_observer *m_observer;
+
+ private:
+ // disabled
+ sc_fxnum();
+ sc_fxnum(const sc_fxnum &);
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast
+//
+// Base class for the fixed-point types; limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_fast
+{
+ friend class sc_fxval_fast;
+
+ friend class sc_fxnum_bitref;
+ friend class sc_fxnum_subref;
+ friend class sc_fxnum_fast_bitref;
+ friend class sc_fxnum_fast_subref;
+
+ friend class sc_core::vcd_sc_fxnum_fast_trace;
+ friend class sc_core::wif_sc_fxnum_fast_trace;
+
+ protected:
+ sc_fxnum_fast_observer *observer() const;
+
+ void cast();
+
+ // constructors
+ sc_fxnum_fast(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer *);
+
+#define DECL_CTOR_T(tp) \
+ sc_fxnum_fast(tp, const sc_fxtype_params &, sc_enc, \
+ const sc_fxcast_switch &, sc_fxnum_fast_observer *);
+
+ DECL_CTOR_T(int)
+ DECL_CTOR_T(unsigned int)
+ DECL_CTOR_T(long)
+ DECL_CTOR_T(unsigned long)
+ DECL_CTOR_T(float)
+ DECL_CTOR_T(double)
+ DECL_CTOR_T(const char *)
+ DECL_CTOR_T(const sc_fxval &)
+ DECL_CTOR_T(const sc_fxval_fast &)
+ DECL_CTOR_T(const sc_fxnum &)
+ DECL_CTOR_T(const sc_fxnum_fast &)
+
+ DECL_CTOR_T(int64)
+ DECL_CTOR_T(uint64)
+ DECL_CTOR_T(const sc_int_base &)
+ DECL_CTOR_T(const sc_uint_base &)
+ DECL_CTOR_T(const sc_signed &)
+ DECL_CTOR_T(const sc_unsigned &)
+
+#undef DECL_CTOR_T
+ ~sc_fxnum_fast();
+
+ // internal use only;
+ double get_val() const;
+
+ public:
+ // unary operators
+ const sc_fxval_fast operator - () const;
+ const sc_fxval_fast operator + () const;
+
+ // unary functions
+ friend void neg(sc_fxval_fast &, const sc_fxnum_fast &);
+ friend void neg(sc_fxnum_fast &, const sc_fxnum_fast &);
+
+
+ // binary operators
+#define DECL_BIN_OP_T(op, tp) \
+ friend const sc_fxval_fast operator op (const sc_fxnum_fast &, tp); \
+ friend const sc_fxval_fast operator op (tp, const sc_fxnum_fast &);
+
+#define DECL_BIN_OP_OTHER(op) \
+ DECL_BIN_OP_T(op, int64) \
+ DECL_BIN_OP_T(op, uint64) \
+ DECL_BIN_OP_T(op, const sc_int_base &) \
+ DECL_BIN_OP_T(op, const sc_uint_base &) \
+ DECL_BIN_OP_T(op, const sc_signed &) \
+ DECL_BIN_OP_T(op, const sc_unsigned &)
+
+#define DECL_BIN_OP(op, dummy) \
+ friend const sc_fxval_fast operator op (const sc_fxnum_fast &, \
+ const sc_fxnum_fast &); \
+ DECL_BIN_OP_T(op, int) \
+ DECL_BIN_OP_T(op, unsigned int) \
+ DECL_BIN_OP_T(op, long) \
+ DECL_BIN_OP_T(op, unsigned long) \
+ DECL_BIN_OP_T(op, float) \
+ DECL_BIN_OP_T(op, double) \
+ DECL_BIN_OP_T(op, const char *) \
+ DECL_BIN_OP_T(op, const sc_fxval_fast &) \
+ DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP(*, mult)
+ DECL_BIN_OP(+, add)
+ DECL_BIN_OP(-, sub)
+// DECL_BIN_OP(/, div)
+ friend const sc_fxval_fast operator / (const sc_fxnum_fast &,
+ const sc_fxnum_fast &);
+ DECL_BIN_OP_T(/, int)
+ DECL_BIN_OP_T(/, unsigned int)
+ DECL_BIN_OP_T(/, long)
+ DECL_BIN_OP_T(/, unsigned long)
+ DECL_BIN_OP_T(/, float)
+ DECL_BIN_OP_T(/, double)
+ DECL_BIN_OP_T(/, const char *)
+ DECL_BIN_OP_T(/, const sc_fxval_fast &)
+// DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP_T(/, int64) \
+ DECL_BIN_OP_T(/, uint64) \
+ DECL_BIN_OP_T(/, const sc_int_base &) \
+ DECL_BIN_OP_T(/, const sc_uint_base &) \
+ DECL_BIN_OP_T(/, const sc_signed &) \
+ DECL_BIN_OP_T(/, const sc_unsigned &)
+
+#undef DECL_BIN_OP_T
+#undef DECL_BIN_OP_OTHER
+#undef DECL_BIN_OP
+
+ friend const sc_fxval_fast operator << (const sc_fxnum_fast &, int);
+ friend const sc_fxval_fast operator >> (const sc_fxnum_fast &, int);
+
+ // binary functions
+#define DECL_BIN_FNC_T(fnc, tp) \
+ friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, tp); \
+ friend void fnc (sc_fxval_fast &, tp, const sc_fxnum_fast &); \
+ friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, tp); \
+ friend void fnc (sc_fxnum_fast &, tp, const sc_fxnum_fast &);
+
+#define DECL_BIN_FNC_OTHER(fnc) \
+ DECL_BIN_FNC_T(fnc, int64) \
+ DECL_BIN_FNC_T(fnc, uint64) \
+ DECL_BIN_FNC_T(fnc, const sc_int_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_signed &) \
+ DECL_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DECL_BIN_FNC(fnc) \
+ friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, \
+ const sc_fxnum_fast &); \
+ friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, \
+ const sc_fxnum_fast &); \
+ DECL_BIN_FNC_T(fnc, int) \
+ DECL_BIN_FNC_T(fnc, unsigned int) \
+ DECL_BIN_FNC_T(fnc, long) \
+ DECL_BIN_FNC_T(fnc, unsigned long) \
+ DECL_BIN_FNC_T(fnc, float) \
+ DECL_BIN_FNC_T(fnc, double) \
+ DECL_BIN_FNC_T(fnc, const char *) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
+ DECL_BIN_FNC_OTHER(fnc)
+
+ DECL_BIN_FNC(mult)
+ DECL_BIN_FNC(div)
+ DECL_BIN_FNC(add)
+ DECL_BIN_FNC(sub)
+
+#undef DECL_BIN_FNC_T
+#undef DECL_BIN_FNC_OTHER
+#undef DECL_BIN_FNC
+
+ friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int);
+ friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int);
+ friend void lshift(sc_fxnum_fast &, const sc_fxnum_fast &, int);
+ friend void rshift(sc_fxnum_fast &, const sc_fxnum_fast &, int);
+
+ // relational (including equality) operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxnum_fast &, tp); \
+ friend bool operator op (tp, const sc_fxnum_fast &);
+
+#define DECL_REL_OP_OTHER(op) \
+ DECL_REL_OP_T(op, int64) \
+ DECL_REL_OP_T(op, uint64) \
+ DECL_REL_OP_T(op, const sc_int_base &) \
+ DECL_REL_OP_T(op, const sc_uint_base &) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &)
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxnum_fast &, const sc_fxnum_fast &); \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long) \
+ DECL_REL_OP_T(op, float) \
+ DECL_REL_OP_T(op, double) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_T(op, const sc_fxval_fast &) \
+ DECL_REL_OP_OTHER(op)
+
+ DECL_REL_OP(<)
+ DECL_REL_OP(<=)
+ DECL_REL_OP(>)
+ DECL_REL_OP(>=)
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP_OTHER
+#undef DECL_REL_OP
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast &operator op(tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_fxnum_fast &operator ++ ();
+ sc_fxnum_fast &operator -- ();
+
+ // bit selection
+ const sc_fxnum_fast_bitref operator [] (int) const;
+ sc_fxnum_fast_bitref operator [] (int);
+
+ const sc_fxnum_fast_bitref bit(int) const;
+ sc_fxnum_fast_bitref bit(int);
+
+ // part selection
+ const sc_fxnum_fast_subref operator () (int, int) const;
+ sc_fxnum_fast_subref operator () (int, int);
+
+ const sc_fxnum_fast_subref range(int, int) const;
+ sc_fxnum_fast_subref range(int, int);
+
+
+ const sc_fxnum_fast_subref operator () () const;
+ sc_fxnum_fast_subref operator () ();
+
+ const sc_fxnum_fast_subref range() const;
+ sc_fxnum_fast_subref range();
+
+ // implicit conversion
+ operator double() const; // necessary evil!
+
+ // explicit conversion to primitive types
+ short to_short() const;
+ unsigned short to_ushort() const;
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ float to_float() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+ const std::string to_string(sc_fmt) const;
+ const std::string to_string(sc_numrep, sc_fmt) const;
+ const std::string to_string(sc_numrep, bool, sc_fmt) const;
+
+ const std::string to_dec() const;
+ const std::string to_bin() const;
+ const std::string to_oct() const;
+ const std::string to_hex() const;
+
+ // query value
+ bool is_neg() const;
+ bool is_zero() const;
+
+ // internal use only;
+ bool is_normal() const;
+
+ bool quantization_flag() const;
+ bool overflow_flag() const;
+
+ const sc_fxval_fast value() const;
+
+ // query parameters
+ int wl() const;
+ int iwl() const;
+ sc_q_mode q_mode() const;
+ sc_o_mode o_mode() const;
+ int n_bits() const;
+
+ const sc_fxtype_params &type_params() const;
+
+ const sc_fxcast_switch &cast_switch() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ // internal use only;
+ void observer_read() const;
+
+ // internal use only;
+ bool get_bit(int) const;
+
+ protected:
+ bool set_bit(int, bool);
+
+ bool get_slice(int, int, sc_bv_base &) const;
+ bool set_slice(int, int, const sc_bv_base &);
+
+ sc_fxnum_fast_observer *lock_observer() const;
+ void unlock_observer(sc_fxnum_fast_observer *) const;
+
+ private:
+ double m_val;
+
+ scfx_params m_params;
+ bool m_q_flag;
+ bool m_o_flag;
+
+ mutable sc_fxnum_fast_observer *m_observer;
+
+ private:
+ // Disabled
+ sc_fxnum_fast();
+ sc_fxnum_fast(const sc_fxnum_fast &);
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_bitref
+//
+// Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
+// ----------------------------------------------------------------------------
+
+// constructor
+
+inline
+sc_fxnum_bitref::sc_fxnum_bitref(sc_fxnum &num_, int idx_) :
+ m_num(num_), m_idx(idx_)
+{}
+
+// copy constructor
+inline sc_fxnum_bitref::sc_fxnum_bitref(const sc_fxnum_bitref &a) :
+ m_num(a.m_num), m_idx(a.m_idx)
+{}
+
+// assignment operators
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator = (const sc_fxnum_bitref &a)
+{
+ if (&a != this) {
+ SC_FXNUM_OBSERVER_READ_(a.m_num)
+ set(a.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ }
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator = (const sc_fxnum_fast_bitref &a)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a.m_num)
+ set(a.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator = (const sc_bit &a)
+{
+ set(static_cast<bool>(a));
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator = (bool a)
+{
+ set(a);
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator &= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() && b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator &= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() && b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator &= (const sc_bit &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() && static_cast<bool>(b));
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator &= (bool b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() && b);
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator |= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() || b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator |= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() || b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator |= (const sc_bit &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() || static_cast<bool>(b));
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator |= (bool b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() || b);
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator ^= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() != b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator ^= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() != b.get());
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator ^= (const sc_bit &b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() != static_cast<bool>(b));
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_bitref &
+sc_fxnum_bitref::operator ^= (bool b)
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ set(get() != b);
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+// implicit conversion
+inline sc_fxnum_bitref::operator bool() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ return get();
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum_bitref &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_bitref
+//
+// Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
+// ----------------------------------------------------------------------------
+
+// constructor
+inline sc_fxnum_fast_bitref::sc_fxnum_fast_bitref(
+ sc_fxnum_fast &num_, int idx_) : m_num(num_), m_idx(idx_)
+{}
+
+// copy constructor
+inline sc_fxnum_fast_bitref::sc_fxnum_fast_bitref(
+ const sc_fxnum_fast_bitref &a) : m_num(a.m_num), m_idx(a.m_idx)
+{}
+
+// assignment operators
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator = (const sc_fxnum_bitref &a)
+{
+ SC_FXNUM_OBSERVER_READ_(a.m_num)
+ set(a.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator = (const sc_fxnum_fast_bitref &a)
+{
+ if (&a != this) {
+ SC_FXNUM_FAST_OBSERVER_READ_(a.m_num)
+ set(a.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ }
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator = (const sc_bit &a)
+{
+ set(static_cast<bool>(a));
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator = (bool a)
+{
+ set(a);
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator &= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() && b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator &= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() && b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator &= (const sc_bit &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() && static_cast<bool>(b));
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator &= (bool b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() && b);
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator |= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() || b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator |= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() || b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator |= (const sc_bit &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() || static_cast<bool>(b));
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator |= (bool b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() || b);
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator ^= (const sc_fxnum_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_OBSERVER_READ_(b.m_num)
+ set(get() != b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator ^= (const sc_fxnum_fast_bitref &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ SC_FXNUM_FAST_OBSERVER_READ_(b.m_num)
+ set(get() != b.get());
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator ^= (const sc_bit &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() != static_cast<bool>(b));
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_bitref &
+sc_fxnum_fast_bitref::operator ^= (bool b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ set(get() != b);
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+
+// implicit conversion
+inline sc_fxnum_fast_bitref::operator bool() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ return get();
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum_fast_bitref &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum_fast_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_subref
+//
+// Proxy class for part-selection in class sc_fxnum,
+// behaves like sc_bv_base.
+// ----------------------------------------------------------------------------
+
+// constructor
+inline sc_fxnum_subref::sc_fxnum_subref(sc_fxnum &num_, int from_, int to_) :
+ m_num(num_), m_from(from_), m_to(to_),
+ m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
+{}
+
+// copy constructor
+inline sc_fxnum_subref::sc_fxnum_subref(const sc_fxnum_subref &a) :
+ m_num(a.m_num), m_from(a.m_from), m_to(a.m_to),
+ m_bv(*new sc_bv_base(a.m_bv))
+{}
+
+// destructor
+inline sc_fxnum_subref::~sc_fxnum_subref()
+{
+ delete &m_bv;
+}
+
+// assignment operators
+inline sc_fxnum_subref &
+sc_fxnum_subref::operator = (const sc_fxnum_subref &a)
+{
+ if (&a != this) {
+ m_bv = static_cast<sc_bv_base>(a);
+ set();
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ }
+ return *this;
+}
+
+inline sc_fxnum_subref &
+sc_fxnum_subref::operator = (const sc_fxnum_fast_subref &a)
+{
+ m_bv = static_cast<sc_bv_base>(a);
+ set();
+ SC_FXNUM_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxnum_subref & \
+sc_fxnum_subref::operator = (tp a) \
+{ \
+ m_bv = a; \
+ set(); \
+ SC_FXNUM_OBSERVER_WRITE_(m_num) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(const sc_bv_base &)
+DEFN_ASN_OP_T(const sc_lv_base &)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const bool *)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(char)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fxnum_subref & \
+sc_fxnum_subref::operator op ## = (tp a) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op a; \
+ set(); \
+ SC_FXNUM_OBSERVER_WRITE_(m_num) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP(op) \
+inline sc_fxnum_subref & \
+sc_fxnum_subref::operator op ## = (const sc_fxnum_subref &a) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op static_cast<sc_bv_base>(a); \
+ set(); \
+ SC_FXNUM_OBSERVER_WRITE_(m_num) \
+ return *this; \
+} \
+ \
+inline sc_fxnum_subref & \
+sc_fxnum_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op static_cast<sc_bv_base>(a); \
+ set(); \
+ SC_FXNUM_OBSERVER_WRITE_(m_num) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, const sc_bv_base &) \
+DEFN_ASN_OP_T(op, const sc_lv_base &)
+
+DEFN_ASN_OP( &)
+DEFN_ASN_OP(|)
+DEFN_ASN_OP(^)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+// relational operators
+#define DEFN_REL_OP_T(op, tp) \
+inline bool \
+operator op (const sc_fxnum_subref &a, tp b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op b); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxnum_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(b) op a); \
+}
+
+#define DEFN_REL_OP(op) \
+inline bool \
+operator op (const sc_fxnum_subref &a, const sc_fxnum_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
+} \
+ \
+inline bool \
+operator op (const sc_fxnum_subref &a, const sc_fxnum_fast_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
+} \
+ \
+DEFN_REL_OP_T(op, const sc_bv_base &) \
+DEFN_REL_OP_T(op, const sc_lv_base &) \
+DEFN_REL_OP_T(op, const char *) \
+DEFN_REL_OP_T(op, const bool *) \
+DEFN_REL_OP_T(op, const sc_signed &) \
+DEFN_REL_OP_T(op, const sc_unsigned &) \
+DEFN_REL_OP_T(op, int) \
+DEFN_REL_OP_T(op, unsigned int) \
+DEFN_REL_OP_T(op, long) \
+DEFN_REL_OP_T(op, unsigned long)
+
+DEFN_REL_OP(==)
+DEFN_REL_OP(!=)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP
+
+
+// reduce functions
+
+#define DEFN_RED_FNC(fnc) \
+inline bool \
+sc_fxnum_subref::fnc() const \
+{ \
+ SC_FXNUM_OBSERVER_READ_(m_num) \
+ get(); \
+ return static_cast<bool>(m_bv.fnc()); \
+}
+
+DEFN_RED_FNC(and_reduce)
+DEFN_RED_FNC(nand_reduce)
+DEFN_RED_FNC(or_reduce)
+DEFN_RED_FNC(nor_reduce)
+DEFN_RED_FNC(xor_reduce)
+DEFN_RED_FNC(xnor_reduce)
+
+#undef DEFN_RED_FNC
+
+// query parameter
+inline int
+sc_fxnum_subref::length() const
+{
+ return m_bv.length();
+}
+
+// explicit conversions
+inline int
+sc_fxnum_subref::to_int() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_int();
+}
+
+inline int64
+sc_fxnum_subref::to_int64() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_int64();
+}
+
+inline unsigned int
+sc_fxnum_subref::to_uint() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_uint();
+}
+
+inline uint64
+sc_fxnum_subref::to_uint64() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_uint64();
+}
+
+inline long
+sc_fxnum_subref::to_long() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_long();
+}
+
+inline unsigned long
+sc_fxnum_subref::to_ulong() const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_ulong();
+}
+
+
+inline const std::string
+sc_fxnum_subref::to_string() const
+{
+ get();
+ return m_bv.to_string();
+}
+
+inline const std::string
+sc_fxnum_subref::to_string(sc_numrep numrep) const
+{
+ get();
+ return m_bv.to_string(numrep);
+}
+
+inline const std::string
+sc_fxnum_subref::to_string(sc_numrep numrep, bool w_prefix) const
+{
+ get();
+ return m_bv.to_string(numrep, w_prefix);
+}
+
+
+// implicit conversion
+inline sc_fxnum_subref::operator sc_bv_base () const
+{
+ SC_FXNUM_OBSERVER_READ_(m_num)
+ get();
+ return m_bv;
+}
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum_subref &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_subref
+//
+// Proxy class for part-selection in class sc_fxnum_fast,
+// behaves like sc_bv_base.
+// ----------------------------------------------------------------------------
+
+// constructor
+
+inline sc_fxnum_fast_subref::sc_fxnum_fast_subref(
+ sc_fxnum_fast &num_, int from_, int to_) :
+ m_num(num_), m_from(from_), m_to(to_),
+ m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
+{}
+
+
+// copy constructor
+inline sc_fxnum_fast_subref::sc_fxnum_fast_subref(
+ const sc_fxnum_fast_subref &a) :
+ m_num(a.m_num), m_from(a.m_from), m_to(a.m_to),
+ m_bv(*new sc_bv_base(a.m_bv))
+{}
+
+
+// destructor
+inline sc_fxnum_fast_subref::~sc_fxnum_fast_subref()
+{
+ delete &m_bv;
+}
+
+
+// assignment operators
+inline sc_fxnum_fast_subref &
+sc_fxnum_fast_subref::operator = (const sc_fxnum_subref &a)
+{
+ m_bv = static_cast<sc_bv_base>(a);
+ set();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ return *this;
+}
+
+inline sc_fxnum_fast_subref &
+sc_fxnum_fast_subref::operator = (const sc_fxnum_fast_subref &a)
+{
+ if (&a != this) {
+ m_bv = static_cast<sc_bv_base>(a);
+ set();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num)
+ }
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxnum_fast_subref & \
+sc_fxnum_fast_subref::operator = (tp a) \
+{ \
+ m_bv = a; \
+ set(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(const sc_bv_base &)
+DEFN_ASN_OP_T(const sc_lv_base &)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const bool *)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(char)
+
+#undef DEFN_ASN_OP_T
+
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fxnum_fast_subref & \
+sc_fxnum_fast_subref::operator op ## = (tp a) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op a; \
+ set(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP(op) \
+inline sc_fxnum_fast_subref & \
+sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_subref &a) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op static_cast<sc_bv_base>(a); \
+ set(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
+ return *this; \
+} \
+ \
+inline sc_fxnum_fast_subref & \
+sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
+ get(); \
+ m_bv = m_bv op static_cast<sc_bv_base>(a); \
+ set(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, const sc_bv_base &) \
+DEFN_ASN_OP_T(op, const sc_lv_base &)
+
+DEFN_ASN_OP(&)
+DEFN_ASN_OP(|)
+DEFN_ASN_OP(^)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+
+// relational operators
+
+#define DEFN_REL_OP_T(op, tp) \
+inline bool \
+operator op (const sc_fxnum_fast_subref &a, tp b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op b); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxnum_fast_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(b) op a); \
+}
+
+#define DEFN_REL_OP(op) \
+inline bool \
+operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_fast_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
+} \
+ \
+inline bool \
+operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_subref &b) \
+{ \
+ return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
+} \
+ \
+DEFN_REL_OP_T(op, const sc_bv_base &) \
+DEFN_REL_OP_T(op, const sc_lv_base &) \
+DEFN_REL_OP_T(op, const char *) \
+DEFN_REL_OP_T(op, const bool *) \
+DEFN_REL_OP_T(op, const sc_signed &) \
+DEFN_REL_OP_T(op, const sc_unsigned &) \
+DEFN_REL_OP_T(op, int) \
+DEFN_REL_OP_T(op, unsigned int) \
+DEFN_REL_OP_T(op, long) \
+DEFN_REL_OP_T(op, unsigned long)
+
+DEFN_REL_OP(==)
+DEFN_REL_OP(!=)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP
+
+// reduce functions
+#define DEFN_RED_FNC(fnc) \
+inline bool \
+sc_fxnum_fast_subref::fnc() const \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
+ get(); \
+ return static_cast<bool>(m_bv.fnc()); \
+}
+
+DEFN_RED_FNC(and_reduce)
+DEFN_RED_FNC(nand_reduce)
+DEFN_RED_FNC(or_reduce)
+DEFN_RED_FNC(nor_reduce)
+DEFN_RED_FNC(xor_reduce)
+DEFN_RED_FNC(xnor_reduce)
+
+#undef DEFN_RED_FNC
+
+// query parameter
+inline int
+sc_fxnum_fast_subref::length() const
+{
+ return m_bv.length();
+}
+
+// explicit conversions
+inline int
+sc_fxnum_fast_subref::to_int() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_int();
+}
+
+inline int64
+sc_fxnum_fast_subref::to_int64() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_int64();
+}
+
+inline unsigned int
+sc_fxnum_fast_subref::to_uint() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_uint();
+}
+
+inline uint64
+sc_fxnum_fast_subref::to_uint64() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_uint64();
+}
+
+inline long
+sc_fxnum_fast_subref::to_long() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_long();
+}
+
+inline unsigned long
+sc_fxnum_fast_subref::to_ulong() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv.to_ulong();
+}
+
+inline const std::string
+sc_fxnum_fast_subref::to_string() const
+{
+ get();
+ return m_bv.to_string();
+}
+
+inline const std::string
+sc_fxnum_fast_subref::to_string(sc_numrep numrep) const
+{
+ get();
+ return m_bv.to_string(numrep);
+}
+
+inline const std::string
+sc_fxnum_fast_subref::to_string(sc_numrep numrep, bool w_prefix) const
+{
+ get();
+ return m_bv.to_string(numrep, w_prefix);
+}
+
+
+// implicit conversion
+inline sc_fxnum_fast_subref::operator sc_bv_base () const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(m_num)
+ get();
+ return m_bv;
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum_fast_subref &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum_fast_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum
+//
+// Base class for the fixed-point types; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+inline sc_fxnum_observer *
+sc_fxnum::observer() const
+{
+ return m_observer;
+}
+
+inline void
+sc_fxnum::cast()
+{
+ SC_ERROR_IF_(!m_rep->is_normal(), "invalid fixed-point value");
+
+ if (m_params.cast_switch() == SC_ON)
+ m_rep->cast(m_params, m_q_flag, m_o_flag);
+}
+
+// constructors
+inline sc_fxnum::sc_fxnum(const sc_fxtype_params &type_params_,
+ sc_enc enc_, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ m_rep(new scfx_rep), m_params(type_params_, enc_, cast_sw),
+ m_q_flag(false), m_o_flag(false), m_observer(observer_)
+{
+ SC_FXNUM_OBSERVER_DEFAULT_
+ SC_FXNUM_OBSERVER_CONSTRUCT_(*this)
+}
+
+#define DEFN_CTOR_T(tp, arg) \
+inline sc_fxnum::sc_fxnum(tp a, const sc_fxtype_params &type_params_, \
+ sc_enc enc_, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ m_rep(new scfx_rep(arg)), m_params(type_params_, enc_, cast_sw), \
+ m_q_flag(false), m_o_flag(false), m_observer(observer_) \
+{ \
+ SC_FXNUM_OBSERVER_DEFAULT_ \
+ cast(); \
+ SC_FXNUM_OBSERVER_CONSTRUCT_(*this) \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+}
+
+#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
+#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, *a.m_rep)
+#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
+#define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp, a.value())
+
+DEFN_CTOR_T_A(int)
+DEFN_CTOR_T_A(unsigned int)
+DEFN_CTOR_T_A(long)
+DEFN_CTOR_T_A(unsigned long)
+DEFN_CTOR_T_A(float)
+DEFN_CTOR_T_A(double)
+DEFN_CTOR_T_A(const char *)
+DEFN_CTOR_T_B(const sc_fxval &)
+DEFN_CTOR_T_C(const sc_fxval_fast &)
+DEFN_CTOR_T_B(const sc_fxnum &)
+DEFN_CTOR_T_C(const sc_fxnum_fast &)
+#ifndef SC_FX_EXCLUDE_OTHER
+DEFN_CTOR_T_A(int64)
+DEFN_CTOR_T_A(uint64)
+DEFN_CTOR_T_D(const sc_int_base &)
+DEFN_CTOR_T_D(const sc_uint_base &)
+DEFN_CTOR_T_A(const sc_signed &)
+DEFN_CTOR_T_A(const sc_unsigned &)
+#endif
+
+#undef DEFN_CTOR_T
+#undef DEFN_CTOR_T_A
+#undef DEFN_CTOR_T_B
+#undef DEFN_CTOR_T_C
+#undef DEFN_CTOR_T_D
+
+inline sc_fxnum::~sc_fxnum()
+{
+ SC_FXNUM_OBSERVER_DESTRUCT_(*this)
+ delete m_rep;
+}
+
+// internal use only;
+inline const scfx_rep *
+sc_fxnum::get_rep() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep;
+}
+
+// unary operators
+inline const sc_fxval
+sc_fxnum::operator - () const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return sc_fxval(sc_dt::neg_scfx_rep(*m_rep));
+}
+
+inline const sc_fxval
+sc_fxnum::operator + () const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return sc_fxval(new scfx_rep(*m_rep));
+}
+
+// unary functions
+inline void
+neg(sc_fxval &c, const sc_fxnum &a)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ c.set_rep(sc_dt::neg_scfx_rep(*a.m_rep));
+}
+
+inline void
+neg(sc_fxnum &c, const sc_fxnum &a)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::neg_scfx_rep(*a.m_rep);
+ c.cast();
+ SC_FXNUM_OBSERVER_WRITE_(c)
+}
+
+// binary operators
+#define DEFN_BIN_OP_T(op, fnc, tp) \
+inline const sc_fxval \
+operator op (const sc_fxnum &a, tp b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
+} \
+ \
+inline const sc_fxval \
+operator op (tp a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
+}
+
+#ifndef SC_FX_EXCLUDE_OTHER
+#define DEFN_BIN_OP_OTHER(op, fnc) \
+DEFN_BIN_OP_T(op, fnc, int64) \
+DEFN_BIN_OP_T(op, fnc, uint64) \
+DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
+DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
+DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
+DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
+#else
+#define DEFN_BIN_OP_OTHER(op, fnc)
+#endif
+
+#define DEFN_BIN_OP(op, fnc) \
+inline const sc_fxval \
+operator op (const sc_fxnum &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
+} \
+ \
+inline const sc_fxval \
+operator op (const sc_fxnum &a, const sc_fxval &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
+} \
+ \
+inline const sc_fxval \
+operator op (const sc_fxval &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
+} \
+ \
+DEFN_BIN_OP_T(op, fnc, int) \
+DEFN_BIN_OP_T(op, fnc, unsigned int) \
+DEFN_BIN_OP_T(op, fnc, long) \
+DEFN_BIN_OP_T(op, fnc, unsigned long) \
+DEFN_BIN_OP_T(op, fnc, float) \
+DEFN_BIN_OP_T(op, fnc, double) \
+DEFN_BIN_OP_T(op, fnc, const char *) \
+DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
+DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) \
+DEFN_BIN_OP_OTHER(op, fnc)
+
+DEFN_BIN_OP(*, mult)
+DEFN_BIN_OP(+, add)
+DEFN_BIN_OP(-, sub)
+// don't use macros
+//DEFN_BIN_OP(/, div)
+inline const sc_fxval
+operator / (const sc_fxnum &a, const sc_fxnum &b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ SC_FXNUM_OBSERVER_READ_(b)
+ return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.m_rep));
+}
+
+inline const sc_fxval
+operator / (const sc_fxnum &a, const sc_fxval &b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.get_rep()));
+}
+
+inline const sc_fxval
+operator / (const sc_fxval &a, const sc_fxnum &b)
+{
+ SC_FXNUM_OBSERVER_READ_(b)
+ return sc_fxval(sc_dt::div_scfx_rep(*a.get_rep(), *b.m_rep));
+}
+
+DEFN_BIN_OP_T(/, div, int)
+DEFN_BIN_OP_T(/, div, unsigned int)
+DEFN_BIN_OP_T(/, div, long)
+DEFN_BIN_OP_T(/, div, unsigned long)
+DEFN_BIN_OP_T(/, div, float)
+DEFN_BIN_OP_T(/, div, double)
+DEFN_BIN_OP_T(/, div, const char *)
+DEFN_BIN_OP_T(/, div, const sc_fxval_fast &)
+DEFN_BIN_OP_T(/, div, const sc_fxnum_fast &)
+//DEFN_BIN_OP_OTHER(/, div)
+
+DEFN_BIN_OP_T(/, div, int64)
+DEFN_BIN_OP_T(/, div, uint64)
+DEFN_BIN_OP_T(/, div, const sc_int_base &)
+DEFN_BIN_OP_T(/, div, const sc_uint_base &)
+DEFN_BIN_OP_T(/, div, const sc_signed &)
+DEFN_BIN_OP_T(/, div, const sc_unsigned &)
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP_OTHER
+#undef DEFN_BIN_OP
+
+inline const sc_fxval
+operator << (const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ return sc_fxval(sc_dt::lsh_scfx_rep(*a.m_rep, b));
+}
+
+inline const sc_fxval
+operator >> (const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ return sc_fxval(sc_dt::rsh_scfx_rep(*a.m_rep, b));
+}
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, tp) \
+inline void \
+fnc (sc_fxval &c, const sc_fxnum &a, tp b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
+} \
+ \
+inline void \
+fnc (sc_fxval &c, tp a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ c.set_rep(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
+} \
+ \
+inline void \
+fnc (sc_fxnum &c, const sc_fxnum &a, tp b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep()); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxnum &c, tp a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC_OTHER(fnc) \
+DEFN_BIN_FNC_T(fnc, int64) \
+DEFN_BIN_FNC_T(fnc, uint64) \
+DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
+DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
+DEFN_BIN_FNC_T(fnc, const sc_signed &) \
+DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DEFN_BIN_FNC(fnc) \
+inline void \
+fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
+} \
+ \
+inline void \
+fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxval &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
+} \
+ \
+inline void \
+fnc (sc_fxval &c, const sc_fxval &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ c.set_rep(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
+} \
+ \
+inline void \
+fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxval &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep()); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxnum &c, const sc_fxval &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+} \
+ \
+DEFN_BIN_FNC_T(fnc, int) \
+DEFN_BIN_FNC_T(fnc, unsigned int) \
+DEFN_BIN_FNC_T(fnc, long) \
+DEFN_BIN_FNC_T(fnc, unsigned long) \
+DEFN_BIN_FNC_T(fnc, float) \
+DEFN_BIN_FNC_T(fnc, double) \
+DEFN_BIN_FNC_T(fnc, const char *) \
+DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
+DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
+DEFN_BIN_FNC_OTHER(fnc)
+
+DEFN_BIN_FNC(mult)
+DEFN_BIN_FNC(div)
+DEFN_BIN_FNC(add)
+DEFN_BIN_FNC(sub)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC_OTHER
+#undef DEFN_BIN_FNC
+
+inline void
+lshift(sc_fxval &c, const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ c.set_rep(sc_dt::lsh_scfx_rep(*a.m_rep, b));
+}
+
+inline void
+rshift(sc_fxval &c, const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ c.set_rep(sc_dt::rsh_scfx_rep(*a.m_rep, b));
+}
+
+inline void
+lshift(sc_fxnum &c, const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::lsh_scfx_rep(*a.m_rep, b);
+ c.cast();
+ SC_FXNUM_OBSERVER_WRITE_(c)
+}
+
+inline void
+rshift(sc_fxnum &c, const sc_fxnum &a, int b)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::rsh_scfx_rep(*a.m_rep, b);
+ c.cast();
+ SC_FXNUM_OBSERVER_WRITE_(c)
+}
+
+// relational (including equality) operators
+#define DEFN_REL_OP_T(op, ret, tp) \
+inline bool \
+operator op (const sc_fxnum &a, tp b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.get_rep()); \
+ return (ret); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ int result = sc_dt::cmp_scfx_rep(*tmp.get_rep(), *b.m_rep); \
+ return (ret); \
+}
+
+#define DEFN_REL_OP_OTHER(op, ret) \
+DEFN_REL_OP_T(op, ret, int64) \
+DEFN_REL_OP_T(op, ret, uint64) \
+DEFN_REL_OP_T(op, ret, const sc_int_base &) \
+DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
+DEFN_REL_OP_T(op, ret, const sc_signed &) \
+DEFN_REL_OP_T(op, ret, const sc_unsigned &)
+
+#define DEFN_REL_OP(op, ret) \
+inline bool \
+operator op (const sc_fxnum &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
+ return (ret); \
+} \
+ \
+inline bool \
+operator op (const sc_fxnum &a, const sc_fxval &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(a) \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.get_rep()); \
+ return (ret); \
+} \
+ \
+inline bool \
+operator op (const sc_fxval &a, const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ int result = sc_dt::cmp_scfx_rep(*a.get_rep(), *b.m_rep); \
+ return (ret); \
+} \
+ \
+DEFN_REL_OP_T(op, ret, int) \
+DEFN_REL_OP_T(op, ret, unsigned int) \
+DEFN_REL_OP_T(op, ret, long) \
+DEFN_REL_OP_T(op, ret, unsigned long) \
+DEFN_REL_OP_T(op, ret, float) \
+DEFN_REL_OP_T(op, ret, double) \
+DEFN_REL_OP_T(op, ret, const char *) \
+DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
+DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) \
+DEFN_REL_OP_OTHER(op, ret)
+
+DEFN_REL_OP(<, result < 0)
+DEFN_REL_OP(<=, result <= 0)
+DEFN_REL_OP(>, result > 0 && result != 2)
+DEFN_REL_OP(>=, result >= 0 && result != 2)
+DEFN_REL_OP(==, result == 0)
+DEFN_REL_OP(!=, result != 0)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP_OTHER
+#undef DEFN_REL_OP
+
+// assignment operators
+inline sc_fxnum &
+sc_fxnum::operator = (const sc_fxnum &a)
+{
+ if (&a != this) {
+ SC_FXNUM_OBSERVER_READ_(a)
+ *m_rep = *a.m_rep;
+ cast();
+ SC_FXNUM_OBSERVER_WRITE_(*this)
+ }
+ return *this;
+}
+
+inline sc_fxnum &
+sc_fxnum::operator = (const sc_fxval &a)
+{
+ *m_rep = *a.get_rep();
+ cast();
+ SC_FXNUM_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxnum & \
+sc_fxnum::operator = (tp a) \
+{ \
+ sc_fxval tmp(a); \
+ *m_rep = *tmp.get_rep(); \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(float)
+DEFN_ASN_OP_T(double)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const sc_fxval_fast &)
+DEFN_ASN_OP_T(const sc_fxnum_fast &)
+
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+
+#undef DEFN_ASN_OP_T
+
+
+#define DEFN_ASN_OP_T(op, fnc, tp) \
+inline sc_fxnum & \
+sc_fxnum::operator op (tp b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(*this) \
+ sc_fxval tmp(b); \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.get_rep()); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op, fnc) \
+DEFN_ASN_OP_T(op, fnc, int64) \
+DEFN_ASN_OP_T(op, fnc, uint64) \
+DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
+DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
+DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op, fnc) \
+inline sc_fxnum & \
+sc_fxnum::operator op (const sc_fxnum &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(*this) \
+ SC_FXNUM_OBSERVER_READ_(b) \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+inline sc_fxnum & \
+sc_fxnum::operator op (const sc_fxval &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(*this) \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, fnc, int) \
+DEFN_ASN_OP_T(op, fnc, unsigned int) \
+DEFN_ASN_OP_T(op, fnc, long) \
+DEFN_ASN_OP_T(op, fnc, unsigned long) \
+DEFN_ASN_OP_T(op, fnc, float) \
+DEFN_ASN_OP_T(op, fnc, double) \
+DEFN_ASN_OP_T(op, fnc, const char *) \
+DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op, fnc)
+
+DEFN_ASN_OP(*=, mult)
+DEFN_ASN_OP(/=, div)
+DEFN_ASN_OP(+=, add)
+DEFN_ASN_OP(-=, sub)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+
+inline sc_fxnum &
+sc_fxnum::operator <<= (int b)
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ m_rep->lshift(b);
+ cast();
+ SC_FXNUM_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxnum &
+sc_fxnum::operator >>= (int b)
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ m_rep->rshift(b);
+ cast();
+ SC_FXNUM_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// auto-increment and auto-decrement
+inline const sc_fxval
+sc_fxnum::operator ++ (int)
+{
+ sc_fxval c(*this);
+ (*this) += 1;
+ return c;
+}
+
+inline const sc_fxval
+sc_fxnum::operator -- (int)
+{
+ sc_fxval c(*this);
+ (*this) -= 1;
+ return c;
+}
+
+inline sc_fxnum &
+sc_fxnum::operator ++ ()
+{
+ (*this) += 1;
+ return *this;
+}
+
+inline sc_fxnum &
+sc_fxnum::operator -- ()
+{
+ (*this) -= 1;
+ return *this;
+}
+
+// bit selection
+inline const sc_fxnum_bitref
+sc_fxnum::operator [] (int i) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
+ i - m_params.fwl());
+}
+
+inline sc_fxnum_bitref
+sc_fxnum::operator [] (int i)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_bitref(*this, i - m_params.fwl());
+}
+
+inline const sc_fxnum_bitref
+sc_fxnum::bit(int i) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
+ i - m_params.fwl());
+}
+
+inline sc_fxnum_bitref
+sc_fxnum::bit(int i)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_bitref(*this, i - m_params.fwl());
+}
+
+// part selection
+
+inline const sc_fxnum_subref
+sc_fxnum::operator () (int i, int j) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
+ i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline sc_fxnum_subref
+sc_fxnum::operator () (int i, int j)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline const sc_fxnum_subref
+sc_fxnum::range(int i, int j) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
+ i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline sc_fxnum_subref
+sc_fxnum::range(int i, int j)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
+}
+
+
+inline const sc_fxnum_subref
+sc_fxnum::operator () () const
+{
+ return this->operator () (m_params.wl() - 1, 0);
+}
+
+inline sc_fxnum_subref
+sc_fxnum::operator () ()
+{
+ return this->operator () (m_params.wl() - 1, 0);
+}
+
+inline const sc_fxnum_subref
+sc_fxnum::range() const
+{
+ return this->range(m_params.wl() - 1, 0);
+}
+
+inline sc_fxnum_subref
+sc_fxnum::range()
+{
+ return this->range(m_params.wl() - 1, 0);
+}
+
+// implicit conversion
+inline sc_fxnum::operator double() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->to_double();
+}
+
+// explicit conversion to primitive types
+inline short
+sc_fxnum::to_short() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<short>(m_rep->to_uint64());
+}
+
+inline unsigned short
+sc_fxnum::to_ushort() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<unsigned short>(m_rep->to_uint64());
+}
+
+inline int
+sc_fxnum::to_int() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<int>(m_rep->to_uint64());
+}
+
+inline int64
+sc_fxnum::to_int64() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<int64>(m_rep->to_uint64());
+}
+
+inline unsigned int
+sc_fxnum::to_uint() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<unsigned int>(m_rep->to_uint64());
+}
+
+inline uint64
+sc_fxnum::to_uint64() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->to_uint64();
+}
+
+inline long
+sc_fxnum::to_long() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<long>(m_rep->to_uint64());
+}
+
+inline unsigned long
+sc_fxnum::to_ulong() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<unsigned long>(m_rep->to_uint64());
+}
+
+inline float
+sc_fxnum::to_float() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return static_cast<float>(m_rep->to_double());
+}
+
+inline double
+sc_fxnum::to_double() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->to_double();
+}
+
+// query value
+inline bool
+sc_fxnum::is_neg() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->is_neg();
+}
+
+inline bool
+sc_fxnum::is_zero() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->is_zero();
+}
+
+// internal use only;
+inline bool
+sc_fxnum::is_normal() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return m_rep->is_normal();
+}
+
+inline bool
+sc_fxnum::quantization_flag() const
+{
+ return m_q_flag;
+}
+
+inline bool
+sc_fxnum::overflow_flag() const
+{
+ return m_o_flag;
+}
+
+
+inline const sc_fxval
+sc_fxnum::value() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ return sc_fxval(new scfx_rep(*m_rep));
+}
+
+// query parameters
+inline int
+sc_fxnum::wl() const
+{
+ return m_params.wl();
+}
+
+inline int
+sc_fxnum::iwl() const
+{
+ return m_params.iwl();
+}
+
+inline sc_q_mode
+sc_fxnum::q_mode() const
+{
+ return m_params.q_mode();
+}
+
+inline sc_o_mode
+sc_fxnum::o_mode() const
+{
+ return m_params.o_mode();
+}
+
+inline int
+sc_fxnum::n_bits() const
+{
+ return m_params.n_bits();
+}
+
+inline const sc_fxtype_params &
+sc_fxnum::type_params() const
+{
+ return m_params.type_params();
+}
+
+inline const sc_fxcast_switch &
+sc_fxnum::cast_switch() const
+{
+ return m_params.cast_switch();
+}
+
+// internal use only;
+inline void
+sc_fxnum::observer_read() const
+{
+ SC_FXNUM_OBSERVER_READ_(*this);
+}
+
+// internal use only;
+inline bool
+sc_fxnum::get_bit(int i) const
+{
+ return m_rep->get_bit(i);
+}
+
+// protected methods and friend functions
+inline bool
+sc_fxnum::set_bit(int i, bool high)
+{
+ if (high)
+ return m_rep->set(i, m_params);
+ else
+ return m_rep->clear(i, m_params);
+}
+
+inline bool
+sc_fxnum::get_slice(int i, int j, sc_bv_base &bv) const
+{
+ return m_rep->get_slice(i, j, m_params, bv);
+}
+
+inline bool
+sc_fxnum::set_slice(int i, int j, const sc_bv_base &bv)
+{
+ return m_rep->set_slice(i, j, m_params, bv);
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast
+//
+// Base class for the fixed-point types; limited precision.
+// ----------------------------------------------------------------------------
+
+inline sc_fxnum_fast_observer *
+sc_fxnum_fast::observer() const
+{
+ return m_observer;
+}
+
+
+// constructors
+inline sc_fxnum_fast::sc_fxnum_fast(const sc_fxtype_params &type_params_,
+ sc_enc enc_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ m_val(0.0), m_params(type_params_, enc_, cast_sw), m_q_flag(false),
+ m_o_flag(false), m_observer(observer_)
+{
+ SC_FXNUM_FAST_OBSERVER_DEFAULT_
+ SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this)
+}
+
+inline sc_fxnum_fast::sc_fxnum_fast(const sc_fxnum_fast &a,
+ const sc_fxtype_params &type_params_,
+ sc_enc enc_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ m_val(a.m_val), m_params(type_params_, enc_, cast_sw), m_q_flag(false),
+ m_o_flag(false), m_observer(observer_)
+{
+ SC_FXNUM_FAST_OBSERVER_DEFAULT_
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ cast();
+ SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this)
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+}
+
+#define DEFN_CTOR_T(tp, arg) \
+inline sc_fxnum_fast::sc_fxnum_fast( \
+ tp a, const sc_fxtype_params &type_params_, sc_enc enc_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ m_val(arg), m_params(type_params_, enc_, cast_sw), m_q_flag(false), \
+ m_o_flag(false), m_observer(observer_) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_DEFAULT_ \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+}
+
+#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
+#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, sc_fxval_fast::from_string(a))
+#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
+
+DEFN_CTOR_T_A(int)
+DEFN_CTOR_T_A(unsigned int)
+DEFN_CTOR_T_A(long)
+DEFN_CTOR_T_A(unsigned long)
+DEFN_CTOR_T_A(float)
+DEFN_CTOR_T_A(double)
+DEFN_CTOR_T_B(const char *)
+DEFN_CTOR_T_C(const sc_fxval &)
+DEFN_CTOR_T_C(const sc_fxval_fast &)
+DEFN_CTOR_T_C(const sc_fxnum &)
+
+DEFN_CTOR_T_A(int64)
+DEFN_CTOR_T_A(uint64)
+DEFN_CTOR_T_C(const sc_int_base &)
+DEFN_CTOR_T_C(const sc_uint_base &)
+DEFN_CTOR_T_C(const sc_signed &)
+DEFN_CTOR_T_C(const sc_unsigned &)
+
+#undef DEFN_CTOR_T
+#undef DEFN_CTOR_T_A
+#undef DEFN_CTOR_T_B
+#undef DEFN_CTOR_T_C
+#undef DEFN_CTOR_T_D
+#undef DEFN_CTOR_T_E
+
+inline sc_fxnum_fast::~sc_fxnum_fast()
+{
+ SC_FXNUM_FAST_OBSERVER_DESTRUCT_(*this)
+}
+
+// internal use only;
+inline double
+sc_fxnum_fast::get_val() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// unary operators
+inline const sc_fxval_fast
+sc_fxnum_fast::operator - () const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return sc_fxval_fast(- m_val);
+}
+
+inline const sc_fxval_fast
+sc_fxnum_fast::operator + () const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return sc_fxval_fast(m_val);
+}
+
+// unary functions
+inline void
+neg(sc_fxval_fast &c, const sc_fxnum_fast &a)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.set_val(- a.m_val);
+}
+
+inline void
+neg(sc_fxnum_fast &c, const sc_fxnum_fast &a)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.m_val = - a.m_val;
+ c.cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c)
+}
+
+// binary operators
+#define DEFN_BIN_OP_T(op, tp) \
+inline const sc_fxval_fast \
+operator op (const sc_fxnum_fast &a, tp b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ return sc_fxval_fast(a.m_val op tmp.get_val()); \
+} \
+ \
+inline const sc_fxval_fast \
+operator op (tp a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ return sc_fxval_fast(tmp.get_val() op b.m_val); \
+}
+
+#define DEFN_BIN_OP_OTHER(op) \
+DEFN_BIN_OP_T(op, int64) \
+DEFN_BIN_OP_T(op, uint64) \
+DEFN_BIN_OP_T(op, const sc_int_base &) \
+DEFN_BIN_OP_T(op, const sc_uint_base &) \
+DEFN_BIN_OP_T(op, const sc_signed &) \
+DEFN_BIN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_BIN_OP(op, dummy) \
+inline const sc_fxval_fast \
+operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ return sc_fxval_fast(a.m_val op b.m_val); \
+} \
+ \
+inline const sc_fxval_fast \
+operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ return sc_fxval_fast(a.m_val op b.get_val()); \
+} \
+ \
+inline const sc_fxval_fast \
+operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ return sc_fxval_fast(a.get_val() op b.m_val); \
+} \
+ \
+DEFN_BIN_OP_T(op, int) \
+DEFN_BIN_OP_T(op, unsigned int) \
+DEFN_BIN_OP_T(op, long) \
+DEFN_BIN_OP_T(op, unsigned long) \
+DEFN_BIN_OP_T(op, float) \
+DEFN_BIN_OP_T(op, double) \
+DEFN_BIN_OP_T(op, const char *) \
+DEFN_BIN_OP_OTHER(op)
+
+DEFN_BIN_OP(*, mult)
+DEFN_BIN_OP(+, add)
+DEFN_BIN_OP(-, sub)
+//DEFN_BIN_OP(/, div)
+inline const sc_fxval_fast
+operator / (const sc_fxnum_fast &a, const sc_fxnum_fast &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ SC_FXNUM_FAST_OBSERVER_READ_(b)
+ return sc_fxval_fast(a.m_val / b.m_val);
+}
+
+inline const sc_fxval_fast
+operator / (const sc_fxnum_fast &a, const sc_fxval_fast &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ return sc_fxval_fast(a.m_val / b.get_val());
+}
+
+inline const sc_fxval_fast
+operator / (const sc_fxval_fast &a, const sc_fxnum_fast &b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(b)
+ return sc_fxval_fast(a.get_val() / b.m_val);
+}
+
+DEFN_BIN_OP_T(/, int)
+DEFN_BIN_OP_T(/, unsigned int)
+DEFN_BIN_OP_T(/, long)
+DEFN_BIN_OP_T(/, unsigned long)
+DEFN_BIN_OP_T(/, float)
+DEFN_BIN_OP_T(/, double)
+DEFN_BIN_OP_T(/, const char *)
+//DEFN_BIN_OP_OTHER(/)
+
+DEFN_BIN_OP_T(/, int64)
+DEFN_BIN_OP_T(/, uint64)
+DEFN_BIN_OP_T(/, const sc_int_base &)
+DEFN_BIN_OP_T(/, const sc_uint_base &)
+DEFN_BIN_OP_T(/, const sc_signed &)
+DEFN_BIN_OP_T(/, const sc_unsigned &)
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP_OTHER
+#undef DEFN_BIN_OP
+
+inline const sc_fxval_fast
+operator << (const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ return sc_fxval_fast(a.m_val *scfx_pow2(b));
+}
+
+inline const sc_fxval_fast
+operator >> (const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ return sc_fxval_fast(a.m_val *scfx_pow2(-b));
+}
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, op, tp) \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, tp b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ c.set_val(a.m_val op tmp.get_val()); \
+} \
+ \
+inline void \
+fnc (sc_fxval_fast &c, tp a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ c.set_val(tmp.get_val() op b.m_val); \
+} \
+ \
+inline void \
+fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, tp b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ c.m_val = a.m_val op tmp.get_val(); \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxnum_fast &c, tp a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ c.m_val = tmp.get_val() op b.m_val; \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC_OTHER(fnc, op) \
+DEFN_BIN_FNC_T(fnc, op, int64) \
+DEFN_BIN_FNC_T(fnc, op, uint64) \
+DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
+
+#define DEFN_BIN_FNC(fnc, op) \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ c.set_val(a.m_val op b.m_val); \
+} \
+ \
+inline void \
+fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ c.m_val = a.m_val op b.m_val; \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ c.set_val(a.m_val op b.get_val()); \
+} \
+ \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ c.set_val(a.get_val() op b.m_val); \
+} \
+ \
+inline void \
+fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ c.m_val = a.m_val op b.get_val(); \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxnum_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ c.m_val = a.get_val() op b.m_val; \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+DEFN_BIN_FNC_T(fnc, op, int) \
+DEFN_BIN_FNC_T(fnc, op, unsigned int) \
+DEFN_BIN_FNC_T(fnc, op, long) \
+DEFN_BIN_FNC_T(fnc, op, unsigned long) \
+DEFN_BIN_FNC_T(fnc, op, float) \
+DEFN_BIN_FNC_T(fnc, op, double) \
+DEFN_BIN_FNC_T(fnc, op, const char *) \
+DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) \
+DEFN_BIN_FNC_OTHER(fnc, op)
+
+DEFN_BIN_FNC(mult, *)
+DEFN_BIN_FNC(div, /)
+DEFN_BIN_FNC(add, +)
+DEFN_BIN_FNC(sub, -)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC_OTHER
+#undef DEFN_BIN_FNC
+
+inline void
+lshift(sc_fxval_fast &c, const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.set_val(a.m_val * scfx_pow2(b));
+}
+
+inline void
+rshift(sc_fxval_fast &c, const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.set_val(a.m_val * scfx_pow2(-b));
+}
+
+inline void
+lshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.m_val = a.m_val * scfx_pow2(b);
+ c.cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c)
+}
+
+inline void
+rshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ c.m_val = a.m_val * scfx_pow2(-b);
+ c.cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c)
+}
+
+// relational (including equality) operators
+#define DEFN_REL_OP_T(op, tp) \
+inline bool \
+operator op (const sc_fxnum_fast &a, tp b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ return (a.m_val op tmp.get_val()); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ return (tmp.get_val() op b.m_val); \
+}
+
+#define DEFN_REL_OP_OTHER(op) \
+DEFN_REL_OP_T(op, int64) \
+DEFN_REL_OP_T(op, uint64) \
+DEFN_REL_OP_T(op, const sc_int_base &) \
+DEFN_REL_OP_T(op, const sc_uint_base &) \
+DEFN_REL_OP_T(op, const sc_signed &) \
+DEFN_REL_OP_T(op, const sc_unsigned &)
+
+#define DEFN_REL_OP(op) \
+inline bool \
+operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ return (a.m_val op b.m_val); \
+} \
+ \
+inline bool \
+operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(a) \
+ return (a.m_val op b.get_val()); \
+} \
+ \
+inline bool \
+operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ return (a.get_val() op b.m_val); \
+} \
+ \
+DEFN_REL_OP_T(op, int) \
+DEFN_REL_OP_T(op, unsigned int) \
+DEFN_REL_OP_T(op, long) \
+DEFN_REL_OP_T(op, unsigned long) \
+DEFN_REL_OP_T(op, float) \
+DEFN_REL_OP_T(op, double) \
+DEFN_REL_OP_T(op, const char *) \
+DEFN_REL_OP_OTHER(op)
+
+DEFN_REL_OP(<)
+DEFN_REL_OP(<=)
+DEFN_REL_OP(>)
+DEFN_REL_OP(>=)
+DEFN_REL_OP(==)
+DEFN_REL_OP(!=)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP_OTHER
+#undef DEFN_REL_OP
+
+// assignment operators
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator = (const sc_fxnum_fast &a)
+{
+ if (&a != this) {
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ m_val = a.m_val;
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ }
+ return *this;
+}
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator = (const sc_fxval_fast &a)
+{
+ m_val = a.get_val();
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxnum_fast & \
+sc_fxnum_fast::operator = (tp a) \
+{ \
+ sc_fxval_fast tmp(a); \
+ m_val = tmp.get_val(); \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(float)
+DEFN_ASN_OP_T(double)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const sc_fxval &)
+DEFN_ASN_OP_T(const sc_fxnum &)
+
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fxnum_fast & \
+sc_fxnum_fast::operator op (tp b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(*this) \
+ sc_fxval_fast tmp(b); \
+ m_val op tmp.get_val(); \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+inline sc_fxnum_fast & \
+sc_fxnum_fast::operator op (const sc_fxnum_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(*this) \
+ SC_FXNUM_FAST_OBSERVER_READ_(b) \
+ m_val op b.m_val; \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+inline sc_fxnum_fast & \
+sc_fxnum_fast::operator op (const sc_fxval_fast &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(*this) \
+ m_val op b.get_val(); \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator <<= (int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ m_val *= scfx_pow2(b);
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator >>= (int b)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ m_val *= scfx_pow2(-b);
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// auto-increment and auto-decrement
+inline const sc_fxval_fast
+sc_fxnum_fast::operator ++ (int)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ double c = m_val;
+ m_val = m_val + 1;
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return sc_fxval_fast(c);
+}
+
+inline const sc_fxval_fast
+sc_fxnum_fast::operator -- (int)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ double c = m_val;
+ m_val = m_val - 1;
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return sc_fxval_fast(c);
+}
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator ++ ()
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ m_val = m_val + 1;
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxnum_fast &
+sc_fxnum_fast::operator -- ()
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ m_val = m_val - 1;
+ cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// bit selection
+inline const sc_fxnum_fast_bitref
+sc_fxnum_fast::operator [] (int i) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
+ i - m_params.fwl());
+}
+
+inline sc_fxnum_fast_bitref
+sc_fxnum_fast::operator [] (int i)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
+}
+
+inline const sc_fxnum_fast_bitref
+sc_fxnum_fast::bit(int i) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
+ i - m_params.fwl());
+}
+
+inline sc_fxnum_fast_bitref
+sc_fxnum_fast::bit(int i)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
+}
+
+// part selection
+inline const sc_fxnum_fast_subref
+sc_fxnum_fast::operator () (int i, int j) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
+ i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline sc_fxnum_fast_subref
+sc_fxnum_fast::operator () (int i, int j)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline const sc_fxnum_fast_subref
+sc_fxnum_fast::range(int i, int j) const
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
+ i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline sc_fxnum_fast_subref
+sc_fxnum_fast::range(int i, int j)
+{
+ SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
+ SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
+
+ return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
+}
+
+inline const sc_fxnum_fast_subref
+sc_fxnum_fast::operator () () const
+{
+ return this->operator () (m_params.wl() - 1, 0);
+}
+
+inline sc_fxnum_fast_subref
+sc_fxnum_fast::operator () ()
+{
+ return this->operator () (m_params.wl() - 1, 0);
+}
+
+inline const sc_fxnum_fast_subref
+sc_fxnum_fast::range() const
+{
+ return this->range(m_params.wl() - 1, 0);
+}
+
+inline sc_fxnum_fast_subref
+sc_fxnum_fast::range()
+{
+ return this->range(m_params.wl() - 1, 0);
+}
+
+// implicit conversion
+inline sc_fxnum_fast::operator double() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// explicit conversion to primitive types
+inline short
+sc_fxnum_fast::to_short() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<short>(to_uint64());
+}
+
+inline unsigned short
+sc_fxnum_fast::to_ushort() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned short>(to_uint64());
+}
+
+inline int
+sc_fxnum_fast::to_int() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<int>(to_uint64());
+}
+
+inline int64
+sc_fxnum_fast::to_int64() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<int64>(to_uint64());
+}
+
+inline unsigned int
+sc_fxnum_fast::to_uint() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned int>(to_uint64());
+}
+
+inline uint64
+sc_fxnum_fast::to_uint64() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in is_normal
+ if (!is_normal()) {
+ return 0;
+ }
+
+ int exponent;
+ double mantissa_dbl = frexp(m_val, &exponent);
+
+ uint64 mantissa = static_cast<uint64>(fabs(mantissa_dbl) *
+ (UINT64_ONE << 53));
+ exponent -= 53;
+
+ if (!(-64 < exponent && exponent < 64)) {
+ return 0;
+ }
+
+ mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
+ return mantissa_dbl >= 0 ? mantissa : -mantissa;
+}
+
+inline long
+sc_fxnum_fast::to_long() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<long>(to_uint64());
+}
+
+inline unsigned long
+sc_fxnum_fast::to_ulong() const
+{
+ // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned long>(to_uint64());
+}
+
+inline float
+sc_fxnum_fast::to_float() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return static_cast<float>(m_val);
+}
+
+inline double
+sc_fxnum_fast::to_double() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// query value
+inline bool
+sc_fxnum_fast::is_neg() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return (id.negative() != 0);
+}
+
+inline bool
+sc_fxnum_fast::is_zero() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return id.is_zero();
+}
+
+// internal use only;
+inline bool
+sc_fxnum_fast::is_normal() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return (id.is_normal() || id.is_subnormal() || id.is_zero());
+}
+
+inline bool
+sc_fxnum_fast::quantization_flag() const
+{
+ return m_q_flag;
+}
+
+inline bool
+sc_fxnum_fast::overflow_flag() const
+{
+ return m_o_flag;
+}
+
+inline const sc_fxval_fast
+sc_fxnum_fast::value() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ return sc_fxval_fast(m_val);
+}
+
+// query parameters
+inline int
+sc_fxnum_fast::wl() const
+{
+ return m_params.wl();
+}
+
+inline int
+sc_fxnum_fast::iwl() const
+{
+ return m_params.iwl();
+}
+
+inline sc_q_mode
+sc_fxnum_fast::q_mode() const
+{
+ return m_params.q_mode();
+}
+
+inline sc_o_mode
+sc_fxnum_fast::o_mode() const
+{
+ return m_params.o_mode();
+}
+
+inline int
+sc_fxnum_fast::n_bits() const
+{
+ return m_params.n_bits();
+}
+
+inline const sc_fxtype_params &
+sc_fxnum_fast::type_params() const
+{
+ return m_params.type_params();
+}
+
+inline const sc_fxcast_switch &
+sc_fxnum_fast::cast_switch() const
+{
+ return m_params.cast_switch();
+}
+
+// internal use only;
+inline void
+sc_fxnum_fast::observer_read() const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this);
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxnum_fast &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxnum_fast &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval
+//
+// Fixed-point value type; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+// public constructors
+inline sc_fxval::sc_fxval(const sc_fxnum &a, sc_fxval_observer *observer_) :
+ m_rep(new scfx_rep(*a.get_rep())), m_observer(observer_)
+{
+ SC_FXVAL_OBSERVER_DEFAULT_
+ SC_FXVAL_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+}
+
+inline sc_fxval::sc_fxval(const sc_fxnum_fast &a,
+ sc_fxval_observer *observer_) :
+ m_rep(new scfx_rep(a.to_double())), m_observer(observer_)
+{
+ SC_FXVAL_OBSERVER_DEFAULT_
+ SC_FXVAL_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+}
+
+// binary operators
+#define DEFN_BIN_OP_T(op, fnc, tp) \
+inline const sc_fxval \
+operator op (const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
+} \
+ \
+inline const sc_fxval \
+operator op (tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
+}
+
+#define DEFN_BIN_OP(op, fnc) \
+DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &)
+
+DEFN_BIN_OP(*, mult)
+DEFN_BIN_OP(+, add)
+DEFN_BIN_OP(-, sub)
+//DEFN_BIN_OP(/, div)
+DEFN_BIN_OP_T(/, div, const sc_fxnum_fast &)
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP
+
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, tp) \
+inline void \
+fnc (sc_fxval &c, const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
+ SC_FXVAL_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval &c, tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
+ SC_FXVAL_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC(fnc) \
+DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &)
+
+DEFN_BIN_FNC(mult)
+DEFN_BIN_FNC(div)
+DEFN_BIN_FNC(add)
+DEFN_BIN_FNC(sub)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC
+
+
+// relational (including equality) operators
+#define DEFN_REL_OP_T(op, ret, tp) \
+inline bool \
+operator op (const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
+ return (ret); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
+ return (ret); \
+}
+
+#define DEFN_REL_OP(op, ret) \
+DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &)
+
+DEFN_REL_OP(<, result < 0)
+DEFN_REL_OP(<=, result <= 0)
+DEFN_REL_OP(>, result > 0 && result != 2)
+DEFN_REL_OP(>=, result >= 0 && result != 2)
+DEFN_REL_OP(==, result == 0)
+DEFN_REL_OP(!=, result != 0)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP
+
+// assignment operators
+inline sc_fxval &
+sc_fxval::operator = (const sc_fxnum &a)
+{
+ *m_rep = *a.get_rep();
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxval & \
+sc_fxval::operator = (tp b) \
+{ \
+ sc_fxval tmp(b); \
+ *m_rep = *tmp.m_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(const sc_fxnum_fast &)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, fnc, tp) \
+inline sc_fxval & \
+sc_fxval::operator op (tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(*this) \
+ sc_fxval tmp(b); \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP(op, fnc) \
+inline sc_fxval & \
+sc_fxval::operator op (const sc_fxnum &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(*this) \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &)
+
+DEFN_ASN_OP(*=, mult)
+DEFN_ASN_OP(/=, div)
+DEFN_ASN_OP(+=, add)
+DEFN_ASN_OP(-=, sub)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_fast
+//
+// Fixed-point value types; limited precision.
+// ----------------------------------------------------------------------------
+
+// public constructors
+
+inline
+sc_fxval_fast::sc_fxval_fast(const sc_fxnum &a,
+ sc_fxval_fast_observer *observer_) :
+ m_val(a.to_double()), m_observer(observer_)
+{
+ SC_FXVAL_FAST_OBSERVER_DEFAULT_
+ SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+}
+
+inline sc_fxval_fast::sc_fxval_fast(const sc_fxnum_fast &a,
+ sc_fxval_fast_observer *observer_) :
+ m_val(a.get_val()), m_observer(observer_)
+{
+ SC_FXVAL_FAST_OBSERVER_DEFAULT_
+ SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+}
+
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, op, tp) \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ c.m_val = a.m_val op tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ c.m_val = tmp.m_val op b.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC(fnc, op) \
+DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &)
+
+DEFN_BIN_FNC(mult, *)
+DEFN_BIN_FNC(div, /)
+DEFN_BIN_FNC(add, +)
+DEFN_BIN_FNC(sub, -)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC
+
+
+// assignment operators
+inline sc_fxval_fast &
+sc_fxval_fast::operator = (const sc_fxnum_fast &a)
+{
+ m_val = a.get_val();
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator = (tp a) \
+{ \
+ sc_fxval_fast tmp(a); \
+ m_val = tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(const sc_fxnum &)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator op (tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(*this) \
+ sc_fxval_fast tmp(b); \
+ m_val op tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP(op) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator op (const sc_fxnum_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(*this) \
+ m_val op b.get_val(); \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, const sc_fxnum &)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxnum_observer.hh b/src/systemc/ext/dt/fx/sc_fxnum_observer.hh
new file mode 100644
index 000000000..73b81d8ef
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxnum_observer.hh
@@ -0,0 +1,175 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxnum_observer.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxnum_observer.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_OBSERVER_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_OBSERVER_HH__
+
+#include "sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxnum_observer;
+class sc_fxnum_fast_observer;
+
+// forward class declarations
+class sc_fxnum;
+class sc_fxnum_fast;
+
+#ifdef SC_ENABLE_OBSERVERS
+
+#define SC_FXNUM_OBSERVER_CONSTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxnum_observer *, construct)
+#define SC_FXNUM_OBSERVER_DESTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxnum_observer *, destruct)
+#define SC_FXNUM_OBSERVER_READ_(object) \
+ SC_OBSERVER_(object, sc_fxnum_observer *, read)
+#define SC_FXNUM_OBSERVER_WRITE_(object) \
+ SC_OBSERVER_(object, sc_fxnum_observer *, write)
+#define SC_FXNUM_OBSERVER_DEFAULT_ \
+ SC_OBSERVER_DEFAULT_(sc_fxnum_observer)
+
+#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxnum_fast_observer *, construct)
+#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxnum_fast_observer *, destruct)
+#define SC_FXNUM_FAST_OBSERVER_READ_(object) \
+ SC_OBSERVER_(object, sc_fxnum_fast_observer *, read)
+#define SC_FXNUM_FAST_OBSERVER_WRITE_(object) \
+ SC_OBSERVER_(object, sc_fxnum_fast_observer *, write)
+#define SC_FXNUM_FAST_OBSERVER_DEFAULT_ \
+ SC_OBSERVER_DEFAULT_(sc_fxnum_fast_observer)
+
+#else
+
+#define SC_FXNUM_OBSERVER_CONSTRUCT_(object)
+#define SC_FXNUM_OBSERVER_DESTRUCT_(object)
+#define SC_FXNUM_OBSERVER_READ_(object)
+#define SC_FXNUM_OBSERVER_WRITE_(object)
+#define SC_FXNUM_OBSERVER_DEFAULT_
+
+#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object)
+#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object)
+#define SC_FXNUM_FAST_OBSERVER_READ_(object)
+#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
+#define SC_FXNUM_FAST_OBSERVER_DEFAULT_
+
+#endif
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_observer
+//
+// Abstract base class for fixed-point types observers; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_observer
+{
+ protected:
+ sc_fxnum_observer() {}
+ virtual ~sc_fxnum_observer() {}
+
+ public:
+ virtual void construct(const sc_fxnum &);
+ virtual void destruct(const sc_fxnum &);
+ virtual void read(const sc_fxnum &);
+ virtual void write(const sc_fxnum &);
+
+ static sc_fxnum_observer *(* default_observer)();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_observer
+//
+// Abstract base class for fixed-point types observers; limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxnum_fast_observer
+{
+ protected:
+ sc_fxnum_fast_observer() {}
+ virtual ~sc_fxnum_fast_observer() {}
+
+ public:
+ virtual void construct(const sc_fxnum_fast &);
+ virtual void destruct(const sc_fxnum_fast &);
+ virtual void read(const sc_fxnum_fast &);
+ virtual void write(const sc_fxnum_fast &);
+
+ static sc_fxnum_fast_observer *(* default_observer) ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_observer
+//
+// Abstract base class for fixed-point types observers; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+inline void sc_fxnum_observer::construct(const sc_fxnum &) {}
+inline void sc_fxnum_observer::destruct(const sc_fxnum &) {}
+inline void sc_fxnum_observer::read(const sc_fxnum &) {}
+inline void sc_fxnum_observer::write(const sc_fxnum &) {}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxnum_fast_observer
+//
+// Abstract base class for fixed-point types observers; limited precision.
+// ----------------------------------------------------------------------------
+
+inline void sc_fxnum_fast_observer::construct(const sc_fxnum_fast &) {}
+inline void sc_fxnum_fast_observer::destruct(const sc_fxnum_fast &) {}
+inline void sc_fxnum_fast_observer::read(const sc_fxnum_fast &) {}
+inline void sc_fxnum_fast_observer::write(const sc_fxnum_fast &) {}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXNUM_OBSERVER_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxtype_params.hh b/src/systemc/ext/dt/fx/sc_fxtype_params.hh
new file mode 100644
index 000000000..b31b12cdd
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxtype_params.hh
@@ -0,0 +1,265 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxtype_params.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxtype_params.h,v $
+// Revision 1.2 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__
+
+#include <iostream>
+
+#include "sc_context.hh"
+#include "sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxtype_params;
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxtype_params
+//
+// Fixed-point type parameters class.
+// ----------------------------------------------------------------------------
+
+class sc_fxtype_params
+{
+ public:
+ sc_fxtype_params();
+ sc_fxtype_params(int, int);
+ sc_fxtype_params(sc_q_mode, sc_o_mode, int=0);
+ sc_fxtype_params(int, int, sc_q_mode, sc_o_mode, int=0);
+ sc_fxtype_params(const sc_fxtype_params &);
+ sc_fxtype_params(const sc_fxtype_params &, int, int);
+ sc_fxtype_params(const sc_fxtype_params&, sc_q_mode, sc_o_mode, int=0);
+ explicit sc_fxtype_params(sc_without_context);
+
+ sc_fxtype_params &operator = (const sc_fxtype_params &);
+
+ friend bool operator == (const sc_fxtype_params &,
+ const sc_fxtype_params &);
+ friend bool operator != (const sc_fxtype_params &,
+ const sc_fxtype_params &);
+
+ int wl() const;
+ void wl(int);
+
+ int iwl() const;
+ void iwl(int);
+
+ sc_q_mode q_mode() const;
+ void q_mode(sc_q_mode);
+
+ sc_o_mode o_mode() const;
+ void o_mode(sc_o_mode);
+
+ int n_bits() const;
+ void n_bits(int);
+
+ const std::string to_string() const;
+
+ void print(::std::ostream & =::std::cout) const;
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ int m_wl;
+ int m_iwl;
+ sc_q_mode m_q_mode;
+ sc_o_mode m_o_mode;
+ int m_n_bits;
+};
+
+} // namespace sc_dt
+
+// ----------------------------------------------------------------------------
+// TYPEDEF : sc_fxtype_context
+//
+// Context type for the fixed-point type parameters.
+// ----------------------------------------------------------------------------
+
+// extern template instantiations
+namespace sc_dt
+{
+
+extern template class sc_global<sc_fxtype_params>;
+extern template class sc_context<sc_fxtype_params>;
+typedef sc_context<sc_fxtype_params> sc_fxtype_context;
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline sc_fxtype_params::sc_fxtype_params() :
+ m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
+{
+ *this = sc_fxtype_context::default_value();
+}
+
+inline sc_fxtype_params::sc_fxtype_params(int wl_, int iwl_) :
+ m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
+{
+ *this = sc_fxtype_context::default_value();
+
+ SC_CHECK_WL_(wl_);
+ m_wl = wl_;
+ m_iwl = iwl_;
+}
+
+inline sc_fxtype_params::sc_fxtype_params(
+ sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) :
+ m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
+{
+ *this = sc_fxtype_context::default_value();
+
+ SC_CHECK_N_BITS_(n_bits_);
+ m_q_mode = q_mode_;
+ m_o_mode = o_mode_;
+ m_n_bits = n_bits_;
+}
+
+inline sc_fxtype_params::sc_fxtype_params(
+ int wl_, int iwl_, sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) :
+ m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
+{
+ SC_CHECK_WL_(wl_);
+ SC_CHECK_N_BITS_(n_bits_);
+ m_wl = wl_;
+ m_iwl = iwl_;
+ m_q_mode = q_mode_;
+ m_o_mode = o_mode_;
+ m_n_bits = n_bits_;
+}
+
+inline sc_fxtype_params::sc_fxtype_params(const sc_fxtype_params &a) :
+ m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(a.m_q_mode),
+ m_o_mode(a.m_o_mode), m_n_bits(a.m_n_bits)
+{}
+
+inline sc_fxtype_params::sc_fxtype_params(
+ const sc_fxtype_params &a, int wl_, int iwl_) :
+ m_wl(wl_), m_iwl(iwl_), m_q_mode(a.m_q_mode), m_o_mode(a.m_o_mode),
+ m_n_bits(a.m_n_bits)
+{}
+
+inline sc_fxtype_params::sc_fxtype_params(
+ const sc_fxtype_params &a, sc_q_mode q_mode_, sc_o_mode o_mode_,
+ int n_bits_) :
+ m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(q_mode_), m_o_mode(o_mode_),
+ m_n_bits(n_bits_)
+{}
+
+inline sc_fxtype_params::sc_fxtype_params(sc_without_context) :
+ m_wl(SC_DEFAULT_WL_), m_iwl(SC_DEFAULT_IWL_),
+ m_q_mode(SC_DEFAULT_Q_MODE_), m_o_mode(SC_DEFAULT_O_MODE_),
+ m_n_bits(SC_DEFAULT_N_BITS_)
+{}
+
+inline sc_fxtype_params &
+sc_fxtype_params::operator = (const sc_fxtype_params &a)
+{
+ if (&a != this) {
+ m_wl = a.m_wl;
+ m_iwl = a.m_iwl;
+ m_q_mode = a.m_q_mode;
+ m_o_mode = a.m_o_mode;
+ m_n_bits = a.m_n_bits;
+ }
+ return *this;
+}
+
+inline bool
+operator == (const sc_fxtype_params &a, const sc_fxtype_params &b)
+{
+ return (a.m_wl == b.m_wl && a.m_iwl == b.m_iwl &&
+ a.m_q_mode == b.m_q_mode && a.m_o_mode == b.m_o_mode &&
+ a.m_n_bits == b.m_n_bits);
+}
+
+inline bool
+operator != (const sc_fxtype_params &a, const sc_fxtype_params &b)
+{
+ return (a.m_wl != b.m_wl || a.m_iwl != b.m_iwl ||
+ a.m_q_mode != b.m_q_mode || a.m_o_mode != b.m_o_mode ||
+ a.m_n_bits != b.m_n_bits );
+}
+
+inline int sc_fxtype_params::wl() const { return m_wl; }
+inline void
+sc_fxtype_params::wl(int wl_)
+{
+ SC_CHECK_WL_(wl_);
+ m_wl = wl_;
+}
+
+inline int sc_fxtype_params::iwl() const { return m_iwl; }
+inline void sc_fxtype_params::iwl(int iwl_) { m_iwl = iwl_; }
+
+
+inline sc_q_mode sc_fxtype_params::q_mode() const { return m_q_mode; }
+inline void sc_fxtype_params::q_mode(sc_q_mode q_mode_) { m_q_mode = q_mode_; }
+
+inline sc_o_mode sc_fxtype_params::o_mode() const { return m_o_mode; }
+inline void sc_fxtype_params::o_mode(sc_o_mode o_mode_) { m_o_mode = o_mode_; }
+
+inline int sc_fxtype_params::n_bits() const { return m_n_bits; }
+inline void
+sc_fxtype_params::n_bits(int n_bits_)
+{
+ SC_CHECK_N_BITS_(n_bits_);
+ m_n_bits = n_bits_;
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxtype_params &a)
+{
+ a.print(os);
+ return os;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAM_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxval.hh b/src/systemc/ext/dt/fx/sc_fxval.hh
new file mode 100644
index 000000000..b42bf9efa
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxval.hh
@@ -0,0 +1,1943 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxval.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxval.h,v $
+// Revision 1.3 2011/01/19 18:57:40 acg
+// Andy Goodrich: changes for IEEE_1666_2011.
+//
+// Revision 1.2 2010/12/07 20:09:08 acg
+// Andy Goodrich: Philipp Hartmann's constructor disambiguation fix
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
+
+#include <iostream>
+
+#include "../int/sc_int_base.hh"
+#include "../int/sc_signed.hh"
+#include "../int/sc_uint_base.hh"
+#include "../int/sc_unsigned.hh"
+#include "sc_fxval_observer.hh"
+#include "scfx_rep.hh"
+
+#define SCFX_EXPLICIT_ explicit
+#define SCFX_EXPLICIT_OTHER_ explicit
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxval;
+class sc_fxval_fast;
+
+// forward class declarations
+class sc_fxnum;
+class sc_fxnum_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval
+//
+// Fixed-point value type; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxval
+{
+ friend class sc_fxnum;
+
+ protected:
+ sc_fxval_observer* observer() const;
+
+ public:
+ // internal use only;
+ explicit sc_fxval(scfx_rep *);
+
+ explicit sc_fxval(sc_fxval_observer * =0);
+ explicit sc_fxval(int, sc_fxval_observer * =0);
+ explicit sc_fxval(unsigned int, sc_fxval_observer * =0);
+ explicit sc_fxval(long, sc_fxval_observer * =0);
+ explicit sc_fxval(unsigned long, sc_fxval_observer * =0);
+ explicit sc_fxval(float, sc_fxval_observer* = 0);
+ explicit sc_fxval(double, sc_fxval_observer* = 0);
+ explicit sc_fxval(const char *, sc_fxval_observer* = 0);
+ sc_fxval(const sc_fxval &, sc_fxval_observer* = 0);
+ sc_fxval(const sc_fxval_fast &, sc_fxval_observer* = 0);
+ sc_fxval(const sc_fxnum &, sc_fxval_observer* = 0);
+ sc_fxval(const sc_fxnum_fast &, sc_fxval_observer* = 0);
+
+ explicit sc_fxval(int64, sc_fxval_observer* = 0);
+ explicit sc_fxval(uint64, sc_fxval_observer* = 0);
+ explicit sc_fxval(const sc_int_base &, sc_fxval_observer* = 0);
+ explicit sc_fxval(const sc_uint_base &, sc_fxval_observer* = 0);
+ explicit sc_fxval(const sc_signed &, sc_fxval_observer* = 0);
+ explicit sc_fxval(const sc_unsigned &, sc_fxval_observer* = 0);
+
+ ~sc_fxval();
+
+ // internal use only;
+ const scfx_rep *get_rep() const;
+ void set_rep(scfx_rep *);
+
+ // unary operators
+ const sc_fxval operator - () const;
+ const sc_fxval &operator + () const;
+
+ // unary functions
+ friend void neg(sc_fxval &, const sc_fxval &);
+
+ // binary operators
+#define DECL_BIN_OP_T(op,tp) \
+ friend const sc_fxval operator op (const sc_fxval &, tp); \
+ friend const sc_fxval operator op (tp, const sc_fxval &);
+
+#define DECL_BIN_OP_OTHER(op) \
+ DECL_BIN_OP_T(op, int64) \
+ DECL_BIN_OP_T(op, uint64) \
+ DECL_BIN_OP_T(op, const sc_int_base &) \
+ DECL_BIN_OP_T(op, const sc_uint_base &) \
+ DECL_BIN_OP_T(op, const sc_signed &) \
+ DECL_BIN_OP_T(op, const sc_unsigned &)
+
+#define DECL_BIN_OP(op, dummy) \
+ friend const sc_fxval operator op (const sc_fxval &, const sc_fxval &); \
+ DECL_BIN_OP_T(op, int) \
+ DECL_BIN_OP_T(op, unsigned int) \
+ DECL_BIN_OP_T(op, long) \
+ DECL_BIN_OP_T(op, unsigned long) \
+ DECL_BIN_OP_T(op, float) \
+ DECL_BIN_OP_T(op, double) \
+ DECL_BIN_OP_T(op, const char *) \
+ DECL_BIN_OP_T(op, const sc_fxval_fast &) \
+ DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP(*, mult)
+ DECL_BIN_OP(+, add)
+ DECL_BIN_OP(-, sub)
+// declaration below doesn't compile with BCB5 (E2206)
+// DECL_BIN_OP(/, div)
+// previous macro expanded
+ friend const sc_fxval operator / (const sc_fxval &, const sc_fxval &);
+ DECL_BIN_OP_T(/, int)
+ DECL_BIN_OP_T(/, unsigned int)
+ DECL_BIN_OP_T(/, long)
+ DECL_BIN_OP_T(/, unsigned long)
+ DECL_BIN_OP_T(/, float)
+ DECL_BIN_OP_T(/, double)
+ DECL_BIN_OP_T(/, const char *)
+ DECL_BIN_OP_T(/, const sc_fxval_fast &)
+ DECL_BIN_OP_T(/, const sc_fxnum_fast &)
+// DECL_BIN_OP_OTHER(/)
+
+ DECL_BIN_OP_T(/, int64)
+ DECL_BIN_OP_T(/, uint64)
+ DECL_BIN_OP_T(/, const sc_int_base &)
+ DECL_BIN_OP_T(/, const sc_uint_base &)
+ DECL_BIN_OP_T(/, const sc_signed &)
+ DECL_BIN_OP_T(/, const sc_unsigned &)
+
+#undef DECL_BIN_OP_T
+#undef DECL_BIN_OP_OTHER
+#undef DECL_BIN_OP
+
+ friend const sc_fxval operator << (const sc_fxval &, int);
+ friend const sc_fxval operator >> (const sc_fxval &, int);
+
+ // binary functions
+#define DECL_BIN_FNC_T(fnc, tp) \
+ friend void fnc (sc_fxval &, const sc_fxval &, tp); \
+ friend void fnc (sc_fxval &, tp, const sc_fxval &);
+
+#define DECL_BIN_FNC_OTHER(fnc) \
+ DECL_BIN_FNC_T(fnc, int64) \
+ DECL_BIN_FNC_T(fnc, uint64) \
+ DECL_BIN_FNC_T(fnc, const sc_int_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_signed &) \
+ DECL_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DECL_BIN_FNC(fnc) \
+ friend void fnc (sc_fxval &, const sc_fxval &, const sc_fxval &); \
+ DECL_BIN_FNC_T(fnc, int) \
+ DECL_BIN_FNC_T(fnc, unsigned int) \
+ DECL_BIN_FNC_T(fnc, long) \
+ DECL_BIN_FNC_T(fnc, unsigned long) \
+ DECL_BIN_FNC_T(fnc, float) \
+ DECL_BIN_FNC_T(fnc, double) \
+ DECL_BIN_FNC_T(fnc, const char *) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
+ DECL_BIN_FNC_OTHER(fnc)
+
+ DECL_BIN_FNC(mult)
+ DECL_BIN_FNC(div)
+ DECL_BIN_FNC(add)
+ DECL_BIN_FNC(sub)
+
+#undef DECL_BIN_FNC_T
+#undef DECL_BIN_FNC_OTHER
+#undef DECL_BIN_FNC
+
+ friend void lshift(sc_fxval &, const sc_fxval &, int);
+ friend void rshift(sc_fxval &, const sc_fxval &, int);
+
+ // relational (including equality) operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxval &, tp); \
+ friend bool operator op (tp, const sc_fxval &);
+
+#define DECL_REL_OP_OTHER(op) \
+ DECL_REL_OP_T(op, int64) \
+ DECL_REL_OP_T(op, uint64) \
+ DECL_REL_OP_T(op, const sc_int_base &) \
+ DECL_REL_OP_T(op, const sc_uint_base &) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &)
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxval &, const sc_fxval &); \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long) \
+ DECL_REL_OP_T(op, float) \
+ DECL_REL_OP_T(op, double) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_T(op, const sc_fxval_fast &) \
+ DECL_REL_OP_T(op, const sc_fxnum_fast &) \
+ DECL_REL_OP_OTHER(op)
+
+ DECL_REL_OP(<)
+ DECL_REL_OP(<=)
+ DECL_REL_OP(>)
+ DECL_REL_OP(>=)
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP_OTHER
+#undef DECL_REL_OP
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) sc_fxval &operator op(tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_fxval & operator ++ ();
+ sc_fxval & operator -- ();
+
+ // implicit conversion
+ operator double() const; // necessary evil!
+
+ // explicit conversion to primitive types
+ short to_short() const;
+ unsigned short to_ushort() const;
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ float to_float() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+ const std::string to_string(sc_fmt) const;
+ const std::string to_string(sc_numrep, sc_fmt) const;
+ const std::string to_string(sc_numrep, bool, sc_fmt) const;
+
+ const std::string to_dec() const;
+ const std::string to_bin() const;
+ const std::string to_oct() const;
+ const std::string to_hex() const;
+
+ // query value
+ bool is_neg() const;
+ bool is_zero() const;
+ bool is_nan() const;
+ bool is_inf() const;
+ bool is_normal() const;
+
+ bool rounding_flag() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ // internal use only;
+ bool get_bit(int) const;
+
+ protected:
+ sc_fxval_observer *lock_observer() const;
+ void unlock_observer(sc_fxval_observer *) const;
+
+ void get_type(int &, int &, sc_enc &) const;
+
+ const sc_fxval quantization(const scfx_params &, bool &) const;
+ const sc_fxval overflow(const scfx_params &, bool &) const;
+
+ private:
+ scfx_rep * m_rep;
+
+ mutable sc_fxval_observer *m_observer;
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_fast
+//
+// Fixed-point value type; limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxval_fast
+{
+ friend class sc_fxnum_fast;
+
+ protected:
+ sc_fxval_fast_observer *observer() const;
+
+ public:
+ explicit sc_fxval_fast(sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(int, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(unsigned int, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(long, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(unsigned long, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(float, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(double, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(const char *, sc_fxval_fast_observer * =0);
+ sc_fxval_fast(const sc_fxval &, sc_fxval_fast_observer * =0);
+ sc_fxval_fast(const sc_fxval_fast &, sc_fxval_fast_observer * =0);
+ sc_fxval_fast(const sc_fxnum &, sc_fxval_fast_observer * =0);
+ sc_fxval_fast(const sc_fxnum_fast &, sc_fxval_fast_observer * =0);
+
+ explicit sc_fxval_fast(int64, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(uint64, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(const sc_int_base &, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(const sc_uint_base &, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(const sc_signed &, sc_fxval_fast_observer * =0);
+ explicit sc_fxval_fast(const sc_unsigned &, sc_fxval_fast_observer * =0);
+
+ ~sc_fxval_fast();
+
+ // internal use only;
+ double get_val() const;
+ void set_val(double);
+
+ // unary operators
+ const sc_fxval_fast operator - () const;
+ const sc_fxval_fast & operator + () const;
+
+ // unary functions
+ friend void neg(sc_fxval_fast &, const sc_fxval_fast &);
+
+ // binary operators
+#define DECL_BIN_OP_T(op, tp) \
+ friend const sc_fxval_fast operator op (const sc_fxval_fast &, tp); \
+ friend const sc_fxval_fast operator op (tp, const sc_fxval_fast &);
+
+#define DECL_BIN_OP_OTHER(op) \
+ DECL_BIN_OP_T(op, int64) \
+ DECL_BIN_OP_T(op, uint64) \
+ DECL_BIN_OP_T(op, const sc_int_base &) \
+ DECL_BIN_OP_T(op, const sc_uint_base &) \
+ DECL_BIN_OP_T(op, const sc_signed &) \
+ DECL_BIN_OP_T(op, const sc_unsigned &)
+
+#define DECL_BIN_OP(op, dummy) \
+ friend const sc_fxval_fast operator op (const sc_fxval_fast &, \
+ const sc_fxval_fast &); \
+ DECL_BIN_OP_T(op, int) \
+ DECL_BIN_OP_T(op, unsigned int) \
+ DECL_BIN_OP_T(op, long) \
+ DECL_BIN_OP_T(op, unsigned long) \
+ DECL_BIN_OP_T(op, float) \
+ DECL_BIN_OP_T(op, double) \
+ DECL_BIN_OP_T(op, const char *) \
+ DECL_BIN_OP_OTHER(op)
+
+ DECL_BIN_OP(*, mult)
+ DECL_BIN_OP(+, add)
+ DECL_BIN_OP(-, sub)
+// don't use macro
+// DECL_BIN_OP(/, div)
+ friend const sc_fxval_fast operator / (const sc_fxval_fast &,
+ const sc_fxval_fast &);
+ DECL_BIN_OP_T(/, int)
+ DECL_BIN_OP_T(/, unsigned int)
+ DECL_BIN_OP_T(/, long)
+ DECL_BIN_OP_T(/, unsigned long)
+ DECL_BIN_OP_T(/, float)
+ DECL_BIN_OP_T(/, double)
+ DECL_BIN_OP_T(/, const char *)
+// DECL_BIN_OP_OTHER(/)
+
+ DECL_BIN_OP_T(/, int64) \
+ DECL_BIN_OP_T(/, uint64) \
+ DECL_BIN_OP_T(/, const sc_int_base &) \
+ DECL_BIN_OP_T(/, const sc_uint_base &) \
+ DECL_BIN_OP_T(/, const sc_signed &) \
+ DECL_BIN_OP_T(/, const sc_unsigned &)
+
+#undef DECL_BIN_OP_T
+#undef DECL_BIN_OP_OTHER
+#undef DECL_BIN_OP
+
+ friend const sc_fxval_fast operator << (const sc_fxval_fast &, int);
+ friend const sc_fxval_fast operator >> (const sc_fxval_fast &, int);
+
+ // binary functions
+#define DECL_BIN_FNC_T(fnc, tp) \
+ friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, tp); \
+ friend void fnc (sc_fxval_fast &, tp, const sc_fxval_fast &);
+
+#define DECL_BIN_FNC_OTHER(fnc) \
+ DECL_BIN_FNC_T(fnc, int64) \
+ DECL_BIN_FNC_T(fnc, uint64) \
+ DECL_BIN_FNC_T(fnc, const sc_int_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
+ DECL_BIN_FNC_T(fnc, const sc_signed &) \
+ DECL_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DECL_BIN_FNC(fnc) \
+ friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, \
+ const sc_fxval_fast &); \
+ DECL_BIN_FNC_T(fnc, int) \
+ DECL_BIN_FNC_T(fnc, unsigned int) \
+ DECL_BIN_FNC_T(fnc, long) \
+ DECL_BIN_FNC_T(fnc, unsigned long) \
+ DECL_BIN_FNC_T(fnc, float) \
+ DECL_BIN_FNC_T(fnc, double) \
+ DECL_BIN_FNC_T(fnc, const char *) \
+ DECL_BIN_FNC_T(fnc, const sc_fxval &) \
+ DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
+ DECL_BIN_FNC_OTHER(fnc)
+
+ DECL_BIN_FNC(mult)
+ DECL_BIN_FNC(div)
+ DECL_BIN_FNC(add)
+ DECL_BIN_FNC(sub)
+
+#undef DECL_BIN_FNC_T
+#undef DECL_BIN_FNC_OTHER
+#undef DECL_BIN_FNC
+
+ friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int);
+ friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int);
+
+ // relational (including equality) operators
+#define DECL_REL_OP_T(op, tp) \
+ friend bool operator op (const sc_fxval_fast &, tp); \
+ friend bool operator op (tp, const sc_fxval_fast &);
+
+#define DECL_REL_OP_OTHER(op) \
+ DECL_REL_OP_T(op, int64) \
+ DECL_REL_OP_T(op, uint64) \
+ DECL_REL_OP_T(op, const sc_int_base &) \
+ DECL_REL_OP_T(op, const sc_uint_base &) \
+ DECL_REL_OP_T(op, const sc_signed &) \
+ DECL_REL_OP_T(op, const sc_unsigned &)
+
+#define DECL_REL_OP(op) \
+ friend bool operator op (const sc_fxval_fast &, const sc_fxval_fast &); \
+ DECL_REL_OP_T(op, int) \
+ DECL_REL_OP_T(op, unsigned int) \
+ DECL_REL_OP_T(op, long) \
+ DECL_REL_OP_T(op, unsigned long) \
+ DECL_REL_OP_T(op, float) \
+ DECL_REL_OP_T(op, double) \
+ DECL_REL_OP_T(op, const char *) \
+ DECL_REL_OP_OTHER(op)
+
+ DECL_REL_OP(<)
+ DECL_REL_OP(<=)
+ DECL_REL_OP(>)
+ DECL_REL_OP(>=)
+ DECL_REL_OP(==)
+ DECL_REL_OP(!=)
+
+#undef DECL_REL_OP_T
+#undef DECL_REL_OP_OTHER
+#undef DECL_REL_OP
+
+ // assignment operators
+#define DECL_ASN_OP_T(op, tp) sc_fxval_fast &operator op(tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_fxval_fast & operator ++ ();
+ sc_fxval_fast & operator -- ();
+
+ // implicit conversion
+ operator double() const; // necessary evil!
+
+ // explicit conversion to primitive types
+ short to_short() const;
+ unsigned short to_ushort() const;
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ float to_float() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string() const;
+ const std::string to_string(sc_numrep) const;
+ const std::string to_string(sc_numrep, bool) const;
+ const std::string to_string(sc_fmt) const;
+ const std::string to_string(sc_numrep, sc_fmt) const;
+ const std::string to_string(sc_numrep, bool, sc_fmt) const;
+
+ const std::string to_dec() const;
+ const std::string to_bin() const;
+ const std::string to_oct() const;
+ const std::string to_hex() const;
+
+ // query value
+ bool is_neg() const;
+ bool is_zero() const;
+ bool is_nan() const;
+ bool is_inf() const;
+ bool is_normal() const;
+
+ bool rounding_flag() const;
+
+ // print or dump content
+ void print(::std::ostream & =::std::cout) const;
+ void scan(::std::istream & =::std::cin);
+ void dump(::std::ostream & =::std::cout) const;
+
+ // internal use only;
+ bool get_bit(int) const;
+
+ protected:
+ sc_fxval_fast_observer *lock_observer() const;
+ void unlock_observer(sc_fxval_fast_observer *) const;
+
+ static double from_string(const char *);
+ private:
+ double m_val;
+
+ mutable sc_fxval_fast_observer *m_observer;
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval
+//
+// Fixed-point value type; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+// protected method
+
+inline sc_fxval_observer *sc_fxval::observer() const { return m_observer; }
+
+// internal use only;
+inline sc_fxval::sc_fxval(scfx_rep *a) :
+ m_rep(a != 0 ? a : new scfx_rep), m_observer(0)
+{}
+
+
+// public constructors
+
+inline sc_fxval::sc_fxval(sc_fxval_observer *observer_) :
+ m_rep(new scfx_rep), m_observer(observer_)
+{
+ SC_FXVAL_OBSERVER_DEFAULT_
+ SC_FXVAL_OBSERVER_CONSTRUCT_(*this)
+}
+
+inline sc_fxval::sc_fxval(const sc_fxval &a, sc_fxval_observer *observer_) :
+ m_rep(new scfx_rep(*a.m_rep)), m_observer(observer_)
+{
+ SC_FXVAL_OBSERVER_DEFAULT_
+ SC_FXVAL_OBSERVER_READ_(a)
+ SC_FXVAL_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+}
+
+#define DEFN_CTOR_T(tp, arg) \
+inline sc_fxval::sc_fxval(tp a, sc_fxval_observer *observer_) : \
+ m_rep(new scfx_rep(arg)), m_observer(observer_) \
+{ \
+ SC_FXVAL_OBSERVER_DEFAULT_ \
+ SC_FXVAL_OBSERVER_CONSTRUCT_(*this) \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+}
+
+#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
+#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, a.to_double())
+#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.value())
+
+DEFN_CTOR_T_A(int)
+DEFN_CTOR_T_A(unsigned int)
+DEFN_CTOR_T_A(long)
+DEFN_CTOR_T_A(unsigned long)
+DEFN_CTOR_T_A(float)
+DEFN_CTOR_T_A(double)
+DEFN_CTOR_T_A(const char *)
+DEFN_CTOR_T_B(const sc_fxval_fast &)
+
+DEFN_CTOR_T_A(int64)
+DEFN_CTOR_T_A(uint64)
+DEFN_CTOR_T_C(const sc_int_base &)
+DEFN_CTOR_T_C(const sc_uint_base &)
+DEFN_CTOR_T_A(const sc_signed &)
+DEFN_CTOR_T_A(const sc_unsigned &)
+
+#undef DEFN_CTOR_T
+#undef DEFN_CTOR_T_A
+#undef DEFN_CTOR_T_B
+#undef DEFN_CTOR_T_C
+
+inline sc_fxval::~sc_fxval()
+{
+ SC_FXVAL_OBSERVER_DESTRUCT_(*this)
+ delete m_rep;
+}
+
+// internal use only;
+inline const scfx_rep *
+sc_fxval::get_rep() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep;
+}
+
+// internal use only;
+inline void
+sc_fxval::set_rep(scfx_rep *rep_)
+{
+ delete m_rep;
+ m_rep = rep_;
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+}
+
+// unary operators
+inline const sc_fxval
+sc_fxval::operator - () const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return sc_fxval(sc_dt::neg_scfx_rep(*m_rep));
+}
+
+inline const sc_fxval &
+sc_fxval::operator + () const
+{
+ // SC_FXVAL_OBSERVER_READ_(*this)
+ return *this;
+}
+
+// unary functions
+inline void
+neg(sc_fxval &c, const sc_fxval &a)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::neg_scfx_rep(*a.m_rep);
+ SC_FXVAL_OBSERVER_WRITE_(c)
+}
+
+// binary operators
+#define DEFN_BIN_OP_T(op, fnc, tp) \
+inline const sc_fxval \
+operator op (const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
+} \
+ \
+inline \
+const sc_fxval \
+operator op (tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
+}
+
+#define DEFN_BIN_OP_OTHER(op, fnc) \
+DEFN_BIN_OP_T(op, fnc, int64) \
+DEFN_BIN_OP_T(op, fnc, uint64) \
+DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
+DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
+DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
+DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
+
+#define DEFN_BIN_OP(op, fnc) \
+inline const sc_fxval \
+operator op (const sc_fxval &a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ return sc_fxval(sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep)); \
+} \
+ \
+DEFN_BIN_OP_T(op, fnc, int) \
+DEFN_BIN_OP_T(op, fnc, unsigned int) \
+DEFN_BIN_OP_T(op, fnc, long) \
+DEFN_BIN_OP_T(op, fnc, unsigned long) \
+DEFN_BIN_OP_T(op, fnc, float) \
+DEFN_BIN_OP_T(op, fnc, double) \
+DEFN_BIN_OP_T(op, fnc, const char *) \
+DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
+DEFN_BIN_OP_OTHER(op, fnc)
+
+DEFN_BIN_OP(*, mult)
+DEFN_BIN_OP(+, add)
+DEFN_BIN_OP(-, sub)
+// don't use macro
+//DEFN_BIN_OP(/, div)
+inline const sc_fxval
+operator / (const sc_fxval &a, const sc_fxval &b)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ SC_FXVAL_OBSERVER_READ_(b)
+ return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.m_rep));
+}
+
+DEFN_BIN_OP_T(/, div, int)
+DEFN_BIN_OP_T(/, div, unsigned int)
+DEFN_BIN_OP_T(/, div, long)
+DEFN_BIN_OP_T(/, div, unsigned long)
+DEFN_BIN_OP_T(/, div, float)
+DEFN_BIN_OP_T(/, div, double)
+DEFN_BIN_OP_T(/, div, const char *)
+DEFN_BIN_OP_T(/, div, const sc_fxval_fast &)
+//DEFN_BIN_OP_OTHER(/, div)
+
+DEFN_BIN_OP_T(/, div, int64)
+DEFN_BIN_OP_T(/, div, uint64)
+DEFN_BIN_OP_T(/, div, const sc_int_base &)
+DEFN_BIN_OP_T(/, div, const sc_uint_base &)
+DEFN_BIN_OP_T(/, div, const sc_signed &)
+DEFN_BIN_OP_T(/, div, const sc_unsigned &)
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP_OTHER
+#undef DEFN_BIN_OP
+
+inline const sc_fxval
+operator << (const sc_fxval &a, int b)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ return sc_fxval(sc_dt::lsh_scfx_rep(*a.m_rep, b));
+}
+
+inline const sc_fxval
+operator >> (const sc_fxval &a, int b)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ return sc_fxval(sc_dt::rsh_scfx_rep(*a.m_rep, b));
+}
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, tp) \
+inline void \
+fnc (sc_fxval &c, const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
+ SC_FXVAL_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval &c, tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
+ SC_FXVAL_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC_OTHER(fnc) \
+DEFN_BIN_FNC_T(fnc, int64) \
+DEFN_BIN_FNC_T(fnc, uint64) \
+DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
+DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
+DEFN_BIN_FNC_T(fnc, const sc_signed &) \
+DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
+
+#define DEFN_BIN_FNC(fnc) \
+inline void \
+fnc(sc_fxval &c, const sc_fxval &a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ delete c.m_rep; \
+ c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
+ SC_FXVAL_OBSERVER_WRITE_(c) \
+} \
+ \
+DEFN_BIN_FNC_T(fnc, int) \
+DEFN_BIN_FNC_T(fnc, unsigned int) \
+DEFN_BIN_FNC_T(fnc, long) \
+DEFN_BIN_FNC_T(fnc, unsigned long) \
+DEFN_BIN_FNC_T(fnc, float) \
+DEFN_BIN_FNC_T(fnc, double) \
+DEFN_BIN_FNC_T(fnc, const char *) \
+DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
+DEFN_BIN_FNC_OTHER(fnc)
+
+DEFN_BIN_FNC(mult)
+DEFN_BIN_FNC(div)
+DEFN_BIN_FNC(add)
+DEFN_BIN_FNC(sub)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC_OTHER
+#undef DEFN_BIN_FNC
+
+inline void
+lshift(sc_fxval &c, const sc_fxval &a, int b)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::lsh_scfx_rep(*a.m_rep, b);
+ SC_FXVAL_OBSERVER_WRITE_(c)
+}
+
+inline void
+rshift(sc_fxval &c, const sc_fxval &a, int b)
+{
+ SC_FXVAL_OBSERVER_READ_(a)
+ delete c.m_rep;
+ c.m_rep = sc_dt::rsh_scfx_rep(*a.m_rep, b);
+ SC_FXVAL_OBSERVER_WRITE_(c)
+}
+
+// relational (including equality) operators
+#define DEFN_REL_OP_T(op, ret, tp) \
+inline bool \
+operator op (const sc_fxval &a, tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ sc_fxval tmp(b); \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
+ return (ret); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ sc_fxval tmp(a); \
+ int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
+ return (ret); \
+}
+
+#define DEFN_REL_OP_OTHER(op, ret) \
+DEFN_REL_OP_T(op, ret, int64) \
+DEFN_REL_OP_T(op, ret, uint64) \
+DEFN_REL_OP_T(op, ret, const sc_int_base &) \
+DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
+DEFN_REL_OP_T(op, ret, const sc_signed &) \
+DEFN_REL_OP_T(op, ret, const sc_unsigned &)
+
+#define DEFN_REL_OP(op, ret) \
+inline bool \
+operator op (const sc_fxval &a, const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(a) \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
+ return (ret); \
+} \
+ \
+DEFN_REL_OP_T(op, ret, int) \
+DEFN_REL_OP_T(op, ret, unsigned int) \
+DEFN_REL_OP_T(op, ret, long) \
+DEFN_REL_OP_T(op, ret, unsigned long) \
+DEFN_REL_OP_T(op, ret, float) \
+DEFN_REL_OP_T(op, ret, double) \
+DEFN_REL_OP_T(op, ret, const char *) \
+DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
+DEFN_REL_OP_OTHER(op, ret)
+
+DEFN_REL_OP(<, result < 0)
+DEFN_REL_OP(<=, result <= 0)
+DEFN_REL_OP(>, result > 0 && result != 2)
+DEFN_REL_OP(>=, result >= 0 && result != 2)
+DEFN_REL_OP(==, result == 0)
+DEFN_REL_OP(!=, result != 0)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP_OTHER
+#undef DEFN_REL_OP
+
+// assignment operators
+inline sc_fxval &
+sc_fxval::operator = (const sc_fxval &a)
+{
+ if (&a != this) {
+ SC_FXVAL_OBSERVER_READ_(a)
+ *m_rep = *a.m_rep;
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+ }
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxval & \
+sc_fxval::operator = (tp b) \
+{ \
+ sc_fxval tmp(b); \
+ *m_rep = *tmp.m_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(float)
+DEFN_ASN_OP_T(double)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const sc_fxval_fast &)
+
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, fnc, tp) \
+inline sc_fxval & \
+sc_fxval::operator op (tp b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(*this) \
+ sc_fxval tmp(b); \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op, fnc) \
+DEFN_ASN_OP_T(op, fnc, int64) \
+DEFN_ASN_OP_T(op, fnc, uint64) \
+DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
+DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
+DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op, fnc) \
+inline sc_fxval & \
+sc_fxval::operator op (const sc_fxval &b) \
+{ \
+ SC_FXVAL_OBSERVER_READ_(*this) \
+ SC_FXVAL_OBSERVER_READ_(b) \
+ scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
+ delete m_rep; \
+ m_rep = new_rep; \
+ SC_FXVAL_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, fnc, int) \
+DEFN_ASN_OP_T(op, fnc, unsigned int) \
+DEFN_ASN_OP_T(op, fnc, long) \
+DEFN_ASN_OP_T(op, fnc, unsigned long) \
+DEFN_ASN_OP_T(op, fnc, float) \
+DEFN_ASN_OP_T(op, fnc, double) \
+DEFN_ASN_OP_T(op, fnc, const char *) \
+DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
+DEFN_ASN_OP_OTHER(op, fnc)
+
+DEFN_ASN_OP(*=, mult)
+DEFN_ASN_OP(/=, div)
+DEFN_ASN_OP(+=, add)
+DEFN_ASN_OP(-=, sub)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+inline sc_fxval &
+sc_fxval::operator <<= (int b)
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ m_rep->lshift(b);
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxval &
+sc_fxval::operator >>= (int b)
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ m_rep->rshift(b);
+ SC_FXVAL_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// auto-increment and auto-decrement
+inline const sc_fxval
+sc_fxval::operator ++ (int)
+{
+ sc_fxval c = *this;
+ (*this) += 1;
+ return c;
+}
+
+inline const sc_fxval
+sc_fxval::operator -- (int)
+{
+ sc_fxval c = *this;
+ (*this) -= 1;
+ return c;
+}
+
+inline sc_fxval &
+sc_fxval::operator ++ ()
+{
+ (*this) += 1;
+ return *this;
+}
+
+inline sc_fxval &
+sc_fxval::operator -- ()
+{
+ (*this) -= 1;
+ return *this;
+}
+
+// implicit conversion
+inline sc_fxval::operator double() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->to_double();
+}
+
+// explicit conversion to primitive types
+inline short
+sc_fxval::to_short() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<short>(m_rep->to_uint64());
+}
+
+inline unsigned short
+sc_fxval::to_ushort() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<unsigned short>(m_rep->to_uint64());
+}
+
+inline int
+sc_fxval::to_int() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<int>(m_rep->to_uint64());
+}
+
+inline int64
+sc_fxval::to_int64() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<int64>(m_rep->to_uint64());
+}
+
+inline unsigned int
+sc_fxval::to_uint() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<unsigned int>(m_rep->to_uint64());
+}
+
+inline uint64
+sc_fxval::to_uint64() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->to_uint64();
+}
+
+inline long
+sc_fxval::to_long() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<long>(m_rep->to_uint64());
+}
+
+inline unsigned long
+sc_fxval::to_ulong() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<unsigned long>(m_rep->to_uint64());
+}
+
+inline float
+sc_fxval::to_float() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return static_cast<float>(m_rep->to_double());
+}
+
+inline double
+sc_fxval::to_double() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->to_double();
+}
+
+// query value
+inline bool
+sc_fxval::is_neg() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->is_neg();
+}
+
+inline bool
+sc_fxval::is_zero() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->is_zero();
+}
+
+inline bool
+sc_fxval::is_nan() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->is_nan();
+}
+
+inline bool
+sc_fxval::is_inf() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->is_inf();
+}
+
+inline bool
+sc_fxval::is_normal() const
+{
+ SC_FXVAL_OBSERVER_READ_(*this)
+ return m_rep->is_normal();
+}
+
+inline bool
+sc_fxval::rounding_flag() const
+{
+ return m_rep->rounding_flag();
+}
+
+// internal use only;
+inline bool
+sc_fxval::get_bit(int i) const
+{
+ return m_rep->get_bit(i);
+}
+
+// protected methods and friend functions
+inline void
+sc_fxval::get_type(int &wl, int &iwl, sc_enc &enc) const
+{
+ m_rep->get_type(wl, iwl, enc);
+}
+
+inline const sc_fxval
+sc_fxval::quantization(const scfx_params &params, bool &q_flag) const
+{
+ return sc_fxval(sc_dt::quantization_scfx_rep(*m_rep, params, q_flag));
+}
+
+inline const sc_fxval
+sc_fxval::overflow(const scfx_params &params, bool &o_flag) const
+{
+ return sc_fxval(sc_dt::overflow_scfx_rep(*m_rep, params, o_flag));
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxval &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxval &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_fast
+//
+// Fixed-point value type; limited precision.
+// ----------------------------------------------------------------------------
+
+// protected method
+inline sc_fxval_fast_observer *
+sc_fxval_fast::observer() const
+{
+ return m_observer;
+}
+
+
+// public constructors
+inline sc_fxval_fast::sc_fxval_fast(sc_fxval_fast_observer *observer_) :
+ m_val(0.0), m_observer(observer_)
+{
+ SC_FXVAL_FAST_OBSERVER_DEFAULT_
+ SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this)
+}
+
+inline sc_fxval_fast::sc_fxval_fast(const sc_fxval_fast &a,
+ sc_fxval_fast_observer *observer_) :
+ m_val(a.m_val), m_observer(observer_)
+{
+ SC_FXVAL_FAST_OBSERVER_DEFAULT_
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this)
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+}
+
+#define DEFN_CTOR_T(tp, arg) \
+inline sc_fxval_fast::sc_fxval_fast( \
+ tp a, sc_fxval_fast_observer * observer_) : \
+ m_val(arg), m_observer(observer_) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
+ SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this) \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+}
+
+#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
+#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, from_string(a))
+#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
+
+DEFN_CTOR_T_A(int)
+DEFN_CTOR_T_A(unsigned int)
+DEFN_CTOR_T_A(long)
+DEFN_CTOR_T_A(unsigned long)
+DEFN_CTOR_T_A(float)
+DEFN_CTOR_T_A(double)
+DEFN_CTOR_T_B(const char *)
+DEFN_CTOR_T_C(const sc_fxval &)
+
+DEFN_CTOR_T_A(int64)
+DEFN_CTOR_T_A(uint64)
+DEFN_CTOR_T_C(const sc_int_base &)
+DEFN_CTOR_T_C(const sc_uint_base &)
+DEFN_CTOR_T_C(const sc_signed &)
+DEFN_CTOR_T_C(const sc_unsigned &)
+
+#undef DEFN_CTOR_T
+#undef DEFN_CTOR_T_A
+#undef DEFN_CTOR_T_B
+#undef DEFN_CTOR_T_C
+#undef DEFN_CTOR_T_D
+#undef DEFN_CTOR_T_E
+
+inline sc_fxval_fast::~sc_fxval_fast()
+{
+ SC_FXVAL_FAST_OBSERVER_DESTRUCT_(*this)
+}
+
+// internal use only;
+inline double
+sc_fxval_fast::get_val() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// internal use only;
+inline void
+sc_fxval_fast::set_val(double val_)
+{
+ m_val = val_;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+}
+
+// unary operators
+inline const sc_fxval_fast
+sc_fxval_fast::operator - () const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return sc_fxval_fast(-m_val);
+}
+
+inline const sc_fxval_fast &
+sc_fxval_fast::operator + () const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return *this;
+}
+
+// unary functions
+inline void
+neg(sc_fxval_fast &c, const sc_fxval_fast &a)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ c.m_val = - a.m_val;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c)
+}
+
+// binary operators
+#define DEFN_BIN_OP_T(op, tp) \
+inline const sc_fxval_fast \
+operator op (const sc_fxval_fast &a, tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ return sc_fxval_fast(a.m_val op tmp.m_val); \
+} \
+ \
+inline const sc_fxval_fast \
+operator op (tp a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ return sc_fxval_fast(tmp.m_val op b.m_val); \
+}
+
+#define DEFN_BIN_OP_OTHER(op) \
+DEFN_BIN_OP_T(op, int64) \
+DEFN_BIN_OP_T(op, uint64) \
+DEFN_BIN_OP_T(op, const sc_int_base &) \
+DEFN_BIN_OP_T(op, const sc_uint_base &) \
+DEFN_BIN_OP_T(op, const sc_signed &) \
+DEFN_BIN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_BIN_OP(op, dummy) \
+inline const sc_fxval_fast \
+operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ return sc_fxval_fast(a.m_val op b.m_val); \
+} \
+ \
+DEFN_BIN_OP_T(op, int) \
+DEFN_BIN_OP_T(op, unsigned int) \
+DEFN_BIN_OP_T(op, long) \
+DEFN_BIN_OP_T(op, unsigned long) \
+DEFN_BIN_OP_T(op, float) \
+DEFN_BIN_OP_T(op, double) \
+DEFN_BIN_OP_T(op, const char *) \
+DEFN_BIN_OP_OTHER(op)
+
+DEFN_BIN_OP(*, mult)
+DEFN_BIN_OP(+, add)
+DEFN_BIN_OP(-, sub)
+//DEFN_BIN_OP(/, div)
+inline const sc_fxval_fast
+operator / (const sc_fxval_fast &a, const sc_fxval_fast &b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ SC_FXVAL_FAST_OBSERVER_READ_(b)
+ return sc_fxval_fast(a.m_val / b.m_val);
+}
+
+DEFN_BIN_OP_T(/, int)
+DEFN_BIN_OP_T(/, unsigned int)
+DEFN_BIN_OP_T(/, long)
+DEFN_BIN_OP_T(/, unsigned long)
+DEFN_BIN_OP_T(/, float)
+DEFN_BIN_OP_T(/, double)
+DEFN_BIN_OP_T(/, const char *)
+//DEFN_BIN_OP_OTHER(/)
+
+DEFN_BIN_OP_T(/, int64)
+DEFN_BIN_OP_T(/, uint64)
+DEFN_BIN_OP_T(/, const sc_int_base &)
+DEFN_BIN_OP_T(/, const sc_uint_base &)
+DEFN_BIN_OP_T(/, const sc_signed &)
+DEFN_BIN_OP_T(/, const sc_unsigned &)
+
+
+#undef DEFN_BIN_OP_T
+#undef DEFN_BIN_OP_OTHER
+#undef DEFN_BIN_OP
+
+
+inline const sc_fxval_fast
+operator << (const sc_fxval_fast &a, int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ return sc_fxval_fast(a.m_val * scfx_pow2(b));
+}
+
+inline const sc_fxval_fast
+operator >> (const sc_fxval_fast &a, int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ return sc_fxval_fast(a.m_val * scfx_pow2(-b));
+}
+
+// binary functions
+#define DEFN_BIN_FNC_T(fnc, op, tp) \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ c.m_val = a.m_val op tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+inline void \
+fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ c.m_val = tmp.m_val op b.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
+}
+
+#define DEFN_BIN_FNC_OTHER(fnc, op) \
+DEFN_BIN_FNC_T(fnc, op, int64) \
+DEFN_BIN_FNC_T(fnc, op, uint64) \
+DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
+DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
+
+#define DEFN_BIN_FNC(fnc, op) \
+inline void \
+fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ c.m_val = a.m_val op b.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
+} \
+ \
+DEFN_BIN_FNC_T(fnc, op, int) \
+DEFN_BIN_FNC_T(fnc, op, unsigned int) \
+DEFN_BIN_FNC_T(fnc, op, long) \
+DEFN_BIN_FNC_T(fnc, op, unsigned long) \
+DEFN_BIN_FNC_T(fnc, op, float) \
+DEFN_BIN_FNC_T(fnc, op, double) \
+DEFN_BIN_FNC_T(fnc, op, const char *) \
+DEFN_BIN_FNC_OTHER(fnc, op)
+
+DEFN_BIN_FNC(mult, *)
+DEFN_BIN_FNC(div, /)
+DEFN_BIN_FNC(add, +)
+DEFN_BIN_FNC(sub, -)
+
+#undef DEFN_BIN_FNC_T
+#undef DEFN_BIN_FNC_OTHER
+#undef DEFN_BIN_FNC
+
+inline void
+lshift(sc_fxval_fast &c, const sc_fxval_fast &a, int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ c.m_val = a.m_val * scfx_pow2(b);
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c)
+}
+
+inline void
+rshift(sc_fxval_fast &c, const sc_fxval_fast &a, int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ c.m_val = a.m_val * scfx_pow2(-b);
+ SC_FXVAL_FAST_OBSERVER_WRITE_(c)
+}
+
+// relational (including equality) operators
+#define DEFN_REL_OP_T(op, tp) \
+inline bool \
+operator op (const sc_fxval_fast &a, tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ sc_fxval_fast tmp(b); \
+ return (a.m_val op tmp.m_val); \
+} \
+ \
+inline bool \
+operator op (tp a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ sc_fxval_fast tmp(a); \
+ return (tmp.m_val op b.m_val); \
+}
+
+#define DEFN_REL_OP_OTHER(op) \
+DEFN_REL_OP_T(op, int64) \
+DEFN_REL_OP_T(op, uint64) \
+DEFN_REL_OP_T(op, const sc_int_base &) \
+DEFN_REL_OP_T(op, const sc_uint_base &) \
+DEFN_REL_OP_T(op, const sc_signed &) \
+DEFN_REL_OP_T(op, const sc_unsigned &)
+
+#define DEFN_REL_OP(op) \
+inline bool \
+operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(a) \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ return (a.m_val op b.m_val); \
+} \
+ \
+DEFN_REL_OP_T(op, int) \
+DEFN_REL_OP_T(op, unsigned int) \
+DEFN_REL_OP_T(op, long) \
+DEFN_REL_OP_T(op, unsigned long) \
+DEFN_REL_OP_T(op, float) \
+DEFN_REL_OP_T(op, double) \
+DEFN_REL_OP_T(op, const char *) \
+DEFN_REL_OP_OTHER(op)
+
+DEFN_REL_OP(<)
+DEFN_REL_OP(<=)
+DEFN_REL_OP(>)
+DEFN_REL_OP(>=)
+DEFN_REL_OP(==)
+DEFN_REL_OP(!=)
+
+#undef DEFN_REL_OP_T
+#undef DEFN_REL_OP_OTHER
+#undef DEFN_REL_OP
+
+// assignment operators
+inline sc_fxval_fast &
+sc_fxval_fast::operator = (const sc_fxval_fast &a)
+{
+ if (&a != this) {
+ SC_FXVAL_FAST_OBSERVER_READ_(a)
+ m_val = a.m_val;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ }
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(tp) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator = (tp a) \
+{ \
+ sc_fxval_fast tmp(a); \
+ m_val = tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(int)
+DEFN_ASN_OP_T(unsigned int)
+DEFN_ASN_OP_T(long)
+DEFN_ASN_OP_T(unsigned long)
+DEFN_ASN_OP_T(float)
+DEFN_ASN_OP_T(double)
+DEFN_ASN_OP_T(const char *)
+DEFN_ASN_OP_T(const sc_fxval &)
+
+DEFN_ASN_OP_T(int64)
+DEFN_ASN_OP_T(uint64)
+DEFN_ASN_OP_T(const sc_int_base &)
+DEFN_ASN_OP_T(const sc_uint_base &)
+DEFN_ASN_OP_T(const sc_signed &)
+DEFN_ASN_OP_T(const sc_unsigned &)
+
+#undef DEFN_ASN_OP_T
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator op (tp b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(*this) \
+ sc_fxval_fast tmp(b); \
+ m_val op tmp.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+inline sc_fxval_fast & \
+sc_fxval_fast::operator op (const sc_fxval_fast &b) \
+{ \
+ SC_FXVAL_FAST_OBSERVER_READ_(*this) \
+ SC_FXVAL_FAST_OBSERVER_READ_(b) \
+ m_val op b.m_val; \
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+} \
+ \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+inline sc_fxval_fast &
+sc_fxval_fast::operator <<= (int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ m_val *= scfx_pow2(b);
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxval_fast &
+sc_fxval_fast::operator >>= (int b)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ m_val *= scfx_pow2(-b);
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// auto-increment and auto-decrement
+inline const sc_fxval_fast
+sc_fxval_fast::operator ++ (int)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ double c = m_val;
+ m_val = m_val + 1;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return sc_fxval_fast(c);
+}
+
+inline const sc_fxval_fast
+sc_fxval_fast::operator -- (int)
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ double c = m_val;
+ m_val = m_val - 1;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return sc_fxval_fast(c);
+}
+
+inline sc_fxval_fast &
+sc_fxval_fast::operator ++ ()
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ m_val = m_val + 1;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+inline sc_fxval_fast &
+sc_fxval_fast::operator -- ()
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ m_val = m_val - 1;
+ SC_FXVAL_FAST_OBSERVER_WRITE_(*this)
+ return *this;
+}
+
+// implicit conversion
+inline sc_fxval_fast::operator double() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// explicit conversion to primitive types
+inline short
+sc_fxval_fast::to_short() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<short>(to_uint64());
+}
+
+inline unsigned short
+sc_fxval_fast::to_ushort() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned short>(to_uint64());
+}
+
+inline int64
+sc_fxval_fast::to_int64() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<int64>(to_uint64());
+}
+
+inline int
+sc_fxval_fast::to_int() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<int>(to_uint64());
+}
+
+inline unsigned int
+sc_fxval_fast::to_uint() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned int>(to_uint64());
+}
+
+inline uint64
+sc_fxval_fast::to_uint64() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in is_normal
+ if (!is_normal()) {
+ return 0;
+ }
+
+ int exponent;
+ double mantissa_dbl = frexp(m_val, &exponent);
+
+ uint64 mantissa = static_cast<uint64>(
+ fabs(mantissa_dbl) * (UINT64_ONE << 53));
+ exponent -= 53;
+
+ if (!(-64 < exponent && exponent < 64)) {
+ return 0;
+ }
+
+ mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
+ return mantissa_dbl >= 0 ? mantissa : -mantissa;
+}
+
+inline long
+sc_fxval_fast::to_long() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<long>(to_uint64());
+}
+
+inline unsigned long
+sc_fxval_fast::to_ulong() const
+{
+ // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
+ return static_cast<unsigned long>(to_uint64());
+}
+
+inline float
+sc_fxval_fast::to_float() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return static_cast<float>(m_val);
+}
+
+inline double
+sc_fxval_fast::to_double() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ return m_val;
+}
+
+// query value
+inline bool
+sc_fxval_fast::is_neg() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return (id.negative() != 0);
+}
+
+inline bool
+sc_fxval_fast::is_zero() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return id.is_zero();
+}
+
+inline bool
+sc_fxval_fast::is_nan() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return id.is_nan();
+}
+
+inline bool
+sc_fxval_fast::is_inf() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return id.is_inf();
+}
+
+inline bool
+sc_fxval_fast::is_normal() const
+{
+ SC_FXVAL_FAST_OBSERVER_READ_(*this)
+ scfx_ieee_double id(m_val);
+ return (id.is_normal() || id.is_subnormal() || id.is_zero());
+}
+
+inline bool
+sc_fxval_fast::rounding_flag() const
+{
+ // does not apply to sc_fxval_fast; included for API compatibility
+ return false;
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_fxval_fast &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_fxval_fast &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#undef SCFX_EXPLICIT_
+#undef SCFX_EXPLICIT_OTHER_
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
diff --git a/src/systemc/ext/dt/fx/sc_fxval_observer.hh b/src/systemc/ext/dt/fx/sc_fxval_observer.hh
new file mode 100644
index 000000000..9a519aa87
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_fxval_observer.hh
@@ -0,0 +1,178 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_fxval_observer.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_fxval_observer.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_FXVAL_OBSERVER_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_FXVAL_OBSERVER_HH__
+
+#include "sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_fxval_observer;
+class sc_fxval_fast_observer;
+
+// forward class declarations
+class sc_fxval;
+class sc_fxval_fast;
+
+#ifdef SC_ENABLE_OBSERVERS
+
+#define SC_FXVAL_OBSERVER_CONSTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxval_observer *, construct)
+#define SC_FXVAL_OBSERVER_DESTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxval_observer *, destruct)
+#define SC_FXVAL_OBSERVER_READ_(object) \
+ SC_OBSERVER_(object, sc_fxval_observer *, read)
+#define SC_FXVAL_OBSERVER_WRITE_(object) \
+ SC_OBSERVER_(object, sc_fxval_observer *, write)
+#define SC_FXVAL_OBSERVER_DEFAULT_ \
+ SC_OBSERVER_DEFAULT_(sc_fxval_observer)
+
+#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxval_fast_observer *, construct)
+#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object) \
+ SC_OBSERVER_(object, sc_fxval_fast_observer *, destruct)
+#define SC_FXVAL_FAST_OBSERVER_READ_(object) \
+ SC_OBSERVER_(object, sc_fxval_fast_observer *, read)
+#define SC_FXVAL_FAST_OBSERVER_WRITE_(object) \
+ SC_OBSERVER_(object, sc_fxval_fast_observer *, write)
+#define SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
+ SC_OBSERVER_DEFAULT_(sc_fxval_fast_observer)
+
+#else
+
+#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
+#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
+#define SC_FXVAL_OBSERVER_READ_(object)
+#define SC_FXVAL_OBSERVER_WRITE_(object)
+#define SC_FXVAL_OBSERVER_DEFAULT_
+
+#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
+#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
+#define SC_FXVAL_FAST_OBSERVER_READ_(object)
+#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
+#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
+
+#endif
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_observer
+//
+// Abstract base class for fixed-point value type observers;
+// arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxval_observer
+{
+ protected:
+ sc_fxval_observer() {}
+ virtual ~sc_fxval_observer() {}
+ public:
+ virtual void construct(const sc_fxval &);
+ virtual void destruct(const sc_fxval &);
+ virtual void read(const sc_fxval &);
+ virtual void write(const sc_fxval &);
+
+ static sc_fxval_observer *(*default_observer) ();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_fast_observer
+//
+// Abstract base class for fixed-point value type observers;
+// limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_fxval_fast_observer
+{
+ protected:
+ sc_fxval_fast_observer() {}
+ virtual ~sc_fxval_fast_observer() {}
+
+ public:
+ virtual void construct(const sc_fxval_fast &);
+ virtual void destruct(const sc_fxval_fast &);
+ virtual void read(const sc_fxval_fast &);
+ virtual void write(const sc_fxval_fast &);
+
+ static sc_fxval_fast_observer *(*default_observer) ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_observer
+//
+// Abstract base class for fixed-point value type observers;
+// arbitrary precision.
+// ----------------------------------------------------------------------------
+
+inline void sc_fxval_observer::construct(const sc_fxval &) {}
+inline void sc_fxval_observer::destruct(const sc_fxval &) {}
+inline void sc_fxval_observer::read(const sc_fxval &) {}
+inline void sc_fxval_observer::write(const sc_fxval &) {}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_fxval_fast_observer
+//
+// Abstract base class for fixed-point value type observers;
+// limited precision.
+// ----------------------------------------------------------------------------
+
+inline void sc_fxval_fast_observer::construct(const sc_fxval_fast &) {}
+inline void sc_fxval_fast_observer::destruct(const sc_fxval_fast &) {}
+inline void sc_fxval_fast_observer::read(const sc_fxval_fast &) {}
+inline void sc_fxval_fast_observer::write(const sc_fxval_fast &) {}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_FXVAL_OBSERVER_HH__
diff --git a/src/systemc/ext/dt/fx/sc_ufix.hh b/src/systemc/ext/dt/fx/sc_ufix.hh
new file mode 100644
index 000000000..1cb3d616d
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_ufix.hh
@@ -0,0 +1,1354 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_ufix.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_ufix.h,v $
+// Revision 1.2 2011/01/20 22:52:30 acg
+// Andy Goodrich: Add float constructors.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
+
+#include "sc_fxnum.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_ufix;
+class sc_ufix_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_ufix
+//
+// "Unconstrained" unsigned fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+class sc_ufix : public sc_fxnum
+{
+ public:
+ // constructors
+ explicit sc_ufix(sc_fxnum_observer * =0);
+ sc_ufix(int, int, sc_fxnum_observer * =0);
+ sc_ufix(sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
+ sc_ufix(sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
+ sc_ufix(int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
+ sc_ufix(int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
+ explicit sc_ufix(const sc_fxcast_switch &, sc_fxnum_observer * =0);
+ sc_ufix(int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+ sc_ufix(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_ufix(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_ufix(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ sc_ufix(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+ explicit sc_ufix(const sc_fxtype_params &, sc_fxnum_observer * =0);
+ sc_ufix(const sc_fxtype_params &, const sc_fxcast_switch &,
+ sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T(tp) \
+ sc_ufix(tp, int, int, sc_fxnum_observer * =0); \
+ sc_ufix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
+ sc_ufix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
+ sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
+ sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
+ sc_ufix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_ufix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_ufix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_ufix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0); \
+ sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ const sc_fxcast_switch &, sc_fxnum_observer * =0); \
+ sc_ufix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
+ sc_ufix(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
+ sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_ufix(tp, sc_fxnum_observer * =0); \
+ DECL_CTORS_T(tp)
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_ufix(tp, sc_fxnum_observer * =0); \
+ DECL_CTORS_T(tp)
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_ufix(const sc_ufix &);
+
+ // unary bitwise operators
+ const sc_ufix operator ~ () const;
+
+ // unary bitwise functions
+ friend void b_not(sc_ufix &, const sc_ufix &);
+
+ // binary bitwise operators
+ friend const sc_ufix operator & (const sc_ufix &, const sc_ufix &);
+ friend const sc_ufix operator & (const sc_ufix &, const sc_ufix_fast &);
+ friend const sc_ufix operator & (const sc_ufix_fast &, const sc_ufix &);
+ friend const sc_ufix operator | (const sc_ufix &, const sc_ufix &);
+ friend const sc_ufix operator | (const sc_ufix &, const sc_ufix_fast &);
+ friend const sc_ufix operator | (const sc_ufix_fast &, const sc_ufix &);
+ friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix &);
+ friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix_fast &);
+ friend const sc_ufix operator ^ (const sc_ufix_fast &, const sc_ufix &);
+
+ // binary bitwise functions
+ friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix &);
+ friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
+ friend void b_and(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
+ friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix &);
+ friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
+ friend void b_or(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
+ friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix &);
+ friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
+ friend void b_xor(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
+
+ // assignment operators
+ sc_ufix &operator = (const sc_ufix &);
+
+#define DECL_ASN_OP_T(op,tp) sc_ufix &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_ufix &)
+ DECL_ASN_OP_T(&=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(|=, const sc_ufix &)
+ DECL_ASN_OP_T(|=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(^=, const sc_ufix &)
+ DECL_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_ufix& operator ++ ();
+ sc_ufix& operator -- ();
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_ufix_fast
+//
+// "Unconstrained" unsigned fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+class sc_ufix_fast : public sc_fxnum_fast
+{
+ public:
+ // constructors
+ explicit sc_ufix_fast(sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, int,
+ sc_fxnum_fast_observer * =0);
+ explicit sc_ufix_fast(const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch&,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+ explicit sc_ufix_fast(const sc_fxtype_params &,
+ sc_fxnum_fast_observer * =0);
+ sc_ufix_fast(const sc_fxtype_params &, const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T(tp) \
+ sc_ufix_fast(tp, int, int, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
+ sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, int, int, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
+ const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
+ const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * =0); \
+ sc_ufix_fast(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_ufix_fast(tp, sc_fxnum_fast_observer * =0); \
+ DECL_CTORS_T(tp)
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_ufix_fast(tp, sc_fxnum_fast_observer * =0); \
+ DECL_CTORS_T(tp)
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+
+ // copy constructor
+ sc_ufix_fast(const sc_ufix_fast &);
+
+ // unary bitwise operators
+ const sc_ufix_fast operator ~ () const;
+
+ // unary bitwise functions
+ friend void b_not(sc_ufix_fast &, const sc_ufix_fast &);
+
+
+ // binary bitwise operators
+
+ friend const sc_ufix_fast operator & (const sc_ufix_fast &,
+ const sc_ufix_fast &);
+ friend const sc_ufix_fast operator ^ (const sc_ufix_fast &,
+ const sc_ufix_fast &);
+ friend const sc_ufix_fast operator | (const sc_ufix_fast &,
+ const sc_ufix_fast &);
+
+
+ // binary bitwise functions
+
+ friend void b_and(sc_ufix_fast &, const sc_ufix_fast &,
+ const sc_ufix_fast &);
+ friend void b_or(sc_ufix_fast &, const sc_ufix_fast &,
+ const sc_ufix_fast &);
+ friend void b_xor(sc_ufix_fast &, const sc_ufix_fast &,
+ const sc_ufix_fast &);
+
+ // assignment operators
+ sc_ufix_fast &operator = (const sc_ufix_fast &);
+
+#define DECL_ASN_OP_T(op,tp) sc_ufix_fast &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_ufix &)
+ DECL_ASN_OP_T(&=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(|=, const sc_ufix &)
+ DECL_ASN_OP_T(|=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(^=, const sc_ufix &)
+ DECL_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_ufix_fast &operator ++ ();
+ sc_ufix_fast &operator -- ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_ufix
+//
+// "Unconstrained" unsigned fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+// constructors
+
+inline sc_ufix::sc_ufix(sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(), SC_US_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_fxnum_observer *observer_ ) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline
+sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix::sc_ufix(const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_ ) :
+ sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
+ observer_)
+{}
+
+inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
+ observer_)
+{}
+
+inline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
+ sc_fxnum_observer *observer_) :
+ sc_fxnum(type_params_, SC_US_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_ ) :
+ sc_fxnum(type_params_, SC_US_, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T_A(tp) \
+inline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_ ) : \
+ sc_fxnum(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
+ observer_ ) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
+ observer_ ) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(), \
+ observer_ ) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_observer * observer_) : \
+ sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
+{}
+
+#define DEFN_CTORS_T_B(tp) \
+inline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline \
+sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_observer* observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch& cast_sw, \
+ sc_fxnum_observer* observer_) : \
+ sc_fxnum(a, a.type_params(), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ int nb, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T_A(int)
+DEFN_CTORS_T_A(unsigned int)
+DEFN_CTORS_T_A(long)
+DEFN_CTORS_T_A(unsigned long)
+DEFN_CTORS_T_A(float)
+DEFN_CTORS_T_A(double)
+DEFN_CTORS_T_A(const char *)
+DEFN_CTORS_T_A(const sc_fxval &)
+DEFN_CTORS_T_A(const sc_fxval_fast &)
+DEFN_CTORS_T_B(const sc_fxnum &)
+DEFN_CTORS_T_B(const sc_fxnum_fast &)
+
+DEFN_CTORS_T_A(int64)
+DEFN_CTORS_T_A(uint64)
+DEFN_CTORS_T_A(const sc_int_base &)
+DEFN_CTORS_T_A(const sc_uint_base &)
+DEFN_CTORS_T_A(const sc_signed &)
+DEFN_CTORS_T_A(const sc_unsigned &)
+
+#undef DEFN_CTORS_T_A
+#undef DEFN_CTORS_T_B
+
+// copy constructor
+
+inline sc_ufix::sc_ufix(const sc_ufix &a) :
+ sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
+{}
+
+// unary bitwise operators
+inline const sc_ufix
+sc_ufix::operator ~ () const
+{
+ SC_FXNUM_OBSERVER_READ_(*this)
+ int iwl_c = iwl();
+ int wl_c = wl();
+ sc_ufix c(wl_c, iwl_c);
+ for (int i = iwl_c - wl_c; i < iwl_c; ++i)
+ c.set_bit(i, !get_bit(i));
+ return sc_ufix(c, wl_c, iwl_c);
+}
+
+// unary bitwise functions
+inline void
+b_not(sc_ufix &c, const sc_ufix &a)
+{
+ SC_FXNUM_OBSERVER_READ_(a)
+ int iwl_c = c.iwl();
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
+ c.set_bit(i, !a.get_bit(i));
+ c.cast();
+ SC_FXNUM_OBSERVER_WRITE_(c)
+}
+
+// binary bitwise operators
+#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
+inline const sc_ufix \
+operator op (const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_a = a.iwl(); \
+ int iwl_b = b.iwl(); \
+ int iwl_c = sc_max(iwl_a, iwl_b); \
+ int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
+ sc_ufix c(iwl_c + fwl_c, iwl_c); \
+ for (int i = -fwl_c; i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ return sc_ufix(c, iwl_c + fwl_c, iwl_c); \
+}
+
+DEFN_BIN_OP_T(&, &&, sc_ufix, sc_ufix)
+DEFN_BIN_OP_T(&, &&, sc_ufix, sc_ufix_fast)
+DEFN_BIN_OP_T(&, &&, sc_ufix_fast, sc_ufix)
+
+DEFN_BIN_OP_T(|, ||, sc_ufix, sc_ufix)
+DEFN_BIN_OP_T(|, ||, sc_ufix, sc_ufix_fast)
+DEFN_BIN_OP_T(|, ||, sc_ufix_fast, sc_ufix)
+
+DEFN_BIN_OP_T(^, !=, sc_ufix, sc_ufix)
+DEFN_BIN_OP_T(^, !=, sc_ufix, sc_ufix_fast)
+DEFN_BIN_OP_T(^, !=, sc_ufix_fast, sc_ufix)
+
+#undef DEFN_BIN_OP_T
+
+// binary bitwise functions
+#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
+inline void \
+fnc (sc_ufix &c, const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_c = c.iwl(); \
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ c.cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(c) \
+}
+
+DEFN_BIN_FNC_T(b_and, &&, sc_ufix, sc_ufix)
+DEFN_BIN_FNC_T(b_and, &&, sc_ufix, sc_ufix_fast)
+DEFN_BIN_FNC_T(b_and, &&, sc_ufix_fast, sc_ufix)
+
+DEFN_BIN_FNC_T(b_or, ||, sc_ufix, sc_ufix)
+DEFN_BIN_FNC_T(b_or, ||, sc_ufix, sc_ufix_fast)
+DEFN_BIN_FNC_T(b_or, ||, sc_ufix_fast, sc_ufix)
+
+DEFN_BIN_FNC_T(b_xor, !=, sc_ufix, sc_ufix)
+DEFN_BIN_FNC_T(b_xor, !=, sc_ufix, sc_ufix_fast)
+DEFN_BIN_FNC_T(b_xor, !=, sc_ufix_fast, sc_ufix)
+
+#undef DEFN_BIN_FNC_T
+
+// assignment operators
+inline sc_ufix &
+sc_ufix::operator = (const sc_ufix &a)
+{
+ sc_fxnum::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_ufix & \
+sc_ufix::operator op (tp a) \
+{ \
+ sc_fxnum::operator op(a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+
+#define DEFN_ASN_OP_T(op, op2, tp) \
+inline sc_ufix & \
+sc_ufix::operator op (const tp &b) \
+{ \
+ SC_FXNUM_OBSERVER_READ_(*this) \
+ b.observer_read(); \
+ int iwl_c = iwl(); \
+ for (int i = iwl_c - wl(); i < iwl_c; ++i) \
+ set_bit(i, get_bit(i) op2 b.get_bit(i)); \
+ cast(); \
+ SC_FXNUM_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(&=, &&, sc_ufix)
+DEFN_ASN_OP_T(&=, &&, sc_ufix_fast)
+DEFN_ASN_OP_T(|=, ||, sc_ufix)
+DEFN_ASN_OP_T(|=, ||, sc_ufix_fast)
+DEFN_ASN_OP_T(^=, !=, sc_ufix)
+DEFN_ASN_OP_T(^=, !=, sc_ufix_fast)
+
+#undef DEFN_ASN_OP_T
+
+// auto-increment and auto-decrement
+inline const sc_fxval
+sc_ufix::operator ++ (int)
+{
+ return sc_fxval(sc_fxnum::operator ++ (0));
+}
+
+inline const sc_fxval
+sc_ufix::operator -- (int)
+{
+ return sc_fxval(sc_fxnum::operator -- (0));
+}
+
+inline sc_ufix &
+sc_ufix::operator ++ ()
+{
+ sc_fxnum::operator ++ ();
+ return *this;
+}
+
+inline sc_ufix &
+sc_ufix::operator -- ()
+{
+ sc_fxnum::operator -- ();
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_ufix_fast
+//
+// "Unconstrained" unsigned fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+// constructors
+
+inline sc_ufix_fast::sc_ufix_fast(sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(), SC_US_, sc_fxcast_switch(),
+ observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(int wl_, int iwl_,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(),
+ observer_ )
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
+ sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ sc_q_mode qm, sc_o_mode om, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ sc_q_mode qm, sc_o_mode om, int nb, const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
+ observer_ )
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(
+ int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
+ observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(type_params_, SC_US_, sc_fxcast_switch(), observer_)
+{}
+
+inline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_fxnum_fast(type_params_, SC_US_, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T_A(tp) \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer* observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
+ sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
+ sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
+{}
+
+#define DEFN_CTORS_T_B(tp) \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
+ sc_fxnum_fast_observer* observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer* observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer* observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, a.type_params(), SC_US_, cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
+ observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast( \
+ tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
+ const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
+ cast_sw, observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
+{} \
+ \
+inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
+ const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer* observer_) : \
+ sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T_A(int)
+DEFN_CTORS_T_A(unsigned int)
+DEFN_CTORS_T_A(long)
+DEFN_CTORS_T_A(unsigned long)
+DEFN_CTORS_T_A(float)
+DEFN_CTORS_T_A(double)
+DEFN_CTORS_T_A(const char *)
+DEFN_CTORS_T_A(const sc_fxval &)
+DEFN_CTORS_T_A(const sc_fxval_fast &)
+DEFN_CTORS_T_B(const sc_fxnum &)
+DEFN_CTORS_T_B(const sc_fxnum_fast &)
+
+DEFN_CTORS_T_A(int64)
+DEFN_CTORS_T_A(uint64)
+DEFN_CTORS_T_A(const sc_int_base &)
+DEFN_CTORS_T_A(const sc_uint_base &)
+DEFN_CTORS_T_A(const sc_signed &)
+DEFN_CTORS_T_A(const sc_unsigned &)
+
+#undef DEFN_CTORS_T_A
+#undef DEFN_CTORS_T_B
+
+// copy constructor
+inline sc_ufix_fast::sc_ufix_fast(const sc_ufix_fast &a) :
+ sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
+{}
+
+// unary bitwise operators
+inline const sc_ufix_fast
+sc_ufix_fast::operator ~ () const
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(*this)
+ int iwl_c = iwl();
+ int wl_c = wl();
+ sc_ufix_fast c(wl_c, iwl_c);
+ for (int i = iwl_c - wl_c; i < iwl_c; ++i)
+ c.set_bit(i, !get_bit(i));
+ return sc_ufix_fast(c, wl_c, iwl_c);
+}
+
+// unary bitwise functions
+inline void
+b_not(sc_ufix_fast &c, const sc_ufix_fast &a)
+{
+ SC_FXNUM_FAST_OBSERVER_READ_(a)
+ int iwl_c = c.iwl();
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
+ c.set_bit(i, !a.get_bit(i));
+ c.cast();
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c)
+}
+
+// binary bitwise operators
+#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
+inline const sc_ufix_fast \
+operator op (const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_a = a.iwl(); \
+ int iwl_b = b.iwl(); \
+ int iwl_c = sc_max(iwl_a, iwl_b); \
+ int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
+ sc_ufix_fast c(iwl_c + fwl_c, iwl_c); \
+ for (int i = -fwl_c; i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ return sc_ufix_fast(c, iwl_c + fwl_c, iwl_c); \
+}
+
+DEFN_BIN_OP_T(&, &&, sc_ufix_fast, sc_ufix_fast)
+DEFN_BIN_OP_T(|, ||, sc_ufix_fast, sc_ufix_fast)
+DEFN_BIN_OP_T(^, !=, sc_ufix_fast, sc_ufix_fast)
+
+#undef DEFN_BIN_OP_T
+
+// binary bitwise functions
+#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
+inline void \
+fnc (sc_ufix_fast &c, const tp1 &a, const tp2 &b) \
+{ \
+ a.observer_read(); \
+ b.observer_read(); \
+ int iwl_c = c.iwl(); \
+ for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
+ c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
+ c.cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
+}
+
+DEFN_BIN_FNC_T(b_and, &&, sc_ufix_fast, sc_ufix_fast)
+DEFN_BIN_FNC_T(b_or, ||, sc_ufix_fast, sc_ufix_fast)
+DEFN_BIN_FNC_T(b_xor, !=, sc_ufix_fast, sc_ufix_fast)
+
+#undef DEFN_BIN_FNC_T
+
+// assignment operators
+inline sc_ufix_fast &
+sc_ufix_fast::operator = (const sc_ufix_fast &a)
+{
+ sc_fxnum_fast::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+inline sc_ufix_fast & \
+sc_ufix_fast::operator op (tp a) \
+{ \
+ sc_fxnum_fast::operator op(a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+#define DEFN_ASN_OP_T(op, op2, tp) \
+inline sc_ufix_fast & \
+sc_ufix_fast::operator op (const tp &b) \
+{ \
+ SC_FXNUM_FAST_OBSERVER_READ_(*this) \
+ b.observer_read(); \
+ int iwl_c = iwl(); \
+ for (int i = iwl_c - wl(); i < iwl_c; ++i) \
+ set_bit(i, get_bit(i) op2 b.get_bit(i)); \
+ cast(); \
+ SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
+ return *this; \
+}
+
+DEFN_ASN_OP_T(&=, &&, sc_ufix)
+DEFN_ASN_OP_T(&=, &&, sc_ufix_fast)
+DEFN_ASN_OP_T(|=, ||, sc_ufix)
+DEFN_ASN_OP_T(|=, ||, sc_ufix_fast)
+DEFN_ASN_OP_T(^=, !=, sc_ufix)
+DEFN_ASN_OP_T(^=, !=, sc_ufix_fast)
+
+#undef DEFN_ASN_OP_T
+
+// auto-increment and auto-decrement
+inline const sc_fxval_fast
+sc_ufix_fast::operator ++ (int)
+{
+ return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
+}
+
+inline const sc_fxval_fast
+sc_ufix_fast::operator -- (int)
+{
+ return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
+}
+
+inline sc_ufix_fast &
+sc_ufix_fast::operator ++ ()
+{
+ sc_fxnum_fast::operator ++ ();
+ return *this;
+}
+
+inline sc_ufix_fast &
+sc_ufix_fast::operator -- ()
+{
+ sc_fxnum_fast::operator -- ();
+ return *this;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
diff --git a/src/systemc/ext/dt/fx/sc_ufixed.hh b/src/systemc/ext/dt/fx/sc_ufixed.hh
new file mode 100644
index 000000000..9245b8e6c
--- /dev/null
+++ b/src/systemc/ext/dt/fx/sc_ufixed.hh
@@ -0,0 +1,585 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_ufixed.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_ufixed.h,v $
+// Revision 1.2 2011/01/19 18:57:40 acg
+// Andy Goodrich: changes for IEEE_1666_2011.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SC_UFIXED_HH__
+#define __SYSTEMC_EXT_DT_FX_SC_UFIXED_HH__
+
+#include "sc_ufix.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+class sc_ufixed;
+template <int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+class sc_ufixed_fast;
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_ufixed
+//
+// "Constrained" unsigned fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I,
+ sc_q_mode Q=SC_DEFAULT_Q_MODE_,
+ sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_>
+class sc_ufixed : public sc_ufix
+{
+ public:
+ // constructors
+ explicit sc_ufixed(sc_fxnum_observer * =0);
+ explicit sc_ufixed(const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_ufixed(tp, sc_fxnum_observer * =0); \
+ sc_ufixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_ufixed(tp, sc_fxnum_observer * =0); \
+ sc_ufixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0);
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+ // copy constructor
+ sc_ufixed(const sc_ufixed<W, I, Q, O, N> &);
+
+ // assignment operators
+ sc_ufixed &operator = (const sc_ufixed<W, I, Q, O, N> &);
+
+#define DECL_ASN_OP_T(op,tp) sc_ufixed &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_ufix &)
+ DECL_ASN_OP_T(&=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(|=, const sc_ufix &)
+ DECL_ASN_OP_T(|=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(^=, const sc_ufix &)
+ DECL_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval operator ++ (int);
+ const sc_fxval operator -- (int);
+
+ sc_ufixed &operator ++ ();
+ sc_ufixed &operator -- ();
+};
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_ufixed_fast
+//
+// "Constrained" unsigned fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+template <int W, int I,
+ sc_q_mode Q=SC_DEFAULT_Q_MODE_,
+ sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_>
+class sc_ufixed_fast : public sc_ufix_fast
+{
+ public:
+ // constructors
+ explicit sc_ufixed_fast(sc_fxnum_fast_observer * =0);
+ explicit sc_ufixed_fast(const sc_fxcast_switch &,
+ sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T_A(tp) \
+ sc_ufixed_fast(tp, sc_fxnum_fast_observer * =0); \
+ sc_ufixed_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * =0);
+
+#define DECL_CTORS_T_B(tp) \
+ explicit sc_ufixed_fast(tp, sc_fxnum_fast_observer * =0); \
+ sc_ufixed_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * =0);
+
+ DECL_CTORS_T_A(int)
+ DECL_CTORS_T_A(unsigned int)
+ DECL_CTORS_T_A(long)
+ DECL_CTORS_T_A(unsigned long)
+ DECL_CTORS_T_A(float)
+ DECL_CTORS_T_A(double)
+ DECL_CTORS_T_A(const char *)
+ DECL_CTORS_T_A(const sc_fxval &)
+ DECL_CTORS_T_A(const sc_fxval_fast &)
+ DECL_CTORS_T_A(const sc_fxnum &)
+ DECL_CTORS_T_A(const sc_fxnum_fast &)
+
+ DECL_CTORS_T_B(int64)
+ DECL_CTORS_T_B(uint64)
+ DECL_CTORS_T_B(const sc_int_base &)
+ DECL_CTORS_T_B(const sc_uint_base &)
+ DECL_CTORS_T_B(const sc_signed &)
+ DECL_CTORS_T_B(const sc_unsigned &)
+
+#undef DECL_CTORS_T_A
+#undef DECL_CTORS_T_B
+ // copy constructor
+ sc_ufixed_fast(const sc_ufixed_fast<W, I, Q, O, N> &);
+
+ // assignment operators
+ sc_ufixed_fast &operator = (const sc_ufixed_fast<W, I, Q, O, N> &);
+
+#define DECL_ASN_OP_T(op,tp) sc_ufixed_fast &operator op (tp);
+
+#define DECL_ASN_OP_OTHER(op) \
+ DECL_ASN_OP_T(op, int64) \
+ DECL_ASN_OP_T(op, uint64) \
+ DECL_ASN_OP_T(op, const sc_int_base &) \
+ DECL_ASN_OP_T(op, const sc_uint_base &) \
+ DECL_ASN_OP_T(op, const sc_signed &) \
+ DECL_ASN_OP_T(op, const sc_unsigned &)
+
+#define DECL_ASN_OP(op) \
+ DECL_ASN_OP_T(op, int) \
+ DECL_ASN_OP_T(op, unsigned int) \
+ DECL_ASN_OP_T(op, long) \
+ DECL_ASN_OP_T(op, unsigned long) \
+ DECL_ASN_OP_T(op, float) \
+ DECL_ASN_OP_T(op, double) \
+ DECL_ASN_OP_T(op, const char *) \
+ DECL_ASN_OP_T(op, const sc_fxval &) \
+ DECL_ASN_OP_T(op, const sc_fxval_fast &) \
+ DECL_ASN_OP_T(op, const sc_fxnum &) \
+ DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
+ DECL_ASN_OP_OTHER(op)
+
+ DECL_ASN_OP(=)
+
+ DECL_ASN_OP(*=)
+ DECL_ASN_OP(/=)
+ DECL_ASN_OP(+=)
+ DECL_ASN_OP(-=)
+
+ DECL_ASN_OP_T(<<=, int)
+ DECL_ASN_OP_T(>>=, int)
+
+ DECL_ASN_OP_T(&=, const sc_ufix &)
+ DECL_ASN_OP_T(&=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(|=, const sc_ufix &)
+ DECL_ASN_OP_T(|=, const sc_ufix_fast &)
+ DECL_ASN_OP_T(^=, const sc_ufix &)
+ DECL_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DECL_ASN_OP_T
+#undef DECL_ASN_OP_OTHER
+#undef DECL_ASN_OP
+
+ // auto-increment and auto-decrement
+ const sc_fxval_fast operator ++ (int);
+ const sc_fxval_fast operator -- (int);
+
+ sc_ufixed_fast& operator ++ ();
+ sc_ufixed_fast& operator -- ();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_ufixed
+//
+// "Constrained" unsigned fixed-point class; arbitrary precision.
+// ----------------------------------------------------------------------------
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N>::sc_ufixed(sc_fxnum_observer *observer_) :
+ sc_ufix(W, I, Q, O, N, observer_)
+{}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N>::sc_ufixed(const sc_fxcast_switch &cast_sw,
+ sc_fxnum_observer *observer_) :
+ sc_ufix(W, I, Q, O, N, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T(tp) \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed<W, I, Q, O, N>::sc_ufixed( \
+ tp a, sc_fxnum_observer *observer_) :\
+ sc_ufix(a, W, I, Q, O, N, observer_) \
+{} \
+ \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed<W, I, Q, O, N>::sc_ufixed( \
+ tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_observer *observer_) : \
+ sc_ufix(a, W, I, Q, O, N, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T(int)
+DEFN_CTORS_T(unsigned int)
+DEFN_CTORS_T(long)
+DEFN_CTORS_T(unsigned long)
+DEFN_CTORS_T(float)
+DEFN_CTORS_T(double)
+DEFN_CTORS_T(const char *)
+DEFN_CTORS_T(const sc_fxval &)
+DEFN_CTORS_T(const sc_fxval_fast &)
+DEFN_CTORS_T(const sc_fxnum &)
+DEFN_CTORS_T(const sc_fxnum_fast &)
+
+DEFN_CTORS_T(int64)
+DEFN_CTORS_T(uint64)
+DEFN_CTORS_T(const sc_int_base &)
+DEFN_CTORS_T(const sc_uint_base &)
+DEFN_CTORS_T(const sc_signed &)
+DEFN_CTORS_T(const sc_unsigned &)
+
+#undef DEFN_CTORS_T
+
+// copy constructor
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N>::sc_ufixed(const sc_ufixed<W, I, Q, O, N> &a) :
+ sc_ufix(a, W, I, Q, O, N)
+{}
+
+// assignment operators
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N> &
+sc_ufixed<W, I, Q, O, N>::operator = (const sc_ufixed<W, I, Q, O, N> &a)
+{
+ sc_ufix::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op,tp) \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed<W, I, Q, O, N> & \
+sc_ufixed<W, I, Q, O, N>::operator op (tp a) \
+{ \
+ sc_ufix::operator op (a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+DEFN_ASN_OP_T(&=, const sc_ufix &)
+DEFN_ASN_OP_T(&=, const sc_ufix_fast &)
+DEFN_ASN_OP_T(|=, const sc_ufix &)
+DEFN_ASN_OP_T(|=, const sc_ufix_fast &)
+DEFN_ASN_OP_T(^=, const sc_ufix &)
+DEFN_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+// auto-increment and auto-decrement
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval
+sc_ufixed<W, I, Q, O, N>::operator ++ (int)
+{
+ return sc_fxval(sc_ufix::operator ++ (0));
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval
+sc_ufixed<W, I, Q, O, N>::operator -- (int)
+{
+ return sc_fxval(sc_ufix::operator -- (0));
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N> &
+sc_ufixed<W, I, Q, O, N>::operator ++ ()
+{
+ sc_ufix::operator ++ ();
+ return *this;
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed<W, I, Q, O, N> &
+sc_ufixed<W, I, Q, O, N>::operator -- ()
+{
+ sc_ufix::operator -- ();
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// TEMPLATE CLASS : sc_ufixed_fast
+//
+// "Constrained" unsigned fixed-point class; limited precision.
+// ----------------------------------------------------------------------------
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N>::sc_ufixed_fast(
+ sc_fxnum_fast_observer *observer_) :
+ sc_ufix_fast(W, I, Q, O, N, observer_)
+{}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N>::sc_ufixed_fast(
+ const sc_fxcast_switch &cast_sw,
+ sc_fxnum_fast_observer *observer_) :
+ sc_ufix_fast(W, I, Q, O, N, cast_sw, observer_)
+{}
+
+#define DEFN_CTORS_T(tp) \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed_fast<W, I, Q, O, N>::sc_ufixed_fast( \
+ tp a, sc_fxnum_fast_observer *observer_ ) : \
+ sc_ufix_fast(a, W, I, Q, O, N, observer_) \
+{} \
+ \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed_fast<W, I, Q, O, N>::sc_ufixed_fast( \
+ tp a, const sc_fxcast_switch &cast_sw, \
+ sc_fxnum_fast_observer *observer_) : \
+ sc_ufix_fast(a, W, I, Q, O, N, cast_sw, observer_) \
+{}
+
+DEFN_CTORS_T(int)
+DEFN_CTORS_T(unsigned int)
+DEFN_CTORS_T(long)
+DEFN_CTORS_T(unsigned long)
+DEFN_CTORS_T(float)
+DEFN_CTORS_T(double)
+DEFN_CTORS_T(const char *)
+DEFN_CTORS_T(const sc_fxval &)
+DEFN_CTORS_T(const sc_fxval_fast &)
+DEFN_CTORS_T(const sc_fxnum &)
+DEFN_CTORS_T(const sc_fxnum_fast &)
+
+DEFN_CTORS_T(int64)
+DEFN_CTORS_T(uint64)
+DEFN_CTORS_T(const sc_int_base &)
+DEFN_CTORS_T(const sc_uint_base &)
+DEFN_CTORS_T(const sc_signed &)
+DEFN_CTORS_T(const sc_unsigned &)
+
+#undef DEFN_CTORS_T
+
+// copy constructor
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N>::sc_ufixed_fast(
+ const sc_ufixed_fast<W, I, Q, O, N> &a) :
+ sc_ufix_fast(a, W, I, Q, O, N)
+{}
+
+// assignment operators
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N> &
+sc_ufixed_fast<W, I, Q, O, N>::operator = (
+ const sc_ufixed_fast<W, I, Q, O, N> &a)
+{
+ sc_ufix_fast::operator = (a);
+ return *this;
+}
+
+#define DEFN_ASN_OP_T(op, tp) \
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N> \
+inline sc_ufixed_fast<W, I, Q, O, N> & \
+sc_ufixed_fast<W, I, Q, O, N>::operator op (tp a) \
+{ \
+ sc_ufix_fast::operator op (a); \
+ return *this; \
+}
+
+#define DEFN_ASN_OP_OTHER(op) \
+DEFN_ASN_OP_T(op, int64) \
+DEFN_ASN_OP_T(op, uint64) \
+DEFN_ASN_OP_T(op, const sc_int_base &) \
+DEFN_ASN_OP_T(op, const sc_uint_base &) \
+DEFN_ASN_OP_T(op, const sc_signed &) \
+DEFN_ASN_OP_T(op, const sc_unsigned &)
+
+#define DEFN_ASN_OP(op) \
+DEFN_ASN_OP_T(op, int) \
+DEFN_ASN_OP_T(op, unsigned int) \
+DEFN_ASN_OP_T(op, long) \
+DEFN_ASN_OP_T(op, unsigned long) \
+DEFN_ASN_OP_T(op, float) \
+DEFN_ASN_OP_T(op, double) \
+DEFN_ASN_OP_T(op, const char *) \
+DEFN_ASN_OP_T(op, const sc_fxval &) \
+DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
+DEFN_ASN_OP_T(op, const sc_fxnum &) \
+DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
+DEFN_ASN_OP_OTHER(op)
+
+DEFN_ASN_OP(=)
+
+DEFN_ASN_OP(*=)
+DEFN_ASN_OP(/=)
+DEFN_ASN_OP(+=)
+DEFN_ASN_OP(-=)
+
+DEFN_ASN_OP_T(<<=, int)
+DEFN_ASN_OP_T(>>=, int)
+
+DEFN_ASN_OP_T(&=, const sc_ufix &)
+DEFN_ASN_OP_T(&=, const sc_ufix_fast &)
+DEFN_ASN_OP_T(|=, const sc_ufix &)
+DEFN_ASN_OP_T(|=, const sc_ufix_fast &)
+DEFN_ASN_OP_T(^=, const sc_ufix &)
+DEFN_ASN_OP_T(^=, const sc_ufix_fast &)
+
+#undef DEFN_ASN_OP_T
+#undef DEFN_ASN_OP_OTHER
+#undef DEFN_ASN_OP
+
+// auto-increment and auto-decrement
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval_fast
+sc_ufixed_fast<W, I, Q, O, N>::operator ++ (int)
+{
+ return sc_fxval_fast( sc_ufix_fast::operator ++ (0));
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline const sc_fxval_fast
+sc_ufixed_fast<W, I, Q, O, N>::operator -- (int)
+{
+ return sc_fxval_fast( sc_ufix_fast::operator -- (0));
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N> &
+sc_ufixed_fast<W, I, Q, O, N>::operator ++ ()
+{
+ sc_ufix_fast::operator ++ ();
+ return *this;
+}
+
+template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
+inline sc_ufixed_fast<W, I, Q, O, N> &
+sc_ufixed_fast<W,I,Q,O,N>::operator -- ()
+{
+ sc_ufix_fast::operator -- ();
+ return *this;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SC_UFIXED_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_ieee.hh b/src/systemc/ext/dt/fx/scfx_ieee.hh
new file mode 100644
index 000000000..a1c5ac6a8
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_ieee.hh
@@ -0,0 +1,613 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_ieee.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_ieee.h,v $
+// Revision 1.3 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/08/07 18:55:24 acg
+// Philipp A. Hartmann: added guard for __clang__ to get the clang platform
+// working.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__
+
+#include "../../utils/endian.hh"
+#include "sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+union ieee_double;
+class scfx_ieee_double;
+union ieee_float;
+class scfx_ieee_float;
+
+#define SCFX_MASK_(Size) ((1u << (Size))-1u)
+
+// ----------------------------------------------------------------------------
+// UNION : ieee_double
+//
+// IEEE 754 double-precision format.
+// ----------------------------------------------------------------------------
+
+union ieee_double
+{
+ double d;
+
+ struct
+ {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ unsigned negative:1;
+ unsigned exponent:11;
+ unsigned mantissa0:20;
+ unsigned mantissa1:32;
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ unsigned mantissa1:32;
+ unsigned mantissa0:20;
+ unsigned exponent:11;
+ unsigned negative:1;
+#endif
+ } s;
+};
+
+
+const unsigned int SCFX_IEEE_DOUBLE_BIAS = 1023U;
+
+const int SCFX_IEEE_DOUBLE_E_MAX = 1023;
+const int SCFX_IEEE_DOUBLE_E_MIN = -1022;
+
+const unsigned int SCFX_IEEE_DOUBLE_M_SIZE = 52;
+const unsigned int SCFX_IEEE_DOUBLE_M0_SIZE = 20;
+const unsigned int SCFX_IEEE_DOUBLE_M1_SIZE = 32;
+const unsigned int SCFX_IEEE_DOUBLE_E_SIZE = 11;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_ieee_double
+//
+// Convenient interface to union ieee_double.
+// ----------------------------------------------------------------------------
+
+class scfx_ieee_double
+{
+ ieee_double m_id;
+ public:
+ scfx_ieee_double();
+ scfx_ieee_double(double);
+ scfx_ieee_double(const scfx_ieee_double &);
+
+ scfx_ieee_double &operator = (double);
+ scfx_ieee_double &operator = (const scfx_ieee_double &);
+
+ operator double() const;
+
+ unsigned int negative() const;
+ void negative(unsigned int);
+ int exponent() const;
+ void exponent(int);
+ unsigned int mantissa0() const;
+ void mantissa0(unsigned int);
+ unsigned int mantissa1() const;
+ void mantissa1(unsigned int);
+
+ bool is_zero() const;
+ bool is_subnormal() const;
+ bool is_normal() const;
+ bool is_inf() const;
+ bool is_nan() const;
+
+ void set_inf();
+ void set_nan();
+
+ int msb() const; // most significant non-zero bit
+ int lsb() const; // least significant non-zero bit
+
+ static const scfx_ieee_double nan();
+ static const scfx_ieee_double inf(int);
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline scfx_ieee_double::scfx_ieee_double() : m_id()
+{
+ m_id.d = 0.0;
+}
+
+inline scfx_ieee_double::scfx_ieee_double(double d) : m_id()
+{
+ m_id.d = d;
+}
+
+inline scfx_ieee_double::scfx_ieee_double(const scfx_ieee_double &a) :
+ m_id(a.m_id)
+{
+ // m_id.d = a.m_id.d;
+}
+
+inline scfx_ieee_double &
+scfx_ieee_double::operator = (double d)
+{
+ m_id.d = d;
+ return *this;
+}
+
+inline scfx_ieee_double &
+scfx_ieee_double::operator = (const scfx_ieee_double &a)
+{
+ m_id.d = a.m_id.d;
+ return *this;
+}
+
+inline scfx_ieee_double::operator double() const
+{
+ return m_id.d;
+}
+
+inline unsigned int
+scfx_ieee_double::negative() const
+{
+ return m_id.s.negative;
+}
+
+inline void
+scfx_ieee_double::negative(unsigned int a)
+{
+ m_id.s.negative = a & SCFX_MASK_(1);
+}
+
+inline int
+scfx_ieee_double::exponent() const
+{
+ return m_id.s.exponent - SCFX_IEEE_DOUBLE_BIAS;
+}
+
+inline void
+scfx_ieee_double::exponent(int a)
+{
+ m_id.s.exponent = (SCFX_IEEE_DOUBLE_BIAS + a)
+ & SCFX_MASK_(SCFX_IEEE_DOUBLE_E_SIZE);
+}
+
+inline unsigned int
+scfx_ieee_double::mantissa0() const
+{
+ return m_id.s.mantissa0;
+}
+
+inline void
+scfx_ieee_double::mantissa0(unsigned int a)
+{
+ m_id.s.mantissa0 = a & SCFX_MASK_(SCFX_IEEE_DOUBLE_M0_SIZE);
+}
+
+inline unsigned int
+scfx_ieee_double::mantissa1() const
+{
+ return m_id.s.mantissa1;
+}
+
+inline void
+scfx_ieee_double::mantissa1(unsigned int a)
+{
+ m_id.s.mantissa1 = a; // & SCFX_MASK_(SCFX_IEEE_DOUBLE_M1_SIZE);
+}
+
+inline bool
+scfx_ieee_double::is_zero() const
+{
+ return (exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
+ mantissa0() == 0U && mantissa1() == 0U);
+}
+
+inline bool
+scfx_ieee_double::is_subnormal() const
+{
+ return (exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
+ (mantissa0() != 0U || mantissa1() != 0U));
+}
+
+inline bool
+scfx_ieee_double::is_normal() const
+{
+ return (exponent() >= SCFX_IEEE_DOUBLE_E_MIN &&
+ exponent() <= SCFX_IEEE_DOUBLE_E_MAX);
+}
+
+inline bool
+scfx_ieee_double::is_inf() const
+{
+ return (exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
+ mantissa0() == 0U && mantissa1() == 0U);
+}
+
+inline bool
+scfx_ieee_double::is_nan() const
+{
+ return (exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
+ (mantissa0() != 0U || mantissa1() != 0U));
+}
+
+inline void
+scfx_ieee_double::set_inf()
+{
+ exponent(SCFX_IEEE_DOUBLE_E_MAX + 1);
+ mantissa0(0U);
+ mantissa1(0U);
+}
+
+inline void
+scfx_ieee_double::set_nan()
+{
+ exponent(SCFX_IEEE_DOUBLE_E_MAX + 1);
+ mantissa0((unsigned int)-1);
+ mantissa1((unsigned int)-1);
+}
+
+#define MSB_STATEMENT(x,n) if ( x >> n ) { x >>= n; i += n; }
+
+inline int
+scfx_ieee_double::msb() const
+{
+ unsigned int m0 = mantissa0();
+ unsigned int m1 = mantissa1();
+ if (m0 != 0) {
+ int i = 0;
+ MSB_STATEMENT(m0, 16);
+ MSB_STATEMENT(m0, 8);
+ MSB_STATEMENT(m0, 4);
+ MSB_STATEMENT(m0, 2);
+ MSB_STATEMENT(m0, 1);
+ return (i - 20);
+ } else if (m1 != 0) {
+ int i = 0;
+ MSB_STATEMENT(m1, 16);
+ MSB_STATEMENT(m1, 8);
+ MSB_STATEMENT(m1, 4);
+ MSB_STATEMENT(m1, 2);
+ MSB_STATEMENT(m1, 1);
+ return (i - 52);
+ } else {
+ return 0;
+ }
+}
+
+#undef MSB_STATEMENT
+
+#define LSB_STATEMENT(x,n) if ( x << n ) { x <<= n; i -= n; }
+
+inline int
+scfx_ieee_double::lsb() const
+{
+ unsigned int m0 = mantissa0();
+ unsigned int m1 = mantissa1();
+ if (m1 != 0) {
+ int i = 31;
+ LSB_STATEMENT(m1, 16);
+ LSB_STATEMENT(m1, 8);
+ LSB_STATEMENT(m1, 4);
+ LSB_STATEMENT(m1, 2);
+ LSB_STATEMENT(m1, 1);
+ return (i - 52);
+ } else if (m0 != 0) {
+ int i = 31;
+ LSB_STATEMENT(m0, 16);
+ LSB_STATEMENT(m0, 8);
+ LSB_STATEMENT(m0, 4);
+ LSB_STATEMENT(m0, 2);
+ LSB_STATEMENT(m0, 1);
+ return (i - 20);
+ } else {
+ return 0;
+ }
+}
+
+#undef LSB_STATEMENT
+
+inline const scfx_ieee_double
+scfx_ieee_double::nan()
+{
+ scfx_ieee_double id;
+ id.set_nan();
+ return id;
+}
+
+inline const scfx_ieee_double
+scfx_ieee_double::inf(int sign)
+{
+ scfx_ieee_double id(sign);
+ id.set_inf();
+ return id;
+}
+
+
+// ----------------------------------------------------------------------------
+// UNION : ieee_float
+//
+// IEEE 754 single-precision format.
+// ----------------------------------------------------------------------------
+
+union ieee_float
+{
+ float f;
+ struct
+ {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ unsigned negative:1;
+ unsigned exponent:8;
+ unsigned mantissa:23;
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ unsigned mantissa:23;
+ unsigned exponent:8;
+ unsigned negative:1;
+#endif
+ } s;
+};
+
+
+const unsigned int SCFX_IEEE_FLOAT_BIAS = 127U;
+
+const int SCFX_IEEE_FLOAT_E_MAX = 127;
+const int SCFX_IEEE_FLOAT_E_MIN = -126;
+
+const unsigned int SCFX_IEEE_FLOAT_M_SIZE = 23;
+const unsigned int SCFX_IEEE_FLOAT_E_SIZE = 8;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_ieee_float
+//
+// Convenient wrapper to union ieee_float.
+// ----------------------------------------------------------------------------
+
+class scfx_ieee_float
+{
+ ieee_float m_if;
+
+ public:
+ scfx_ieee_float();
+ scfx_ieee_float(float);
+ scfx_ieee_float(const scfx_ieee_float &);
+
+ scfx_ieee_float &operator = (float);
+ scfx_ieee_float &operator = (const scfx_ieee_float &);
+
+ operator float() const;
+
+ unsigned int negative() const;
+ void negative(unsigned int);
+ int exponent() const;
+ void exponent(int);
+ unsigned int mantissa() const;
+ void mantissa(unsigned int);
+
+ bool is_zero() const;
+ bool is_subnormal() const;
+ bool is_normal() const;
+ bool is_inf() const;
+ bool is_nan() const;
+
+ void set_inf();
+ void set_nan();
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline scfx_ieee_float::scfx_ieee_float() : m_if()
+{
+ m_if.f = 0.0;
+}
+
+inline scfx_ieee_float::scfx_ieee_float(float f) : m_if()
+{
+ m_if.f = f;
+}
+
+inline scfx_ieee_float::scfx_ieee_float(const scfx_ieee_float &a) :
+ m_if(a.m_if)
+{
+ // m_if.f = a.m_if.f;
+}
+
+
+inline scfx_ieee_float &
+scfx_ieee_float::operator = (float f)
+{
+ m_if.f = f;
+ return *this;
+}
+
+inline scfx_ieee_float &
+scfx_ieee_float::operator = (const scfx_ieee_float &a)
+{
+ m_if.f = a.m_if.f;
+ return *this;
+}
+
+inline scfx_ieee_float::operator float() const
+{
+ return m_if.f;
+}
+
+inline unsigned int
+scfx_ieee_float::negative() const
+{
+ return m_if.s.negative;
+}
+
+inline void
+scfx_ieee_float::negative(unsigned int a)
+{
+ m_if.s.negative = a & SCFX_MASK_(1);
+}
+
+inline int
+scfx_ieee_float::exponent() const
+{
+ return m_if.s.exponent - SCFX_IEEE_FLOAT_BIAS;
+}
+
+inline void
+scfx_ieee_float::exponent(int a)
+{
+ m_if.s.exponent = (SCFX_IEEE_FLOAT_BIAS + a) &
+ SCFX_MASK_(SCFX_IEEE_FLOAT_E_SIZE);
+}
+
+inline unsigned int
+scfx_ieee_float::mantissa() const
+{
+ return m_if.s.mantissa;
+}
+
+inline void
+scfx_ieee_float::mantissa(unsigned int a)
+{
+ m_if.s.mantissa = a & SCFX_MASK_(SCFX_IEEE_FLOAT_M_SIZE);
+}
+
+
+inline bool
+scfx_ieee_float::is_zero() const
+{
+ return (exponent() == SCFX_IEEE_FLOAT_E_MIN - 1 && mantissa() == 0U);
+}
+
+inline bool
+scfx_ieee_float::is_subnormal() const
+{
+ return (exponent() == SCFX_IEEE_FLOAT_E_MIN - 1 && mantissa() != 0U);
+}
+
+inline bool
+scfx_ieee_float::is_normal() const
+{
+ return (exponent() >= SCFX_IEEE_FLOAT_E_MIN &&
+ exponent() <= SCFX_IEEE_FLOAT_E_MAX);
+}
+
+inline bool
+scfx_ieee_float::is_inf() const
+{
+ return (exponent() == SCFX_IEEE_FLOAT_E_MAX + 1 && mantissa() == 0U);
+}
+
+inline bool
+scfx_ieee_float::is_nan() const
+{
+ return (exponent() == SCFX_IEEE_FLOAT_E_MAX + 1 && mantissa() != 0U);
+}
+
+inline void
+scfx_ieee_float::set_inf()
+{
+ exponent(SCFX_IEEE_FLOAT_E_MAX + 1);
+ mantissa(0U);
+}
+
+inline void
+scfx_ieee_float::set_nan()
+{
+ exponent(SCFX_IEEE_FLOAT_E_MAX + 1);
+ mantissa((unsigned int)-1);
+}
+
+
+// ----------------------------------------------------------------------------
+// FUNCTION : scfx_pow2
+//
+// Computes 2.0**exp in double-precision.
+// ----------------------------------------------------------------------------
+
+inline double
+scfx_pow2(int exp)
+{
+ scfx_ieee_double r;
+ if (exp < SCFX_IEEE_DOUBLE_E_MIN) {
+ r = 0.0;
+ // handle subnormal case
+ exp -= SCFX_IEEE_DOUBLE_E_MIN;
+ if ((exp += 20) >= 0) {
+ r.mantissa0(1U << exp);
+ } else if ((exp += 32) >= 0) {
+ r.mantissa1(1U << exp);
+ }
+ } else if (exp > SCFX_IEEE_DOUBLE_E_MAX) {
+ r.set_inf();
+ } else {
+ r = 1.0;
+ r.exponent(exp);
+ }
+ return r;
+}
+
+
+// ----------------------------------------------------------------------------
+// FUNCTION : uint64_to_double
+//
+// Platform independent conversion from double uint64 to double.
+// Needed because VC++6 doesn't support this conversion.
+// ----------------------------------------------------------------------------
+
+inline double
+uint64_to_double(uint64 a)
+{
+#if defined(__clang__)
+ // conversion from uint64 to double not implemented; use int64
+ double tmp = static_cast<double>(static_cast<int64>(a));
+ return (tmp >= 0) ? tmp : tmp + sc_dt::scfx_pow2(64);
+#else
+ return static_cast<double>(a);
+#endif
+}
+
+} // namespace sc_dt
+
+#undef SCFX_MASK_
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_mant.hh b/src/systemc/ext/dt/fx/scfx_mant.hh
new file mode 100644
index 000000000..ff2033ba9
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_mant.hh
@@ -0,0 +1,415 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_mant.h -
+
+ Original Author: Robert Graulich, Synopsys, Inc.
+ Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_mant.h,v $
+// Revision 1.2 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_MANT_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_MANT_HH__
+
+#include "../../utils/endian.hh"
+#include "../../utils/functions.hh"
+#include "scfx_ieee.hh"
+#include "scfx_utils.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class scfx_mant;
+class scfx_mant_ref;
+
+typedef unsigned int word; // Using int because of 64-bit machines.
+typedef unsigned short half_word;
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_mant
+//
+// Mantissa class.
+// ----------------------------------------------------------------------------
+
+class scfx_mant
+{
+ word *m_array;
+ int m_size;
+
+ public:
+ explicit scfx_mant(std::size_t);
+ scfx_mant(const scfx_mant &);
+
+ scfx_mant &operator = (const scfx_mant &);
+
+ ~scfx_mant();
+
+ void clear();
+
+ void resize_to(int, int=0);
+
+ int size() const;
+
+ word operator [] (int) const;
+ word &operator [] (int);
+
+ half_word half_at(int) const;
+ half_word &half_at(int);
+
+ half_word *half_addr(int=0) const;
+
+ private:
+ static word *alloc(std::size_t);
+ static void free(word *, std::size_t);
+
+ static word *alloc_word(std::size_t size);
+ static void free_word(word *array, std::size_t size);
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline int scfx_mant::size() const { return m_size; }
+
+inline word *
+scfx_mant::alloc(std::size_t size)
+{
+#if defined(SC_BOOST_BIG_ENDIAN )
+ return alloc_word(size) + (size - 1);
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ return alloc_word(size);
+#endif
+}
+
+inline void
+scfx_mant::free(word *mant, std::size_t size)
+{
+#if defined(SC_BOOST_BIG_ENDIAN)
+ free_word(mant - (size - 1), size);
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ free_word(mant, size);
+#endif
+}
+
+inline word
+scfx_mant::operator [] (int i) const
+{
+ SC_ASSERT_(i >= 0 && i < m_size, "mantissa index out of range");
+#if defined(SC_BOOST_BIG_ENDIAN)
+ return m_array[-i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ return m_array[i];
+#endif
+}
+
+inline word &
+scfx_mant::operator [] (int i)
+{
+ SC_ASSERT_(i >= 0 && i < m_size, "mantissa index out of range");
+#if defined(SC_BOOST_BIG_ENDIAN)
+ return m_array[-i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ return m_array[i];
+#endif
+}
+
+inline scfx_mant::scfx_mant(std::size_t size_) : m_array(0), m_size(size_)
+{
+ m_array = alloc(size_);
+}
+
+inline scfx_mant::scfx_mant(const scfx_mant &rhs) :
+ m_array(0), m_size(rhs.m_size)
+{
+ m_array = alloc(m_size);
+ for (int i = 0; i < m_size; i++) {
+ (*this)[i] = rhs[i];
+ }
+}
+
+inline scfx_mant &
+scfx_mant::operator = (const scfx_mant &rhs)
+{
+ if (&rhs != this) {
+ if (m_size != rhs.m_size) {
+ free(m_array, m_size);
+ m_array = alloc(m_size = rhs.m_size);
+ }
+
+ for (int i = 0; i < m_size; i++) {
+ (*this)[i] = rhs[i];
+ }
+ }
+ return *this;
+}
+
+inline scfx_mant::~scfx_mant()
+{
+ if (m_array != 0) {
+ free(m_array, m_size);
+ }
+}
+
+inline void
+scfx_mant::clear()
+{
+ for (int i = 0; i < m_size; i++) {
+ (*this)[i] = 0;
+ }
+}
+
+inline void
+scfx_mant::resize_to(int size, int restore)
+{
+ if (size == m_size) {
+ return;
+ }
+
+ if (!m_array) {
+ m_array = alloc(m_size = size);
+ } else {
+ word* p = alloc(size);
+
+ if (restore) {
+ int end = sc_min(size, m_size);
+ if (restore == 1) { // msb resized -> align at 0
+ for (int i = 0; i < size; i++) {
+ if (i < end) {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ p[-i] = m_array[-i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ p[i] = m_array[i];
+#endif
+ } else {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ p[-i] = 0;
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ p[i] = 0;
+#endif
+ }
+ }
+ } else { // lsb resized -> align at size - 1
+ for (int i = 0; i < size; i++) {
+ if (i < end) {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ p[-size + 1 + i] = m_array[-m_size + 1 + i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ p[size - 1 - i] = m_array[m_size - 1 - i];
+#endif
+ } else {
+#if defined(SC_BOOST_BIG_ENDIAN)
+ p[-size + 1 + i] = 0;
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ p[size - 1 - i] = 0;
+#endif
+ }
+ }
+ }
+ }
+
+ free(m_array, m_size);
+ m_array = p;
+ m_size = size;
+ }
+}
+
+inline half_word
+scfx_mant::half_at(int i) const
+{
+ SC_ASSERT_((i >> 1) >= 0 && (i >> 1) < m_size,
+ "mantissa index out of range");
+#if defined(SC_BOOST_BIG_ENDIAN)
+ return reinterpret_cast<half_word *>(m_array)[-i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN )
+ return reinterpret_cast<half_word *>(m_array)[i];
+#endif
+}
+
+inline half_word &
+scfx_mant::half_at(int i)
+{
+ SC_ASSERT_((i >> 1) >= 0 && (i >> 1) < m_size,
+ "mantissa index out of range" );
+#if defined(SC_BOOST_BIG_ENDIAN)
+ return reinterpret_cast<half_word *>(m_array)[-i];
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ return reinterpret_cast<half_word *>(m_array)[i];
+#endif
+}
+
+inline half_word *
+scfx_mant::half_addr(int i) const
+{
+ SC_ASSERT_(i >= 0 && i < m_size, "mantissa index out of range");
+#if defined(SC_BOOST_BIG_ENDIAN)
+ return reinterpret_cast<half_word *>(m_array - i) + 1;
+#elif defined(SC_BOOST_LITTLE_ENDIAN)
+ return reinterpret_cast<half_word *>(m_array + i);
+#endif
+}
+
+// ----------------------------------------------------------------------------
+// one's complement of a mantissa
+// ----------------------------------------------------------------------------
+
+inline void
+complement(scfx_mant &target, const scfx_mant &source, int size)
+{
+ for (int i = 0; i < size; i++) {
+ target[i] = ~source[i];
+ }
+}
+
+// ----------------------------------------------------------------------------
+// increment mantissa
+// ----------------------------------------------------------------------------
+
+inline void
+inc(scfx_mant &mant)
+{
+ for (int i = 0; i < mant.size(); i++) {
+ if (++mant[i]) {
+ break;
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_mant_ref
+//
+// Mantissa reference class.
+// ----------------------------------------------------------------------------
+
+class scfx_mant_ref
+{
+ scfx_mant *m_mant;
+ bool m_not_const;
+
+ public:
+ scfx_mant_ref();
+ scfx_mant_ref(const scfx_mant &);
+ scfx_mant_ref(scfx_mant *);
+
+ scfx_mant_ref &operator = (const scfx_mant &);
+ scfx_mant_ref &operator = (scfx_mant *);
+
+ ~scfx_mant_ref();
+
+ operator scfx_mant & ();
+
+ word operator [] (int);
+
+ private:
+ void remove_it();
+
+ scfx_mant_ref(const scfx_mant_ref &);
+ scfx_mant_ref &operator = (const scfx_mant_ref &);
+
+ void *operator new(std::size_t sz) { return ::operator new (sz); }
+
+};
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline void
+scfx_mant_ref::remove_it()
+{
+ if (m_not_const) {
+ delete m_mant;
+ }
+}
+
+inline scfx_mant_ref::scfx_mant_ref() : m_mant(0), m_not_const(false) {}
+
+inline scfx_mant_ref::scfx_mant_ref(const scfx_mant &mant) :
+ m_mant(const_cast<scfx_mant *>(& mant)), m_not_const(false)
+{}
+
+inline scfx_mant_ref::scfx_mant_ref(scfx_mant *mant) :
+ m_mant(mant), m_not_const(true)
+{}
+
+inline scfx_mant_ref &
+scfx_mant_ref::operator = (const scfx_mant &mant)
+{
+ remove_it();
+
+ m_mant = const_cast<scfx_mant *>(&mant);
+ m_not_const = false;
+
+ return *this;
+}
+
+inline scfx_mant_ref &
+scfx_mant_ref::operator = (scfx_mant *mant)
+{
+ remove_it();
+
+ m_mant = mant;
+ m_not_const = true;
+
+ return *this;
+}
+
+inline scfx_mant_ref::~scfx_mant_ref()
+{
+ remove_it();
+}
+
+inline scfx_mant_ref::operator scfx_mant & ()
+{
+ // SC_ASSERT_(m_not_const, "not allowed to modify mant");
+ return *m_mant;
+}
+
+inline word
+scfx_mant_ref::operator [] (int i)
+{
+ return (*m_mant)[i];
+}
+
+} // namespace sc_dt
+
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_MANT_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_other_defs.hh b/src/systemc/ext/dt/fx/scfx_other_defs.hh
new file mode 100644
index 000000000..71eec9ff8
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_other_defs.hh
@@ -0,0 +1,324 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_other_defs.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_other_defs.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
+
+#include "../int/sc_int_base.hh"
+#include "../int/sc_signed.hh"
+#include "../int/sc_uint_base.hh"
+#include "../int/sc_unsigned.hh"
+
+namespace sc_dt
+{
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed
+// ----------------------------------------------------------------------------
+
+// assignment operators
+inline const sc_signed &
+sc_signed::operator = (const sc_fxval &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_signed::operator = ( const sc_fxval& )");
+ return *this;
+ }
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_signed &
+sc_signed::operator = (const sc_fxval_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_signed::operator = ( const sc_fxval_fast& )");
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_signed &
+sc_signed::operator = (const sc_fxnum &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_signed::operator = ( const sc_fxnum& )");
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_signed &
+sc_signed::operator = (const sc_fxnum_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_signed::operator = ( const sc_fxnum_fast& )");
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline const sc_unsigned &
+sc_unsigned::operator = (const sc_fxval &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_unsigned::operator = ( const sc_fxval& )");
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_unsigned &
+sc_unsigned::operator = (const sc_fxval_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_unsigned::operator = ( const sc_fxval_fast& )");
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_unsigned &
+sc_unsigned::operator = (const sc_fxnum &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_unsigned::operator = ( const sc_fxnum& )" );
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+inline const sc_unsigned &
+sc_unsigned::operator = (const sc_fxnum_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_unsigned::operator = ( const sc_fxnum_fast& )" );
+ return *this;
+ }
+
+ for (int i = 0; i < length(); ++i)
+ (*this)[i] = v.get_bit(i);
+
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_base
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline sc_int_base &
+sc_int_base::operator = (const sc_fxval &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_int_base::operator = ( const sc_fxval& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_int_base &
+sc_int_base::operator = (const sc_fxval_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_int_base::operator = ( const sc_fxval_fast& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_int_base &
+sc_int_base::operator = (const sc_fxnum &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_int_base::operator = ( const sc_fxnum& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_int_base &
+sc_int_base::operator = (const sc_fxnum_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_int_base::operator = ( const sc_fxnum_fast& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set (i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_base
+// ----------------------------------------------------------------------------
+
+// assignment operators
+inline sc_uint_base &
+sc_uint_base::operator = (const sc_fxval &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_uint_base::operator = ( const sc_fxval& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_uint_base &
+sc_uint_base::operator = (const sc_fxval_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_uint_base::operator = ( const sc_fxval_fast& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_uint_base &
+sc_uint_base::operator = (const sc_fxnum &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_uint_base::operator = ( const sc_fxnum& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+inline sc_uint_base &
+sc_uint_base::operator = (const sc_fxnum_fast &v)
+{
+ if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
+ SC_REPORT_ERROR("invalid fixed-point value",
+ "sc_uint_base::operator = ( const sc_fxnum_fast& )");
+ return *this;
+ }
+ for (int i = 0; i < m_len; ++i) {
+ set(i, v.get_bit(i));
+ }
+ extend_sign();
+ return *this;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_params.hh b/src/systemc/ext/dt/fx/scfx_params.hh
new file mode 100644
index 000000000..dd5c9b695
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_params.hh
@@ -0,0 +1,182 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_params.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_params.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
+
+#include "sc_fxcast_switch.hh"
+#include "sc_fxtype_params.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class scfx_params;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_params
+//
+// ...
+// ----------------------------------------------------------------------------
+
+class scfx_params
+{
+ public:
+ // constructor
+ scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &);
+
+ // query functions
+ const sc_fxtype_params &type_params() const;
+ sc_enc enc() const;
+ const sc_fxcast_switch &cast_switch() const;
+
+ // shortcuts
+ int wl() const;
+ int iwl() const;
+ int fwl() const;
+ sc_q_mode q_mode() const;
+ sc_o_mode o_mode() const;
+ int n_bits() const;
+
+ // dump content
+ void dump(::std::ostream &) const;
+
+ private:
+ sc_fxtype_params m_type_params;
+ sc_enc m_enc;
+ sc_fxcast_switch m_cast_switch;
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// constructor
+inline scfx_params::scfx_params(const sc_fxtype_params &type_params_,
+ sc_enc enc_,
+ const sc_fxcast_switch &cast_sw) :
+ m_type_params(type_params_), m_enc(enc_), m_cast_switch(cast_sw)
+{
+ if (m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM) {
+ SC_REPORT_ERROR("invalid overflow mode",
+ "SC_WRAP_SM not defined for unsigned numbers");
+ // may continue, if suppressed
+ }
+}
+
+// query functions
+inline const sc_fxtype_params &
+scfx_params::type_params() const
+{
+ return m_type_params;
+}
+
+inline sc_enc
+scfx_params::enc() const
+{
+ return m_enc;
+}
+
+inline const sc_fxcast_switch &
+scfx_params::cast_switch() const
+{
+ return m_cast_switch;
+}
+
+// shortcuts
+inline int
+scfx_params::wl() const
+{
+ return m_type_params.wl();
+}
+
+inline int
+scfx_params::iwl() const
+{
+ return m_type_params.iwl();
+}
+
+inline int
+scfx_params::fwl() const
+{
+ return (m_type_params.wl() - m_type_params.iwl());
+}
+
+inline sc_q_mode
+scfx_params::q_mode() const
+{
+ return m_type_params.q_mode();
+}
+
+inline sc_o_mode
+scfx_params::o_mode() const
+{
+ return m_type_params.o_mode();
+}
+
+inline int
+scfx_params::n_bits() const
+{
+ return m_type_params.n_bits();
+}
+
+// dump content
+inline void
+scfx_params::dump(::std::ostream &os) const
+{
+ os << "scfx_params" << ::std::endl;
+ os << "(" << ::std::endl;
+ os << "type_params = ";
+ m_type_params.dump( os );
+ os << "enc = " << m_enc << ::std::endl;
+ os << "cast_switch = ";
+ m_cast_switch.dump( os );
+ os << ")" << ::std::endl;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_pow10.hh b/src/systemc/ext/dt/fx/scfx_pow10.hh
new file mode 100644
index 000000000..e67595fc4
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_pow10.hh
@@ -0,0 +1,86 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_pow10.h -
+
+ Original Author: Robert Graulich, Synopsys, Inc.
+ Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_pow10.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_POW10_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_POW10_HH__
+
+#include "scfx_rep.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class scfx_pow10;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_pow10
+//
+// Class to compute (and cache) powers of 10 in arbitrary precision.
+// ----------------------------------------------------------------------------
+
+const int SCFX_POW10_TABLE_SIZE = 32;
+
+class scfx_pow10
+{
+ public:
+ scfx_pow10();
+ ~scfx_pow10();
+
+ const scfx_rep operator() (int);
+
+ private:
+ scfx_rep *pos(int);
+ scfx_rep *neg(int);
+
+ scfx_rep m_pos[SCFX_POW10_TABLE_SIZE];
+ scfx_rep m_neg[SCFX_POW10_TABLE_SIZE];
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_POW10_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_rep.hh b/src/systemc/ext/dt/fx/scfx_rep.hh
new file mode 100644
index 000000000..9465b1afd
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_rep.hh
@@ -0,0 +1,724 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_rep.h -
+
+ Original Author: Robert Graulich, Synopsys, Inc.
+ Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_rep.h,v $
+// Revision 1.6 2011/08/24 22:05:43 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.5 2011/07/25 10:20:29 acg
+// Andy Goodrich: check in aftermath of call to automake.
+//
+// Revision 1.4 2010/12/07 20:09:08 acg
+// Andy Goodrich: Philipp Hartmann's constructor disambiguation fix
+//
+// Revision 1.3 2010/08/03 15:54:52 acg
+// Andy Goodrich: formatting.
+//
+// Revision 1.2 2010/03/15 18:29:01 acg
+// Andy Goodrich: Moved default argument specifications from friend
+// declarations to the actual function signatures.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.4 2006/03/13 20:24:27 acg
+// Andy Goodrich: Addition of function declarations, e.g., neg_scfx_rep(),
+// to keep gcc 4.x happy.
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_REP_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_REP_HH__
+
+#include <climits>
+
+#include "scfx_mant.hh"
+#include "scfx_params.hh"
+#include "scfx_string.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class scfx_index;
+class scfx_rep;
+
+// forward class declarations
+class sc_bv_base;
+class sc_signed;
+class sc_unsigned;
+
+// function declarations
+void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &,
+ int max_wl=SC_DEFAULT_MAX_WL_);
+scfx_rep *neg_scfx_rep(const scfx_rep &);
+scfx_rep *mult_scfx_rep(const scfx_rep &, const scfx_rep &,
+ int max_wl=SC_DEFAULT_MAX_WL_);
+scfx_rep *div_scfx_rep(const scfx_rep &, const scfx_rep &,
+ int max_wl=SC_DEFAULT_DIV_WL_);
+scfx_rep *add_scfx_rep(const scfx_rep &, const scfx_rep &,
+ int max_wl=SC_DEFAULT_MAX_WL_);
+scfx_rep *sub_scfx_rep(const scfx_rep &, const scfx_rep &,
+ int max_wl=SC_DEFAULT_MAX_WL_);
+scfx_rep *lsh_scfx_rep(const scfx_rep &, int);
+scfx_rep *rsh_scfx_rep(const scfx_rep &, int);
+int cmp_scfx_rep(const scfx_rep &, const scfx_rep &);
+
+const int min_mant = 4;
+
+const int bits_in_int = sizeof(int) * CHAR_BIT;
+const int bits_in_word = sizeof(word) * CHAR_BIT;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_index
+// ----------------------------------------------------------------------------
+
+class scfx_index
+{
+ public:
+ scfx_index(int wi_, int bi_) : m_wi(wi_), m_bi(bi_) {}
+
+ int wi() const { return m_wi; }
+ int bi() const { return m_bi; }
+
+ void wi(int wi_) { m_wi = wi_; }
+
+ private:
+ int m_wi;
+ int m_bi;
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_rep
+//
+// Arbitrary-precision fixed-point implementation class.
+// ----------------------------------------------------------------------------
+
+class scfx_rep
+{
+ enum state
+ {
+ normal,
+ infinity,
+ not_a_number
+ };
+
+ public:
+ // constructors
+ scfx_rep();
+ explicit scfx_rep(int);
+ explicit scfx_rep(unsigned int);
+ explicit scfx_rep(long);
+ explicit scfx_rep(unsigned long);
+ explicit scfx_rep(double);
+ explicit scfx_rep(const char *);
+ explicit scfx_rep(int64);
+ explicit scfx_rep(uint64);
+ explicit scfx_rep(const sc_signed &);
+ explicit scfx_rep(const sc_unsigned &);
+
+ // copy constructor
+ scfx_rep(const scfx_rep &);
+
+ // destructor
+ ~scfx_rep();
+
+ void *operator new (std::size_t);
+ void operator delete (void *, std::size_t);
+
+ void from_string(const char *, int);
+
+ double to_double() const;
+ uint64 to_uint64() const;
+
+ const char *to_string(sc_numrep, int, sc_fmt,
+ const scfx_params * =0) const;
+
+ // assignment operator
+ void operator = (const scfx_rep &);
+
+ friend void multiply( scfx_rep&, const scfx_rep&, const scfx_rep&, int );
+
+ friend scfx_rep *neg_scfx_rep(const scfx_rep &);
+ friend scfx_rep *mult_scfx_rep(const scfx_rep &, const scfx_rep &, int);
+ friend scfx_rep *div_scfx_rep(const scfx_rep &, const scfx_rep &, int);
+ friend scfx_rep *add_scfx_rep(const scfx_rep &, const scfx_rep &, int);
+ friend scfx_rep *sub_scfx_rep(const scfx_rep &, const scfx_rep &, int);
+ friend scfx_rep *lsh_scfx_rep(const scfx_rep &, int);
+ friend scfx_rep *rsh_scfx_rep(const scfx_rep &, int);
+
+ void lshift(int);
+ void rshift(int);
+
+ friend int cmp_scfx_rep(const scfx_rep &, const scfx_rep &);
+
+ void cast(const scfx_params &, bool &, bool &);
+
+ bool is_neg() const;
+ bool is_zero() const;
+ bool is_nan() const;
+ bool is_inf() const;
+ bool is_normal() const;
+
+ void set_zero(int=1);
+ void set_nan();
+ void set_inf(int);
+
+ bool get_bit(int) const;
+ bool set(int, const scfx_params &);
+ bool clear(int, const scfx_params &);
+
+ bool get_slice(int, int, const scfx_params &, sc_bv_base &) const;
+ bool set_slice(int, int, const scfx_params &, const sc_bv_base &);
+
+ void print(::std::ostream &) const;
+ void dump(::std::ostream &) const;
+
+ void get_type(int &, int &, sc_enc &) const;
+
+ friend scfx_rep *quantization_scfx_rep(
+ const scfx_rep &, const scfx_params &, bool &);
+ friend scfx_rep *overflow_scfx_rep(
+ const scfx_rep &, const scfx_params &, bool &);
+
+ bool rounding_flag() const;
+
+ private:
+ friend void align(const scfx_rep &, const scfx_rep &, int &, int &,
+ scfx_mant_ref &, scfx_mant_ref &);
+ friend int compare_msw(const scfx_rep &, const scfx_rep &);
+ friend int compare_msw_ff(const scfx_rep &lhs, const scfx_rep &rhs);
+ unsigned int divide_by_ten();
+ int find_lsw() const;
+ int find_msw() const;
+ void find_sw();
+ void multiply_by_ten();
+ void normalize(int);
+ scfx_mant *resize(int, int) const;
+ void set_bin(int);
+ void set_oct(int, int);
+ void set_hex(int, int);
+ void shift_left(int);
+ void shift_right(int);
+
+ const scfx_index calc_indices(int) const;
+
+ void o_extend(const scfx_index &, sc_enc);
+ bool o_bit_at(const scfx_index &) const;
+ bool o_zero_left(const scfx_index &) const;
+ bool o_zero_right(const scfx_index &) const;
+ void o_set_low(const scfx_index &, sc_enc);
+ void o_set_high(const scfx_index &, const scfx_index &, sc_enc, int=1);
+ void o_set(const scfx_index &, const scfx_index &, sc_enc, bool);
+ void o_invert(const scfx_index &);
+ bool q_bit(const scfx_index &) const;
+ void q_clear(const scfx_index &);
+ void q_incr(const scfx_index &);
+ bool q_odd(const scfx_index &) const;
+ bool q_zero(const scfx_index &) const;
+
+ void resize_to(int, int=0);
+ int size() const;
+ void toggle_tc();
+
+ friend void print_dec(scfx_string &, const scfx_rep &, int, sc_fmt);
+ friend void print_other(scfx_string &, const scfx_rep &, sc_numrep, int,
+ sc_fmt, const scfx_params *);
+
+ void quantization(const scfx_params &, bool &);
+ void overflow(const scfx_params &, bool &);
+
+ friend int compare_abs(const scfx_rep &, const scfx_rep &);
+
+ void round(int);
+
+ private:
+ scfx_mant m_mant; // mantissa (bits of the value).
+ int m_wp; // index of highest order word in value.
+ int m_sign; // sign of value.
+ state m_state; // value state, e.g., normal, inf, etc.
+ int m_msw; // index of most significant non-zero word.
+ int m_lsw; // index of least significant non-zero word.
+ bool m_r_flag; // true if rounding occurred.
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline void
+scfx_rep::set_zero(int sign)
+{
+ m_mant.clear();
+ m_wp = m_msw = m_lsw = 0;
+ m_sign = sign;
+ m_state = normal;
+}
+
+inline void
+scfx_rep::set_nan()
+{
+ m_mant.resize_to(min_mant);
+ m_state = not_a_number;
+}
+
+inline void
+scfx_rep::set_inf(int sign)
+{
+ m_mant.resize_to(min_mant);
+ m_state = infinity;
+ m_sign = sign;
+}
+
+// constructors
+inline scfx_rep::scfx_rep(const char *s) :
+ m_mant(min_mant), m_wp(2), m_sign(1), m_state(normal),
+ m_msw(0), m_lsw(0), m_r_flag(false)
+{
+ from_string(s, SC_DEFAULT_CTE_WL_);
+}
+
+// destructor
+inline scfx_rep::~scfx_rep() {}
+
+// assignment operator
+inline void
+scfx_rep::operator = (const scfx_rep &f)
+{
+ if (&f != this) {
+ m_mant = f.m_mant;
+ m_wp = f.m_wp;
+ m_sign = f.m_sign;
+ m_state = f.m_state;
+ m_msw = f.m_msw;
+ m_lsw = f.m_lsw;
+ round(SC_DEFAULT_MAX_WL_);
+ }
+}
+
+inline scfx_rep *
+neg_scfx_rep(const scfx_rep &a)
+{
+ scfx_rep &c = *new scfx_rep(a);
+ c.m_sign = - c.m_sign;
+ return &c;
+}
+
+inline scfx_rep *
+mult_scfx_rep(const scfx_rep &a, const scfx_rep &b, int max_wl)
+{
+ scfx_rep &c = *new scfx_rep;
+ sc_dt::multiply(c, a, b, max_wl);
+ return &c;
+}
+
+inline scfx_rep *
+lsh_scfx_rep(const scfx_rep &a, int b)
+{
+ scfx_rep &c = *new scfx_rep(a);
+ c.lshift(b);
+ return &c;
+}
+
+inline scfx_rep *
+rsh_scfx_rep(const scfx_rep &a, int b)
+{
+ scfx_rep &c = *new scfx_rep(a);
+ c.rshift(b);
+ return &c;
+}
+
+inline int scfx_rep::size() const { return m_mant.size(); }
+
+inline bool scfx_rep::is_neg() const { return (m_sign == -1); }
+
+inline bool
+scfx_rep::is_zero() const
+{
+ if (m_state != normal)
+ return false;
+
+ for (int i = 0; i < size(); i++) {
+ if (m_mant[i])
+ return false;
+ }
+
+ return true;
+}
+
+inline bool scfx_rep::is_nan() const { return (m_state == not_a_number); }
+
+inline bool scfx_rep::is_inf() const { return (m_state == infinity); }
+
+inline bool scfx_rep::is_normal() const { return (m_state == normal); }
+
+inline scfx_rep *
+quantization_scfx_rep(const scfx_rep &a, const scfx_params &params,
+ bool &q_flag)
+{
+ scfx_rep &c = *new scfx_rep(a);
+ c.quantization(params, q_flag);
+ return &c;
+}
+
+inline scfx_rep *
+overflow_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &o_flag)
+{
+ scfx_rep& c = *new scfx_rep(a);
+ c.overflow(params, o_flag);
+ return &c;
+}
+
+inline bool scfx_rep::rounding_flag() const { return m_r_flag; }
+
+inline void
+scfx_rep::resize_to(int new_size, int restore)
+{
+ if (restore == -1) {
+ int size_incr = new_size - size();
+ m_wp += size_incr;
+ m_msw += size_incr;
+ m_lsw += size_incr;
+ }
+ m_mant.resize_to(new_size, restore);
+}
+
+inline const scfx_index
+scfx_rep::calc_indices(int n) const
+{
+ int wi = n / bits_in_word + m_wp;
+ int bi = n % bits_in_word;
+
+ if (bi < 0) {
+ bi += bits_in_word;
+ -- wi;
+ }
+
+ return scfx_index(wi, bi);
+}
+
+inline void
+scfx_rep::o_extend(const scfx_index &x, sc_enc enc)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ if (enc == SC_US_ || (m_mant[wi] & (((word)1) << bi)) == 0) {
+ if (bi != bits_in_word - 1)
+ m_mant[wi] &= ~(((word)-1) << (bi + 1));
+ for (int i = wi + 1; i < size(); ++i)
+ m_mant[i] = 0;
+ m_sign = 1;
+ } else {
+ if (bi != bits_in_word - 1)
+ m_mant[wi] |= (((word)-1) << (bi + 1));
+ for (int i = wi + 1; i < size(); ++i)
+ m_mant[i] = static_cast<word>(-1);
+ m_sign = -1;
+ }
+}
+
+inline bool
+scfx_rep::o_bit_at(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ return (m_mant[wi] & (((word)1) << bi)) != 0;
+}
+
+inline bool
+scfx_rep::o_zero_left(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ bool zero = true;
+ if (bi != bits_in_word - 1)
+ zero = (m_mant[wi] & (((word)-1) << (bi + 1))) == 0;
+ for (int i = wi + 1; i < size(); ++i)
+ zero = zero && m_mant[i] == 0;
+
+ return zero;
+}
+
+inline bool
+scfx_rep::o_zero_right(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ bool zero = (m_mant[wi] & ~(((word)-1) << bi)) == 0;
+ for (int i = wi - 1; i >= 0; --i)
+ zero = zero && m_mant[i] == 0;
+
+ return zero;
+}
+
+inline void
+scfx_rep::o_set_low(const scfx_index &x, sc_enc enc)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ m_mant.clear();
+
+ if (enc == SC_TC_) {
+ m_mant[wi] |= (((word)1) << bi);
+ m_sign = -1;
+ } else {
+ m_sign = 1;
+ }
+}
+
+inline void
+scfx_rep::o_set_high(const scfx_index &x, const scfx_index &x2,
+ sc_enc enc, int sign)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+ int wi2 = x2.wi();
+ int bi2 = x2.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+ SC_ASSERT_(wi2 >= 0 && wi2 < size(), "word index out of range");
+
+ int i;
+
+ for (i = 0; i < size(); ++i)
+ m_mant[i] = static_cast<word>(-1);
+
+ m_mant[wi] &= ~(((word)-1) << bi);
+ for (i = wi + 1; i < size(); ++i)
+ m_mant[i] = 0;
+
+ m_mant[wi2] &= (((word)-1) << bi2);
+ for (i = wi2 - 1; i >= 0; --i)
+ m_mant[i] = 0;
+
+ if (enc == SC_TC_) {
+ m_sign = sign;
+ } else {
+ m_mant[wi] |= (((word)1) << bi);
+ m_sign = 1;
+ }
+}
+
+inline void
+scfx_rep::o_set(const scfx_index &x, const scfx_index &x3, sc_enc enc,
+ bool under)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+ int wi3 = x3.wi();
+ int bi3 = x3.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+ SC_ASSERT_(wi3 >= 0 && wi3 < size(), "word index out of range");
+
+ if (bi3 != bits_in_word - 1) {
+ if (under)
+ m_mant[wi3] &= ~(((word)-1) << (bi3 + 1));
+ else
+ m_mant[wi3] |= (((word)-1) << (bi3 + 1));
+ }
+ for (int i = wi3 + 1; i < size(); ++i) {
+ if (under)
+ m_mant[i] = 0;
+ else
+ m_mant[i] = static_cast<word>(-1);
+ }
+
+ if (enc == SC_TC_) {
+ if (under)
+ m_mant[wi] |= (((word)1) << bi);
+ else
+ m_mant[wi] &= ~(((word)1) << bi);
+ }
+}
+
+inline void
+scfx_rep::o_invert(const scfx_index &x2)
+{
+ int wi2 = x2.wi();
+ int bi2 = x2.bi();
+
+ m_mant[wi2] ^= (((word)-1) << bi2);
+ for (int i = wi2 + 1; i < size(); ++i)
+ m_mant[i] = ~ m_mant[i];
+}
+
+inline bool
+scfx_rep::q_bit(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ if (bi != 0)
+ return (m_mant[wi] & (((word)1) << (bi - 1))) != 0;
+ else if (wi != 0)
+ return (m_mant[wi - 1] & (((word)1) << (bits_in_word - 1))) != 0;
+ else
+ return false;
+}
+
+inline void
+scfx_rep::q_clear(const scfx_index &x)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ m_mant[wi] &= (((word)-1) << bi);
+ for (int i = wi - 1; i >= 0; --i)
+ m_mant[i] = 0;
+}
+
+inline void
+scfx_rep::q_incr(const scfx_index &x)
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ word old_val = m_mant[wi];
+ m_mant[wi] += (((word)1) << bi);
+ if (m_mant[wi] <= old_val) {
+ if (wi + 1 == size())
+ resize_to(size() + 1, 1);
+
+ for (int i = wi + 1; i < size(); ++i) {
+ if (++m_mant[i] != 0)
+ break;
+ }
+ }
+}
+
+inline bool
+scfx_rep::q_odd(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ return (m_mant[wi] & (((word)1) << bi)) != 0;
+}
+
+inline bool
+scfx_rep::q_zero(const scfx_index &x) const
+{
+ int wi = x.wi();
+ int bi = x.bi();
+
+ SC_ASSERT_(wi >= 0 && wi < size(), "word index out of range");
+
+ bool zero;
+
+ if (bi != 0) {
+ zero = (m_mant[wi] & ~(((word)-1) << (bi - 1))) == 0;
+ for (int i = wi - 1; i >= 0; --i)
+ zero = zero && m_mant[i] == 0;
+ } else if (wi != 0) {
+ zero = (m_mant[wi - 1] & ~( ((word)-1) << (bits_in_word - 1))) == 0;
+ for (int i = wi - 2; i >= 0; --i)
+ zero = zero && m_mant[i] == 0;
+ } else {
+ zero = true;
+ }
+
+ return zero;
+}
+
+inline int
+scfx_rep::find_lsw() const
+{
+ for (int i = 0; i < size(); i++) {
+ if (m_mant[i])
+ return i;
+ }
+ return 0;
+}
+
+inline int
+scfx_rep::find_msw() const
+{
+ for (int i = size() - 1; i >= 0; i--) {
+ if (m_mant[i])
+ return i;
+ }
+ return 0;
+}
+
+inline void
+scfx_rep::find_sw()
+{
+ m_lsw = find_lsw();
+ m_msw = find_msw();
+}
+
+inline void
+scfx_rep::toggle_tc()
+{
+ if (is_neg()) {
+ complement(m_mant, m_mant, m_mant.size());
+ inc(m_mant);
+ }
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_REP_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_string.hh b/src/systemc/ext/dt/fx/scfx_string.hh
new file mode 100644
index 000000000..f1f973992
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_string.hh
@@ -0,0 +1,199 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_string.h -
+
+ Original Author: Robert Graulich, Synopsys, Inc.
+ Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+// $Log: scfx_string.h,v $
+// Revision 1.1.1.1 2006/12/15 20:20:04 acg
+// SystemC 2.3
+//
+// Revision 1.2 2006/01/03 23:18:34 acg
+// Changed copyright to include 2006.
+//
+// Revision 1.1.1.1 2005/12/19 23:16:43 acg
+// First check in of SystemC 2.1 into its own archive.
+//
+// Revision 1.9 2005/09/15 23:02:03 acg
+// Added std:: prefix to appropriate methods and types to get around
+// issues with the Edison Front End.
+//
+// Revision 1.8 2005/06/07 17:27:02 acg
+// Fixed bug in scfx_string::operator += where an array reference was used
+// rather than the [] operator. This meant that the buffer may have been
+// accessed beyond its allocated storage.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_STRING_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_STRING_HH__
+
+#include <cstdio>
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class scfx_string;
+
+
+// ----------------------------------------------------------------------------
+// CLASS : scfx_string
+//
+// Simple string class for internal use.
+// ----------------------------------------------------------------------------
+
+class scfx_string
+{
+ void resize(std::size_t);
+
+ public:
+ scfx_string();
+
+ ~scfx_string();
+
+ int length() const;
+
+ void clear();
+
+ char & operator [] (int);
+
+ void append(int);
+ void discard(int);
+ void remove(int);
+
+ void operator += (char);
+ void operator += (const char *);
+
+ operator const char * ();
+
+ private:
+ std::size_t m_len;
+ std::size_t m_alloc;
+ char *m_buffer;
+};
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline void
+scfx_string::resize(std::size_t i)
+{
+ do {
+ m_alloc *= 2;
+ } while (i >= m_alloc);
+
+ char *temp = new char[m_alloc];
+
+ for (int j = 0; j < (int) m_len; ++j) {
+ temp[j] = m_buffer[j];
+ }
+ temp[m_len] = 0;
+
+ delete [] m_buffer;
+ m_buffer = temp;
+}
+
+inline scfx_string::scfx_string() :
+ m_len(0), m_alloc(BUFSIZ), m_buffer(new char[m_alloc])
+{
+ m_buffer[m_len] = 0;
+}
+
+inline scfx_string::~scfx_string() { delete [] m_buffer; }
+
+inline int scfx_string::length() const { return m_len; }
+
+inline void
+scfx_string::clear()
+{
+ m_len = 0;
+ m_buffer[m_len] = 0;
+}
+
+inline char &
+scfx_string::operator [] (int i)
+{
+ if (i >= (int)m_alloc) {
+ resize(i);
+ }
+ return m_buffer[i];
+}
+
+inline void
+scfx_string::append(int n)
+{
+ m_len += n;
+ m_buffer[m_len] = 0;
+}
+
+inline void
+scfx_string::discard(int n)
+{
+ m_len -= n;
+ m_buffer[m_len] = 0;
+}
+
+inline void
+scfx_string::remove(int i)
+{
+ for (int j = i + 1; j < (int)m_len; ++j)
+ m_buffer[j - 1] = m_buffer[j];
+ --m_len;
+ m_buffer[m_len] = 0;
+}
+
+inline void
+scfx_string::operator += (char c)
+{
+ this->operator [] (m_len) = c;
+ m_len++;
+ this->operator [] (m_len) = 0;
+}
+
+inline void
+scfx_string::operator += (const char *s)
+{
+ while (*s)
+ (*this) += *s++;
+}
+
+inline scfx_string::operator const char * ()
+{
+ m_buffer[m_len] = 0;
+ return m_buffer;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_STRING_HH__
diff --git a/src/systemc/ext/dt/fx/scfx_utils.hh b/src/systemc/ext/dt/fx/scfx_utils.hh
new file mode 100644
index 000000000..37c57844c
--- /dev/null
+++ b/src/systemc/ext/dt/fx/scfx_utils.hh
@@ -0,0 +1,493 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ scfx_utils.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: scfx_utils.h,v $
+// Revision 1.2 2009/02/28 00:26:20 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.1.1.1 2006/12/15 20:31:36 acg
+// SystemC 2.2
+//
+// Revision 1.3 2006/01/13 18:53:58 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_FX_SCFX_UTILS_HH__
+#define __SYSTEMC_EXT_DT_FX_SCFX_UTILS_HH__
+
+#include "sc_fxdefs.hh"
+#include "scfx_params.hh"
+#include "scfx_string.hh"
+
+namespace sc_dt
+{
+
+// ----------------------------------------------------------------------------
+// Find the most and least significant non-zero bits in a unsigned long
+// ----------------------------------------------------------------------------
+
+#define MSB_STATEMENT(n) if (x >> n) { x >>= n; i += n; }
+
+inline int
+scfx_find_msb(unsigned long x)
+{
+ int i = 0;
+# if defined(SC_LONG_64)
+ MSB_STATEMENT(32);
+# endif // defined(SC_LONG_64)
+ MSB_STATEMENT(16);
+ MSB_STATEMENT(8);
+ MSB_STATEMENT(4);
+ MSB_STATEMENT(2);
+ MSB_STATEMENT(1);
+ return i;
+}
+
+#undef MSB_STATEMENT
+
+#define LSB_STATEMENT(n) if (x << n) { x <<= n; i -= n; }
+
+inline int
+scfx_find_lsb(unsigned long x)
+{
+ int i;
+# if defined(SC_LONG_64)
+ i = 63;
+ LSB_STATEMENT(32);
+# else
+ i = 31;
+# endif // defined(SC_LONG_64)
+ LSB_STATEMENT(16);
+ LSB_STATEMENT(8);
+ LSB_STATEMENT(4);
+ LSB_STATEMENT(2);
+ LSB_STATEMENT(1);
+ return i;
+}
+
+#undef LSB_STATEMENT
+
+
+// ----------------------------------------------------------------------------
+// Utilities for parsing a character string number
+// ----------------------------------------------------------------------------
+
+inline int
+scfx_parse_sign(const char *&s, bool &sign_char)
+{
+ int sign = 1;
+
+ if (*s == '+') {
+ ++s;
+ sign_char = true;
+ } else if (*s == '-' ) {
+ sign = -1;
+ ++s;
+ sign_char = true;
+ } else {
+ sign_char = false;
+ }
+
+ return sign;
+}
+
+inline sc_numrep
+scfx_parse_prefix(const char *&s)
+{
+ if (s[0] == '0') {
+ switch (s[1]) {
+ case 'b':
+ case 'B':
+ {
+ if ((s[2] == 'u' || s[2] == 'U') &&
+ (s[3] == 's' || s[3] == 'S')) {
+ s += 4;
+ return SC_BIN_US;
+ }
+ if ((s[2] == 's' || s[2] == 'S') &&
+ (s[3] == 'm' || s[3] == 'M')) {
+ s += 4;
+ return SC_BIN_SM;
+ }
+ s += 2;
+ return SC_BIN;
+ }
+ case 'o':
+ case 'O':
+ {
+ if ((s[2] == 'u' || s[2] == 'U') &&
+ (s[3] == 's' || s[3] == 'S')) {
+ s += 4;
+ return SC_OCT_US;
+ }
+ if ((s[2] == 's' || s[2] == 'S') &&
+ (s[3] == 'm' || s[3] == 'M')) {
+ s += 4;
+ return SC_OCT_SM;
+ }
+ s += 2;
+ return SC_OCT;
+ }
+ case 'x':
+ case 'X':
+ {
+ if ((s[2] == 'u' || s[2] == 'U') &&
+ (s[3] == 's' || s[3] == 'S')) {
+ s += 4;
+ return SC_HEX_US;
+ }
+ if ((s[2] == 's' || s[2] == 'S') &&
+ (s[3] == 'm' || s[3] == 'M')) {
+ s += 4;
+ return SC_HEX_SM;
+ }
+ s += 2;
+ return SC_HEX;
+ }
+ case 'd':
+ case 'D':
+ {
+ s += 2;
+ return SC_DEC;
+ }
+ case 'c':
+ case 'C':
+ {
+ if ((s[2] == 's' || s[2] == 'S') &&
+ (s[3] == 'd' || s[3] == 'D')) {
+ s += 4;
+ return SC_CSD;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ return SC_DEC;
+}
+
+inline int
+scfx_parse_base(const char *&s)
+{
+ const char *s1 = s + 1;
+
+ int base = 10;
+
+ if (*s == '0') {
+ switch (*s1) {
+ case 'b':
+ case 'B': base = 2; s += 2; break;
+ case 'o':
+ case 'O': base = 8; s += 2; break;
+ case 'd':
+ case 'D': base = 10; s += 2; break;
+ case 'x':
+ case 'X': base = 16; s += 2; break;
+ }
+ }
+
+ return base;
+}
+
+inline bool
+scfx_is_equal(const char *a, const char *b)
+{
+ while (*a != 0 && *b != 0 && *a == *b) {
+ ++ a;
+ ++ b;
+ }
+ return (*a == 0 && *b == 0);
+}
+
+inline bool
+scfx_is_nan(const char *s)
+{
+ return scfx_is_equal(s, "NaN");
+}
+
+inline bool
+scfx_is_inf(const char *s)
+{
+ return (scfx_is_equal(s, "Inf") || scfx_is_equal(s, "Infinity"));
+}
+
+inline bool
+scfx_exp_start(const char *s)
+{
+ if (*s == 'e' || *s == 'E') {
+ ++s;
+ if (*s == '+' || *s == '-')
+ return true;
+ }
+ return false;
+}
+
+inline bool
+scfx_is_digit(char c, sc_numrep numrep)
+{
+ bool is_digit;
+
+ switch(numrep) {
+ case SC_DEC:
+ {
+ switch(c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ is_digit = true;
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+ break;
+ }
+ case SC_BIN:
+ case SC_BIN_US:
+ case SC_BIN_SM:
+ {
+ switch(c) {
+ case '0': case '1':
+ {
+ is_digit = true;
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+ break;
+ }
+ case SC_OCT:
+ case SC_OCT_US:
+ case SC_OCT_SM:
+ {
+ switch(c) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ {
+ is_digit = true;
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+ break;
+ }
+ case SC_HEX:
+ case SC_HEX_US:
+ case SC_HEX_SM:
+ {
+ switch (c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ {
+ is_digit = true;
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+ break;
+ }
+ case SC_CSD:
+ {
+ switch (c) {
+ case '0': case '1': case '-':
+ {
+ is_digit = true;
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+ break;
+ }
+ default:
+ is_digit = false;
+ }
+
+ return is_digit;
+}
+
+inline int
+scfx_to_digit(char c, sc_numrep numrep)
+{
+ int to_digit;
+
+ switch (numrep) {
+ case SC_DEC:
+ case SC_BIN:
+ case SC_BIN_US:
+ case SC_BIN_SM:
+ case SC_OCT:
+ case SC_OCT_US:
+ case SC_OCT_SM:
+ {
+ to_digit = c - '0';
+ break;
+ }
+ case SC_HEX:
+ case SC_HEX_US:
+ case SC_HEX_SM:
+ {
+ switch (c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ to_digit = c - '0';
+ break;
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ to_digit = c - 'a' + 10;
+ break;
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ to_digit = c - 'A' + 10;
+ break;
+ default:
+ to_digit = -2;
+ }
+ break;
+ }
+ case SC_CSD:
+ {
+ if (c == '-')
+ to_digit = -1;
+ else
+ to_digit = c - '0';
+ break;
+ }
+ default:
+ to_digit = -2;
+ }
+
+ return to_digit;
+}
+
+
+// ----------------------------------------------------------------------------
+// Utilities for printing a character string number
+// ----------------------------------------------------------------------------
+
+inline void scfx_print_nan(scfx_string &s) { s += "NaN"; }
+inline void
+scfx_print_inf(scfx_string &s, bool negative)
+{
+ if (negative)
+ s += "-Inf";
+ else
+ s += "Inf";
+}
+
+inline void
+scfx_print_prefix(scfx_string &s, sc_numrep numrep)
+{
+ switch (numrep) {
+ case SC_DEC:
+ s += "0d";
+ break;
+ case SC_BIN:
+ s += "0b";
+ break;
+ case SC_BIN_US:
+ s += "0bus";
+ break;
+ case SC_BIN_SM:
+ s += "0bsm";
+ break;
+ case SC_OCT:
+ s += "0o";
+ break;
+ case SC_OCT_US:
+ s += "0ous";
+ break;
+ case SC_OCT_SM:
+ s += "0osm";
+ break;
+ case SC_HEX:
+ s += "0x";
+ break;
+ case SC_HEX_US:
+ s += "0xus";
+ break;
+ case SC_HEX_SM:
+ s += "0xsm";
+ break;
+ case SC_CSD:
+ s += "0csd";
+ break;
+ default:
+ s += "unknown";
+ }
+}
+
+inline void
+scfx_print_exp(scfx_string &s, int exp)
+{
+ if (exp != 0) {
+ s += 'e';
+
+ if (exp < 0) {
+ exp = - exp;
+ s += '-';
+ } else {
+ s += '+';
+ }
+
+ bool first = true;
+ int scale = 1000000000;
+ do {
+ int digit = exp / scale;
+ exp = exp % scale;
+ if (digit != 0 || !first) {
+ s += static_cast<char>(digit + '0');
+ first = false;
+ }
+ scale /= 10;
+ }
+ while (scale > 0);
+ }
+}
+
+void scfx_tc2csd(scfx_string &, int);
+void scfx_csd2tc(scfx_string &);
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_FX_SCFX_UTILS_HH__
diff --git a/src/systemc/ext/dt/int/_int.hh b/src/systemc/ext/dt/int/_int.hh
index 11c2b4aba..dfbcf6ebd 100644
--- a/src/systemc/ext/dt/int/_int.hh
+++ b/src/systemc/ext/dt/int/_int.hh
@@ -27,9 +27,20 @@
* Authors: Gabe Black
*/
-#ifndef __SYSTEMC_EXT_CORE_DT__INT_HH__
-#define __SYSTEMC_EXT_CORE_DT__INT_HH__
+#ifndef __SYSTEMC_EXT_CORE_DT_INT__INT_HH__
+#define __SYSTEMC_EXT_CORE_DT_INT__INT_HH__
+#include "sc_bigint.hh"
+#include "sc_biguint.hh"
+#include "sc_int.hh"
+#include "sc_int_base.hh"
+#include "sc_length_param.hh"
#include "sc_nbdefs.hh"
+#include "sc_nbexterns.hh"
+#include "sc_nbutils.hh"
+#include "sc_signed.hh"
+#include "sc_uint.hh"
+#include "sc_uint_base.hh"
+#include "sc_unsigned.hh"
-#endif //__SYSTEMC_EXT_CORE_DT__INT_HH__
+#endif //__SYSTEMC_EXT_CORE_DT_INT__INT_HH__
diff --git a/src/systemc/ext/dt/int/_using.hh b/src/systemc/ext/dt/int/_using.hh
index a53ac36ec..82f64dd25 100644
--- a/src/systemc/ext/dt/int/_using.hh
+++ b/src/systemc/ext/dt/int/_using.hh
@@ -27,27 +27,38 @@
* Authors: Gabe Black
*/
-#ifndef __SYSTEMC_EXT_CORE_INT__USING_HH__
-#define __SYSTEMC_EXT_CORE_INT__USING_HH__
+#ifndef __SYSTEMC_EXT_DT_INT__USING_HH__
+#define __SYSTEMC_EXT_DT_INT__USING_HH__
-#include "int.hh"
+#include "_int.hh"
-using sc_dt::SC_NOBASE;
using sc_dt::SC_BIN;
-using sc_dt::SC_OCT;
+using sc_dt::SC_BIN_SM;
+using sc_dt::SC_BIN_US;
+using sc_dt::SC_CSD;
using sc_dt::SC_DEC;
using sc_dt::SC_HEX;
-using sc_dt::SC_BIN_US;
-using sc_dt::SC_BIN_SM;
-using sc_dt::SC_OCT_US;
-using sc_dt::SC_OCT_SM;
-using sc_dt::SC_HEX_US;
using sc_dt::SC_HEX_SM;
-using sc_dt::SC_CSD;
-using sc_dt::small_type
+using sc_dt::SC_HEX_US;
+using sc_dt::SC_NOBASE;
+using sc_dt::SC_OCT;
+using sc_dt::SC_OCT_SM;
+using sc_dt::SC_OCT_US;
using sc_dt::int64;
+using sc_dt::sc_bigint;
+using sc_dt::sc_biguint;
+using sc_dt::sc_digit;
+using sc_dt::sc_int;
+using sc_dt::sc_int_base;
+using sc_dt::sc_io_show_base;
+using sc_dt::sc_length_context;
+using sc_dt::sc_length_param;
+using sc_dt::sc_logic;
+using sc_dt::sc_numrep;
+using sc_dt::sc_signed;
+using sc_dt::sc_uint;
+using sc_dt::sc_uint_base;
+using sc_dt::sc_unsigned;
using sc_dt::uint64;
-using sc_dt::int_type;
-using sc_dt::uint_type;
-#endif //__SYSTEMC_EXT_CORE_INT__USING_HH__
+#endif //__SYSTEMC_EXT_DT_INT__USING_HH__
diff --git a/src/systemc/ext/dt/int/sc_bigint.hh b/src/systemc/ext/dt/int/sc_bigint.hh
new file mode 100644
index 000000000..bcfbcaefc
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_bigint.hh
@@ -0,0 +1,284 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_bigint.h -- Template version of sc_signed. This class enables
+ compile-time bit widths for sc_signed numbers.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc.
+ Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_bigint.h,v $
+// Revision 1.2 2011/02/18 20:19:14 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:31 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__
+
+#include "sc_signed.hh"
+#include "sc_unsigned.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_bigint;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_bigint<W>
+//
+// Arbitrary size signed integer type.
+// ----------------------------------------------------------------------------
+
+#ifdef SC_MAX_NBITS
+template<int W=SC_MAX_NBITS>
+#else
+template<int W>
+#endif
+class sc_bigint : public sc_signed
+{
+ public:
+ // constructors
+ sc_bigint() : sc_signed(W) {}
+ sc_bigint(const sc_bigint<W> &v) : sc_signed(W) { *this = v; }
+ sc_bigint(const sc_signed &v) : sc_signed(W) { *this = v; }
+ sc_bigint(const sc_signed_subref &v) : sc_signed(W) { *this = v; }
+
+ template< class T >
+ sc_bigint(const sc_generic_base<T> &a) : sc_signed(W)
+ {
+ a->to_sc_signed(*this);
+ }
+
+ sc_bigint(const sc_unsigned &v) : sc_signed(W) { *this = v; }
+ sc_bigint(const sc_unsigned_subref &v) : sc_signed(W) { *this = v; }
+ sc_bigint(const char *v) : sc_signed(W) { *this = v; }
+ sc_bigint(int64 v) : sc_signed(W) { *this = v; }
+ sc_bigint(uint64 v) : sc_signed(W) { *this = v; }
+ sc_bigint(long v) : sc_signed(W) { *this = v; }
+ sc_bigint(unsigned long v) : sc_signed(W) { *this = v; }
+ sc_bigint(int v) : sc_signed(W) { *this = v; }
+ sc_bigint(unsigned int v) : sc_signed(W) { *this = v; }
+ sc_bigint(double v) : sc_signed(W) { *this = v; }
+ sc_bigint(const sc_bv_base &v) : sc_signed(W) { *this = v; }
+ sc_bigint(const sc_lv_base &v) : sc_signed(W) { *this = v; }
+
+ explicit sc_bigint(const sc_fxval &v) : sc_signed(W) { *this = v; }
+ explicit sc_bigint(const sc_fxval_fast &v) : sc_signed(W) { *this = v; }
+ explicit sc_bigint(const sc_fxnum &v) : sc_signed(W) { *this = v; }
+ explicit sc_bigint(const sc_fxnum_fast &v) : sc_signed(W) { *this = v; }
+
+#ifndef SC_MAX_NBITS
+ // destructor
+ ~sc_bigint() {}
+#endif
+
+ // assignment operators
+ sc_bigint<W> &
+ operator = (const sc_bigint<W> &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_signed &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_signed_subref &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ template< class T >
+ sc_bigint<W> &
+ operator = (const sc_generic_base<T> &a)
+ {
+ a->to_sc_signed(*this);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_unsigned &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_unsigned_subref &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const char *v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (int64 v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (uint64 v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (long v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (unsigned long v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (int v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (unsigned int v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &operator = (double v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+
+ sc_bigint<W> &
+ operator = (const sc_bv_base &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_lv_base &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_int_base &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_uint_base &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_fxval &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_fxval_fast& v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_fxnum &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+
+ sc_bigint<W> &
+ operator = (const sc_fxnum_fast &v)
+ {
+ sc_signed::operator = (v);
+ return *this;
+ }
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__
diff --git a/src/systemc/ext/dt/int/sc_biguint.hh b/src/systemc/ext/dt/int/sc_biguint.hh
new file mode 100644
index 000000000..7b6676971
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_biguint.hh
@@ -0,0 +1,284 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_biguint.h -- Template version of sc_unsigned. This class
+ enables compile-time bit widths for sc_unsigned numbers.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc.
+ Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_biguint.h,v $
+// Revision 1.2 2011/02/18 20:19:14 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:31 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__
+
+#include "sc_signed.hh"
+#include "sc_unsigned.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_biguint;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_biguint<W>
+//
+// Arbitrary size unsigned integer type.
+// ----------------------------------------------------------------------------
+
+#ifdef SC_MAX_NBITS
+template<int W=SC_MAX_NBITS>
+#else
+template<int W>
+#endif
+class sc_biguint : public sc_unsigned
+{
+ public:
+ // constructors
+ sc_biguint() : sc_unsigned(W) {}
+ sc_biguint(const sc_biguint<W> &v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const sc_unsigned &v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const sc_unsigned_subref &v) : sc_unsigned(W) { *this = v; }
+
+ template<class T>
+ sc_biguint(const sc_generic_base<T> &a) : sc_unsigned(W)
+ {
+ a->to_sc_unsigned(*this);
+ }
+
+ sc_biguint(const sc_signed &v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const sc_signed_subref &v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const char* v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(int64 v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(uint64 v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(long v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(unsigned long v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(int v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(unsigned int v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(double v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const sc_bv_base &v) : sc_unsigned(W) { *this = v; }
+ sc_biguint(const sc_lv_base &v) : sc_unsigned(W) { *this = v; }
+
+ explicit sc_biguint(const sc_fxval &v) : sc_unsigned(W) { *this = v; }
+ explicit sc_biguint(const sc_fxval_fast &v) : sc_unsigned(W) { *this = v; }
+ explicit sc_biguint(const sc_fxnum &v) : sc_unsigned(W) { *this = v; }
+ explicit sc_biguint(const sc_fxnum_fast &v) : sc_unsigned(W) { *this = v; }
+
+#ifndef SC_MAX_NBITS
+ // destructor
+ ~sc_biguint() {}
+#endif
+
+ // assignment operators
+ sc_biguint<W> &
+ operator = (const sc_biguint<W> &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_unsigned &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_unsigned_subref &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ template< class T >
+ sc_biguint<W> &
+ operator = (const sc_generic_base<T> &a)
+ { a->to_sc_unsigned(*this);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_signed &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_signed_subref &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const char* v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (int64 v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (uint64 v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (long v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (unsigned long v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (int v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (unsigned int v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (double v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+
+ sc_biguint<W> &
+ operator = (const sc_bv_base &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_lv_base &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_int_base &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_uint_base &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_fxval &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_fxval_fast &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_fxnum &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+
+ sc_biguint<W> &
+ operator = (const sc_fxnum_fast &v)
+ {
+ sc_unsigned::operator = (v);
+ return *this;
+ }
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__
diff --git a/src/systemc/ext/dt/int/sc_int.hh b/src/systemc/ext/dt/int/sc_int.hh
new file mode 100644
index 000000000..d417321ef
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_int.hh
@@ -0,0 +1,381 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_int.h -- A signed integer whose length is less than 64 bits.
+
+ Unlike arbitrary precision, arithmetic and bitwise operations
+ are performed using the native types (hence capped at 64 bits).
+ The sc_int integer is useful when the user does not need
+ arbitrary precision and the performance is superior to
+ sc_bigint/sc_biguint.
+
+ Original Author: Amit Rao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
+ Description of Modification: - Resolved ambiguity with sc_(un)signed.
+ - Merged the code for 64- and 32-bit versions
+ via the constants in sc_nbdefs.h.
+ - Eliminated redundant file inclusions.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_int.h,v $
+// Revision 1.2 2011/02/18 20:19:14 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:31 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_INT_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_INT_HH__
+
+#include "sc_int_base.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_int;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_int<W>
+//
+// Template class sc_int<W> is the interface that the user sees. It is
+// derived from sc_int_base and most of its methods are just wrappers
+// that call the corresponding method in the parent class. Note that
+// the length of sc_int datatype is specified as a template parameter.
+// ----------------------------------------------------------------------------
+
+template <int W>
+class sc_int : public sc_int_base
+{
+ public:
+ // constructors
+ sc_int() : sc_int_base(W) {}
+ sc_int(int_type v) : sc_int_base(v, W) {}
+ sc_int(const sc_int<W> &a) : sc_int_base(a) {}
+
+ sc_int(const sc_int_base &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(const sc_int_subref_r &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ template< class T >
+ sc_int(const sc_generic_base<T> &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a->to_int64());
+ }
+ sc_int(const sc_signed &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(const sc_unsigned &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ explicit sc_int(const sc_fxval &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ explicit sc_int(const sc_fxval_fast &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ explicit sc_int(const sc_fxnum &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ explicit sc_int(const sc_fxnum_fast &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(const sc_bv_base &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(const sc_lv_base &a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(const char *a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(unsigned long a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(long a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(unsigned int a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(int a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(uint64 a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+ sc_int(double a) : sc_int_base(W)
+ {
+ sc_int_base::operator = (a);
+ }
+
+ // assignment operators
+ sc_int<W> &
+ operator = (int_type v)
+ {
+ sc_int_base::operator = (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_int_base &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_int_subref_r &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_int<W> &a)
+ {
+ m_val = a.m_val;
+ return *this;
+ }
+ template< class T >
+ sc_int<W> &
+ operator = (const sc_generic_base<T> &a)
+ {
+ sc_int_base::operator = (a->to_int64());
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_signed &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_unsigned &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_fxval &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_fxval_fast &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_fxnum &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &operator = (const sc_fxnum_fast &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_bv_base &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const sc_lv_base &a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (const char *a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (unsigned long a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (long a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (unsigned int a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (int a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (uint64 a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+ sc_int<W> &
+ operator = (double a)
+ {
+ sc_int_base::operator = (a);
+ return *this;
+ }
+
+ // arithmetic assignment operators
+ sc_int<W> &
+ operator += (int_type v)
+ {
+ sc_int_base::operator += (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator -= (int_type v)
+ {
+ sc_int_base::operator -= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator *= (int_type v)
+ {
+ sc_int_base::operator *= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator /= (int_type v)
+ {
+ sc_int_base::operator /= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator %= (int_type v)
+ {
+ sc_int_base::operator %= (v);
+ return *this;
+ }
+
+ // bitwise assignment operators
+ sc_int<W> &
+ operator &= (int_type v)
+ {
+ sc_int_base::operator &= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator |= (int_type v)
+ {
+ sc_int_base::operator |= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator ^= (int_type v)
+ {
+ sc_int_base::operator ^= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator <<= (int_type v)
+ {
+ sc_int_base::operator <<= (v);
+ return *this;
+ }
+ sc_int<W> &
+ operator >>= (int_type v)
+ {
+ sc_int_base::operator >>= (v);
+ return *this;
+ }
+
+ // prefix and postfix increment and decrement operators
+ sc_int<W> &
+ operator ++ () // prefix
+ {
+ sc_int_base::operator ++ ();
+ return *this;
+ }
+ const sc_int<W>
+ operator ++ (int) // postfix
+ {
+ return sc_int<W>(sc_int_base::operator ++ (0));
+ }
+ sc_int<W> &
+ operator -- () // prefix
+ {
+ sc_int_base::operator -- ();
+ return *this;
+ }
+ const sc_int<W>
+ operator -- (int) // postfix
+ {
+ return sc_int<W>(sc_int_base::operator -- (0));
+ }
+};
+
+} // namespace sc_dt
+
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_INT_HH__
diff --git a/src/systemc/ext/dt/int/sc_int_base.hh b/src/systemc/ext/dt/int/sc_int_base.hh
new file mode 100644
index 000000000..a8f602028
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_int_base.hh
@@ -0,0 +1,1386 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_int_base.h -- A signed integer whose length is less than 64 bit.
+
+ Unlike arbitrary precision, arithmetic and bitwise operations
+ are performed using the native types (hence capped at 64 bits).
+ The sc_int integer is useful when the user does not need
+ arbitrary precision and the performance is superior to
+ sc_bigint/sc_biguint.
+
+ Original Author: Amit Rao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
+ Description of Modification: - Resolved ambiguity with sc_(un)signed.
+ - Merged the code for 64- and 32-bit versions
+ via the constants in sc_nbdefs.h.
+ - Eliminated redundant file inclusions.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_int_base.h,v $
+// Revision 1.3 2011/08/24 22:05:45 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.4 2006/05/08 17:50:01 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.3 2006/01/13 18:49:31 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
+
+#include <iostream>
+
+#include "../misc/sc_value_base.hh"
+#include "../sc_temporary.hh"
+#include "sc_length_param.hh"
+#include "sc_nbdefs.hh"
+#include "sc_uint_base.hh"
+
+namespace sc_dt
+{
+
+class sc_concatref;
+
+// classes defined in this module
+class sc_int_bitref_r;
+class sc_int_bitref;
+class sc_int_subref_r;
+class sc_int_subref;
+class sc_int_base;
+class sc_signed_subref_r;
+class sc_unsigned_subref_r;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_signed;
+class sc_unsigned;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+} // namespace sc_dt
+
+// extern template instantiations
+namespace sc_core
+{
+
+extern template class sc_vpool<sc_dt::sc_int_bitref>;
+extern template class sc_vpool<sc_dt::sc_int_subref>;
+
+} // namespace sc_core
+
+namespace sc_dt
+{
+
+extern const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH];
+
+// friend operator declarations
+
+// relational operators
+
+inline bool operator == (const sc_int_base &a, const sc_int_base &b);
+inline bool operator != (const sc_int_base &a, const sc_int_base &b);
+inline bool operator < (const sc_int_base &a, const sc_int_base &b);
+inline bool operator <= (const sc_int_base &a, const sc_int_base &b);
+inline bool operator > (const sc_int_base &a, const sc_int_base &b);
+inline bool operator >= (const sc_int_base &a, const sc_int_base &b);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_bitref_r
+//
+// Proxy class for sc_int bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_int_bitref_r : public sc_value_base
+{
+ friend class sc_int_base;
+
+ protected:
+ // constructor
+ sc_int_bitref_r() : sc_value_base(), m_index(), m_obj_p() {}
+
+ // initializer for sc_core::sc_vpool:
+ void initialize(const sc_int_base *obj_p, int index_)
+ {
+ m_obj_p = (sc_int_base *)obj_p;
+ m_index = index_;
+ }
+
+ public:
+ // copy constructor
+ sc_int_bitref_r(const sc_int_bitref_r &a) :
+ sc_value_base(a), m_index(a.m_index), m_obj_p(a.m_obj_p)
+ {}
+
+ // destructor
+ virtual ~sc_int_bitref_r() {}
+
+ // capacity
+ int length() const { return 1; }
+
+#ifdef SC_DT_DEPRECATED
+ int bitwidth() const { return length(); }
+#endif
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return 1;
+ }
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+
+ dst_p[word_i] &= ~bit_mask;
+ return false;
+ }
+ virtual bool
+ concat_get_data(sc_digit *dst_p, int low_i) const
+ {
+ bool non_zero;
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+
+ if (operator uint64()) {
+ dst_p[word_i] |= bit_mask;
+ non_zero = true;
+ } else {
+ dst_p[word_i] &= ~bit_mask;
+ non_zero = false;
+ }
+ return non_zero;
+ }
+ virtual uint64
+ concat_get_uint64() const
+ {
+ return operator uint64();
+ }
+
+
+ // implicit conversions
+ operator uint64 () const;
+ bool operator ! () const;
+ bool operator ~ () const;
+
+
+ // explicit conversions
+ uint64 value() const { return operator uint64(); }
+
+ bool to_bool() const { return operator uint64(); }
+
+
+ // other methods
+ void print(::std::ostream& os=::std::cout) const { os << to_bool(); }
+
+ protected:
+ int m_index;
+ sc_int_base *m_obj_p;
+
+ private:
+ // Disabled
+ sc_int_bitref_r &operator = (const sc_int_bitref_r &);
+};
+
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_int_bitref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_bitref
+//
+// Proxy class for sc_int bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_int_bitref : public sc_int_bitref_r
+{
+ friend class sc_int_base;
+ friend class sc_core::sc_vpool<sc_int_bitref>;
+
+ // constructor
+ sc_int_bitref() : sc_int_bitref_r() {}
+
+ public:
+ // copy constructor
+ sc_int_bitref(const sc_int_bitref &a) : sc_int_bitref_r(a) {}
+
+ // assignment operators
+ sc_int_bitref &operator = (const sc_int_bitref_r &b);
+ sc_int_bitref &operator = (const sc_int_bitref &b);
+ sc_int_bitref &operator = (bool b);
+
+ sc_int_bitref &operator &= (bool b);
+ sc_int_bitref &operator |= (bool b);
+ sc_int_bitref &operator ^= (bool b);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ public:
+ static sc_core::sc_vpool<sc_int_bitref> m_pool;
+};
+
+
+
+inline ::std::istream &operator >> (::std::istream &, sc_int_bitref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_subref_r
+//
+// Proxy class for sc_int part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_int_subref_r : public sc_value_base
+{
+ friend class sc_int_base;
+ friend class sc_int_signal;
+ friend class sc_int_subref;
+
+ protected:
+ // constructor
+ sc_int_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0) {}
+
+ // initializer for sc_core::sc_vpool:
+ void initialize( const sc_int_base *obj_p, int left_i, int right_i)
+ {
+ m_obj_p = (sc_int_base *)obj_p;
+ m_left = left_i;
+ m_right = right_i;
+ }
+
+ public:
+ // copy constructor
+ sc_int_subref_r(const sc_int_subref_r &a) :
+ sc_value_base(a), m_left(a.m_left), m_obj_p(a.m_obj_p),
+ m_right(a.m_right)
+ {}
+
+ // destructor
+ virtual ~sc_int_subref_r() {}
+
+ // capacity
+ int length() const { return (m_left - m_right + 1); }
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return length();
+ }
+ virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
+ virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
+ virtual uint64
+ concat_get_uint64() const
+ {
+ int len = length();
+ uint64 val = operator uint_type();
+ if (len < 64)
+ return (uint64)(val & ~((uint_type)-1 << len));
+ else
+ return (uint64)val;
+ }
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return xor_reduce(); }
+
+ // implicit conversion to uint_type
+ operator uint_type () const;
+
+ // explicit conversions
+ uint_type value() const { return operator uint_type(); }
+
+
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ protected:
+ int m_left;
+ sc_int_base *m_obj_p;
+ int m_right;
+
+ private:
+ const sc_int_subref_r &operator = (const sc_int_subref_r &);
+};
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_int_subref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_subref
+//
+// Proxy class for sc_int part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_int_subref : public sc_int_subref_r
+{
+ friend class sc_int_base;
+ friend class sc_core::sc_vpool<sc_int_subref>;
+
+ protected:
+ // constructor
+ sc_int_subref() : sc_int_subref_r() {}
+
+ public:
+ // copy constructor
+ sc_int_subref(const sc_int_subref &a) : sc_int_subref_r(a) {}
+
+ // assignment operators
+ sc_int_subref &operator = (int_type v);
+ sc_int_subref &operator = (const sc_int_base &a);
+
+ sc_int_subref &
+ operator = (const sc_int_subref_r &a)
+ {
+ return operator = (a.operator uint_type());
+ }
+
+ sc_int_subref &
+ operator = (const sc_int_subref &a)
+ {
+ return operator = (a.operator uint_type());
+ }
+
+ template< class T >
+ sc_int_subref &
+ operator = (const sc_generic_base<T> &a)
+ {
+ return operator = (a->to_int64());
+ }
+
+ sc_int_subref &operator = (const char *a);
+
+ sc_int_subref &
+ operator = (unsigned long a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &
+ operator = (long a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &
+ operator = (unsigned int a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &
+ operator = (int a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &
+ operator = (uint64 a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &
+ operator = (double a)
+ {
+ return operator = ((int_type)a);
+ }
+
+ sc_int_subref &operator = (const sc_signed &);
+ sc_int_subref &operator = (const sc_unsigned &);
+ sc_int_subref &operator = (const sc_bv_base &);
+ sc_int_subref &operator = (const sc_lv_base &);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ public:
+ static sc_core::sc_vpool<sc_int_subref> m_pool;
+};
+
+
+inline ::std::istream &operator >> (::std::istream &, sc_int_subref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_base
+//
+// Base class for sc_int.
+// ----------------------------------------------------------------------------
+
+class sc_int_base : public sc_value_base
+{
+ friend class sc_int_bitref_r;
+ friend class sc_int_bitref;
+ friend class sc_int_subref_r;
+ friend class sc_int_subref;
+
+
+ // support methods
+ void invalid_length() const;
+ void invalid_index(int i) const;
+ void invalid_range(int l, int r) const;
+
+ void
+ check_length() const
+ {
+ if (m_len <= 0 || m_len > SC_INTWIDTH) {
+ invalid_length();
+ }
+ }
+
+ void
+ check_index(int i) const
+ {
+ if (i < 0 || i >= m_len) {
+ invalid_index(i);
+ }
+ }
+
+ void
+ check_range(int l, int r) const
+ {
+ if (r < 0 || l >= m_len || l < r) {
+ invalid_range(l, r);
+ }
+ }
+
+ void check_value() const;
+
+ void
+ extend_sign()
+ {
+#ifdef DEBUG_SYSTEMC
+ check_value();
+#endif
+ m_val = (m_val << m_ulen >> m_ulen);
+ }
+
+public:
+
+ // constructors
+ explicit sc_int_base(int w=sc_length_param().len()) :
+ m_val(0), m_len(w), m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ }
+
+ sc_int_base(int_type v, int w) :
+ m_val(v), m_len(w), m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ extend_sign();
+ }
+
+ sc_int_base(const sc_int_base &a) :
+ sc_value_base(a), m_val(a.m_val), m_len(a.m_len), m_ulen(a.m_ulen)
+ {}
+
+ explicit sc_int_base(const sc_int_subref_r &a) :
+ m_val(a), m_len(a.length()), m_ulen(SC_INTWIDTH - m_len)
+ {
+ extend_sign();
+ }
+
+ template< class T >
+ explicit sc_int_base(const sc_generic_base<T> &a) :
+ m_val(a->to_int64()), m_len(a->length()), m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ extend_sign();
+ }
+
+ explicit sc_int_base(const sc_signed &a);
+ explicit sc_int_base(const sc_unsigned &a);
+ explicit sc_int_base(const sc_bv_base &v);
+ explicit sc_int_base(const sc_lv_base &v);
+ explicit sc_int_base(const sc_uint_subref_r &v);
+ explicit sc_int_base(const sc_signed_subref_r &v);
+ explicit sc_int_base(const sc_unsigned_subref_r &v);
+
+
+ // destructor
+ virtual ~sc_int_base() {}
+
+ // assignment operators
+ sc_int_base &
+ operator = (int_type v)
+ {
+ m_val = v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (const sc_int_base &a)
+ {
+ m_val = a.m_val;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (const sc_int_subref_r &a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ template<class T>
+ sc_int_base &
+ operator = (const sc_generic_base<T> &a)
+ {
+ m_val = a->to_int64();
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &operator = (const sc_signed &a);
+ sc_int_base &operator = (const sc_unsigned &a);
+
+ sc_int_base &operator = (const sc_fxval &a);
+ sc_int_base &operator = (const sc_fxval_fast &a);
+ sc_int_base &operator = (const sc_fxnum &a);
+ sc_int_base &operator = (const sc_fxnum_fast &a);
+
+ sc_int_base &operator = (const sc_bv_base &a);
+ sc_int_base &operator = (const sc_lv_base &a);
+
+ sc_int_base &operator = (const char *a);
+
+ sc_int_base &
+ operator = (unsigned long a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (long a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (unsigned int a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (int a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (uint64 a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator = (double a)
+ {
+ m_val = (int_type)a;
+ extend_sign();
+ return *this;
+ }
+
+ // arithmetic assignment operators
+ sc_int_base &
+ operator += (int_type v)
+ {
+ m_val += v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator -= (int_type v)
+ {
+ m_val -= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator *= (int_type v)
+ {
+ m_val *= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator /= (int_type v)
+ {
+ m_val /= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator %= (int_type v)
+ {
+ m_val %= v;
+ extend_sign();
+ return *this;
+ }
+
+
+ // bitwise assignment operators
+ sc_int_base &
+ operator &= (int_type v)
+ {
+ m_val &= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator |= (int_type v)
+ {
+ m_val |= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator ^= (int_type v)
+ {
+ m_val ^= v;
+ extend_sign();
+ return *this;
+ }
+
+
+ sc_int_base &
+ operator <<= (int_type v)
+ {
+ m_val <<= v;
+ extend_sign();
+ return *this;
+ }
+
+ sc_int_base &
+ operator >>= (int_type v)
+ {
+ m_val >>= v;
+ /* no sign extension needed */
+ return *this;
+ }
+
+
+ // prefix and postfix increment and decrement operators
+ sc_int_base &
+ operator ++ () // prefix
+ {
+ ++m_val;
+ extend_sign();
+ return *this;
+ }
+
+ const sc_int_base
+ operator ++ (int) // postfix
+ {
+ sc_int_base tmp(*this);
+ ++m_val;
+ extend_sign();
+ return tmp;
+ }
+
+ sc_int_base &
+ operator -- () // prefix
+ {
+ --m_val;
+ extend_sign();
+ return *this;
+ }
+
+ const sc_int_base
+ operator -- ( int ) // postfix
+ {
+ sc_int_base tmp(*this);
+ --m_val;
+ extend_sign();
+ return tmp;
+ }
+
+
+ // relational operators
+ friend bool
+ operator == (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val == b.m_val;
+ }
+
+ friend bool
+ operator != (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val != b.m_val;
+ }
+
+ friend bool
+ operator < (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val < b.m_val;
+ }
+
+ friend bool
+ operator <= (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val <= b.m_val;
+ }
+
+ friend bool
+ operator > (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val > b.m_val;
+ }
+
+ friend bool
+ operator >= (const sc_int_base &a, const sc_int_base &b)
+ {
+ return a.m_val >= b.m_val;
+ }
+
+
+ // bit selection
+ sc_int_bitref &operator [] (int i);
+ const sc_int_bitref_r &operator [] (int i) const;
+
+ sc_int_bitref &bit(int i);
+ const sc_int_bitref_r &bit(int i) const;
+
+
+ // part selection
+ sc_int_subref &operator () (int left, int right);
+ const sc_int_subref_r &operator () (int left, int right) const;
+
+ sc_int_subref &range(int left, int right);
+ const sc_int_subref_r &range(int left, int right) const;
+
+
+ // bit access, without bounds checking or sign extension
+ bool test(int i) const { return (0 != (m_val & (UINT_ONE << i))); }
+
+ void set(int i) { m_val |= (UINT_ONE << i); }
+
+ void
+ set(int i, bool v)
+ {
+ v ? m_val |= (UINT_ONE << i) : m_val &= ~(UINT_ONE << i);
+ }
+
+ // capacity
+ int length() const { return m_len; }
+
+ // concatenation support
+ virtual int
+ concat_length(bool* xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return length();
+ }
+ virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
+ virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
+ virtual uint64
+ concat_get_uint64() const
+ {
+ if (m_len < 64)
+ return (uint64)(m_val & ~((uint_type) - 1 << m_len));
+ else
+ return (uint64)m_val;
+ }
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return !or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return !xor_reduce(); }
+
+
+ // implicit conversion to int_type
+ operator int_type() const { return m_val; }
+
+
+ // explicit conversions
+ int_type value() const { return operator int_type(); }
+ int to_int() const { return (int)m_val; }
+ unsigned int to_uint() const { return (unsigned int)m_val; }
+ long to_long() const { return (long)m_val; }
+ unsigned long to_ulong() const { return (unsigned long)m_val; }
+ int64 to_int64() const { return (int64)m_val; }
+ uint64 to_uint64() const { return (uint64)m_val; }
+ double to_double() const { return (double)m_val; }
+ long long_low() const { return (long)(m_val & UINT64_32ONES); }
+ long long_high() const { return (long)((m_val >> 32) & UINT64_32ONES); }
+
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ int_type m_val; // value
+ int m_len; // length
+ int m_ulen; // unused length
+};
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_int_base &);
+inline ::std::istream &operator >> (::std::istream &, sc_int_base &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_bitref_r
+//
+// Proxy class for sc_int bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// implicit conversion to uint64
+
+inline sc_int_bitref_r::operator uint64 () const
+{
+ return m_obj_p->test(m_index);
+}
+
+inline bool
+sc_int_bitref_r::operator ! () const
+{
+ return ! m_obj_p->test(m_index);
+}
+
+inline bool
+sc_int_bitref_r::operator ~ () const
+{
+ return !m_obj_p->test(m_index);
+}
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_int_bitref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_bitref
+//
+// Proxy class for sc_int bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline sc_int_bitref &
+sc_int_bitref::operator = (const sc_int_bitref_r &b)
+{
+ m_obj_p->set(m_index, (bool)b);
+ m_obj_p->extend_sign();
+ return *this;
+}
+
+inline sc_int_bitref &
+sc_int_bitref::operator = (const sc_int_bitref &b)
+{
+ m_obj_p->set(m_index, (bool)b);
+ m_obj_p->extend_sign();
+ return *this;
+}
+
+inline sc_int_bitref &
+sc_int_bitref::operator = (bool b)
+{
+ m_obj_p->set(m_index, b);
+ m_obj_p->extend_sign();
+ return *this;
+}
+
+
+inline sc_int_bitref &
+sc_int_bitref::operator &= (bool b)
+{
+ if (!b) {
+ m_obj_p->set(m_index, b);
+ m_obj_p->extend_sign();
+ }
+ return *this;
+}
+
+inline sc_int_bitref &
+sc_int_bitref::operator |= (bool b)
+{
+ if (b) {
+ m_obj_p->set(m_index, b);
+ m_obj_p->extend_sign();
+ }
+ return *this;
+}
+
+inline sc_int_bitref &
+sc_int_bitref::operator ^= (bool b)
+{
+ if (b) {
+ m_obj_p->m_val ^= (UINT_ONE << m_index);
+ m_obj_p->extend_sign();
+ }
+ return *this;
+}
+
+
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_int_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_subref_r
+//
+// Proxy class for sc_int part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// implicit conversion to int_type
+
+inline sc_int_subref_r::operator uint_type() const
+{
+ uint_type /*int_type*/ val = m_obj_p->m_val;
+ int uleft = SC_INTWIDTH - (m_left + 1);
+ int uright = uleft + m_right;
+ return (val << uleft >> uright);
+}
+
+
+// reduce methods
+
+inline bool
+sc_int_subref_r::and_reduce() const
+{
+ sc_int_base a(*this);
+ return a.and_reduce();
+}
+
+inline bool
+sc_int_subref_r::or_reduce() const
+{
+ sc_int_base a(*this);
+ return a.or_reduce();
+}
+
+inline bool
+sc_int_subref_r::xor_reduce() const
+{
+ sc_int_base a(*this);
+ return a.xor_reduce();
+}
+
+
+// explicit conversions
+
+inline int
+sc_int_subref_r::to_int() const
+{
+ int result = static_cast<int>(operator uint_type());
+ return result;
+}
+
+inline unsigned int
+sc_int_subref_r::to_uint() const
+{
+ unsigned int result = static_cast<unsigned int>(operator uint_type());
+ return result;
+}
+
+inline long
+sc_int_subref_r::to_long() const
+{
+ long result = static_cast<long>(operator uint_type());
+ return result;
+}
+
+inline unsigned long
+sc_int_subref_r::to_ulong() const
+{
+ unsigned long result = static_cast<unsigned long>(operator uint_type());
+ return result;
+}
+
+inline int64
+sc_int_subref_r::to_int64() const
+{
+ int64 result = operator uint_type();
+ return result;
+}
+
+inline uint64
+sc_int_subref_r::to_uint64() const
+{
+ uint64 result = operator uint_type();
+ return result;
+}
+
+inline double
+sc_int_subref_r::to_double() const
+{
+ double result = static_cast<double>(operator uint_type());
+ return result;
+}
+
+
+// explicit conversion to character string
+
+inline const std::string
+sc_int_subref_r::to_string(sc_numrep numrep) const
+{
+ sc_uint_base a(length());
+ a = operator uint_type();
+ return a.to_string(numrep);
+}
+
+inline const std::string
+sc_int_subref_r::to_string(sc_numrep numrep, bool w_prefix) const
+{
+ sc_uint_base a(length());
+ a = operator uint_type();
+ return a.to_string(numrep, w_prefix);
+}
+
+
+// functional notation for the reduce methods
+
+inline bool
+and_reduce(const sc_int_subref_r &a)
+{
+ return a.and_reduce();
+}
+
+inline bool
+nand_reduce(const sc_int_subref_r &a)
+{
+ return a.nand_reduce();
+}
+
+inline bool
+or_reduce(const sc_int_subref_r &a)
+{
+ return a.or_reduce();
+}
+
+inline bool
+nor_reduce(const sc_int_subref_r &a)
+{
+ return a.nor_reduce();
+}
+
+inline bool
+xor_reduce(const sc_int_subref_r &a)
+{
+ return a.xor_reduce();
+}
+
+inline bool
+xnor_reduce(const sc_int_subref_r &a)
+{
+ return a.xnor_reduce();
+}
+
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_int_subref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_subref
+//
+// Proxy class for sc_int part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline sc_int_subref &
+sc_int_subref::operator = (const sc_int_base &a)
+{
+ return operator = (a.operator int_type());
+}
+
+inline sc_int_subref &
+sc_int_subref::operator = (const char *a)
+{
+ sc_int_base aa(length());
+ return (*this = aa = a);
+}
+
+
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_int_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_int_base
+//
+// Base class for sc_int.
+// ----------------------------------------------------------------------------
+
+// bit selection
+
+inline sc_int_bitref &
+sc_int_base::operator [] (int i)
+{
+ check_index(i);
+ sc_int_bitref *result_p = sc_int_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+inline const sc_int_bitref_r &
+sc_int_base::operator [] (int i) const
+{
+ check_index(i);
+ sc_int_bitref *result_p = sc_int_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+
+inline sc_int_bitref &
+sc_int_base::bit(int i)
+{
+ check_index(i);
+ sc_int_bitref *result_p = sc_int_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+inline const sc_int_bitref_r &
+sc_int_base::bit(int i) const
+{
+ check_index(i);
+ sc_int_bitref *result_p = sc_int_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+
+// part selection
+
+inline sc_int_subref &
+sc_int_base::operator () (int left, int right)
+{
+ check_range(left, right);
+ sc_int_subref *result_p = sc_int_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+inline const sc_int_subref_r &
+sc_int_base::operator () (int left, int right) const
+{
+ check_range(left, right);
+ sc_int_subref *result_p = sc_int_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+
+inline sc_int_subref &
+sc_int_base::range(int left, int right)
+{
+ check_range(left, right);
+ sc_int_subref *result_p = sc_int_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+inline const sc_int_subref_r &
+sc_int_base::range(int left, int right) const
+{
+ check_range(left, right);
+ sc_int_subref *result_p = sc_int_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+
+// functional notation for the reduce methods
+
+inline bool
+and_reduce(const sc_int_base &a)
+{
+ return a.and_reduce();
+}
+
+inline bool
+nand_reduce(const sc_int_base &a)
+{
+ return a.nand_reduce();
+}
+
+inline bool
+or_reduce(const sc_int_base &a)
+{
+ return a.or_reduce();
+}
+
+inline bool
+nor_reduce(const sc_int_base &a)
+{
+ return a.nor_reduce();
+}
+
+inline bool
+xor_reduce(const sc_int_base &a)
+{
+ return a.xor_reduce();
+}
+
+inline bool
+xnor_reduce(const sc_int_base &a)
+{
+ return a.xnor_reduce();
+}
+
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_int_base &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_int_base &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_INT_BASE_HH__
diff --git a/src/systemc/ext/dt/int/sc_length_param.hh b/src/systemc/ext/dt/int/sc_length_param.hh
new file mode 100644
index 000000000..2321cbc78
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_length_param.hh
@@ -0,0 +1,192 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_length_param.h -
+
+ Original Author: Martin Janssen, Synopsys, Inc., 2002-03-19
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_length_param.h,v $
+// Revision 1.3 2011/08/24 22:05:46 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.4 2006/05/08 17:50:01 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
+
+#include <iostream>
+
+#include "../fx/sc_context.hh"
+#include "../fx/sc_fxdefs.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_length_param;
+
+// friend operator declarations
+bool operator == (const sc_length_param &, const sc_length_param &);
+bool operator != (const sc_length_param &, const sc_length_param &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_length_param
+//
+// Length parameter type.
+// ----------------------------------------------------------------------------
+
+class sc_length_param
+{
+ public:
+ sc_length_param();
+ sc_length_param(int);
+ sc_length_param(const sc_length_param &);
+ explicit sc_length_param(sc_without_context);
+
+ sc_length_param &operator = (const sc_length_param &);
+
+ friend bool operator == (const sc_length_param &, const sc_length_param &);
+ friend bool operator != (const sc_length_param &, const sc_length_param &);
+
+ int len() const;
+ void len(int);
+
+ const std::string to_string() const;
+
+ void print(::std::ostream & =::std::cout) const;
+ void dump(::std::ostream & =::std::cout) const;
+
+ private:
+ int m_len;
+};
+
+} // namespace sc_dt
+
+// ----------------------------------------------------------------------------
+// TYPEDEF : sc_length_context
+//
+// Context type for the length parameter type.
+// ----------------------------------------------------------------------------
+
+namespace sc_dt
+{
+
+extern template class sc_global<sc_length_param>;
+extern template class sc_context<sc_length_param>;
+
+typedef sc_context<sc_length_param> sc_length_context;
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+inline sc_length_param::sc_length_param() : m_len()
+{
+ *this = sc_length_context::default_value();
+}
+
+inline sc_length_param::sc_length_param(int len_) : m_len(len_)
+{
+ SC_CHECK_WL_(len_);
+}
+
+inline sc_length_param::sc_length_param(const sc_length_param &a) :
+ m_len(a.m_len)
+{}
+
+inline sc_length_param::sc_length_param(sc_without_context) :
+ m_len(SC_DEFAULT_WL_)
+{}
+
+
+inline sc_length_param &
+sc_length_param::operator = (const sc_length_param &a)
+{
+ if (&a != this) {
+ m_len = a.m_len;
+ }
+ return *this;
+}
+
+
+inline bool
+operator == (const sc_length_param &a, const sc_length_param &b)
+{
+ return (a.m_len == b.m_len);
+}
+
+inline bool
+operator != (const sc_length_param &a, const sc_length_param &b)
+{
+ return (a.m_len != b.m_len);
+}
+
+
+inline int
+sc_length_param::len() const
+{
+ return m_len;
+}
+
+inline void
+sc_length_param::len(int len_)
+{
+ SC_CHECK_WL_(len_);
+ m_len = len_;
+}
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_length_param &a)
+{
+ a.print(os);
+ return os;
+}
+
+} // namespace sc_dt
+
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_LENGTH_PARAM_HH__
diff --git a/src/systemc/ext/dt/int/sc_nbdefs.hh b/src/systemc/ext/dt/int/sc_nbdefs.hh
index 48d735adf..3854a9198 100644
--- a/src/systemc/ext/dt/int/sc_nbdefs.hh
+++ b/src/systemc/ext/dt/int/sc_nbdefs.hh
@@ -18,12 +18,52 @@
*****************************************************************************/
/*****************************************************************************
+
sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned
arithmetic. This file defines all the constants needed.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Torsten Maehne, Berner Fachhochschule,
+ 2016-09-24
+ Description of Modification: Move constant definitions to the header so that
+ that their value is known at compile time.
+
*****************************************************************************/
-#ifndef __SYSTEMC_DT_SC_NBDEFS_H__
-#define __SYSTEMC_DT_SC_NBDEFS_H__
+// $Log: sc_nbdefs.h,v $
+// Revision 1.7 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.6 2011/02/18 20:09:34 acg
+// Philipp A. Hartmann: added alternative #define for Windows to guard.
+//
+// Revision 1.5 2011/01/20 16:52:20 acg
+// Andy Goodrich: changes for IEEE 1666 2011.
+//
+// Revision 1.4 2010/02/08 18:35:55 acg
+// Andy Goodrich: Philipp Hartmann's changes for Solaris and Linux 64.
+//
+// Revision 1.2 2009/05/22 16:06:29 acg
+// Andy Goodrich: process control updates.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__
#include <stdint.h>
@@ -77,8 +117,8 @@ typedef int small_type;
#define LOG2_BITS_PER_BYTE 3
// Attributes of the unsigned long. These definitions are used mainly in
-// the functions that are aware of the internal representation of digits,
-// e.g., get/set_packed_rep().
+// the functions that are aware of the internal representation of
+// digits, e.g., get/set_packed_rep().
#define BYTES_PER_DIGIT_TYPE 4
#define BITS_PER_DIGIT_TYPE 32
@@ -120,35 +160,41 @@ static const int MAX_NDIGITS = DIV_CEIL(SC_MAX_NBITS) + 2;
// since the unsigned long data type varies in size between 32-bit and 64-bit
// machines.
-typedef unsigned int sc_digit; // 32-bit unsigned integer
+typedef unsigned int sc_digit; // 32-bit unsigned integer
// Support for the long long type. This type is not in the standard
// but is usually supported by compilers.
+#if defined(__x86_64__) || defined(__aarch64__)
+typedef long long int64;
+typedef unsigned long long uint64;
+#else
typedef int64_t int64;
typedef uint64_t uint64;
+#endif
-static const uint64 UINT64_ZERO = 0ULL;
-static const uint64 UINT64_ONE = 1ULL;
+static const uint64 UINT64_ZERO = 0ULL;
+static const uint64 UINT64_ONE = 1ULL;
static const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
+
// Bits per ...
// will be deleted in the future. Use numeric_limits instead
-#define BITS_PER_CHAR 8
-#define BITS_PER_INT (sizeof(int) * BITS_PER_CHAR)
-#define BITS_PER_LONG (sizeof(long) * BITS_PER_CHAR)
-#define BITS_PER_INT64 (sizeof(::sc_dt::int64) * BITS_PER_CHAR)
-#define BITS_PER_UINT (sizeof(unsigned int) * BITS_PER_CHAR)
-#define BITS_PER_ULONG (sizeof(unsigned long) * BITS_PER_CHAR)
+#define BITS_PER_CHAR 8
+#define BITS_PER_INT (sizeof(int) * BITS_PER_CHAR)
+#define BITS_PER_LONG (sizeof(long) * BITS_PER_CHAR)
+#define BITS_PER_INT64 (sizeof(::sc_dt::int64) * BITS_PER_CHAR)
+#define BITS_PER_UINT (sizeof(unsigned int) * BITS_PER_CHAR)
+#define BITS_PER_ULONG (sizeof(unsigned long) * BITS_PER_CHAR)
#define BITS_PER_UINT64 (sizeof(::sc_dt::uint64) * BITS_PER_CHAR)
// Digits per ...
-#define DIGITS_PER_CHAR 1
-#define DIGITS_PER_INT ((BITS_PER_INT+29)/30)
-#define DIGITS_PER_LONG ((BITS_PER_LONG+29)/30)
-#define DIGITS_PER_INT64 ((BITS_PER_INT64+29)/30)
-#define DIGITS_PER_UINT ((BITS_PER_UINT+29)/30)
-#define DIGITS_PER_ULONG ((BITS_PER_ULONG+29)/30)
-#define DIGITS_PER_UINT64 ((BITS_PER_UINT64+29)/30)
+#define DIGITS_PER_CHAR 1
+#define DIGITS_PER_INT ((BITS_PER_INT + 29) / 30)
+#define DIGITS_PER_LONG ((BITS_PER_LONG + 29) / 30)
+#define DIGITS_PER_INT64 ((BITS_PER_INT64 + 29) / 30)
+#define DIGITS_PER_UINT ((BITS_PER_UINT + 29) / 30)
+#define DIGITS_PER_ULONG ((BITS_PER_ULONG + 29) / 30)
+#define DIGITS_PER_UINT64 ((BITS_PER_UINT64 + 29) / 30)
// Above, BITS_PER_X is mainly used for sc_signed, and BITS_PER_UX is
// mainly used for sc_unsigned.
@@ -165,4 +211,4 @@ static const uint64 UINT_ONE = UINT64_ONE;
} // namespace sc_dt
-#endif
+#endif // __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__
diff --git a/src/systemc/ext/dt/int/sc_nbexterns.hh b/src/systemc/ext/dt/int/sc_nbexterns.hh
new file mode 100644
index 000000000..942b52194
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_nbexterns.hh
@@ -0,0 +1,108 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_nbexterns.h -- External functions for both sc_signed and sc_unsigned
+ classes. These functions work on two parameters u and
+ v, and copy the result to the first parameter u. This
+ is also the reason that they are suffixed with _on_help.
+
+ The vec_* functions are called through either these
+ functions or those in sc_nbfriends.cpp. The functions in
+ sc_nbfriends.cpp perform their work on two inputs u and v,
+ and return the result object.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_nbexterns.h,v $
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_NBEXTERNS_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_NBEXTERNS_HH__
+
+#include "sc_nbutils.hh"
+
+namespace sc_dt
+{
+
+extern void add_on_help(
+ small_type &us, int unb, int und, sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+extern void mul_on_help_signed(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+void div_on_help_signed(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+extern void mod_on_help_signed(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+extern void mul_on_help_unsigned(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+void div_on_help_unsigned(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+extern void mod_on_help_unsigned(
+ small_type &us, int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+extern void and_on_help(
+ small_type us, int unb, int und, sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+extern void or_on_help(
+ small_type us, int unb, int und, sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+extern void xor_on_help(
+ small_type us, int unb, int und, sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_NBEXTERNS_HH__
diff --git a/src/systemc/ext/dt/int/sc_nbutils.hh b/src/systemc/ext/dt/int/sc_nbutils.hh
new file mode 100644
index 000000000..9f7269e8c
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_nbutils.hh
@@ -0,0 +1,832 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_nbutils.h -- External and friend functions for both sc_signed and
+ sc_unsigned classes.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_nbutils.h,v $
+// Revision 1.6 2011/09/08 16:12:15 acg
+// Philipp A. Hartmann: fix issue with Sun machines wrt real math libraries.
+//
+// Revision 1.5 2011/08/26 23:00:01 acg
+// Torsten Maehne: remove use of ieeefp.h.
+//
+// Revision 1.4 2011/08/15 16:43:24 acg
+// Torsten Maehne: changes to remove unused argument warnings.
+//
+// Revision 1.3 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.2 2010/09/06 16:35:48 acg
+// Andy Goodrich: changed i386 to __i386__ in ifdef's.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_NBUTILS_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_NBUTILS_HH__
+
+#include <cmath>
+#include <ios>
+#include <limits>
+#include <ostream>
+
+#include "../../utils/sc_report_handler.hh"
+#include "sc_nbdefs.hh"
+
+namespace sc_dt
+{
+
+//-----------------------------------------------------------------------------
+//"sc_io_base"
+//
+// This inline function returns the type of an i/o stream's base as a SystemC
+// base designator.
+// stream_object = reference to the i/o stream whose base is to be returned.
+//
+//"sc_io_show_base"
+//
+// This inline function returns true if the base should be shown when a SystemC
+// value is displayed via the supplied stream operator.
+// stream_object = reference to the i/o stream to return showbase value for.
+//-----------------------------------------------------------------------------
+inline sc_numrep
+sc_io_base(::std::ostream &os, sc_numrep def_base)
+{
+ std::ios::fmtflags flags = os.flags() & std::ios::basefield;
+ if (flags & ::std::ios::dec) return SC_DEC;
+ if (flags & ::std::ios::hex) return SC_HEX;
+ if (flags & ::std::ios::oct) return SC_OCT;
+ return def_base;
+}
+
+inline bool
+sc_io_show_base(::std::ostream &os)
+{
+ return (os.flags() & ::std::ios::showbase) != 0;
+}
+
+const std::string to_string(sc_numrep);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, sc_numrep numrep)
+{
+ os << to_string(numrep);
+ return os;
+}
+
+// ----------------------------------------------------------------------------
+
+// One transition of the FSM to find base and sign of a number.
+extern small_type fsm_move(
+ char c, small_type &b, small_type &s, small_type &state);
+
+// Parse a character string into its equivalent binary bits.
+extern void parse_binary_bits(
+ const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p=0);
+
+// Parse a character string into its equivalent hexadecimal bits.
+extern void parse_hex_bits(
+ const char *src_p, int dst_n, sc_digit *data_p, sc_digit *ctrl_p=0);
+
+// Find the base and sign of a number in v.
+extern const char *get_base_and_sign(
+ const char *v, small_type &base, small_type &sign);
+
+// Create a number out of v in base.
+extern small_type
+vec_from_str(int unb, int und, sc_digit *u,
+ const char *v, sc_numrep base=SC_NOBASE);
+
+
+// ----------------------------------------------------------------------------
+// Naming convention for the vec_ functions below:
+// vec_OP(u, v, w) : computes w = u OP v.
+// vec_OP_on(u, v) : computes u = u OP v if u has more digits than v.
+// vec_OP_on2(u, v) : computes u = u OP v if u has fewer digits than v.
+// _large : parameters are vectors.
+// _small : one of the parameters is a single digit.
+// Xlen : the number of digits in X.
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// Functions for vector addition: w = u + v or u += v.
+// ----------------------------------------------------------------------------
+
+extern void vec_add(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v, sc_digit *w);
+extern void vec_add_on(int ulen, sc_digit *u, int vlen, const sc_digit *v);
+extern void vec_add_on2(int ulen, sc_digit *u, int vlen, const sc_digit *v);
+extern void vec_add_small(int ulen, const sc_digit *u,
+ sc_digit v, sc_digit *w);
+extern void vec_add_small_on(int ulen, sc_digit *u, sc_digit v);
+
+// ----------------------------------------------------------------------------
+// Functions for vector subtraction: w = u - v, u -= v, or u = v - u.
+// ----------------------------------------------------------------------------
+
+extern void vec_sub(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v, sc_digit *w);
+extern void vec_sub_on(int ulen, sc_digit *u, int vlen, const sc_digit *v);
+extern void vec_sub_on2(int ulen, sc_digit *u, int vlen, const sc_digit *v);
+extern void vec_sub_small(int ulen, const sc_digit *u,
+ sc_digit v, sc_digit *w);
+extern void vec_sub_small_on(int ulen, sc_digit *u, sc_digit v);
+
+
+// ----------------------------------------------------------------------------
+// Functions for vector multiplication: w = u * v or u *= v.
+// ----------------------------------------------------------------------------
+
+extern void vec_mul(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v, sc_digit *w);
+extern void vec_mul_small(int ulen, const sc_digit *u,
+ sc_digit v, sc_digit *w);
+extern void vec_mul_small_on(int ulen, sc_digit *u, sc_digit v);
+
+
+// ----------------------------------------------------------------------------
+// Functions for vector division: w = u / v.
+// ----------------------------------------------------------------------------
+
+extern void vec_div_large(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v, sc_digit *w);
+extern void vec_div_small(int ulen, const sc_digit *u,
+ sc_digit v, sc_digit *w);
+
+
+// ----------------------------------------------------------------------------
+// Functions for vector remainder: w = u % v or u %= v.
+// ----------------------------------------------------------------------------
+
+extern void vec_rem_large(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v, sc_digit *w);
+extern sc_digit vec_rem_small(int ulen, const sc_digit *u, sc_digit v);
+extern sc_digit vec_rem_on_small(int ulen, sc_digit *u, sc_digit v);
+
+
+// ----------------------------------------------------------------------------
+// Functions to convert between vectors of char and sc_digit.
+// ----------------------------------------------------------------------------
+
+extern int vec_to_char(int ulen, const sc_digit *u, int vlen, uchar *v);
+extern void vec_from_char(int ulen, const uchar *u, int vlen, sc_digit *v);
+
+
+// ----------------------------------------------------------------------------
+// Functions to shift left or right, or to create a mirror image of vectors.
+// ----------------------------------------------------------------------------
+
+extern void vec_shift_left(int ulen, sc_digit *u, int nsl);
+extern void vec_shift_right(int vlen, sc_digit *u, int nsr, sc_digit fill=0);
+extern void vec_reverse(int unb, int und, sc_digit *ud, int l, int r=0);
+
+
+// ----------------------------------------------------------------------------
+// Various utility functions.
+// ----------------------------------------------------------------------------
+
+// Return the low half part of d.
+inline sc_digit low_half(sc_digit d) { return (d & HALF_DIGIT_MASK); }
+
+// Return the high half part of d. The high part of the digit may have
+// more bits than BITS_PER_HALF_DIGIT due to, e.g., overflow in the
+// multiplication. Hence, in other functions that use high_half(),
+// make sure that the result contains BITS_PER_HALF_DIGIT if
+// necessary. This is done by high_half_masked().
+inline sc_digit high_half(sc_digit d) { return (d >> BITS_PER_HALF_DIGIT); }
+inline sc_digit
+high_half_masked(sc_digit d)
+{
+ return (high_half(d) & HALF_DIGIT_MASK);
+}
+
+// Concatenate the high part h and low part l. Assumes that h and l
+// are less than or equal to HALF_DIGIT_MASK;
+inline sc_digit
+concat(sc_digit h, sc_digit l)
+{
+ return ((h << BITS_PER_HALF_DIGIT) | l);
+}
+
+// Create a number with n 1's.
+inline sc_digit
+one_and_ones(int n)
+{
+ return (((sc_digit) 1 << n) - 1);
+}
+
+// Create a number with one 1 and n 0's.
+inline sc_digit one_and_zeros(int n) { return ((sc_digit) 1 << n); }
+
+
+// ----------------------------------------------------------------------------
+
+// Find the digit that bit i is in.
+inline int digit_ord(int i) { return (i / BITS_PER_DIGIT); }
+
+// Find the bit in digit_ord(i) that bit i corressponds to.
+inline int bit_ord(int i) { return (i % BITS_PER_DIGIT); }
+
+
+// ----------------------------------------------------------------------------
+// Functions to compare, zero, complement vector(s).
+// ----------------------------------------------------------------------------
+
+// Compare u and v and return r
+// r = 0 if u == v
+// r < 0 if u < v
+// r > 0 if u > v
+// - Assume that all the leading zero digits are already skipped.
+// - ulen and/or vlen can be zero.
+// - Every digit is less than or equal to DIGIT_MASK;
+inline int
+vec_cmp(int ulen, const sc_digit *u,
+ int vlen, const sc_digit *v)
+{
+
+#ifdef DEBUG_SYSTEMC
+ // sc_assert((ulen <= 0) || (u != NULL));
+ // sc_assert((vlen <= 0) || (v != NULL));
+
+ // ulen and vlen can be equal to 0 because vec_cmp can be called
+ // after vec_skip_leading_zeros.
+ sc_assert((ulen >= 0) && (u != NULL));
+ sc_assert((vlen >= 0) && (v != NULL));
+ // If ulen > 0, then the leading digit of u must be non-zero.
+ sc_assert((ulen <= 0) || (u[ulen - 1] != 0));
+ sc_assert((vlen <= 0) || (v[vlen - 1] != 0));
+#endif
+
+ if (ulen != vlen)
+ return (ulen - vlen);
+
+ // ulen == vlen >= 1
+ while ((--ulen >= 0) && (u[ulen] == v[ulen]))
+ {}
+
+ if (ulen < 0)
+ return 0;
+
+#ifdef DEBUG_SYSTEMC
+ // Test to see if the result is wrong due to the presence of
+ // overflow bits.
+ sc_assert((u[ulen] & DIGIT_MASK) != (v[ulen] & DIGIT_MASK));
+#endif
+
+ return (int)(u[ulen] - v[ulen]);
+}
+
+// Find the index of the first non-zero digit.
+// - ulen (before) = the number of digits in u.
+// - the returned value = the index of the first non-zero digit.
+// A negative value of -1 indicates that every digit in u is zero.
+inline int
+vec_find_first_nonzero(int ulen, const sc_digit *u)
+{
+
+#ifdef DEBUG_SYSTEMC
+ // sc_assert((ulen <= 0) || (u != NULL));
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+
+ while ((--ulen >= 0) && (! u[ulen]))
+ {}
+
+ return ulen;
+}
+
+// Skip all the leading zero digits.
+// - ulen (before) = the number of digits in u.
+// - the returned value = the number of non-zero digits in u.
+// - the returned value is non-negative.
+inline int
+vec_skip_leading_zeros(int ulen, const sc_digit *u)
+{
+#ifdef DEBUG_SYSTEMC
+ // sc_assert((ulen <= 0) || (u != NULL));
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+
+ return (1 + vec_find_first_nonzero(ulen, u));
+}
+
+// Compare u and v and return r
+// r = 0 if u == v
+// r < 0 if u < v
+// r > 0 if u > v
+inline int
+vec_skip_and_cmp(int ulen, const sc_digit *u, int vlen, const sc_digit *v)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((ulen > 0) && (u != NULL));
+ sc_assert((vlen > 0) && (v != NULL));
+#endif
+
+ ulen = vec_skip_leading_zeros(ulen, u);
+ vlen = vec_skip_leading_zeros(vlen, v);
+ // ulen and/or vlen can be equal to zero here.
+ return vec_cmp(ulen, u, vlen, v);
+}
+
+// Set u[i] = 0 where i = from ... (ulen - 1).
+inline void
+vec_zero(int from, int ulen, sc_digit *u)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+ for (int i = from; i < ulen; i++)
+ u[i] = 0;
+}
+
+// Set u[i] = 0 where i = 0 .. (ulen - 1).
+inline void vec_zero(int ulen, sc_digit *u) { vec_zero(0, ulen, u); }
+
+// Copy n digits from v to u.
+inline void
+vec_copy(int n, sc_digit *u, const sc_digit *v)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((n > 0) && (u != NULL) && (v != NULL));
+#endif
+ for (int i = 0; i < n; ++i)
+ u[i] = v[i];
+}
+
+// Copy v to u, where ulen >= vlen, and zero the rest of the digits in u.
+inline void
+vec_copy_and_zero(int ulen, sc_digit *u, int vlen, const sc_digit *v)
+{
+
+#ifdef DEBUG_SYSTEMC
+ sc_assert((ulen > 0) && (u != NULL));
+ sc_assert((vlen > 0) && (v != NULL));
+ sc_assert(ulen >= vlen);
+#endif
+ vec_copy(vlen, u, v);
+ vec_zero(vlen, ulen, u);
+
+}
+
+// 2's-complement the digits in u.
+inline void
+vec_complement(int ulen, sc_digit *u)
+{
+
+#ifdef DEBUG_SYSTEMC
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+
+ sc_digit carry = 1;
+
+ for (int i = 0; i < ulen; ++i) {
+ carry += (~u[i] & DIGIT_MASK);
+ u[i] = carry & DIGIT_MASK;
+ carry >>= BITS_PER_DIGIT;
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to handle built-in types or signs.
+// ----------------------------------------------------------------------------
+
+// u = v
+// - v is an unsigned long or uint64, and positive integer.
+template<class Type>
+inline void
+from_uint(int ulen, sc_digit *u, Type v)
+{
+#ifdef DEBUG_SYSTEMC
+ // sc_assert((ulen <= 0) || (u != NULL));
+ sc_assert((ulen > 0) && (u != NULL));
+ sc_assert(v >= 0);
+#endif
+
+ int i = 0;
+
+ while (v && (i < ulen)) {
+ u[i++] = static_cast<sc_digit>(v & DIGIT_MASK);
+ v >>= BITS_PER_DIGIT;
+ }
+ vec_zero(i, ulen, u);
+}
+
+#ifndef __GNUC__
+# define SC_LIKELY_(x) !!(x)
+#else
+# define SC_LIKELY_(x) __builtin_expect(!!(x), 1)
+#endif
+
+// Get u's sign and return its absolute value.
+// u can be long, unsigned long, int64, or uint64.
+template<class Type>
+inline small_type
+get_sign(Type &u)
+{
+ if (u > 0)
+ return SC_POS;
+
+ if (u == 0)
+ return SC_ZERO;
+
+ // no positive number representable for minimum value,
+ // leave as is to avoid Undefined Behaviour
+ if (SC_LIKELY_(u > (std::numeric_limits<Type>::min)()))
+ u = -u;
+
+ return SC_NEG;
+}
+
+#undef SC_LIKELY_
+
+
+// Return us * vs:
+// - Return SC_ZERO if either sign is SC_ZERO.
+// - Return SC_POS if us == vs
+// - Return SC_NEG if us != vs.
+inline small_type
+mul_signs(small_type us, small_type vs)
+{
+ if ((us == SC_ZERO) || (vs == SC_ZERO))
+ return SC_ZERO;
+
+ if (us == vs)
+ return SC_POS;
+
+ return SC_NEG;
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to test for errors and print out error messages.
+// ----------------------------------------------------------------------------
+
+#ifdef SC_MAX_NBITS
+
+void test_bound_failed(int nb);
+
+inline void
+test_bound(int nb)
+{
+ if (nb > SC_MAX_NBITS) {
+ test_bound_failed(nb);
+ sc_core::sc_abort(); // can't recover from here
+ }
+}
+
+#endif
+
+template<class Type>
+inline void
+div_by_zero(Type s)
+{
+ if (s == 0) {
+ SC_REPORT_ERROR("operation failed",
+ "div_by_zero<Type>(Type) : division by zero");
+ sc_core::sc_abort(); // can't recover from here
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to check if a given vector is zero or make one.
+// ----------------------------------------------------------------------------
+
+// If u[i] is zero for every i = 0,..., ulen - 1, return SC_ZERO,
+// else return s.
+inline small_type
+check_for_zero(small_type s, int ulen, const sc_digit *u)
+{
+
+#ifdef DEBUG_SYSTEMC
+ // sc_assert(ulen >= 0);
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+
+ if (vec_find_first_nonzero(ulen, u) < 0)
+ return SC_ZERO;
+
+ return s;
+}
+
+// If u[i] is zero for every i = 0,..., ulen - 1, return true,
+// else return false.
+inline bool
+check_for_zero(int ulen, const sc_digit *u)
+{
+
+#ifdef DEBUG_SYSTEMC
+ // sc_assert(ulen >= 0);
+ sc_assert((ulen > 0) && (u != NULL));
+#endif
+
+ if (vec_find_first_nonzero(ulen, u) < 0)
+ return true;
+
+ return false;
+}
+
+inline small_type
+make_zero(int nd, sc_digit *d)
+{
+ vec_zero(nd, d);
+ return SC_ZERO;
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions for both signed and unsigned numbers to convert sign-magnitude
+// (SM) and 2's complement (2C) representations.
+// added = 1 => for signed.
+// added = 0 => for unsigned.
+// IF_SC_SIGNED can be used as 'added'.
+// ----------------------------------------------------------------------------
+
+// Trim the extra leading bits of a signed or unsigned number.
+inline void
+trim(small_type added, int nb, int nd, sc_digit *d)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((nb > 0) && (nd > 0) && (d != NULL));
+#endif
+ d[nd - 1] &= one_and_ones(bit_ord(nb - 1) + added);
+}
+
+// Convert an (un)signed number from sign-magnitude representation to
+// 2's complement representation and trim the extra bits.
+inline void
+convert_SM_to_2C_trimmed(small_type added,
+ small_type s, int nb, int nd, sc_digit *d)
+{
+ if (s == SC_NEG) {
+ vec_complement(nd, d);
+ trim(added, nb, nd, d);
+ }
+}
+
+// Convert an (un)signed number from sign-magnitude representation to
+// 2's complement representation but do not trim the extra bits.
+inline void
+convert_SM_to_2C(small_type s, int nd, sc_digit *d)
+{
+ if (s == SC_NEG)
+ vec_complement(nd, d);
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to convert between sign-magnitude (SM) and 2's complement
+// (2C) representations of signed numbers.
+// ----------------------------------------------------------------------------
+
+// Trim the extra leading bits off a signed number.
+inline void
+trim_signed(int nb, int nd, sc_digit *d)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((nb > 0) && (nd > 0) && (d != NULL));
+#endif
+ d[nd - 1] &= one_and_ones(bit_ord(nb - 1) + 1);
+}
+
+// Convert a signed number from 2's complement representation to
+// sign-magnitude representation, and return its sign. nd is d's
+// actual size, without zeros eliminated.
+inline small_type
+convert_signed_2C_to_SM(int nb, int nd, sc_digit *d)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((nb > 0) && (nd > 0) && (d != NULL));
+#endif
+
+ small_type s;
+
+ int xnb = bit_ord(nb - 1) + 1;
+
+ // Test the sign bit.
+ if (d[nd - 1] & one_and_zeros(xnb - 1)) {
+ s = SC_NEG;
+ vec_complement(nd, d);
+ } else {
+ s = SC_POS;
+ }
+
+ // Trim the last digit.
+ d[nd - 1] &= one_and_ones(xnb);
+
+ // Check if the new number is zero.
+ if (s == SC_POS)
+ return check_for_zero(s, nd, d);
+
+ return s;
+}
+
+// Convert a signed number from sign-magnitude representation to 2's
+// complement representation, get its sign, convert back to
+// sign-magnitude representation, and return its sign. nd is d's
+// actual size, without zeros eliminated.
+inline small_type
+convert_signed_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
+{
+ convert_SM_to_2C(s, nd, d);
+ return convert_signed_2C_to_SM(nb, nd, d);
+}
+
+// Convert a signed number from sign-magnitude representation to 2's
+// complement representation and trim the extra bits.
+inline void
+convert_signed_SM_to_2C_trimmed(small_type s, int nb, int nd, sc_digit *d)
+{
+ convert_SM_to_2C_trimmed(1, s, nb, nd, d);
+}
+
+// Convert a signed number from sign-magnitude representation to 2's
+// complement representation but do not trim the extra bits.
+inline void
+convert_signed_SM_to_2C(small_type s, int nd, sc_digit *d)
+{
+ convert_SM_to_2C(s, nd, d);
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to convert between sign-magnitude (SM) and 2's complement
+// (2C) representations of unsigned numbers.
+// ----------------------------------------------------------------------------
+
+// Trim the extra leading bits off an unsigned number.
+inline void
+trim_unsigned(int nb, int nd, sc_digit *d)
+{
+#ifdef DEBUG_SYSTEMC
+ sc_assert((nb > 0) && (nd > 0) && (d != NULL));
+#endif
+
+ d[nd - 1] &= one_and_ones(bit_ord(nb - 1));
+}
+
+// Convert an unsigned number from 2's complement representation to
+// sign-magnitude representation, and return its sign. nd is d's
+// actual size, without zeros eliminated.
+inline small_type
+convert_unsigned_2C_to_SM(int nb, int nd, sc_digit *d)
+{
+ trim_unsigned(nb, nd, d);
+ return check_for_zero(SC_POS, nd, d);
+}
+
+// Convert an unsigned number from sign-magnitude representation to
+// 2's complement representation, get its sign, convert back to
+// sign-magnitude representation, and return its sign. nd is d's
+// actual size, without zeros eliminated.
+inline small_type
+convert_unsigned_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
+{
+ convert_SM_to_2C(s, nd, d);
+ return convert_unsigned_2C_to_SM(nb, nd, d);
+}
+
+// Convert an unsigned number from sign-magnitude representation to
+// 2's complement representation and trim the extra bits.
+inline void
+convert_unsigned_SM_to_2C_trimmed(small_type s, int nb, int nd, sc_digit *d)
+{
+ convert_SM_to_2C_trimmed(0, s, nb, nd, d);
+}
+
+// Convert an unsigned number from sign-magnitude representation to
+// 2's complement representation but do not trim the extra bits.
+inline void
+convert_unsigned_SM_to_2C(small_type s, int nd, sc_digit *d)
+{
+ convert_SM_to_2C(s, nd, d);
+}
+
+
+// ----------------------------------------------------------------------------
+// Functions to copy one (un)signed number to another.
+// ----------------------------------------------------------------------------
+
+// Copy v to u.
+inline void
+copy_digits_signed(small_type &us,
+ int unb, int und, sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd)
+{
+ if (und <= vnd) {
+ vec_copy(und, ud, vd);
+
+ if (unb <= vnb)
+ us = convert_signed_SM_to_2C_to_SM(us, unb, und, ud);
+ } else { // und > vnd
+ vec_copy_and_zero(und, ud, vnd, vd);
+ }
+}
+
+// Copy v to u.
+inline void
+copy_digits_unsigned(small_type &us,
+ int unb, int und, sc_digit *ud,
+ int /* vnb */, int vnd, const sc_digit *vd)
+{
+ if (und <= vnd)
+ vec_copy(und, ud, vd);
+ else // und > vnd
+ vec_copy_and_zero(und, ud, vnd, vd);
+
+ us = convert_unsigned_SM_to_2C_to_SM(us, unb, und, ud);
+}
+
+
+// ----------------------------------------------------------------------------
+// Faster set(i, v), without bound checking.
+// ----------------------------------------------------------------------------
+
+// A version of set(i, v) without bound checking.
+inline void
+safe_set(int i, bool v, sc_digit *d)
+{
+
+#ifdef DEBUG_SYSTEMC
+ sc_assert((i >= 0) && (d != NULL));
+#endif
+
+ int bit_num = bit_ord(i);
+ int digit_num = digit_ord(i);
+
+ if (v)
+ d[digit_num] |= one_and_zeros(bit_num);
+ else
+ d[digit_num] &= ~(one_and_zeros(bit_num));
+}
+
+
+// ----------------------------------------------------------------------------
+// Function to check if a double number is bad (NaN or infinite).
+// ----------------------------------------------------------------------------
+
+inline bool
+is_nan(double v)
+{
+ return std::numeric_limits<double>::has_quiet_NaN && (v != v);
+}
+
+inline bool
+is_inf(double v)
+{
+ return v == std::numeric_limits<double>::infinity() ||
+ v == -std::numeric_limits<double>::infinity();
+}
+
+inline void
+is_bad_double(double v)
+{
+ // Windows throws exception.
+ if (is_nan(v) || is_inf(v))
+ SC_REPORT_ERROR("value is not valid",
+ "is_bad_double(double v) : "
+ "v is not finite - NaN or Inf");
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_NBUTILS_HH__
diff --git a/src/systemc/ext/dt/int/sc_signed.hh b/src/systemc/ext/dt/int/sc_signed.hh
new file mode 100644
index 000000000..9d31a276d
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_signed.hh
@@ -0,0 +1,2504 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_signed.h -- Arbitrary precision signed arithmetic.
+
+ This file includes the definitions of sc_signed_bitref,
+ sc_signed_subref, and sc_signed classes. The first two classes are
+ proxy classes to reference one bit and a range of bits of a
+ sc_signed number, respectively.
+
+ An sc_signed number has the sign-magnitude representation
+ internally. However, its interface guarantees a 2's-complement
+ representation. The sign-magnitude representation is chosen
+ because of its efficiency: The sc_signed and sc_unsigned types are
+ optimized for arithmetic rather than bitwise operations. For
+ arithmetic operations, the sign-magnitude representation performs
+ better.
+
+ The implementations of sc_signed and sc_unsigned classes are
+ almost identical: Most of the member and friend functions are
+ defined in sc_nbcommon.cpp and sc_nbfriends.cpp so that they can
+ be shared by both of these classes. These functions are chosed by
+ defining a few macros before including them such as IF_SC_SIGNED
+ and CLASS_TYPE. Our implementation choices are mostly dictated by
+ performance considerations in that we tried to provide the most
+ efficient sc_signed and sc_unsigned types without compromising
+ their interface.
+
+ For the behavior of operators, we have two semantics: the old and
+ new. The most important difference between these two semantics is
+ that the old semantics is closer to C/C++ semantics in that the
+ result type of a binary operator on unsigned and signed arguments
+ is unsigned; the new semantics, on the other hand, requires the
+ result type be signed. The new semantics is required by the VSIA
+ C/C++ data types standard. We have implemented the new semantics.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_signed.h,v $
+// Revision 1.3 2011/08/24 22:05:46 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.5 2006/05/08 17:50:01 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.4 2006/03/13 20:25:27 acg
+// Andy Goodrich: Addition of function declarations, e.g., xor_signed_friend()
+// to keep gcc 4.x happy.
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
+
+#include <iostream>
+
+#include "../misc/sc_value_base.hh"
+#include "../sc_temporary.hh"
+#include "sc_length_param.hh"
+#include "sc_nbdefs.hh"
+#include "sc_nbexterns.hh"
+#include "sc_nbutils.hh"
+#include "sc_unsigned.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_signed_bitref_r;
+class sc_signed_bitref;
+class sc_signed_subref_r;
+class sc_signed_subref;
+class sc_concatref;
+class sc_signed;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_int_base;
+class sc_uint_base;
+class sc_int_subref_r;
+class sc_uint_subref_r;
+class sc_signed;
+class sc_unsigned;
+class sc_unsigned_subref_r;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+} // namespace sc_dt
+
+// extern template instantiations
+namespace sc_core
+{
+
+extern template class sc_vpool<sc_dt::sc_signed_bitref>;
+extern template class sc_vpool<sc_dt::sc_signed_subref>;
+
+} // namespace sc_core
+
+namespace sc_dt
+{
+
+// Helper function declarations
+sc_signed add_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_signed sub_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_signed mul_signed_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_signed div_signed_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_signed mod_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_signed and_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_signed or_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_signed xor_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+/*
+ * friend operator declarations
+ */
+
+// ARITHMETIC OPERATORS:
+
+// ADDition operators:
+sc_signed operator + (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator + (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator + (const sc_unsigned &u, int64 v);
+sc_signed operator + (const sc_unsigned &u, long v);
+inline sc_signed operator + (const sc_unsigned &u, int v);
+
+sc_signed operator + (int64 u, const sc_unsigned &v);
+sc_signed operator + (long u, const sc_unsigned &v);
+inline sc_signed operator + (int u, const sc_unsigned &v);
+
+sc_signed operator + (const sc_signed &u, const sc_signed &v);
+sc_signed operator + (const sc_signed &u, int64 v);
+sc_signed operator + (const sc_signed &u, uint64 v);
+sc_signed operator + (const sc_signed &u, long v);
+sc_signed operator + (const sc_signed &u, unsigned long v);
+inline sc_signed operator + (const sc_signed &u, int v);
+inline sc_signed operator + (const sc_signed &u, unsigned int v);
+
+sc_signed operator + (int64 u, const sc_signed &v);
+sc_signed operator + (uint64 u, const sc_signed &v);
+sc_signed operator + (long u, const sc_signed &v);
+sc_signed operator + (unsigned long u, const sc_signed &v);
+inline sc_signed operator + (int u, const sc_signed &v);
+inline sc_signed operator + (unsigned int u, const sc_signed &v);
+
+sc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator + (const sc_signed &u, const sc_int_base &v);
+sc_signed operator + (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator + (const sc_int_base &u, const sc_signed &v);
+sc_signed operator + (const sc_uint_base &u, const sc_signed &v);
+
+
+// SUBtraction operators:
+sc_signed operator - (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator - (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator - (const sc_unsigned &u, int64 v);
+sc_signed operator - (const sc_unsigned &u, uint64 v);
+sc_signed operator - (const sc_unsigned &u, long v);
+sc_signed operator - (const sc_unsigned &u, unsigned long v);
+inline sc_signed operator - (const sc_unsigned &u, int v);
+inline sc_signed operator - (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator - (int64 u, const sc_unsigned &v);
+sc_signed operator - (uint64 u, const sc_unsigned &v);
+sc_signed operator - (long u, const sc_unsigned &v);
+sc_signed operator - (unsigned long u, const sc_unsigned &v);
+inline sc_signed operator - (int u, const sc_unsigned &v);
+inline sc_signed operator - (unsigned int u, const sc_unsigned &v);
+
+sc_signed operator - (const sc_signed &u, const sc_signed &v);
+sc_signed operator - (const sc_signed &u, int64 v);
+sc_signed operator - (const sc_signed &u, uint64 v);
+sc_signed operator - (const sc_signed &u, long v);
+sc_signed operator - (const sc_signed &u, unsigned long v);
+inline sc_signed operator - (const sc_signed &u, int v);
+inline sc_signed operator - (const sc_signed &u, unsigned int v);
+
+sc_signed operator - (int64 u, const sc_signed &v);
+sc_signed operator - (uint64 u, const sc_signed &v);
+sc_signed operator - (long u, const sc_signed &v);
+sc_signed operator - (unsigned long u, const sc_signed &v);
+inline sc_signed operator - (int u, const sc_signed &v);
+inline sc_signed operator - (unsigned int u, const sc_signed &v);
+
+
+sc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator - (const sc_signed &u, const sc_int_base &v);
+sc_signed operator - (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator - (const sc_int_base &u, const sc_signed &v);
+sc_signed operator - (const sc_uint_base &u, const sc_signed &v);
+
+
+// MULtiplication operators:
+sc_signed operator * (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator * (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator * (const sc_unsigned &u, int64 v);
+sc_signed operator * (const sc_unsigned &u, long v);
+inline sc_signed operator * (const sc_unsigned &u, int v);
+
+sc_signed operator * (int64 u, const sc_unsigned &v);
+sc_signed operator * (long u, const sc_unsigned &v);
+inline sc_signed operator * (int u, const sc_unsigned &v);
+
+sc_signed operator * (const sc_signed &u, const sc_signed &v);
+sc_signed operator * (const sc_signed &u, int64 v);
+sc_signed operator * (const sc_signed &u, uint64 v);
+sc_signed operator * (const sc_signed &u, long v);
+sc_signed operator * (const sc_signed &u, unsigned long v);
+inline sc_signed operator * (const sc_signed &u, int v);
+inline sc_signed operator * (const sc_signed &u, unsigned int v);
+
+sc_signed operator * (int64 u, const sc_signed &v);
+sc_signed operator * (uint64 u, const sc_signed &v);
+sc_signed operator * (long u, const sc_signed &v);
+sc_signed operator * (unsigned long u, const sc_signed &v);
+inline sc_signed operator * (int u, const sc_signed &v);
+inline sc_signed operator * (unsigned int u, const sc_signed &v);
+
+sc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator * (const sc_signed &u, const sc_int_base &v);
+sc_signed operator * (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator * (const sc_int_base &u, const sc_signed &v);
+sc_signed operator * (const sc_uint_base &u, const sc_signed &v);
+
+
+// DIVision operators:
+sc_signed operator / (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator / (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator / (const sc_unsigned &u, int64 v);
+sc_signed operator / (const sc_unsigned &u, long v);
+inline sc_signed operator / (const sc_unsigned &u, int v);
+
+sc_signed operator / (int64 u, const sc_unsigned &v);
+sc_signed operator / (long u, const sc_unsigned &v);
+inline sc_signed operator / (int u, const sc_unsigned &v);
+
+sc_signed operator / (const sc_signed &u, const sc_signed &v);
+sc_signed operator / (const sc_signed &u, int64 v);
+sc_signed operator / (const sc_signed &u, uint64 v);
+sc_signed operator / (const sc_signed &u, long v);
+sc_signed operator / (const sc_signed &u, unsigned long v);
+inline sc_signed operator / (const sc_signed &u, int v);
+inline sc_signed operator / (const sc_signed &u, unsigned int v);
+
+sc_signed operator / (int64 u, const sc_signed &v);
+sc_signed operator / (uint64 u, const sc_signed &v);
+sc_signed operator / (long u, const sc_signed &v);
+sc_signed operator / (unsigned long u, const sc_signed &v);
+inline sc_signed operator / (int u, const sc_signed &v);
+inline sc_signed operator / (unsigned int u, const sc_signed &v);
+
+sc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator / (const sc_signed &u, const sc_int_base &v);
+sc_signed operator / (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator / (const sc_int_base &u, const sc_signed &v);
+sc_signed operator / (const sc_uint_base &u, const sc_signed &v);
+
+
+// MODulo operators:
+sc_signed operator % (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator % (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator % (const sc_unsigned &u, int64 v);
+sc_signed operator % (const sc_unsigned &u, long v);
+inline sc_signed operator % (const sc_unsigned &u, int v);
+
+sc_signed operator % (int64 u, const sc_unsigned &v);
+sc_signed operator % (long u, const sc_unsigned &v);
+inline sc_signed operator % (int u, const sc_unsigned &v);
+
+sc_signed operator % (const sc_signed &u, const sc_signed &v);
+sc_signed operator % (const sc_signed &u, int64 v);
+sc_signed operator % (const sc_signed &u, uint64 v);
+sc_signed operator % (const sc_signed &u, long v);
+sc_signed operator % (const sc_signed &u, unsigned long v);
+inline sc_signed operator % (const sc_signed &u, int v);
+inline sc_signed operator % (const sc_signed &u, unsigned int v);
+
+sc_signed operator % (int64 u, const sc_signed &v);
+sc_signed operator % (uint64 u, const sc_signed &v);
+sc_signed operator % (long u, const sc_signed &v);
+sc_signed operator % (unsigned long u, const sc_signed &v);
+inline sc_signed operator % (int u, const sc_signed &v);
+inline sc_signed operator % (unsigned int u, const sc_signed &v);
+
+sc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator % (const sc_signed &u, const sc_int_base &v);
+sc_signed operator % (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator % (const sc_int_base &u, const sc_signed &v);
+sc_signed operator % (const sc_uint_base &u, const sc_signed &v);
+
+
+// BITWISE OPERATORS:
+
+// Bitwise AND operators:
+sc_signed operator & (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator & (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator & (const sc_unsigned &u, int64 v);
+sc_signed operator & (const sc_unsigned &u, long v);
+inline sc_signed operator & (const sc_unsigned &u, int v);
+
+sc_signed operator & (int64 u, const sc_unsigned &v);
+sc_signed operator & (long u, const sc_unsigned &v);
+inline sc_signed operator & (int u, const sc_unsigned &v);
+
+sc_signed operator & (const sc_signed &u, const sc_signed &v);
+sc_signed operator & (const sc_signed &u, int64 v);
+sc_signed operator & (const sc_signed &u, uint64 v);
+sc_signed operator & (const sc_signed &u, long v);
+sc_signed operator & (const sc_signed &u, unsigned long v);
+inline sc_signed operator & (const sc_signed &u, int v);
+inline sc_signed operator & (const sc_signed &u, unsigned int v);
+
+sc_signed operator & (int64 u, const sc_signed &v);
+sc_signed operator & (uint64 u, const sc_signed &v);
+sc_signed operator & (long u, const sc_signed &v);
+sc_signed operator & (unsigned long u, const sc_signed &v);
+inline sc_signed operator & (int u, const sc_signed &v);
+inline sc_signed operator & (unsigned int u, const sc_signed &v);
+
+sc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator & (const sc_signed &u, const sc_int_base &v);
+sc_signed operator & (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator & (const sc_int_base &u, const sc_signed &v);
+sc_signed operator & (const sc_uint_base &u, const sc_signed &v);
+
+
+// Bitwise OR operators:
+sc_signed operator | (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator | (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator | (const sc_unsigned &u, int64 v);
+sc_signed operator | (const sc_unsigned &u, long v);
+inline sc_signed operator | (const sc_unsigned &u, int v);
+
+sc_signed operator | (int64 u, const sc_unsigned &v);
+sc_signed operator | (long u, const sc_unsigned &v);
+inline sc_signed operator | (int u, const sc_unsigned &v);
+
+sc_signed operator | (const sc_signed &u, const sc_signed &v);
+sc_signed operator | (const sc_signed &u, int64 v);
+sc_signed operator | (const sc_signed &u, uint64 v);
+sc_signed operator | (const sc_signed &u, long v);
+sc_signed operator | (const sc_signed &u, unsigned long v);
+inline sc_signed operator | (const sc_signed &u, int v);
+inline sc_signed operator | (const sc_signed &u, unsigned int v);
+
+sc_signed operator | (int64 u, const sc_signed &v);
+sc_signed operator | (uint64 u, const sc_signed &v);
+sc_signed operator | (long u, const sc_signed &v);
+sc_signed operator | (unsigned long u, const sc_signed &v);
+inline sc_signed operator | (int u, const sc_signed &v);
+inline sc_signed operator | (unsigned int u, const sc_signed &v);
+
+sc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator | (const sc_signed &u, const sc_int_base &v);
+sc_signed operator | (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator | (const sc_int_base &u, const sc_signed &v);
+sc_signed operator | (const sc_uint_base &u, const sc_signed &v);
+
+
+// Bitwise XOR operators:
+sc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator ^ (const sc_unsigned &u, int64 v);
+sc_signed operator ^ (const sc_unsigned &u, long v);
+inline sc_signed operator ^ (const sc_unsigned &u, int v);
+
+sc_signed operator ^ (int64 u, const sc_unsigned &v);
+sc_signed operator ^ (long u, const sc_unsigned &v);
+inline sc_signed operator ^ (int u, const sc_unsigned &v);
+
+sc_signed operator ^ (const sc_signed &u, const sc_signed &v);
+sc_signed operator ^ (const sc_signed &u, int64 v);
+sc_signed operator ^ (const sc_signed &u, uint64 v);
+sc_signed operator ^ (const sc_signed &u, long v);
+sc_signed operator ^ (const sc_signed &u, unsigned long v);
+inline sc_signed operator ^ (const sc_signed &u, int v);
+inline sc_signed operator ^ (const sc_signed &u, unsigned int v);
+
+sc_signed operator ^ (int64 u, const sc_signed &v);
+sc_signed operator ^ (uint64 u, const sc_signed &v);
+sc_signed operator ^ (long u, const sc_signed &v);
+sc_signed operator ^ (unsigned long u, const sc_signed &v);
+inline sc_signed operator ^ (int u, const sc_signed &v);
+inline sc_signed operator ^ (unsigned int u, const sc_signed &v);
+
+sc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
+sc_signed operator ^ (const sc_signed &u, const sc_int_base &v);
+sc_signed operator ^ (const sc_signed &u, const sc_uint_base &v);
+sc_signed operator ^ (const sc_int_base &u, const sc_signed &v);
+sc_signed operator ^ (const sc_uint_base &u, const sc_signed &v);
+
+
+// SHIFT OPERATORS:
+// LEFT SHIFT operators:
+sc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator << (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator << (const sc_signed &u, const sc_signed &v);
+sc_signed operator << (const sc_signed &u, int64 v);
+sc_signed operator << (const sc_signed &u, uint64 v);
+sc_signed operator << (const sc_signed &u, long v);
+sc_signed operator << (const sc_signed &u, unsigned long v);
+inline sc_signed operator << (const sc_signed &u, int v);
+inline sc_signed operator << (const sc_signed &u, unsigned int v);
+
+sc_signed operator << (const sc_signed &u, const sc_int_base &v);
+sc_signed operator << (const sc_signed &u, const sc_uint_base &v);
+
+
+// RIGHT SHIFT operators:
+sc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator >> (const sc_signed &u, const sc_signed &v);
+sc_signed operator >> (const sc_signed &u, int64 v);
+sc_signed operator >> (const sc_signed &u, uint64 v);
+sc_signed operator >> (const sc_signed &u, long v);
+sc_signed operator >> (const sc_signed &u, unsigned long v);
+inline sc_signed operator >> (const sc_signed &u, int v);
+inline sc_signed operator >> (const sc_signed &u, unsigned int v);
+
+sc_signed operator >> (const sc_signed &u, const sc_int_base &v);
+sc_signed operator >> (const sc_signed &u, const sc_uint_base &v);
+
+
+// Unary arithmetic operators
+sc_signed operator + (const sc_signed &u);
+sc_signed operator - (const sc_signed &u);
+sc_signed operator - (const sc_unsigned &u);
+
+
+// LOGICAL OPERATORS:
+
+// Logical EQUAL operators:
+bool operator == (const sc_unsigned &u, const sc_signed &v);
+bool operator == (const sc_signed &u, const sc_unsigned &v);
+
+bool operator == (const sc_signed &u, const sc_signed &v);
+bool operator == (const sc_signed &u, int64 v);
+bool operator == (const sc_signed &u, uint64 v);
+bool operator == (const sc_signed &u, long v);
+bool operator == (const sc_signed &u, unsigned long v);
+inline bool operator == (const sc_signed &u, int v);
+inline bool operator == (const sc_signed &u, unsigned int v);
+
+bool operator == (int64 u, const sc_signed &v);
+bool operator == (uint64 u, const sc_signed &v);
+bool operator == (long u, const sc_signed &v);
+bool operator == (unsigned long u, const sc_signed &v);
+inline bool operator == (int u, const sc_signed &v);
+inline bool operator == (unsigned int u, const sc_signed &v);
+
+bool operator == (const sc_signed &u, const sc_int_base &v);
+bool operator == (const sc_signed &u, const sc_uint_base &v);
+bool operator == (const sc_int_base &u, const sc_signed &v);
+bool operator == (const sc_uint_base &u, const sc_signed &v);
+
+// Logical NOT_EQUAL operators:
+bool operator != (const sc_unsigned &u, const sc_signed &v);
+bool operator != (const sc_signed &u, const sc_unsigned &v);
+
+bool operator != (const sc_signed &u, const sc_signed &v);
+bool operator != (const sc_signed &u, int64 v);
+bool operator != (const sc_signed &u, uint64 v);
+bool operator != (const sc_signed &u, long v);
+bool operator != (const sc_signed &u, unsigned long v);
+inline bool operator != (const sc_signed &u, int v);
+inline bool operator != (const sc_signed &u, unsigned int v);
+
+bool operator != (int64 u, const sc_signed &v);
+bool operator != (uint64 u, const sc_signed &v);
+bool operator != (long u, const sc_signed &v);
+bool operator != (unsigned long u, const sc_signed &v);
+inline bool operator != (int u, const sc_signed &v);
+inline bool operator != (unsigned int u, const sc_signed &v);
+
+bool operator != (const sc_signed &u, const sc_int_base &v);
+bool operator != (const sc_signed &u, const sc_uint_base &v);
+bool operator != (const sc_int_base &u, const sc_signed &v);
+bool operator != (const sc_uint_base &u, const sc_signed &v);
+
+// Logical LESS_THAN operators:
+bool operator < (const sc_unsigned &u, const sc_signed &v);
+bool operator < (const sc_signed &u, const sc_unsigned &v);
+
+bool operator < (const sc_signed &u, const sc_signed &v);
+bool operator < (const sc_signed &u, int64 v);
+bool operator < (const sc_signed &u, uint64 v);
+bool operator < (const sc_signed &u, long v);
+bool operator < (const sc_signed &u, unsigned long v);
+inline bool operator < (const sc_signed &u, int v);
+inline bool operator < (const sc_signed &u, unsigned int v);
+
+bool operator < (int64 u, const sc_signed &v);
+bool operator < (uint64 u, const sc_signed &v);
+bool operator < (long u, const sc_signed &v);
+bool operator < (unsigned long u, const sc_signed &v);
+inline bool operator < (int u, const sc_signed &v);
+inline bool operator < (unsigned int u, const sc_signed &v);
+
+bool operator < (const sc_signed &u, const sc_int_base &v);
+bool operator < (const sc_signed &u, const sc_uint_base &v);
+bool operator < (const sc_int_base &u, const sc_signed &v);
+bool operator < (const sc_uint_base &u, const sc_signed &v);
+
+// Logical LESS_THAN_AND_EQUAL operators:
+bool operator <= (const sc_unsigned &u, const sc_signed &v);
+bool operator <= (const sc_signed &u, const sc_unsigned &v);
+
+bool operator <= (const sc_signed &u, const sc_signed &v);
+bool operator <= (const sc_signed &u, int64 v);
+bool operator <= (const sc_signed &u, uint64 v);
+bool operator <= (const sc_signed &u, long v);
+bool operator <= (const sc_signed &u, unsigned long v);
+inline bool operator <= (const sc_signed &u, int v);
+inline bool operator <= (const sc_signed &u, unsigned int v);
+
+bool operator <= (int64 u, const sc_signed &v);
+bool operator <= (uint64 u, const sc_signed &v);
+bool operator <= (long u, const sc_signed &v);
+bool operator <= (unsigned long u, const sc_signed &v);
+inline bool operator <= (int u, const sc_signed &v);
+inline bool operator <= (unsigned int u, const sc_signed &v);
+
+bool operator <= (const sc_signed &u, const sc_int_base &v);
+bool operator <= (const sc_signed &u, const sc_uint_base &v);
+bool operator <= (const sc_int_base &u, const sc_signed &v);
+bool operator <= (const sc_uint_base &u, const sc_signed &v);
+
+// Logical GREATER_THAN operators:
+bool operator > (const sc_unsigned &u, const sc_signed &v);
+bool operator > (const sc_signed &u, const sc_unsigned &v);
+
+bool operator > (const sc_signed &u, const sc_signed &v);
+bool operator > (const sc_signed &u, int64 v);
+bool operator > (const sc_signed &u, uint64 v);
+bool operator > (const sc_signed &u, long v);
+bool operator > (const sc_signed &u, unsigned long v);
+inline bool operator > (const sc_signed &u, int v);
+inline bool operator > (const sc_signed &u, unsigned int v);
+
+bool operator > (int64 u, const sc_signed &v);
+bool operator > (uint64 u, const sc_signed &v);
+bool operator > (long u, const sc_signed &v);
+bool operator > (unsigned long u, const sc_signed &v);
+inline bool operator > (int u, const sc_signed &v);
+inline bool operator > (unsigned int u, const sc_signed &v);
+
+bool operator > (const sc_signed &u, const sc_int_base &v);
+bool operator > (const sc_signed &u, const sc_uint_base &v);
+bool operator > (const sc_int_base &u, const sc_signed &v);
+bool operator > (const sc_uint_base &u, const sc_signed &v);
+
+// Logical GREATER_THAN_AND_EQUAL operators:
+bool operator >= (const sc_unsigned &u, const sc_signed &v);
+bool operator >= (const sc_signed &u, const sc_unsigned &v);
+
+bool operator >= (const sc_signed &u, const sc_signed &v);
+bool operator >= (const sc_signed &u, int64 v);
+bool operator >= (const sc_signed &u, uint64 v);
+bool operator >= (const sc_signed &u, long v);
+bool operator >= (const sc_signed &u, unsigned long v);
+inline bool operator >= (const sc_signed &u, int v);
+inline bool operator >= (const sc_signed &u, unsigned int v);
+
+bool operator >= (int64 u, const sc_signed &v);
+bool operator >= (uint64 u, const sc_signed &v);
+bool operator >= (long u, const sc_signed &v);
+bool operator >= (unsigned long u, const sc_signed &v);
+inline bool operator >= (int u, const sc_signed &v);
+inline bool operator >= (unsigned int u, const sc_signed &v);
+
+bool operator >= (const sc_signed &u, const sc_int_base &v);
+bool operator >= (const sc_signed &u, const sc_uint_base &v);
+bool operator >= (const sc_int_base &u, const sc_signed &v);
+bool operator >= (const sc_uint_base &u, const sc_signed &v);
+
+ // Bitwise NOT operator (unary).
+sc_signed operator ~ (const sc_signed &u);
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_bitref_r
+//
+// Proxy class for sc_signed bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_signed_bitref_r : public sc_value_base
+{
+ friend class sc_signed;
+ protected:
+ // constructor
+ sc_signed_bitref_r() : sc_value_base(), m_index(0), m_obj_p(0) {}
+
+ void
+ initialize(const sc_signed* obj_p, int index_)
+ {
+ m_index = index_;
+ m_obj_p = const_cast<sc_signed*>(obj_p);
+ }
+
+ public:
+ // destructor
+ virtual ~sc_signed_bitref_r() {}
+
+ // copy constructor
+ sc_signed_bitref_r(const sc_signed_bitref_r &a) :
+ sc_value_base(a), m_index(a.m_index), m_obj_p(a.m_obj_p)
+ {}
+
+ // capacity
+ int length() const { return 1; }
+
+
+ // implicit conversion to bool
+ operator uint64 () const;
+ bool operator ! () const;
+ bool operator ~ () const;
+
+
+ // explicit conversions
+ bool value() const { return operator uint64(); }
+
+ bool to_bool() const { return operator uint64(); }
+
+ // concatenation support
+ virtual int
+ concat_length(bool* xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return 1;
+ }
+
+ virtual uint64
+ concat_get_uint64() const
+ {
+ return (uint64)operator uint64();
+ }
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+ dst_p[word_i] &= ~bit_mask;
+ return false;
+ }
+
+ virtual bool
+ concat_get_data( sc_digit* dst_p, int low_i ) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ bool result; // True if non-zero.
+ int word_i = low_i / BITS_PER_DIGIT;
+ if (operator uint64()) {
+ dst_p[word_i] |= bit_mask;
+ result = true;
+ } else {
+ dst_p[word_i] &= ~bit_mask;
+ result = false;
+ }
+ return result;
+ }
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_bool(); }
+
+ protected:
+ int m_index; // Bit to be selected.
+ sc_signed *m_obj_p; // Target of this bit selection.
+
+ private:
+ // Disabled
+ const sc_signed_bitref_r &operator = (const sc_signed_bitref_r &);
+};
+
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_signed_bitref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_bitref
+//
+// Proxy class for sc_signed bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_signed_bitref : public sc_signed_bitref_r
+{
+ friend class sc_signed;
+ friend class sc_core::sc_vpool<sc_signed_bitref>;
+
+ protected:
+ // constructor
+ sc_signed_bitref() : sc_signed_bitref_r() {}
+
+ public:
+ // copy constructor
+ sc_signed_bitref(const sc_signed_bitref &a) : sc_signed_bitref_r(a) {}
+
+ // assignment operators
+ const sc_signed_bitref &operator = (const sc_signed_bitref_r &);
+ const sc_signed_bitref &operator = (const sc_signed_bitref &);
+ const sc_signed_bitref &operator = (bool);
+
+ const sc_signed_bitref &operator &= (bool);
+ const sc_signed_bitref &operator |= (bool);
+ const sc_signed_bitref &operator ^= (bool);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_signed_bitref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_signed_bitref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_subref_r
+//
+// Proxy class for sc_signed part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_signed_subref_r : public sc_value_base
+{
+ friend class sc_signed;
+ friend class sc_signed_signal;
+ friend class sc_unsigned;
+
+ protected:
+ // constructor
+ sc_signed_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0)
+ {}
+
+ void
+ initialize(const sc_signed *obj_p, int left_, int right_)
+ {
+ m_obj_p = (const_cast<sc_signed*>(obj_p));
+ m_left = left_;
+ m_right = right_;
+ }
+
+ public:
+ // destructor
+ virtual ~sc_signed_subref_r() {}
+
+ // copy constructor
+ sc_signed_subref_r(const sc_signed_subref_r &a) :
+ sc_value_base(a), m_left(a.m_left), m_obj_p(a.m_obj_p),
+ m_right(a.m_right)
+ {}
+
+ // capacity
+ int
+ length() const
+ {
+ return m_left >= m_right ? (m_left-m_right + 1) : (m_right-m_left + 1);
+ }
+
+ // implicit conversion to sc_unsigned
+ operator sc_unsigned () const;
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // concatenation support
+ virtual int
+ concat_length(bool* xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return m_left - m_right + 1;
+ }
+ virtual uint64 concat_get_uint64() const;
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const;
+ bool or_reduce() const;
+ bool nor_reduce() const;
+ bool xor_reduce() const ;
+ bool xnor_reduce() const;
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ protected:
+ int m_left; // Left-most bit in this part selection.
+ sc_signed *m_obj_p; // Target of this part selection.
+ int m_right; // Right-most bit in this part selection.
+
+ private:
+ const sc_signed_subref_r &operator = (const sc_signed_subref_r &);
+};
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_signed_subref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_subref
+//
+// Proxy class for sc_signed part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_signed_subref : public sc_signed_subref_r
+{
+ friend class sc_signed;
+ friend class sc_core::sc_vpool<sc_signed_subref>;
+
+ // constructor
+ sc_signed_subref() : sc_signed_subref_r() {}
+
+ public:
+ // copy constructor
+ sc_signed_subref(const sc_signed_subref &a) : sc_signed_subref_r(a) {}
+
+ // assignment operators
+ const sc_signed_subref &operator = (const sc_signed_subref_r &a);
+ const sc_signed_subref &operator = (const sc_signed_subref &a);
+ const sc_signed_subref &operator = (const sc_signed &a);
+
+ const sc_signed_subref &operator = (const sc_unsigned_subref_r &a);
+ const sc_signed_subref &operator = (const sc_unsigned &a);
+
+ template< class T >
+ const sc_signed_subref &
+ operator = (const sc_generic_base<T> &a)
+ {
+ sc_unsigned temp(length());
+ a->to_sc_unsigned(temp);
+ return operator = (temp);
+ }
+
+ const sc_signed_subref &operator = (const char *a);
+ const sc_signed_subref &operator = (unsigned long a);
+ const sc_signed_subref &operator = (long a);
+ const sc_signed_subref &
+ operator = (unsigned int a)
+ {
+ return operator = ((unsigned long)a);
+ }
+
+ const sc_signed_subref &
+ operator = (int a)
+ {
+ return operator = ((long)a);
+ }
+
+ const sc_signed_subref &operator = (uint64 a);
+ const sc_signed_subref &operator = (int64 a);
+ const sc_signed_subref &operator = (double a);
+ const sc_signed_subref &operator = (const sc_int_base &a);
+ const sc_signed_subref &operator = (const sc_uint_base &a);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_signed_subref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_signed_subref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed
+//
+// Arbitrary precision signed number.
+// ----------------------------------------------------------------------------
+
+class sc_signed : public sc_value_base
+{
+ friend class sc_concatref;
+ friend class sc_signed_bitref_r;
+ friend class sc_signed_bitref;
+ friend class sc_signed_subref_r;
+ friend class sc_signed_subref;
+ friend class sc_unsigned;
+ friend class sc_unsigned_subref;
+
+ // Needed for types using sc_signed.
+ typedef bool elemtype;
+
+ void invalid_init(const char *type_name, int nb) const;
+
+ public:
+ // constructors
+ explicit sc_signed(int nb=sc_length_param().len());
+ sc_signed(const sc_signed &v);
+ sc_signed(const sc_unsigned &v);
+ template<class T>
+ explicit sc_signed(const sc_generic_base<T> &v);
+ explicit sc_signed(const sc_bv_base &v);
+ explicit sc_signed(const sc_lv_base &v);
+ explicit sc_signed(const sc_int_subref_r &v);
+ explicit sc_signed(const sc_uint_subref_r &v);
+ explicit sc_signed(const sc_signed_subref_r &v);
+ explicit sc_signed(const sc_unsigned_subref_r &v);
+
+ // assignment operators
+ const sc_signed &operator = (const sc_signed &v);
+ const sc_signed &operator = (const sc_signed_subref_r &a);
+
+ template< class T >
+ const sc_signed &
+ operator = (const sc_generic_base<T> &a)
+ {
+ a->to_sc_signed(*this);
+ return *this;
+ }
+
+ const sc_signed &operator = (const sc_unsigned &v);
+ const sc_signed &operator = (const sc_unsigned_subref_r &a);
+
+ const sc_signed &operator = (const char *v);
+ const sc_signed &operator = (int64 v);
+ const sc_signed &operator = (uint64 v);
+ const sc_signed &operator = (long v);
+ const sc_signed &operator = (unsigned long v);
+
+ const sc_signed &operator = (int v) { return operator=((long)v); }
+
+ const sc_signed &
+ operator = (unsigned int v)
+ {
+ return operator=((unsigned long)v);
+ }
+
+ const sc_signed &operator = (double v);
+ const sc_signed &operator = (const sc_int_base & v);
+ const sc_signed &operator = (const sc_uint_base & v);
+
+ const sc_signed &operator = (const sc_bv_base &);
+ const sc_signed &operator = (const sc_lv_base &);
+
+ const sc_signed &operator = (const sc_fxval &);
+ const sc_signed &operator = (const sc_fxval_fast &);
+ const sc_signed &operator = (const sc_fxnum &);
+ const sc_signed &operator = (const sc_fxnum_fast &);
+
+ // destructor
+ virtual ~sc_signed()
+ {
+#ifndef SC_MAX_NBITS
+ delete [] digit;
+#endif
+ }
+
+ // Concatenation support:
+ sc_digit* get_raw() const { return digit; }
+ virtual int
+ concat_length(bool* xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return nbits;
+ }
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+ virtual uint64 concat_get_uint64() const;
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // Increment operators.
+ sc_signed &operator ++ ();
+ const sc_signed operator ++ (int);
+
+ // Decrement operators.
+ sc_signed &operator -- ();
+ const sc_signed operator -- (int);
+
+ // bit selection
+ inline void
+ check_index(int i) const
+ {
+ if (i < 0 || i >= nbits)
+ invalid_index(i);
+ }
+
+ void invalid_index(int i) const;
+
+ sc_signed_bitref &
+ operator [] (int i)
+ {
+ check_index(i);
+ sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ const sc_signed_bitref_r &
+ operator [] (int i) const
+ {
+ check_index(i);
+ sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ sc_signed_bitref &
+ bit(int i)
+ {
+ check_index(i);
+ sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ const sc_signed_bitref_r &
+ bit(int i) const
+ {
+ check_index(i);
+ sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+
+ // part selection
+
+ // Subref operators. Help access the range of bits from the ith to
+ // jth. These indices have arbitrary precedence with respect to each
+ // other, i.e., we can have i <= j or i > j. Note the equivalence
+ // between range(i, j) and operator(i, j). Also note that
+ // operator(i, i) returns a signed number that corresponds to the
+ // bit operator[i], so these two forms are not the same.
+
+ inline void
+ check_range(int l, int r) const
+ {
+ if (l < r)
+ {
+ if (l < 0 || r >= nbits)
+ invalid_range(l, r);
+ } else {
+ if (r < 0 || l >= nbits)
+ invalid_range(l, r);
+ }
+ }
+
+ void invalid_range(int l, int r) const;
+
+ sc_signed_subref &
+ range(int i, int j)
+ {
+ check_range(i, j);
+ sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ const sc_signed_subref_r &
+ range(int i, int j) const
+ {
+ check_range(i, j);
+ sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ sc_signed_subref &
+ operator () (int i, int j)
+ {
+ check_range(i, j);
+ sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ const sc_signed_subref_r &
+ operator () (int i, int j) const
+ {
+ check_range(i, j);
+ sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+
+ // Print functions. dump prints the internals of the class.
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ void scan(::std::istream &is=::std::cin);
+
+ void dump(::std::ostream &os=::std::cout) const;
+
+ // Functions to find various properties.
+ int length() const { return nbits; } // Bit width.
+ bool iszero() const; // Is the number zero?
+ bool sign() const; // Sign.
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return !or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return !xor_reduce(); }
+
+ // Functions to access individual bits.
+ bool test(int i) const; // Is the ith bit 0 or 1?
+ void set(int i); // Set the ith bit to 1.
+ void clear(int i); // Set the ith bit to 0.
+ void
+ set(int i, bool v) // Set the ith bit to v.
+ {
+ if (v)
+ set(i);
+ else
+ clear(i);
+ }
+ void
+ invert(int i) // Negate the ith bit.
+ {
+ if (test(i))
+ clear(i);
+ else set(i);
+ }
+
+ // Make the number equal to its mirror image.
+ void reverse();
+
+ // Get/set a packed bit representation of the number.
+ void get_packed_rep(sc_digit *buf) const;
+ void set_packed_rep(sc_digit *buf);
+
+ /*
+ The comparison of the old and new semantics are as follows:
+
+ Let s = sc_signed,
+ u = sc_unsigned,
+ un = { uint64, unsigned long, unsigned int },
+ sn = { int64, long, int, char* }, and
+ OP = { +, -, *, /, % }.
+
+ Old semantics: New semantics:
+ u OP u -> u u OP u -> u
+ s OP u -> u s OP u -> s
+ u OP s -> u u OP s -> s
+ s OP s -> s s OP s -> s
+
+ u OP un = un OP u -> u u OP un = un OP u -> u
+ u OP sn = sn OP u -> u u OP sn = sn OP u -> s
+
+ s OP un = un OP s -> s s OP un = un OP s -> s
+ s OP sn = sn OP s -> s s OP sn = sn OP s -> s
+
+ In the new semantics, the result is u if both operands are u; the
+ result is s otherwise. The only exception is subtraction. The result
+ of a subtraction is always s.
+
+ The old semantics is like C/C++ semantics on integer types; the
+ new semantics is due to the VSIA C/C++ data types standard.
+ */
+
+ // ARITHMETIC OPERATORS:
+
+ // ADDition operators:
+ friend sc_signed operator + (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator + (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator + (const sc_unsigned &u, int64 v);
+ friend sc_signed operator + (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator + (const sc_unsigned &u, int v)
+ {
+ return operator + (u, (long)v);
+ }
+
+ friend sc_signed operator + (int64 u, const sc_unsigned &v);
+ friend sc_signed operator + (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator + (int u, const sc_unsigned &v)
+ {
+ return operator + ((long)u, v);
+ }
+
+ friend sc_signed operator + (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator + (const sc_signed &u, int64 v);
+ friend sc_signed operator + (const sc_signed &u, uint64 v);
+ friend sc_signed operator + (const sc_signed &u, long v);
+ friend sc_signed operator + (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator + (const sc_signed &u, int v)
+ {
+ return operator + (u, (long)v);
+ }
+ friend sc_signed
+ operator + (const sc_signed &u, unsigned int v)
+ {
+ return operator + (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator + (int64 u, const sc_signed &v);
+ friend sc_signed operator + (uint64 u, const sc_signed &v);
+ friend sc_signed operator + (long u, const sc_signed &v);
+ friend sc_signed operator + (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator + (int u, const sc_signed &v)
+ {
+ return operator + ((long)u, v);
+ }
+ friend sc_signed
+ operator + (unsigned int u, const sc_signed &v)
+ {
+ return operator + ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator += (const sc_signed &v);
+ const sc_signed &operator += (const sc_unsigned &v);
+ const sc_signed &operator += (int64 v);
+ const sc_signed &operator += (uint64 v);
+ const sc_signed &operator += (long v);
+ const sc_signed &operator += (unsigned long v);
+ const sc_signed &
+ operator += (int v)
+ {
+ return operator += ((long)v);
+ }
+ const sc_signed &
+ operator += (unsigned int v)
+ {
+ return operator += ((unsigned long)v);
+ }
+
+ friend sc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator + (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator + (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator + (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator + (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed & operator += (const sc_int_base &v);
+ const sc_signed & operator += (const sc_uint_base &v);
+
+ // SUBtraction operators:
+ friend sc_signed operator - (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator - (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator - (const sc_unsigned &u, int64 v);
+ friend sc_signed operator - (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator - (const sc_unsigned &u, long v);
+ friend sc_signed operator - (const sc_unsigned &u, unsigned long v);
+ friend sc_signed
+ operator - (const sc_unsigned &u, int v)
+ {
+ return operator - (u, (long)v);
+ }
+ friend sc_signed
+ operator - (const sc_unsigned &u, unsigned int v)
+ {
+ return operator - (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator - (int64 u, const sc_unsigned &v);
+ friend sc_signed operator - (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator - (long u, const sc_unsigned &v);
+ friend sc_signed operator - (unsigned long u, const sc_unsigned &v);
+ friend sc_signed
+ operator - (int u, const sc_unsigned &v)
+ {
+ return operator - ((long)u, v);
+ }
+ friend sc_signed
+ operator - (unsigned int u, const sc_unsigned &v)
+ {
+ return operator - ((unsigned long)u, v);
+ }
+
+ friend sc_signed operator - (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator - (const sc_signed &u, int64 v);
+ friend sc_signed operator - (const sc_signed &u, uint64 v);
+ friend sc_signed operator - (const sc_signed &u, long v);
+ friend sc_signed operator - (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator - (const sc_signed &u, int v)
+ {
+ return operator - (u, (long) v);
+ }
+ friend sc_signed
+ operator - (const sc_signed &u, unsigned int v)
+ {
+ return operator - (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator - (int64 u, const sc_signed &v);
+ friend sc_signed operator - (uint64 u, const sc_signed &v);
+ friend sc_signed operator - (long u, const sc_signed &v);
+ friend sc_signed operator - (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator - (int u, const sc_signed &v)
+ {
+ return operator - ((long)u, v);
+ }
+ friend sc_signed
+ operator - (unsigned int u, const sc_signed &v)
+ {
+ return operator - ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator -= (const sc_signed &v);
+ const sc_signed &operator -= (const sc_unsigned &v);
+ const sc_signed &operator -= (int64 v);
+ const sc_signed &operator -= (uint64 v);
+ const sc_signed &operator -= (long v);
+ const sc_signed &operator -= (unsigned long v);
+ const sc_signed &
+ operator -= (int v)
+ {
+ return operator -= ((long)v);
+ }
+ const sc_signed &
+ operator -= (unsigned int v)
+ {
+ return operator -= ((unsigned long)v);
+ }
+
+ friend sc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator - (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator - (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator - (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator - (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator -= (const sc_int_base &v);
+ const sc_signed &operator -= (const sc_uint_base &v);
+
+ // MULtiplication operators:
+ friend sc_signed operator * (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator * (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator * (const sc_unsigned &u, int64 v);
+ friend sc_signed operator * (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator * (const sc_unsigned &u, int v)
+ {
+ return operator * (u, (long)v);
+ }
+
+ friend sc_signed operator * (int64 u, const sc_unsigned &v);
+ friend sc_signed operator * (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator * (int u, const sc_unsigned &v)
+ {
+ return operator * ((long)u, v);
+ }
+
+ friend sc_signed operator * (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator * (const sc_signed &u, int64 v);
+ friend sc_signed operator * (const sc_signed &u, uint64 v);
+ friend sc_signed operator * (const sc_signed &u, long v);
+ friend sc_signed operator * (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator * (const sc_signed &u, int v)
+ {
+ return operator * (u, (long)v);
+ }
+ friend sc_signed
+ operator * (const sc_signed &u, unsigned int v)
+ {
+ return operator * (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator * (int64 u, const sc_signed &v);
+ friend sc_signed operator * (uint64 u, const sc_signed &v);
+ friend sc_signed operator * (long u, const sc_signed &v);
+ friend sc_signed operator * (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator * (int u, const sc_signed &v)
+ {
+ return operator * ((long)u, v);
+ }
+ friend sc_signed
+ operator * (unsigned int u, const sc_signed &v)
+ {
+ return operator * ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator *= (const sc_signed &v);
+ const sc_signed &operator *= (const sc_unsigned &v);
+ const sc_signed &operator *= (int64 v);
+ const sc_signed &operator *= (uint64 v);
+ const sc_signed &operator *= (long v);
+ const sc_signed &operator *= (unsigned long v);
+ const sc_signed &
+ operator *= (int v)
+ {
+ return operator *= ((long)v);
+ }
+ const sc_signed &
+ operator *= (unsigned int v)
+ {
+ return operator *= ((unsigned long)v);
+ }
+
+ friend sc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator * (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator * (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator * (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator * (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator *= (const sc_int_base &v);
+ const sc_signed &operator *= (const sc_uint_base &v);
+
+ // DIVision operators:
+ friend sc_signed operator / (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator / (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator / (const sc_unsigned &u, int64 v);
+ friend sc_signed operator / (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator / (const sc_unsigned &u, int v)
+ {
+ return operator / (u, (long)v);
+ }
+
+ friend sc_signed operator / (int64 u, const sc_unsigned &v);
+ friend sc_signed operator / (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator / (int u, const sc_unsigned &v)
+ {
+ return operator / ((long)u, v);
+ }
+
+ friend sc_signed operator / (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator / (const sc_signed &u, int64 v);
+ friend sc_signed operator / (const sc_signed &u, uint64 v);
+ friend sc_signed operator / (const sc_signed &u, long v);
+ friend sc_signed operator / (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator / (const sc_signed &u, int v)
+ {
+ return operator / (u, (long)v);
+ }
+ friend sc_signed
+ operator / (const sc_signed &u, unsigned int v)
+ {
+ return operator / (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator / (int64 u, const sc_signed &v);
+ friend sc_signed operator / (uint64 u, const sc_signed &v);
+ friend sc_signed operator / (long u, const sc_signed &v);
+ friend sc_signed operator / (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator / (int u, const sc_signed &v)
+ {
+ return operator / ((long)u, v);
+ }
+ friend sc_signed
+ operator / (unsigned int u, const sc_signed &v)
+ {
+ return operator / ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator /= (const sc_signed &v);
+ const sc_signed &operator /= (const sc_unsigned &v);
+ const sc_signed &operator /= (int64 v);
+ const sc_signed &operator /= (uint64 v);
+ const sc_signed &operator /= (long v);
+ const sc_signed &operator /= (unsigned long v);
+ const sc_signed &
+ operator /= (int v)
+ {
+ return operator /= ((long)v);
+ }
+ const sc_signed &
+ operator /= (unsigned int v)
+ {
+ return operator /= ((unsigned long)v);
+ }
+
+ friend sc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator / (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator / (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator / (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator / (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator /= (const sc_int_base &v);
+ const sc_signed &operator /= (const sc_uint_base &v);
+
+ // MODulo operators:
+ friend sc_signed operator % (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator % (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator % (const sc_unsigned &u, int64 v);
+ friend sc_signed operator % (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator % (const sc_unsigned &u, int v)
+ {
+ return operator % (u, (long)v);
+ }
+
+ friend sc_signed operator % (int64 u, const sc_unsigned &v);
+ friend sc_signed operator % (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator % (int u, const sc_unsigned &v)
+ {
+ return operator % ((long)u, v);
+ }
+
+ friend sc_signed operator % (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator % (const sc_signed &u, int64 v);
+ friend sc_signed operator % (const sc_signed &u, uint64 v);
+ friend sc_signed operator % (const sc_signed &u, long v);
+ friend sc_signed operator % (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator % (const sc_signed &u, int v)
+ {
+ return operator % (u, (long)v);
+ }
+ friend sc_signed
+ operator % (const sc_signed &u, unsigned int v)
+ {
+ return operator % (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator % (int64 u, const sc_signed &v);
+ friend sc_signed operator % (uint64 u, const sc_signed &v);
+ friend sc_signed operator % (long u, const sc_signed &v);
+ friend sc_signed operator % (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator % (int u, const sc_signed &v)
+ {
+ return operator % ((long)u, v);
+ }
+ friend sc_signed
+ operator % (unsigned int u, const sc_signed &v)
+ {
+ return operator % ((unsigned long) u, v);
+ }
+
+ const sc_signed &operator %= (const sc_signed &v);
+ const sc_signed &operator %= (const sc_unsigned &v);
+ const sc_signed &operator %= (int64 v);
+ const sc_signed &operator %= (uint64 v);
+ const sc_signed &operator %= (long v);
+ const sc_signed &operator %= (unsigned long v);
+ const sc_signed &
+ operator %= (int v)
+ {
+ return operator %= ((long)v);
+ }
+ const sc_signed &
+ operator %= (unsigned int v)
+ {
+ return operator %= ((unsigned long)v);
+ }
+
+ friend sc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator % (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator % (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator % (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator % (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator %= (const sc_int_base &v);
+ const sc_signed &operator %= (const sc_uint_base &v);
+
+ // BITWISE OPERATORS:
+
+ // Bitwise AND operators:
+ friend sc_signed operator & (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator & (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator & (const sc_unsigned &u, int64 v);
+ friend sc_signed operator & (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator &(const sc_unsigned &u, int v)
+ {
+ return operator & (u, (long)v);
+ }
+
+ friend sc_signed operator & (int64 u, const sc_unsigned &v);
+ friend sc_signed operator & (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator & (int u, const sc_unsigned &v)
+ {
+ return operator & ((long) u, v);
+ }
+
+ friend sc_signed operator & (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator & (const sc_signed &u, int64 v);
+ friend sc_signed operator & (const sc_signed &u, uint64 v);
+ friend sc_signed operator & (const sc_signed &u, long v);
+ friend sc_signed operator & (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator & (const sc_signed &u, int v)
+ {
+ return operator & (u, (long)v);
+ }
+ friend sc_signed
+ operator & (const sc_signed &u, unsigned int v)
+ {
+ return operator & (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator & (int64 u, const sc_signed &v);
+ friend sc_signed operator & (uint64 u, const sc_signed &v);
+ friend sc_signed operator & (long u, const sc_signed &v);
+ friend sc_signed operator & (unsigned long u, const sc_signed &v);
+ friend sc_signed operator & (int u, const sc_signed &v)
+ { return operator&((long) u, v); }
+ friend sc_signed operator & (unsigned int u, const sc_signed &v)
+ { return operator&((unsigned long) u, v); }
+
+ const sc_signed &operator &= (const sc_signed &v);
+ const sc_signed &operator &= (const sc_unsigned &v);
+ const sc_signed &operator &= (int64 v);
+ const sc_signed &operator &= (uint64 v);
+ const sc_signed &operator &= (long v);
+ const sc_signed &operator &= (unsigned long v);
+ const sc_signed &
+ operator &= (int v)
+ {
+ return operator &= ((long) v);
+ }
+ const sc_signed &
+ operator &= (unsigned int v)
+ {
+ return operator &= ((unsigned long) v);
+ }
+
+ friend sc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator & (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator & (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator & (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator & (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator &= (const sc_int_base &v);
+ const sc_signed &operator &= (const sc_uint_base &v);
+
+ // Bitwise OR operators:
+ friend sc_signed operator | (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator | (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator | (const sc_unsigned &u, int64 v);
+ friend sc_signed operator | (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator | (const sc_unsigned &u, int v)
+ {
+ return operator | (u, (long)v);
+ }
+
+ friend sc_signed operator | (int64 u, const sc_unsigned &v);
+ friend sc_signed operator | (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator | (int u, const sc_unsigned &v)
+ {
+ return operator | ((long)u, v);
+ }
+
+ friend sc_signed operator | (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator | (const sc_signed &u, int64 v);
+ friend sc_signed operator | (const sc_signed &u, uint64 v);
+ friend sc_signed operator | (const sc_signed &u, long v);
+ friend sc_signed operator | (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator | (const sc_signed &u, int v)
+ {
+ return operator | (u, (long)v);
+ }
+ friend sc_signed
+ operator | (const sc_signed &u, unsigned int v)
+ {
+ return operator | (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator | (int64 u, const sc_signed &v);
+ friend sc_signed operator | (uint64 u, const sc_signed &v);
+ friend sc_signed operator | (long u, const sc_signed &v);
+ friend sc_signed operator | (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator | (int u, const sc_signed &v)
+ {
+ return operator | ((long) u, v);
+ }
+ friend sc_signed
+ operator | (unsigned int u, const sc_signed &v)
+ {
+ return operator | ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator |= (const sc_signed &v);
+ const sc_signed &operator |= (const sc_unsigned &v);
+ const sc_signed &operator |= (int64 v);
+ const sc_signed &operator |= (uint64 v);
+ const sc_signed &operator |= (long v);
+ const sc_signed &operator |= (unsigned long v);
+ const sc_signed &
+ operator |= (int v)
+ {
+ return operator |= ((long)v);
+ }
+ const sc_signed &
+ operator |= (unsigned int v)
+ {
+ return operator |= ((unsigned long)v);
+ }
+
+ friend sc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator | (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator | (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator | (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator | (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator |= (const sc_int_base &v);
+ const sc_signed &operator |= (const sc_uint_base &v);
+
+ // Bitwise XOR operators:
+ friend sc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator ^ (const sc_unsigned &u, int64 v);
+ friend sc_signed operator ^ (const sc_unsigned &u, long v);
+ friend sc_signed
+ operator ^ (const sc_unsigned &u, int v)
+ {
+ return operator ^ (u, (long)v);
+ }
+
+ friend sc_signed operator ^ (int64 u, const sc_unsigned &v);
+ friend sc_signed operator ^ (long u, const sc_unsigned &v);
+ friend sc_signed
+ operator ^ (int u, const sc_unsigned &v)
+ {
+ return operator ^ ((long)u, v);
+ }
+
+ friend sc_signed operator ^ (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator ^ (const sc_signed &u, int64 v);
+ friend sc_signed operator ^ (const sc_signed &u, uint64 v);
+ friend sc_signed operator ^ (const sc_signed &u, long v);
+ friend sc_signed operator ^ (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator ^ (const sc_signed &u, int v)
+ {
+ return operator ^ (u, (long)v);
+ }
+ friend sc_signed
+ operator ^ (const sc_signed &u, unsigned int v)
+ {
+ return operator ^ (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator ^ (int64 u, const sc_signed &v);
+ friend sc_signed operator ^ (uint64 u, const sc_signed &v);
+ friend sc_signed operator ^ (long u, const sc_signed &v);
+ friend sc_signed operator ^ (unsigned long u, const sc_signed &v);
+ friend sc_signed
+ operator ^ (int u, const sc_signed &v)
+ {
+ return operator ^ ((long)u, v);
+ }
+ friend sc_signed
+ operator ^ (unsigned int u, const sc_signed &v)
+ {
+ return operator ^ ((unsigned long)u, v);
+ }
+
+ const sc_signed &operator ^= (const sc_signed &v);
+ const sc_signed &operator ^= (const sc_unsigned &v);
+ const sc_signed &operator ^= (int64 v);
+ const sc_signed &operator ^= (uint64 v);
+ const sc_signed &operator ^= (long v);
+ const sc_signed &operator ^= (unsigned long v);
+ const sc_signed &
+ operator ^= (int v)
+ {
+ return operator ^= ((long)v);
+ }
+ const sc_signed &
+ operator ^= (unsigned int v)
+ {
+ return operator ^= ((unsigned long)v);
+ }
+
+ friend sc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
+ friend sc_signed operator ^ (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator ^ (const sc_signed &u, const sc_uint_base &v);
+ friend sc_signed operator ^ (const sc_int_base &u, const sc_signed &v);
+ friend sc_signed operator ^ (const sc_uint_base &u, const sc_signed &v);
+ const sc_signed &operator ^= (const sc_int_base &v);
+ const sc_signed &operator ^= (const sc_uint_base &v);
+
+ // SHIFT OPERATORS:
+
+ // LEFT SHIFT operators:
+ friend sc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator << (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator << (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator << (const sc_signed &u, int64 v);
+ friend sc_signed operator << (const sc_signed &u, uint64 v);
+ friend sc_signed operator << (const sc_signed &u, long v);
+ friend sc_signed operator << (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator << (const sc_signed &u, int v)
+ {
+ return operator << (u, (long)v);
+ }
+ friend sc_signed
+ operator << (const sc_signed &u, unsigned int v)
+ {
+ return operator << (u, (unsigned long)v);
+ }
+
+ const sc_signed &operator <<= (const sc_signed &v);
+ const sc_signed &operator <<= (const sc_unsigned &v);
+ const sc_signed &operator <<= (int64 v);
+ const sc_signed &operator <<= (uint64 v);
+ const sc_signed &operator <<= (long v);
+ const sc_signed &operator <<= (unsigned long v);
+ const sc_signed &
+ operator <<= (int v)
+ {
+ return operator <<= ((long)v);
+ }
+ const sc_signed &
+ operator <<= (unsigned int v)
+ {
+ return operator <<= ((unsigned long)v);
+ }
+
+ friend sc_signed operator << (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator << (const sc_signed &u, const sc_uint_base &v);
+ const sc_signed &operator <<= (const sc_int_base &v);
+ const sc_signed &operator <<= (const sc_uint_base &v);
+
+ // RIGHT SHIFT operators:
+ friend sc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator >> (const sc_signed &u, const sc_signed &v);
+ friend sc_signed operator >> (const sc_signed &u, int64 v);
+ friend sc_signed operator >> (const sc_signed &u, uint64 v);
+ friend sc_signed operator >> (const sc_signed &u, long v);
+ friend sc_signed operator >> (const sc_signed &u, unsigned long v);
+ friend sc_signed
+ operator >> (const sc_signed &u, int v)
+ {
+ return operator >> (u, (long)v);
+ }
+ friend sc_signed
+ operator >> (const sc_signed &u, unsigned int v)
+ {
+ return operator >> (u, (unsigned long) v);
+ }
+
+ const sc_signed &operator >>= (const sc_signed &v);
+ const sc_signed &operator >>= (const sc_unsigned &v);
+ const sc_signed &operator >>= (int64 v);
+ const sc_signed &operator >>= (uint64 v);
+ const sc_signed &operator >>= (long v);
+ const sc_signed &operator >>= (unsigned long v);
+ const sc_signed &
+ operator >>= (int v)
+ {
+ return operator >>= ((long)v);
+ }
+ const sc_signed &
+ operator >>= (unsigned int v)
+ {
+ return operator >>= ((unsigned long)v);
+ }
+
+ friend sc_signed operator >> (const sc_signed &u, const sc_int_base &v);
+ friend sc_signed operator >> (const sc_signed &u, const sc_uint_base &v);
+ const sc_signed &operator >>= (const sc_int_base &v);
+ const sc_signed &operator >>= (const sc_uint_base &v);
+
+ // Unary arithmetic operators
+ friend sc_signed operator + (const sc_signed &u);
+ friend sc_signed operator - (const sc_signed &u);
+ friend sc_signed operator - (const sc_unsigned &u);
+
+ // LOGICAL OPERATORS:
+
+ // Logical EQUAL operators:
+ friend bool operator == (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator == (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator == (const sc_signed &u, const sc_signed &v);
+ friend bool operator == (const sc_signed &u, int64 v);
+ friend bool operator == (const sc_signed &u, uint64 v);
+ friend bool operator == (const sc_signed &u, long v);
+ friend bool operator == (const sc_signed &u, unsigned long v);
+ friend bool
+ operator == (const sc_signed &u, int v)
+ {
+ return operator == (u, (long)v);
+ }
+ friend bool
+ operator == (const sc_signed &u, unsigned int v)
+ {
+ return operator == (u, (unsigned long)v);
+ }
+
+ friend bool operator == (int64 u, const sc_signed &v);
+ friend bool operator == (uint64 u, const sc_signed &v);
+ friend bool operator == (long u, const sc_signed &v);
+ friend bool operator == (unsigned long u, const sc_signed &v);
+ friend bool
+ operator == (int u, const sc_signed &v)
+ {
+ return operator == ((long)u, v);
+ }
+ friend bool
+ operator == (unsigned int u, const sc_signed &v)
+ {
+ return operator == ((unsigned long)u, v);
+ }
+
+ friend bool operator == (const sc_signed &u, const sc_int_base &v);
+ friend bool operator == (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator == (const sc_int_base &u, const sc_signed &v);
+ friend bool operator == (const sc_uint_base &u, const sc_signed &v);
+
+ // Logical NOT_EQUAL operators:
+ friend bool operator != (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator != (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator != (const sc_signed &u, const sc_signed &v);
+ friend bool operator != (const sc_signed &u, int64 v);
+ friend bool operator != (const sc_signed &u, uint64 v);
+ friend bool operator != (const sc_signed &u, long v);
+ friend bool operator != (const sc_signed &u, unsigned long v);
+ friend bool
+ operator != (const sc_signed &u, int v)
+ {
+ return operator != (u, (long)v);
+ }
+ friend bool
+ operator != (const sc_signed &u, unsigned int v)
+ {
+ return operator != (u, (unsigned long)v);
+ }
+
+ friend bool operator != (int64 u, const sc_signed &v);
+ friend bool operator != (uint64 u, const sc_signed &v);
+ friend bool operator != (long u, const sc_signed &v);
+ friend bool operator != (unsigned long u, const sc_signed &v);
+ friend bool
+ operator != (int u, const sc_signed &v)
+ {
+ return operator != ((long)u, v);
+ }
+ friend bool
+ operator != (unsigned int u, const sc_signed &v)
+ {
+ return operator != ((unsigned long)u, v);
+ }
+
+ friend bool operator != (const sc_signed &u, const sc_int_base &v);
+ friend bool operator != (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator != (const sc_int_base &u, const sc_signed &v);
+ friend bool operator != (const sc_uint_base &u, const sc_signed &v);
+
+ // Logical LESS_THAN operators:
+ friend bool operator < (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator < (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator < (const sc_signed &u, const sc_signed &v);
+ friend bool operator < (const sc_signed &u, int64 v);
+ friend bool operator < (const sc_signed &u, uint64 v);
+ friend bool operator < (const sc_signed &u, long v);
+ friend bool operator < (const sc_signed &u, unsigned long v);
+ friend bool operator < (const sc_signed &u, int v)
+ { return operator<(u, (long) v); }
+ friend bool operator < (const sc_signed &u, unsigned int v)
+ { return operator<(u, (unsigned long) v); }
+
+ friend bool operator < (int64 u, const sc_signed &v);
+ friend bool operator < (uint64 u, const sc_signed &v);
+ friend bool operator < (long u, const sc_signed &v);
+ friend bool operator < (unsigned long u, const sc_signed &v);
+ friend bool
+ operator < (int u, const sc_signed &v)
+ {
+ return operator < ((long)u, v);
+ }
+ friend bool
+ operator < (unsigned int u, const sc_signed &v)
+ {
+ return operator < ((unsigned long)u, v);
+ }
+
+ friend bool operator < (const sc_signed &u, const sc_int_base &v);
+ friend bool operator < (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator < (const sc_int_base &u, const sc_signed &v);
+ friend bool operator < (const sc_uint_base &u, const sc_signed &v);
+
+ // Logical LESS_THAN_AND_EQUAL operators:
+ friend bool operator <= (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator <= (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator <= (const sc_signed &u, const sc_signed &v);
+ friend bool operator <= (const sc_signed &u, int64 v);
+ friend bool operator <= (const sc_signed &u, uint64 v);
+ friend bool operator <= (const sc_signed &u, long v);
+ friend bool operator <= (const sc_signed &u, unsigned long v);
+ friend bool
+ operator <= (const sc_signed &u, int v)
+ {
+ return operator <= (u, (long)v);
+ }
+ friend bool
+ operator <= (const sc_signed &u, unsigned int v)
+ {
+ return operator <= (u, (unsigned long)v);
+ }
+
+ friend bool operator <= (int64 u, const sc_signed &v);
+ friend bool operator <= (uint64 u, const sc_signed &v);
+ friend bool operator <= (long u, const sc_signed &v);
+ friend bool operator <= (unsigned long u, const sc_signed &v);
+ friend bool
+ operator <= (int u, const sc_signed &v)
+ {
+ return operator <= ((long)u, v);
+ }
+ friend bool
+ operator <= (unsigned int u, const sc_signed &v)
+ {
+ return operator <= ((unsigned long)u, v);
+ }
+
+ friend bool operator <= (const sc_signed &u, const sc_int_base &v);
+ friend bool operator <= (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator <= (const sc_int_base &u, const sc_signed &v);
+ friend bool operator <= (const sc_uint_base &u, const sc_signed &v);
+
+ // Logical GREATER_THAN operators:
+ friend bool operator > (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator > (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator > (const sc_signed &u, const sc_signed &v);
+ friend bool operator > (const sc_signed &u, int64 v);
+ friend bool operator > (const sc_signed &u, uint64 v);
+ friend bool operator > (const sc_signed &u, long v);
+ friend bool operator > (const sc_signed &u, unsigned long v);
+ friend bool
+ operator > (const sc_signed &u, int v)
+ {
+ return operator > (u, (long)v);
+ }
+ friend bool
+ operator > (const sc_signed &u, unsigned int v)
+ {
+ return operator > (u, (unsigned long)v);
+ }
+
+ friend bool operator > (int64 u, const sc_signed &v);
+ friend bool operator > (uint64 u, const sc_signed &v);
+ friend bool operator > (long u, const sc_signed &v);
+ friend bool operator > (unsigned long u, const sc_signed &v);
+ friend bool
+ operator > (int u, const sc_signed &v)
+ {
+ return operator > ((long)u, v);
+ }
+ friend bool
+ operator > (unsigned int u, const sc_signed &v)
+ {
+ return operator > ((unsigned long)u, v);
+ }
+
+ friend bool operator > (const sc_signed &u, const sc_int_base &v);
+ friend bool operator > (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator > (const sc_int_base &u, const sc_signed &v);
+ friend bool operator > (const sc_uint_base &u, const sc_signed &v);
+
+ // Logical GREATER_THAN_AND_EQUAL operators:
+ friend bool operator >= (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator >= (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator >= (const sc_signed &u, const sc_signed &v);
+ friend bool operator >= (const sc_signed &u, int64 v);
+ friend bool operator >= (const sc_signed &u, uint64 v);
+ friend bool operator >= (const sc_signed &u, long v);
+ friend bool operator >= (const sc_signed &u, unsigned long v);
+ friend bool
+ operator >= (const sc_signed &u, int v)
+ {
+ return operator >= (u, (long)v);
+ }
+ friend bool
+ operator >= (const sc_signed &u, unsigned int v)
+ {
+ return operator >= (u, (unsigned long)v);
+ }
+
+ friend bool operator >= (int64 u, const sc_signed &v);
+ friend bool operator >= (uint64 u, const sc_signed &v);
+ friend bool operator >= (long u, const sc_signed &v);
+ friend bool operator >= (unsigned long u, const sc_signed &v);
+ friend bool
+ operator >= (int u, const sc_signed &v)
+ {
+ return operator >= ((long)u, v);
+ }
+ friend bool
+ operator >= (unsigned int u, const sc_signed &v)
+ {
+ return operator >= ((unsigned long)u, v);
+ }
+
+ friend bool operator >= (const sc_signed &u, const sc_int_base &v);
+ friend bool operator >= (const sc_signed &u, const sc_uint_base &v);
+ friend bool operator >= (const sc_int_base &u, const sc_signed &v);
+ friend bool operator >= (const sc_uint_base &u, const sc_signed &v);
+
+ // Bitwise NOT operator (unary).
+ friend sc_signed operator ~ (const sc_signed &u);
+
+ // Helper functions.
+ friend sc_signed add_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed sub_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed mul_signed_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed div_signed_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed mod_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed and_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed or_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_signed xor_signed_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ private:
+
+ small_type sgn; // Shortened as s.
+ int nbits; // Shortened as nb.
+ int ndigits; // Shortened as nd.
+
+#ifdef SC_MAX_NBITS
+ sc_digit digit[DIV_CEIL(SC_MAX_NBITS)]; // Shortened as d.
+#else
+ sc_digit *digit; // Shortened as d.
+#endif
+
+ /*
+ * Private constructors:
+ */
+
+ // Create a copy of v with sign s.
+ sc_signed(const sc_signed &v, small_type s);
+ sc_signed(const sc_unsigned &v, small_type s);
+
+ // Create a signed number with the given attributes.
+ sc_signed(small_type s, int nb, int nd, sc_digit *d, bool alloc=true);
+
+ // Create an unsigned number using the bits u[l..r].
+ sc_signed(const sc_signed *u, int l, int r);
+ sc_signed(const sc_unsigned *u, int l, int r);
+
+ // Private member functions. The called functions are inline functions.
+ small_type default_sign() const { return SC_NOSIGN; }
+ int num_bits(int nb) const { return nb; }
+
+ bool check_if_outside(int bit_num) const;
+
+ void
+ copy_digits(int nb, int nd, const sc_digit *d)
+ {
+ copy_digits_signed(sgn, nbits, ndigits, digit, nb, nd, d);
+ }
+
+ void makezero() { sgn = make_zero(ndigits, digit); }
+
+ // Conversion functions between 2's complement (2C) and
+ // sign-magnitude (SM):
+ void
+ convert_2C_to_SM()
+ {
+ sgn = convert_signed_2C_to_SM(nbits, ndigits, digit);
+ }
+
+ void
+ convert_SM_to_2C_to_SM()
+ {
+ sgn = convert_signed_SM_to_2C_to_SM(sgn, nbits, ndigits, digit);
+ }
+
+ void
+ convert_SM_to_2C()
+ {
+ convert_signed_SM_to_2C(sgn, ndigits, digit);
+ }
+};
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_signed &);
+
+inline ::std::istream &operator >> (::std::istream &, sc_signed &);
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_signed_bitref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_signed_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_subref_r
+//
+// Proxy class for sc_signed part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+
+// reduce methods
+
+inline bool
+sc_signed_subref_r::and_reduce() const
+{
+ const sc_signed *target_p = m_obj_p;
+ for (int i = m_right; i <= m_left; i++)
+ if (!target_p->test(i))
+ return false;
+ return true;
+}
+
+inline bool
+sc_signed_subref_r::nand_reduce() const
+{
+ return !and_reduce();
+}
+
+inline bool
+sc_signed_subref_r::or_reduce() const
+{
+ const sc_signed *target_p = m_obj_p;
+ for (int i = m_right; i <= m_left; i++)
+ if (target_p->test(i))
+ return true;
+ return false;
+}
+
+inline bool
+sc_signed_subref_r::nor_reduce() const
+{
+ return !or_reduce();
+}
+
+inline bool
+sc_signed_subref_r::xor_reduce() const
+{
+ int odd;
+ const sc_signed *target_p = m_obj_p;
+ odd = 0;
+ for (int i = m_right; i <= m_left; i++)
+ if (target_p->test(i)) odd = ~odd;
+ return odd ? true : false;
+}
+
+inline bool
+sc_signed_subref_r::xnor_reduce() const
+{
+ return !xor_reduce();
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_signed_subref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed_subref
+//
+// Proxy class for sc_signed part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline const sc_signed_subref &
+sc_signed_subref::operator = (const char *a)
+{
+ sc_signed aa(length());
+ return (*this = aa = a);
+}
+
+
+
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_signed_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_signed
+//
+// Arbitrary precision signed number.
+// ----------------------------------------------------------------------------
+
+template<class T>
+sc_signed::sc_signed(const sc_generic_base<T> &v)
+{
+ int nb = v->length();
+ sgn = default_sign();
+ if (nb > 0) {
+ nbits = num_bits(nb);
+ } else {
+ invalid_init("sc_generic_base<T>", nb);
+ sc_core::sc_abort(); // can't recover from here
+ }
+ ndigits = DIV_CEIL(nbits);
+# ifdef SC_MAX_NBITS
+ test_bound(nb);
+# else
+ digit = new sc_digit[ndigits];
+# endif
+ makezero();
+ v->to_sc_signed(*this);
+}
+
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_signed &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_signed &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
diff --git a/src/systemc/ext/dt/int/sc_uint.hh b/src/systemc/ext/dt/int/sc_uint.hh
new file mode 100644
index 000000000..7f4a6cf2e
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_uint.hh
@@ -0,0 +1,382 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_uint.h -- An unsigned integer whose length is less than 64 bits.
+
+ Unlike arbitrary precision, arithmetic and bitwise operations
+ are performed using the native types (hence capped at 64 bits).
+ The sc_uint integer is useful when the user does not need
+ arbitrary precision and the performance is superior to
+ sc_bigint/sc_biguint.
+
+ Original Author: Amit Rao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
+ Description of Modification: - Resolved ambiguity with sc_(un)signed.
+ - Merged the code for 64- and 32-bit versions
+ via the constants in sc_nbdefs.h.
+ - Eliminated redundant file inclusions.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_uint.h,v $
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_UINT_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_UINT_HH__
+
+#include "sc_uint_base.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+template <int W>
+class sc_uint;
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_uint<W>
+//
+// Template class sc_uint<W> is the interface that the user sees. It
+// is derived from sc_uint_base and most of its methods are just
+// wrappers that call the corresponding method in the parent
+// class. Note that the length of sc_uint datatype is specified as a
+// template parameter.
+// ----------------------------------------------------------------------------
+
+template <int W>
+class sc_uint : public sc_uint_base
+{
+ public:
+ // constructors
+ sc_uint() : sc_uint_base(W) {}
+ sc_uint(uint_type v) : sc_uint_base(v, W) {}
+ sc_uint(const sc_uint<W> &a) : sc_uint_base(a) {}
+ sc_uint(const sc_uint_base &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const sc_uint_subref_r &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ template< class T >
+ sc_uint(const sc_generic_base<T> &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const sc_signed &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const sc_unsigned &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ explicit sc_uint(const sc_fxval &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ explicit sc_uint(const sc_fxval_fast &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ explicit sc_uint(const sc_fxnum &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ explicit sc_uint(const sc_fxnum_fast &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const sc_bv_base &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const sc_lv_base &a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(const char* a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(unsigned long a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(long a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(unsigned int a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(int a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(int64 a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+ sc_uint(double a) : sc_uint_base(W)
+ {
+ sc_uint_base::operator = (a);
+ }
+
+ // assignment operators
+ sc_uint<W> &
+ operator = (uint_type v)
+ {
+ sc_uint_base::operator = (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_uint_base &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_uint_subref_r &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_uint<W> &a)
+ {
+ m_val = a.m_val;
+ return *this;
+ }
+ template<class T>
+ sc_uint<W> &
+ operator = (const sc_generic_base<T> &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_signed &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_unsigned &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_fxval &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_fxval_fast &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_fxnum &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_fxnum_fast &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_bv_base &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const sc_lv_base &a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (const char* a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (unsigned long a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (long a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (unsigned int a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (int a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (int64 a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+ sc_uint<W> &
+ operator = (double a)
+ {
+ sc_uint_base::operator = (a);
+ return *this;
+ }
+
+ // arithmetic assignment operators
+ sc_uint<W> &
+ operator += (uint_type v)
+ {
+ sc_uint_base::operator += (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator -= (uint_type v)
+ {
+ sc_uint_base::operator -= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator *= (uint_type v)
+ {
+ sc_uint_base::operator *= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator /= (uint_type v)
+ {
+ sc_uint_base::operator /= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator %= (uint_type v)
+ {
+ sc_uint_base::operator %= (v);
+ return *this;
+ }
+
+ // bitwise assignment operators
+ sc_uint<W> &
+ operator &= (uint_type v)
+ {
+ sc_uint_base::operator &= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator |= (uint_type v)
+ {
+ sc_uint_base::operator |= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator ^= (uint_type v)
+ {
+ sc_uint_base::operator ^= (v);
+ return *this;
+ }
+
+ sc_uint<W> &
+ operator <<= (uint_type v)
+ {
+ sc_uint_base::operator <<= (v);
+ return *this;
+ }
+ sc_uint<W> &
+ operator >>= (uint_type v)
+ {
+ sc_uint_base::operator >>= (v);
+ return *this;
+ }
+
+ // prefix and postfix increment and decrement operators
+ sc_uint<W> &
+ operator ++ () // prefix
+ {
+ sc_uint_base::operator ++ ();
+ return *this;
+ }
+ const sc_uint<W>
+ operator ++ ( int ) // postfix
+ {
+ return sc_uint<W>(sc_uint_base::operator ++ (0));
+ }
+ sc_uint<W> &
+ operator -- () // prefix
+ {
+ sc_uint_base::operator -- ();
+ return *this;
+ }
+ const sc_uint<W>
+ operator -- (int) // postfix
+ {
+ return sc_uint<W>(sc_uint_base::operator -- (0));
+ }
+};
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_UINT_HH__
diff --git a/src/systemc/ext/dt/int/sc_uint_base.hh b/src/systemc/ext/dt/int/sc_uint_base.hh
new file mode 100644
index 000000000..28a2e8d85
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_uint_base.hh
@@ -0,0 +1,1258 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_uint_base.h -- An unsigned integer whose length is less than 64 bits.
+
+ Unlike arbitrary precision, arithmetic and bitwise operations
+ are performed using the native types (hence capped at 64 bits).
+ The sc_uint integer is useful when the user does not need
+ arbitrary precision and the performance is superior to
+ sc_bigint/sc_biguint.
+
+ Original Author: Amit Rao, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
+ Description of Modification: - Resolved ambiguity with sc_(un)signed.
+ - Merged the code for 64- and 32-bit versions
+ via the constants in sc_nbdefs.h.
+ - Eliminated redundant file inclusions.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_uint_base.h,v $
+// Revision 1.3 2011/08/24 22:05:46 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.4 2006/05/08 17:50:02 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_UINT_BASE_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_UINT_BASE_HH__
+
+#include <iostream>
+
+#include "../fx/scfx_ieee.hh"
+#include "../misc/sc_value_base.hh"
+#include "../sc_temporary.hh"
+#include "sc_length_param.hh"
+#include "sc_nbdefs.hh"
+
+namespace sc_dt
+{
+
+class sc_concatref;
+
+// classes defined in this module
+class sc_uint_bitref_r;
+class sc_uint_bitref;
+class sc_uint_subref_r;
+class sc_uint_subref;
+class sc_uint_base;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_int_subref_r;
+class sc_signed_subref_r;
+class sc_unsigned_subref_r;
+class sc_signed;
+class sc_unsigned;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+} // namespace sc_dt
+
+// extern template instantiations
+namespace sc_core
+{
+
+extern template class sc_vpool<sc_dt::sc_uint_bitref>;
+extern template class sc_vpool<sc_dt::sc_uint_subref>;
+
+} // namespace sc_core
+
+namespace sc_dt
+{
+
+extern const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH];
+
+// friend operator declarations
+inline bool operator == (const sc_uint_base &a, const sc_uint_base &b);
+inline bool operator != (const sc_uint_base &a, const sc_uint_base &b);
+inline bool operator < (const sc_uint_base &a, const sc_uint_base &b);
+inline bool operator <= (const sc_uint_base &a, const sc_uint_base &b);
+inline bool operator > (const sc_uint_base &a, const sc_uint_base &b);
+inline bool operator >= (const sc_uint_base &a, const sc_uint_base &b);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_bitref_r
+//
+// Proxy class for sc_uint bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_uint_bitref_r : public sc_value_base
+{
+ friend class sc_uint_base;
+ friend class sc_uint_signal;
+
+ // constructors
+ public:
+ sc_uint_bitref_r(const sc_uint_bitref_r &init) :
+ sc_value_base(init), m_index(init.m_index), m_obj_p(init.m_obj_p)
+ {}
+
+ protected:
+ sc_uint_bitref_r() : sc_value_base(), m_index(0), m_obj_p(0) {}
+
+ // initializer for sc_core::sc_vpool:
+ void
+ initialize(const sc_uint_base* obj_p, int index_)
+ {
+ m_obj_p = (sc_uint_base *)obj_p;
+ m_index = index_;
+ }
+
+ public:
+ // destructor
+ virtual ~sc_uint_bitref_r() {}
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return 1;
+ }
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+
+ dst_p[word_i] &= ~bit_mask;
+ return false;
+ }
+ virtual bool
+ concat_get_data(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ bool result; // True is non-zero.
+ int word_i = low_i / BITS_PER_DIGIT;
+
+ if (operator uint64()) {
+ dst_p[word_i] |= bit_mask;
+ result = true;
+ } else {
+ dst_p[word_i] &= ~bit_mask;
+ result = false;
+ }
+ return result;
+ }
+ virtual uint64 concat_get_uint64() const { return operator uint64(); }
+
+ // capacity
+ int length() const { return 1; }
+
+ // implicit conversion to uint64
+ operator uint64 () const;
+ bool operator ! () const;
+ bool operator ~ () const;
+
+ // explicit conversions
+ uint64 value() const { return operator uint64 (); }
+ bool to_bool() const { return operator uint64 (); }
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_bool(); }
+
+ protected:
+ int m_index;
+ sc_uint_base *m_obj_p;
+
+ private:
+ // Disabled
+ sc_uint_bitref_r &operator = (const sc_uint_bitref_r &);
+};
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_uint_bitref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_bitref
+//
+// Proxy class for sc_uint bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_uint_bitref : public sc_uint_bitref_r
+{
+ friend class sc_uint_base;
+ friend class sc_core::sc_vpool<sc_uint_bitref>;
+
+ // constructors
+ protected:
+ sc_uint_bitref() : sc_uint_bitref_r() {}
+
+ public:
+ sc_uint_bitref(const sc_uint_bitref &init) : sc_uint_bitref_r(init) {}
+
+ public:
+ // assignment operators
+ sc_uint_bitref &operator = (const sc_uint_bitref_r &b);
+ sc_uint_bitref &operator = (const sc_uint_bitref &b);
+ sc_uint_bitref &operator = (bool b);
+
+ sc_uint_bitref &operator &= (bool b);
+ sc_uint_bitref &operator |= (bool b);
+ sc_uint_bitref &operator ^= (bool b);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_uint_bitref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_uint_bitref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_subref_r
+//
+// Proxy class for sc_uint part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_uint_subref_r : public sc_value_base
+{
+ friend class sc_uint_base;
+ friend class sc_uint_subref;
+
+ // constructors
+ public:
+ sc_uint_subref_r( const sc_uint_subref_r& init ) :
+ sc_value_base(init), m_left(init.m_left), m_obj_p(init.m_obj_p),
+ m_right(init.m_right)
+ {}
+
+ protected:
+ sc_uint_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0) {}
+
+ // initializer for sc_core::sc_vpool:
+ void
+ initialize(const sc_uint_base *obj_p, int left_i, int right_i)
+ {
+ m_obj_p = (sc_uint_base *)obj_p;
+ m_left = left_i;
+ m_right = right_i;
+ }
+
+ public:
+ // destructor
+ virtual ~sc_uint_subref_r() {}
+
+ // capacity
+ int length() const { return (m_left - m_right + 1); }
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return length();
+ }
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+ virtual uint64
+ concat_get_uint64() const
+ {
+ return (uint64)operator uint_type();
+ }
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return !or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return !xor_reduce(); }
+
+ // implicit conversion to uint_type
+ operator uint_type() const;
+
+ // explicit conversions
+ uint_type value() const { return operator uint_type(); }
+
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ protected:
+ int m_left;
+ sc_uint_base *m_obj_p;
+ int m_right;
+
+ private:
+ // Disabled
+ sc_uint_subref_r &operator = (const sc_uint_subref_r &);
+};
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_uint_subref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_subref
+//
+// Proxy class for sc_uint part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_uint_subref : public sc_uint_subref_r
+{
+ friend class sc_uint_base;
+ friend class sc_core::sc_vpool<sc_uint_subref>;
+
+ // constructors
+ protected:
+ sc_uint_subref() : sc_uint_subref_r() {}
+
+ public:
+ sc_uint_subref(const sc_uint_subref &init) : sc_uint_subref_r(init) {}
+
+ public:
+ // assignment operators
+ sc_uint_subref &operator = (uint_type v);
+ sc_uint_subref &operator = (const sc_uint_base &a);
+ sc_uint_subref &
+ operator = (const sc_uint_subref_r &a)
+ {
+ return operator = (a.operator uint_type());
+ }
+ sc_uint_subref &
+ operator = (const sc_uint_subref &a)
+ {
+ return operator = (a.operator uint_type());
+ }
+ template<class T>
+ sc_uint_subref &
+ operator = (const sc_generic_base<T> &a)
+ {
+ return operator = (a->to_uint64());
+ }
+ sc_uint_subref &operator = (const char *a);
+ sc_uint_subref &
+ operator = (unsigned long a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &
+ operator = (long a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &
+ operator = (unsigned int a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &
+ operator = (int a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &
+ operator = (int64 a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &
+ operator = (double a)
+ {
+ return operator = ((uint_type)a);
+ }
+ sc_uint_subref &operator = (const sc_signed &);
+ sc_uint_subref &operator = (const sc_unsigned &);
+ sc_uint_subref &operator = (const sc_bv_base &);
+ sc_uint_subref &operator = (const sc_lv_base &);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_uint_subref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_uint_subref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_base
+//
+// Base class for sc_uint.
+// ----------------------------------------------------------------------------
+
+class sc_uint_base : public sc_value_base
+{
+ friend class sc_uint_bitref_r;
+ friend class sc_uint_bitref;
+ friend class sc_uint_subref_r;
+ friend class sc_uint_subref;
+
+ // support methods
+ void invalid_length() const;
+ void invalid_index(int i) const;
+ void invalid_range(int l, int r) const;
+
+ void
+ check_length() const
+ {
+ if (m_len <= 0 || m_len > SC_INTWIDTH) {
+ invalid_length();
+ }
+ }
+
+ void
+ check_index(int i) const
+ {
+ if (i < 0 || i >= m_len) {
+ invalid_index( i );
+ }
+ }
+
+ void
+ check_range(int l, int r) const
+ {
+ if (r < 0 || l >= m_len || l < r) {
+ invalid_range( l, r );
+ }
+ }
+
+ void check_value() const;
+
+ void
+ extend_sign()
+ {
+#ifdef DEBUG_SYSTEMC
+ check_value();
+#endif
+ m_val &= (~UINT_ZERO >> m_ulen);
+ }
+
+ public:
+ // constructors
+ explicit sc_uint_base(int w=sc_length_param().len()) :
+ m_val(0), m_len(w), m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ }
+
+ sc_uint_base(uint_type v, int w) :
+ m_val(v), m_len(w), m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ extend_sign();
+ }
+
+ sc_uint_base(const sc_uint_base &a) :
+ sc_value_base(a), m_val(a.m_val), m_len(a.m_len), m_ulen(a.m_ulen)
+ {}
+
+ explicit sc_uint_base(const sc_uint_subref_r &a) :
+ m_val(a), m_len(a.length()), m_ulen(SC_INTWIDTH - m_len)
+ {
+ extend_sign();
+ }
+
+ template<class T>
+ explicit sc_uint_base(const sc_generic_base<T> &a) :
+ m_val(a->to_uint64()), m_len(a->length()),
+ m_ulen(SC_INTWIDTH - m_len)
+ {
+ check_length();
+ extend_sign();
+ }
+
+ explicit sc_uint_base(const sc_bv_base &v);
+ explicit sc_uint_base(const sc_lv_base &v);
+ explicit sc_uint_base(const sc_int_subref_r &v);
+ explicit sc_uint_base(const sc_signed_subref_r &v);
+ explicit sc_uint_base(const sc_unsigned_subref_r &v);
+ explicit sc_uint_base(const sc_signed &a);
+ explicit sc_uint_base(const sc_unsigned &a);
+
+ // destructor
+ virtual ~sc_uint_base() {}
+
+ // assignment operators
+ sc_uint_base &
+ operator = (uint_type v)
+ {
+ m_val = v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (const sc_uint_base &a)
+ {
+ m_val = a.m_val;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (const sc_uint_subref_r &a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ template<class T>
+ sc_uint_base &
+ operator = (const sc_generic_base<T> &a)
+ {
+ m_val = a->to_uint64();
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &operator = (const sc_signed &a);
+ sc_uint_base &operator = (const sc_unsigned &a);
+ sc_uint_base &operator = (const sc_fxval &a);
+ sc_uint_base &operator = (const sc_fxval_fast &a);
+ sc_uint_base &operator = (const sc_fxnum &a);
+ sc_uint_base &operator = (const sc_fxnum_fast &a);
+ sc_uint_base &operator = (const sc_bv_base &a);
+ sc_uint_base &operator = (const sc_lv_base &a);
+ sc_uint_base &operator = (const char *a);
+ sc_uint_base &
+ operator = (unsigned long a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (long a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (unsigned int a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (int a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (int64 a)
+ {
+ m_val = a;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator = (double a)
+ {
+ m_val = (uint_type)a;
+ extend_sign();
+ return *this;
+ }
+
+ // arithmetic assignment operators
+ sc_uint_base &
+ operator += (uint_type v)
+ {
+ m_val += v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator -= (uint_type v)
+ {
+ m_val -= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator *= (uint_type v)
+ {
+ m_val *= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator /= (uint_type v)
+ {
+ m_val /= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator %= (uint_type v)
+ {
+ m_val %= v;
+ extend_sign();
+ return *this;
+ }
+
+ // bitwise assignment operators
+ sc_uint_base &
+ operator &= (uint_type v)
+ {
+ m_val &= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator |= (uint_type v)
+ {
+ m_val |= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator ^= (uint_type v)
+ {
+ m_val ^= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator <<= (uint_type v)
+ {
+ m_val <<= v;
+ extend_sign();
+ return *this;
+ }
+ sc_uint_base &
+ operator >>= (uint_type v)
+ {
+ m_val >>= v;
+ /* no sign extension needed */
+ return *this;
+ }
+
+ // prefix and postfix increment and decrement operators
+ sc_uint_base &
+ operator ++ () // prefix
+ {
+ ++m_val;
+ extend_sign();
+ return *this;
+ }
+ const sc_uint_base
+ operator ++ (int) // postfix
+ {
+ sc_uint_base tmp(*this);
+ ++m_val;
+ extend_sign();
+ return tmp;
+ }
+
+ sc_uint_base &
+ operator -- () // prefix
+ {
+ --m_val;
+ extend_sign();
+ return *this;
+ }
+ const sc_uint_base
+ operator -- (int) // postfix
+ {
+ sc_uint_base tmp(*this);
+ --m_val;
+ extend_sign();
+ return tmp;
+ }
+
+ // relational operators
+ friend bool
+ operator == (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val == b.m_val;
+ }
+ friend bool
+ operator != (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val != b.m_val;
+ }
+ friend bool
+ operator < (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val < b.m_val;
+ }
+ friend bool
+ operator <= (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val <= b.m_val;
+ }
+ friend bool
+ operator > (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val > b.m_val;
+ }
+ friend bool
+ operator >= (const sc_uint_base &a, const sc_uint_base &b)
+ {
+ return a.m_val >= b.m_val;
+ }
+
+ // bit selection
+ sc_uint_bitref &operator [] (int i);
+ const sc_uint_bitref_r &operator [] (int i) const;
+
+ sc_uint_bitref &bit(int i);
+ const sc_uint_bitref_r &bit(int i) const;
+
+ // part selection
+ sc_uint_subref &operator () (int left, int right);
+ const sc_uint_subref_r &operator () (int left, int right) const;
+
+ sc_uint_subref &range(int left, int right);
+ const sc_uint_subref_r &range(int left, int right) const;
+
+ // bit access, without bounds checking or sign extension
+ bool test(int i) const { return (0 != (m_val & (UINT_ONE << i))); }
+
+ void set(int i) { m_val |= (UINT_ONE << i); }
+ void
+ set(int i, bool v)
+ {
+ v ? m_val |= (UINT_ONE << i) : m_val &= ~(UINT_ONE << i);
+ }
+
+ // capacity
+ int length() const { return m_len; }
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return length();
+ }
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data( sc_digit *dst_p, int low_i) const;
+ virtual uint64 concat_get_uint64() const { return m_val; }
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return !or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return !xor_reduce(); }
+
+ // implicit conversion to uint_type
+ operator uint_type() const { return m_val; }
+
+ // explicit conversions
+ uint_type value() const { return operator uint_type(); }
+
+ int to_int() const { return (int) m_val; }
+ unsigned int to_uint() const { return (unsigned int)m_val; }
+ long to_long() const { return (long)m_val; }
+ unsigned long to_ulong() const { return (unsigned long)m_val; }
+ int64 to_int64() const { return (int64)m_val; }
+ uint64 to_uint64() const { return (uint64)m_val; }
+ double to_double() const { return uint64_to_double(m_val); }
+
+ long long_low() const { return (long)(m_val & UINT64_32ONES); }
+ long long_high() const { return (long)((m_val >> 32) & UINT64_32ONES); }
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ uint_type m_val; // value
+ int m_len; // length
+ int m_ulen; // unused length
+};
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_uint_base &);
+inline ::std::istream &operator >> (::std::istream &, sc_uint_base &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_bitref_r
+//
+// Proxy class for sc_uint bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// implicit conversion to bool
+
+inline sc_uint_bitref_r::operator uint64 () const
+{
+ return m_obj_p->test(m_index);
+}
+
+inline bool
+sc_uint_bitref_r::operator ! () const
+{
+ return !m_obj_p->test(m_index);
+}
+
+inline bool
+sc_uint_bitref_r::operator ~ () const
+{
+ return !m_obj_p->test(m_index);
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_uint_bitref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_bitref
+//
+// Proxy class for sc_uint bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator = (const sc_uint_bitref_r &b)
+{
+ m_obj_p->set(m_index, b.to_bool());
+ return *this;
+}
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator = (const sc_uint_bitref &b)
+{
+ m_obj_p->set(m_index, b.to_bool());
+ return *this;
+}
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator = (bool b)
+{
+ m_obj_p->set(m_index, b);
+ return *this;
+}
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator &= (bool b)
+{
+ if (!b) {
+ m_obj_p->set(m_index, b);
+ }
+ return *this;
+}
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator |= (bool b)
+{
+ if (b) {
+ m_obj_p->set(m_index, b);
+ }
+ return *this;
+}
+
+inline sc_uint_bitref &
+sc_uint_bitref::operator ^= (bool b)
+{
+ if (b) {
+ m_obj_p->m_val ^= (UINT_ONE << m_index);
+ }
+ return *this;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_uint_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_subref_r
+//
+// Proxy class for sc_uint part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// implicit conversion to uint_type
+
+inline sc_uint_subref_r::operator uint_type() const
+{
+ uint_type val = m_obj_p->m_val;
+ int uleft = SC_INTWIDTH - (m_left + 1);
+ return ((val & (~UINT_ZERO >> uleft)) >> m_right);
+}
+
+
+// reduce methods
+inline bool
+sc_uint_subref_r::and_reduce() const
+{
+ sc_uint_base a(*this);
+ return a.and_reduce();
+}
+inline bool
+sc_uint_subref_r::or_reduce() const
+{
+ sc_uint_base a(*this);
+ return a.or_reduce();
+}
+inline bool
+sc_uint_subref_r::xor_reduce() const
+{
+ sc_uint_base a(*this);
+ return a.xor_reduce();
+}
+
+// explicit conversions
+inline int
+sc_uint_subref_r::to_int() const
+{
+ sc_uint_base a(*this);
+ return a.to_int();
+}
+inline unsigned int
+sc_uint_subref_r::to_uint() const
+{
+ sc_uint_base a(*this);
+ return a.to_uint();
+}
+inline long
+sc_uint_subref_r::to_long() const
+{
+ sc_uint_base a(*this);
+ return a.to_long();
+}
+inline unsigned long
+sc_uint_subref_r::to_ulong() const
+{
+ sc_uint_base a(*this);
+ return a.to_ulong();
+}
+inline int64
+sc_uint_subref_r::to_int64() const
+{
+ sc_uint_base a(*this);
+ return a.to_int64();
+}
+inline uint64
+sc_uint_subref_r::to_uint64() const
+{
+ sc_uint_base a(*this);
+ return a.to_uint64();
+}
+inline double
+sc_uint_subref_r::to_double() const
+{
+ sc_uint_base a(*this);
+ return a.to_double();
+}
+
+// explicit conversion to character string
+inline const std::string
+sc_uint_subref_r::to_string(sc_numrep numrep) const
+{
+ sc_uint_base a(*this);
+ return a.to_string(numrep);
+}
+
+inline const std::string
+sc_uint_subref_r::to_string(sc_numrep numrep, bool w_prefix) const
+{
+ sc_uint_base a(*this);
+ return a.to_string(numrep, w_prefix);
+}
+
+// functional notation for the reduce methods
+inline bool
+and_reduce(const sc_uint_subref_r &a)
+{
+ return a.and_reduce();
+}
+inline bool
+nand_reduce(const sc_uint_subref_r &a)
+{
+ return a.nand_reduce();
+}
+inline bool
+or_reduce(const sc_uint_subref_r &a)
+{
+ return a.or_reduce();
+}
+inline bool
+nor_reduce(const sc_uint_subref_r &a)
+{
+ return a.nor_reduce();
+}
+inline bool
+xor_reduce(const sc_uint_subref_r &a)
+{
+ return a.xor_reduce();
+}
+inline bool
+xnor_reduce(const sc_uint_subref_r &a)
+{
+ return a.xnor_reduce();
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_uint_subref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_subref
+//
+// Proxy class for sc_uint part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline sc_uint_subref &
+sc_uint_subref::operator = (const sc_uint_base &a)
+{
+ return operator = (a.operator uint_type());
+}
+
+inline sc_uint_subref &
+sc_uint_subref::operator = (const char *a)
+{
+ sc_uint_base aa(length());
+ return (*this = aa = a);
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_uint_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_uint_base
+//
+// Base class for sc_uint.
+// ----------------------------------------------------------------------------
+
+// bit selection
+inline sc_uint_bitref &
+sc_uint_base::operator [] (int i)
+{
+ check_index(i);
+ sc_uint_bitref *result_p = sc_uint_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+inline const sc_uint_bitref_r &
+sc_uint_base::operator [] (int i) const
+{
+ check_index(i);
+ sc_uint_bitref *result_p = sc_uint_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+inline sc_uint_bitref &
+sc_uint_base::bit(int i)
+{
+ check_index(i);
+ sc_uint_bitref *result_p = sc_uint_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+inline const sc_uint_bitref_r &
+sc_uint_base::bit(int i) const
+{
+ check_index(i);
+ sc_uint_bitref *result_p = sc_uint_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+}
+
+// part selection
+inline sc_uint_subref &
+sc_uint_base::operator () (int left, int right)
+{
+ check_range(left, right);
+ sc_uint_subref *result_p = sc_uint_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+inline const sc_uint_subref_r &
+sc_uint_base::operator () (int left, int right) const
+{
+ check_range(left, right);
+ sc_uint_subref *result_p = sc_uint_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+inline sc_uint_subref &
+sc_uint_base::range(int left, int right)
+{
+ check_range(left, right);
+ sc_uint_subref *result_p = sc_uint_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+inline const sc_uint_subref_r &
+sc_uint_base::range(int left, int right) const
+{
+ check_range(left, right);
+ sc_uint_subref *result_p = sc_uint_subref::m_pool.allocate();
+ result_p->initialize(this, left, right);
+ return *result_p;
+}
+
+// functional notation for the reduce methods
+inline bool
+and_reduce(const sc_uint_base &a)
+{
+ return a.and_reduce();
+}
+inline bool
+nand_reduce(const sc_uint_base &a)
+{
+ return a.nand_reduce();
+}
+inline bool
+or_reduce(const sc_uint_base &a)
+{
+ return a.or_reduce();
+}
+inline bool
+nor_reduce(const sc_uint_base &a)
+{
+ return a.nor_reduce();
+}
+inline bool
+xor_reduce(const sc_uint_base &a)
+{
+ return a.xor_reduce();
+}
+inline bool
+xnor_reduce(const sc_uint_base &a)
+{
+ return a.xnor_reduce();
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_uint_base &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_uint_base &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_UINT_BASE_HH__
diff --git a/src/systemc/ext/dt/int/sc_unsigned.hh b/src/systemc/ext/dt/int/sc_unsigned.hh
new file mode 100644
index 000000000..8927c12cb
--- /dev/null
+++ b/src/systemc/ext/dt/int/sc_unsigned.hh
@@ -0,0 +1,2195 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_unsigned.h -- Arbitrary precision unsigned arithmetic.
+
+ This file includes the definitions of sc_unsigned_bitref,
+ sc_unsigned_subref, and sc_unsigned classes. The first two classes
+ are proxy classes to reference one bit and a range of bits of a
+ sc_unsigned number, respectively.
+
+ An sc_signed number has the sign-magnitude representation
+ internally. However, its interface guarantees a 2's-complement
+ representation. The sign-magnitude representation is chosen
+ because of its efficiency: The sc_signed and sc_unsigned types are
+ optimized for arithmetic rather than bitwise operations. For
+ arithmetic operations, the sign-magnitude representation performs
+ better.
+
+ It is also important to note that an sc_unsigned number with n
+ bits is equivalent to an sc_signed non-negative number with n + 1
+ bits.
+
+ The implementations of sc_signed and sc_unsigned classes are
+ almost identical: Most of the member and friend functions are
+ defined in sc_nbcommon.cpp and sc_nbfriends.cpp so that they can
+ be shared by both of these classes. These functions are chosed by
+ defining a few macros before including them such as IF_SC_SIGNED
+ and CLASS_TYPE. Our implementation choices are mostly dictated by
+ performance considerations in that we tried to provide the most
+ efficient sc_signed and sc_unsigned types without compromising
+ their interface.
+
+ For the behavior of operators, we have two semantics: the old and
+ new. The most important difference between these two semantics is
+ that the old semantics is closer to C/C++ semantics in that the
+ result type of a binary operator on unsigned and signed arguments
+ is unsigned; the new semantics, on the other hand, requires the
+ result type be signed. The new semantics is required by the VSIA
+ C/C++ data types standard. We have implemented the new semantics.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_unsigned.h,v $
+// Revision 1.4 2011/08/24 22:05:46 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.3 2011/02/18 20:19:15 acg
+// Andy Goodrich: updating Copyright notice.
+//
+// Revision 1.2 2009/02/28 00:26:26 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.5 2006/05/08 17:50:02 acg
+// Andy Goodrich: Added David Long's declarations for friend operators,
+// functions, and methods, to keep the Microsoft compiler happy.
+//
+// Revision 1.4 2006/03/13 20:25:27 acg
+// Andy Goodrich: Addition of function declarations, e.g., xor_signed_friend()
+// to keep gcc 4.x happy.
+//
+// Revision 1.3 2006/01/13 18:49:32 acg
+// Added $Log command so that CVS check in comments are reproduced in the
+// source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_INT_SC_UNSIGNED_HH__
+#define __SYSTEMC_EXT_DT_INT_SC_UNSIGNED_HH__
+
+#include <iostream>
+
+#include "../misc/sc_value_base.hh"
+#include "../sc_temporary.hh"
+#include "sc_length_param.hh"
+#include "sc_nbdefs.hh"
+#include "sc_nbexterns.hh"
+#include "sc_nbutils.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_unsigned_bitref_r;
+class sc_unsigned_bitref;
+class sc_unsigned_subref_r;
+class sc_unsigned_subref;
+class sc_concatref;
+class sc_unsigned;
+
+// forward class declarations
+class sc_bv_base;
+class sc_lv_base;
+class sc_int_base;
+class sc_uint_base;
+class sc_int_subref_r;
+class sc_uint_subref_r;
+class sc_signed;
+class sc_signed_subref_r;
+class sc_fxval;
+class sc_fxval_fast;
+class sc_fxnum;
+class sc_fxnum_fast;
+
+} // namespace sc_dt
+
+// extern template instantiations
+namespace sc_core
+{
+
+extern template class sc_vpool<sc_dt::sc_unsigned_bitref>;
+extern template class sc_vpool<sc_dt::sc_unsigned_subref>;
+extern template class sc_vpool<sc_dt::sc_unsigned>;
+
+} // namespace sc_core
+
+namespace sc_dt
+{
+
+// Helper function declarions
+int compare_unsigned(small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd,
+ small_type if_u_signed=0, small_type if_v_signed=0);
+
+sc_unsigned add_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned sub_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned mul_unsigned_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned div_unsigned_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned mod_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned and_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+
+sc_unsigned or_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+sc_unsigned xor_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+
+/*
+ * friend operator declarations
+ */
+
+// ARITHMETIC OPERATORS:
+
+// ADDition operators:
+sc_signed operator + (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator + (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator + (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator + (const sc_unsigned &u, int64 v);
+sc_unsigned operator + (const sc_unsigned &u, uint64 v);
+sc_signed operator + (const sc_unsigned &u, long v);
+sc_unsigned operator + (const sc_unsigned &u, unsigned long v);
+sc_signed operator + (const sc_unsigned &u, int v);
+inline sc_unsigned operator + (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator + (int64 u, const sc_unsigned &v);
+sc_unsigned operator + (uint64 u, const sc_unsigned &v);
+sc_signed operator + (long u, const sc_unsigned &v);
+sc_unsigned operator + (unsigned long u, const sc_unsigned &v);
+sc_signed operator + (int u, const sc_unsigned &v);
+inline sc_unsigned operator + (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator + (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator + (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
+
+// SUBtraction operators:
+sc_signed operator - (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator - (const sc_signed &u, const sc_unsigned &v);
+
+sc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator - (const sc_unsigned &u, int64 v);
+sc_signed operator - (const sc_unsigned &u, uint64 v);
+sc_signed operator - (const sc_unsigned &u, long v);
+sc_signed operator - (const sc_unsigned &u, unsigned long v);
+sc_signed operator - (const sc_unsigned &u, int v);
+sc_signed operator - (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator - (int64 u, const sc_unsigned &v);
+sc_signed operator - (uint64 u, const sc_unsigned &v);
+sc_signed operator - (long u, const sc_unsigned &v);
+sc_signed operator - (unsigned long u, const sc_unsigned &v);
+sc_signed operator - (int u, const sc_unsigned &v);
+sc_signed operator - (unsigned int u, const sc_unsigned &v);
+
+sc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
+sc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
+
+// MULtiplication operators:
+sc_signed operator * (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator * (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator * (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator * (const sc_unsigned &u, int64 v);
+sc_unsigned operator * (const sc_unsigned &u, uint64 v);
+sc_signed operator * (const sc_unsigned &u, long v);
+sc_unsigned operator * (const sc_unsigned &u, unsigned long v);
+sc_signed operator * (const sc_unsigned &u, int v);
+inline sc_unsigned operator * (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator * (int64 u, const sc_unsigned &v);
+sc_unsigned operator * (uint64 u, const sc_unsigned &v);
+sc_signed operator * (long u, const sc_unsigned &v);
+sc_unsigned operator * (unsigned long u, const sc_unsigned &v);
+sc_signed operator * (int u, const sc_unsigned &v);
+inline sc_unsigned operator * (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator * (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator * (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
+
+// DIVision operators:
+sc_signed operator / (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator / (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator / (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator / (const sc_unsigned &u, int64 v);
+sc_unsigned operator / (const sc_unsigned &u, uint64 v);
+sc_signed operator / (const sc_unsigned &u, long v);
+sc_unsigned operator / (const sc_unsigned &u, unsigned long v);
+sc_signed operator / (const sc_unsigned &u, int v);
+inline sc_unsigned operator / (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator / (int64 u, const sc_unsigned &v);
+sc_unsigned operator / (uint64 u, const sc_unsigned &v);
+sc_signed operator / (long u, const sc_unsigned &v);
+sc_unsigned operator / (unsigned long u, const sc_unsigned &v);
+sc_signed operator / (int u, const sc_unsigned &v);
+inline sc_unsigned operator / (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator / (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator / (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
+
+// MODulo operators:
+sc_signed operator % (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator % (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator % (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator % (const sc_unsigned &u, int64 v);
+sc_unsigned operator % (const sc_unsigned &u, uint64 v);
+sc_signed operator % (const sc_unsigned &u, long v);
+sc_unsigned operator % (const sc_unsigned &u, unsigned long v);
+sc_signed operator % (const sc_unsigned &u, int v);
+inline sc_unsigned operator % (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator % (int64 u, const sc_unsigned &v);
+sc_unsigned operator % (uint64 u, const sc_unsigned &v);
+sc_signed operator % (long u, const sc_unsigned &v);
+sc_unsigned operator % (unsigned long u, const sc_unsigned &v);
+sc_signed operator % (int u, const sc_unsigned &v);
+inline sc_unsigned operator % (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator % (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator % (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
+
+// BITWISE OPERATORS:
+
+// Bitwise AND operators:
+sc_signed operator & (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator & (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator & (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator & (const sc_unsigned &u, int64 v);
+sc_unsigned operator & (const sc_unsigned &u, uint64 v);
+sc_signed operator & (const sc_unsigned &u, long v);
+sc_unsigned operator & (const sc_unsigned &u, unsigned long v);
+sc_signed operator & (const sc_unsigned &u, int v);
+inline sc_unsigned operator & (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator & (int64 u, const sc_unsigned &v);
+sc_unsigned operator & (uint64 u, const sc_unsigned &v);
+sc_signed operator & (long u, const sc_unsigned &v);
+sc_unsigned operator & (unsigned long u, const sc_unsigned &v);
+sc_signed operator & (int u, const sc_unsigned &v);
+inline sc_unsigned operator & (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator & (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator & (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
+
+// Bitwise OR operators:
+sc_signed operator | (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator | (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator | (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator | (const sc_unsigned &u, int64 v);
+sc_unsigned operator | (const sc_unsigned &u, uint64 v);
+sc_signed operator | (const sc_unsigned &u, long v);
+sc_unsigned operator | (const sc_unsigned &u, unsigned long v);
+sc_signed operator | (const sc_unsigned &u, int v);
+inline sc_unsigned operator | (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator | (int64 u, const sc_unsigned &v);
+sc_unsigned operator | (uint64 u, const sc_unsigned &v);
+sc_signed operator | (long u, const sc_unsigned &v);
+sc_unsigned operator | (unsigned long u, const sc_unsigned &v);
+sc_signed operator | (int u, const sc_unsigned &v);
+inline sc_unsigned operator | (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator | (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator | (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
+
+// Bitwise XOR operators:
+sc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator ^ (const sc_unsigned &u, const sc_unsigned &v);
+sc_signed operator ^ (const sc_unsigned &u, int64 v);
+sc_unsigned operator ^ (const sc_unsigned &u, uint64 v);
+sc_signed operator ^ (const sc_unsigned &u, long v);
+sc_unsigned operator ^ (const sc_unsigned &u, unsigned long v);
+sc_signed operator ^ (const sc_unsigned &u, int v);
+inline sc_unsigned operator ^ (const sc_unsigned &u, unsigned int v);
+
+sc_signed operator ^ (int64 u, const sc_unsigned &v);
+sc_unsigned operator ^ (uint64 u, const sc_unsigned &v);
+sc_signed operator ^ (long u, const sc_unsigned &v);
+sc_unsigned operator ^ (unsigned long u, const sc_unsigned &v);
+sc_signed operator ^ (int u, const sc_unsigned &v);
+inline sc_unsigned operator ^ (unsigned int u, const sc_unsigned &v);
+
+sc_unsigned operator ^ (const sc_unsigned &u, const sc_uint_base &v);
+sc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
+sc_unsigned operator ^ (const sc_uint_base &u, const sc_unsigned &v);
+sc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
+
+// SHIFT OPERATORS:
+
+// LEFT SHIFT operators:
+sc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator << (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator << (const sc_unsigned &u, const sc_unsigned &v);
+sc_unsigned operator << (const sc_unsigned &u, int64 v);
+sc_unsigned operator << (const sc_unsigned &u, uint64 v);
+sc_unsigned operator << (const sc_unsigned &u, long v);
+sc_unsigned operator << (const sc_unsigned &u, unsigned long v);
+inline sc_unsigned operator << (const sc_unsigned &u, int v);
+inline sc_unsigned operator << (const sc_unsigned &u, unsigned int v);
+
+sc_unsigned operator << (const sc_unsigned &u, const sc_uint_base &v);
+sc_unsigned operator << (const sc_unsigned &u, const sc_int_base &v);
+
+// RIGHT SHIFT operators:
+sc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
+sc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
+
+sc_unsigned operator >> (const sc_unsigned &u, const sc_unsigned &v);
+sc_unsigned operator >> (const sc_unsigned &u, int64 v);
+sc_unsigned operator >> (const sc_unsigned &u, uint64 v);
+sc_unsigned operator >> (const sc_unsigned &u, long v);
+sc_unsigned operator >> (const sc_unsigned &u, unsigned long v);
+inline sc_unsigned operator >> (const sc_unsigned &u, int v);
+inline sc_unsigned operator >> (const sc_unsigned &u, unsigned int v);
+
+sc_unsigned operator >> ( const sc_unsigned &, const sc_uint_base &);
+sc_unsigned operator >> ( const sc_unsigned&, const sc_int_base &);
+
+// Unary arithmetic operators
+sc_unsigned operator + (const sc_unsigned &u);
+sc_signed operator - (const sc_unsigned &u);
+
+// LOGICAL OPERATORS:
+
+// Logical EQUAL operators:
+bool operator == (const sc_unsigned &u, const sc_signed &v);
+bool operator == (const sc_signed &u, const sc_unsigned &v);
+
+bool operator == (const sc_unsigned &u, const sc_unsigned &v);
+bool operator == (const sc_unsigned &u, int64 v);
+bool operator == (const sc_unsigned &u, uint64 v);
+bool operator == (const sc_unsigned &u, long v);
+bool operator == (const sc_unsigned &u, unsigned long v);
+inline bool operator == (const sc_unsigned &u, int v);
+inline bool operator == (const sc_unsigned &u, unsigned int v);
+
+bool operator == (int64 u, const sc_unsigned &v);
+bool operator == (uint64 u, const sc_unsigned &v);
+bool operator == (long u, const sc_unsigned &v);
+bool operator == (unsigned long u, const sc_unsigned &v);
+inline bool operator == (int u, const sc_unsigned &v);
+inline bool operator == (unsigned int u, const sc_unsigned &v) ;
+
+bool operator == (const sc_unsigned &u, const sc_uint_base &v);
+bool operator == (const sc_unsigned &u, const sc_int_base &v);
+bool operator == (const sc_uint_base &u, const sc_unsigned &v);
+bool operator == (const sc_int_base &u, const sc_unsigned &v);
+
+// Logical NOT_EQUAL operators:
+bool operator != (const sc_unsigned &u, const sc_signed &v);
+bool operator != (const sc_signed &u, const sc_unsigned &v);
+
+bool operator != (const sc_unsigned &u, const sc_unsigned &v);
+bool operator != (const sc_unsigned &u, int64 v);
+bool operator != (const sc_unsigned &u, uint64 v);
+bool operator != (const sc_unsigned &u, long v);
+bool operator != (const sc_unsigned &u, unsigned long v);
+inline bool operator != (const sc_unsigned &u, int v);
+inline bool operator != (const sc_unsigned &u, unsigned int v);
+
+bool operator != (int64 u, const sc_unsigned &v);
+bool operator != (uint64 u, const sc_unsigned &v);
+bool operator != (long u, const sc_unsigned &v);
+bool operator != (unsigned long u, const sc_unsigned &v);
+inline bool operator != (int u, const sc_unsigned &v);
+inline bool operator != (unsigned int u, const sc_unsigned &v);
+
+bool operator != (const sc_unsigned &u, const sc_uint_base &v);
+bool operator != (const sc_unsigned &u, const sc_int_base &v);
+bool operator != (const sc_uint_base &u, const sc_unsigned &v);
+bool operator != (const sc_int_base &u, const sc_unsigned &v);
+
+// Logical LESS_THAN operators:
+bool operator < (const sc_unsigned &u, const sc_signed &v);
+bool operator < (const sc_signed &u, const sc_unsigned &v);
+
+bool operator < (const sc_unsigned &u, const sc_unsigned &v);
+bool operator < (const sc_unsigned &u, int64 v);
+bool operator < (const sc_unsigned &u, uint64 v);
+bool operator < (const sc_unsigned &u, long v);
+bool operator < (const sc_unsigned &u, unsigned long v);
+inline bool operator < (const sc_unsigned &u, int v);
+inline bool operator < (const sc_unsigned &u, unsigned int v);
+
+bool operator < (int64 u, const sc_unsigned &v);
+bool operator < (uint64 u, const sc_unsigned &v);
+bool operator < (long u, const sc_unsigned &v);
+bool operator < (unsigned long u, const sc_unsigned &v);
+inline bool operator < (int u, const sc_unsigned &v);
+inline bool operator < (unsigned int u, const sc_unsigned &v);
+
+bool operator < (const sc_unsigned &u, const sc_uint_base &v);
+bool operator < (const sc_unsigned &u, const sc_int_base &v);
+bool operator < (const sc_uint_base &u, const sc_unsigned &v);
+bool operator < (const sc_int_base &u, const sc_unsigned &v);
+
+// Logical LESS_THAN_AND_EQUAL operators:
+bool operator <= (const sc_unsigned &u, const sc_signed &v);
+bool operator <= (const sc_signed &u, const sc_unsigned &v);
+
+bool operator <= (const sc_unsigned &u, const sc_unsigned &v);
+bool operator <= (const sc_unsigned &u, int64 v);
+bool operator <= (const sc_unsigned &u, uint64 v);
+bool operator <= (const sc_unsigned &u, long v);
+bool operator <= (const sc_unsigned &u, unsigned long v);
+inline bool operator <= (const sc_unsigned &u, int v);
+inline bool operator <= (const sc_unsigned &u, unsigned int v);
+
+bool operator <= (int64 u, const sc_unsigned &v);
+bool operator <= (uint64 u, const sc_unsigned &v);
+bool operator <= (long u, const sc_unsigned &v);
+bool operator <= (unsigned long u, const sc_unsigned &v);
+inline bool operator <= (int u, const sc_unsigned &v);
+inline bool operator <= (unsigned int u, const sc_unsigned &v);
+
+bool operator <= (const sc_unsigned &u, const sc_uint_base &v);
+bool operator <= (const sc_unsigned &u, const sc_int_base &v);
+bool operator <= (const sc_uint_base &u, const sc_unsigned &v);
+bool operator <= (const sc_int_base &u, const sc_unsigned &v);
+
+// Logical GREATER_THAN operators:
+bool operator > (const sc_unsigned &u, const sc_signed &v);
+bool operator > (const sc_signed &u, const sc_unsigned &v);
+
+bool operator > (const sc_unsigned &u, const sc_unsigned &v);
+bool operator > (const sc_unsigned &u, int64 v);
+bool operator > (const sc_unsigned &u, uint64 v);
+bool operator > (const sc_unsigned &u, long v);
+bool operator > (const sc_unsigned &u, unsigned long v);
+inline bool operator > (const sc_unsigned &u, int v);
+inline bool operator > (const sc_unsigned &u, unsigned int v);
+
+bool operator > (int64 u, const sc_unsigned &v);
+bool operator > (uint64 u, const sc_unsigned &v);
+bool operator > (long u, const sc_unsigned &v);
+bool operator > (unsigned long u, const sc_unsigned &v);
+inline bool operator > (int u, const sc_unsigned &v);
+inline bool operator > (unsigned int u, const sc_unsigned &v);
+
+bool operator > (const sc_unsigned &u, const sc_uint_base &v);
+bool operator > (const sc_unsigned &u, const sc_int_base &v);
+bool operator > (const sc_uint_base &u, const sc_unsigned &v);
+bool operator > (const sc_int_base &u, const sc_unsigned &v);
+
+// Logical GREATER_THAN_AND_EQUAL operators:
+bool operator >= (const sc_unsigned &u, const sc_signed &v);
+bool operator >= (const sc_signed &u, const sc_unsigned &v);
+
+bool operator >= (const sc_unsigned &u, const sc_unsigned &v);
+bool operator >= (const sc_unsigned &u, int64 v);
+bool operator >= (const sc_unsigned &u, uint64 v);
+bool operator >= (const sc_unsigned &u, long v);
+bool operator >= (const sc_unsigned &u, unsigned long v);
+inline bool operator >= (const sc_unsigned &u, int v);
+inline bool operator >= (const sc_unsigned &u, unsigned int v);
+
+bool operator >= (int64 u, const sc_unsigned &v);
+bool operator >= (uint64 u, const sc_unsigned &v);
+bool operator >= (long u, const sc_unsigned &v);
+bool operator >= (unsigned long u, const sc_unsigned &v);
+inline bool operator >= (int u, const sc_unsigned &v);
+inline bool operator >= (unsigned int u, const sc_unsigned &v);
+
+bool operator >= (const sc_unsigned &u, const sc_uint_base &v);
+bool operator >= (const sc_unsigned &u, const sc_int_base &v);
+bool operator >= (const sc_uint_base &u, const sc_unsigned &v);
+bool operator >= (const sc_int_base &u, const sc_unsigned &v);
+
+// Bitwise NOT operator (unary).
+sc_unsigned operator ~ (const sc_unsigned &u);
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_bitref_r
+//
+// Proxy class for sc_unsigned bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_unsigned_bitref_r : public sc_value_base
+{
+ friend class sc_unsigned;
+
+ protected:
+ // construction and initialization:
+ sc_unsigned_bitref_r() : sc_value_base(), m_index(0), m_obj_p(0) {}
+
+ void
+ initialize(const sc_unsigned *obj_p, int index_)
+ {
+ m_obj_p = const_cast<sc_unsigned *>(obj_p);
+ m_index = index_;
+ }
+
+ public:
+ // destructor
+ virtual ~sc_unsigned_bitref_r() {}
+
+ // copy constructor
+ sc_unsigned_bitref_r(const sc_unsigned_bitref_r &a) :
+ sc_value_base(a), m_index(a.m_index), m_obj_p(a.m_obj_p)
+ {}
+
+ // capacity
+ int length() const { return 1; }
+
+ // implicit conversion to bool
+ operator uint64 () const;
+ bool operator ! () const;
+ bool operator ~ () const;
+
+ // explicit conversions
+ uint64 value() const { return operator uint64(); }
+ bool to_bool() const { return operator uint64(); }
+
+ // concatenation support
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return 1;
+ }
+ virtual uint64
+ concat_get_uint64() const
+ {
+ return (uint64)operator uint64();
+ }
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+ dst_p[word_i] &= ~bit_mask;
+ return false;
+ }
+ virtual bool
+ concat_get_data(sc_digit *dst_p, int low_i) const
+ {
+ int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
+ bool result; // True if non-zero.
+ int word_i = low_i / BITS_PER_DIGIT;
+ if (operator uint64())
+ {
+ dst_p[word_i] |= bit_mask;
+ result = true;
+ } else {
+ dst_p[word_i] &= ~bit_mask;
+ result = false;
+ }
+ return result;
+ }
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << to_bool(); }
+
+ protected:
+ int m_index;
+ sc_unsigned *m_obj_p;
+
+ private:
+ // Disabled
+ const sc_unsigned_bitref_r &operator = (const sc_unsigned_bitref_r &);
+};
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_unsigned_bitref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_bitref
+//
+// Proxy class for sc_unsigned bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_unsigned_bitref : public sc_unsigned_bitref_r
+{
+ friend class sc_unsigned;
+ friend class sc_core::sc_vpool<sc_unsigned_bitref>;
+
+ protected: // construction
+ sc_unsigned_bitref() : sc_unsigned_bitref_r() {}
+
+ public:
+ // copy constructor
+ sc_unsigned_bitref(const sc_unsigned_bitref &a) : sc_unsigned_bitref_r(a)
+ {}
+
+ // assignment operators
+ const sc_unsigned_bitref &operator = (const sc_unsigned_bitref_r &);
+ const sc_unsigned_bitref &operator = (const sc_unsigned_bitref &);
+ const sc_unsigned_bitref &operator = (bool);
+
+ const sc_unsigned_bitref &operator &= (bool);
+ const sc_unsigned_bitref &operator |= (bool);
+ const sc_unsigned_bitref &operator ^= (bool);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_unsigned_bitref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_unsigned_bitref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_subref_r
+//
+// Proxy class for sc_unsigned part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+class sc_unsigned_subref_r : public sc_value_base
+{
+ friend class sc_signed;
+ friend class sc_unsigned;
+ friend class sc_unsigned_signal;
+
+ protected:
+ // constructor
+ sc_unsigned_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0)
+ {}
+
+ void
+ initialize(const sc_unsigned *obj_p, int left_, int right_)
+ {
+ m_obj_p = const_cast<sc_unsigned *>(obj_p);
+ m_left = left_;
+ m_right = right_;
+ }
+
+ public:
+ // destructor
+ virtual ~sc_unsigned_subref_r() {}
+
+ // copy constructor
+ sc_unsigned_subref_r(const sc_unsigned_subref_r &a) :
+ sc_value_base(a), m_left(a.m_left), m_obj_p(a.m_obj_p),
+ m_right(a.m_right)
+ {}
+
+ // capacity
+ int
+ length() const
+ {
+ if (m_left >= m_right)
+ return m_left - m_right + 1;
+ else
+ return m_right - m_left + 1;
+ }
+
+ // implicit conversion to sc_unsigned
+ operator sc_unsigned () const;
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // concatenation support
+ virtual int concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return m_left - m_right + 1;
+ }
+ virtual uint64 concat_get_uint64() const;
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const;
+ bool or_reduce() const;
+ bool nor_reduce() const;
+ bool xor_reduce() const ;
+ bool xnor_reduce() const;
+
+ // other methods
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ protected:
+ int m_left; // Left-most bit in this part selection.
+ sc_unsigned *m_obj_p; // Target of this part selection.
+ int m_right; // Right-most bit in this part selection.
+
+ private:
+ // Disabled
+ const sc_unsigned_subref_r &operator = (const sc_unsigned_subref_r &);
+};
+
+inline ::std::ostream &operator << (
+ ::std::ostream &, const sc_unsigned_subref_r &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_subref
+//
+// Proxy class for sc_unsigned part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+class sc_unsigned_subref : public sc_unsigned_subref_r
+{
+ friend class sc_unsigned;
+ friend class sc_core::sc_vpool<sc_unsigned_subref>;
+
+ // constructor
+ protected:
+ sc_unsigned_subref() : sc_unsigned_subref_r() {}
+
+ public:
+ // copy constructor
+ sc_unsigned_subref(const sc_unsigned_subref &a) : sc_unsigned_subref_r(a)
+ {}
+
+ // assignment operators
+ const sc_unsigned_subref &operator = (const sc_unsigned_subref_r &a);
+ const sc_unsigned_subref &operator = (const sc_unsigned_subref &a);
+ const sc_unsigned_subref &operator = (const sc_unsigned &a);
+
+ template<class T>
+ const sc_unsigned_subref &operator = (const sc_generic_base<T> &a);
+ const sc_unsigned_subref &operator = (const sc_signed_subref_r &a);
+ const sc_unsigned_subref &operator = (const sc_signed &a);
+
+ const sc_unsigned_subref &operator = (const char *a);
+ const sc_unsigned_subref &operator = (unsigned long a);
+ const sc_unsigned_subref &operator = (long a);
+
+ const sc_unsigned_subref &
+ operator = (unsigned int a)
+ {
+ return operator = ((unsigned long)a);
+ }
+
+ const sc_unsigned_subref &
+ operator = (int a)
+ {
+ return operator = ((long)a);
+ }
+
+ const sc_unsigned_subref &operator = (uint64 a);
+ const sc_unsigned_subref &operator = (int64 a);
+ const sc_unsigned_subref &operator = (double a);
+ const sc_unsigned_subref &operator = (const sc_int_base &a);
+ const sc_unsigned_subref &operator = (const sc_uint_base &a);
+
+ // concatenation methods
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // other methods
+ void scan(::std::istream &is=::std::cin);
+
+ protected:
+ static sc_core::sc_vpool<sc_unsigned_subref> m_pool;
+};
+
+inline ::std::istream &operator >> (::std::istream &, sc_unsigned_subref &);
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned
+//
+// Arbitrary precision unsigned number.
+// ----------------------------------------------------------------------------
+
+class sc_unsigned : public sc_value_base
+{
+ friend class sc_concatref;
+ friend class sc_unsigned_bitref_r;
+ friend class sc_unsigned_bitref;
+ friend class sc_unsigned_subref_r;
+ friend class sc_unsigned_subref;
+ friend class sc_signed;
+ friend class sc_signed_subref;
+ friend class sc_signed_subref_r;
+
+ // Needed for types using sc_unsigned.
+ typedef bool elemtype;
+
+ void invalid_init(const char *type_name, int nb) const;
+
+ public:
+ // constructors
+ explicit sc_unsigned(int nb=sc_length_param().len());
+ sc_unsigned(const sc_unsigned &v);
+ sc_unsigned(const sc_signed &v);
+ template<class T>
+ explicit sc_unsigned(const sc_generic_base<T> &v);
+ explicit sc_unsigned(const sc_bv_base &v);
+ explicit sc_unsigned(const sc_lv_base &v);
+ explicit sc_unsigned(const sc_int_subref_r &v);
+ explicit sc_unsigned(const sc_uint_subref_r &v);
+ explicit sc_unsigned(const sc_signed_subref_r &v);
+ explicit sc_unsigned(const sc_unsigned_subref_r &v);
+
+ // assignment operators
+ const sc_unsigned &operator = (const sc_unsigned &v);
+ const sc_unsigned &operator = (const sc_unsigned_subref_r &a);
+
+ template<class T>
+ const sc_unsigned &
+ operator = (const sc_generic_base<T> &a)
+ {
+ a->to_sc_unsigned(*this);
+ return *this;
+ }
+
+ const sc_unsigned &operator = (const sc_signed &v);
+ const sc_unsigned &operator = (const sc_signed_subref_r &a);
+
+ const sc_unsigned &operator = (const char *v);
+ const sc_unsigned &operator = (int64 v);
+ const sc_unsigned &operator = (uint64 v);
+ const sc_unsigned &operator = (long v);
+ const sc_unsigned &operator = (unsigned long v);
+
+ const sc_unsigned &
+ operator = (int v)
+ {
+ return operator = ((long)v);
+ }
+
+ const sc_unsigned &
+ operator = (unsigned int v)
+ {
+ return operator = ((unsigned long)v);
+ }
+
+ const sc_unsigned &operator = (double v);
+ const sc_unsigned &operator = (const sc_int_base &v);
+ const sc_unsigned &operator = (const sc_uint_base &v);
+
+ const sc_unsigned &operator = (const sc_bv_base &);
+ const sc_unsigned &operator = (const sc_lv_base &);
+
+ const sc_unsigned &operator = (const sc_fxval &);
+ const sc_unsigned &operator = (const sc_fxval_fast &);
+ const sc_unsigned &operator = (const sc_fxnum &);
+ const sc_unsigned &operator = (const sc_fxnum_fast &);
+
+ // destructor
+ virtual ~sc_unsigned()
+ {
+# ifndef SC_MAX_NBITS
+ delete [] digit;
+# endif
+ }
+
+ // Concatenation support:
+ sc_digit *get_raw() const { return digit; }
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return nbits - 1;
+ }
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+ virtual uint64 concat_get_uint64() const;
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed &src, int low_i);
+ virtual void concat_set(const sc_unsigned &src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+
+ // Increment operators.
+ sc_unsigned &operator ++ ();
+ const sc_unsigned operator ++ (int);
+
+ // Decrement operators.
+ sc_unsigned &operator -- ();
+ const sc_unsigned operator -- (int);
+
+ // bit selection
+ inline void
+ check_index(int i) const
+ {
+ if ((i < 0) || (i >= nbits - 1))
+ invalid_index(i);
+ }
+
+ void invalid_index(int i) const;
+
+ sc_unsigned_bitref &
+ operator [] (int i)
+ {
+ check_index(i);
+ sc_unsigned_bitref *result_p = sc_unsigned_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ const sc_unsigned_bitref_r &
+ operator [] (int i) const
+ {
+ check_index(i);
+ sc_unsigned_bitref *result_p = sc_unsigned_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ sc_unsigned_bitref &
+ bit(int i)
+ {
+ check_index(i);
+ sc_unsigned_bitref *result_p = sc_unsigned_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ const sc_unsigned_bitref_r &
+ bit(int i) const
+ {
+ check_index(i);
+ sc_unsigned_bitref *result_p = sc_unsigned_bitref::m_pool.allocate();
+ result_p->initialize(this, i);
+ return *result_p;
+ }
+
+ // part selection
+
+ // Subref operators. Help access the range of bits from the ith to
+ // jth. These indices have arbitrary precedence with respect to each
+ // other, i.e., we can have i <= j or i > j. Note the equivalence
+ // between range(i, j) and operator (i, j). Also note that
+ // operator (i, i) returns an unsigned number that corresponds to the
+ // bit operator [i], so these two forms are not the same.
+ inline void
+ check_range(int l, int r) const
+ {
+ if (l < r) {
+ if ((l < 0) || (r >= nbits - 1))
+ invalid_range(l, r);
+ } else {
+ if ((r < 0) || (l >= nbits - 1))
+ invalid_range(l, r);
+ }
+ }
+
+ void invalid_range(int l, int r) const;
+
+ sc_unsigned_subref &
+ range(int i, int j)
+ {
+ check_range(i, j);
+ sc_unsigned_subref *result_p = sc_unsigned_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ const sc_unsigned_subref_r &
+ range(int i, int j) const
+ {
+ check_range(i, j);
+ sc_unsigned_subref *result_p = sc_unsigned_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ sc_unsigned_subref &
+ operator () (int i, int j)
+ {
+ check_range(i,j);
+ sc_unsigned_subref *result_p = sc_unsigned_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ const sc_unsigned_subref_r &
+ operator () (int i, int j) const
+ {
+ check_range(i,j);
+ sc_unsigned_subref *result_p = sc_unsigned_subref::m_pool.allocate();
+ result_p->initialize(this, i, j);
+ return *result_p;
+ }
+
+ // explicit conversions
+ int to_int() const;
+ unsigned int to_uint() const;
+ long to_long() const;
+ unsigned long to_ulong() const;
+ int64 to_int64() const;
+ uint64 to_uint64() const;
+ double to_double() const;
+
+ // explicit conversion to character string
+ const std::string to_string(sc_numrep numrep=SC_DEC) const;
+ const std::string to_string(sc_numrep numrep, bool w_prefix) const;
+
+ // Print functions. dump prints the internals of the class.
+ void
+ print(::std::ostream &os=::std::cout) const
+ {
+ os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
+ }
+
+ void scan(::std::istream &is=::std::cin);
+ void dump(::std::ostream &os=::std::cout) const;
+
+ // Functions to find various properties.
+ int length() const { return nbits - 1; } // Bit width.
+ bool iszero() const; // Is the number zero?
+ bool sign() const { return 0; } // Sign.
+
+ // reduce methods
+ bool and_reduce() const;
+ bool nand_reduce() const { return !and_reduce(); }
+ bool or_reduce() const;
+ bool nor_reduce() const { return !or_reduce(); }
+ bool xor_reduce() const;
+ bool xnor_reduce() const { return !xor_reduce(); }
+
+ // Functions to access individual bits.
+ bool test(int i) const; // Is the ith bit 0 or 1?
+ void set(int i); // Set the ith bit to 1.
+ void clear(int i); // Set the ith bit to 0.
+ void
+ set(int i, bool v) // Set the ith bit to v.
+ {
+ if (v)
+ set(i);
+ else
+ clear(i);
+ }
+ void
+ invert(int i) // Negate the ith bit.
+ {
+ if (test(i))
+ clear(i);
+ else
+ set(i);
+ }
+
+ // Make the number equal to its mirror image.
+ void reverse();
+
+ // Get/set a packed bit representation of the number.
+ void get_packed_rep(sc_digit *buf) const;
+ void set_packed_rep(sc_digit *buf);
+
+ /*
+ The comparison of the old and new semantics are as follows:
+
+ Let s = sc_signed,
+ u = sc_unsigned,
+ un = { uint64, unsigned long, unsigned int },
+ sn = { int64, long, int, char* }, and
+ OP = { +, -, *, /, % }.
+
+ Old semantics: New semantics:
+ u OP u -> u u OP u -> u
+ s OP u -> u s OP u -> s
+ u OP s -> u u OP s -> s
+ s OP s -> s s OP s -> s
+
+ u OP un = un OP u -> u u OP un = un OP u -> u
+ u OP sn = sn OP u -> u u OP sn = sn OP u -> s
+
+ s OP un = un OP s -> s s OP un = un OP s -> s
+ s OP sn = sn OP s -> s s OP sn = sn OP s -> s
+
+ In the new semantics, the result is u if both operands are u; the
+ result is s otherwise. The only exception is subtraction. The result
+ of a subtraction is always s.
+
+ The old semantics is like C/C++ semantics on integer types; the
+ new semantics is due to the VSIA C/C++ data types standard.
+ */
+
+ // ARITHMETIC OPERATORS:
+
+ // ADDition operators:
+ friend sc_signed operator + (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator + (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator + (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator + (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator + (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator + (const sc_unsigned &u, long v);
+ friend sc_unsigned operator + (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator + (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator + (const sc_unsigned &u, unsigned int v)
+ {
+ return operator + (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator + (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator + (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator + (long u, const sc_unsigned &v);
+ friend sc_unsigned operator + (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator + (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator + (unsigned int u, const sc_unsigned &v)
+ {
+ return operator + ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator += (const sc_signed &v);
+ const sc_unsigned &operator += (const sc_unsigned &v);
+ const sc_unsigned &operator += (int64 v);
+ const sc_unsigned &operator += (uint64 v);
+ const sc_unsigned &operator += (long v);
+ const sc_unsigned &operator += (unsigned long v);
+ const sc_unsigned &
+ operator += (int v)
+ {
+ return operator += ((long)v);
+ }
+ const sc_unsigned &
+ operator += (unsigned int v)
+ {
+ return operator += ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator + (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator + (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator += (const sc_int_base &v);
+ const sc_unsigned &operator += (const sc_uint_base &v);
+
+ // SUBtraction operators:
+ friend sc_signed operator - (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator - (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator - (const sc_unsigned &u, int64 v);
+ friend sc_signed operator - (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator - (const sc_unsigned &u, long v);
+ friend sc_signed operator - (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator - (const sc_unsigned &u, int v);
+ friend sc_signed operator - (const sc_unsigned &u, unsigned int v);
+
+ friend sc_signed operator - (int64 u, const sc_unsigned &v);
+ friend sc_signed operator - (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator - (long u, const sc_unsigned &v);
+ friend sc_signed operator - (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator - (int u, const sc_unsigned &v);
+ friend sc_signed operator - (unsigned int u, const sc_unsigned &v);
+
+ const sc_unsigned &operator -= (const sc_signed &v);
+ const sc_unsigned &operator -= (const sc_unsigned &v);
+ const sc_unsigned &operator -= (int64 v);
+ const sc_unsigned &operator -= (uint64 v);
+ const sc_unsigned &operator -= (long v);
+ const sc_unsigned &operator -= (unsigned long v);
+ const sc_unsigned &
+ operator -= (int v)
+ {
+ return operator -= ((long)v);
+ }
+ const sc_unsigned &
+ operator -= (unsigned int v)
+ {
+ return operator -= ((unsigned long)v);
+ }
+
+ friend sc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator -= (const sc_int_base &v);
+ const sc_unsigned &operator -= (const sc_uint_base &v);
+
+ // MULtiplication operators:
+ friend sc_signed operator * (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator * (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator * (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator * (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator * (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator * (const sc_unsigned &u, long v);
+ friend sc_unsigned operator * (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator * (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator * (const sc_unsigned &u, unsigned int v)
+ {
+ return operator * (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator * (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator * (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator * (long u, const sc_unsigned &v);
+ friend sc_unsigned operator * (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator * (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator * (unsigned int u, const sc_unsigned &v)
+ {
+ return operator * ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator *= (const sc_signed &v);
+ const sc_unsigned &operator *= (const sc_unsigned &v);
+ const sc_unsigned &operator *= (int64 v);
+ const sc_unsigned &operator *= (uint64 v);
+ const sc_unsigned &operator *= (long v);
+ const sc_unsigned &operator *= (unsigned long v);
+ const sc_unsigned &operator *= (int v) { return operator *= ((long)v); }
+ const sc_unsigned &
+ operator *= (unsigned int v)
+ {
+ return operator *= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator * (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator * (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator *= (const sc_int_base &v);
+ const sc_unsigned &operator *= (const sc_uint_base &v);
+
+ // DIVision operators:
+ friend sc_signed operator / (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator / (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator / (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator / (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator / (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator / (const sc_unsigned &u, long v);
+ friend sc_unsigned operator / (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator / (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator / (const sc_unsigned &u, unsigned int v)
+ {
+ return operator / (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator / (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator / (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator / (long u, const sc_unsigned &v);
+ friend sc_unsigned operator / (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator / (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator / (unsigned int u, const sc_unsigned &v)
+ {
+ return operator / ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator /= (const sc_signed &v);
+ const sc_unsigned &operator /= (const sc_unsigned &v);
+ const sc_unsigned &operator /= (int64 v);
+ const sc_unsigned &operator /= (uint64 v);
+ const sc_unsigned &operator /= (long v);
+ const sc_unsigned &operator /= (unsigned long v);
+ const sc_unsigned &operator /= (int v) { return operator /= ((long)v); }
+ const sc_unsigned &
+ operator /= (unsigned int v)
+ {
+ return operator /= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator / (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator / (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator /= (const sc_int_base &v);
+ const sc_unsigned &operator /= (const sc_uint_base &v);
+
+ // MODulo operators:
+ friend sc_signed operator % (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator % (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator % (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator % (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator % (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator % (const sc_unsigned &u, long v);
+ friend sc_unsigned operator % (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator % (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator % (const sc_unsigned &u, unsigned int v)
+ {
+ return operator % (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator % (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator % (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator % (long u, const sc_unsigned &v);
+ friend sc_unsigned operator % (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator % (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator % (unsigned int u, const sc_unsigned &v)
+ {
+ return operator % ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator %= (const sc_signed &v);
+ const sc_unsigned &operator %= (const sc_unsigned &v);
+ const sc_unsigned &operator %= (int64 v);
+ const sc_unsigned &operator %= (uint64 v);
+ const sc_unsigned &operator %= (long v);
+ const sc_unsigned &operator %= (unsigned long v);
+ const sc_unsigned &operator %= (int v) { return operator %= ((long)v); }
+ const sc_unsigned &
+ operator %= (unsigned int v)
+ {
+ return operator %= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator % (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator % (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator %= (const sc_int_base &v);
+ const sc_unsigned &operator %= (const sc_uint_base &v);
+
+ // BITWISE OPERATORS:
+
+ // Bitwise AND operators:
+ friend sc_signed operator & (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator & (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator & (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator & (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator & (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator & (const sc_unsigned &u, long v);
+ friend sc_unsigned operator & (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator & (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator & (const sc_unsigned &u, unsigned int v)
+ {
+ return operator & (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator & (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator & (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator & (long u, const sc_unsigned &v);
+ friend sc_unsigned operator & (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator & (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator & (unsigned int u, const sc_unsigned &v)
+ {
+ return operator & ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator &= (const sc_signed &v);
+ const sc_unsigned &operator &= (const sc_unsigned &v);
+ const sc_unsigned &operator &= (int64 v);
+ const sc_unsigned &operator &= (uint64 v);
+ const sc_unsigned &operator &= (long v);
+ const sc_unsigned &operator &= (unsigned long v);
+ const sc_unsigned &operator &= (int v) { return operator&=((long) v); }
+ const sc_unsigned &
+ operator &= (unsigned int v)
+ {
+ return operator &= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator & (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator & (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator &= (const sc_int_base &v);
+ const sc_unsigned &operator &= (const sc_uint_base &v);
+
+ // Bitwise OR operators:
+ friend sc_signed operator | (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator | (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator | (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator | (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator | (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator | (const sc_unsigned &u, long v);
+ friend sc_unsigned operator | (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator | (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator | (const sc_unsigned &u, unsigned int v)
+ {
+ return operator | (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator | (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator | (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator | (long u, const sc_unsigned &v);
+ friend sc_unsigned operator | (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator | (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator | (unsigned int u, const sc_unsigned &v)
+ {
+ return operator | ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator |= (const sc_signed &v);
+ const sc_unsigned &operator |= (const sc_unsigned &v);
+ const sc_unsigned &operator |= (int64 v);
+ const sc_unsigned &operator |= (uint64 v);
+ const sc_unsigned &operator |= (long v);
+ const sc_unsigned &operator |= (unsigned long v);
+ const sc_unsigned &operator |= (int v) { return operator|=((long) v); }
+ const sc_unsigned &
+ operator |= (unsigned int v)
+ {
+ return operator |= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator | (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator | (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator |= (const sc_int_base &v);
+ const sc_unsigned &operator |= (const sc_uint_base &v);
+
+ // Bitwise XOR operators:
+ friend sc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator ^ (const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_signed operator ^ (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator ^ (const sc_unsigned &u, uint64 v);
+ friend sc_signed operator ^ (const sc_unsigned &u, long v);
+ friend sc_unsigned operator ^ (const sc_unsigned &u, unsigned long v);
+ friend sc_signed operator ^ (const sc_unsigned &u, int v);
+ friend sc_unsigned
+ operator ^ (const sc_unsigned &u, unsigned int v)
+ {
+ return operator ^ (u, (unsigned long)v);
+ }
+
+ friend sc_signed operator ^ (int64 u, const sc_unsigned &v);
+ friend sc_unsigned operator ^ (uint64 u, const sc_unsigned &v);
+ friend sc_signed operator ^ (long u, const sc_unsigned &v);
+ friend sc_unsigned operator ^ (unsigned long u, const sc_unsigned &v);
+ friend sc_signed operator ^ (int u, const sc_unsigned &v);
+ friend sc_unsigned
+ operator ^ (unsigned int u, const sc_unsigned &v)
+ {
+ return operator ^ ((unsigned long)u, v);
+ }
+
+ const sc_unsigned &operator ^= (const sc_signed &v);
+ const sc_unsigned &operator ^= (const sc_unsigned &v);
+ const sc_unsigned &operator ^= (int64 v);
+ const sc_unsigned &operator ^= (uint64 v);
+ const sc_unsigned &operator ^= (long v);
+ const sc_unsigned &operator ^= (unsigned long v);
+ const sc_unsigned &
+ operator ^= (int v)
+ {
+ return operator ^= ((long)v);
+ }
+ const sc_unsigned &
+ operator ^= (unsigned int v)
+ {
+ return operator ^= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator ^ (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
+ friend sc_unsigned operator ^ (
+ const sc_uint_base &u, const sc_unsigned &v);
+ friend sc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
+ const sc_unsigned &operator ^= (const sc_int_base &v);
+ const sc_unsigned &operator ^= (const sc_uint_base &v);
+
+ // SHIFT OPERATORS:
+
+ // LEFT SHIFT operators:
+ friend sc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator << (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator << (
+ const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_unsigned operator << (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator << (const sc_unsigned &u, uint64 v);
+ friend sc_unsigned operator << (const sc_unsigned &u, long v);
+ friend sc_unsigned operator << (const sc_unsigned &u, unsigned long v);
+ friend sc_unsigned
+ operator << (const sc_unsigned &u, int v)
+ {
+ return operator << (u, (long)v);
+ }
+ friend sc_unsigned
+ operator << (const sc_unsigned &u, unsigned int v)
+ {
+ return operator << (u, (unsigned long)v);
+ }
+
+ const sc_unsigned &operator <<= (const sc_signed &v);
+ const sc_unsigned &operator <<= (const sc_unsigned &v);
+ const sc_unsigned &operator <<= (int64 v);
+ const sc_unsigned &operator <<= (uint64 v);
+ const sc_unsigned &operator <<= (long v);
+ const sc_unsigned &operator <<= (unsigned long v);
+ const sc_unsigned &operator <<= (int v) { return operator <<= ((long)v); }
+ const sc_unsigned &
+ operator <<= (unsigned int v)
+ {
+ return operator <<= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator << (
+ const sc_unsigned &u, const sc_uint_base &v);
+ friend sc_unsigned operator << (
+ const sc_unsigned &u, const sc_int_base &v);
+ const sc_unsigned &operator <<= (const sc_int_base &v);
+ const sc_unsigned &operator <<= (const sc_uint_base &v);
+
+ // RIGHT SHIFT operators:
+ friend sc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
+ friend sc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
+
+ friend sc_unsigned operator >> (
+ const sc_unsigned &u, const sc_unsigned &v);
+ friend sc_unsigned operator >> (const sc_unsigned &u, int64 v);
+ friend sc_unsigned operator >> (const sc_unsigned &u, uint64 v);
+ friend sc_unsigned operator >> (const sc_unsigned &u, long v);
+ friend sc_unsigned operator >> (const sc_unsigned &u, unsigned long v);
+ friend sc_unsigned
+ operator >> (const sc_unsigned &u, int v)
+ {
+ return operator >> (u, (long)v);
+ }
+ friend sc_unsigned
+ operator >> (const sc_unsigned &u, unsigned int v)
+ {
+ return operator >> (u, (unsigned long)v);
+ }
+
+ const sc_unsigned &operator >>= (const sc_signed &v);
+ const sc_unsigned &operator >>= (const sc_unsigned &v);
+ const sc_unsigned &operator >>= (int64 v);
+ const sc_unsigned &operator >>= (uint64 v);
+ const sc_unsigned &operator >>= (long v);
+ const sc_unsigned &operator >>= (unsigned long v);
+ const sc_unsigned &operator >>= (int v) { return operator >>= ((long)v); }
+ const sc_unsigned &
+ operator >>= (unsigned int v)
+ {
+ return operator >>= ((unsigned long)v);
+ }
+
+ friend sc_unsigned operator >> (const sc_unsigned &, const sc_uint_base &);
+ friend sc_unsigned operator >> (const sc_unsigned&, const sc_int_base &);
+ const sc_unsigned &operator >>= (const sc_int_base &v);
+ const sc_unsigned &operator >>= (const sc_uint_base &v);
+
+ // Unary arithmetic operators
+ friend sc_unsigned operator + (const sc_unsigned &u);
+ friend sc_signed operator - (const sc_unsigned &u);
+
+ // LOGICAL OPERATORS:
+
+ // Logical EQUAL operators:
+ friend bool operator == (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator == (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator == (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator == (const sc_unsigned &u, int64 v);
+ friend bool operator == (const sc_unsigned &u, uint64 v);
+ friend bool operator == (const sc_unsigned &u, long v);
+ friend bool operator == (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator == (const sc_unsigned &u, int v)
+ {
+ return operator == (u, (long)v);
+ }
+ friend bool
+ operator == (const sc_unsigned &u, unsigned int v)
+ {
+ return operator == (u, (unsigned long)v);
+ }
+
+ friend bool operator == (int64 u, const sc_unsigned &v);
+ friend bool operator == (uint64 u, const sc_unsigned &v);
+ friend bool operator == (long u, const sc_unsigned &v);
+ friend bool operator == (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator == (int u, const sc_unsigned &v)
+ {
+ return operator == ((long)u, v);
+ }
+ friend bool
+ operator == (unsigned int u, const sc_unsigned &v)
+ {
+ return operator == ((unsigned long)u, v);
+ }
+
+ friend bool operator == (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator == (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator == (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator == (const sc_int_base &u, const sc_unsigned &v);
+
+ // Logical NOT_EQUAL operators:
+ friend bool operator != (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator != (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator != (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator != (const sc_unsigned &u, int64 v);
+ friend bool operator != (const sc_unsigned &u, uint64 v);
+ friend bool operator != (const sc_unsigned &u, long v);
+ friend bool operator != (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator != (const sc_unsigned &u, int v)
+ {
+ return operator != (u, (long)v);
+ }
+ friend bool
+ operator != (const sc_unsigned &u, unsigned int v)
+ {
+ return operator != (u, (unsigned long)v);
+ }
+
+ friend bool operator != (int64 u, const sc_unsigned &v);
+ friend bool operator != (uint64 u, const sc_unsigned &v);
+ friend bool operator != (long u, const sc_unsigned &v);
+ friend bool operator != (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator != (int u, const sc_unsigned &v)
+ {
+ return operator != ((long)u, v);
+ }
+ friend bool
+ operator != (unsigned int u, const sc_unsigned &v)
+ {
+ return operator != ((unsigned long)u, v);
+ }
+
+ friend bool operator != (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator != (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator != (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator != (const sc_int_base &u, const sc_unsigned &v);
+
+ // Logical LESS_THAN operators:
+ friend bool operator < (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator < (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator < (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator < (const sc_unsigned &u, int64 v);
+ friend bool operator < (const sc_unsigned &u, uint64 v);
+ friend bool operator < (const sc_unsigned &u, long v);
+ friend bool operator < (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator < (const sc_unsigned &u, int v)
+ {
+ return operator < (u, (long)v);
+ }
+ friend bool
+ operator < (const sc_unsigned &u, unsigned int v)
+ {
+ return operator < (u, (unsigned long)v);
+ }
+
+ friend bool operator < (int64 u, const sc_unsigned &v);
+ friend bool operator < (uint64 u, const sc_unsigned &v);
+ friend bool operator < (long u, const sc_unsigned &v);
+ friend bool operator < (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator < (int u, const sc_unsigned &v)
+ {
+ return operator < ((long)u, v);
+ }
+ friend bool
+ operator < (unsigned int u, const sc_unsigned &v)
+ {
+ return operator < ((unsigned long)u, v);
+ }
+
+ friend bool operator < (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator < (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator < (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator < (const sc_int_base &u, const sc_unsigned &v);
+
+ // Logical LESS_THAN_AND_EQUAL operators:
+ friend bool operator <= (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator <= (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator <= (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator <= (const sc_unsigned &u, int64 v);
+ friend bool operator <= (const sc_unsigned &u, uint64 v);
+ friend bool operator <= (const sc_unsigned &u, long v);
+ friend bool operator <= (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator <= (const sc_unsigned &u, int v)
+ {
+ return operator <= (u, (long)v);
+ }
+ friend bool
+ operator <= (const sc_unsigned &u, unsigned int v)
+ {
+ return operator <= (u, (unsigned long)v);
+ }
+
+ friend bool operator <= (int64 u, const sc_unsigned &v);
+ friend bool operator <= (uint64 u, const sc_unsigned &v);
+ friend bool operator <= (long u, const sc_unsigned &v);
+ friend bool operator <= (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator <= (int u, const sc_unsigned &v)
+ {
+ return operator <= ((long)u, v);
+ }
+ friend bool
+ operator <= (unsigned int u, const sc_unsigned &v)
+ {
+ return operator <= ((unsigned long)u, v);
+ }
+
+ friend bool operator <= (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator <= (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator <= (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator <= (const sc_int_base &u, const sc_unsigned &v);
+
+ // Logical GREATER_THAN operators:
+ friend bool operator > (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator > (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator > (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator > (const sc_unsigned &u, int64 v);
+ friend bool operator > (const sc_unsigned &u, uint64 v);
+ friend bool operator > (const sc_unsigned &u, long v);
+ friend bool operator > (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator > (const sc_unsigned &u, int v)
+ {
+ return operator > (u, (long)v);
+ }
+ friend bool
+ operator > (const sc_unsigned &u, unsigned int v)
+ {
+ return operator > (u, (unsigned long)v);
+ }
+
+ friend bool operator > (int64 u, const sc_unsigned &v);
+ friend bool operator > (uint64 u, const sc_unsigned &v);
+ friend bool operator > (long u, const sc_unsigned &v);
+ friend bool operator > (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator > (int u, const sc_unsigned &v)
+ {
+ return operator > ((long)u, v);
+ }
+ friend bool
+ operator > (unsigned int u, const sc_unsigned &v)
+ {
+ return operator > ((unsigned long)u, v);
+ }
+
+ friend bool operator > (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator > (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator > (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator > (const sc_int_base &u, const sc_unsigned &v);
+
+ // Logical GREATER_THAN_AND_EQUAL operators:
+ friend bool operator >= (const sc_unsigned &u, const sc_signed &v);
+ friend bool operator >= (const sc_signed &u, const sc_unsigned &v);
+
+ friend bool operator >= (const sc_unsigned &u, const sc_unsigned &v);
+ friend bool operator >= (const sc_unsigned &u, int64 v);
+ friend bool operator >= (const sc_unsigned &u, uint64 v);
+ friend bool operator >= (const sc_unsigned &u, long v);
+ friend bool operator >= (const sc_unsigned &u, unsigned long v);
+ friend bool
+ operator >= (const sc_unsigned &u, int v)
+ {
+ return operator >= (u, (long)v);
+ }
+ friend bool
+ operator >= (const sc_unsigned &u, unsigned int v)
+ {
+ return operator >= (u, (unsigned long)v);
+ }
+
+ friend bool operator >= (int64 u, const sc_unsigned &v);
+ friend bool operator >= (uint64 u, const sc_unsigned &v);
+ friend bool operator >= (long u, const sc_unsigned &v);
+ friend bool operator >= (unsigned long u, const sc_unsigned &v);
+ friend bool
+ operator >= (int u, const sc_unsigned &v)
+ {
+ return operator >= ((long)u, v);
+ }
+ friend bool
+ operator >= (unsigned int u, const sc_unsigned &v)
+ {
+ return operator >= ((unsigned long)u, v);
+ }
+
+ friend bool operator >= (const sc_unsigned &u, const sc_uint_base &v);
+ friend bool operator >= (const sc_unsigned &u, const sc_int_base &v);
+ friend bool operator >= (const sc_uint_base &u, const sc_unsigned &v);
+ friend bool operator >= (const sc_int_base &u, const sc_unsigned &v);
+
+ // Bitwise NOT operator (unary).
+ friend sc_unsigned operator ~ (const sc_unsigned &u);
+
+ // Helper functions.
+ friend int compare_unsigned(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd,
+ small_type if_u_signed, small_type if_v_signed);
+
+ friend sc_unsigned add_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned sub_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned mul_unsigned_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned div_unsigned_friend(
+ small_type s, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned mod_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned and_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned or_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ friend sc_unsigned xor_unsigned_friend(
+ small_type us, int unb, int und, const sc_digit *ud,
+ small_type vs, int vnb, int vnd, const sc_digit *vd);
+
+ public:
+ static sc_core::sc_vpool<sc_unsigned> m_pool;
+
+ private:
+ small_type sgn; // Shortened as s.
+ int nbits; // Shortened as nb.
+ int ndigits; // Shortened as nd.
+
+#ifdef SC_MAX_NBITS
+ sc_digit digit[DIV_CEIL(SC_MAX_NBITS)]; // Shortened as d.
+#else
+ sc_digit *digit; // Shortened as d.
+#endif
+
+ // Private constructors:
+
+ // Create a copy of v with sign s.
+ sc_unsigned(const sc_unsigned &v, small_type s);
+ sc_unsigned(const sc_signed &v, small_type s);
+
+ // Create an unsigned number with the given attributes.
+ sc_unsigned(small_type s, int nb, int nd, sc_digit *d, bool alloc=true);
+
+ // Create an unsigned number using the bits u[l..r].
+ sc_unsigned(const sc_signed *u, int l, int r);
+ sc_unsigned(const sc_unsigned *u, int l, int r);
+
+ // Private member functions. The called functions are inline functions.
+
+ small_type default_sign() const { return SC_POS; }
+
+ int num_bits(int nb) const { return nb + 1; }
+
+ bool check_if_outside(int bit_num) const;
+
+ void
+ copy_digits(int nb, int nd, const sc_digit *d)
+ {
+ copy_digits_unsigned(sgn, nbits, ndigits, digit, nb, nd, d);
+ }
+
+ void makezero() { sgn = make_zero(ndigits, digit); }
+
+ // Conversion functions between 2's complement (2C) and
+ // sign-magnitude (SM):
+ void
+ convert_2C_to_SM()
+ {
+ sgn = convert_unsigned_2C_to_SM(nbits, ndigits, digit);
+ }
+
+ void
+ convert_SM_to_2C_to_SM()
+ {
+ sgn = convert_unsigned_SM_to_2C_to_SM(sgn, nbits, ndigits, digit);
+ }
+
+ void convert_SM_to_2C() { convert_unsigned_SM_to_2C(sgn, ndigits, digit); }
+};
+
+inline ::std::ostream &operator << (::std::ostream &, const sc_unsigned &);
+
+inline ::std::istream &operator >> (::std::istream &, sc_unsigned &);
+
+
+// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_bitref_r
+//
+// Proxy class for sc_unsigned bit selection (r-value only).
+// ----------------------------------------------------------------------------
+
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_unsigned_bitref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_bitref
+//
+// Proxy class for sc_unsigned bit selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+template<class T>
+inline const sc_unsigned_subref &
+sc_unsigned_subref::operator = (const sc_generic_base<T> &a)
+{
+ sc_unsigned temp(length());
+ a->to_sc_unsigned(temp);
+ return *this = temp;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_unsigned_bitref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_subref_r
+//
+// Proxy class for sc_unsigned part selection (r-value only).
+// ----------------------------------------------------------------------------
+
+// reduce methods
+
+inline bool
+sc_unsigned_subref_r::and_reduce() const
+{
+ const sc_unsigned *target_p = m_obj_p;
+ for (int i = m_right; i <= m_left; i++)
+ if (!target_p->test(i))
+ return false;
+ return true;
+}
+
+inline bool
+sc_unsigned_subref_r::nand_reduce() const
+{
+ return !and_reduce();
+}
+
+inline bool
+sc_unsigned_subref_r::or_reduce() const
+{
+ const sc_unsigned *target_p = m_obj_p;
+ for (int i = m_right; i <= m_left; i++)
+ if (target_p->test(i))
+ return true;
+ return false;
+}
+
+inline bool
+sc_unsigned_subref_r::nor_reduce() const
+{
+ return !or_reduce();
+}
+
+inline bool
+sc_unsigned_subref_r::xor_reduce() const
+{
+ int odd;
+ const sc_unsigned *target_p = m_obj_p;
+ odd = 0;
+ for (int i = m_right; i <= m_left; i++)
+ if (target_p->test(i)) odd = ~odd;
+ return odd ? true : false;
+}
+
+inline bool sc_unsigned_subref_r::xnor_reduce() const { return !xor_reduce(); }
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_unsigned_subref_r &a)
+{
+ a.print(os);
+ return os;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned_subref
+//
+// Proxy class for sc_unsigned part selection (r-value and l-value).
+// ----------------------------------------------------------------------------
+
+// assignment operators
+
+inline const sc_unsigned_subref &
+sc_unsigned_subref::operator = (const char *a)
+{
+ sc_unsigned aa(length());
+ return (*this = aa = a);
+}
+
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_unsigned_subref &a)
+{
+ a.scan(is);
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_unsigned
+//
+// Arbitrary precision signed number.
+// ----------------------------------------------------------------------------
+
+template<class T>
+sc_unsigned::sc_unsigned( const sc_generic_base<T> &v)
+{
+ int nb = v->length();
+ sgn = default_sign();
+ if (nb > 0) {
+ nbits = num_bits(nb);
+ } else {
+ invalid_init("sc_generic_base<T>", nb);
+ sc_core::sc_abort(); // can't recover from here
+ }
+ ndigits = DIV_CEIL(nbits);
+# ifdef SC_MAX_NBITS
+ test_bound(nb);
+# else
+ digit = new sc_digit[ndigits];
+# endif
+ makezero();
+ v->to_sc_unsigned(*this);
+}
+
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_unsigned &a)
+{
+ a.print(os);
+ return os;
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_unsigned &a)
+{
+ a.scan(is);
+ return is;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_INT_SC_UNSIGNED_HH__
diff --git a/src/systemc/ext/dt/misc/_misc.hh b/src/systemc/ext/dt/misc/_misc.hh
new file mode 100644
index 000000000..0f0fdfaef
--- /dev/null
+++ b/src/systemc/ext/dt/misc/_misc.hh
@@ -0,0 +1,36 @@
+/*
+ * 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_CORE_DT_MISC__MISC_HH__
+#define __SYSTEMC_EXT_CORE_DT_MISC__MISC_HH__
+
+#include "sc_concatref.hh"
+#include "sc_value_base.hh"
+
+#endif //__SYSTEMC_EXT_CORE_DT_MISC__MISC_HH__
diff --git a/src/systemc/ext/dt/misc/_using.hh b/src/systemc/ext/dt/misc/_using.hh
new file mode 100644
index 000000000..c581ce62c
--- /dev/null
+++ b/src/systemc/ext/dt/misc/_using.hh
@@ -0,0 +1,35 @@
+/*
+ * 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_CORE_MISC__USING_HH__
+#define __SYSTEMC_EXT_CORE_MISC__USING_HH__
+
+#include "_misc.hh"
+
+#endif //__SYSTEMC_EXT_CORE_MISC__USING_HH__
diff --git a/src/systemc/ext/dt/misc/sc_concatref.hh b/src/systemc/ext/dt/misc/sc_concatref.hh
new file mode 100644
index 000000000..cd36eb526
--- /dev/null
+++ b/src/systemc/ext/dt/misc/sc_concatref.hh
@@ -0,0 +1,806 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_concatref.h -- Concatenation support.
+
+ Original Author: Andy Goodrich, Forte Design, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ Andy Goodrich, Forte Design Systems, 17 Nov 2002
+ Creation of sc_concatref class by merging the capabilities of
+ sc_int_concref, sc_int_concref, sc_uint_concref, sc_uint_concref,
+ and implementing the capabilities of sc_signed_concref, sc_signed_concref,
+ sc_unsigned_concref, and sc_unsigned_concref. The resultant class allows
+ mixed mode concatenations on the left and right sides of an assignment.
+
+ *****************************************************************************/
+
+// $Log: sc_concatref.h,v $
+// Revision 1.6 2011/08/24 22:05:48 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.5 2009/11/17 19:58:15 acg
+// Andy Goodrich: fix of shift rhs possibilities to include "int".
+//
+// Revision 1.4 2009/02/28 00:26:29 acg
+// Andy Goodrich: bug fixes.
+//
+// Revision 1.3 2008/04/29 20:23:55 acg
+// Andy Goodrich: fixed the code that assigns the value of a string to
+// an sc_concatref instance.
+//
+// Revision 1.2 2008/02/14 20:57:26 acg
+// Andy Goodrich: added casts to ~0 instances to keep MSVC compiler happy.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.4 2006/10/23 19:36:59 acg
+// Andy Goodrich: changed casts for operations on concatenation values to
+// mirror those of sc_unsigned. For instance, an sc_unsigned minus a value
+// returns an sc_signed result, whereas an sc_concatref minus a value was
+// returning an sc_unsigned result. Now both sc_unsigned and sc_concatref
+// minus a value return an sc_signed result.
+//
+// Revision 1.3 2006/01/13 18:54:01 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__
+#define __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__
+
+#include <iostream>
+
+#include "../bit/sc_bv.hh"
+#include "../bit/sc_lv.hh"
+#include "../int/sc_int_base.hh"
+#include "../int/sc_signed.hh"
+#include "../int/sc_uint_base.hh"
+#include "../int/sc_unsigned.hh"
+#include "../sc_temporary.hh"
+#include "sc_value_base.hh"
+
+namespace sc_dt
+{
+
+// classes defined in this module
+class sc_concatref;
+class sc_concat_bool;
+
+} // namespace sc_dt
+
+namespace sc_core
+{
+
+extern sc_byte_heap sc_temp_heap; // Temporary storage.
+
+// explicit template instantiations
+extern template class sc_vpool<sc_dt::sc_concatref>;
+extern template class sc_vpool<sc_dt::sc_concat_bool>;
+
+} // namespace sc_core
+
+namespace sc_dt {
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concatref
+//
+// Proxy class for sized bit concatenation.
+// ----------------------------------------------------------------------------
+
+class sc_concatref : public sc_generic_base<sc_concatref>, public sc_value_base
+{
+ public:
+ friend class sc_core::sc_vpool<sc_concatref>;
+
+ inline void
+ initialize(sc_value_base &left, sc_value_base &right)
+ {
+ bool left_xz; // True if x's and/or z's found in left.
+ bool right_xz; // True if x's and/or z's found in right.
+
+ m_left_p = (sc_value_base *)&left;
+ m_right_p = (sc_value_base *)&right;
+ m_len_r = right.concat_length(&right_xz);
+ m_len = left.concat_length(&left_xz) + m_len_r;
+ m_flags = (left_xz || right_xz) ? cf_xz_present : cf_none;
+ }
+
+
+ inline void
+ initialize(const sc_value_base &left, const sc_value_base &right)
+ {
+ bool left_xz; // True if x's and/or z's found in left.
+ bool right_xz; // True if x's and/or z's found in right.
+
+ m_left_p = (sc_value_base *)&left;
+ m_right_p = (sc_value_base *)&right;
+ m_len_r = right.concat_length(&right_xz);
+ m_len = left.concat_length(&left_xz) + m_len_r;
+ m_flags = (left_xz || right_xz) ? cf_xz_present : cf_none;
+ }
+
+ // destructor
+ virtual ~sc_concatref() {}
+
+ // capacity
+ unsigned int length() const { return m_len; }
+
+ // concatenation
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = m_flags & cf_xz_present ? true : false;
+ return m_len;
+ }
+
+ virtual void
+ concat_clear_data(bool to_ones)
+ {
+ m_left_p->concat_clear_data(to_ones);
+ m_right_p->concat_clear_data(to_ones);
+ }
+
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ bool rnz = m_right_p->concat_get_ctrl(dst_p, low_i);
+ bool lnz = m_left_p->concat_get_ctrl(dst_p, low_i + m_len_r);
+ return rnz || lnz;
+ }
+
+ virtual bool
+ concat_get_data(sc_digit *dst_p, int low_i) const
+ {
+ bool rnz = m_right_p->concat_get_data(dst_p, low_i);
+ bool lnz = m_left_p->concat_get_data(dst_p, low_i + m_len_r);
+ return rnz || lnz;
+ }
+
+ virtual uint64
+ concat_get_uint64() const
+ {
+ if (m_len_r >= 64) {
+ return m_right_p->concat_get_uint64();
+ } else {
+ return (m_left_p->concat_get_uint64() << m_len_r) |
+ m_right_p->concat_get_uint64();
+ }
+ }
+
+ virtual void
+ concat_set(int64 src, int low_i)
+ {
+ m_right_p->concat_set(src, low_i);
+ m_left_p->concat_set(src, low_i + m_len_r);
+ }
+
+ virtual void
+ concat_set(const sc_signed &src, int low_i)
+ {
+ m_right_p->concat_set(src, low_i);
+ m_left_p->concat_set(src, low_i + m_len_r);
+ }
+
+ virtual void
+ concat_set(const sc_unsigned &src, int low_i)
+ {
+ m_right_p->concat_set(src, low_i);
+ m_left_p->concat_set(src, low_i + m_len_r);
+ }
+
+ virtual void
+ concat_set(uint64 src, int low_i)
+ {
+ m_right_p->concat_set(src, low_i);
+ m_left_p->concat_set(src, low_i + m_len_r);
+ }
+
+ // explicit conversions
+ uint64
+ to_uint64() const
+ {
+ uint64 mask;
+ uint64 result;
+
+ result = m_right_p->concat_get_uint64();
+ if (m_len_r < 64) {
+ mask = (uint64)~0;
+ result = (m_left_p->concat_get_uint64() << m_len_r) |
+ (result & ~(mask << m_len_r));
+ }
+ if (m_len < 64) {
+ mask = (uint64)~0;
+ result = result & ~(mask << m_len);
+ }
+ return result;
+ }
+
+ const sc_unsigned &
+ value() const
+ {
+ bool left_non_zero;
+ sc_unsigned *result_p = sc_unsigned::m_pool.allocate();
+ bool right_non_zero;
+
+ result_p->nbits = result_p->num_bits(m_len);
+ result_p->ndigits = DIV_CEIL(result_p->nbits);
+ result_p->digit = (sc_digit *)sc_core::sc_temp_heap.allocate(
+ sizeof(sc_digit) * result_p->ndigits);
+ result_p->digit[result_p->ndigits - 1] = 0;
+ right_non_zero = m_right_p->concat_get_data(result_p->digit, 0);
+ left_non_zero = m_left_p->concat_get_data(result_p->digit, m_len_r);
+ if (left_non_zero || right_non_zero)
+ result_p->sgn = SC_POS;
+ else
+ result_p->sgn = SC_ZERO;
+ return *result_p;
+ }
+
+ int64 to_int64() const { return (int64)to_uint64(); }
+ int to_int() const { return (int)to_int64(); }
+ unsigned int to_uint() const { return (unsigned int)to_uint64(); }
+ long to_long() const { return (long)to_int64(); }
+ unsigned long to_ulong() const { return (unsigned long)to_uint64(); }
+ double to_double() const { return value().to_double(); }
+
+ void to_sc_signed(sc_signed &target) const { target = value(); }
+
+ void to_sc_unsigned(sc_unsigned &target) const { target = value(); }
+
+ // implicit conversions:
+ operator uint64 () const { return to_uint64(); }
+
+ operator const sc_unsigned & () const { return value(); }
+
+ // unary operators:
+ sc_unsigned operator + () const { return value(); }
+
+ sc_signed operator - () const { return -value(); }
+
+ sc_unsigned operator ~ () const { return ~value(); }
+
+ // explicit conversion to character string
+ const std::string
+ to_string(sc_numrep numrep=SC_DEC) const
+ {
+ return value().to_string(numrep);
+ }
+
+ const std::string
+ to_string(sc_numrep numrep, bool w_prefix) const
+ {
+ return value().to_string(numrep,w_prefix);
+ }
+
+ // assignments
+ inline const sc_concatref &
+ operator = (int v)
+ {
+ m_right_p->concat_set((int64)v, 0);
+ m_left_p->concat_set((int64)v, m_len_r);
+ return *this;
+ }
+
+ inline const sc_concatref &
+ operator = (long v)
+ {
+ m_right_p->concat_set((int64)v, 0);
+ m_left_p->concat_set((int64)v, m_len_r);
+ return *this;
+ }
+
+ inline const sc_concatref &
+ operator = (int64 v)
+ {
+ m_right_p->concat_set(v, 0);
+ m_left_p->concat_set(v, m_len_r);
+ return *this;
+ }
+
+ inline const sc_concatref &
+ operator = (unsigned int v)
+ {
+ m_right_p->concat_set((uint64)v, 0);
+ m_left_p->concat_set((uint64)v, m_len_r);
+ return *this;
+ }
+
+ inline const sc_concatref &
+ operator = (unsigned long v)
+ {
+ m_right_p->concat_set((uint64)v, 0);
+ m_left_p->concat_set((uint64)v, m_len_r);
+ return *this;
+ }
+
+ inline const sc_concatref &
+ operator = (uint64 v)
+ {
+ m_right_p->concat_set(v, 0);
+ m_left_p->concat_set(v, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const sc_concatref &v)
+ {
+ sc_unsigned temp(v.length());
+ temp = v.value();
+ m_right_p->concat_set(temp, 0);
+ m_left_p->concat_set(temp, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const sc_signed &v)
+ {
+ m_right_p->concat_set(v, 0);
+ m_left_p->concat_set(v, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const sc_unsigned &v)
+ {
+ m_right_p->concat_set(v, 0);
+ m_left_p->concat_set(v, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const char *v_p)
+ {
+ sc_unsigned v(m_len);
+ v = v_p;
+ m_right_p->concat_set(v, 0);
+ m_left_p->concat_set(v, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const sc_bv_base &v)
+ {
+ sc_unsigned temp(v.length());
+ temp = v;
+ m_right_p->concat_set(temp, 0);
+ m_left_p->concat_set(temp, m_len_r);
+ return *this;
+ }
+
+ const sc_concatref &
+ operator = (const sc_lv_base &v)
+ {
+ sc_unsigned data(v.length());
+ data = v;
+ m_right_p->concat_set(data, 0);
+ m_left_p->concat_set(data, m_len_r);
+ return *this;
+ }
+
+ // reduce methods
+ bool and_reduce() const { return value().and_reduce(); }
+ bool nand_reduce() const { return value().nand_reduce(); }
+ bool or_reduce() const { return value().or_reduce(); }
+ bool nor_reduce() const { return value().nor_reduce(); }
+ bool xor_reduce() const { return value().xor_reduce(); }
+ bool xnor_reduce() const { return value().xnor_reduce(); }
+
+ // other methods
+ void print(::std::ostream &os=::std::cout) const { os << this->value(); }
+
+ void
+ scan(::std::istream &is)
+ {
+ std::string s;
+ is >> s;
+ *this = s.c_str();
+ }
+
+ public:
+ // Pool of temporary objects.
+ static sc_core::sc_vpool<sc_concatref> m_pool;
+
+ public:
+ enum concat_flags {
+ cf_none = 0, // Normal value.
+ cf_xz_present = 1 // X and/or Z values present.
+ };
+
+ protected:
+ sc_value_base *m_left_p; // Left hand operand of concatenation.
+ sc_value_base *m_right_p; // Right hand operand of concatenation.
+ int m_len; // Length of concatenation.
+ int m_len_r; // Length of m_rightt_p.
+ concat_flags m_flags; // Value is read only.
+
+ private:
+ sc_concatref(const sc_concatref &);
+ sc_concatref() : m_left_p(0), m_right_p(0), m_len(0), m_len_r(0), m_flags()
+ {}
+};
+
+// functional notation for the reduce methods
+inline bool and_reduce(const sc_concatref &a) { return a.and_reduce(); }
+inline bool nand_reduce(const sc_concatref &a) { return a.nand_reduce(); }
+inline bool or_reduce(const sc_concatref &a) { return a.or_reduce(); }
+inline bool nor_reduce(const sc_concatref &a) { return a.nor_reduce(); }
+inline bool xor_reduce(const sc_concatref &a) { return a.xor_reduce(); }
+inline bool xnor_reduce(const sc_concatref &a) { return a.xnor_reduce(); }
+
+// SHIFT OPERATORS FOR sc_concatref OBJECT INSTANCES:
+//
+// Because sc_concatref has implicit casts to both uint64 and sc_unsigned
+// it is necessary to disambiguate the use of the shift operators. We do
+// this in favor of sc_unsigned so that precision is not lost. To get an
+// integer-based result use a cast to uint64 before performing the shift.
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, uint64 shift)
+{
+ return target.value() << (int)shift;
+}
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, int64 shift)
+{
+ return target.value() << (int)shift;
+}
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, unsigned long shift)
+{
+ return target.value() << (int)shift;
+}
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, int shift)
+{
+ return target.value() << shift;
+}
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, unsigned int shift)
+{
+ return target.value() << (int)shift;
+}
+
+inline const sc_unsigned
+operator << (const sc_concatref &target, long shift)
+{
+ return target.value() << (int)shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, uint64 shift)
+{
+ return target.value() >> (int)shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, int64 shift)
+{
+ return target.value() >> (int)shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, unsigned long shift)
+{
+ return target.value() >> (int)shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, int shift)
+{
+ return target.value() >> shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, unsigned int shift)
+{
+ return target.value() >> (int)shift;
+}
+
+inline const sc_unsigned
+operator >> (const sc_concatref &target, long shift)
+{
+ return target.value() >> (int)shift;
+}
+
+// STREAM OPERATORS FOR sc_concatref OBJECT INSTANCES:
+inline ::std::ostream &
+operator << (::std::ostream &os, const sc_concatref &v)
+{
+ return os << v.value();
+}
+
+inline ::std::istream &
+operator >> (::std::istream &is, sc_concatref &a)
+{
+ sc_unsigned temp(a.concat_length(0));
+ temp.scan(is);
+ a = temp;
+ return is;
+}
+
+
+// ----------------------------------------------------------------------------
+// CLASS TEMPLATE : sc_concat_bool
+//
+// Proxy class for read-only boolean values in concatenations.
+// ----------------------------------------------------------------------------
+
+class sc_concat_bool : public sc_value_base
+{
+ protected:
+ static sc_core::sc_vpool<sc_concat_bool> m_pool; // Temporaries pool.
+ bool m_value; // Value for this obj.
+
+ public:
+ // constructor:
+ sc_concat_bool() : sc_value_base(), m_value() {}
+
+ // destructor:
+ virtual ~sc_concat_bool() { }
+
+ // allocation of temporary object:
+ static inline sc_concat_bool *
+ allocate(bool v)
+ {
+ sc_concat_bool *result_p = m_pool.allocate();
+ result_p->m_value = v;
+ return result_p;
+ }
+
+ // concatenation:
+ virtual int
+ concat_length(bool *xz_present_p) const
+ {
+ if (xz_present_p)
+ *xz_present_p = false;
+ return 1;
+ }
+
+ virtual bool
+ concat_get_ctrl(sc_digit *dst_p, int low_i) const
+ {
+ int bit = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+ dst_p[word_i] &= ~bit;
+ return false;
+ }
+
+ virtual bool
+ concat_get_data(sc_digit *dst_p, int low_i) const
+ {
+ int bit = 1 << (low_i % BITS_PER_DIGIT);
+ int word_i = low_i / BITS_PER_DIGIT;
+ if (m_value)
+ dst_p[word_i] |= bit;
+ else
+ dst_p[word_i] &= ~bit;
+ return m_value;
+ }
+
+ virtual uint64
+ concat_get_uint64() const
+ {
+ return m_value ? 1 : 0;
+ }
+};
+
+
+// ----------------------------------------------------------------------------
+// ARITHMETIC AND LOGIC OPERATORS FOR sc_concatref
+// ----------------------------------------------------------------------------
+
+#define SC_CONCAT_OP_TYPE(RESULT, OP, OTHER_TYPE) \
+ inline RESULT \
+ operator OP (const sc_concatref &a, OTHER_TYPE b) \
+ { \
+ return a.value() OP b; \
+ } \
+ inline RESULT \
+ operator OP (OTHER_TYPE a, const sc_concatref &b) \
+ { \
+ return a OP b.value(); \
+ }
+
+
+#define SC_CONCAT_OP(RESULT, OP) \
+ inline RESULT \
+ operator OP (const sc_concatref &a, const sc_concatref &b) \
+ { \
+ return a.value() OP b.value(); \
+ } \
+ SC_CONCAT_OP_TYPE(const sc_signed, OP, int) \
+ SC_CONCAT_OP_TYPE(const sc_signed, OP, long) \
+ SC_CONCAT_OP_TYPE(const sc_signed, OP, int64) \
+ SC_CONCAT_OP_TYPE(RESULT, OP, unsigned int) \
+ SC_CONCAT_OP_TYPE(RESULT, OP, unsigned long) \
+ SC_CONCAT_OP_TYPE(RESULT, OP, uint64) \
+ SC_CONCAT_OP_TYPE(const sc_signed, OP, const sc_int_base &) \
+ SC_CONCAT_OP_TYPE(RESULT, OP, const sc_uint_base &) \
+ SC_CONCAT_OP_TYPE(const sc_signed, OP, const sc_signed &) \
+ SC_CONCAT_OP_TYPE(RESULT, OP, const sc_unsigned &) \
+ inline RESULT \
+ operator OP (const sc_concatref &a, bool b) \
+ { \
+ return a.value() OP (int)b; \
+ } \
+ inline RESULT \
+ operator OP (bool a, const sc_concatref &b) \
+ { \
+ return (int)a OP b.value(); \
+ }
+
+#define SC_CONCAT_BOOL_OP(OP) \
+ inline bool \
+ operator OP (const sc_concatref &a, const sc_concatref &b) \
+ { \
+ return a.value() OP b.value(); \
+ } \
+ SC_CONCAT_OP_TYPE(bool, OP, int) \
+ SC_CONCAT_OP_TYPE(bool, OP, long) \
+ SC_CONCAT_OP_TYPE(bool, OP, int64) \
+ SC_CONCAT_OP_TYPE(bool, OP, unsigned int) \
+ SC_CONCAT_OP_TYPE(bool, OP, unsigned long) \
+ SC_CONCAT_OP_TYPE(bool, OP, uint64) \
+ SC_CONCAT_OP_TYPE(bool, OP, const sc_int_base &) \
+ SC_CONCAT_OP_TYPE(bool, OP, const sc_uint_base &) \
+ SC_CONCAT_OP_TYPE(bool, OP, const sc_signed &) \
+ SC_CONCAT_OP_TYPE(bool, OP, const sc_unsigned &) \
+ inline bool \
+ operator OP (const sc_concatref &a, bool b) \
+ { \
+ return a.value() OP (int)b; \
+ } \
+ inline bool \
+ operator OP (bool a, const sc_concatref &b) \
+ { \
+ return (int)a OP b.value(); \
+ }
+
+SC_CONCAT_OP(const sc_unsigned, +)
+SC_CONCAT_OP(const sc_signed, -)
+SC_CONCAT_OP(const sc_unsigned, *)
+SC_CONCAT_OP(const sc_unsigned, /)
+SC_CONCAT_OP(const sc_unsigned, %)
+SC_CONCAT_OP(const sc_unsigned, &)
+SC_CONCAT_OP(const sc_unsigned, |)
+SC_CONCAT_OP(const sc_unsigned, ^)
+SC_CONCAT_BOOL_OP(==)
+SC_CONCAT_BOOL_OP(<=)
+SC_CONCAT_BOOL_OP(>=)
+SC_CONCAT_BOOL_OP(!=)
+SC_CONCAT_BOOL_OP(>)
+SC_CONCAT_BOOL_OP(<)
+
+#undef SC_CONCAT_OP
+#undef SC_CONCAT_OP_TYPE
+
+
+// ----------------------------------------------------------------------------
+// CONCATENATION FUNCTION AND OPERATOR FOR STANDARD SYSTEM C DATA TYPES:
+// ----------------------------------------------------------------------------
+
+inline sc_dt::sc_concatref &
+concat(sc_dt::sc_value_base &a, sc_dt::sc_value_base &b)
+{
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, b);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+concat(const sc_dt::sc_value_base &a, const sc_dt::sc_value_base &b)
+{
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, b);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+concat(const sc_dt::sc_value_base &a, bool b)
+{
+ const sc_dt::sc_concat_bool *b_p; // Proxy for boolean value.
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ b_p = sc_dt::sc_concat_bool::allocate(b);
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, *b_p);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+concat(bool a, const sc_dt::sc_value_base &b)
+{
+ const sc_dt::sc_concat_bool *a_p; // Proxy for boolean value.
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ a_p = sc_dt::sc_concat_bool::allocate(a);
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(*a_p, b);
+ return *result_p;
+}
+
+inline sc_dt::sc_concatref &
+operator , (sc_dt::sc_value_base &a, sc_dt::sc_value_base &b)
+{
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, b);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+operator , (const sc_dt::sc_value_base &a, const sc_dt::sc_value_base &b)
+{
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, b);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+operator , (const sc_dt::sc_value_base &a, bool b)
+{
+ const sc_dt::sc_concat_bool *b_p; // Proxy for boolean value.
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ b_p = sc_dt::sc_concat_bool::allocate(b);
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(a, *b_p);
+ return *result_p;
+}
+
+inline const sc_dt::sc_concatref &
+operator , (bool a, const sc_dt::sc_value_base &b)
+{
+ const sc_dt::sc_concat_bool *a_p; // Proxy for boolean value.
+ sc_dt::sc_concatref *result_p; // Proxy for the concatenation.
+
+ a_p = sc_dt::sc_concat_bool::allocate(a);
+ result_p = sc_dt::sc_concatref::m_pool.allocate();
+ result_p->initialize(*a_p, b);
+ return *result_p;
+}
+
+} // namespace sc_dt
+
+#endif // __SYSTEMC_EXT_DT_MISC_SC_CONCATREF_HH__
diff --git a/src/systemc/ext/dt/misc/sc_value_base.hh b/src/systemc/ext/dt/misc/sc_value_base.hh
new file mode 100644
index 000000000..2ea6ce22e
--- /dev/null
+++ b/src/systemc/ext/dt/misc/sc_value_base.hh
@@ -0,0 +1,123 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_value_base.h -- Base class for SystemC bit values.
+
+ Original Author: Andy Goodrich, Forte Design Systems
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: sc_value_base.h,v $
+// Revision 1.4 2011/08/29 18:04:32 acg
+// Philipp A. Hartmann: miscellaneous clean ups.
+//
+// Revision 1.3 2011/08/24 22:05:48 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/06/28 21:23:04 acg
+// Andy Goodrich: merging of SCV tree.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:05 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:54:01 acg
+// Andy Goodrich: added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#ifndef __SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__
+#define __SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__
+
+#include "../int/sc_nbdefs.hh"
+
+namespace sc_dt
+{
+
+class sc_signed;
+class sc_unsigned;
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_value_base
+//
+// Abstract base class of all SystemC native variables. It provides
+// support for concatenation operations via a set of virtual methods.
+// A general description of the methods appear with their default
+// definitions in sc_object.cpp.
+// ----------------------------------------------------------------------------
+
+class sc_value_base
+{
+ friend class sc_concatref;
+ private:
+ virtual void concat_clear_data(bool to_ones=false);
+ virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
+ virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
+ virtual uint64 concat_get_uint64() const;
+ virtual int concat_length(bool *xz_present_p=0) const;
+ virtual void concat_set(int64 src, int low_i);
+ virtual void concat_set(const sc_signed& src, int low_i);
+ virtual void concat_set(const sc_unsigned& src, int low_i);
+ virtual void concat_set(uint64 src, int low_i);
+ public:
+ virtual ~sc_value_base() {}
+};
+
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_generic_base
+//
+// Proxy class for user-defined value classes and other classes that
+// are defined outside of SystemC.
+// The class is utilized as a base class for the arbitrary class:
+//
+// class my_class : public sc_generic_base<my_class>
+//
+// The purpose of the class is to allow to_XXXX methods defined within that
+// class so that assignments and casts from the arbitrary class to native
+// SystemC types are possible. To interact correctly with the SystemC library
+// the class derived from sc_generic_base must implement the following
+// methods:
+// (1) uint64 to_uint64() const
+// (2) int64 to_int64() const
+// (3) void to_sc_unsigned( sc_unsigned& ) const
+// (4) void to_sc_signed( sc_signed& ) const
+// ----------------------------------------------------------------------------
+template< class T >
+class sc_generic_base
+{
+ public:
+ inline const T *operator-> () const { return (const T *)this; }
+ inline T *operator-> () { return (T *)this; }
+};
+
+} // namespace sc_dt
+
+#endif // SYSTEMC_EXT_DT_MISC_SC_VALUE_BASE_HH__
diff --git a/src/systemc/ext/dt/sc_mempool.hh b/src/systemc/ext/dt/sc_mempool.hh
new file mode 100644
index 000000000..40b1950cb
--- /dev/null
+++ b/src/systemc/ext/dt/sc_mempool.hh
@@ -0,0 +1,100 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_mempool.h - Memory pools for small objects.
+
+ Original Author: Stan Y. Liao, Synopsys, Inc.
+
+ CHANGE LOG AT END OF FILE
+ *****************************************************************************/
+
+#ifndef __SYSTEMC_EXT_DT_SC_MEMPOOL_HH__
+#define __SYSTEMC_EXT_DT_SC_MEMPOOL_HH__
+
+namespace sc_core
+{
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_mempool
+//
+// ...
+// ----------------------------------------------------------------------------
+
+class sc_mempool
+{
+ public:
+ static void *allocate(std::size_t sz);
+ static void release(void *p, std::size_t sz);
+ static void display_statistics();
+};
+
+// ----------------------------------------------------------------------------
+// CLASS : sc_mpobject
+//
+// ...
+// ----------------------------------------------------------------------------
+
+class sc_mpobject
+{
+ public:
+ static void *
+ operator new(std::size_t sz)
+ {
+ return sc_mempool::allocate(sz);
+ }
+
+ static void
+ operator delete(void *p, std::size_t sz)
+ {
+ sc_mempool::release(p, sz);
+ }
+
+ static void *
+ operator new [] (std::size_t sz)
+ {
+ return sc_mempool::allocate(sz);
+ }
+
+ static void
+ operator delete [] (void *p, std::size_t sz)
+ {
+ sc_mempool::release(p, sz);
+ }
+};
+
+} // namespace sc_core
+
+// $Log: sc_mempool.h,v $
+// Revision 1.3 2011/08/26 20:46:18 acg
+// Andy Goodrich: moved the modification log to the end of the file to
+// eliminate source line number skew when check-ins are done.
+//
+// Revision 1.2 2011/02/18 20:38:44 acg
+// Andy Goodrich: Updated Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:06 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:11 acg
+// Andy Goodrich: Added $Log command so that CVS comments are reproduced in
+// the source.
+
+#endif // __SYSTEMC_EXT_DT_SC_MEMPOOL_HH__
diff --git a/src/systemc/ext/dt/sc_temporary.hh b/src/systemc/ext/dt/sc_temporary.hh
new file mode 100644
index 000000000..c462b7fe0
--- /dev/null
+++ b/src/systemc/ext/dt/sc_temporary.hh
@@ -0,0 +1,227 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sc_temporary.h -- Temporary value pool classes.
+
+ Original Author: Andy Goodrich, Forte Design Systems, Inc.
+
+ CHANGE LOG AT END OF FILE
+ *****************************************************************************/
+
+#ifndef __SYSTEMC_EXT_DT_SC_TEMPORARY_HH__
+#define __SYSTEMC_EXT_DT_SC_TEMPORARY_HH__
+
+#include <cstddef> // std::size_t
+
+namespace sc_core
+{
+
+//-----------------------------------------------------------------------------
+// sc_byte_heap - CLASS MANAGING A TEMPORARY HEAP OF BYTES
+//
+// This facility implements a heap of temporary byte allocations. Once an
+// request has been allocated it is not freed. However the entire heap
+// wraps and the storage is reused. This means that no allocations should
+// be assumed as permanent. Allocations are double-word aligned. This is
+// raw storage, so objects which contain virtual methods cannot be allocated
+// with this object. See the sc_vpool object for that type of storage
+// allocation.
+//
+// char* allocate( int size )
+// This method returns a pointer to block of size bytes. The block
+// returned is the next available one in the heap. If the current heap
+// cannot fullfil the request it will be rewound and storage allocated from
+// its start. All allocations start on an 8-byte boundary.
+// size = number of bytes to be allocated.
+//
+// void initialize( int heap_size=0x100000 )
+// This method allocates the storage to be managed. If there is already
+// a block of storage under management it is freed. If no argument is
+// provided for the heap size, a megabyte will be allocated.
+// heap_size = number of bytes to allocate for the heap.
+//
+// unsigned int length()
+// This method returns the size of this object's heap in bytes.
+//
+// sc_byte_heap()
+// This is the non-initialized object instance constructor. It does not
+// allocate the heap storage, that is done by the initialize() method.
+//
+// sc_byte_heap(int)
+// This is the initializing object instance constructor. It does allocates
+// a heap of the specified number of bytes.
+// heap_size = number of bytes to allocate for the heap.
+//-----------------------------------------------------------------------------
+class sc_byte_heap
+{
+ public:
+ char *m_bgn_p; // Beginning of heap storage.
+ char *m_end_p; // End of heap storage.
+ char *m_next_p; // Next heap location to be allocated.
+
+ inline char *
+ allocate(std::size_t bytes_n)
+ {
+ char *result_p;
+ bytes_n = (bytes_n + 7) & ((std::size_t)(-8));
+ result_p = m_next_p;
+ m_next_p += bytes_n;
+ if (m_next_p >= m_end_p) {
+ result_p = m_bgn_p;
+ m_next_p = m_bgn_p + bytes_n;
+ }
+ return result_p;
+ }
+
+ inline void
+ initialize(std::size_t heap_size=0x100000)
+ {
+ delete [] m_bgn_p;
+ m_bgn_p = new char[heap_size];
+ m_end_p = &m_bgn_p[heap_size];
+ m_next_p = m_bgn_p;
+ }
+
+ inline std::size_t
+ length()
+ {
+ return (std::size_t)(m_end_p - m_bgn_p);
+ }
+
+ inline sc_byte_heap() : m_bgn_p(0), m_end_p(0), m_next_p(0) {}
+
+ inline sc_byte_heap(std::size_t heap_size) :
+ m_bgn_p(0), m_end_p(0), m_next_p(0)
+ {
+ initialize(heap_size);
+ }
+
+ inline ~sc_byte_heap() { delete [] m_bgn_p; }
+};
+
+
+//-----------------------------------------------------------------------------
+// sc_vpool<T> - CLASS MANAGING A TEMPORARY VECTOR OF CLASS T INSTANCES
+//
+// This class implements a fixed pool of objects contained in a vector. These
+// objects are allocated via the allocate() method. An index, m_pool_i,
+// indicates the next object to be allocated. The vector is a power of 2 in
+// size, and this fact is used to wrap the list when m_pool_i reaches the
+// end of the vector.
+//
+// sc_vpool( int log2, T* pool_p=0 )
+// This is the object instance constructor for this class. It configures
+// the object to manage a vector of 2**log2 entries. If a vector is
+// not supplied one will be allocated.
+// log2 = the log base two of the size of the vector.
+// pool_p -> vector of 2**log2 entries to be managed or 0.
+//
+// ~sc_vpool()
+// This is the object instance destructor for this class. It frees the
+// block of storage which was being managed.
+//
+// T* allocate()
+// This method returns the address of the next entry in the vector, m_pool_p,
+// pointed to by the index, m_pool_i, and updates that index. The index
+// update consists of adding 1 to m_pool_i and masking it by m_wrap.
+//
+// void reset()
+// This method resets the allocation index, m_pool_i, to point to the start
+// of the vector of objects under management. This call is not usually made
+// since there are a fixed number of entries and the index wraps. However,
+// for diagnostics tests it is convenient to be able to reset to the start
+// of the vector.
+//
+// int size()
+// This method returns the number of object instances contained in the
+// vector being managed by this object instance.
+//-----------------------------------------------------------------------------
+template<class T>
+class sc_vpool
+{
+ protected:
+ std::size_t m_pool_i; // Index of next entry to m_pool_m to provide.
+ T *m_pool_p; // Vector of temporaries.
+ std::size_t m_wrap; // Mask to wrap vector index.
+
+ public:
+ inline sc_vpool(int log2, T *pool_p=0);
+ inline ~sc_vpool();
+ inline T *allocate();
+ inline void reset();
+ inline std::size_t size();
+};
+
+template<class T>
+sc_vpool<T>::sc_vpool(int log2, T *pool_p) : m_pool_i(0),
+ m_pool_p(pool_p ? pool_p : new T[static_cast<std::size_t>(1) << log2]),
+ m_wrap(~(static_cast<std::size_t>(-1) << log2))
+{
+ // if (log2 > 32) SC_REPORT_ERROR(SC_ID_POOL_SIZE_, "");
+}
+
+template<class T>
+sc_vpool<T>::~sc_vpool()
+{
+ // delete [] m_pool_p;
+}
+
+template<class T>
+T *sc_vpool<T>::allocate()
+{
+ T *result_p; // Entry to return.
+
+ result_p = &m_pool_p[m_pool_i];
+ m_pool_i = (m_pool_i + 1) & m_wrap;
+ return result_p;
+}
+
+template<class T>
+void sc_vpool<T>::reset()
+{
+ m_pool_i = 0;
+}
+
+template<class T>
+std::size_t sc_vpool<T>::size() { return m_wrap + 1; }
+
+} // namespace sc_core
+
+// $Log: sc_temporary.h,v $
+// Revision 1.4 2011/08/26 20:46:19 acg
+// Andy Goodrich: moved the modification log to the end of the file to
+// eliminate source line number skew when check-ins are done.
+//
+// Revision 1.3 2011/08/24 22:05:56 acg
+// Torsten Maehne: initialization changes to remove warnings.
+//
+// Revision 1.2 2011/02/18 20:38:44 acg
+// Andy Goodrich: Updated Copyright notice.
+//
+// Revision 1.1.1.1 2006/12/15 20:20:06 acg
+// SystemC 2.3
+//
+// Revision 1.3 2006/01/13 18:53:11 acg
+// Andy Goodrich: Added $Log command so that CVS comments are reproduced in
+// the source.
+//
+
+#endif // __SYSTEMC_EXT_DT_SC_TEMPORARY_HH__