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_bigint.h -- Template version of sc_signed. This class enables 00021 compile-time bit widths for sc_signed 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_bigint.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_BIGINT_H 00050 #define SC_BIGINT_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_bigint; 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_bigint<W> 00073 // 00074 // Arbitrary size signed 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_bigint 00083 : public sc_signed 00084 { 00085 public: 00086 00087 // constructors 00088 00089 sc_bigint() 00090 : sc_signed( W ) 00091 {} 00092 00093 sc_bigint( const sc_bigint<W>& v ) 00094 : sc_signed( W ) 00095 { *this = v; } 00096 00097 sc_bigint( const sc_signed& v ) 00098 : sc_signed( W ) 00099 { *this = v; } 00100 00101 sc_bigint( const sc_signed_subref& v ) 00102 : sc_signed( W ) 00103 { *this = v; } 00104 00105 template< class T > 00106 sc_bigint( const sc_generic_base<T>& a ) 00107 : sc_signed( W ) 00108 { a->to_sc_signed(*this); } 00109 00110 sc_bigint( const sc_unsigned& v ) 00111 : sc_signed( W ) 00112 { *this = v; } 00113 00114 sc_bigint( const sc_unsigned_subref& v ) 00115 : sc_signed( W ) 00116 { *this = v; } 00117 00118 sc_bigint( const char* v ) 00119 : sc_signed( W ) 00120 { *this = v; } 00121 00122 sc_bigint( int64 v ) 00123 : sc_signed( W ) 00124 { *this = v; } 00125 00126 sc_bigint( uint64 v ) 00127 : sc_signed( W ) 00128 { *this = v; } 00129 00130 sc_bigint( long v ) 00131 : sc_signed( W ) 00132 { *this = v; } 00133 00134 sc_bigint( unsigned long v ) 00135 : sc_signed( W ) 00136 { *this = v; } 00137 00138 sc_bigint( int v ) 00139 : sc_signed( W ) 00140 { *this = v; } 00141 00142 sc_bigint( unsigned int v ) 00143 : sc_signed( W ) 00144 { *this = v; } 00145 00146 sc_bigint( double v ) 00147 : sc_signed( W ) 00148 { *this = v; } 00149 00150 sc_bigint( const sc_bv_base& v ) 00151 : sc_signed( W ) 00152 { *this = v; } 00153 00154 sc_bigint( const sc_lv_base& v ) 00155 : sc_signed( W ) 00156 { *this = v; } 00157 00158 #ifdef SC_INCLUDE_FX 00159 00160 explicit sc_bigint( const sc_fxval& v ) 00161 : sc_signed( W ) 00162 { *this = v; } 00163 00164 explicit sc_bigint( const sc_fxval_fast& v ) 00165 : sc_signed( W ) 00166 { *this = v; } 00167 00168 explicit sc_bigint( const sc_fxnum& v ) 00169 : sc_signed( W ) 00170 { *this = v; } 00171 00172 explicit sc_bigint( const sc_fxnum_fast& v ) 00173 : sc_signed( W ) 00174 { *this = v; } 00175 00176 #endif 00177 00178 00179 #ifndef SC_MAX_NBITS 00180 00181 // destructor 00182 00183 ~sc_bigint() 00184 {} 00185 00186 #endif 00187 00188 // assignment operators 00189 00190 sc_bigint<W>& operator = ( const sc_bigint<W>& v ) 00191 { sc_signed::operator = ( v ); return *this; } 00192 00193 sc_bigint<W>& operator = ( const sc_signed& v ) 00194 { sc_signed::operator = ( v ); return *this; } 00195 00196 sc_bigint<W>& operator = (const sc_signed_subref& v ) 00197 { sc_signed::operator = ( v ); return *this; } 00198 00199 template< class T > 00200 sc_bigint<W>& operator = ( const sc_generic_base<T>& a ) 00201 { a->to_sc_signed(*this); return *this;} 00202 00203 sc_bigint<W>& operator = ( const sc_unsigned& v ) 00204 { sc_signed::operator = ( v ); return *this; } 00205 00206 sc_bigint<W>& operator = ( const sc_unsigned_subref& v ) 00207 { sc_signed::operator = ( v ); return *this; } 00208 00209 sc_bigint<W>& operator = ( const char* v ) 00210 { sc_signed::operator = ( v ); return *this; } 00211 00212 sc_bigint<W>& operator = ( int64 v ) 00213 { sc_signed::operator = ( v ); return *this; } 00214 00215 sc_bigint<W>& operator = ( uint64 v ) 00216 { sc_signed::operator = ( v ); return *this; } 00217 00218 sc_bigint<W>& operator = ( long v ) 00219 { sc_signed::operator = ( v ); return *this; } 00220 00221 sc_bigint<W>& operator = ( unsigned long v ) 00222 { sc_signed::operator = ( v ); return *this; } 00223 00224 sc_bigint<W>& operator = ( int v ) 00225 { sc_signed::operator = ( v ); return *this; } 00226 00227 sc_bigint<W>& operator = ( unsigned int v ) 00228 { sc_signed::operator = ( v ); return *this; } 00229 00230 sc_bigint<W>& operator = ( double v ) 00231 { sc_signed::operator = ( v ); return *this; } 00232 00233 00234 sc_bigint<W>& operator = ( const sc_bv_base& v ) 00235 { sc_signed::operator = ( v ); return *this; } 00236 00237 sc_bigint<W>& operator = ( const sc_lv_base& v ) 00238 { sc_signed::operator = ( v ); return *this; } 00239 00240 sc_bigint<W>& operator = ( const sc_int_base& v ) 00241 { sc_signed::operator = ( v ); return *this; } 00242 00243 sc_bigint<W>& operator = ( const sc_uint_base& v ) 00244 { sc_signed::operator = ( v ); return *this; } 00245 00246 #ifdef SC_INCLUDE_FX 00247 00248 sc_bigint<W>& operator = ( const sc_fxval& v ) 00249 { sc_signed::operator = ( v ); return *this; } 00250 00251 sc_bigint<W>& operator = ( const sc_fxval_fast& v ) 00252 { sc_signed::operator = ( v ); return *this; } 00253 00254 sc_bigint<W>& operator = ( const sc_fxnum& v ) 00255 { sc_signed::operator = ( v ); return *this; } 00256 00257 sc_bigint<W>& operator = ( const sc_fxnum_fast& v ) 00258 { sc_signed::operator = ( v ); return *this; } 00259 00260 #endif 00261 }; 00262 00263 } // namespace sc_dt 00264 00265 00266 #endif