00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.4 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_biguint.h -- Template version of sc_unsigned. This class 00021 enables compile-time bit widths for sc_unsigned numbers. 00022 00023 Original Author: Ali Dasdan, Synopsys, Inc. 00024 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 00029 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00030 changes you are making here. 00031 00032 Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc. 00033 Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv. 00034 00035 Name, Affiliation, Date: 00036 Description of Modification: 00037 00038 *****************************************************************************/ 00039 00040 #ifndef SC_BIGUINT_H 00041 #define SC_BIGUINT_H 00042 00043 00044 #include "sysc/datatypes/int/sc_signed.h" 00045 #include "sysc/datatypes/int/sc_unsigned.h" 00046 00047 namespace sc_dt 00048 { 00049 00050 // classes defined in this module 00051 template <int W> class sc_biguint; 00052 00053 // forward class declarations 00054 class sc_bv_base; 00055 class sc_lv_base; 00056 class sc_fxval; 00057 class sc_fxval_fast; 00058 class sc_fxnum; 00059 class sc_fxnum_fast; 00060 00061 00062 // ---------------------------------------------------------------------------- 00063 // CLASS TEMPLATE : sc_biguint<W> 00064 // 00065 // Arbitrary size unsigned integer type. 00066 // ---------------------------------------------------------------------------- 00067 00068 #ifdef SC_MAX_NBITS 00069 template< int W = SC_MAX_NBITS > 00070 #else 00071 template< int W > 00072 #endif 00073 class sc_biguint 00074 : public sc_unsigned 00075 { 00076 public: 00077 00078 // constructors 00079 00080 sc_biguint() 00081 : sc_unsigned( W ) 00082 {} 00083 00084 sc_biguint( const sc_biguint<W>& v ) 00085 : sc_unsigned( W ) 00086 { *this = v; } 00087 00088 sc_biguint( const sc_unsigned& v ) 00089 : sc_unsigned( W ) 00090 { *this = v; } 00091 00092 sc_biguint( const sc_unsigned_subref& v ) 00093 : sc_unsigned( W ) 00094 { *this = v; } 00095 00096 template< class T > 00097 sc_biguint( const sc_generic_base<T>& a ) 00098 : sc_unsigned( W ) 00099 { a->to_sc_unsigned(*this); } 00100 00101 sc_biguint( const sc_signed& v ) 00102 : sc_unsigned( W ) 00103 { *this = v; } 00104 00105 sc_biguint( const sc_signed_subref& v ) 00106 : sc_unsigned( W ) 00107 { *this = v; } 00108 00109 sc_biguint( const char* v ) 00110 : sc_unsigned( W ) 00111 { *this = v; } 00112 00113 sc_biguint( int64 v ) 00114 : sc_unsigned( W ) 00115 { *this = v; } 00116 00117 sc_biguint( uint64 v ) 00118 : sc_unsigned( W ) 00119 { *this = v; } 00120 00121 sc_biguint( long v ) 00122 : sc_unsigned( W ) 00123 { *this = v; } 00124 00125 sc_biguint( unsigned long v ) 00126 : sc_unsigned( W ) 00127 { *this = v; } 00128 00129 sc_biguint( int v ) 00130 : sc_unsigned( W ) 00131 { *this = v; } 00132 00133 sc_biguint( unsigned int v ) 00134 : sc_unsigned( W ) 00135 { *this = v; } 00136 00137 sc_biguint( double v ) 00138 : sc_unsigned( W ) 00139 { *this = v; } 00140 00141 sc_biguint( const sc_bv_base& v ) 00142 : sc_unsigned( W ) 00143 { *this = v; } 00144 00145 sc_biguint( const sc_lv_base& v ) 00146 : sc_unsigned( W ) 00147 { *this = v; } 00148 00149 #ifdef SC_INCLUDE_FX 00150 00151 explicit sc_biguint( const sc_fxval& v ) 00152 : sc_unsigned( W ) 00153 { *this = v; } 00154 00155 explicit sc_biguint( const sc_fxval_fast& v ) 00156 : sc_unsigned( W ) 00157 { *this = v; } 00158 00159 explicit sc_biguint( const sc_fxnum& v ) 00160 : sc_unsigned( W ) 00161 { *this = v; } 00162 00163 explicit sc_biguint( const sc_fxnum_fast& v ) 00164 : sc_unsigned( W ) 00165 { *this = v; } 00166 00167 #endif 00168 00169 00170 #ifndef SC_MAX_NBITS 00171 00172 // destructor 00173 00174 ~sc_biguint() 00175 {} 00176 00177 #endif 00178 00179 00180 // assignment operators 00181 00182 sc_biguint<W>& operator = ( const sc_biguint<W>& v ) 00183 { sc_unsigned::operator = ( v ); return *this; } 00184 00185 sc_biguint<W>& operator = ( const sc_unsigned& v ) 00186 { sc_unsigned::operator = ( v ); return *this; } 00187 00188 sc_biguint<W>& operator = ( const sc_unsigned_subref& v ) 00189 { sc_unsigned::operator = ( v ); return *this; } 00190 00191 template< class T > 00192 sc_biguint<W>& operator = ( const sc_generic_base<T>& a ) 00193 { a->to_sc_unsigned(*this); return *this; } 00194 00195 sc_biguint<W>& operator = ( const sc_signed& v ) 00196 { sc_unsigned::operator = ( v ); return *this; } 00197 00198 sc_biguint<W>& operator = ( const sc_signed_subref& v ) 00199 { sc_unsigned::operator = ( v ); return *this; } 00200 00201 sc_biguint<W>& operator = ( const char* v ) 00202 { sc_unsigned::operator = ( v ); return *this; } 00203 00204 sc_biguint<W>& operator = ( int64 v ) 00205 { sc_unsigned::operator = ( v ); return *this; } 00206 00207 sc_biguint<W>& operator = ( uint64 v ) 00208 { sc_unsigned::operator = ( v ); return *this; } 00209 00210 sc_biguint<W>& operator = ( long v ) 00211 { sc_unsigned::operator = ( v ); return *this; } 00212 00213 sc_biguint<W>& operator = ( unsigned long v ) 00214 { sc_unsigned::operator = ( v ); return *this; } 00215 00216 sc_biguint<W>& operator = ( int v ) 00217 { sc_unsigned::operator = ( v ); return *this; } 00218 00219 sc_biguint<W>& operator = ( unsigned int v ) 00220 { sc_unsigned::operator = ( v ); return *this; } 00221 00222 sc_biguint<W>& operator = ( double v ) 00223 { sc_unsigned::operator = ( v ); return *this; } 00224 00225 00226 sc_biguint<W>& operator = ( const sc_bv_base& v ) 00227 { sc_unsigned::operator = ( v ); return *this; } 00228 00229 sc_biguint<W>& operator = ( const sc_lv_base& v ) 00230 { sc_unsigned::operator = ( v ); return *this; } 00231 00232 sc_biguint<W>& operator = ( const sc_int_base& v ) 00233 { sc_unsigned::operator = ( v ); return *this; } 00234 00235 sc_biguint<W>& operator = ( const sc_uint_base& v ) 00236 { sc_unsigned::operator = ( v ); return *this; } 00237 00238 #ifdef SC_INCLUDE_FX 00239 00240 sc_biguint<W>& operator = ( const sc_fxval& v ) 00241 { sc_unsigned::operator = ( v ); return *this; } 00242 00243 sc_biguint<W>& operator = ( const sc_fxval_fast& v ) 00244 { sc_unsigned::operator = ( v ); return *this; } 00245 00246 sc_biguint<W>& operator = ( const sc_fxnum& v ) 00247 { sc_unsigned::operator = ( v ); return *this; } 00248 00249 sc_biguint<W>& operator = ( const sc_fxnum_fast& v ) 00250 { sc_unsigned::operator = ( v ); return *this; } 00251 00252 #endif 00253 }; 00254 00255 } // namespace sc_dt 00256 00257 00258 #endif
1.5.1