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