00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 #ifndef SC_SIGNED_H
00091 #define SC_SIGNED_H
00092 
00093 
00094 #include "sysc/kernel/sc_object.h"
00095 #include "sysc/datatypes/misc/sc_value_base.h"
00096 #include "sysc/utils/sc_iostream.h"
00097 #include "sysc/utils/sc_temporary.h"
00098 #include "sysc/datatypes/int/sc_length_param.h"
00099 #include "sysc/datatypes/int/sc_nbdefs.h"
00100 #include "sysc/datatypes/int/sc_nbutils.h"
00101 #include "sysc/datatypes/int/sc_nbexterns.h"
00102 #include "sysc/datatypes/int/sc_unsigned.h"
00103 
00104 
00105 namespace sc_dt
00106 {
00107 
00108 
00109 class sc_signed_bitref_r;
00110 class sc_signed_bitref;
00111 class sc_signed_subref_r;
00112 class sc_signed_subref;
00113 class sc_concatref;
00114 class sc_signed;
00115 
00116 
00117 class sc_bv_base;
00118 class sc_lv_base;
00119 class sc_int_base;
00120 class sc_uint_base;
00121 class sc_int_subref_r;
00122 class sc_uint_subref_r;
00123 class sc_signed;
00124 class sc_unsigned;
00125 class sc_unsigned_subref_r;
00126 class sc_fxval;
00127 class sc_fxval_fast;
00128 class sc_fxnum;
00129 class sc_fxnum_fast;
00130 
00131 
00132 
00133 sc_signed add_signed_friend(small_type us,
00134                                      int unb,
00135                                      int und,
00136                                      const sc_digit *ud,
00137                                      small_type vs,
00138                                      int vnb,
00139                                      int vnd,
00140                                      const sc_digit *vd);
00141 
00142 sc_signed sub_signed_friend(small_type us,
00143                                      int unb,
00144                                      int und,
00145                                      const sc_digit *ud,
00146                                      small_type vs,
00147                                      int vnb,
00148                                      int vnd,
00149                                      const sc_digit *vd);
00150 
00151 sc_signed mul_signed_friend(small_type s,
00152                                      int unb,
00153                                      int und,
00154                                      const sc_digit *ud,
00155                                      int vnb,
00156                                      int vnd,
00157                                      const sc_digit *vd);
00158 
00159 sc_signed div_signed_friend(small_type s,
00160                                      int unb,
00161                                      int und,
00162                                      const sc_digit *ud,
00163                                      int vnb,
00164                                      int vnd,
00165                                      const sc_digit *vd);
00166 
00167 sc_signed mod_signed_friend(small_type us,
00168                                      int unb,
00169                                      int und,
00170                                      const sc_digit *ud,
00171                                      int vnb,
00172                                      int vnd,
00173                                      const sc_digit *vd);
00174 
00175 sc_signed and_signed_friend(small_type us,
00176                                      int unb,
00177                                      int und,
00178                                      const sc_digit *ud,
00179                                      small_type vs,
00180                                      int vnb,
00181                                      int vnd,
00182                                      const sc_digit *vd);
00183 
00184 sc_signed or_signed_friend(small_type us,
00185                                     int unb,
00186                                     int und,
00187                                     const sc_digit *ud,
00188                                     small_type vs,
00189                                     int vnb,
00190                                     int vnd,
00191                                     const sc_digit *vd);
00192 
00193 sc_signed xor_signed_friend(small_type us,
00194                                      int unb,
00195                                      int und,
00196                                      const sc_digit *ud,
00197                                      small_type vs,
00198                                      int vnb,
00199                                      int vnd,
00200                                      const sc_digit *vd);
00201 
00202 
00203 
00204   
00205 
00206   
00207 
00208   sc_signed operator + (const sc_unsigned&  u, const sc_signed&    v);
00209   sc_signed operator + (const sc_signed&    u, const sc_unsigned&  v);
00210 
00211   sc_signed operator + (const sc_unsigned&  u, int64               v);
00212   sc_signed operator + (const sc_unsigned&  u, long                v);
00213   inline sc_signed operator + (const sc_unsigned&  u, int                 v);
00214 
00215   sc_signed operator + (int64               u, const sc_unsigned&  v);
00216   sc_signed operator + (long                u, const sc_unsigned&  v);
00217   inline sc_signed operator + (int                 u, const sc_unsigned&  v);
00218 
00219   sc_signed operator + (const sc_signed&    u, const sc_signed&    v);
00220   sc_signed operator + (const sc_signed&    u, int64               v);
00221   sc_signed operator + (const sc_signed&    u, uint64              v);
00222   sc_signed operator + (const sc_signed&    u, long                v);
00223   sc_signed operator + (const sc_signed&    u, unsigned long       v);
00224   inline sc_signed operator + (const sc_signed&    u, int                 v);
00225   inline sc_signed operator + (const sc_signed&    u, unsigned int        v);
00226 
00227   sc_signed operator + (int64               u, const sc_signed&    v);
00228   sc_signed operator + (uint64              u, const sc_signed&    v);
00229   sc_signed operator + (long                u, const sc_signed&    v);
00230   sc_signed operator + (unsigned long       u, const sc_signed&    v);
00231   inline sc_signed operator + (int                 u, const sc_signed&    v);
00232   inline sc_signed operator + (unsigned int        u, const sc_signed&    v);
00233 
00234   sc_signed operator + (const sc_unsigned&  u, const sc_int_base&  v);
00235   sc_signed operator + (const sc_int_base&  u, const sc_unsigned&  v);
00236   sc_signed operator + (const sc_signed&    u, const sc_int_base&  v);
00237   sc_signed operator + (const sc_signed&    u, const sc_uint_base& v);
00238   sc_signed operator + (const sc_int_base&  u, const sc_signed&    v);
00239   sc_signed operator + (const sc_uint_base& u, const sc_signed&    v);
00240 
00241 
00242 
00243   
00244 
00245   sc_signed operator - (const sc_unsigned&  u, const sc_signed&    v);
00246   sc_signed operator - (const sc_signed&    u, const sc_unsigned&  v);
00247 
00248   sc_signed operator - (const sc_unsigned&  u, const sc_unsigned&  v);
00249   sc_signed operator - (const sc_unsigned&  u, int64               v);
00250   sc_signed operator - (const sc_unsigned&  u, uint64              v);
00251   sc_signed operator - (const sc_unsigned&  u, long                v);
00252   sc_signed operator - (const sc_unsigned&  u, unsigned long       v);
00253   inline sc_signed operator - (const sc_unsigned&  u, int                v);
00254   inline sc_signed operator - (const sc_unsigned&  u, unsigned int       v);
00255 
00256   sc_signed operator - (int64               u, const sc_unsigned&  v);
00257   sc_signed operator - (uint64              u, const sc_unsigned&  v);
00258   sc_signed operator - (long                u, const sc_unsigned&  v);
00259   sc_signed operator - (unsigned long       u, const sc_unsigned&  v);
00260   inline sc_signed operator - (int                 u, const sc_unsigned&  v);
00261   inline sc_signed operator - (unsigned int        u, const sc_unsigned& v);
00262 
00263   sc_signed operator - (const sc_signed&    u, const sc_signed&    v);
00264   sc_signed operator - (const sc_signed&    u, int64               v);
00265   sc_signed operator - (const sc_signed&    u, uint64              v);
00266   sc_signed operator - (const sc_signed&    u, long                v);
00267   sc_signed operator - (const sc_signed&    u, unsigned long       v);
00268   inline sc_signed operator - (const sc_signed&    u, int                 v);
00269   inline sc_signed operator - (const sc_signed&    u, unsigned int        v);
00270 
00271   sc_signed operator - (int64               u, const sc_signed&    v);
00272   sc_signed operator - (uint64              u, const sc_signed&    v);
00273   sc_signed operator - (long                u, const sc_signed&    v);
00274   sc_signed operator - (unsigned long       u, const sc_signed&    v);
00275   inline sc_signed operator - (int                 u, const sc_signed&    v);
00276   inline sc_signed operator - (unsigned int        u, const sc_signed&    v);
00277 
00278 
00279   sc_signed operator - (const sc_unsigned&  u, const sc_int_base&  v);
00280   sc_signed operator - (const sc_unsigned&  u, const sc_uint_base& v);
00281   sc_signed operator - (const sc_int_base&  u, const sc_unsigned&  v);
00282   sc_signed operator - (const sc_uint_base& u, const sc_unsigned&  v);
00283   sc_signed operator - (const sc_signed&    u, const sc_int_base&  v);
00284   sc_signed operator - (const sc_signed&    u, const sc_uint_base& v);
00285   sc_signed operator - (const sc_int_base&  u, const sc_signed&    v);
00286   sc_signed operator - (const sc_uint_base& u, const sc_signed&    v);
00287 
00288 
00289 
00290   
00291 
00292   sc_signed operator * (const sc_unsigned&  u, const sc_signed&    v);
00293   sc_signed operator * (const sc_signed&    u, const sc_unsigned&  v);
00294 
00295   sc_signed operator * (const sc_unsigned&  u, int64               v);
00296   sc_signed operator * (const sc_unsigned&  u, long                v);
00297   inline sc_signed operator * (const sc_unsigned&  u, int                 v);
00298 
00299   sc_signed operator * (int64               u, const sc_unsigned&  v);
00300   sc_signed operator * (long                u, const sc_unsigned&  v);
00301   inline sc_signed operator * (int                 u, const sc_unsigned&  v);
00302 
00303   sc_signed operator * (const sc_signed&  u, const sc_signed&  v);
00304   sc_signed operator * (const sc_signed&  u, int64             v);
00305   sc_signed operator * (const sc_signed&  u, uint64            v);
00306   sc_signed operator * (const sc_signed&  u, long              v);
00307   sc_signed operator * (const sc_signed&  u, unsigned long     v);
00308   inline sc_signed operator * (const sc_signed&  u, int               v);
00309   inline sc_signed operator * (const sc_signed&  u, unsigned int      v);
00310 
00311   sc_signed operator * (int64             u, const sc_signed&  v);
00312   sc_signed operator * (uint64            u, const sc_signed&  v);
00313   sc_signed operator * (long              u, const sc_signed&  v);
00314   sc_signed operator * (unsigned long     u, const sc_signed&  v);
00315   inline sc_signed operator * (int               u, const sc_signed&  v);
00316   inline sc_signed operator * (unsigned int      u, const sc_signed&  v);
00317 
00318   sc_signed operator * (const sc_unsigned&  u, const sc_int_base&  v);
00319   sc_signed operator * (const sc_int_base&  u, const sc_unsigned&  v);
00320   sc_signed operator * (const sc_signed&    u, const sc_int_base&  v);
00321   sc_signed operator * (const sc_signed&    u, const sc_uint_base& v);
00322   sc_signed operator * (const sc_int_base&  u, const sc_signed&    v);
00323   sc_signed operator * (const sc_uint_base& u, const sc_signed&    v);
00324 
00325 
00326 
00327   
00328 
00329   sc_signed operator / (const sc_unsigned&  u, const sc_signed&    v);
00330   sc_signed operator / (const sc_signed&    u, const sc_unsigned&  v);
00331 
00332   sc_signed operator / (const sc_unsigned&  u, int64               v);
00333   sc_signed operator / (const sc_unsigned&  u, long                v);
00334   inline sc_signed operator / (const sc_unsigned&  u, int                 v);
00335 
00336   sc_signed operator / (int64               u, const sc_unsigned&  v);
00337   sc_signed operator / (long                u, const sc_unsigned&  v);
00338   inline sc_signed operator / (int                 u, const sc_unsigned&  v);
00339 
00340   sc_signed operator / (const sc_signed&    u, const sc_signed&    v);
00341   sc_signed operator / (const sc_signed&    u, int64               v);
00342   sc_signed operator / (const sc_signed&    u, uint64              v);
00343   sc_signed operator / (const sc_signed&    u, long                v);
00344   sc_signed operator / (const sc_signed&    u, unsigned long       v);
00345   inline sc_signed operator / (const sc_signed&    u, int                 v);
00346   inline sc_signed operator / (const sc_signed&    u, unsigned int        v);
00347 
00348   sc_signed operator / (int64               u, const sc_signed&    v);
00349   sc_signed operator / (uint64              u, const sc_signed&    v);
00350   sc_signed operator / (long                u, const sc_signed&    v);
00351   sc_signed operator / (unsigned long       u, const sc_signed&    v);
00352   inline sc_signed operator / (int                 u, const sc_signed&    v);
00353   inline sc_signed operator / (unsigned int        u, const sc_signed&    v);
00354 
00355   sc_signed operator / (const sc_unsigned&  u, const sc_int_base&  v);
00356   sc_signed operator / (const sc_int_base&  u, const sc_unsigned&  v);
00357   sc_signed operator / (const sc_signed&    u, const sc_int_base&  v);
00358   sc_signed operator / (const sc_signed&    u, const sc_uint_base& v);
00359   sc_signed operator / (const sc_int_base&  u, const sc_signed&    v);
00360   sc_signed operator / (const sc_uint_base& u, const sc_signed&    v);
00361 
00362 
00363 
00364   
00365 
00366   sc_signed operator % (const sc_unsigned&  u, const sc_signed&    v);
00367   sc_signed operator % (const sc_signed&    u, const sc_unsigned&  v);
00368 
00369   sc_signed operator % (const sc_unsigned&  u, int64               v);
00370   sc_signed operator % (const sc_unsigned&  u, long                v);
00371   inline sc_signed operator % (const sc_unsigned&  u, int                 v);
00372 
00373   sc_signed operator % (int64               u, const sc_unsigned&  v);
00374   sc_signed operator % (long                u, const sc_unsigned&  v);
00375   inline sc_signed operator % (int                 u, const sc_unsigned&  v);
00376 
00377   sc_signed operator % (const sc_signed&    u, const sc_signed&    v);
00378   sc_signed operator % (const sc_signed&    u, int64               v);
00379   sc_signed operator % (const sc_signed&    u, uint64              v);
00380   sc_signed operator % (const sc_signed&    u, long                v);
00381   sc_signed operator % (const sc_signed&    u, unsigned long       v);
00382   inline sc_signed operator % (const sc_signed&    u, int                 v);
00383   inline sc_signed operator % (const sc_signed&    u, unsigned int        v);
00384 
00385   sc_signed operator % (int64               u, const sc_signed&    v);
00386   sc_signed operator % (uint64              u, const sc_signed&    v);
00387   sc_signed operator % (long                u, const sc_signed&    v);
00388   sc_signed operator % (unsigned long       u, const sc_signed&    v);
00389   inline sc_signed operator % (int                 u, const sc_signed&    v);
00390   inline sc_signed operator % (unsigned int        u, const sc_signed&    v);
00391 
00392   sc_signed operator % (const sc_unsigned&  u, const sc_int_base&  v);
00393   sc_signed operator % (const sc_int_base&  u, const sc_unsigned&  v);
00394   sc_signed operator % (const sc_signed&    u, const sc_int_base&  v);
00395   sc_signed operator % (const sc_signed&    u, const sc_uint_base& v);
00396   sc_signed operator % (const sc_int_base&  u, const sc_signed&    v);
00397   sc_signed operator % (const sc_uint_base& u, const sc_signed&    v);
00398 
00399 
00400 
00401   
00402 
00403   
00404 
00405   sc_signed operator & (const sc_unsigned&  u, const sc_signed&    v);
00406   sc_signed operator & (const sc_signed&    u, const sc_unsigned&  v);
00407 
00408   sc_signed operator & (const sc_unsigned&  u, int64               v);
00409   sc_signed operator & (const sc_unsigned&  u, long                v);
00410   inline sc_signed operator & (const sc_unsigned&  u, int                 v);
00411 
00412   sc_signed operator & (int64               u, const sc_unsigned&  v);
00413   sc_signed operator & (long                u, const sc_unsigned&  v);
00414   inline sc_signed operator & (int                 u, const sc_unsigned&  v);
00415 
00416   sc_signed operator & (const sc_signed&    u, const sc_signed&    v);
00417   sc_signed operator & (const sc_signed&    u, int64               v);
00418   sc_signed operator & (const sc_signed&    u, uint64              v);
00419   sc_signed operator & (const sc_signed&    u, long                v);
00420   sc_signed operator & (const sc_signed&    u, unsigned long       v);
00421   inline sc_signed operator & (const sc_signed&    u, int                 v);
00422   inline sc_signed operator & (const sc_signed&    u, unsigned int        v);
00423 
00424   sc_signed operator & (int64             u, const sc_signed&  v);
00425   sc_signed operator & (uint64            u, const sc_signed&  v);
00426   sc_signed operator & (long              u, const sc_signed&  v);
00427   sc_signed operator & (unsigned long     u, const sc_signed&  v);
00428   inline sc_signed operator & (int               u, const sc_signed&  v);
00429   inline sc_signed operator & (unsigned int      u, const sc_signed&  v);
00430 
00431   sc_signed operator & (const sc_unsigned&  u, const sc_int_base&  v);
00432   sc_signed operator & (const sc_int_base&  u, const sc_unsigned&  v);
00433   sc_signed operator & (const sc_signed&    u, const sc_int_base&  v);
00434   sc_signed operator & (const sc_signed&    u, const sc_uint_base& v);
00435   sc_signed operator & (const sc_int_base&  u, const sc_signed&    v);
00436   sc_signed operator & (const sc_uint_base& u, const sc_signed&    v);
00437 
00438 
00439 
00440   
00441 
00442   sc_signed operator | (const sc_unsigned&  u, const sc_signed&    v);
00443   sc_signed operator | (const sc_signed&    u, const sc_unsigned&  v);
00444 
00445   sc_signed operator | (const sc_unsigned&  u, int64               v);
00446   sc_signed operator | (const sc_unsigned&  u, long                v);
00447   inline sc_signed operator | (const sc_unsigned&  u, int                 v);
00448 
00449   sc_signed operator | (int64               u, const sc_unsigned&  v);
00450   sc_signed operator | (long                u, const sc_unsigned&  v);
00451   inline sc_signed operator | (int                 u, const sc_unsigned&  v);
00452 
00453   sc_signed operator | (const sc_signed&    u, const sc_signed&    v);
00454   sc_signed operator | (const sc_signed&    u, int64               v);
00455   sc_signed operator | (const sc_signed&    u, uint64              v);
00456   sc_signed operator | (const sc_signed&    u, long                v);
00457   sc_signed operator | (const sc_signed&    u, unsigned long       v);
00458   inline sc_signed operator | (const sc_signed&    u, int                 v);
00459   inline sc_signed operator | (const sc_signed&    u, unsigned int        v);
00460 
00461   sc_signed operator | (int64             u, const sc_signed&  v);
00462   sc_signed operator | (uint64            u, const sc_signed&  v);
00463   sc_signed operator | (long              u, const sc_signed&  v);
00464   sc_signed operator | (unsigned long     u, const sc_signed&  v);
00465   inline sc_signed operator | (int               u, const sc_signed&  v);
00466   inline sc_signed operator | (unsigned int      u, const sc_signed&  v);
00467 
00468   sc_signed operator | (const sc_unsigned&  u, const sc_int_base&  v);
00469   sc_signed operator | (const sc_int_base&  u, const sc_unsigned&  v);
00470   sc_signed operator | (const sc_signed&    u, const sc_int_base&  v);
00471   sc_signed operator | (const sc_signed&    u, const sc_uint_base& v);
00472   sc_signed operator | (const sc_int_base&  u, const sc_signed&    v);
00473   sc_signed operator | (const sc_uint_base& u, const sc_signed&    v);
00474 
00475 
00476 
00477   
00478 
00479   sc_signed operator ^ (const sc_unsigned&  u, const sc_signed&    v);
00480   sc_signed operator ^ (const sc_signed&    u, const sc_unsigned&  v);
00481 
00482   sc_signed operator ^ (const sc_unsigned&  u, int64               v);
00483   sc_signed operator ^ (const sc_unsigned&  u, long                v);
00484   inline sc_signed operator ^ (const sc_unsigned&  u, int                 v);
00485 
00486   sc_signed operator ^ (int64               u, const sc_unsigned&  v);
00487   sc_signed operator ^ (long                u, const sc_unsigned&  v);
00488   inline sc_signed operator ^ (int                 u, const sc_unsigned&  v);
00489 
00490   sc_signed operator ^ (const sc_signed&    u, const sc_signed&    v);
00491   sc_signed operator ^ (const sc_signed&    u, int64               v);
00492   sc_signed operator ^ (const sc_signed&    u, uint64              v);
00493   sc_signed operator ^ (const sc_signed&    u, long                v);
00494   sc_signed operator ^ (const sc_signed&    u, unsigned long       v);
00495   inline sc_signed operator ^ (const sc_signed&    u, int                 v);
00496   inline sc_signed operator ^ (const sc_signed&    u, unsigned int        v);
00497 
00498   sc_signed operator ^ (int64             u, const sc_signed&  v);
00499   sc_signed operator ^ (uint64            u, const sc_signed&  v);
00500   sc_signed operator ^ (long              u, const sc_signed&  v);
00501   sc_signed operator ^ (unsigned long     u, const sc_signed&  v);
00502   inline sc_signed operator ^ (int               u, const sc_signed&  v);
00503   inline sc_signed operator ^ (unsigned int      u, const sc_signed&  v);
00504 
00505   sc_signed operator ^ (const sc_unsigned&  u, const sc_int_base&  v);
00506   sc_signed operator ^ (const sc_int_base&  u, const sc_unsigned&  v);
00507   sc_signed operator ^ (const sc_signed&    u, const sc_int_base&  v);
00508   sc_signed operator ^ (const sc_signed&    u, const sc_uint_base& v);
00509   sc_signed operator ^ (const sc_int_base&  u, const sc_signed&    v);
00510   sc_signed operator ^ (const sc_uint_base& u, const sc_signed&    v);
00511 
00512 
00513 
00514   
00515 
00516   
00517 
00518   sc_unsigned operator << (const sc_unsigned&  u, const sc_signed&    v);
00519     sc_signed operator << (const sc_signed&    u, const sc_unsigned&  v);
00520 
00521     sc_signed operator << (const sc_signed&    u, const sc_signed&    v);
00522     sc_signed operator << (const sc_signed&    u, int64               v);
00523     sc_signed operator << (const sc_signed&    u, uint64              v);
00524     sc_signed operator << (const sc_signed&    u, long                v);
00525     sc_signed operator << (const sc_signed&    u, unsigned long       v);
00526   inline   sc_signed operator << (const sc_signed&    u, int                 v);
00527   inline   sc_signed operator << (const sc_signed&    u, unsigned int        v);
00528 
00529     sc_signed operator << (const sc_signed&    u, const sc_int_base&  v);
00530     sc_signed operator << (const sc_signed&    u, const sc_uint_base& v);
00531 
00532 
00533 
00534   
00535 
00536   sc_unsigned operator >> (const sc_unsigned&  u, const sc_signed&    v);
00537     sc_signed operator >> (const sc_signed&    u, const sc_unsigned&  v);
00538 
00539     sc_signed operator >> (const sc_signed&    u, const sc_signed&    v);
00540     sc_signed operator >> (const sc_signed&    u, int64               v);
00541     sc_signed operator >> (const sc_signed&    u, uint64              v);
00542     sc_signed operator >> (const sc_signed&    u, long                v);
00543     sc_signed operator >> (const sc_signed&    u, unsigned long       v);
00544   inline   sc_signed operator >> (const sc_signed&    u, int                 v);
00545   inline   sc_signed operator >> (const sc_signed&    u, unsigned int        v);
00546 
00547   sc_signed operator >> (const sc_signed&    u, const sc_int_base&  v);
00548   sc_signed operator >> (const sc_signed&    u, const sc_uint_base& v);
00549 
00550 
00551 
00552   
00553   sc_signed operator + (const sc_signed&   u);
00554   sc_signed operator - (const sc_signed&   u);
00555   sc_signed operator - (const sc_unsigned& u);
00556 
00557   
00558 
00559   
00560 
00561   bool operator == (const sc_unsigned&  u, const sc_signed&    v);
00562   bool operator == (const sc_signed&    u, const sc_unsigned&  v);
00563 
00564   bool operator == (const sc_signed&    u, const sc_signed&    v);
00565   bool operator == (const sc_signed&    u, int64               v);
00566   bool operator == (const sc_signed&    u, uint64              v);
00567   bool operator == (const sc_signed&    u, long                v);
00568   bool operator == (const sc_signed&    u, unsigned long       v);
00569   inline bool operator == (const sc_signed&    u, int                 v);
00570   inline bool operator == (const sc_signed&    u, unsigned int        v);
00571 
00572   bool operator == (int64               u, const sc_signed&    v);
00573   bool operator == (uint64              u, const sc_signed&    v);
00574   bool operator == (long                u, const sc_signed&    v);
00575   bool operator == (unsigned long       u, const sc_signed&    v);
00576   inline bool operator == (int                 u, const sc_signed&    v);
00577   inline bool operator == (unsigned int        u, const sc_signed&    v);
00578 
00579   bool operator == (const sc_signed&    u, const sc_int_base&  v);
00580   bool operator == (const sc_signed&    u, const sc_uint_base& v);
00581   bool operator == (const sc_int_base&  u, const sc_signed&    v);
00582   bool operator == (const sc_uint_base& u, const sc_signed&    v);
00583 
00584   
00585 
00586   bool operator != (const sc_unsigned&  u, const sc_signed&    v);
00587   bool operator != (const sc_signed&    u, const sc_unsigned&  v);
00588 
00589   bool operator != (const sc_signed&    u, const sc_signed&    v);
00590   bool operator != (const sc_signed&    u, int64               v);
00591   bool operator != (const sc_signed&    u, uint64              v);
00592   bool operator != (const sc_signed&    u, long                v);
00593   bool operator != (const sc_signed&    u, unsigned long       v);
00594   inline bool operator != (const sc_signed&    u, int                 v);
00595   inline bool operator != (const sc_signed&    u, unsigned int        v);
00596 
00597   bool operator != (int64               u, const sc_signed&    v);
00598   bool operator != (uint64              u, const sc_signed&    v);
00599   bool operator != (long                u, const sc_signed&    v);
00600   bool operator != (unsigned long       u, const sc_signed&    v);
00601   inline bool operator != (int                 u, const sc_signed&    v);
00602   inline bool operator != (unsigned int        u, const sc_signed&    v);
00603 
00604   bool operator != (const sc_signed&    u, const sc_int_base&  v);
00605   bool operator != (const sc_signed&    u, const sc_uint_base& v);
00606   bool operator != (const sc_int_base&  u, const sc_signed&    v);
00607   bool operator != (const sc_uint_base& u, const sc_signed&    v);
00608 
00609   
00610 
00611   bool operator < (const sc_unsigned&  u, const sc_signed&    v);
00612   bool operator < (const sc_signed&    u, const sc_unsigned&  v);
00613 
00614   bool operator < (const sc_signed&    u, const sc_signed&    v);
00615   bool operator < (const sc_signed&    u, int64               v);
00616   bool operator < (const sc_signed&    u, uint64              v);
00617   bool operator < (const sc_signed&    u, long                v);
00618   bool operator < (const sc_signed&    u, unsigned long       v);
00619   inline bool operator < (const sc_signed&    u, int                 v);
00620   inline bool operator < (const sc_signed&    u, unsigned int        v);
00621 
00622   bool operator < (int64               u, const sc_signed&    v);
00623   bool operator < (uint64              u, const sc_signed&    v);
00624   bool operator < (long                u, const sc_signed&    v);
00625   bool operator < (unsigned long       u, const sc_signed&    v);
00626   inline bool operator < (int                 u, const sc_signed&    v);
00627   inline bool operator < (unsigned int        u, const sc_signed&    v);
00628 
00629   bool operator < (const sc_signed&    u, const sc_int_base&  v);
00630   bool operator < (const sc_signed&    u, const sc_uint_base& v);
00631   bool operator < (const sc_int_base&  u, const sc_signed&    v);
00632   bool operator < (const sc_uint_base& u, const sc_signed&    v);
00633 
00634   
00635 
00636   bool operator <= (const sc_unsigned&  u, const sc_signed&    v);
00637   bool operator <= (const sc_signed&    u, const sc_unsigned&  v);
00638 
00639   bool operator <= (const sc_signed&    u, const sc_signed&    v);
00640   bool operator <= (const sc_signed&    u, int64               v);
00641   bool operator <= (const sc_signed&    u, uint64              v);
00642   bool operator <= (const sc_signed&    u, long                v);
00643   bool operator <= (const sc_signed&    u, unsigned long       v);
00644   inline bool operator <= (const sc_signed&    u, int                 v);
00645   inline bool operator <= (const sc_signed&    u, unsigned int        v);
00646 
00647   bool operator <= (int64               u, const sc_signed&    v);
00648   bool operator <= (uint64              u, const sc_signed&    v);
00649   bool operator <= (long                u, const sc_signed&    v);
00650   bool operator <= (unsigned long       u, const sc_signed&    v);
00651   inline bool operator <= (int                 u, const sc_signed&    v);
00652   inline bool operator <= (unsigned int        u, const sc_signed&    v);
00653 
00654   bool operator <= (const sc_signed&    u, const sc_int_base&  v);
00655   bool operator <= (const sc_signed&    u, const sc_uint_base& v);
00656   bool operator <= (const sc_int_base&  u, const sc_signed&    v);
00657   bool operator <= (const sc_uint_base& u, const sc_signed&    v);
00658 
00659   
00660 
00661   bool operator > (const sc_unsigned&  u, const sc_signed&    v);
00662   bool operator > (const sc_signed&    u, const sc_unsigned&  v);
00663 
00664   bool operator > (const sc_signed&    u, const sc_signed&    v);
00665   bool operator > (const sc_signed&    u, int64               v);
00666   bool operator > (const sc_signed&    u, uint64              v);
00667   bool operator > (const sc_signed&    u, long                v);
00668   bool operator > (const sc_signed&    u, unsigned long       v);
00669   inline bool operator > (const sc_signed&    u, int                 v);
00670   inline bool operator > (const sc_signed&    u, unsigned int        v);
00671 
00672   bool operator > (int64               u, const sc_signed&    v);
00673   bool operator > (uint64              u, const sc_signed&    v);
00674   bool operator > (long                u, const sc_signed&    v);
00675   bool operator > (unsigned long       u, const sc_signed&    v);
00676   inline bool operator > (int                 u, const sc_signed&    v);
00677   inline bool operator > (unsigned int        u, const sc_signed&    v);
00678 
00679   bool operator > (const sc_signed&    u, const sc_int_base&  v);
00680   bool operator > (const sc_signed&    u, const sc_uint_base& v);
00681   bool operator > (const sc_int_base&  u, const sc_signed&    v);
00682   bool operator > (const sc_uint_base& u, const sc_signed&    v);
00683 
00684   
00685 
00686   bool operator >= (const sc_unsigned&  u, const sc_signed&    v);
00687   bool operator >= (const sc_signed&    u, const sc_unsigned&  v);
00688 
00689   bool operator >= (const sc_signed&    u, const sc_signed&    v);
00690   bool operator >= (const sc_signed&    u, int64               v);
00691   bool operator >= (const sc_signed&    u, uint64              v);
00692   bool operator >= (const sc_signed&    u, long                v);
00693   bool operator >= (const sc_signed&    u, unsigned long       v);
00694   inline bool operator >= (const sc_signed&    u, int                 v);
00695   inline bool operator >= (const sc_signed&    u, unsigned int        v);
00696 
00697   bool operator >= (int64               u, const sc_signed&    v);
00698   bool operator >= (uint64              u, const sc_signed&    v);
00699   bool operator >= (long                u, const sc_signed&    v);
00700   bool operator >= (unsigned long       u, const sc_signed&    v);
00701   inline bool operator >= (int                 u, const sc_signed&    v);
00702   inline bool operator >= (unsigned int        u, const sc_signed&    v);
00703 
00704   bool operator >= (const sc_signed&    u, const sc_int_base&  v);
00705   bool operator >= (const sc_signed&    u, const sc_uint_base& v);
00706   bool operator >= (const sc_int_base&  u, const sc_signed&    v);
00707   bool operator >= (const sc_uint_base& u, const sc_signed&    v);
00708 
00709   
00710   sc_signed operator ~ (const sc_signed& u);
00711 
00712 
00713 
00714 
00715 
00716 
00717 
00718 class sc_signed_bitref_r : public sc_value_base
00719 {
00720     friend class sc_signed;
00721 
00722 protected:
00723 
00724     
00725 
00726     sc_signed_bitref_r() : sc_value_base(), m_index(0), m_obj_p(0)
00727         {}
00728 
00729     void initialize( const sc_signed* obj_p, int index_ )
00730         {
00731             m_index = index_;
00732             m_obj_p = ( CCAST<sc_signed*>( obj_p ) );
00733         }
00734 
00735 public:
00736 
00737     
00738 
00739     virtual ~sc_signed_bitref_r()
00740         {}
00741 
00742     
00743 
00744     sc_signed_bitref_r( const sc_signed_bitref_r& a )
00745         : sc_value_base(a), m_index( a.m_index ), m_obj_p( a.m_obj_p )
00746         {}
00747 
00748     
00749 
00750     int length() const
00751         { return 1; }
00752 
00753 
00754     
00755 
00756     operator uint64 () const;
00757     bool operator ! () const;
00758     bool operator ~ () const;
00759 
00760 
00761     
00762 
00763     bool value() const
00764         { return operator uint64(); }
00765 
00766     bool to_bool() const
00767         { return operator uint64(); }
00768 
00769     
00770 
00771     virtual int concat_length(bool* xz_present_p) const
00772         { if ( xz_present_p ) *xz_present_p = false; return 1; }
00773     virtual uint64 concat_get_uint64() const
00774         { return (uint64)operator uint64(); }
00775     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const
00776         {
00777             int  bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00778             int  word_i = low_i / BITS_PER_DIGIT;
00779             dst_p[word_i] &= ~bit_mask;
00780             return false;
00781         }
00782     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const
00783         {
00784             int  bit_mask = 1 << (low_i % BITS_PER_DIGIT);
00785             bool result;        
00786             int  word_i = low_i / BITS_PER_DIGIT;
00787             if ( operator uint64() )
00788             {
00789                 dst_p[word_i] |= bit_mask;
00790                 result = true;
00791             }
00792             else
00793             {
00794                 dst_p[word_i] &= ~bit_mask;
00795                 result = false;
00796             }
00797             return result;
00798         }
00799 
00800 
00801     
00802 
00803     void print( ::std::ostream& os = ::std::cout ) const
00804         { os << to_bool(); }
00805 
00806 protected:
00807 
00808     int        m_index;  
00809     sc_signed* m_obj_p;  
00810 
00811 private:
00812 
00813     
00814     const sc_signed_bitref_r& operator = ( const sc_signed_bitref_r& );
00815 };
00816 
00817 
00818 
00819 inline
00820 ::std::ostream&
00821 operator << ( ::std::ostream&, const sc_signed_bitref_r& );
00822 
00823 
00824 
00825 
00826 
00827 
00828 
00829 
00830 class sc_signed_bitref
00831     : public sc_signed_bitref_r
00832 {
00833     friend class sc_signed;
00834     friend class sc_core::sc_vpool<sc_signed_bitref>;
00835 
00836 
00837     
00838 
00839 protected:
00840 
00841     sc_signed_bitref() : sc_signed_bitref_r()
00842         {}
00843 
00844 public:
00845 
00846     
00847 
00848     sc_signed_bitref( const sc_signed_bitref& a )
00849         : sc_signed_bitref_r( a )
00850         {}
00851 
00852     
00853 
00854     const sc_signed_bitref& operator = ( const sc_signed_bitref_r& );
00855     const sc_signed_bitref& operator = ( const sc_signed_bitref& );
00856     const sc_signed_bitref& operator = ( bool );
00857 
00858     const sc_signed_bitref& operator &= ( bool );
00859     const sc_signed_bitref& operator |= ( bool );
00860     const sc_signed_bitref& operator ^= ( bool );
00861 
00862     
00863 
00864     virtual void concat_set(int64 src, int low_i);
00865     virtual void concat_set(const sc_signed& src, int low_i);
00866     virtual void concat_set(const sc_unsigned& src, int low_i);
00867     virtual void concat_set(uint64 src, int low_i);
00868 
00869 
00870     
00871 
00872     void scan( ::std::istream& is = ::std::cin );
00873 
00874 protected:
00875     static sc_core::sc_vpool<sc_signed_bitref> m_pool;
00876 };
00877 
00878 
00879 
00880 inline
00881 ::std::istream&
00882 operator >> ( ::std::istream&, sc_signed_bitref& );
00883 
00884 
00885 
00886 
00887 
00888 
00889 
00890 
00891 class sc_signed_subref_r : public sc_value_base
00892 {
00893     friend class sc_signed;
00894     friend class sc_signed_signal;
00895     friend class sc_unsigned;
00896 
00897 protected:
00898 
00899     
00900 
00901     sc_signed_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0)
00902         {}
00903 
00904     void initialize( const sc_signed* obj_p, int left_, int right_ )
00905         {
00906             m_obj_p = ( CCAST<sc_signed*>( obj_p ));
00907             m_left = left_;
00908             m_right = right_;
00909         }
00910 
00911 
00912 public:
00913 
00914     
00915 
00916     virtual ~sc_signed_subref_r()
00917         {}
00918 
00919     
00920 
00921     sc_signed_subref_r( const sc_signed_subref_r& a )
00922         : sc_value_base(a), m_left( a.m_left ), m_obj_p( a.m_obj_p ), 
00923           m_right( a.m_right )
00924         {}
00925 
00926 
00927     
00928 
00929     int length() const
00930         { return m_left >= m_right ? (m_left-m_right+1) : (m_right-m_left+1 ); }
00931 
00932 
00933     
00934 
00935     operator sc_unsigned () const;
00936 
00937 
00938     
00939 
00940     int           to_int() const;
00941     unsigned int  to_uint() const;
00942     long          to_long() const;
00943     unsigned long to_ulong() const;
00944     int64         to_int64() const;
00945     uint64        to_uint64() const;
00946     double        to_double() const;
00947 
00948 
00949     
00950 
00951     const std::string to_string( sc_numrep numrep = SC_DEC ) const;
00952     const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
00953 
00954     
00955 
00956     virtual int concat_length(bool* xz_present_p) const
00957         {
00958             if ( xz_present_p ) *xz_present_p = false;
00959             return m_left - m_right + 1;
00960         }
00961     virtual uint64 concat_get_uint64() const;
00962     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
00963     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
00964 
00965     
00966 
00967     bool and_reduce() const;
00968     bool nand_reduce() const;
00969     bool or_reduce() const;
00970     bool nor_reduce() const;
00971     bool xor_reduce() const ;
00972     bool xnor_reduce() const;
00973 
00974 
00975     
00976 
00977     void print( ::std::ostream& os = ::std::cout ) const
00978         { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
00979 
00980 protected:
00981 
00982     int        m_left;   
00983     sc_signed* m_obj_p;  
00984     int        m_right;  
00985 
00986 private:
00987     const sc_signed_subref_r& operator = ( const sc_signed_subref_r& );
00988 
00989 };
00990 
00991 
00992 
00993 inline
00994 ::std::ostream&
00995 operator << ( ::std::ostream&, const sc_signed_subref_r& );
00996 
00997 
00998 
00999 
01000 
01001 
01002 
01003 
01004 class sc_signed_subref
01005     : public sc_signed_subref_r
01006 {
01007     friend class sc_signed;
01008     friend class sc_core::sc_vpool<sc_signed_subref>;
01009 
01010 
01011     
01012 
01013     sc_signed_subref() : sc_signed_subref_r()
01014         {}
01015 
01016 public:
01017 
01018     
01019 
01020     sc_signed_subref( const sc_signed_subref& a )
01021         : sc_signed_subref_r( a )
01022         {}
01023 
01024 
01025     
01026 
01027     const sc_signed_subref& operator = ( const sc_signed_subref_r& a );
01028     const sc_signed_subref& operator = ( const sc_signed_subref& a );
01029     const sc_signed_subref& operator = ( const sc_signed& a );
01030 
01031     const sc_signed_subref& operator = ( const sc_unsigned_subref_r& a );
01032     const sc_signed_subref& operator = ( const sc_unsigned& a );
01033 
01034     template< class T >
01035     const sc_signed_subref& operator = ( const sc_generic_base<T>& a )
01036     {
01037         sc_unsigned temp( length() );
01038         a->to_sc_unsigned(temp);
01039         return operator = (temp);
01040     }
01041 
01042     const sc_signed_subref& operator = ( const char* a );
01043     const sc_signed_subref& operator = ( unsigned long a );
01044     const sc_signed_subref& operator = ( long a );
01045     const sc_signed_subref& operator = ( unsigned int a )
01046         { return operator = ( (unsigned long) a ); }
01047 
01048     const sc_signed_subref& operator = ( int a )
01049         { return operator = ( (long) a ); }
01050 
01051     const sc_signed_subref& operator = ( uint64 a );
01052     const sc_signed_subref& operator = ( int64 a );
01053     const sc_signed_subref& operator = ( double a );
01054     const sc_signed_subref& operator = ( const sc_int_base& a );
01055     const sc_signed_subref& operator = ( const sc_uint_base& a );
01056 
01057     
01058 
01059     virtual void concat_set(int64 src, int low_i);
01060     virtual void concat_set(const sc_signed& src, int low_i);
01061     virtual void concat_set(const sc_unsigned& src, int low_i);
01062     virtual void concat_set(uint64 src, int low_i);
01063 
01064     
01065 
01066     void scan( ::std::istream& is = ::std::cin );
01067 
01068 protected:
01069     static sc_core::sc_vpool<sc_signed_subref> m_pool;
01070 };
01071 
01072 
01073 
01074 inline
01075 ::std::istream&
01076 operator >> ( ::std::istream&, sc_signed_subref& );
01077 
01078 
01079 
01080 
01081 
01082 
01083 
01084 
01085 class sc_signed : public sc_value_base
01086 {
01087     friend class sc_concatref;
01088     friend class sc_signed_bitref_r;
01089     friend class sc_signed_bitref;
01090     friend class sc_signed_subref_r;
01091     friend class sc_signed_subref;
01092     friend class sc_unsigned;
01093     friend class sc_unsigned_subref;
01094 
01095   
01096   typedef bool elemtype;
01097 
01098 public:
01099 
01100     
01101 
01102     explicit sc_signed( int nb = sc_length_param().len() );
01103     sc_signed( const sc_signed&   v );
01104     sc_signed( const sc_unsigned& v );
01105     template<class T>
01106     explicit sc_signed( const sc_generic_base<T>& v );
01107     explicit sc_signed( const sc_bv_base& v );
01108     explicit sc_signed( const sc_lv_base& v );
01109     explicit sc_signed( const sc_int_subref_r& v );
01110     explicit sc_signed( const sc_uint_subref_r& v );
01111     explicit sc_signed( const sc_signed_subref_r& v );
01112     explicit sc_signed( const sc_unsigned_subref_r& v );
01113 
01114     
01115 
01116     const sc_signed& operator = (const sc_signed&          v);
01117     const sc_signed& operator = (const sc_signed_subref_r& a );
01118 
01119     template< class T >
01120     const sc_signed& operator = ( const sc_generic_base<T>& a )
01121         { a->to_sc_signed(*this); return *this; }
01122 
01123     const sc_signed& operator = (const sc_unsigned&        v);
01124     const sc_signed& operator = (const sc_unsigned_subref_r& a );
01125 
01126     const sc_signed& operator = (const char*               v);
01127     const sc_signed& operator = (int64                     v);
01128     const sc_signed& operator = (uint64                    v);
01129     const sc_signed& operator = (long                      v);
01130     const sc_signed& operator = (unsigned long             v);
01131 
01132     const sc_signed& operator = (int                       v)
01133         { return operator=((long) v); }
01134 
01135     const sc_signed& operator = (unsigned int              v)
01136         { return operator=((unsigned long) v); }
01137 
01138     const sc_signed& operator = (double                    v);
01139     const sc_signed& operator = (const sc_int_base&        v);
01140     const sc_signed& operator = (const sc_uint_base&       v);
01141 
01142     const sc_signed& operator = ( const sc_bv_base& );
01143     const sc_signed& operator = ( const sc_lv_base& );
01144 
01145 #ifdef SC_INCLUDE_FX
01146     const sc_signed& operator = ( const sc_fxval& );
01147     const sc_signed& operator = ( const sc_fxval_fast& );
01148     const sc_signed& operator = ( const sc_fxnum& );
01149     const sc_signed& operator = ( const sc_fxnum_fast& );
01150 #endif
01151 
01152 
01153     
01154 
01155     virtual ~sc_signed()
01156         {
01157 #ifndef SC_MAX_NBITS
01158             delete [] digit;
01159 #endif
01160         }
01161 
01162     
01163 
01164     sc_digit* get_raw() const
01165         { return digit; }
01166     virtual int concat_length(bool* xz_present_p) const
01167         { if ( xz_present_p ) *xz_present_p = false; return nbits; }
01168     virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
01169     virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
01170     virtual uint64 concat_get_uint64() const;
01171     virtual void concat_set(int64 src, int low_i);
01172     virtual void concat_set(const sc_signed& src, int low_i);
01173     virtual void concat_set(const sc_unsigned& src, int low_i);
01174     virtual void concat_set(uint64 src, int low_i);
01175 
01176 
01177 
01178     
01179     sc_signed& operator ++ ();
01180     const sc_signed operator ++ (int);
01181 
01182     
01183     sc_signed& operator -- ();
01184     const sc_signed operator -- (int);
01185 
01186 
01187     
01188 
01189     inline void check_index( int i ) const
01190         { if ( i < 0 || i >= nbits ) invalid_index(i); }
01191 
01192     void invalid_index( int i ) const;
01193 
01194     sc_signed_bitref& operator [] ( int i )
01195         {
01196             check_index(i);
01197             sc_signed_bitref* result_p =
01198                 sc_signed_bitref::m_pool.allocate();
01199             result_p->initialize( this, i );
01200             return *result_p;
01201         }
01202 
01203     const sc_signed_bitref_r& operator [] ( int i ) const
01204         {
01205             check_index(i);
01206             sc_signed_bitref* result_p =
01207                 sc_signed_bitref::m_pool.allocate();
01208             result_p->initialize( this, i );
01209             return *result_p;
01210         }
01211 
01212     sc_signed_bitref& bit( int i )
01213         {
01214             check_index(i);
01215             sc_signed_bitref* result_p =
01216                 sc_signed_bitref::m_pool.allocate();
01217             result_p->initialize( this, i );
01218             return *result_p;
01219         }
01220 
01221     const sc_signed_bitref_r& bit( int i ) const
01222         {
01223             check_index(i);
01224             sc_signed_bitref* result_p =
01225                 sc_signed_bitref::m_pool.allocate();
01226             result_p->initialize( this, i );
01227             return *result_p;
01228         }
01229 
01230 
01231     
01232 
01233     
01234     
01235     
01236     
01237     
01238     
01239 
01240     inline void check_range( int l, int r ) const
01241         {
01242             if ( l < r )
01243             {
01244                 if ( l < 0 || r >= nbits ) invalid_range(l,r);
01245             }
01246             else
01247             {
01248                 if ( r < 0 || l >= nbits ) invalid_range(l,r);
01249             }
01250         }
01251 
01252     void invalid_range( int l, int r ) const;
01253 
01254     sc_signed_subref& range( int i, int j )
01255         {
01256             check_range( i, j );
01257             sc_signed_subref* result_p =
01258                 sc_signed_subref::m_pool.allocate();
01259             result_p->initialize( this, i, j );
01260             return *result_p;
01261         }
01262 
01263     const sc_signed_subref_r& range( int i, int j ) const
01264         {
01265             check_range( i, j );
01266             sc_signed_subref* result_p =
01267                 sc_signed_subref::m_pool.allocate();
01268             result_p->initialize( this, i, j );
01269             return *result_p;
01270         }
01271 
01272     sc_signed_subref& operator () ( int i, int j )
01273         {
01274             check_range( i, j );
01275             sc_signed_subref* result_p =
01276                 sc_signed_subref::m_pool.allocate();
01277             result_p->initialize( this, i, j );
01278             return *result_p;
01279         }
01280 
01281     const sc_signed_subref_r& operator () ( int i, int j ) const
01282         {
01283             check_range( i, j );
01284             sc_signed_subref* result_p =
01285                 sc_signed_subref::m_pool.allocate();
01286             result_p->initialize( this, i, j );
01287             return *result_p;
01288         }
01289 
01290 
01291     
01292 
01293     int           to_int() const;
01294     unsigned int  to_uint() const;
01295     long          to_long() const;
01296     unsigned long to_ulong() const;
01297     int64         to_int64() const;
01298     uint64        to_uint64() const;
01299     double        to_double() const;
01300 
01301 #ifdef SC_DT_DEPRECATED
01302     int to_signed() const
01303         { return to_int(); }
01304 
01305     unsigned int to_unsigned() const
01306         { return to_uint(); }
01307 #endif
01308 
01309     
01310 
01311     const std::string to_string( sc_numrep numrep = SC_DEC ) const;
01312     const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
01313 
01314 
01315     
01316 
01317     void print( ::std::ostream& os = ::std::cout ) const
01318         { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
01319 
01320     void scan( ::std::istream& is = ::std::cin );
01321 
01322     void dump( ::std::ostream& os = ::std::cout ) const;
01323 
01324 
01325   
01326   int  length() const { return nbits; }  
01327   bool iszero() const;                   
01328   bool sign() const;                     
01329 
01330    
01331 
01332     bool and_reduce() const;
01333 
01334     bool nand_reduce() const
01335         { return ( ! and_reduce() ); }
01336 
01337     bool or_reduce() const;
01338 
01339     bool nor_reduce() const
01340         { return ( ! or_reduce() ); }
01341 
01342     bool xor_reduce() const;
01343 
01344     bool xnor_reduce() const
01345         { return ( ! xor_reduce() ); }
01346 
01347   
01348   bool test(int i) const;      
01349   void set(int i);             
01350   void clear(int i);           
01351   void set(int i, bool v)      
01352     { if (v) set(i); else clear(i);  }
01353   void invert(int i)           
01354     { if (test(i)) clear(i); else set(i);  }
01355 
01356   
01357   void reverse();
01358 
01359   
01360   void get_packed_rep(sc_digit *buf) const;
01361   void set_packed_rep(sc_digit *buf);
01362 
01363   
01364 
01365 
01366 
01367 
01368 
01369 
01370 
01371 
01372 
01373 
01374 
01375 
01376 
01377 
01378 
01379 
01380 
01381 
01382 
01383 
01384 
01385 
01386 
01387 
01388 
01389 
01390 
01391 
01392   
01393 
01394   
01395 
01396   friend sc_signed operator + (const sc_unsigned&  u, const sc_signed&    v);
01397   friend sc_signed operator + (const sc_signed&    u, const sc_unsigned&  v);
01398 
01399   friend sc_signed operator + (const sc_unsigned&  u, int64               v);
01400   friend sc_signed operator + (const sc_unsigned&  u, long                v);
01401   friend sc_signed operator + (const sc_unsigned&  u, int                 v)
01402     { return operator+(u, (long) v); }
01403 
01404   friend sc_signed operator + (int64               u, const sc_unsigned&  v);
01405   friend sc_signed operator + (long                u, const sc_unsigned&  v);
01406   friend sc_signed operator + (int                 u, const sc_unsigned&  v)
01407     { return operator+((long) u, v); }
01408 
01409   friend sc_signed operator + (const sc_signed&    u, const sc_signed&    v);
01410   friend sc_signed operator + (const sc_signed&    u, int64               v);
01411   friend sc_signed operator + (const sc_signed&    u, uint64              v);
01412   friend sc_signed operator + (const sc_signed&    u, long                v);
01413   friend sc_signed operator + (const sc_signed&    u, unsigned long       v);
01414   friend sc_signed operator + (const sc_signed&    u, int                 v)
01415     { return operator+(u, (long) v); }
01416   friend sc_signed operator + (const sc_signed&    u, unsigned int        v)
01417     { return operator+(u, (unsigned long) v); }
01418 
01419   friend sc_signed operator + (int64               u, const sc_signed&    v);
01420   friend sc_signed operator + (uint64              u, const sc_signed&    v);
01421   friend sc_signed operator + (long                u, const sc_signed&    v);
01422   friend sc_signed operator + (unsigned long       u, const sc_signed&    v);
01423   friend sc_signed operator + (int                 u, const sc_signed&    v)
01424     { return operator+((long) u, v); }
01425   friend sc_signed operator + (unsigned int        u, const sc_signed&    v)
01426     { return operator+((unsigned long) u, v); }
01427 
01428   const sc_signed& operator += (const sc_signed&    v);
01429   const sc_signed& operator += (const sc_unsigned&  v);
01430   const sc_signed& operator += (int64               v);
01431   const sc_signed& operator += (uint64              v);
01432   const sc_signed& operator += (long                v);
01433   const sc_signed& operator += (unsigned long       v);
01434   const sc_signed& operator += (int                 v)
01435     { return operator+=((long) v); }
01436   const sc_signed& operator += (unsigned int        v)
01437     { return operator+=((unsigned long) v); }
01438 
01439   friend sc_signed operator + (const sc_unsigned&  u, const sc_int_base&  v);
01440   friend sc_signed operator + (const sc_int_base&  u, const sc_unsigned&  v);
01441   friend sc_signed operator + (const sc_signed&    u, const sc_int_base&  v);
01442   friend sc_signed operator + (const sc_signed&    u, const sc_uint_base& v);
01443   friend sc_signed operator + (const sc_int_base&  u, const sc_signed&    v);
01444   friend sc_signed operator + (const sc_uint_base& u, const sc_signed&    v);
01445   const sc_signed& operator += (const sc_int_base&  v);
01446   const sc_signed& operator += (const sc_uint_base& v);
01447 
01448   
01449 
01450   friend sc_signed operator - (const sc_unsigned&  u, const sc_signed&    v);
01451   friend sc_signed operator - (const sc_signed&    u, const sc_unsigned&  v);
01452 
01453   friend sc_signed operator - (const sc_unsigned&  u, const sc_unsigned&  v);
01454   friend sc_signed operator - (const sc_unsigned&  u, int64               v);
01455   friend sc_signed operator - (const sc_unsigned&  u, uint64              v);
01456   friend sc_signed operator - (const sc_unsigned&  u, long                v);
01457   friend sc_signed operator - (const sc_unsigned&  u, unsigned long       v);
01458   friend sc_signed operator - (const sc_unsigned&  u, int                v)
01459     { return operator-(u, (long) v); }
01460   friend sc_signed operator - (const sc_unsigned&  u, unsigned int       v)
01461     { return operator-(u, (unsigned long) v); }
01462 
01463   friend sc_signed operator - (int64               u, const sc_unsigned&  v);
01464   friend sc_signed operator - (uint64              u, const sc_unsigned&  v);
01465   friend sc_signed operator - (long                u, const sc_unsigned&  v);
01466   friend sc_signed operator - (unsigned long       u, const sc_unsigned&  v);
01467   friend sc_signed operator - (int                 u, const sc_unsigned&  v)
01468     { return operator-((long) u, v); }
01469   friend sc_signed operator - (unsigned int        u, const sc_unsigned& v)
01470     { return operator-((unsigned long) u, v); }
01471 
01472   friend sc_signed operator - (const sc_signed&    u, const sc_signed&    v);
01473   friend sc_signed operator - (const sc_signed&    u, int64               v);
01474   friend sc_signed operator - (const sc_signed&    u, uint64              v);
01475   friend sc_signed operator - (const sc_signed&    u, long                v);
01476   friend sc_signed operator - (const sc_signed&    u, unsigned long       v);
01477   friend sc_signed operator - (const sc_signed&    u, int                 v)
01478     { return operator-(u, (long) v); }
01479   friend sc_signed operator - (const sc_signed&    u, unsigned int        v)
01480     { return operator-(u, (unsigned long) v); }
01481 
01482   friend sc_signed operator - (int64               u, const sc_signed&    v);
01483   friend sc_signed operator - (uint64              u, const sc_signed&    v);
01484   friend sc_signed operator - (long                u, const sc_signed&    v);
01485   friend sc_signed operator - (unsigned long       u, const sc_signed&    v);
01486   friend sc_signed operator - (int                 u, const sc_signed&    v)
01487     { return operator-((long) u, v); }
01488   friend sc_signed operator - (unsigned int        u, const sc_signed&    v)
01489     { return operator-((unsigned long) u, v); }
01490 
01491   const sc_signed& operator -= (const sc_signed&    v);
01492   const sc_signed& operator -= (const sc_unsigned&  v);
01493   const sc_signed& operator -= (int64               v);
01494   const sc_signed& operator -= (uint64              v);
01495   const sc_signed& operator -= (long                v);
01496   const sc_signed& operator -= (unsigned long       v);
01497   const sc_signed& operator -= (int                 v)
01498     { return operator -= ((long) v); }
01499   const sc_signed& operator -= (unsigned int        v)
01500     { return operator -= ((unsigned long) v); }
01501 
01502   friend sc_signed operator - (const sc_unsigned&  u, const sc_int_base&  v);
01503   friend sc_signed operator - (const sc_unsigned&  u, const sc_uint_base& v);
01504   friend sc_signed operator - (const sc_int_base&  u, const sc_unsigned&  v);
01505   friend sc_signed operator - (const sc_uint_base& u, const sc_unsigned&  v);
01506   friend sc_signed operator - (const sc_signed&    u, const sc_int_base&  v);
01507   friend sc_signed operator - (const sc_signed&    u, const sc_uint_base& v);
01508   friend sc_signed operator - (const sc_int_base&  u, const sc_signed&    v);
01509   friend sc_signed operator - (const sc_uint_base& u, const sc_signed&    v);
01510   const sc_signed& operator -= (const sc_int_base&  v);
01511   const sc_signed& operator -= (const sc_uint_base& v);
01512 
01513   
01514 
01515   friend sc_signed operator * (const sc_unsigned&  u, const sc_signed&    v);
01516   friend sc_signed operator * (const sc_signed&    u, const sc_unsigned&  v);
01517 
01518   friend sc_signed operator * (const sc_unsigned&  u, int64               v);
01519   friend sc_signed operator * (const sc_unsigned&  u, long                v);
01520   friend sc_signed operator * (const sc_unsigned&  u, int                 v)
01521     { return operator*(u, (long) v); }
01522 
01523   friend sc_signed operator * (int64               u, const sc_unsigned&  v);
01524   friend sc_signed operator * (long                u, const sc_unsigned&  v);
01525   friend sc_signed operator * (int                 u, const sc_unsigned&  v)
01526     { return operator*((long) u, v); }
01527 
01528   friend sc_signed operator * (const sc_signed&  u, const sc_signed&  v);
01529   friend sc_signed operator * (const sc_signed&  u, int64             v);
01530   friend sc_signed operator * (const sc_signed&  u, uint64            v);
01531   friend sc_signed operator * (const sc_signed&  u, long              v);
01532   friend sc_signed operator * (const sc_signed&  u, unsigned long     v);
01533   friend sc_signed operator * (const sc_signed&  u, int               v)
01534     { return operator*(u, (long) v); }
01535   friend sc_signed operator * (const sc_signed&  u, unsigned int      v)
01536     { return operator*(u, (unsigned long) v); }
01537 
01538   friend sc_signed operator * (int64             u, const sc_signed&  v);
01539   friend sc_signed operator * (uint64            u, const sc_signed&  v);
01540   friend sc_signed operator * (long              u, const sc_signed&  v);
01541   friend sc_signed operator * (unsigned long     u, const sc_signed&  v);
01542   friend sc_signed operator * (int               u, const sc_signed&  v)
01543     { return operator*((long) u, v); }
01544   friend sc_signed operator * (unsigned int      u, const sc_signed&  v)
01545     { return operator*((unsigned long) u, v); }
01546 
01547   const sc_signed& operator *= (const sc_signed&    v);
01548   const sc_signed& operator *= (const sc_unsigned&  v);
01549   const sc_signed& operator *= (int64               v);
01550   const sc_signed& operator *= (uint64              v);
01551   const sc_signed& operator *= (long                v);
01552   const sc_signed& operator *= (unsigned long       v);
01553   const sc_signed& operator *= (int                 v)
01554     { return operator*=((long) v); }
01555   const sc_signed& operator *= (unsigned int        v)
01556     { return operator*=((unsigned long) v); }
01557 
01558   friend sc_signed operator * (const sc_unsigned&  u, const sc_int_base&  v);
01559   friend sc_signed operator * (const sc_int_base&  u, const sc_unsigned&  v);
01560   friend sc_signed operator * (const sc_signed&    u, const sc_int_base&  v);
01561   friend sc_signed operator * (const sc_signed&    u, const sc_uint_base& v);
01562   friend sc_signed operator * (const sc_int_base&  u, const sc_signed&    v);
01563   friend sc_signed operator * (const sc_uint_base& u, const sc_signed&    v);
01564   const sc_signed& operator *= (const sc_int_base&  v);
01565   const sc_signed& operator *= (const sc_uint_base& v);
01566 
01567   
01568 
01569   friend sc_signed operator / (const sc_unsigned&  u, const sc_signed&    v);
01570   friend sc_signed operator / (const sc_signed&    u, const sc_unsigned&  v);
01571 
01572   friend sc_signed operator / (const sc_unsigned&  u, int64               v);
01573   friend sc_signed operator / (const sc_unsigned&  u, long                v);
01574   friend sc_signed operator / (const sc_unsigned&  u, int                 v)
01575     { return operator/(u, (long) v); }
01576 
01577   friend sc_signed operator / (int64               u, const sc_unsigned&  v);
01578   friend sc_signed operator / (long                u, const sc_unsigned&  v);
01579   friend sc_signed operator / (int                 u, const sc_unsigned&  v)
01580     { return operator/((long) u, v); }
01581 
01582   friend sc_signed operator / (const sc_signed&    u, const sc_signed&    v);
01583   friend sc_signed operator / (const sc_signed&    u, int64               v);
01584   friend sc_signed operator / (const sc_signed&    u, uint64              v);
01585   friend sc_signed operator / (const sc_signed&    u, long                v);
01586   friend sc_signed operator / (const sc_signed&    u, unsigned long       v);
01587   friend sc_signed operator / (const sc_signed&    u, int                 v)
01588     { return operator/(u, (long) v); }
01589   friend sc_signed operator / (const sc_signed&    u, unsigned int        v)
01590     { return operator/(u, (unsigned long) v); }
01591 
01592   friend sc_signed operator / (int64               u, const sc_signed&    v);
01593   friend sc_signed operator / (uint64              u, const sc_signed&    v);
01594   friend sc_signed operator / (long                u, const sc_signed&    v);
01595   friend sc_signed operator / (unsigned long       u, const sc_signed&    v);
01596   friend sc_signed operator / (int                 u, const sc_signed&    v)
01597     { return operator/((long) u, v); }
01598   friend sc_signed operator / (unsigned int        u, const sc_signed&    v)
01599     { return operator/((unsigned long) u, v); }
01600 
01601   const sc_signed& operator /= (const sc_signed&    v);
01602   const sc_signed& operator /= (const sc_unsigned&  v);
01603   const sc_signed& operator /= (int64               v);
01604   const sc_signed& operator /= (uint64              v);
01605   const sc_signed& operator /= (long                v);
01606   const sc_signed& operator /= (unsigned long       v);
01607   const sc_signed& operator /= (int                 v)
01608     { return operator/=((long) v); }
01609   const sc_signed& operator /= (unsigned int        v)
01610     { return operator/=((unsigned long) v); }
01611 
01612   friend sc_signed operator / (const sc_unsigned&  u, const sc_int_base&  v);
01613   friend sc_signed operator / (const sc_int_base&  u, const sc_unsigned&  v);
01614   friend sc_signed operator / (const sc_signed&    u, const sc_int_base&  v);
01615   friend sc_signed operator / (const sc_signed&    u, const sc_uint_base& v);
01616   friend sc_signed operator / (const sc_int_base&  u, const sc_signed&    v);
01617   friend sc_signed operator / (const sc_uint_base& u, const sc_signed&    v);
01618   const sc_signed& operator /= (const sc_int_base&  v);
01619   const sc_signed& operator /= (const sc_uint_base& v);
01620 
01621   
01622 
01623   friend sc_signed operator % (const sc_unsigned&  u, const sc_signed&    v);
01624   friend sc_signed operator % (const sc_signed&    u, const sc_unsigned&  v);
01625 
01626   friend sc_signed operator % (const sc_unsigned&  u, int64               v);
01627   friend sc_signed operator % (const sc_unsigned&  u, long                v);
01628   friend sc_signed operator % (const sc_unsigned&  u, int                 v)
01629     { return operator%(u, (long) v); }
01630 
01631   friend sc_signed operator % (int64               u, const sc_unsigned&  v);
01632   friend sc_signed operator % (long                u, const sc_unsigned&  v);
01633   friend sc_signed operator % (int                 u, const sc_unsigned&  v)
01634     { return operator%((long) u, v); }
01635 
01636   friend sc_signed operator % (const sc_signed&    u, const sc_signed&    v);
01637   friend sc_signed operator % (const sc_signed&    u, int64               v);
01638   friend sc_signed operator % (const sc_signed&    u, uint64              v);
01639   friend sc_signed operator % (const sc_signed&    u, long                v);
01640   friend sc_signed operator % (const sc_signed&    u, unsigned long       v);
01641   friend sc_signed operator % (const sc_signed&    u, int                 v)
01642     { return operator%(u, (long) v); }
01643   friend sc_signed operator % (const sc_signed&    u, unsigned int        v)
01644     { return operator%(u, (unsigned long) v); }
01645 
01646   friend sc_signed operator % (int64               u, const sc_signed&    v);
01647   friend sc_signed operator % (uint64              u, const sc_signed&    v);
01648   friend sc_signed operator % (long                u, const sc_signed&    v);
01649   friend sc_signed operator % (unsigned long       u, const sc_signed&    v);
01650   friend sc_signed operator % (int                 u, const sc_signed&    v)
01651     { return operator%((long) u, v); }
01652   friend sc_signed operator % (unsigned int        u, const sc_signed&    v)
01653     { return operator%((unsigned long) u, v); }
01654 
01655   const sc_signed& operator %= (const sc_signed&    v);
01656   const sc_signed& operator %= (const sc_unsigned&  v);
01657   const sc_signed& operator %= (int64               v);
01658   const sc_signed& operator %= (uint64              v);
01659   const sc_signed& operator %= (long                v);
01660   const sc_signed& operator %= (unsigned long       v);
01661   const sc_signed& operator %= (int                 v)
01662     { return operator%=((long) v); }
01663   const sc_signed& operator %= (unsigned int        v)
01664     { return operator%=((unsigned long) v); }
01665 
01666   friend sc_signed operator % (const sc_unsigned&  u, const sc_int_base&  v);
01667   friend sc_signed operator % (const sc_int_base&  u, const sc_unsigned&  v);
01668   friend sc_signed operator % (const sc_signed&    u, const sc_int_base&  v);
01669   friend sc_signed operator % (const sc_signed&    u, const sc_uint_base& v);
01670   friend sc_signed operator % (const sc_int_base&  u, const sc_signed&    v);
01671   friend sc_signed operator % (const sc_uint_base& u, const sc_signed&    v);
01672   const sc_signed& operator %= (const sc_int_base&  v);
01673   const sc_signed& operator %= (const sc_uint_base& v);
01674 
01675   
01676 
01677   
01678 
01679   friend sc_signed operator & (const sc_unsigned&  u, const sc_signed&    v);
01680   friend sc_signed operator & (const sc_signed&    u, const sc_unsigned&  v);
01681 
01682   friend sc_signed operator & (const sc_unsigned&  u, int64               v);
01683   friend sc_signed operator & (const sc_unsigned&  u, long                v);
01684   friend sc_signed operator & (const sc_unsigned&  u, int                 v)
01685     { return operator&(u, (long) v); }
01686 
01687   friend sc_signed operator & (int64               u, const sc_unsigned&  v);
01688   friend sc_signed operator & (long                u, const sc_unsigned&  v);
01689   friend sc_signed operator & (int                 u, const sc_unsigned&  v)
01690     { return operator&((long) u, v); }
01691 
01692   friend sc_signed operator & (const sc_signed&    u, const sc_signed&    v);
01693   friend sc_signed operator & (const sc_signed&    u, int64               v);
01694   friend sc_signed operator & (const sc_signed&    u, uint64              v);
01695   friend sc_signed operator & (const sc_signed&    u, long                v);
01696   friend sc_signed operator & (const sc_signed&    u, unsigned long       v);
01697   friend sc_signed operator & (const sc_signed&    u, int                 v)
01698     { return operator&(u, (long) v); }
01699   friend sc_signed operator & (const sc_signed&    u, unsigned int        v)
01700     { return operator&(u, (unsigned long) v); }
01701 
01702   friend sc_signed operator & (int64             u, const sc_signed&  v);
01703   friend sc_signed operator & (uint64            u, const sc_signed&  v);
01704   friend sc_signed operator & (long              u, const sc_signed&  v);
01705   friend sc_signed operator & (unsigned long     u, const sc_signed&  v);
01706   friend sc_signed operator & (int               u, const sc_signed&  v)
01707     { return operator&((long) u, v); }
01708   friend sc_signed operator & (unsigned int      u, const sc_signed&  v)
01709     { return operator&((unsigned long) u, v); }
01710 
01711   const sc_signed& operator &= (const sc_signed&    v);
01712   const sc_signed& operator &= (const sc_unsigned&  v);
01713   const sc_signed& operator &= (int64               v);
01714   const sc_signed& operator &= (uint64              v);
01715   const sc_signed& operator &= (long                v);
01716   const sc_signed& operator &= (unsigned long       v);
01717   const sc_signed& operator &= (int                 v)
01718     { return operator&=((long) v); }
01719   const sc_signed& operator &= (unsigned int        v)
01720     { return operator&=((unsigned long) v); }
01721 
01722   friend sc_signed operator & (const sc_unsigned&  u, const sc_int_base&  v);
01723   friend sc_signed operator & (const sc_int_base&  u, const sc_unsigned&  v);
01724   friend sc_signed operator & (const sc_signed&    u, const sc_int_base&  v);
01725   friend sc_signed operator & (const sc_signed&    u, const sc_uint_base& v);
01726   friend sc_signed operator & (const sc_int_base&  u, const sc_signed&    v);
01727   friend sc_signed operator & (const sc_uint_base& u, const sc_signed&    v);
01728   const sc_signed& operator &= (const sc_int_base&  v);
01729   const sc_signed& operator &= (const sc_uint_base& v);
01730 
01731   
01732 
01733   friend sc_signed operator | (const sc_unsigned&  u, const sc_signed&    v);
01734   friend sc_signed operator | (const sc_signed&    u, const sc_unsigned&  v);
01735 
01736   friend sc_signed operator | (const sc_unsigned&  u, int64               v);
01737   friend sc_signed operator | (const sc_unsigned&  u, long                v);
01738   friend sc_signed operator | (const sc_unsigned&  u, int                 v)
01739     { return operator|(u, (long) v); }
01740 
01741   friend sc_signed operator | (int64               u, const sc_unsigned&  v);
01742   friend sc_signed operator | (long                u, const sc_unsigned&  v);
01743   friend sc_signed operator | (int                 u, const sc_unsigned&  v)
01744     { return operator|((long) u, v); }
01745 
01746   friend sc_signed operator | (const sc_signed&    u, const sc_signed&    v);
01747   friend sc_signed operator | (const sc_signed&    u, int64               v);
01748   friend sc_signed operator | (const sc_signed&    u, uint64              v);
01749   friend sc_signed operator | (const sc_signed&    u, long                v);
01750   friend sc_signed operator | (const sc_signed&    u, unsigned long       v);
01751   friend sc_signed operator | (const sc_signed&    u, int                 v)
01752     { return operator|(u, (long) v); }
01753   friend sc_signed operator | (const sc_signed&    u, unsigned int        v)
01754     { return operator|(u, (unsigned long) v); }
01755 
01756   friend sc_signed operator | (int64             u, const sc_signed&  v);
01757   friend sc_signed operator | (uint64            u, const sc_signed&  v);
01758   friend sc_signed operator | (long              u, const sc_signed&  v);
01759   friend sc_signed operator | (unsigned long     u, const sc_signed&  v);
01760   friend sc_signed operator | (int               u, const sc_signed&  v)
01761     { return operator|((long) u, v); }
01762   friend sc_signed operator | (unsigned int      u, const sc_signed&  v)
01763     { return operator|((unsigned long) u, v); }
01764 
01765   const sc_signed& operator |= (const sc_signed&    v);
01766   const sc_signed& operator |= (const sc_unsigned&  v);
01767   const sc_signed& operator |= (int64               v);
01768   const sc_signed& operator |= (uint64              v);
01769   const sc_signed& operator |= (long                v);
01770   const sc_signed& operator |= (unsigned long       v);
01771   const sc_signed& operator |= (int                 v)
01772     { return operator|=((long) v); }
01773   const sc_signed& operator |= (unsigned int        v)
01774     { return operator|=((unsigned long) v); }
01775 
01776   friend sc_signed operator | (const sc_unsigned&  u, const sc_int_base&  v);
01777   friend sc_signed operator | (const sc_int_base&  u, const sc_unsigned&  v);
01778   friend sc_signed operator | (const sc_signed&    u, const sc_int_base&  v);
01779   friend sc_signed operator | (const sc_signed&    u, const sc_uint_base& v);
01780   friend sc_signed operator | (const sc_int_base&  u, const sc_signed&    v);
01781   friend sc_signed operator | (const sc_uint_base& u, const sc_signed&    v);
01782   const sc_signed& operator |= (const sc_int_base&  v);
01783   const sc_signed& operator |= (const sc_uint_base& v);
01784 
01785   
01786 
01787   friend sc_signed operator ^ (const sc_unsigned&  u, const sc_signed&    v);
01788   friend sc_signed operator ^ (const sc_signed&    u, const sc_unsigned&  v);
01789 
01790   friend sc_signed operator ^ (const sc_unsigned&  u, int64               v);
01791   friend sc_signed operator ^ (const sc_unsigned&  u, long                v);
01792   friend sc_signed operator ^ (const sc_unsigned&  u, int                 v)
01793     { return operator^(u, (long) v); }
01794 
01795   friend sc_signed operator ^ (int64               u, const sc_unsigned&  v);
01796   friend sc_signed operator ^ (long                u, const sc_unsigned&  v);
01797   friend sc_signed operator ^ (int                 u, const sc_unsigned&  v)
01798     { return operator^((long) u, v); }
01799 
01800   friend sc_signed operator ^ (const sc_signed&    u, const sc_signed&    v);
01801   friend sc_signed operator ^ (const sc_signed&    u, int64               v);
01802   friend sc_signed operator ^ (const sc_signed&    u, uint64              v);
01803   friend sc_signed operator ^ (const sc_signed&    u, long                v);
01804   friend sc_signed operator ^ (const sc_signed&    u, unsigned long       v);
01805   friend sc_signed operator ^ (const sc_signed&    u, int                 v)
01806     { return operator^(u, (long) v); }
01807   friend sc_signed operator ^ (const sc_signed&    u, unsigned int        v)
01808     { return operator^(u, (unsigned long) v); }
01809 
01810   friend sc_signed operator ^ (int64             u, const sc_signed&  v);
01811   friend sc_signed operator ^ (uint64            u, const sc_signed&  v);
01812   friend sc_signed operator ^ (long              u, const sc_signed&  v);
01813   friend sc_signed operator ^ (unsigned long     u, const sc_signed&  v);
01814   friend sc_signed operator ^ (int               u, const sc_signed&  v)
01815     { return operator^((long) u, v); }
01816   friend sc_signed operator ^ (unsigned int      u, const sc_signed&  v)
01817     { return operator^((unsigned long) u, v); }
01818 
01819   const sc_signed& operator ^= (const sc_signed&    v);
01820   const sc_signed& operator ^= (const sc_unsigned&  v);
01821   const sc_signed& operator ^= (int64               v);
01822   const sc_signed& operator ^= (uint64              v);
01823   const sc_signed& operator ^= (long                v);
01824   const sc_signed& operator ^= (unsigned long       v);
01825   const sc_signed& operator ^= (int                 v)
01826     { return operator^=((long) v); }
01827   const sc_signed& operator ^= (unsigned int        v)
01828     { return operator^=((unsigned long) v); }
01829 
01830   friend sc_signed operator ^ (const sc_unsigned&  u, const sc_int_base&  v);
01831   friend sc_signed operator ^ (const sc_int_base&  u, const sc_unsigned&  v);
01832   friend sc_signed operator ^ (const sc_signed&    u, const sc_int_base&  v);
01833   friend sc_signed operator ^ (const sc_signed&    u, const sc_uint_base& v);
01834   friend sc_signed operator ^ (const sc_int_base&  u, const sc_signed&    v);
01835   friend sc_signed operator ^ (const sc_uint_base& u, const sc_signed&    v);
01836   const sc_signed& operator ^= (const sc_int_base&  v);
01837   const sc_signed& operator ^= (const sc_uint_base& v);
01838 
01839   
01840 
01841   
01842 
01843   friend sc_unsigned operator << (const sc_unsigned&  u, const sc_signed&    v);
01844   friend   sc_signed operator << (const sc_signed&    u, const sc_unsigned&  v);
01845 
01846   friend   sc_signed operator << (const sc_signed&    u, const sc_signed&    v);
01847   friend   sc_signed operator << (const sc_signed&    u, int64               v);
01848   friend   sc_signed operator << (const sc_signed&    u, uint64              v);
01849   friend   sc_signed operator << (const sc_signed&    u, long                v);
01850   friend   sc_signed operator << (const sc_signed&    u, unsigned long       v);
01851   friend   sc_signed operator << (const sc_signed&    u, int                 v)
01852     { return operator<<(u, (long) v); }
01853   friend   sc_signed operator << (const sc_signed&    u, unsigned int        v)
01854     { return operator<<(u, (unsigned long) v); }
01855 
01856   const sc_signed& operator <<= (const sc_signed&    v);
01857   const sc_signed& operator <<= (const sc_unsigned&  v);
01858   const sc_signed& operator <<= (int64               v);
01859   const sc_signed& operator <<= (uint64              v);
01860   const sc_signed& operator <<= (long                v);
01861   const sc_signed& operator <<= (unsigned long       v);
01862   const sc_signed& operator <<= (int                 v)
01863     { return operator<<=((long) v); }
01864   const sc_signed& operator <<= (unsigned int        v)
01865     { return operator<<=((unsigned long) v); }
01866 
01867   friend   sc_signed operator << (const sc_signed&    u, const sc_int_base&  v);
01868   friend   sc_signed operator << (const sc_signed&    u, const sc_uint_base& v);
01869   const sc_signed& operator <<= (const sc_int_base&  v);
01870   const sc_signed& operator <<= (const sc_uint_base& v);
01871 
01872   
01873 
01874   friend sc_unsigned operator >> (const sc_unsigned&  u, const sc_signed&    v);
01875   friend   sc_signed operator >> (const sc_signed&    u, const sc_unsigned&  v);
01876 
01877   friend   sc_signed operator >> (const sc_signed&    u, const sc_signed&    v);
01878   friend   sc_signed operator >> (const sc_signed&    u, int64               v);
01879   friend   sc_signed operator >> (const sc_signed&    u, uint64              v);
01880   friend   sc_signed operator >> (const sc_signed&    u, long                v);
01881   friend   sc_signed operator >> (const sc_signed&    u, unsigned long       v);
01882   friend   sc_signed operator >> (const sc_signed&    u, int                 v)
01883     { return operator>>(u, (long) v); }
01884   friend   sc_signed operator >> (const sc_signed&    u, unsigned int        v)
01885     { return operator>>(u, (unsigned long) v); }
01886 
01887   const sc_signed& operator >>= (const sc_signed&    v);
01888   const sc_signed& operator >>= (const sc_unsigned&  v);
01889   const sc_signed& operator >>= (int64               v);
01890   const sc_signed& operator >>= (uint64              v);
01891   const sc_signed& operator >>= (long                v);
01892   const sc_signed& operator >>= (unsigned long       v);
01893   const sc_signed& operator >>= (int                 v)
01894     { return operator>>=((long) v); }
01895   const sc_signed& operator >>= (unsigned int        v)
01896     { return operator>>=((unsigned long) v); }
01897 
01898   friend sc_signed operator >> (const sc_signed&    u, const sc_int_base&  v);
01899   friend sc_signed operator >> (const sc_signed&    u, const sc_uint_base& v);
01900   const sc_signed& operator >>= (const sc_int_base&  v);
01901   const sc_signed& operator >>= (const sc_uint_base& v);
01902 
01903   
01904   friend sc_signed operator + (const sc_signed&   u);
01905   friend sc_signed operator - (const sc_signed&   u);
01906   friend sc_signed operator - (const sc_unsigned& u);
01907 
01908   
01909 
01910   
01911 
01912   friend bool operator == (const sc_unsigned&  u, const sc_signed&    v);
01913   friend bool operator == (const sc_signed&    u, const sc_unsigned&  v);
01914 
01915   friend bool operator == (const sc_signed&    u, const sc_signed&    v);
01916   friend bool operator == (const sc_signed&    u, int64               v);
01917   friend bool operator == (const sc_signed&    u, uint64              v);
01918   friend bool operator == (const sc_signed&    u, long                v);
01919   friend bool operator == (const sc_signed&    u, unsigned long       v);
01920   friend bool operator == (const sc_signed&    u, int                 v)
01921     { return operator==(u, (long) v); }
01922   friend bool operator == (const sc_signed&    u, unsigned int        v)
01923     { return operator==(u, (unsigned long) v); }
01924 
01925   friend bool operator == (int64               u, const sc_signed&    v);
01926   friend bool operator == (uint64              u, const sc_signed&    v);
01927   friend bool operator == (long                u, const sc_signed&    v);
01928   friend bool operator == (unsigned long       u, const sc_signed&    v);
01929   friend bool operator == (int                 u, const sc_signed&    v)
01930     { return operator==((long) u, v); }
01931   friend bool operator == (unsigned int        u, const sc_signed&    v)
01932     { return operator==((unsigned long) u, v); }
01933 
01934   friend bool operator == (const sc_signed&    u, const sc_int_base&  v);
01935   friend bool operator == (const sc_signed&    u, const sc_uint_base& v);
01936   friend bool operator == (const sc_int_base&  u, const sc_signed&    v);
01937   friend bool operator == (const sc_uint_base& u, const sc_signed&    v);
01938 
01939   
01940 
01941   friend bool operator != (const sc_unsigned&  u, const sc_signed&    v);
01942   friend bool operator != (const sc_signed&    u, const sc_unsigned&  v);
01943 
01944   friend bool operator != (const sc_signed&    u, const sc_signed&    v);
01945   friend bool operator != (const sc_signed&    u, int64               v);
01946   friend bool operator != (const sc_signed&    u, uint64              v);
01947   friend bool operator != (const sc_signed&    u, long                v);
01948   friend bool operator != (const sc_signed&    u, unsigned long       v);
01949   friend bool operator != (const sc_signed&    u, int                 v)
01950     { return operator!=(u, (long) v); }
01951   friend bool operator != (const sc_signed&    u, unsigned int        v)
01952     { return operator!=(u, (unsigned long) v); }
01953 
01954   friend bool operator != (int64               u, const sc_signed&    v);
01955   friend bool operator != (uint64              u, const sc_signed&    v);
01956   friend bool operator != (long                u, const sc_signed&    v);
01957   friend bool operator != (unsigned long       u, const sc_signed&    v);
01958   friend bool operator != (int                 u, const sc_signed&    v)
01959     { return operator!=((long) u, v); }
01960   friend bool operator != (unsigned int        u, const sc_signed&    v)
01961     { return operator!=((unsigned long) u, v); }
01962 
01963   friend bool operator != (const sc_signed&    u, const sc_int_base&  v);
01964   friend bool operator != (const sc_signed&    u, const sc_uint_base& v);
01965   friend bool operator != (const sc_int_base&  u, const sc_signed&    v);
01966   friend bool operator != (const sc_uint_base& u, const sc_signed&    v);
01967 
01968   
01969 
01970   friend bool operator < (const sc_unsigned&  u, const sc_signed&    v);
01971   friend bool operator < (const sc_signed&    u, const sc_unsigned&  v);
01972 
01973   friend bool operator < (const sc_signed&    u, const sc_signed&    v);
01974   friend bool operator < (const sc_signed&    u, int64               v);
01975   friend bool operator < (const sc_signed&    u, uint64              v);
01976   friend bool operator < (const sc_signed&    u, long                v);
01977   friend bool operator < (const sc_signed&    u, unsigned long       v);
01978   friend bool operator < (const sc_signed&    u, int                 v)
01979     { return operator<(u, (long) v); }
01980   friend bool operator < (const sc_signed&    u, unsigned int        v)
01981     { return operator<(u, (unsigned long) v); }
01982 
01983   friend bool operator < (int64               u, const sc_signed&    v);
01984   friend bool operator < (uint64              u, const sc_signed&    v);
01985   friend bool operator < (long                u, const sc_signed&    v);
01986   friend bool operator < (unsigned long       u, const sc_signed&    v);
01987   friend bool operator < (int                 u, const sc_signed&    v)
01988     { return operator<((long) u, v); }
01989   friend bool operator < (unsigned int        u, const sc_signed&    v)
01990     { return operator<((unsigned long) u, v); }
01991 
01992   friend bool operator < (const sc_signed&    u, const sc_int_base&  v);
01993   friend bool operator < (const sc_signed&    u, const sc_uint_base& v);
01994   friend bool operator < (const sc_int_base&  u, const sc_signed&    v);
01995   friend bool operator < (const sc_uint_base& u, const sc_signed&    v);
01996 
01997   
01998 
01999   friend bool operator <= (const sc_unsigned&  u, const sc_signed&    v);
02000   friend bool operator <= (const sc_signed&    u, const sc_unsigned&  v);
02001 
02002   friend bool operator <= (const sc_signed&    u, const sc_signed&    v);
02003   friend bool operator <= (const sc_signed&    u, int64               v);
02004   friend bool operator <= (const sc_signed&    u, uint64              v);
02005   friend bool operator <= (const sc_signed&    u, long                v);
02006   friend bool operator <= (const sc_signed&    u, unsigned long       v);
02007   friend bool operator <= (const sc_signed&    u, int                 v)
02008     { return operator<=(u, (long) v); }
02009   friend bool operator <= (const sc_signed&    u, unsigned int        v)
02010     { return operator<=(u, (unsigned long) v); }
02011 
02012   friend bool operator <= (int64               u, const sc_signed&    v);
02013   friend bool operator <= (uint64              u, const sc_signed&    v);
02014   friend bool operator <= (long                u, const sc_signed&    v);
02015   friend bool operator <= (unsigned long       u, const sc_signed&    v);
02016   friend bool operator <= (int                 u, const sc_signed&    v)
02017     { return operator<=((long) u, v); }
02018   friend bool operator <= (unsigned int        u, const sc_signed&    v)
02019     { return operator<=((unsigned long) u, v); }
02020 
02021   friend bool operator <= (const sc_signed&    u, const sc_int_base&  v);
02022   friend bool operator <= (const sc_signed&    u, const sc_uint_base& v);
02023   friend bool operator <= (const sc_int_base&  u, const sc_signed&    v);
02024   friend bool operator <= (const sc_uint_base& u, const sc_signed&    v);
02025 
02026   
02027 
02028   friend bool operator > (const sc_unsigned&  u, const sc_signed&    v);
02029   friend bool operator > (const sc_signed&    u, const sc_unsigned&  v);
02030 
02031   friend bool operator > (const sc_signed&    u, const sc_signed&    v);
02032   friend bool operator > (const sc_signed&    u, int64               v);
02033   friend bool operator > (const sc_signed&    u, uint64              v);
02034   friend bool operator > (const sc_signed&    u, long                v);
02035   friend bool operator > (const sc_signed&    u, unsigned long       v);
02036   friend bool operator > (const sc_signed&    u, int                 v)
02037     { return operator>(u, (long) v); }
02038   friend bool operator > (const sc_signed&    u, unsigned int        v)
02039     { return operator>(u, (unsigned long) v); }
02040 
02041   friend bool operator > (int64               u, const sc_signed&    v);
02042   friend bool operator > (uint64              u, const sc_signed&    v);
02043   friend bool operator > (long                u, const sc_signed&    v);
02044   friend bool operator > (unsigned long       u, const sc_signed&    v);
02045   friend bool operator > (int                 u, const sc_signed&    v)
02046     { return operator>((long) u, v); }
02047   friend bool operator > (unsigned int        u, const sc_signed&    v)
02048     { return operator>((unsigned long) u, v); }
02049 
02050   friend bool operator > (const sc_signed&    u, const sc_int_base&  v);
02051   friend bool operator > (const sc_signed&    u, const sc_uint_base& v);
02052   friend bool operator > (const sc_int_base&  u, const sc_signed&    v);
02053   friend bool operator > (const sc_uint_base& u, const sc_signed&    v);
02054 
02055   
02056 
02057   friend bool operator >= (const sc_unsigned&  u, const sc_signed&    v);
02058   friend bool operator >= (const sc_signed&    u, const sc_unsigned&  v);
02059 
02060   friend bool operator >= (const sc_signed&    u, const sc_signed&    v);
02061   friend bool operator >= (const sc_signed&    u, int64               v);
02062   friend bool operator >= (const sc_signed&    u, uint64              v);
02063   friend bool operator >= (const sc_signed&    u, long                v);
02064   friend bool operator >= (const sc_signed&    u, unsigned long       v);
02065   friend bool operator >= (const sc_signed&    u, int                 v)
02066     { return operator>=(u, (long) v); }
02067   friend bool operator >= (const sc_signed&    u, unsigned int        v)
02068     { return operator>=(u, (unsigned long) v); }
02069 
02070   friend bool operator >= (int64               u, const sc_signed&    v);
02071   friend bool operator >= (uint64              u, const sc_signed&    v);
02072   friend bool operator >= (long                u, const sc_signed&    v);
02073   friend bool operator >= (unsigned long       u, const sc_signed&    v);
02074   friend bool operator >= (int                 u, const sc_signed&    v)
02075     { return operator>=((long) u, v); }
02076   friend bool operator >= (unsigned int        u, const sc_signed&    v)
02077     { return operator>=((unsigned long) u, v); }
02078 
02079   friend bool operator >= (const sc_signed&    u, const sc_int_base&  v);
02080   friend bool operator >= (const sc_signed&    u, const sc_uint_base& v);
02081   friend bool operator >= (const sc_int_base&  u, const sc_signed&    v);
02082   friend bool operator >= (const sc_uint_base& u, const sc_signed&    v);
02083 
02084   
02085   friend sc_signed operator ~ (const sc_signed& u);
02086 
02087   
02088   friend sc_signed add_signed_friend(small_type us,
02089                                      int unb,
02090                                      int und,
02091                                      const sc_digit *ud,
02092                                      small_type vs,
02093                                      int vnb,
02094                                      int vnd,
02095                                      const sc_digit *vd);
02096 
02097   friend sc_signed sub_signed_friend(small_type us,
02098                                      int unb,
02099                                      int und,
02100                                      const sc_digit *ud,
02101                                      small_type vs,
02102                                      int vnb,
02103                                      int vnd,
02104                                      const sc_digit *vd);
02105 
02106   friend sc_signed mul_signed_friend(small_type s,
02107                                      int unb,
02108                                      int und,
02109                                      const sc_digit *ud,
02110                                      int vnb,
02111                                      int vnd,
02112                                      const sc_digit *vd);
02113 
02114   friend sc_signed div_signed_friend(small_type s,
02115                                      int unb,
02116                                      int und,
02117                                      const sc_digit *ud,
02118                                      int vnb,
02119                                      int vnd,
02120                                      const sc_digit *vd);
02121 
02122   friend sc_signed mod_signed_friend(small_type us,
02123                                      int unb,
02124                                      int und,
02125                                      const sc_digit *ud,
02126                                      int vnb,
02127                                      int vnd,
02128                                      const sc_digit *vd);
02129 
02130   friend sc_signed and_signed_friend(small_type us,
02131                                      int unb,
02132                                      int und,
02133                                      const sc_digit *ud,
02134                                      small_type vs,
02135                                      int vnb,
02136                                      int vnd,
02137                                      const sc_digit *vd);
02138 
02139   friend sc_signed or_signed_friend(small_type us,
02140                                     int unb,
02141                                     int und,
02142                                     const sc_digit *ud,
02143                                     small_type vs,
02144                                     int vnb,
02145                                     int vnd,
02146                                     const sc_digit *vd);
02147 
02148   friend sc_signed xor_signed_friend(small_type us,
02149                                      int unb,
02150                                      int und,
02151                                      const sc_digit *ud,
02152                                      small_type vs,
02153                                      int vnb,
02154                                      int vnd,
02155                                      const sc_digit *vd);
02156 
02157 private:
02158 
02159   small_type  sgn;         
02160   int nbits;       
02161   int ndigits;     
02162 
02163 #ifdef SC_MAX_NBITS
02164   sc_digit digit[DIV_CEIL(SC_MAX_NBITS)];   
02165 #else
02166   sc_digit *digit;                       
02167 #endif
02168 
02169   
02170 
02171   
02172   sc_signed(const sc_signed&   v, small_type s);
02173   sc_signed(const sc_unsigned& v, small_type s);
02174 
02175   
02176   sc_signed(small_type s, int nb, int nd,
02177             sc_digit *d, bool alloc = true);
02178 
02179   
02180   sc_signed(const sc_signed* u, int l, int r);
02181   sc_signed(const sc_unsigned* u, int l, int r);
02182 
02183   
02184 
02185   small_type default_sign() const
02186     { return SC_NOSIGN; }
02187 
02188   int num_bits(int nb) const { return nb; }
02189 
02190   bool check_if_outside(int bit_num) const;
02191 
02192   void copy_digits(int nb, int nd, const sc_digit *d)
02193     { copy_digits_signed(sgn, nbits, ndigits, digit, nb, nd, d); }
02194 
02195   void makezero()
02196     { sgn = make_zero(ndigits, digit); }
02197 
02198   
02199   
02200   void convert_2C_to_SM()
02201     { sgn = convert_signed_2C_to_SM(nbits, ndigits, digit); }
02202 
02203   void convert_SM_to_2C_to_SM()
02204     { sgn = convert_signed_SM_to_2C_to_SM(sgn, nbits, ndigits, digit); }
02205 
02206   void convert_SM_to_2C()
02207     { convert_signed_SM_to_2C(sgn, ndigits, digit); }
02208 
02209 };
02210 
02211 
02212 
02213 inline
02214 ::std::ostream&
02215 operator << ( ::std::ostream&, const sc_signed& );
02216 
02217 inline
02218 ::std::istream&
02219 operator >> ( ::std::istream&, sc_signed& );
02220 
02221 
02222 
02223 inline
02224 ::std::ostream&
02225 operator << ( ::std::ostream& os, const sc_signed_bitref_r& a )
02226 {
02227     a.print( os );
02228     return os;
02229 }
02230 
02231 
02232 inline
02233 ::std::istream&
02234 operator >> ( ::std::istream& is, sc_signed_bitref& a )
02235 {
02236     a.scan( is );
02237     return is;
02238 }
02239 
02240 
02241 
02242 
02243 
02244 
02245 
02246 
02247 
02248 
02249 
02250 inline bool sc_signed_subref_r::and_reduce() const
02251 {
02252    const sc_signed* target_p = m_obj_p;
02253    for ( int i = m_right; i <= m_left; i++ )
02254         if ( !target_p->test(i) ) return false;
02255    return true;
02256 }
02257 
02258 inline bool sc_signed_subref_r::nand_reduce() const
02259 {
02260     return !and_reduce();
02261 }
02262 
02263 inline bool sc_signed_subref_r::or_reduce() const
02264 {
02265    const sc_signed* target_p = m_obj_p;
02266    for ( int i = m_right; i <= m_left; i++ )
02267         if ( target_p->test(i) ) return true;
02268    return false;
02269 }
02270 
02271 inline bool sc_signed_subref_r::nor_reduce() const
02272 {
02273     return !or_reduce();
02274 }
02275 
02276 inline bool sc_signed_subref_r::xor_reduce() const
02277 {
02278    int                odd;
02279    const sc_signed* target_p = m_obj_p;
02280    odd = 0;
02281    for ( int i = m_right; i <= m_left; i++ )
02282         if ( target_p->test(i) ) odd = ~odd;
02283    return odd ? true : false;
02284 }
02285 
02286 inline bool sc_signed_subref_r::xnor_reduce() const
02287 {
02288     return !xor_reduce();
02289 }
02290 
02291 inline
02292 ::std::ostream&
02293 operator << ( ::std::ostream& os, const sc_signed_subref_r& a )
02294 {
02295     a.print( os );
02296     return os;
02297 }
02298 
02299 
02300 
02301 
02302 
02303 
02304 
02305 
02306 
02307 
02308 inline
02309 const sc_signed_subref&
02310 sc_signed_subref::operator = ( const char* a )
02311 {
02312     sc_signed aa( length() );
02313     return ( *this = aa = a );
02314 }
02315 
02316 
02317 
02318 
02319 inline
02320 ::std::istream&
02321 operator >> ( ::std::istream& is, sc_signed_subref& a )
02322 {
02323     a.scan( is );
02324     return is;
02325 }
02326 
02327 
02328 
02329 
02330 
02331 
02332 
02333 
02334 
02335 template<class T>
02336 sc_signed::sc_signed( const sc_generic_base<T>& v )
02337 {
02338     int nb = v->length();
02339     sgn = default_sign();
02340     if( nb > 0 ) {
02341         nbits = num_bits( nb );
02342     } else {
02343         char msg[BUFSIZ];
02344         std::sprintf( msg,
02345                     "sc_unsigned( sc_generic_base<T> ) : nb = %d is not valid", nb);
02346         SC_REPORT_ERROR( sc_core::SC_ID_INIT_FAILED_, msg );
02347     }
02348     ndigits = DIV_CEIL(nbits);
02349 #   ifdef SC_MAX_NBITS
02350         test_bound(nb);
02351 #    else
02352         digit = new sc_digit[ndigits];
02353 #    endif
02354     makezero();
02355     v->to_sc_signed(*this);
02356 }
02357 
02358 
02359 
02360 inline
02361 ::std::ostream&
02362 operator << ( ::std::ostream& os, const sc_signed& a )
02363 {
02364     a.print( os );
02365     return os;
02366 }
02367 
02368 inline
02369 ::std::istream&
02370 operator >> ( ::std::istream& is, sc_signed& a )
02371 {
02372     a.scan( is );
02373     return is;
02374 }
02375 
02376 
02377 } 
02378 
02379 
02380 #endif