00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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 // $Log: sc_biguint.h,v $ 00041 // Revision 1.2 2011/02/18 20:19:14 acg 00042 // Andy Goodrich: updating Copyright notice. 00043 // 00044 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00045 // SystemC 2.3 00046 // 00047 // Revision 1.3 2006/01/13 18:49:31 acg 00048 // Added $Log command so that CVS check in comments are reproduced in the 00049 // source. 00050 // 00051 00052 #ifndef SC_BIGUINT_H 00053 #define SC_BIGUINT_H 00054 00055 00056 #include "sysc/datatypes/int/sc_signed.h" 00057 #include "sysc/datatypes/int/sc_unsigned.h" 00058 00059 namespace sc_dt 00060 { 00061 00062 // classes defined in this module 00063 template <int W> class sc_biguint; 00064 00065 // forward class declarations 00066 class sc_bv_base; 00067 class sc_lv_base; 00068 class sc_fxval; 00069 class sc_fxval_fast; 00070 class sc_fxnum; 00071 class sc_fxnum_fast; 00072 00073 00074 // ---------------------------------------------------------------------------- 00075 // CLASS TEMPLATE : sc_biguint<W> 00076 // 00077 // Arbitrary size unsigned integer type. 00078 // ---------------------------------------------------------------------------- 00079 00080 #ifdef SC_MAX_NBITS 00081 template< int W = SC_MAX_NBITS > 00082 #else 00083 template< int W > 00084 #endif 00085 class sc_biguint 00086 : public sc_unsigned 00087 { 00088 public: 00089 00090 // constructors 00091 00092 sc_biguint() 00093 : sc_unsigned( W ) 00094 {} 00095 00096 sc_biguint( const sc_biguint<W>& v ) 00097 : sc_unsigned( W ) 00098 { *this = v; } 00099 00100 sc_biguint( const sc_unsigned& v ) 00101 : sc_unsigned( W ) 00102 { *this = v; } 00103 00104 sc_biguint( const sc_unsigned_subref& v ) 00105 : sc_unsigned( W ) 00106 { *this = v; } 00107 00108 template< class T > 00109 sc_biguint( const sc_generic_base<T>& a ) 00110 : sc_unsigned( W ) 00111 { a->to_sc_unsigned(*this); } 00112 00113 sc_biguint( const sc_signed& v ) 00114 : sc_unsigned( W ) 00115 { *this = v; } 00116 00117 sc_biguint( const sc_signed_subref& v ) 00118 : sc_unsigned( W ) 00119 { *this = v; } 00120 00121 sc_biguint( const char* v ) 00122 : sc_unsigned( W ) 00123 { *this = v; } 00124 00125 sc_biguint( int64 v ) 00126 : sc_unsigned( W ) 00127 { *this = v; } 00128 00129 sc_biguint( uint64 v ) 00130 : sc_unsigned( W ) 00131 { *this = v; } 00132 00133 sc_biguint( long v ) 00134 : sc_unsigned( W ) 00135 { *this = v; } 00136 00137 sc_biguint( unsigned long v ) 00138 : sc_unsigned( W ) 00139 { *this = v; } 00140 00141 sc_biguint( int v ) 00142 : sc_unsigned( W ) 00143 { *this = v; } 00144 00145 sc_biguint( unsigned int v ) 00146 : sc_unsigned( W ) 00147 { *this = v; } 00148 00149 sc_biguint( double v ) 00150 : sc_unsigned( W ) 00151 { *this = v; } 00152 00153 sc_biguint( const sc_bv_base& v ) 00154 : sc_unsigned( W ) 00155 { *this = v; } 00156 00157 sc_biguint( const sc_lv_base& v ) 00158 : sc_unsigned( W ) 00159 { *this = v; } 00160 00161 #ifdef SC_INCLUDE_FX 00162 00163 explicit sc_biguint( const sc_fxval& v ) 00164 : sc_unsigned( W ) 00165 { *this = v; } 00166 00167 explicit sc_biguint( const sc_fxval_fast& v ) 00168 : sc_unsigned( W ) 00169 { *this = v; } 00170 00171 explicit sc_biguint( const sc_fxnum& v ) 00172 : sc_unsigned( W ) 00173 { *this = v; } 00174 00175 explicit sc_biguint( const sc_fxnum_fast& v ) 00176 : sc_unsigned( W ) 00177 { *this = v; } 00178 00179 #endif 00180 00181 00182 #ifndef SC_MAX_NBITS 00183 00184 // destructor 00185 00186 ~sc_biguint() 00187 {} 00188 00189 #endif 00190 00191 00192 // assignment operators 00193 00194 sc_biguint<W>& operator = ( const sc_biguint<W>& v ) 00195 { sc_unsigned::operator = ( v ); return *this; } 00196 00197 sc_biguint<W>& operator = ( const sc_unsigned& v ) 00198 { sc_unsigned::operator = ( v ); return *this; } 00199 00200 sc_biguint<W>& operator = ( const sc_unsigned_subref& v ) 00201 { sc_unsigned::operator = ( v ); return *this; } 00202 00203 template< class T > 00204 sc_biguint<W>& operator = ( const sc_generic_base<T>& a ) 00205 { a->to_sc_unsigned(*this); return *this; } 00206 00207 sc_biguint<W>& operator = ( const sc_signed& v ) 00208 { sc_unsigned::operator = ( v ); return *this; } 00209 00210 sc_biguint<W>& operator = ( const sc_signed_subref& v ) 00211 { sc_unsigned::operator = ( v ); return *this; } 00212 00213 sc_biguint<W>& operator = ( const char* v ) 00214 { sc_unsigned::operator = ( v ); return *this; } 00215 00216 sc_biguint<W>& operator = ( int64 v ) 00217 { sc_unsigned::operator = ( v ); return *this; } 00218 00219 sc_biguint<W>& operator = ( uint64 v ) 00220 { sc_unsigned::operator = ( v ); return *this; } 00221 00222 sc_biguint<W>& operator = ( long v ) 00223 { sc_unsigned::operator = ( v ); return *this; } 00224 00225 sc_biguint<W>& operator = ( unsigned long v ) 00226 { sc_unsigned::operator = ( v ); return *this; } 00227 00228 sc_biguint<W>& operator = ( int v ) 00229 { sc_unsigned::operator = ( v ); return *this; } 00230 00231 sc_biguint<W>& operator = ( unsigned int v ) 00232 { sc_unsigned::operator = ( v ); return *this; } 00233 00234 sc_biguint<W>& operator = ( double v ) 00235 { sc_unsigned::operator = ( v ); return *this; } 00236 00237 00238 sc_biguint<W>& operator = ( const sc_bv_base& v ) 00239 { sc_unsigned::operator = ( v ); return *this; } 00240 00241 sc_biguint<W>& operator = ( const sc_lv_base& v ) 00242 { sc_unsigned::operator = ( v ); return *this; } 00243 00244 sc_biguint<W>& operator = ( const sc_int_base& v ) 00245 { sc_unsigned::operator = ( v ); return *this; } 00246 00247 sc_biguint<W>& operator = ( const sc_uint_base& v ) 00248 { sc_unsigned::operator = ( v ); return *this; } 00249 00250 #ifdef SC_INCLUDE_FX 00251 00252 sc_biguint<W>& operator = ( const sc_fxval& v ) 00253 { sc_unsigned::operator = ( v ); return *this; } 00254 00255 sc_biguint<W>& operator = ( const sc_fxval_fast& v ) 00256 { sc_unsigned::operator = ( v ); return *this; } 00257 00258 sc_biguint<W>& operator = ( const sc_fxnum& v ) 00259 { sc_unsigned::operator = ( v ); return *this; } 00260 00261 sc_biguint<W>& operator = ( const sc_fxnum_fast& v ) 00262 { sc_unsigned::operator = ( v ); return *this; } 00263 00264 #endif 00265 }; 00266 00267 } // namespace sc_dt 00268 00269 00270 #endif