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