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