sc_signed.h

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

Generated on Wed Jan 21 15:32:08 2009 for SystemC by  doxygen 1.5.5