sc_fix.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_fix.h - 
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 // $Log: sc_fix.h,v $
00037 // Revision 1.1.1.1  2006/12/15 20:31:36  acg
00038 // SystemC 2.2
00039 //
00040 // Revision 1.3  2006/01/13 18:53:57  acg
00041 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
00042 // the source.
00043 //
00044 
00045 #ifndef SC_FIX_H
00046 #define SC_FIX_H
00047 
00048 
00049 #include "sysc/datatypes/fx/sc_fxnum.h"
00050 
00051 
00052 namespace sc_dt
00053 {
00054 
00055 // classes defined in this module
00056 class sc_fix;
00057 class sc_fix_fast;
00058 
00059 
00060 // ----------------------------------------------------------------------------
00061 //  CLASS : sc_fix
00062 //
00063 //  "Unconstrained" signed fixed-point class; arbitrary precision.
00064 // ----------------------------------------------------------------------------
00065 
00066 class sc_fix : public sc_fxnum
00067 {
00068 
00069 public:
00070 
00071     // constructors
00072 
00073     explicit sc_fix( sc_fxnum_observer* = 0 );
00074              sc_fix( int, int,
00075              sc_fxnum_observer* = 0 );
00076              sc_fix( sc_q_mode, sc_o_mode,
00077              sc_fxnum_observer* = 0 );
00078              sc_fix( sc_q_mode, sc_o_mode, int,
00079              sc_fxnum_observer* = 0 );
00080              sc_fix( int, int, sc_q_mode, sc_o_mode,
00081              sc_fxnum_observer* = 0 );
00082              sc_fix( int, int, sc_q_mode, sc_o_mode, int,
00083              sc_fxnum_observer* = 0 );
00084     explicit sc_fix( const sc_fxcast_switch&,
00085              sc_fxnum_observer* = 0 );
00086              sc_fix( int, int,
00087              const sc_fxcast_switch&,
00088              sc_fxnum_observer* = 0 );
00089              sc_fix( sc_q_mode, sc_o_mode,
00090              const sc_fxcast_switch&,
00091              sc_fxnum_observer* = 0 );
00092              sc_fix( sc_q_mode, sc_o_mode, int,
00093              const sc_fxcast_switch&,
00094              sc_fxnum_observer* = 0 );
00095              sc_fix( int, int, sc_q_mode, sc_o_mode,
00096              const sc_fxcast_switch&,
00097              sc_fxnum_observer* = 0 );
00098              sc_fix( int, int, sc_q_mode, sc_o_mode, int,
00099              const sc_fxcast_switch&,
00100              sc_fxnum_observer* = 0 );
00101     explicit sc_fix( const sc_fxtype_params&,
00102              sc_fxnum_observer* = 0 );
00103              sc_fix( const sc_fxtype_params&,
00104              const sc_fxcast_switch&,
00105              sc_fxnum_observer* = 0 );
00106 
00107 #define DECL_CTORS_T(tp)                                                      \
00108              sc_fix( tp,                                                      \
00109                  int, int,                                                \
00110                  sc_fxnum_observer* = 0 );                                \
00111              sc_fix( tp,                                                      \
00112                  sc_q_mode, sc_o_mode,                                    \
00113                  sc_fxnum_observer* = 0 );                                \
00114              sc_fix( tp,                                                      \
00115                  sc_q_mode, sc_o_mode, int,                               \
00116                  sc_fxnum_observer* = 0 );                                \
00117              sc_fix( tp,                                                      \
00118                  int, int, sc_q_mode, sc_o_mode,                          \
00119                  sc_fxnum_observer* = 0 );                                \
00120              sc_fix( tp,                                                      \
00121                  int, int, sc_q_mode, sc_o_mode, int,                     \
00122                  sc_fxnum_observer* = 0 );                                \
00123              sc_fix( tp,                                                      \
00124                  const sc_fxcast_switch&,                                 \
00125                  sc_fxnum_observer* = 0 );                                \
00126              sc_fix( tp,                                                      \
00127                  int, int,                                                \
00128                  const sc_fxcast_switch&,                                 \
00129                  sc_fxnum_observer* = 0 );                                \
00130              sc_fix( tp,                                                      \
00131                  sc_q_mode, sc_o_mode,                                    \
00132                  const sc_fxcast_switch&,                                 \
00133                  sc_fxnum_observer* = 0 );                                \
00134              sc_fix( tp,                                                      \
00135                  sc_q_mode, sc_o_mode, int,                               \
00136                  const sc_fxcast_switch&,                                 \
00137                  sc_fxnum_observer* = 0 );                                \
00138              sc_fix( tp,                                                      \
00139                  int, int, sc_q_mode, sc_o_mode,                          \
00140                  const sc_fxcast_switch&,                                 \
00141                  sc_fxnum_observer* = 0 );                                \
00142              sc_fix( tp,                                                      \
00143                  int, int, sc_q_mode, sc_o_mode, int,                     \
00144                  const sc_fxcast_switch&,                                 \
00145                  sc_fxnum_observer* = 0 );                                \
00146              sc_fix( tp,                                                      \
00147                  const sc_fxtype_params&,                                 \
00148                  sc_fxnum_observer* = 0 );                                \
00149              sc_fix( tp,                                                      \
00150                  const sc_fxtype_params&,                                 \
00151                  const sc_fxcast_switch&,                                 \
00152                  sc_fxnum_observer* = 0 );
00153 
00154 #define DECL_CTORS_T_A(tp)                                                    \
00155              sc_fix( tp,                                                      \
00156                  sc_fxnum_observer* = 0 );                                \
00157     DECL_CTORS_T(tp)
00158 
00159 #define DECL_CTORS_T_B(tp)                                                    \
00160     explicit sc_fix( tp,                                                      \
00161                  sc_fxnum_observer* = 0 );                                \
00162     DECL_CTORS_T(tp)
00163 
00164     DECL_CTORS_T_A(int)
00165     DECL_CTORS_T_A(unsigned int)
00166     DECL_CTORS_T_A(long)
00167     DECL_CTORS_T_A(unsigned long)
00168     DECL_CTORS_T_A(double)
00169     DECL_CTORS_T_A(const char*)
00170     DECL_CTORS_T_A(const sc_fxval&)
00171     DECL_CTORS_T_A(const sc_fxval_fast&)
00172     DECL_CTORS_T_A(const sc_fxnum&)
00173     DECL_CTORS_T_A(const sc_fxnum_fast&)
00174 #ifndef SC_FX_EXCLUDE_OTHER
00175     DECL_CTORS_T_B(int64)
00176     DECL_CTORS_T_B(uint64)
00177     DECL_CTORS_T_B(const sc_int_base&)
00178     DECL_CTORS_T_B(const sc_uint_base&)
00179     DECL_CTORS_T_B(const sc_signed&)
00180     DECL_CTORS_T_B(const sc_unsigned&)
00181 #endif
00182 
00183 #undef DECL_CTORS_T
00184 #undef DECL_CTORS_T_A
00185 #undef DECL_CTORS_T_B
00186 
00187     // copy constructor
00188 
00189     sc_fix( const sc_fix& );
00190 
00191 
00192     // unary bitwise operators
00193 
00194     const sc_fix operator ~ () const;
00195 
00196 
00197     // unary bitwise functions
00198 
00199     friend void b_not( sc_fix&, const sc_fix& );
00200 
00201 
00202     // binary bitwise operators
00203 
00204     friend const sc_fix operator & ( const sc_fix&, const sc_fix& );
00205     friend const sc_fix operator & ( const sc_fix&, const sc_fix_fast& );
00206     friend const sc_fix operator & ( const sc_fix_fast&, const sc_fix& );
00207     friend const sc_fix operator | ( const sc_fix&, const sc_fix& );
00208     friend const sc_fix operator | ( const sc_fix&, const sc_fix_fast& );
00209     friend const sc_fix operator | ( const sc_fix_fast&, const sc_fix& );
00210     friend const sc_fix operator ^ ( const sc_fix&, const sc_fix& );
00211     friend const sc_fix operator ^ ( const sc_fix&, const sc_fix_fast& );
00212     friend const sc_fix operator ^ ( const sc_fix_fast&, const sc_fix& );
00213 
00214 
00215     // binary bitwise functions
00216 
00217     friend void b_and( sc_fix&, const sc_fix&, const sc_fix& );
00218     friend void b_and( sc_fix&, const sc_fix&, const sc_fix_fast& );
00219     friend void b_and( sc_fix&, const sc_fix_fast&, const sc_fix& );
00220     friend void b_or ( sc_fix&, const sc_fix&, const sc_fix& );
00221     friend void b_or ( sc_fix&, const sc_fix&, const sc_fix_fast& );
00222     friend void b_or ( sc_fix&, const sc_fix_fast&, const sc_fix& );
00223     friend void b_xor( sc_fix&, const sc_fix&, const sc_fix& );
00224     friend void b_xor( sc_fix&, const sc_fix&, const sc_fix_fast& );
00225     friend void b_xor( sc_fix&, const sc_fix_fast&, const sc_fix& );
00226 
00227 
00228     // assignment operators
00229 
00230     sc_fix& operator = ( const sc_fix& );
00231 
00232 #define DECL_ASN_OP_T(op,tp)                                                  \
00233     sc_fix& operator op ( tp );
00234 
00235 #ifndef SC_FX_EXCLUDE_OTHER
00236 #define DECL_ASN_OP_OTHER(op)                                                 \
00237     DECL_ASN_OP_T(op,int64)                                                   \
00238     DECL_ASN_OP_T(op,uint64)                                                  \
00239     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00240     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00241     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00242     DECL_ASN_OP_T(op,const sc_unsigned&)
00243 #else
00244 #define DECL_ASN_OP_OTHER(op)
00245 #endif
00246 
00247 #define DECL_ASN_OP(op)                                                       \
00248     DECL_ASN_OP_T(op,int)                                                     \
00249     DECL_ASN_OP_T(op,unsigned int)                                            \
00250     DECL_ASN_OP_T(op,long)                                                    \
00251     DECL_ASN_OP_T(op,unsigned long)                                           \
00252     DECL_ASN_OP_T(op,double)                                                  \
00253     DECL_ASN_OP_T(op,const char*)                                             \
00254     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00255     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00256     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00257     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00258     DECL_ASN_OP_OTHER(op)
00259 
00260     DECL_ASN_OP(=)
00261 
00262     DECL_ASN_OP(*=)
00263     DECL_ASN_OP(/=)
00264     DECL_ASN_OP(+=)
00265     DECL_ASN_OP(-=)
00266 
00267     DECL_ASN_OP_T(<<=,int)
00268     DECL_ASN_OP_T(>>=,int)
00269 
00270     DECL_ASN_OP_T(&=,const sc_fix&)
00271     DECL_ASN_OP_T(&=,const sc_fix_fast&)
00272     DECL_ASN_OP_T(|=,const sc_fix&)
00273     DECL_ASN_OP_T(|=,const sc_fix_fast&)
00274     DECL_ASN_OP_T(^=,const sc_fix&)
00275     DECL_ASN_OP_T(^=,const sc_fix_fast&)
00276 
00277 #undef DECL_ASN_OP_T
00278 #undef DECL_ASN_OP_OTHER
00279 #undef DECL_ASN_OP
00280 
00281 
00282     // auto-increment and auto-decrement
00283 
00284     const sc_fxval operator ++ ( int );
00285     const sc_fxval operator -- ( int );
00286 
00287     sc_fix& operator ++ ();
00288     sc_fix& operator -- ();
00289 
00290 };
00291 
00292 
00293 // ----------------------------------------------------------------------------
00294 //  CLASS : sc_fix_fast
00295 //
00296 //  "Unconstrained" signed fixed-point class; limited precision.
00297 // ----------------------------------------------------------------------------
00298 
00299 class sc_fix_fast : public sc_fxnum_fast
00300 {
00301 
00302 public:
00303 
00304     // constructors
00305 
00306     explicit sc_fix_fast( sc_fxnum_fast_observer* = 0 );
00307              sc_fix_fast( int, int,
00308               sc_fxnum_fast_observer* = 0 );
00309              sc_fix_fast( sc_q_mode, sc_o_mode,
00310               sc_fxnum_fast_observer* = 0 );
00311              sc_fix_fast( sc_q_mode, sc_o_mode, int,
00312               sc_fxnum_fast_observer* = 0 );
00313              sc_fix_fast( int, int, sc_q_mode, sc_o_mode,
00314               sc_fxnum_fast_observer* = 0 );
00315              sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int,
00316               sc_fxnum_fast_observer* = 0 );
00317     explicit sc_fix_fast( const sc_fxcast_switch&,
00318               sc_fxnum_fast_observer* = 0 );
00319              sc_fix_fast( int, int,
00320               const sc_fxcast_switch&,
00321               sc_fxnum_fast_observer* = 0 );
00322              sc_fix_fast( sc_q_mode, sc_o_mode,
00323               const sc_fxcast_switch&,
00324               sc_fxnum_fast_observer* = 0 );
00325              sc_fix_fast( sc_q_mode, sc_o_mode, int,
00326               const sc_fxcast_switch&,
00327               sc_fxnum_fast_observer* = 0 );
00328              sc_fix_fast( int, int, sc_q_mode, sc_o_mode,
00329               const sc_fxcast_switch&,
00330               sc_fxnum_fast_observer* = 0 );
00331              sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int,
00332               const sc_fxcast_switch&,
00333               sc_fxnum_fast_observer* = 0 );
00334     explicit sc_fix_fast( const sc_fxtype_params&,
00335               sc_fxnum_fast_observer* = 0 );
00336              sc_fix_fast( const sc_fxtype_params&,
00337               const sc_fxcast_switch&,
00338               sc_fxnum_fast_observer* = 0 );
00339 
00340 #define DECL_CTORS_T(tp)                                                      \
00341              sc_fix_fast( tp,                                                 \
00342                   int, int,                                           \
00343                   sc_fxnum_fast_observer* = 0 );                      \
00344              sc_fix_fast( tp,                                                 \
00345                   sc_q_mode, sc_o_mode,                               \
00346                   sc_fxnum_fast_observer* = 0 );                      \
00347              sc_fix_fast( tp,                                                 \
00348                   sc_q_mode, sc_o_mode, int,                          \
00349                   sc_fxnum_fast_observer* = 0 );                      \
00350              sc_fix_fast( tp,                                                 \
00351                   int, int, sc_q_mode, sc_o_mode,                     \
00352                   sc_fxnum_fast_observer* = 0 );                      \
00353              sc_fix_fast( tp,                                                 \
00354                   int, int, sc_q_mode, sc_o_mode, int,                \
00355                   sc_fxnum_fast_observer* = 0 );                      \
00356              sc_fix_fast( tp,                                                 \
00357                   const sc_fxcast_switch&,                            \
00358                   sc_fxnum_fast_observer* = 0 );                      \
00359              sc_fix_fast( tp,                                                 \
00360                   int, int,                                           \
00361                   const sc_fxcast_switch&,                            \
00362                   sc_fxnum_fast_observer* = 0 );                      \
00363              sc_fix_fast( tp,                                                 \
00364                   sc_q_mode, sc_o_mode,                               \
00365                   const sc_fxcast_switch&,                            \
00366                   sc_fxnum_fast_observer* = 0 );                      \
00367              sc_fix_fast( tp,                                                 \
00368                   sc_q_mode, sc_o_mode, int,                          \
00369                   const sc_fxcast_switch&,                            \
00370                   sc_fxnum_fast_observer* = 0 );                      \
00371              sc_fix_fast( tp,                                                 \
00372                   int, int, sc_q_mode, sc_o_mode,                     \
00373                   const sc_fxcast_switch&,                            \
00374                   sc_fxnum_fast_observer* = 0 );                      \
00375              sc_fix_fast( tp,                                                 \
00376                   int, int, sc_q_mode, sc_o_mode, int,                \
00377                   const sc_fxcast_switch&,                            \
00378                   sc_fxnum_fast_observer* = 0 );                      \
00379              sc_fix_fast( tp,                                                 \
00380                   const sc_fxtype_params&,                            \
00381                   sc_fxnum_fast_observer* = 0 );                      \
00382              sc_fix_fast( tp,                                                 \
00383                   const sc_fxtype_params&,                            \
00384                   const sc_fxcast_switch&,                            \
00385                   sc_fxnum_fast_observer* = 0 );
00386 
00387 #define DECL_CTORS_T_A(tp)                                                    \
00388              sc_fix_fast( tp,                                                 \
00389                   sc_fxnum_fast_observer* = 0 );                      \
00390     DECL_CTORS_T(tp)
00391 
00392 #define DECL_CTORS_T_B(tp)                                                    \
00393     explicit sc_fix_fast( tp,                                                 \
00394                   sc_fxnum_fast_observer* = 0 );                      \
00395     DECL_CTORS_T(tp)
00396 
00397     DECL_CTORS_T_A(int)
00398     DECL_CTORS_T_A(unsigned int)
00399     DECL_CTORS_T_A(long)
00400     DECL_CTORS_T_A(unsigned long)
00401     DECL_CTORS_T_A(double)
00402     DECL_CTORS_T_A(const char*)
00403     DECL_CTORS_T_A(const sc_fxval&)
00404     DECL_CTORS_T_A(const sc_fxval_fast&)
00405     DECL_CTORS_T_A(const sc_fxnum&)
00406     DECL_CTORS_T_A(const sc_fxnum_fast&)
00407 #ifndef SC_FX_EXCLUDE_OTHER
00408     DECL_CTORS_T_B(int64)
00409     DECL_CTORS_T_B(uint64)
00410     DECL_CTORS_T_B(const sc_int_base&)
00411     DECL_CTORS_T_B(const sc_uint_base&)
00412     DECL_CTORS_T_B(const sc_signed&)
00413     DECL_CTORS_T_B(const sc_unsigned&)
00414 #endif
00415 
00416 #undef DECL_CTORS_T
00417 #undef DECL_CTORS_T_A
00418 #undef DECL_CTORS_T_B
00419 
00420     // copy constructor
00421 
00422     sc_fix_fast( const sc_fix_fast& );
00423 
00424 
00425     // unary bitwise operators
00426 
00427     const sc_fix_fast operator ~ () const;
00428 
00429 
00430     // unary bitwise functions
00431 
00432     friend void b_not( sc_fix_fast&, const sc_fix_fast& );
00433 
00434 
00435     // binary bitwise operators
00436 
00437     friend const sc_fix_fast operator & ( const sc_fix_fast&,
00438                       const sc_fix_fast& );
00439     friend const sc_fix_fast operator ^ ( const sc_fix_fast&,
00440                       const sc_fix_fast& );
00441     friend const sc_fix_fast operator | ( const sc_fix_fast&,
00442                       const sc_fix_fast& );
00443 
00444 
00445     // binary bitwise functions
00446 
00447     friend void b_and( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00448     friend void b_or ( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00449     friend void b_xor( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00450 
00451 
00452     // assignment operators
00453 
00454     sc_fix_fast& operator = ( const sc_fix_fast& );
00455 
00456 #define DECL_ASN_OP_T(op,tp)                                                  \
00457     sc_fix_fast& operator op ( tp );
00458 
00459 #ifndef SC_FX_EXCLUDE_OTHER
00460 #define DECL_ASN_OP_OTHER(op)                                                 \
00461     DECL_ASN_OP_T(op,int64)                                                   \
00462     DECL_ASN_OP_T(op,uint64)                                                  \
00463     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00464     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00465     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00466     DECL_ASN_OP_T(op,const sc_unsigned&)
00467 #else
00468 #define DECL_ASN_OP_OTHER(op)
00469 #endif
00470 
00471 #define DECL_ASN_OP(op)                                                       \
00472     DECL_ASN_OP_T(op,int)                                                     \
00473     DECL_ASN_OP_T(op,unsigned int)                                            \
00474     DECL_ASN_OP_T(op,long)                                                    \
00475     DECL_ASN_OP_T(op,unsigned long)                                           \
00476     DECL_ASN_OP_T(op,double)                                                  \
00477     DECL_ASN_OP_T(op,const char*)                                             \
00478     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00479     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00480     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00481     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00482     DECL_ASN_OP_OTHER(op)
00483 
00484     DECL_ASN_OP(=)
00485 
00486     DECL_ASN_OP(*=)
00487     DECL_ASN_OP(/=)
00488     DECL_ASN_OP(+=)
00489     DECL_ASN_OP(-=)
00490 
00491     DECL_ASN_OP_T(<<=,int)
00492     DECL_ASN_OP_T(>>=,int)
00493 
00494     DECL_ASN_OP_T(&=,const sc_fix&)
00495     DECL_ASN_OP_T(&=,const sc_fix_fast&)
00496     DECL_ASN_OP_T(|=,const sc_fix&)
00497     DECL_ASN_OP_T(|=,const sc_fix_fast&)
00498     DECL_ASN_OP_T(^=,const sc_fix&)
00499     DECL_ASN_OP_T(^=,const sc_fix_fast&)
00500 
00501 #undef DECL_ASN_OP_T
00502 #undef DECL_ASN_OP_OTHER
00503 #undef DECL_ASN_OP
00504 
00505 
00506     // auto-increment and auto-decrement
00507 
00508     const sc_fxval_fast operator ++ ( int );
00509     const sc_fxval_fast operator -- ( int );
00510 
00511     sc_fix_fast& operator ++ ();
00512     sc_fix_fast& operator -- ();
00513 
00514 };
00515 
00516 
00517 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00518 
00519 // ----------------------------------------------------------------------------
00520 //  CLASS : sc_fix
00521 //
00522 //  "Unconstrained" signed fixed-point class; arbitrary precision.
00523 // ----------------------------------------------------------------------------
00524 
00525 // constructors
00526 
00527 inline
00528 sc_fix::sc_fix( sc_fxnum_observer* observer_ )
00529 : sc_fxnum( sc_fxtype_params(),
00530         SC_TC_,
00531         sc_fxcast_switch(),
00532         observer_ )
00533 {}
00534 
00535 inline
00536 sc_fix::sc_fix( int wl_, int iwl_,
00537         sc_fxnum_observer* observer_ )
00538 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
00539         SC_TC_,
00540         sc_fxcast_switch(),
00541         observer_ )
00542 {}
00543 
00544 inline
00545 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om,
00546         sc_fxnum_observer* observer_ )
00547 : sc_fxnum( sc_fxtype_params( qm, om ),
00548         SC_TC_,
00549         sc_fxcast_switch(),
00550         observer_ )
00551 {}
00552 
00553 inline
00554 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb,
00555         sc_fxnum_observer* observer_ )
00556 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
00557         SC_TC_,
00558         sc_fxcast_switch(),
00559         observer_ )
00560 {}
00561 
00562 inline
00563 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
00564         sc_fxnum_observer* observer_ )
00565 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
00566         SC_TC_,
00567         sc_fxcast_switch(),
00568         observer_ )
00569 {}
00570 
00571 inline
00572 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
00573         sc_fxnum_observer* observer_ )
00574 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
00575         SC_TC_,
00576         sc_fxcast_switch(),
00577         observer_ )
00578 {}
00579 
00580 inline
00581 sc_fix::sc_fix( const sc_fxcast_switch& cast_sw,
00582         sc_fxnum_observer* observer_ )
00583 : sc_fxnum( sc_fxtype_params(),
00584         SC_TC_,
00585         cast_sw,
00586         observer_ )
00587 {}
00588 
00589 inline
00590 sc_fix::sc_fix( int wl_, int iwl_,
00591         const sc_fxcast_switch& cast_sw,
00592         sc_fxnum_observer* observer_ )
00593 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
00594         SC_TC_,
00595         cast_sw,
00596         observer_ )
00597 {}
00598 
00599 inline
00600 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om,
00601         const sc_fxcast_switch& cast_sw,
00602         sc_fxnum_observer* observer_ )
00603 : sc_fxnum( sc_fxtype_params( qm, om ),
00604         SC_TC_,
00605         cast_sw,
00606         observer_ )
00607 {}
00608 
00609 inline
00610 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb,
00611         const sc_fxcast_switch& cast_sw,
00612         sc_fxnum_observer* observer_ )
00613 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
00614         SC_TC_,
00615         cast_sw,
00616         observer_ )
00617 {}
00618 
00619 inline
00620 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
00621         const sc_fxcast_switch& cast_sw,
00622         sc_fxnum_observer* observer_ )
00623 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
00624         SC_TC_,
00625         cast_sw,
00626         observer_ )
00627 {}
00628 
00629 inline
00630 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
00631         const sc_fxcast_switch& cast_sw,
00632         sc_fxnum_observer* observer_ )
00633 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
00634         SC_TC_,
00635         cast_sw,
00636         observer_ )
00637 {}
00638 
00639 inline
00640 sc_fix::sc_fix( const sc_fxtype_params& type_params,
00641         sc_fxnum_observer* observer_ )
00642 : sc_fxnum( type_params,
00643         SC_TC_,
00644         sc_fxcast_switch(),
00645         observer_ )
00646 {}
00647 
00648 inline
00649 sc_fix::sc_fix( const sc_fxtype_params& type_params,
00650         const sc_fxcast_switch& cast_sw,
00651         sc_fxnum_observer* observer_ )
00652 : sc_fxnum( type_params,
00653         SC_TC_,
00654         cast_sw,
00655         observer_ )
00656 {}
00657 
00658 #define DEFN_CTORS_T_A(tp)                                                    \
00659 inline                                                                        \
00660 sc_fix::sc_fix( tp a,                                                         \
00661         sc_fxnum_observer* observer_ )                                \
00662 : sc_fxnum( a,                                                                \
00663         sc_fxtype_params(),                                               \
00664         SC_TC_,                                                           \
00665         sc_fxcast_switch(),                                               \
00666         observer_ )                                                       \
00667 {}                                                                            \
00668                                                                               \
00669 inline                                                                        \
00670 sc_fix::sc_fix( tp a,                                                         \
00671         int wl_, int iwl_,                                            \
00672         sc_fxnum_observer* observer_ )                                \
00673 : sc_fxnum( a,                                                                \
00674         sc_fxtype_params( wl_, iwl_ ),                                    \
00675         SC_TC_,                                                           \
00676         sc_fxcast_switch(),                                               \
00677         observer_ )                                                       \
00678 {}                                                                            \
00679                                                                               \
00680 inline                                                                        \
00681 sc_fix::sc_fix( tp a,                                                         \
00682         sc_q_mode qm, sc_o_mode om,                                   \
00683         sc_fxnum_observer* observer_ )                                \
00684 : sc_fxnum( a,                                                                \
00685         sc_fxtype_params( qm, om ),                                       \
00686         SC_TC_,                                                           \
00687         sc_fxcast_switch(),                                               \
00688         observer_ )                                                       \
00689 {}                                                                            \
00690                                                                               \
00691 inline                                                                        \
00692 sc_fix::sc_fix( tp a,                                                         \
00693         sc_q_mode qm, sc_o_mode om, int nb,                           \
00694         sc_fxnum_observer* observer_ )                                \
00695 : sc_fxnum( a,                                                                \
00696         sc_fxtype_params( qm, om, nb ),                                   \
00697         SC_TC_,                                                           \
00698         sc_fxcast_switch(),                                               \
00699         observer_ )                                                       \
00700 {}                                                                            \
00701                                                                               \
00702 inline                                                                        \
00703 sc_fix::sc_fix( tp a,                                                         \
00704         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00705         sc_fxnum_observer* observer_ )                                \
00706 : sc_fxnum( a,                                                                \
00707         sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00708         SC_TC_,                                                           \
00709         sc_fxcast_switch(),                                               \
00710         observer_ )                                                       \
00711 {}                                                                            \
00712                                                                               \
00713 inline                                                                        \
00714 sc_fix::sc_fix( tp a,                                                         \
00715         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00716         sc_fxnum_observer* observer_ )                                \
00717 : sc_fxnum( a,                                                                \
00718         sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00719         SC_TC_,                                                           \
00720         sc_fxcast_switch(),                                               \
00721         observer_ )                                                       \
00722 {}                                                                            \
00723                                                                               \
00724 inline                                                                        \
00725 sc_fix::sc_fix( tp a,                                                         \
00726         const sc_fxcast_switch& cast_sw,                              \
00727         sc_fxnum_observer* observer_ )                                \
00728 : sc_fxnum( a,                                                                \
00729         sc_fxtype_params(),                                               \
00730         SC_TC_,                                                           \
00731         cast_sw,                                                          \
00732         observer_ )                                                       \
00733 {}                                                                            \
00734                                                                               \
00735 inline                                                                        \
00736 sc_fix::sc_fix( tp a,                                                         \
00737         int wl_, int iwl_,                                            \
00738         const sc_fxcast_switch& cast_sw,                              \
00739         sc_fxnum_observer* observer_ )                                \
00740 : sc_fxnum( a,                                                                \
00741         sc_fxtype_params( wl_, iwl_ ),                                    \
00742         SC_TC_,                                                           \
00743         cast_sw,                                                          \
00744         observer_ )                                                       \
00745 {}                                                                            \
00746                                                                               \
00747 inline                                                                        \
00748 sc_fix::sc_fix( tp a,                                                         \
00749         sc_q_mode qm, sc_o_mode om,                                   \
00750         const sc_fxcast_switch& cast_sw,                              \
00751         sc_fxnum_observer* observer_ )                                \
00752 : sc_fxnum( a,                                                                \
00753         sc_fxtype_params( qm, om ),                                       \
00754         SC_TC_,                                                           \
00755         cast_sw,                                                          \
00756         observer_ )                                                       \
00757 {}                                                                            \
00758                                                                               \
00759 inline                                                                        \
00760 sc_fix::sc_fix( tp a,                                                         \
00761         sc_q_mode qm, sc_o_mode om, int nb,                           \
00762         const sc_fxcast_switch& cast_sw,                              \
00763         sc_fxnum_observer* observer_ )                                \
00764 : sc_fxnum( a,                                                                \
00765         sc_fxtype_params( qm, om, nb ),                                   \
00766         SC_TC_,                                                           \
00767         cast_sw,                                                          \
00768         observer_ )                                                       \
00769 {}                                                                            \
00770                                                                               \
00771 inline                                                                        \
00772 sc_fix::sc_fix( tp a,                                                         \
00773         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00774         const sc_fxcast_switch& cast_sw,                              \
00775         sc_fxnum_observer* observer_ )                                \
00776 : sc_fxnum( a,                                                                \
00777         sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00778         SC_TC_,                                                           \
00779         cast_sw,                                                          \
00780         observer_ )                                                       \
00781 {}                                                                            \
00782                                                                               \
00783 inline                                                                        \
00784 sc_fix::sc_fix( tp a,                                                         \
00785         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00786         const sc_fxcast_switch& cast_sw,                              \
00787         sc_fxnum_observer* observer_ )                                \
00788 : sc_fxnum( a,                                                                \
00789         sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00790         SC_TC_,                                                           \
00791         cast_sw,                                                          \
00792         observer_ )                                                       \
00793 {}                                                                            \
00794                                                                               \
00795 inline                                                                        \
00796 sc_fix::sc_fix( tp a,                                                         \
00797         const sc_fxtype_params& type_params,                          \
00798         sc_fxnum_observer* observer_ )                                \
00799 : sc_fxnum( a,                                                                \
00800         type_params,                                                      \
00801         SC_TC_,                                                           \
00802         sc_fxcast_switch(),                                               \
00803         observer_ )                                                       \
00804 {}                                                                            \
00805                                                                               \
00806 inline                                                                        \
00807 sc_fix::sc_fix( tp a,                                                         \
00808         const sc_fxtype_params& type_params,                          \
00809         const sc_fxcast_switch& cast_sw,                              \
00810         sc_fxnum_observer* observer_ )                                \
00811 : sc_fxnum( a,                                                                \
00812         type_params,                                                      \
00813         SC_TC_,                                                           \
00814         cast_sw,                                                          \
00815         observer_ )                                                       \
00816 {}
00817 
00818 #define DEFN_CTORS_T_B(tp)                                                    \
00819 inline                                                                        \
00820 sc_fix::sc_fix( tp a,                                                         \
00821         sc_fxnum_observer* observer_ )                                \
00822 : sc_fxnum( a,                                                                \
00823         a.type_params(),                                                  \
00824         SC_TC_,                                                           \
00825         sc_fxcast_switch(),                                               \
00826         observer_ )                                                       \
00827 {}                                                                            \
00828                                                                               \
00829 inline                                                                        \
00830 sc_fix::sc_fix( tp a,                                                         \
00831         int wl_, int iwl_,                                            \
00832         sc_fxnum_observer* observer_ )                                \
00833 : sc_fxnum( a,                                                                \
00834         sc_fxtype_params( a.type_params(), wl_, iwl_ ),                   \
00835         SC_TC_,                                                           \
00836         sc_fxcast_switch(),                                               \
00837         observer_ )                                                       \
00838 {}                                                                            \
00839                                                                               \
00840 inline                                                                        \
00841 sc_fix::sc_fix( tp a,                                                         \
00842         sc_q_mode qm, sc_o_mode om,                                   \
00843         sc_fxnum_observer* observer_ )                                \
00844 : sc_fxnum( a,                                                                \
00845         sc_fxtype_params( a.type_params(), qm, om ),                      \
00846         SC_TC_,                                                           \
00847         sc_fxcast_switch(),                                               \
00848         observer_ )                                                       \
00849 {}                                                                            \
00850                                                                               \
00851 inline                                                                        \
00852 sc_fix::sc_fix( tp a,                                                         \
00853         sc_q_mode qm, sc_o_mode om, int nb,                           \
00854         sc_fxnum_observer* observer_ )                                \
00855 : sc_fxnum( a,                                                                \
00856         sc_fxtype_params( a.type_params(), qm, om, nb ),                  \
00857         SC_TC_,                                                           \
00858         sc_fxcast_switch(),                                               \
00859         observer_ )                                                       \
00860 {}                                                                            \
00861                                                                               \
00862 inline                                                                        \
00863 sc_fix::sc_fix( tp a,                                                         \
00864         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00865         sc_fxnum_observer* observer_ )                                \
00866 : sc_fxnum( a,                                                                \
00867         sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00868         SC_TC_,                                                           \
00869         sc_fxcast_switch(),                                               \
00870         observer_ )                                                       \
00871 {}                                                                            \
00872                                                                               \
00873 inline                                                                        \
00874 sc_fix::sc_fix( tp a,                                                         \
00875         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00876         sc_fxnum_observer* observer_ )                                \
00877 : sc_fxnum( a,                                                                \
00878         sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00879         SC_TC_,                                                           \
00880         sc_fxcast_switch(),                                               \
00881         observer_ )                                                       \
00882 {}                                                                            \
00883                                                                               \
00884 inline                                                                        \
00885 sc_fix::sc_fix( tp a,                                                         \
00886         const sc_fxcast_switch& cast_sw,                              \
00887         sc_fxnum_observer* observer_ )                                \
00888 : sc_fxnum( a,                                                                \
00889         a.type_params(),                                                  \
00890         SC_TC_,                                                           \
00891         cast_sw,                                                          \
00892         observer_ )                                                       \
00893 {}                                                                            \
00894                                                                               \
00895 inline                                                                        \
00896 sc_fix::sc_fix( tp a,                                                         \
00897         int wl_, int iwl_,                                            \
00898         const sc_fxcast_switch& cast_sw,                              \
00899         sc_fxnum_observer* observer_ )                                \
00900 : sc_fxnum( a,                                                                \
00901         sc_fxtype_params( a.type_params(), wl_, iwl_ ),                   \
00902         SC_TC_,                                                           \
00903         cast_sw,                                                          \
00904         observer_ )                                                       \
00905 {}                                                                            \
00906                                                                               \
00907 inline                                                                        \
00908 sc_fix::sc_fix( tp a,                                                         \
00909         sc_q_mode qm, sc_o_mode om,                                   \
00910         const sc_fxcast_switch& cast_sw,                              \
00911         sc_fxnum_observer* observer_ )                                \
00912 : sc_fxnum( a,                                                                \
00913         sc_fxtype_params( a.type_params(), qm, om ),                      \
00914         SC_TC_,                                                           \
00915         cast_sw,                                                          \
00916         observer_ )                                                       \
00917 {}                                                                            \
00918                                                                               \
00919 inline                                                                        \
00920 sc_fix::sc_fix( tp a,                                                         \
00921         sc_q_mode qm, sc_o_mode om, int nb,                           \
00922         const sc_fxcast_switch& cast_sw,                              \
00923         sc_fxnum_observer* observer_ )                                \
00924 : sc_fxnum( a,                                                                \
00925         sc_fxtype_params( a.type_params(), qm, om, nb ),                  \
00926         SC_TC_,                                                           \
00927         cast_sw,                                                          \
00928         observer_ )                                                       \
00929 {}                                                                            \
00930                                                                               \
00931 inline                                                                        \
00932 sc_fix::sc_fix( tp a,                                                         \
00933         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00934         const sc_fxcast_switch& cast_sw,                              \
00935         sc_fxnum_observer* observer_ )                                \
00936 : sc_fxnum( a,                                                                \
00937         sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00938         SC_TC_,                                                           \
00939         cast_sw,                                                          \
00940         observer_ )                                                       \
00941 {}                                                                            \
00942                                                                               \
00943 inline                                                                        \
00944 sc_fix::sc_fix( tp a,                                                         \
00945         int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00946         const sc_fxcast_switch& cast_sw,                              \
00947         sc_fxnum_observer* observer_ )                                \
00948 : sc_fxnum( a,                                                                \
00949         sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00950         SC_TC_,                                                           \
00951         cast_sw,                                                          \
00952         observer_ )                                                       \
00953 {}                                                                            \
00954                                                                               \
00955 inline                                                                        \
00956 sc_fix::sc_fix( tp a,                                                         \
00957         const sc_fxtype_params& type_params,                          \
00958         sc_fxnum_observer* observer_ )                                \
00959 : sc_fxnum( a,                                                                \
00960         type_params,                                                      \
00961         SC_TC_,                                                           \
00962         sc_fxcast_switch(),                                               \
00963         observer_ )                                                       \
00964 {}                                                                            \
00965                                                                               \
00966 inline                                                                        \
00967 sc_fix::sc_fix( tp a,                                                         \
00968         const sc_fxtype_params& type_params,                          \
00969         const sc_fxcast_switch& cast_sw,                              \
00970         sc_fxnum_observer* observer_ )                                \
00971 : sc_fxnum( a,                                                                \
00972         type_params,                                                      \
00973         SC_TC_,                                                           \
00974         cast_sw,                                                          \
00975         observer_ )                                                       \
00976 {}
00977 
00978 DEFN_CTORS_T_A(int)
00979 DEFN_CTORS_T_A(unsigned int)
00980 DEFN_CTORS_T_A(long)
00981 DEFN_CTORS_T_A(unsigned long)
00982 DEFN_CTORS_T_A(double)
00983 DEFN_CTORS_T_A(const char*)
00984 DEFN_CTORS_T_A(const sc_fxval&)
00985 DEFN_CTORS_T_A(const sc_fxval_fast&)
00986 DEFN_CTORS_T_B(const sc_fxnum&)
00987 DEFN_CTORS_T_B(const sc_fxnum_fast&)
00988 #ifndef SC_FX_EXCLUDE_OTHER
00989 DEFN_CTORS_T_A(int64)
00990 DEFN_CTORS_T_A(uint64)
00991 DEFN_CTORS_T_A(const sc_int_base&)
00992 DEFN_CTORS_T_A(const sc_uint_base&)
00993 DEFN_CTORS_T_A(const sc_signed&)
00994 DEFN_CTORS_T_A(const sc_unsigned&)
00995 #endif
00996 
00997 #undef DEFN_CTORS_T_A
00998 #undef DEFN_CTORS_T_B
00999 
01000 // copy constructor
01001 
01002 inline
01003 sc_fix::sc_fix( const sc_fix& a )
01004 : sc_fxnum( a,
01005         a.type_params(),
01006         SC_TC_,
01007         sc_fxcast_switch(),
01008         0 )
01009 {}
01010 
01011 
01012 // unary bitwise operators
01013 
01014 inline
01015 const sc_fix
01016 sc_fix::operator ~ () const
01017 {
01018     SC_FXNUM_OBSERVER_READ_( *this )
01019     int iwl_c = iwl();
01020     int wl_c = wl();
01021     sc_fix c( wl_c, iwl_c );
01022     for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
01023     c.set_bit( i, ! get_bit( i ) );
01024     return sc_fix( c, wl_c, iwl_c );
01025 }
01026 
01027 
01028 // unary bitwise functions
01029 
01030 inline
01031 void
01032 b_not( sc_fix& c, const sc_fix& a )
01033 {
01034     SC_FXNUM_OBSERVER_READ_( a )
01035     int iwl_c = c.iwl();
01036     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
01037     c.set_bit( i, ! a.get_bit( i ) );
01038     c.cast();
01039     SC_FXNUM_OBSERVER_WRITE_( c )
01040 }
01041 
01042 
01043 // binary bitwise operators
01044 
01045 #define DEFN_BIN_OP_T(op,op2,tp1,tp2)                                         \
01046 inline                                                                        \
01047 const sc_fix                                                                  \
01048 operator op ( const tp1& a, const tp2& b )                                    \
01049 {                                                                             \
01050     a.observer_read();                                                        \
01051     b.observer_read();                                                        \
01052     int iwl_a = a.iwl();                                                      \
01053     int iwl_b = b.iwl();                                                      \
01054     int iwl_c = sc_max( iwl_a, iwl_b );                              \
01055     int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b );            \
01056     sc_fix c( iwl_c + fwl_c, iwl_c );                                         \
01057     for( int i = -fwl_c; i < iwl_c; ++ i )                                    \
01058     c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01059     return sc_fix( c, iwl_c + fwl_c, iwl_c );                                 \
01060 }
01061 
01062 DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix)
01063 DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix_fast)
01064 DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix)
01065 
01066 DEFN_BIN_OP_T(|,||,sc_fix,sc_fix)
01067 DEFN_BIN_OP_T(|,||,sc_fix,sc_fix_fast)
01068 DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix)
01069 
01070 DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix)
01071 DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix_fast)
01072 DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix)
01073 
01074 #undef DEFN_BIN_OP_T
01075 
01076 
01077 // binary bitwise functions
01078 
01079 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2)                                       \
01080 inline                                                                        \
01081 void                                                                          \
01082 fnc ( sc_fix& c, const tp1& a, const tp2& b )                                 \
01083 {                                                                             \
01084     a.observer_read();                                                        \
01085     b.observer_read();                                                        \
01086     int iwl_c = c.iwl();                                                      \
01087     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )                            \
01088     c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01089     c.cast();                                                                 \
01090     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
01091 }
01092 
01093 DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix)
01094 DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix_fast)
01095 DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix)
01096 
01097 DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix)
01098 DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix_fast)
01099 DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix)
01100 
01101 DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix)
01102 DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix_fast)
01103 DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix)
01104 
01105 #undef DEFN_BIN_FNC_T
01106 
01107 
01108 // assignment operators
01109 
01110 inline
01111 sc_fix&
01112 sc_fix::operator = ( const sc_fix& a )
01113 {
01114     sc_fxnum::operator = ( a );
01115     return *this;
01116 }
01117 
01118 #define DEFN_ASN_OP_T(op,tp)                                                  \
01119 inline                                                                        \
01120 sc_fix&                                                                       \
01121 sc_fix::operator op ( tp a )                                                  \
01122 {                                                                             \
01123     sc_fxnum::operator op( a );                                               \
01124     return *this;                                                             \
01125 }
01126 
01127 #ifndef SC_FX_EXCLUDE_OTHER
01128 #define DEFN_ASN_OP_OTHER(op)                                                 \
01129 DEFN_ASN_OP_T(op,int64)                                                       \
01130 DEFN_ASN_OP_T(op,uint64)                                                      \
01131 DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
01132 DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
01133 DEFN_ASN_OP_T(op,const sc_signed&)                                            \
01134 DEFN_ASN_OP_T(op,const sc_unsigned&)
01135 #else
01136 #define DEFN_ASN_OP_OTHER(op)
01137 #endif
01138 
01139 #define DEFN_ASN_OP(op)                                                       \
01140 DEFN_ASN_OP_T(op,int)                                                         \
01141 DEFN_ASN_OP_T(op,unsigned int)                                                \
01142 DEFN_ASN_OP_T(op,long)                                                        \
01143 DEFN_ASN_OP_T(op,unsigned long)                                               \
01144 DEFN_ASN_OP_T(op,double)                                                      \
01145 DEFN_ASN_OP_T(op,const char*)                                                 \
01146 DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
01147 DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
01148 DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
01149 DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
01150 DEFN_ASN_OP_OTHER(op)
01151 
01152 DEFN_ASN_OP(=)
01153 
01154 DEFN_ASN_OP(*=)
01155 DEFN_ASN_OP(/=)
01156 DEFN_ASN_OP(+=)
01157 DEFN_ASN_OP(-=)
01158 
01159 DEFN_ASN_OP_T(<<=,int)
01160 DEFN_ASN_OP_T(>>=,int)
01161 
01162 #undef DEFN_ASN_OP_T
01163 #undef DEFN_ASN_OP_OTHER
01164 #undef DEFN_ASN_OP
01165 
01166 
01167 #define DEFN_ASN_OP_T(op,op2,tp)                                              \
01168 inline                                                                        \
01169 sc_fix&                                                                       \
01170 sc_fix::operator op ( const tp& b )                                           \
01171 {                                                                             \
01172     SC_FXNUM_OBSERVER_READ_( *this )                                          \
01173     b.observer_read();                                                        \
01174     int iwl_c = iwl();                                                        \
01175     for( int i = iwl_c - wl(); i < iwl_c; ++ i )                              \
01176     set_bit( i, get_bit( i ) op2 b.get_bit( i ) );                        \
01177     cast();                                                                   \
01178     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
01179     return *this;                                                             \
01180 }
01181 
01182 DEFN_ASN_OP_T(&=,&&,sc_fix)
01183 DEFN_ASN_OP_T(&=,&&,sc_fix_fast)
01184 DEFN_ASN_OP_T(|=,||,sc_fix)
01185 DEFN_ASN_OP_T(|=,||,sc_fix_fast)
01186 DEFN_ASN_OP_T(^=,!=,sc_fix)
01187 DEFN_ASN_OP_T(^=,!=,sc_fix_fast)
01188 
01189 #undef DEFN_ASN_OP_T
01190 
01191 
01192 // auto-increment and auto-decrement
01193 
01194 inline
01195 const sc_fxval
01196 sc_fix::operator ++ ( int )
01197 {
01198     return sc_fxval( sc_fxnum::operator ++ ( 0 ) );
01199 }
01200 
01201 inline
01202 const sc_fxval
01203 sc_fix::operator -- ( int )
01204 {
01205     return sc_fxval( sc_fxnum::operator -- ( 0 ) );
01206 }
01207 
01208 inline
01209 sc_fix&
01210 sc_fix::operator ++ ()
01211 {
01212     sc_fxnum::operator ++ ();
01213     return *this;
01214 }
01215 
01216 inline
01217 sc_fix&
01218 sc_fix::operator -- ()
01219 {
01220     sc_fxnum::operator -- ();
01221     return *this;
01222 }
01223 
01224 
01225 // ----------------------------------------------------------------------------
01226 //  CLASS : sc_fix_fast
01227 //
01228 //  "Unconstrained" signed fixed-point class; limited precision.
01229 // ----------------------------------------------------------------------------
01230 
01231 // constructors
01232 
01233 inline
01234 sc_fix_fast::sc_fix_fast( sc_fxnum_fast_observer* observer_ )
01235 : sc_fxnum_fast( sc_fxtype_params(),
01236          SC_TC_,
01237          sc_fxcast_switch(),
01238          observer_ )
01239 {}
01240 
01241 inline
01242 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01243               sc_fxnum_fast_observer* observer_ )
01244 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
01245          SC_TC_,
01246          sc_fxcast_switch(),
01247          observer_ )
01248 {}
01249 
01250 inline
01251 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om,
01252               sc_fxnum_fast_observer* observer_ )
01253 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
01254          SC_TC_,
01255          sc_fxcast_switch(),
01256          observer_ )
01257 {}
01258 
01259 inline
01260 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb,
01261               sc_fxnum_fast_observer* observer_ )
01262 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
01263          SC_TC_,
01264          sc_fxcast_switch(),
01265          observer_ )
01266 {}
01267 
01268 inline
01269 sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
01270               sc_fxnum_fast_observer* observer_ )
01271 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
01272          SC_TC_,
01273          sc_fxcast_switch(),
01274          observer_ )
01275 {}
01276 
01277 inline
01278 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01279               sc_q_mode qm, sc_o_mode om, int nb,
01280               sc_fxnum_fast_observer* observer_ )
01281 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
01282          SC_TC_,
01283          sc_fxcast_switch(),
01284          observer_ )
01285 {}
01286 
01287 inline
01288 sc_fix_fast::sc_fix_fast( const sc_fxcast_switch& cast_sw,
01289               sc_fxnum_fast_observer* observer_ )
01290 : sc_fxnum_fast( sc_fxtype_params(),
01291          SC_TC_,
01292          cast_sw,
01293          observer_ )
01294 {}
01295 
01296 inline
01297 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01298               const sc_fxcast_switch& cast_sw,
01299               sc_fxnum_fast_observer* observer_ )
01300 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
01301          SC_TC_,
01302          cast_sw,
01303          observer_ )
01304 {}
01305 
01306 inline
01307 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om,
01308               const sc_fxcast_switch& cast_sw,
01309               sc_fxnum_fast_observer* observer_ )
01310 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
01311          SC_TC_,
01312          cast_sw,
01313          observer_ )
01314 {}
01315 
01316 inline
01317 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb,
01318               const sc_fxcast_switch& cast_sw,
01319               sc_fxnum_fast_observer* observer_ )
01320 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
01321          SC_TC_,
01322          cast_sw,
01323          observer_ )
01324 {}
01325 
01326 inline
01327 sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
01328               const sc_fxcast_switch& cast_sw,
01329               sc_fxnum_fast_observer* observer_ )
01330 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
01331          SC_TC_,
01332          cast_sw,
01333          observer_ )
01334 {}
01335 
01336 inline
01337 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01338               sc_q_mode qm, sc_o_mode om, int nb,
01339               const sc_fxcast_switch& cast_sw,
01340               sc_fxnum_fast_observer* observer_ )
01341 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
01342          SC_TC_,
01343          cast_sw,
01344          observer_ )
01345 {}
01346 
01347 inline
01348 sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params,
01349               sc_fxnum_fast_observer* observer_ )
01350 : sc_fxnum_fast( type_params,
01351          SC_TC_,
01352          sc_fxcast_switch(),
01353          observer_ )
01354 {}
01355 
01356 inline
01357 sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params,
01358               const sc_fxcast_switch& cast_sw,
01359               sc_fxnum_fast_observer* observer_ )
01360 : sc_fxnum_fast( type_params,
01361          SC_TC_,
01362          cast_sw,
01363          observer_ )
01364 {}
01365 
01366 #define DEFN_CTORS_T_A(tp)                                                    \
01367 inline                                                                        \
01368 sc_fix_fast::sc_fix_fast( tp a,                                               \
01369               sc_fxnum_fast_observer* observer_ )                 \
01370 : sc_fxnum_fast( a,                                                           \
01371          sc_fxtype_params(),                                          \
01372          SC_TC_,                                                      \
01373          sc_fxcast_switch(),                                          \
01374          observer_ )                                                  \
01375 {}                                                                            \
01376                                                                               \
01377 inline                                                                        \
01378 sc_fix_fast::sc_fix_fast( tp a,                                               \
01379               int wl_, int iwl_,                                  \
01380               sc_fxnum_fast_observer* observer_ )                 \
01381 : sc_fxnum_fast( a,                                                           \
01382          sc_fxtype_params( wl_, iwl_ ),                               \
01383          SC_TC_,                                                      \
01384          sc_fxcast_switch(),                                          \
01385          observer_ )                                                  \
01386 {}                                                                            \
01387                                                                               \
01388 inline                                                                        \
01389 sc_fix_fast::sc_fix_fast( tp a,                                               \
01390               sc_q_mode qm, sc_o_mode om,                         \
01391               sc_fxnum_fast_observer* observer_ )                 \
01392 : sc_fxnum_fast( a,                                                           \
01393          sc_fxtype_params( qm, om ),                                  \
01394          SC_TC_,                                                      \
01395          sc_fxcast_switch(),                                          \
01396          observer_ )                                                  \
01397 {}                                                                            \
01398                                                                               \
01399 inline                                                                        \
01400 sc_fix_fast::sc_fix_fast( tp a,                                               \
01401               sc_q_mode qm, sc_o_mode om, int nb,                 \
01402               sc_fxnum_fast_observer* observer_ )                 \
01403 : sc_fxnum_fast( a,                                                           \
01404          sc_fxtype_params( qm, om, nb ),                              \
01405          SC_TC_,                                                      \
01406          sc_fxcast_switch(),                                          \
01407          observer_ )                                                  \
01408 {}                                                                            \
01409                                                                               \
01410 inline                                                                        \
01411 sc_fix_fast::sc_fix_fast( tp a,                                               \
01412               int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01413               sc_fxnum_fast_observer* observer_ )                 \
01414 : sc_fxnum_fast( a,                                                           \
01415          sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01416          SC_TC_,                                                      \
01417          sc_fxcast_switch(),                                          \
01418          observer_ )                                                  \
01419 {}                                                                            \
01420                                                                               \
01421 inline                                                                        \
01422 sc_fix_fast::sc_fix_fast( tp a,                                               \
01423               int wl_, int iwl_,                                  \
01424               sc_q_mode qm, sc_o_mode om, int nb,                 \
01425               sc_fxnum_fast_observer* observer_ )                 \
01426 : sc_fxnum_fast( a,                                                           \
01427          sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01428          SC_TC_,                                                      \
01429          sc_fxcast_switch(),                                          \
01430          observer_ )                                                  \
01431 {}                                                                            \
01432                                                                               \
01433 inline                                                                        \
01434 sc_fix_fast::sc_fix_fast( tp a,                                               \
01435               const sc_fxcast_switch& cast_sw,                    \
01436               sc_fxnum_fast_observer* observer_ )                 \
01437 : sc_fxnum_fast( a,                                                           \
01438          sc_fxtype_params(),                                          \
01439          SC_TC_,                                                      \
01440          cast_sw,                                                     \
01441          observer_ )                                                  \
01442 {}                                                                            \
01443                                                                               \
01444 inline                                                                        \
01445 sc_fix_fast::sc_fix_fast( tp a,                                               \
01446               int wl_, int iwl_,                                  \
01447               const sc_fxcast_switch& cast_sw,                    \
01448               sc_fxnum_fast_observer* observer_ )                 \
01449 : sc_fxnum_fast( a,                                                           \
01450          sc_fxtype_params( wl_, iwl_ ),                               \
01451          SC_TC_,                                                      \
01452          cast_sw,                                                     \
01453          observer_ )                                                  \
01454 {}                                                                            \
01455                                                                               \
01456 inline                                                                        \
01457 sc_fix_fast::sc_fix_fast( tp a,                                               \
01458               sc_q_mode qm, sc_o_mode om,                         \
01459               const sc_fxcast_switch& cast_sw,                    \
01460               sc_fxnum_fast_observer* observer_ )                 \
01461 : sc_fxnum_fast( a,                                                           \
01462          sc_fxtype_params( qm, om ),                                  \
01463          SC_TC_,                                                      \
01464          cast_sw,                                                     \
01465          observer_ )                                                  \
01466 {}                                                                            \
01467                                                                               \
01468 inline                                                                        \
01469 sc_fix_fast::sc_fix_fast( tp a,                                               \
01470               sc_q_mode qm, sc_o_mode om, int nb,                 \
01471               const sc_fxcast_switch& cast_sw,                    \
01472               sc_fxnum_fast_observer* observer_ )                 \
01473 : sc_fxnum_fast( a,                                                           \
01474          sc_fxtype_params( qm, om, nb ),                              \
01475          SC_TC_,                                                      \
01476          cast_sw,                                                     \
01477          observer_ )                                                  \
01478 {}                                                                            \
01479                                                                               \
01480 inline                                                                        \
01481 sc_fix_fast::sc_fix_fast( tp a,                                               \
01482               int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01483               const sc_fxcast_switch& cast_sw,                    \
01484               sc_fxnum_fast_observer* observer_ )                 \
01485 : sc_fxnum_fast( a,                                                           \
01486          sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01487          SC_TC_,                                                      \
01488          cast_sw,                                                     \
01489          observer_ )                                                  \
01490 {}                                                                            \
01491                                                                               \
01492 inline                                                                        \
01493 sc_fix_fast::sc_fix_fast( tp a,                                               \
01494               int wl_, int iwl_,                                  \
01495               sc_q_mode qm, sc_o_mode om, int nb,                 \
01496               const sc_fxcast_switch& cast_sw,                    \
01497               sc_fxnum_fast_observer* observer_ )                 \
01498 : sc_fxnum_fast( a,                                                           \
01499          sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01500          SC_TC_,                                                      \
01501          cast_sw,                                                     \
01502          observer_ )                                                  \
01503 {}                                                                            \
01504                                                                               \
01505 inline                                                                        \
01506 sc_fix_fast::sc_fix_fast( tp a,                                               \
01507               const sc_fxtype_params& type_params,                \
01508               sc_fxnum_fast_observer* observer_ )                 \
01509 : sc_fxnum_fast( a,                                                           \
01510          type_params,                                                 \
01511          SC_TC_,                                                      \
01512          sc_fxcast_switch(),                                          \
01513          observer_ )                                                  \
01514 {}                                                                            \
01515                                                                               \
01516 inline                                                                        \
01517 sc_fix_fast::sc_fix_fast( tp a,                                               \
01518               const sc_fxtype_params& type_params,                \
01519               const sc_fxcast_switch& cast_sw,                    \
01520               sc_fxnum_fast_observer* observer_ )                 \
01521 : sc_fxnum_fast( a,                                                           \
01522          type_params,                                                 \
01523          SC_TC_,                                                      \
01524          cast_sw,                                                     \
01525          observer_ )                                                  \
01526 {}
01527 
01528 #define DEFN_CTORS_T_B(tp)                                                    \
01529 inline                                                                        \
01530 sc_fix_fast::sc_fix_fast( tp a,                                               \
01531               sc_fxnum_fast_observer* observer_ )                 \
01532 : sc_fxnum_fast( a,                                                           \
01533          a.type_params(),                                             \
01534          SC_TC_,                                                      \
01535          sc_fxcast_switch(),                                          \
01536          observer_ )                                                  \
01537 {}                                                                            \
01538                                                                               \
01539 inline                                                                        \
01540 sc_fix_fast::sc_fix_fast( tp a,                                               \
01541               int wl_, int iwl_,                                  \
01542               sc_fxnum_fast_observer* observer_ )                 \
01543 : sc_fxnum_fast( a,                                                           \
01544          sc_fxtype_params( a.type_params(), wl_, iwl_ ),              \
01545          SC_TC_,                                                      \
01546          sc_fxcast_switch(),                                          \
01547          observer_ )                                                  \
01548 {}                                                                            \
01549                                                                               \
01550 inline                                                                        \
01551 sc_fix_fast::sc_fix_fast( tp a,                                               \
01552               sc_q_mode qm, sc_o_mode om,                         \
01553               sc_fxnum_fast_observer* observer_ )                 \
01554 : sc_fxnum_fast( a,                                                           \
01555          sc_fxtype_params( a.type_params(), qm, om ),                 \
01556          SC_TC_,                                                      \
01557          sc_fxcast_switch(),                                          \
01558          observer_ )                                                  \
01559 {}                                                                            \
01560                                                                               \
01561 inline                                                                        \
01562 sc_fix_fast::sc_fix_fast( tp a,                                               \
01563               sc_q_mode qm, sc_o_mode om, int nb,                 \
01564               sc_fxnum_fast_observer* observer_ )                 \
01565 : sc_fxnum_fast( a,                                                           \
01566          sc_fxtype_params( a.type_params(), qm, om, nb ),             \
01567          SC_TC_,                                                      \
01568          sc_fxcast_switch(),                                          \
01569          observer_ )                                                  \
01570 {}                                                                            \
01571                                                                               \
01572 inline                                                                        \
01573 sc_fix_fast::sc_fix_fast( tp a,                                               \
01574               int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01575               sc_fxnum_fast_observer* observer_ )                 \
01576 : sc_fxnum_fast( a,                                                           \
01577          sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01578          SC_TC_,                                                      \
01579          sc_fxcast_switch(),                                          \
01580          observer_ )                                                  \
01581 {}                                                                            \
01582                                                                               \
01583 inline                                                                        \
01584 sc_fix_fast::sc_fix_fast( tp a,                                               \
01585               int wl_, int iwl_,                                  \
01586               sc_q_mode qm, sc_o_mode om, int nb,                 \
01587               sc_fxnum_fast_observer* observer_ )                 \
01588 : sc_fxnum_fast( a,                                                           \
01589          sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01590          SC_TC_,                                                      \
01591          sc_fxcast_switch(),                                          \
01592          observer_ )                                                  \
01593 {}                                                                            \
01594                                                                               \
01595 inline                                                                        \
01596 sc_fix_fast::sc_fix_fast( tp a,                                               \
01597               const sc_fxcast_switch& cast_sw,                    \
01598               sc_fxnum_fast_observer* observer_ )                 \
01599 : sc_fxnum_fast( a,                                                           \
01600          a.type_params(),                                             \
01601          SC_TC_,                                                      \
01602          cast_sw,                                                     \
01603          observer_ )                                                  \
01604 {}                                                                            \
01605                                                                               \
01606 inline                                                                        \
01607 sc_fix_fast::sc_fix_fast( tp a,                                               \
01608               int wl_, int iwl_,                                  \
01609               const sc_fxcast_switch& cast_sw,                    \
01610               sc_fxnum_fast_observer* observer_ )                 \
01611 : sc_fxnum_fast( a,                                                           \
01612          sc_fxtype_params( a.type_params(), wl_, iwl_ ),              \
01613          SC_TC_,                                                      \
01614          cast_sw,                                                     \
01615          observer_ )                                                  \
01616 {}                                                                            \
01617                                                                               \
01618 inline                                                                        \
01619 sc_fix_fast::sc_fix_fast( tp a,                                               \
01620               sc_q_mode qm, sc_o_mode om,                         \
01621               const sc_fxcast_switch& cast_sw,                    \
01622               sc_fxnum_fast_observer* observer_ )                 \
01623 : sc_fxnum_fast( a,                                                           \
01624          sc_fxtype_params( a.type_params(), qm, om ),                 \
01625          SC_TC_,                                                      \
01626          cast_sw,                                                     \
01627          observer_ )                                                  \
01628 {}                                                                            \
01629                                                                               \
01630 inline                                                                        \
01631 sc_fix_fast::sc_fix_fast( tp a,                                               \
01632               sc_q_mode qm, sc_o_mode om, int nb,                 \
01633               const sc_fxcast_switch& cast_sw,                    \
01634               sc_fxnum_fast_observer* observer_ )                 \
01635 : sc_fxnum_fast( a,                                                           \
01636          sc_fxtype_params( a.type_params(), qm, om, nb ),             \
01637          SC_TC_,                                                      \
01638          cast_sw,                                                     \
01639          observer_ )                                                  \
01640 {}                                                                            \
01641                                                                               \
01642 inline                                                                        \
01643 sc_fix_fast::sc_fix_fast( tp a,                                               \
01644               int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01645               const sc_fxcast_switch& cast_sw,                    \
01646               sc_fxnum_fast_observer* observer_ )                 \
01647 : sc_fxnum_fast( a,                                                           \
01648          sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01649          SC_TC_,                                                      \
01650          cast_sw,                                                     \
01651          observer_ )                                                  \
01652 {}                                                                            \
01653                                                                               \
01654 inline                                                                        \
01655 sc_fix_fast::sc_fix_fast( tp a,                                               \
01656               int wl_, int iwl_,                                  \
01657               sc_q_mode qm, sc_o_mode om, int nb,                 \
01658               const sc_fxcast_switch& cast_sw,                    \
01659               sc_fxnum_fast_observer* observer_ )                 \
01660 : sc_fxnum_fast( a,                                                           \
01661          sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01662          SC_TC_,                                                      \
01663          cast_sw,                                                     \
01664          observer_ )                                                  \
01665 {}                                                                            \
01666                                                                               \
01667 inline                                                                        \
01668 sc_fix_fast::sc_fix_fast( tp a,                                               \
01669               const sc_fxtype_params& type_params,                \
01670               sc_fxnum_fast_observer* observer_ )                 \
01671 : sc_fxnum_fast( a,                                                           \
01672          type_params,                                                 \
01673          SC_TC_,                                                      \
01674          sc_fxcast_switch(),                                          \
01675          observer_ )                                                  \
01676 {}                                                                            \
01677                                                                               \
01678 inline                                                                        \
01679 sc_fix_fast::sc_fix_fast( tp a,                                               \
01680               const sc_fxtype_params& type_params,                \
01681               const sc_fxcast_switch& cast_sw,                    \
01682               sc_fxnum_fast_observer* observer_ )                 \
01683 : sc_fxnum_fast( a,                                                           \
01684          type_params,                                                 \
01685          SC_TC_,                                                      \
01686          cast_sw,                                                     \
01687          observer_ )                                                  \
01688 {}
01689 
01690 DEFN_CTORS_T_A(int)
01691 DEFN_CTORS_T_A(unsigned int)
01692 DEFN_CTORS_T_A(long)
01693 DEFN_CTORS_T_A(unsigned long)
01694 DEFN_CTORS_T_A(double)
01695 DEFN_CTORS_T_A(const char*)
01696 DEFN_CTORS_T_A(const sc_fxval&)
01697 DEFN_CTORS_T_A(const sc_fxval_fast&)
01698 DEFN_CTORS_T_B(const sc_fxnum&)
01699 DEFN_CTORS_T_B(const sc_fxnum_fast&)
01700 #ifndef SC_FX_EXCLUDE_OTHER
01701 DEFN_CTORS_T_A(int64)
01702 DEFN_CTORS_T_A(uint64)
01703 DEFN_CTORS_T_A(const sc_int_base&)
01704 DEFN_CTORS_T_A(const sc_uint_base&)
01705 DEFN_CTORS_T_A(const sc_signed&)
01706 DEFN_CTORS_T_A(const sc_unsigned&)
01707 #endif
01708 
01709 #undef DEFN_CTORS_T_A
01710 #undef DEFN_CTORS_T_B
01711 
01712 // copy constructor
01713 
01714 inline
01715 sc_fix_fast::sc_fix_fast( const sc_fix_fast& a )
01716 : sc_fxnum_fast( a,
01717          a.type_params(),
01718          SC_TC_,
01719          sc_fxcast_switch(),
01720          0 )
01721 {}
01722 
01723 
01724 // unary bitwise operators
01725 
01726 inline
01727 const sc_fix_fast
01728 sc_fix_fast::operator ~ () const
01729 {
01730     SC_FXNUM_FAST_OBSERVER_READ_( *this )
01731     int iwl_c = iwl();
01732     int wl_c = wl();
01733     sc_fix_fast c( wl_c, iwl_c );
01734     for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
01735     c.set_bit( i, ! get_bit( i ) );
01736     return sc_fix_fast( c, wl_c, iwl_c );
01737 }
01738 
01739 
01740 // unary bitwise functions
01741 
01742 inline
01743 void
01744 b_not( sc_fix_fast& c, const sc_fix_fast& a )
01745 {
01746     SC_FXNUM_FAST_OBSERVER_READ_( a )
01747     int iwl_c = c.iwl();
01748     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
01749     c.set_bit( i, ! a.get_bit( i ) );
01750     c.cast();
01751     SC_FXNUM_FAST_OBSERVER_WRITE_( c )
01752 }
01753 
01754 
01755 // binary bitwise operators
01756 
01757 #define DEFN_BIN_OP_T(op,op2,tp1,tp2)                                         \
01758 inline                                                                        \
01759 const sc_fix_fast                                                             \
01760 operator op ( const tp1& a, const tp2& b )                                    \
01761 {                                                                             \
01762     a.observer_read();                                                        \
01763     b.observer_read();                                                        \
01764     int iwl_a = a.iwl();                                                      \
01765     int iwl_b = b.iwl();                                                      \
01766     int iwl_c = sc_max( iwl_a, iwl_b );                              \
01767     int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b );            \
01768     sc_fix_fast c( iwl_c + fwl_c, iwl_c );                                    \
01769     for( int i = -fwl_c; i < iwl_c; ++ i )                                    \
01770     c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01771     return sc_fix_fast( c, iwl_c + fwl_c, iwl_c );                            \
01772 }
01773 
01774 DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix_fast)
01775 DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix_fast)
01776 DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix_fast)
01777 
01778 #undef DEFN_BIN_OP_T
01779 
01780 
01781 // binary bitwise functions
01782 
01783 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2)                                       \
01784 inline                                                                        \
01785 void                                                                          \
01786 fnc ( sc_fix_fast& c, const tp1& a, const tp2& b )                            \
01787 {                                                                             \
01788     a.observer_read();                                                        \
01789     b.observer_read();                                                        \
01790     int iwl_c = c.iwl();                                                      \
01791     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )                            \
01792     c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01793     c.cast();                                                                 \
01794     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
01795 }
01796 
01797 DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix_fast)
01798 DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix_fast)
01799 DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix_fast)
01800 
01801 #undef DEFN_BIN_FNC_T
01802 
01803 
01804 // assignment operators
01805 
01806 inline
01807 sc_fix_fast&
01808 sc_fix_fast::operator = ( const sc_fix_fast& a )
01809 {
01810     sc_fxnum_fast::operator = ( a );
01811     return *this;
01812 }
01813 
01814 #define DEFN_ASN_OP_T(op,tp)                                                  \
01815 inline                                                                        \
01816 sc_fix_fast&                                                                  \
01817 sc_fix_fast::operator op ( tp a )                                             \
01818 {                                                                             \
01819     sc_fxnum_fast::operator op( a );                                          \
01820     return *this;                                                             \
01821 }
01822 
01823 #ifndef SC_FX_EXCLUDE_OTHER
01824 #define DEFN_ASN_OP_OTHER(op)                                                 \
01825 DEFN_ASN_OP_T(op,int64)                                                       \
01826 DEFN_ASN_OP_T(op,uint64)                                                      \
01827 DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
01828 DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
01829 DEFN_ASN_OP_T(op,const sc_signed&)                                            \
01830 DEFN_ASN_OP_T(op,const sc_unsigned&)
01831 #else
01832 #define DEFN_ASN_OP_OTHER(op)
01833 #endif
01834 
01835 #define DEFN_ASN_OP(op)                                                       \
01836 DEFN_ASN_OP_T(op,int)                                                         \
01837 DEFN_ASN_OP_T(op,unsigned int)                                                \
01838 DEFN_ASN_OP_T(op,long)                                                        \
01839 DEFN_ASN_OP_T(op,unsigned long)                                               \
01840 DEFN_ASN_OP_T(op,double)                                                      \
01841 DEFN_ASN_OP_T(op,const char*)                                                 \
01842 DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
01843 DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
01844 DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
01845 DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
01846 DEFN_ASN_OP_OTHER(op)
01847 
01848 DEFN_ASN_OP(=)
01849 
01850 DEFN_ASN_OP(*=)
01851 DEFN_ASN_OP(/=)
01852 DEFN_ASN_OP(+=)
01853 DEFN_ASN_OP(-=)
01854 
01855 DEFN_ASN_OP_T(<<=,int)
01856 DEFN_ASN_OP_T(>>=,int)
01857 
01858 #undef DEFN_ASN_OP_T
01859 #undef DEFN_ASN_OP_OTHER
01860 #undef DEFN_ASN_OP
01861 
01862 
01863 #define DEFN_ASN_OP_T(op,op2,tp)                                              \
01864 inline                                                                        \
01865 sc_fix_fast&                                                                  \
01866 sc_fix_fast::operator op ( const tp& b )                                      \
01867 {                                                                             \
01868     SC_FXNUM_FAST_OBSERVER_READ_( *this )                                     \
01869     b.observer_read();                                                        \
01870     int iwl_c = iwl();                                                        \
01871     for( int i = iwl_c - wl(); i < iwl_c; ++ i )                              \
01872     set_bit( i, get_bit( i ) op2 b.get_bit( i ) );                        \
01873     cast();                                                                   \
01874     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
01875     return *this;                                                             \
01876 }
01877 
01878 DEFN_ASN_OP_T(&=,&&,sc_fix)
01879 DEFN_ASN_OP_T(&=,&&,sc_fix_fast)
01880 DEFN_ASN_OP_T(|=,||,sc_fix)
01881 DEFN_ASN_OP_T(|=,||,sc_fix_fast)
01882 DEFN_ASN_OP_T(^=,!=,sc_fix)
01883 DEFN_ASN_OP_T(^=,!=,sc_fix_fast)
01884 
01885 #undef DEFN_ASN_OP_T
01886 
01887 
01888 // auto-increment and auto-decrement
01889 
01890 inline
01891 const sc_fxval_fast
01892 sc_fix_fast::operator ++ ( int )
01893 {
01894     return sc_fxval_fast( sc_fxnum_fast::operator ++ ( 0 ) );
01895 }
01896 
01897 inline
01898 const sc_fxval_fast
01899 sc_fix_fast::operator -- ( int )
01900 {
01901     return sc_fxval_fast( sc_fxnum_fast::operator -- ( 0 ) );
01902 }
01903 
01904 inline
01905 sc_fix_fast&
01906 sc_fix_fast::operator ++ ()
01907 {
01908     sc_fxnum_fast::operator ++ ();
01909     return *this;
01910 }
01911 
01912 inline
01913 sc_fix_fast&
01914 sc_fix_fast::operator -- ()
01915 {
01916     sc_fxnum_fast::operator -- ();
01917     return *this;
01918 }
01919 
01920 } // namespace sc_dt
01921 
01922 
01923 #endif
01924 
01925 // Taf!

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