SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_fxnum.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_fxnum.h -
23 
24  Original Author: Martin Janssen, Synopsys, Inc.
25 
26  *****************************************************************************/
27 
28 /*****************************************************************************
29 
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32 
33  Name, Affiliation, Date:
34  Description of Modification:
35 
36  *****************************************************************************/
37 
38 // $Log: sc_fxnum.h,v $
39 // Revision 1.5 2011/08/29 18:04:32 acg
40 // Philipp A. Hartmann: miscellaneous clean ups.
41 //
42 // Revision 1.4 2011/08/24 22:05:43 acg
43 // Torsten Maehne: initialization changes to remove warnings.
44 //
45 // Revision 1.3 2011/01/19 18:57:40 acg
46 // Andy Goodrich: changes for IEEE_1666_2011.
47 //
48 // Revision 1.2 2009/03/09 17:26:46 acg
49 // Andy Goodrich: removed ; from namespace { }
50 //
51 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
52 // SystemC 2.3
53 //
54 // Revision 1.3 2006/01/13 18:53:58 acg
55 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
56 // the source.
57 //
58 
59 #ifndef SC_FXNUM_H
60 #define SC_FXNUM_H
61 
62 
63 #include "sysc/kernel/sc_cmnhdr.h"
68 
69 
70 namespace sc_core {
71  class vcd_sc_fxnum_trace;
72  class vcd_sc_fxnum_fast_trace;
73  class wif_sc_fxnum_trace;
74  class wif_sc_fxnum_fast_trace;
75 }
76 
77 
78 namespace sc_dt
79 {
80 
81 // classes defined in this module
82 class sc_fxnum_bitref;
83 class sc_fxnum_fast_bitref;
84 class sc_fxnum_subref;
85 class sc_fxnum_fast_subref;
86 class sc_fxnum;
87 class sc_fxnum_fast;
88 
89 
97 {
98  friend class sc_fxnum;
99  friend class sc_fxnum_fast_bitref;
100 
101 
102  bool get() const;
103  void set( bool );
104 
105 
106  // constructor
107 
108  sc_fxnum_bitref( sc_fxnum&, int );
109 
110 public:
111 
112  // copy constructor
113 
115 
116 
117  // assignment operators
118 
119 #define DECL_ASN_OP_T(op,tp) \
120  sc_fxnum_bitref& operator op ( tp );
121 
122 #define DECL_ASN_OP(op) \
123  DECL_ASN_OP_T(op,const sc_fxnum_bitref&) \
124  DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&) \
125  DECL_ASN_OP_T(op,const sc_bit&) \
126  DECL_ASN_OP_T(op,bool)
127 
128  DECL_ASN_OP(=)
129 
130  DECL_ASN_OP(&=)
131  DECL_ASN_OP(|=)
132  DECL_ASN_OP(^=)
133 
134 #undef DECL_ASN_OP_T
135 #undef DECL_ASN_OP
136 
137 
138  // implicit conversion
139 
140  operator bool() const;
141 
142 
143  // print or dump content
144 
145  void print( ::std::ostream& = ::std::cout ) const;
146  void scan( ::std::istream& = ::std::cin );
147  void dump( ::std::ostream& = ::std::cout ) const;
148 
149 private:
150 
151  sc_fxnum& m_num;
152  int m_idx;
153 
154 private:
155 
156  // disabled
157  sc_fxnum_bitref();
158 };
159 
160 
168 {
169  friend class sc_fxnum_fast;
170  friend class sc_fxnum_bitref;
171 
172 
173  bool get() const;
174  void set( bool );
175 
176 
177  // constructor
178 
180 
181 public:
182 
183  // copy constructor
184 
186 
187 
188  // assignment operators
189 
190 #define DECL_ASN_OP_T(op,tp) \
191  sc_fxnum_fast_bitref& operator op ( tp );
192 
193 #define DECL_ASN_OP(op) \
194  DECL_ASN_OP_T(op,const sc_fxnum_bitref&) \
195  DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&) \
196  DECL_ASN_OP_T(op,const sc_bit&) \
197  DECL_ASN_OP_T(op,bool)
198 
199  DECL_ASN_OP(=)
200 
201  DECL_ASN_OP(&=)
202  DECL_ASN_OP(|=)
203  DECL_ASN_OP(^=)
204 
205 #undef DECL_ASN_OP_T
206 #undef DECL_ASN_OP
207 
208 
209  // implicit conversion
210 
211  operator bool() const;
212 
213 
214  // print or dump content
215 
216  void print( ::std::ostream& = ::std::cout ) const;
217  void scan( ::std::istream& = ::std::cin );
218  void dump( ::std::ostream& = ::std::cout ) const;
219 
220 private:
221 
222  sc_fxnum_fast& m_num;
223  int m_idx;
224 
225 private:
226 
227  // disabled
229 };
230 
231 
240 {
241  friend class sc_fxnum;
242  friend class sc_fxnum_fast_subref;
243 
244  bool get() const;
245  bool set();
246 
247 
248  // constructor
249 
250  sc_fxnum_subref( sc_fxnum&, int, int );
251 
252 public:
253 
254  // copy constructor
255 
257 
258 
259  // destructor
260 
261  ~sc_fxnum_subref();
262 
263 
264  // assignment operators
265 
266 #define DECL_ASN_OP_T(tp) \
267  sc_fxnum_subref& operator = ( tp );
268 
271  DECL_ASN_OP_T(const sc_bv_base&)
272  DECL_ASN_OP_T(const sc_lv_base&)
273  DECL_ASN_OP_T(const char*)
274  DECL_ASN_OP_T(const bool*)
275  DECL_ASN_OP_T(const sc_signed&)
276  DECL_ASN_OP_T(const sc_unsigned&)
277  DECL_ASN_OP_T(const sc_int_base&)
281  DECL_ASN_OP_T(int)
282  DECL_ASN_OP_T(unsigned int)
283  DECL_ASN_OP_T(long)
284  DECL_ASN_OP_T(unsigned long)
285  DECL_ASN_OP_T(char)
286 
287 #undef DECL_ASN_OP_T
288 
289 #define DECL_ASN_OP_T_A(op,tp) \
290  sc_fxnum_subref& operator op ## = ( tp );
291 
292 #define DECL_ASN_OP_A(op) \
293  DECL_ASN_OP_T_A(op,const sc_fxnum_subref&) \
294  DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&) \
295  DECL_ASN_OP_T_A(op,const sc_bv_base&) \
296  DECL_ASN_OP_T_A(op,const sc_lv_base&)
297 
298  DECL_ASN_OP_A(&)
299  DECL_ASN_OP_A(|)
300  DECL_ASN_OP_A(^)
301 
302 #undef DECL_ASN_OP_T_A
303 #undef DECL_ASN_OP_A
304 
305 
306  // relational operators
307 
308 #define DECL_REL_OP_T(op,tp) \
309  friend bool operator op ( const sc_fxnum_subref&, tp ); \
310  friend bool operator op ( tp, const sc_fxnum_subref& );
311 
312 #define DECL_REL_OP(op) \
313  friend bool operator op ( const sc_fxnum_subref&, \
314  const sc_fxnum_subref& ); \
315  friend bool operator op ( const sc_fxnum_subref&, \
316  const sc_fxnum_fast_subref& ); \
317  DECL_REL_OP_T(op,const sc_bv_base&) \
318  DECL_REL_OP_T(op,const sc_lv_base&) \
319  DECL_REL_OP_T(op,const char*) \
320  DECL_REL_OP_T(op,const bool*) \
321  DECL_REL_OP_T(op,const sc_signed&) \
322  DECL_REL_OP_T(op,const sc_unsigned&) \
323  DECL_REL_OP_T(op,int) \
324  DECL_REL_OP_T(op,unsigned int) \
325  DECL_REL_OP_T(op,long) \
326  DECL_REL_OP_T(op,unsigned long)
327 
328  DECL_REL_OP(==)
329  DECL_REL_OP(!=)
330 
331 #undef DECL_REL_OP_T
332 #undef DECL_REL_OP
333 
334 
335  // reduce functions
336 
337  bool and_reduce() const;
338  bool nand_reduce() const;
339  bool or_reduce() const;
340  bool nor_reduce() const;
341  bool xor_reduce() const;
342  bool xnor_reduce() const;
343 
344 
345  // query parameter
346 
347  int length() const;
348 
349 
350  // explicit conversions
351 
352  int to_int() const;
353  unsigned int to_uint() const;
354  long to_long() const;
355  unsigned long to_ulong() const;
356  int64 to_int64() const;
357  uint64 to_uint64() const;
358 
359 #ifdef SC_DT_DEPRECATED
360  int to_signed() const;
361  unsigned int to_unsigned() const;
362 #endif
363 
364  const std::string to_string() const;
365  const std::string to_string( sc_numrep ) const;
366  const std::string to_string( sc_numrep, bool ) const;
367 
368 
369  // implicit conversion
370 
371  operator sc_bv_base() const;
372 
373 
374  // print or dump content
375 
376  void print( ::std::ostream& = ::std::cout ) const;
377  void scan( ::std::istream& = ::std::cin );
378  void dump( ::std::ostream& = ::std::cout ) const;
379 
380 private:
381 
382  sc_fxnum& m_num;
383  int m_from;
384  int m_to;
385 
386  sc_bv_base& m_bv;
387 
388 private:
389 
390  // disabled
391  sc_fxnum_subref();
392 };
393 
394 
403 {
404  friend class sc_fxnum_fast;
405  friend class sc_fxnum_subref;
406 
407  bool get() const;
408  bool set();
409 
410 
411  // constructor
412 
413  sc_fxnum_fast_subref( sc_fxnum_fast&, int, int );
414 
415 public:
416 
417  // copy constructor
418 
420 
421 
422  // destructor
423 
425 
426 
427  // assignment operators
428 
429 #define DECL_ASN_OP_T(tp) \
430  sc_fxnum_fast_subref& operator = ( tp );
431 
434  DECL_ASN_OP_T(const sc_bv_base&)
435  DECL_ASN_OP_T(const sc_lv_base&)
436  DECL_ASN_OP_T(const char*)
437  DECL_ASN_OP_T(const bool*)
438  DECL_ASN_OP_T(const sc_signed&)
439  DECL_ASN_OP_T(const sc_unsigned&)
440  DECL_ASN_OP_T(const sc_int_base&)
444  DECL_ASN_OP_T(int)
445  DECL_ASN_OP_T(unsigned int)
446  DECL_ASN_OP_T(long)
447  DECL_ASN_OP_T(unsigned long)
448  DECL_ASN_OP_T(char)
449 
450 #undef DECL_ASN_OP_T
451 
452 #define DECL_ASN_OP_T_A(op,tp) \
453  sc_fxnum_fast_subref& operator op ## = ( tp );
454 
455 #define DECL_ASN_OP_A(op) \
456  DECL_ASN_OP_T_A(op,const sc_fxnum_subref&) \
457  DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&) \
458  DECL_ASN_OP_T_A(op,const sc_bv_base&) \
459  DECL_ASN_OP_T_A(op,const sc_lv_base&)
460 
461  DECL_ASN_OP_A(&)
462  DECL_ASN_OP_A(|)
463  DECL_ASN_OP_A(^)
464 
465 #undef DECL_ASN_OP_T_A
466 #undef DECL_ASN_OP_A
467 
468 
469  // relational operators
470 
471 #define DECL_REL_OP_T(op,tp) \
472  friend bool operator op ( const sc_fxnum_fast_subref&, tp ); \
473  friend bool operator op ( tp, const sc_fxnum_fast_subref& );
474 
475 #define DECL_REL_OP(op) \
476  friend bool operator op ( const sc_fxnum_fast_subref&, \
477  const sc_fxnum_fast_subref& ); \
478  friend bool operator op ( const sc_fxnum_fast_subref&, \
479  const sc_fxnum_subref& ); \
480  DECL_REL_OP_T(op,const sc_bv_base&) \
481  DECL_REL_OP_T(op,const sc_lv_base&) \
482  DECL_REL_OP_T(op,const char*) \
483  DECL_REL_OP_T(op,const bool*) \
484  DECL_REL_OP_T(op,const sc_signed&) \
485  DECL_REL_OP_T(op,const sc_unsigned&) \
486  DECL_REL_OP_T(op,int) \
487  DECL_REL_OP_T(op,unsigned int) \
488  DECL_REL_OP_T(op,long) \
489  DECL_REL_OP_T(op,unsigned long)
490 
491  DECL_REL_OP(==)
492  DECL_REL_OP(!=)
493 
494 #undef DECL_REL_OP_T
495 #undef DECL_REL_OP
496 
497 
498  // reduce functions
499 
500  bool and_reduce() const;
501  bool nand_reduce() const;
502  bool or_reduce() const;
503  bool nor_reduce() const;
504  bool xor_reduce() const;
505  bool xnor_reduce() const;
506 
507 
508  // query parameter
509 
510  int length() const;
511 
512 
513  // explicit conversions
514 
515  int to_int() const;
516  unsigned int to_uint() const;
517  long to_long() const;
518  unsigned long to_ulong() const;
519  int64 to_int64() const;
520  uint64 to_uint64() const;
521 
522 #ifdef SC_DT_DEPRECATED
523  int to_signed() const;
524  unsigned int to_unsigned() const;
525 #endif
526 
527  const std::string to_string() const;
528  const std::string to_string( sc_numrep ) const;
529  const std::string to_string( sc_numrep, bool ) const;
530 
531 
532  // implicit conversion
533 
534  operator sc_bv_base() const;
535 
536 
537  // print or dump content
538 
539  void print( ::std::ostream& = ::std::cout ) const;
540  void scan( ::std::istream& = ::std::cin );
541  void dump( ::std::ostream& = ::std::cout ) const;
542 
543 private:
544 
545  sc_fxnum_fast& m_num;
546  int m_from;
547  int m_to;
548 
549  sc_bv_base& m_bv;
550 
551 private:
552 
553  // disabled
554  sc_fxnum_fast_subref();
555 };
556 
557 
565 {
566  friend class sc_fxval;
567 
568  friend class sc_fxnum_bitref;
569  friend class sc_fxnum_subref;
570  friend class sc_fxnum_fast_bitref;
571  friend class sc_fxnum_fast_subref;
572 
573  friend class sc_core::vcd_sc_fxnum_trace;
574  friend class sc_core::wif_sc_fxnum_trace;
575 
576 protected:
577 
578  sc_fxnum_observer* observer() const;
579 
580 
581  void cast();
582 
583 
584  // constructors
585 
586  sc_fxnum( const sc_fxtype_params&,
587  sc_enc,
588  const sc_fxcast_switch&,
590 
591 #define DECL_CTOR_T(tp) \
592  sc_fxnum( tp, \
593  const sc_fxtype_params&, \
594  sc_enc, \
595  const sc_fxcast_switch&, \
596  sc_fxnum_observer* );
597 
598  DECL_CTOR_T(int)
599  DECL_CTOR_T(unsigned int)
600  DECL_CTOR_T(long)
601  DECL_CTOR_T(unsigned long)
602  DECL_CTOR_T(float)
603  DECL_CTOR_T(double)
604  DECL_CTOR_T(const char*)
605  DECL_CTOR_T(const sc_fxval&)
606  DECL_CTOR_T(const sc_fxval_fast&)
607  DECL_CTOR_T(const sc_fxnum&)
608  DECL_CTOR_T(const sc_fxnum_fast&)
609 #ifndef SC_FX_EXCLUDE_OTHER
612  DECL_CTOR_T(const sc_int_base&)
613  DECL_CTOR_T(const sc_uint_base&)
614  DECL_CTOR_T(const sc_signed&)
615  DECL_CTOR_T(const sc_unsigned&)
616 #endif
617 
618 #undef DECL_CTOR_T
619 
620  ~sc_fxnum();
621 
622 
623  // internal use only;
624  const scfx_rep* get_rep() const;
625 
626 public:
627 
628  // unary operators
629 
630  const sc_fxval operator - () const;
631  const sc_fxval operator + () const;
632 
633 
634  // unary functions
635 
636  friend void neg( sc_fxval&, const sc_fxnum& );
637  friend void neg( sc_fxnum&, const sc_fxnum& );
638 
639 
640  // binary operators
641 
642 #define DECL_BIN_OP_T(op,tp) \
643  friend const sc_fxval operator op ( const sc_fxnum&, tp ); \
644  friend const sc_fxval operator op ( tp, const sc_fxnum& );
645 
646 #ifndef SC_FX_EXCLUDE_OTHER
647 #define DECL_BIN_OP_OTHER(op) \
648  DECL_BIN_OP_T(op,int64) \
649  DECL_BIN_OP_T(op,uint64) \
650  DECL_BIN_OP_T(op,const sc_int_base&) \
651  DECL_BIN_OP_T(op,const sc_uint_base&) \
652  DECL_BIN_OP_T(op,const sc_signed&) \
653  DECL_BIN_OP_T(op,const sc_unsigned&)
654 #else
655 #define DECL_BIN_OP_OTHER(op)
656 #endif
657 
658 #define DECL_BIN_OP(op,dummy) \
659  friend const sc_fxval operator op ( const sc_fxnum&, const sc_fxnum& ); \
660  DECL_BIN_OP_T(op,int) \
661  DECL_BIN_OP_T(op,unsigned int) \
662  DECL_BIN_OP_T(op,long) \
663  DECL_BIN_OP_T(op,unsigned long) \
664  DECL_BIN_OP_T(op,float) \
665  DECL_BIN_OP_T(op,double) \
666  DECL_BIN_OP_T(op,const char*) \
667  DECL_BIN_OP_T(op,const sc_fxval&) \
668  DECL_BIN_OP_T(op,const sc_fxval_fast&) \
669  DECL_BIN_OP_T(op,const sc_fxnum_fast&) \
670  DECL_BIN_OP_OTHER(op)
671 
672  DECL_BIN_OP(*,mult)
673  DECL_BIN_OP(+,add)
674  DECL_BIN_OP(-,sub)
675 // don't use macros
676 // DECL_BIN_OP(/,div)
677  friend const sc_fxval operator / ( const sc_fxnum&, const sc_fxnum& );
678  DECL_BIN_OP_T(/,int)
679  DECL_BIN_OP_T(/,unsigned int)
680  DECL_BIN_OP_T(/,long)
681  DECL_BIN_OP_T(/,unsigned long)
682  DECL_BIN_OP_T(/,float)
683  DECL_BIN_OP_T(/,double)
684  DECL_BIN_OP_T(/,const char*)
685  DECL_BIN_OP_T(/,const sc_fxval&)
686  DECL_BIN_OP_T(/,const sc_fxval_fast&)
687  DECL_BIN_OP_T(/,const sc_fxnum_fast&)
688 // DECL_BIN_OP_OTHER(op)
689 #ifndef SC_FX_EXCLUDE_OTHER
692  DECL_BIN_OP_T(/,const sc_int_base&)
693  DECL_BIN_OP_T(/,const sc_uint_base&)
694  DECL_BIN_OP_T(/,const sc_signed&)
695  DECL_BIN_OP_T(/,const sc_unsigned&)
696 #endif
697 
698 #undef DECL_BIN_OP_T
699 #undef DECL_BIN_OP_OTHER
700 #undef DECL_BIN_OP
701 
702  friend const sc_fxval operator << ( const sc_fxnum&, int );
703  friend const sc_fxval operator >> ( const sc_fxnum&, int );
704 
705 
706  // binary functions
707 
708 #define DECL_BIN_FNC_T(fnc,tp) \
709  friend void fnc ( sc_fxval&, const sc_fxnum&, tp ); \
710  friend void fnc ( sc_fxval&, tp, const sc_fxnum& ); \
711  friend void fnc ( sc_fxnum&, const sc_fxnum&, tp ); \
712  friend void fnc ( sc_fxnum&, tp, const sc_fxnum& );
713 
714 #ifndef SC_FX_EXCLUDE_OTHER
715 #define DECL_BIN_FNC_OTHER(fnc) \
716  DECL_BIN_FNC_T(fnc,int64) \
717  DECL_BIN_FNC_T(fnc,uint64) \
718  DECL_BIN_FNC_T(fnc,const sc_int_base&) \
719  DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
720  DECL_BIN_FNC_T(fnc,const sc_signed&) \
721  DECL_BIN_FNC_T(fnc,const sc_unsigned&)
722 #else
723 #define DECL_BIN_FNC_OTHER(fnc)
724 #endif
725 
726 #define DECL_BIN_FNC(fnc) \
727  friend void fnc ( sc_fxval&, const sc_fxnum&, const sc_fxnum& ); \
728  friend void fnc ( sc_fxnum&, const sc_fxnum&, const sc_fxnum& ); \
729  DECL_BIN_FNC_T(fnc,int) \
730  DECL_BIN_FNC_T(fnc,unsigned int) \
731  DECL_BIN_FNC_T(fnc,long) \
732  DECL_BIN_FNC_T(fnc,unsigned long) \
733  DECL_BIN_FNC_T(fnc,float) \
734  DECL_BIN_FNC_T(fnc,double) \
735  DECL_BIN_FNC_T(fnc,const char*) \
736  DECL_BIN_FNC_T(fnc,const sc_fxval&) \
737  DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \
738  DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&) \
739  DECL_BIN_FNC_OTHER(fnc)
740 
741  DECL_BIN_FNC(mult)
743  DECL_BIN_FNC(add)
744  DECL_BIN_FNC(sub)
745 
746 #undef DECL_BIN_FNC_T
747 #undef DECL_BIN_FNC_OTHER
748 #undef DECL_BIN_FNC
749 
750  friend void lshift( sc_fxval&, const sc_fxnum&, int );
751  friend void rshift( sc_fxval&, const sc_fxnum&, int );
752  friend void lshift( sc_fxnum&, const sc_fxnum&, int );
753  friend void rshift( sc_fxnum&, const sc_fxnum&, int );
754 
755 
756  // relational (including equality) operators
757 
758 #define DECL_REL_OP_T(op,tp) \
759  friend bool operator op ( const sc_fxnum&, tp ); \
760  friend bool operator op ( tp, const sc_fxnum& );
761 
762 #ifndef SC_FX_EXCLUDE_OTHER
763 #define DECL_REL_OP_OTHER(op) \
764  DECL_REL_OP_T(op,int64) \
765  DECL_REL_OP_T(op,uint64) \
766  DECL_REL_OP_T(op,const sc_int_base&) \
767  DECL_REL_OP_T(op,const sc_uint_base&) \
768  DECL_REL_OP_T(op,const sc_signed&) \
769  DECL_REL_OP_T(op,const sc_unsigned&)
770 #else
771 #define DECL_REL_OP_OTHER(op)
772 #endif
773 
774 #define DECL_REL_OP(op) \
775  friend bool operator op ( const sc_fxnum&, const sc_fxnum& ); \
776  DECL_REL_OP_T(op,int) \
777  DECL_REL_OP_T(op,unsigned int) \
778  DECL_REL_OP_T(op,long) \
779  DECL_REL_OP_T(op,unsigned long) \
780  DECL_REL_OP_T(op,float) \
781  DECL_REL_OP_T(op,double) \
782  DECL_REL_OP_T(op,const char*) \
783  DECL_REL_OP_T(op,const sc_fxval&) \
784  DECL_REL_OP_T(op,const sc_fxval_fast&) \
785  DECL_REL_OP_T(op,const sc_fxnum_fast&) \
786  DECL_REL_OP_OTHER(op)
787 
788  DECL_REL_OP(<)
789  DECL_REL_OP(<=)
790  DECL_REL_OP(>)
791  DECL_REL_OP(>=)
792  DECL_REL_OP(==)
793  DECL_REL_OP(!=)
794 
795 #undef DECL_REL_OP_T
796 #undef DECL_REL_OP_OTHER
797 #undef DECL_REL_OP
798 
799 
800  // assignment operators
801 
802 #define DECL_ASN_OP_T(op,tp) \
803  sc_fxnum& operator op( tp );
804 
805 #ifndef SC_FX_EXCLUDE_OTHER
806 #define DECL_ASN_OP_OTHER(op) \
807  DECL_ASN_OP_T(op,int64) \
808  DECL_ASN_OP_T(op,uint64) \
809  DECL_ASN_OP_T(op,const sc_int_base&) \
810  DECL_ASN_OP_T(op,const sc_uint_base&) \
811  DECL_ASN_OP_T(op,const sc_signed&) \
812  DECL_ASN_OP_T(op,const sc_unsigned&)
813 #else
814 #define DECL_ASN_OP_OTHER(op)
815 #endif
816 
817 #define DECL_ASN_OP(op) \
818  DECL_ASN_OP_T(op,int) \
819  DECL_ASN_OP_T(op,unsigned int) \
820  DECL_ASN_OP_T(op,long) \
821  DECL_ASN_OP_T(op,unsigned long) \
822  DECL_ASN_OP_T(op,float) \
823  DECL_ASN_OP_T(op,double) \
824  DECL_ASN_OP_T(op,const char*) \
825  DECL_ASN_OP_T(op,const sc_fxval&) \
826  DECL_ASN_OP_T(op,const sc_fxval_fast&) \
827  DECL_ASN_OP_T(op,const sc_fxnum&) \
828  DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
829  DECL_ASN_OP_OTHER(op)
830 
831  DECL_ASN_OP(=)
832 
833  DECL_ASN_OP(*=)
834  DECL_ASN_OP(/=)
835  DECL_ASN_OP(+=)
836  DECL_ASN_OP(-=)
837 
838  DECL_ASN_OP_T(<<=,int)
839  DECL_ASN_OP_T(>>=,int)
840 
841 #undef DECL_ASN_OP_T
842 #undef DECL_ASN_OP_OTHER
843 #undef DECL_ASN_OP
844 
845 
846  // auto-increment and auto-decrement
847 
848  const sc_fxval operator ++ ( int );
849  const sc_fxval operator -- ( int );
850 
851  sc_fxnum& operator ++ ();
852  sc_fxnum& operator -- ();
853 
854 
855  // bit selection
856 
857  const sc_fxnum_bitref operator [] ( int ) const;
858  sc_fxnum_bitref operator [] ( int );
859 
860  const sc_fxnum_bitref bit( int ) const;
861  sc_fxnum_bitref bit( int );
862 
863 
864  // part selection
865 
866  const sc_fxnum_subref operator () ( int, int ) const;
867  sc_fxnum_subref operator () ( int, int );
868 
869  const sc_fxnum_subref range( int, int ) const;
870  sc_fxnum_subref range( int, int );
871 
872 
873  const sc_fxnum_subref operator () () const;
874  sc_fxnum_subref operator () ();
875 
876  const sc_fxnum_subref range() const;
877  sc_fxnum_subref range();
878 
879 
880  // implicit conversion
881 
882  operator double() const; // necessary evil!
883 
884 
885  // explicit conversion to primitive types
886 
887  short to_short() const;
888  unsigned short to_ushort() const;
889  int to_int() const;
890  unsigned int to_uint() const;
891  long to_long() const;
892  unsigned long to_ulong() const;
893  int64 to_int64() const;
894  uint64 to_uint64() const;
895  float to_float() const;
896  double to_double() const;
897 
898 
899  // explicit conversion to character string
900 
901  const std::string to_string() const;
902  const std::string to_string( sc_numrep ) const;
903  const std::string to_string( sc_numrep, bool ) const;
904  const std::string to_string( sc_fmt ) const;
905  const std::string to_string( sc_numrep, sc_fmt ) const;
906  const std::string to_string( sc_numrep, bool, sc_fmt ) const;
907 
908  const std::string to_dec() const;
909  const std::string to_bin() const;
910  const std::string to_oct() const;
911  const std::string to_hex() const;
912 
913 
914  // query value
915 
916  bool is_neg() const;
917  bool is_zero() const;
918 
919  // internal use only;
920  bool is_normal() const;
921 
922  bool quantization_flag() const;
923  bool overflow_flag() const;
924 
925  const sc_fxval value() const;
926 
927 
928  // query parameters
929 
930  int wl() const;
931  int iwl() const;
932  sc_q_mode q_mode() const;
933  sc_o_mode o_mode() const;
934  int n_bits() const;
935 
936  const sc_fxtype_params& type_params() const;
937 
938  const sc_fxcast_switch& cast_switch() const;
939 
940 
941  // print or dump content
942 
943  void print( ::std::ostream& = ::std::cout ) const;
944  void scan( ::std::istream& = ::std::cin );
945  void dump( ::std::ostream& = ::std::cout ) const;
946 
947 
948  // internal use only;
949  void observer_read() const;
950 
951 
952  // internal use only;
953  bool get_bit( int ) const;
954 
955 protected:
956 
957  bool set_bit( int, bool );
958 
959 
960  bool get_slice( int, int, sc_bv_base& ) const;
961  bool set_slice( int, int, const sc_bv_base& );
962 
963 
964  sc_fxnum_observer* lock_observer() const;
965  void unlock_observer( sc_fxnum_observer* ) const;
966 
967 private:
968 
969  scfx_rep* m_rep;
970 
971  scfx_params m_params;
972  bool m_q_flag;
973  bool m_o_flag;
974 
975  mutable sc_fxnum_observer* m_observer;
976 
977 private:
978 
979  // disabled
980  sc_fxnum();
981  sc_fxnum( const sc_fxnum& );
982 };
983 
984 
992 {
993  friend class sc_fxval_fast;
994 
995  friend class sc_fxnum_bitref;
996  friend class sc_fxnum_subref;
997  friend class sc_fxnum_fast_bitref;
998  friend class sc_fxnum_fast_subref;
999 
1000  friend class sc_core::vcd_sc_fxnum_fast_trace;
1001  friend class sc_core::wif_sc_fxnum_fast_trace;
1002 
1003 protected:
1004 
1005  sc_fxnum_fast_observer* observer() const;
1006 
1007 
1008  void cast();
1009 
1010 
1011  // constructors
1012 
1014  sc_enc,
1015  const sc_fxcast_switch&,
1017 
1018 #define DECL_CTOR_T(tp) \
1019  sc_fxnum_fast( tp, \
1020  const sc_fxtype_params&, \
1021  sc_enc, \
1022  const sc_fxcast_switch&, \
1023  sc_fxnum_fast_observer* );
1024 
1025  DECL_CTOR_T(int)
1026  DECL_CTOR_T(unsigned int)
1027  DECL_CTOR_T(long)
1028  DECL_CTOR_T(unsigned long)
1029  DECL_CTOR_T(float)
1030  DECL_CTOR_T(double)
1031  DECL_CTOR_T(const char*)
1032  DECL_CTOR_T(const sc_fxval&)
1033  DECL_CTOR_T(const sc_fxval_fast&)
1034  DECL_CTOR_T(const sc_fxnum&)
1035  DECL_CTOR_T(const sc_fxnum_fast&)
1036 #ifndef SC_FX_EXCLUDE_OTHER
1039  DECL_CTOR_T(const sc_int_base&)
1040  DECL_CTOR_T(const sc_uint_base&)
1041  DECL_CTOR_T(const sc_signed&)
1042  DECL_CTOR_T(const sc_unsigned&)
1043 #endif
1044 
1045 #undef DECL_CTOR_T
1046 
1047  ~sc_fxnum_fast();
1048 
1049 
1050  // internal use only;
1051  double get_val() const;
1052 
1053 public:
1054 
1055  // unary operators
1056 
1057  const sc_fxval_fast operator - () const;
1058  const sc_fxval_fast operator + () const;
1059 
1060 
1061  // unary functions
1062 
1063  friend void neg( sc_fxval_fast&, const sc_fxnum_fast& );
1064  friend void neg( sc_fxnum_fast&, const sc_fxnum_fast& );
1065 
1066 
1067  // binary operators
1068 
1069 #define DECL_BIN_OP_T(op,tp) \
1070  friend const sc_fxval_fast operator op ( const sc_fxnum_fast&, tp ); \
1071  friend const sc_fxval_fast operator op ( tp, const sc_fxnum_fast& );
1072 
1073 #ifndef SC_FX_EXCLUDE_OTHER
1074 #define DECL_BIN_OP_OTHER(op) \
1075  DECL_BIN_OP_T(op,int64) \
1076  DECL_BIN_OP_T(op,uint64) \
1077  DECL_BIN_OP_T(op,const sc_int_base&) \
1078  DECL_BIN_OP_T(op,const sc_uint_base&) \
1079  DECL_BIN_OP_T(op,const sc_signed&) \
1080  DECL_BIN_OP_T(op,const sc_unsigned&)
1081 #else
1082 #define DECL_BIN_OP_OTHER(op)
1083 #endif
1084 
1085 #define DECL_BIN_OP(op,dummy) \
1086  friend const sc_fxval_fast operator op ( const sc_fxnum_fast&, \
1087  const sc_fxnum_fast& ); \
1088  DECL_BIN_OP_T(op,int) \
1089  DECL_BIN_OP_T(op,unsigned int) \
1090  DECL_BIN_OP_T(op,long) \
1091  DECL_BIN_OP_T(op,unsigned long) \
1092  DECL_BIN_OP_T(op,float) \
1093  DECL_BIN_OP_T(op,double) \
1094  DECL_BIN_OP_T(op,const char*) \
1095  DECL_BIN_OP_T(op,const sc_fxval_fast&) \
1096  DECL_BIN_OP_OTHER(op)
1097 
1098  DECL_BIN_OP(*,mult)
1099  DECL_BIN_OP(+,add)
1100  DECL_BIN_OP(-,sub)
1101 // DECL_BIN_OP(/,div)
1102  friend const sc_fxval_fast operator / ( const sc_fxnum_fast&,
1103  const sc_fxnum_fast& );
1104  DECL_BIN_OP_T(/,int)
1105  DECL_BIN_OP_T(/,unsigned int)
1106  DECL_BIN_OP_T(/,long)
1107  DECL_BIN_OP_T(/,unsigned long)
1108  DECL_BIN_OP_T(/,float)
1109  DECL_BIN_OP_T(/,double)
1110  DECL_BIN_OP_T(/,const char*)
1111  DECL_BIN_OP_T(/,const sc_fxval_fast&)
1112 // DECL_BIN_OP_OTHER(op)
1113 #ifndef SC_FX_EXCLUDE_OTHER
1114  DECL_BIN_OP_T(/,int64) \
1115  DECL_BIN_OP_T(/,uint64) \
1116  DECL_BIN_OP_T(/,const sc_int_base&) \
1117  DECL_BIN_OP_T(/,const sc_uint_base&) \
1118  DECL_BIN_OP_T(/,const sc_signed&) \
1119  DECL_BIN_OP_T(/,const sc_unsigned&)
1120 #endif
1121 
1122 #undef DECL_BIN_OP_T
1123 #undef DECL_BIN_OP_OTHER
1124 #undef DECL_BIN_OP
1125 
1126  friend const sc_fxval_fast operator << ( const sc_fxnum_fast&, int );
1127  friend const sc_fxval_fast operator >> ( const sc_fxnum_fast&, int );
1128 
1129 
1130  // binary functions
1131 
1132 #define DECL_BIN_FNC_T(fnc,tp) \
1133  friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&, tp ); \
1134  friend void fnc ( sc_fxval_fast&, tp, const sc_fxnum_fast& ); \
1135  friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, tp ); \
1136  friend void fnc ( sc_fxnum_fast&, tp, const sc_fxnum_fast& );
1137 
1138 #ifndef SC_FX_EXCLUDE_OTHER
1139 #define DECL_BIN_FNC_OTHER(fnc) \
1140  DECL_BIN_FNC_T(fnc,int64) \
1141  DECL_BIN_FNC_T(fnc,uint64) \
1142  DECL_BIN_FNC_T(fnc,const sc_int_base&) \
1143  DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
1144  DECL_BIN_FNC_T(fnc,const sc_signed&) \
1145  DECL_BIN_FNC_T(fnc,const sc_unsigned&)
1146 #else
1147 #define DECL_BIN_FNC_OTHER(fnc)
1148 #endif
1149 
1150 #define DECL_BIN_FNC(fnc) \
1151  friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&, \
1152  const sc_fxnum_fast& ); \
1153  friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, \
1154  const sc_fxnum_fast& ); \
1155  DECL_BIN_FNC_T(fnc,int) \
1156  DECL_BIN_FNC_T(fnc,unsigned int) \
1157  DECL_BIN_FNC_T(fnc,long) \
1158  DECL_BIN_FNC_T(fnc,unsigned long) \
1159  DECL_BIN_FNC_T(fnc,float) \
1160  DECL_BIN_FNC_T(fnc,double) \
1161  DECL_BIN_FNC_T(fnc,const char*) \
1162  DECL_BIN_FNC_T(fnc,const sc_fxval&) \
1163  DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \
1164  DECL_BIN_FNC_T(fnc,const sc_fxnum&) \
1165  DECL_BIN_FNC_OTHER(fnc)
1166 
1167  DECL_BIN_FNC(mult)
1168  DECL_BIN_FNC(div)
1169  DECL_BIN_FNC(add)
1170  DECL_BIN_FNC(sub)
1171 
1172 #undef DECL_BIN_FNC_T
1173 #undef DECL_BIN_FNC_OTHER
1174 #undef DECL_BIN_FNC
1175 
1176  friend void lshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
1177  friend void rshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
1178  friend void lshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
1179  friend void rshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
1180 
1181 
1182  // relational (including equality) operators
1183 
1184 #define DECL_REL_OP_T(op,tp) \
1185  friend bool operator op ( const sc_fxnum_fast&, tp ); \
1186  friend bool operator op ( tp, const sc_fxnum_fast& );
1187 
1188 #ifndef SC_FX_EXCLUDE_OTHER
1189 #define DECL_REL_OP_OTHER(op) \
1190  DECL_REL_OP_T(op,int64) \
1191  DECL_REL_OP_T(op,uint64) \
1192  DECL_REL_OP_T(op,const sc_int_base&) \
1193  DECL_REL_OP_T(op,const sc_uint_base&) \
1194  DECL_REL_OP_T(op,const sc_signed&) \
1195  DECL_REL_OP_T(op,const sc_unsigned&)
1196 #else
1197 #define DECL_REL_OP_OTHER(op)
1198 #endif
1199 
1200 #define DECL_REL_OP(op) \
1201  friend bool operator op ( const sc_fxnum_fast&, const sc_fxnum_fast& ); \
1202  DECL_REL_OP_T(op,int) \
1203  DECL_REL_OP_T(op,unsigned int) \
1204  DECL_REL_OP_T(op,long) \
1205  DECL_REL_OP_T(op,unsigned long) \
1206  DECL_REL_OP_T(op,float) \
1207  DECL_REL_OP_T(op,double) \
1208  DECL_REL_OP_T(op,const char*) \
1209  DECL_REL_OP_T(op,const sc_fxval_fast&) \
1210  DECL_REL_OP_OTHER(op)
1211 
1212  DECL_REL_OP(<)
1213  DECL_REL_OP(<=)
1214  DECL_REL_OP(>)
1215  DECL_REL_OP(>=)
1216  DECL_REL_OP(==)
1217  DECL_REL_OP(!=)
1218 
1219 #undef DECL_REL_OP_T
1220 #undef DECL_REL_OP_OTHER
1221 #undef DECL_REL_OP
1222 
1223 
1224  // assignment operators
1225 
1226 #define DECL_ASN_OP_T(op,tp) \
1227  sc_fxnum_fast& operator op( tp );
1228 
1229 #ifndef SC_FX_EXCLUDE_OTHER
1230 #define DECL_ASN_OP_OTHER(op) \
1231  DECL_ASN_OP_T(op,int64) \
1232  DECL_ASN_OP_T(op,uint64) \
1233  DECL_ASN_OP_T(op,const sc_int_base&) \
1234  DECL_ASN_OP_T(op,const sc_uint_base&) \
1235  DECL_ASN_OP_T(op,const sc_signed&) \
1236  DECL_ASN_OP_T(op,const sc_unsigned&)
1237 #else
1238 #define DECL_ASN_OP_OTHER(op)
1239 #endif
1240 
1241 #define DECL_ASN_OP(op) \
1242  DECL_ASN_OP_T(op,int) \
1243  DECL_ASN_OP_T(op,unsigned int) \
1244  DECL_ASN_OP_T(op,long) \
1245  DECL_ASN_OP_T(op,unsigned long) \
1246  DECL_ASN_OP_T(op,float) \
1247  DECL_ASN_OP_T(op,double) \
1248  DECL_ASN_OP_T(op,const char*) \
1249  DECL_ASN_OP_T(op,const sc_fxval&) \
1250  DECL_ASN_OP_T(op,const sc_fxval_fast&) \
1251  DECL_ASN_OP_T(op,const sc_fxnum&) \
1252  DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
1253  DECL_ASN_OP_OTHER(op)
1254 
1255  DECL_ASN_OP(=)
1256 
1257  DECL_ASN_OP(*=)
1258  DECL_ASN_OP(/=)
1259  DECL_ASN_OP(+=)
1260  DECL_ASN_OP(-=)
1261 
1262  DECL_ASN_OP_T(<<=,int)
1263  DECL_ASN_OP_T(>>=,int)
1264 
1265 #undef DECL_ASN_OP_T
1266 #undef DECL_ASN_OP_OTHER
1267 #undef DECL_ASN_OP
1268 
1269 
1270  // auto-increment and auto-decrement
1271 
1272  const sc_fxval_fast operator ++ ( int );
1273  const sc_fxval_fast operator -- ( int );
1274 
1275  sc_fxnum_fast& operator ++ ();
1276  sc_fxnum_fast& operator -- ();
1277 
1278 
1279  // bit selection
1280 
1281  const sc_fxnum_fast_bitref operator [] ( int ) const;
1282  sc_fxnum_fast_bitref operator [] ( int );
1283 
1284  const sc_fxnum_fast_bitref bit( int ) const;
1285  sc_fxnum_fast_bitref bit( int );
1286 
1287 
1288  // part selection
1289 
1290  const sc_fxnum_fast_subref operator () ( int, int ) const;
1291  sc_fxnum_fast_subref operator () ( int, int );
1292 
1293  const sc_fxnum_fast_subref range( int, int ) const;
1294  sc_fxnum_fast_subref range( int, int );
1295 
1296 
1297  const sc_fxnum_fast_subref operator () () const;
1298  sc_fxnum_fast_subref operator () ();
1299 
1300  const sc_fxnum_fast_subref range() const;
1301  sc_fxnum_fast_subref range();
1302 
1303 
1304  // implicit conversion
1305 
1306  operator double() const; // necessary evil!
1307 
1308 
1309  // explicit conversion to primitive types
1310 
1311  short to_short() const;
1312  unsigned short to_ushort() const;
1313  int to_int() const;
1314  unsigned int to_uint() const;
1315  long to_long() const;
1316  unsigned long to_ulong() const;
1317  int64 to_int64() const;
1318  uint64 to_uint64() const;
1319  float to_float() const;
1320  double to_double() const;
1321 
1322 
1323  // explicit conversion to character string
1324 
1325  const std::string to_string() const;
1326  const std::string to_string( sc_numrep ) const;
1327  const std::string to_string( sc_numrep, bool ) const;
1328  const std::string to_string( sc_fmt ) const;
1329  const std::string to_string( sc_numrep, sc_fmt ) const;
1330  const std::string to_string( sc_numrep, bool, sc_fmt ) const;
1331 
1332  const std::string to_dec() const;
1333  const std::string to_bin() const;
1334  const std::string to_oct() const;
1335  const std::string to_hex() const;
1336 
1337 
1338  // query value
1339 
1340  bool is_neg() const;
1341  bool is_zero() const;
1342 
1343  // internal use only;
1344  bool is_normal() const;
1345 
1346  bool quantization_flag() const;
1347  bool overflow_flag() const;
1348 
1349  const sc_fxval_fast value() const;
1350 
1351 
1352  // query parameters
1353 
1354  int wl() const;
1355  int iwl() const;
1356  sc_q_mode q_mode() const;
1357  sc_o_mode o_mode() const;
1358  int n_bits() const;
1359 
1360  const sc_fxtype_params& type_params() const;
1361 
1362  const sc_fxcast_switch& cast_switch() const;
1363 
1364 
1365  // print or dump content
1366 
1367  void print( ::std::ostream& = ::std::cout ) const;
1368  void scan( ::std::istream& = ::std::cin );
1369  void dump( ::std::ostream& = ::std::cout ) const;
1370 
1371 
1372  // internal use only;
1373  void observer_read() const;
1374 
1375 
1376  // internal use only;
1377  bool get_bit( int ) const;
1378 
1379 protected:
1380 
1381  bool set_bit( int, bool );
1382 
1383 
1384  bool get_slice( int, int, sc_bv_base& ) const;
1385  bool set_slice( int, int, const sc_bv_base& );
1386 
1387 
1388  sc_fxnum_fast_observer* lock_observer() const;
1389  void unlock_observer( sc_fxnum_fast_observer* ) const;
1390 
1391 private:
1392 
1393  double m_val;
1394 
1395  scfx_params m_params;
1396  bool m_q_flag;
1397  bool m_o_flag;
1398 
1399  mutable sc_fxnum_fast_observer* m_observer;
1400 
1401 private:
1402 
1403  // disabled
1404  sc_fxnum_fast();
1405  sc_fxnum_fast( const sc_fxnum_fast& );
1406 };
1407 
1408 
1409 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
1410 
1417 // constructor
1418 
1419 inline
1420 sc_fxnum_bitref::sc_fxnum_bitref( sc_fxnum& num_, int idx_ )
1421  : m_num( num_ ), m_idx( idx_ )
1422 {}
1423 
1424 
1425 // copy constructor
1426 
1427 inline
1428 sc_fxnum_bitref::sc_fxnum_bitref( const sc_fxnum_bitref& a )
1429  : m_num( a.m_num ), m_idx( a.m_idx )
1430 {}
1431 
1432 
1433 // assignment operators
1434 
1435 inline
1437 sc_fxnum_bitref::operator = ( const sc_fxnum_bitref& a )
1438 {
1439  if( &a != this )
1440  {
1441  SC_FXNUM_OBSERVER_READ_( a.m_num )
1442  set( a.get() );
1443  SC_FXNUM_OBSERVER_WRITE_( m_num )
1444  }
1445  return *this;
1446 }
1447 
1448 inline
1450 sc_fxnum_bitref::operator = ( const sc_fxnum_fast_bitref& a )
1451 {
1452  SC_FXNUM_FAST_OBSERVER_READ_( a.m_num )
1453  set( a.get() );
1454  SC_FXNUM_OBSERVER_WRITE_( m_num )
1455  return *this;
1456 }
1457 
1458 inline
1460 sc_fxnum_bitref::operator = ( const sc_bit& a )
1461 {
1462  set( static_cast<bool>( a ) );
1463  SC_FXNUM_OBSERVER_WRITE_( m_num )
1464  return *this;
1465 }
1466 
1467 inline
1469 sc_fxnum_bitref::operator = ( bool a )
1470 {
1471  set( a );
1472  SC_FXNUM_OBSERVER_WRITE_( m_num )
1473  return *this;
1474 }
1475 
1476 
1477 inline
1480 {
1481  SC_FXNUM_OBSERVER_READ_( m_num )
1482  SC_FXNUM_OBSERVER_READ_( b.m_num )
1483  set( get() && b.get() );
1484  SC_FXNUM_OBSERVER_WRITE_( m_num )
1485  return *this;
1486 }
1487 
1488 inline
1491 {
1492  SC_FXNUM_OBSERVER_READ_( m_num )
1493  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1494  set( get() && b.get() );
1495  SC_FXNUM_OBSERVER_WRITE_( m_num )
1496  return *this;
1497 }
1498 
1499 inline
1502 {
1503  SC_FXNUM_OBSERVER_READ_( m_num )
1504  set( get() && static_cast<bool>( b ) );
1505  SC_FXNUM_OBSERVER_WRITE_( m_num )
1506  return *this;
1507 }
1508 
1509 inline
1512 {
1513  SC_FXNUM_OBSERVER_READ_( m_num )
1514  set( get() && b );
1515  SC_FXNUM_OBSERVER_WRITE_( m_num )
1516  return *this;
1517 }
1518 
1519 
1520 inline
1523 {
1524  SC_FXNUM_OBSERVER_READ_( m_num )
1525  SC_FXNUM_OBSERVER_READ_( b.m_num )
1526  set( get() || b.get() );
1527  SC_FXNUM_OBSERVER_WRITE_( m_num )
1528  return *this;
1529 }
1530 
1531 inline
1534 {
1535  SC_FXNUM_OBSERVER_READ_( m_num )
1536  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1537  set( get() || b.get() );
1538  SC_FXNUM_OBSERVER_WRITE_( m_num )
1539  return *this;
1540 }
1541 
1542 inline
1545 {
1546  SC_FXNUM_OBSERVER_READ_( m_num )
1547  set( get() || static_cast<bool>( b ) );
1548  SC_FXNUM_OBSERVER_WRITE_( m_num )
1549  return *this;
1550 }
1551 
1552 inline
1555 {
1556  SC_FXNUM_OBSERVER_READ_( m_num )
1557  set( get() || b );
1558  SC_FXNUM_OBSERVER_WRITE_( m_num )
1559  return *this;
1560 }
1561 
1562 
1563 inline
1566 {
1567  SC_FXNUM_OBSERVER_READ_( m_num )
1568  SC_FXNUM_OBSERVER_READ_( b.m_num )
1569  set( get() != b.get() );
1570  SC_FXNUM_OBSERVER_WRITE_( m_num )
1571  return *this;
1572 }
1573 
1574 inline
1577 {
1578  SC_FXNUM_OBSERVER_READ_( m_num )
1579  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1580  set( get() != b.get() );
1581  SC_FXNUM_OBSERVER_WRITE_( m_num )
1582  return *this;
1583 }
1584 
1585 inline
1588 {
1589  SC_FXNUM_OBSERVER_READ_( m_num )
1590  set( get() != static_cast<bool>( b ) );
1591  SC_FXNUM_OBSERVER_WRITE_( m_num )
1592  return *this;
1593 }
1594 
1595 inline
1598 {
1599  SC_FXNUM_OBSERVER_READ_( m_num )
1600  set( get() != b );
1601  SC_FXNUM_OBSERVER_WRITE_( m_num )
1602  return *this;
1603 }
1604 
1605 
1606 // implicit conversion
1607 
1608 inline
1609 sc_fxnum_bitref::operator bool() const
1610 {
1611  SC_FXNUM_OBSERVER_READ_( m_num )
1612  return get();
1613 }
1614 
1615 
1616 inline
1617 ::std::ostream&
1618 operator << ( ::std::ostream& os, const sc_fxnum_bitref& a )
1619 {
1620  a.print( os );
1621  return os;
1622 }
1623 
1624 inline
1625 ::std::istream&
1626 operator >> ( ::std::istream& is, sc_fxnum_bitref& a )
1627 {
1628  a.scan( is );
1629  return is;
1630 }
1631 
1632 
1639 // constructor
1640 
1641 inline
1642 sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( sc_fxnum_fast& num_, int idx_ )
1643  : m_num( num_ ), m_idx( idx_ )
1644 {}
1645 
1646 
1647 // copy constructor
1648 
1649 inline
1650 sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( const sc_fxnum_fast_bitref& a )
1651  : m_num( a.m_num ), m_idx( a.m_idx )
1652 {}
1653 
1654 
1655 // assignment operators
1656 
1657 inline
1659 sc_fxnum_fast_bitref::operator = ( const sc_fxnum_bitref& a )
1660 {
1661  SC_FXNUM_OBSERVER_READ_( a.m_num )
1662  set( a.get() );
1664  return *this;
1665 }
1666 
1667 inline
1669 sc_fxnum_fast_bitref::operator = ( const sc_fxnum_fast_bitref& a )
1670 {
1671  if( &a != this )
1672  {
1673  SC_FXNUM_FAST_OBSERVER_READ_( a.m_num )
1674  set( a.get() );
1676  }
1677  return *this;
1678 }
1679 
1680 inline
1682 sc_fxnum_fast_bitref::operator = ( const sc_bit& a )
1683 {
1684  set( static_cast<bool>( a ) );
1686  return *this;
1687 }
1688 
1689 inline
1691 sc_fxnum_fast_bitref::operator = ( bool a )
1692 {
1693  set( a );
1695  return *this;
1696 }
1697 
1698 
1699 inline
1702 {
1704  SC_FXNUM_OBSERVER_READ_( b.m_num )
1705  set( get() && b.get() );
1707  return *this;
1708 }
1709 
1710 inline
1713 {
1715  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1716  set( get() && b.get() );
1718  return *this;
1719 }
1720 
1721 inline
1724 {
1726  set( get() && static_cast<bool>( b ) );
1728  return *this;
1729 }
1730 
1731 inline
1734 {
1736  set( get() && b );
1738  return *this;
1739 }
1740 
1741 
1742 inline
1745 {
1747  SC_FXNUM_OBSERVER_READ_( b.m_num )
1748  set( get() || b.get() );
1750  return *this;
1751 }
1752 
1753 inline
1756 {
1758  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1759  set( get() || b.get() );
1761  return *this;
1762 }
1763 
1764 inline
1767 {
1769  set( get() || static_cast<bool>( b ) );
1771  return *this;
1772 }
1773 
1774 inline
1777 {
1779  set( get() || b );
1781  return *this;
1782 }
1783 
1784 
1785 inline
1788 {
1790  SC_FXNUM_OBSERVER_READ_( b.m_num )
1791  set( get() != b.get() );
1793  return *this;
1794 }
1795 
1796 inline
1799 {
1801  SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
1802  set( get() != b.get() );
1804  return *this;
1805 }
1806 
1807 inline
1810 {
1812  set( get() != static_cast<bool>( b ) );
1814  return *this;
1815 }
1816 
1817 inline
1820 {
1822  set( get() != b );
1824  return *this;
1825 }
1826 
1827 
1828 // implicit conversion
1829 
1830 inline
1831 sc_fxnum_fast_bitref::operator bool() const
1832 {
1834  return get();
1835 }
1836 
1837 
1838 inline
1839 ::std::ostream&
1840 operator << ( ::std::ostream& os, const sc_fxnum_fast_bitref& a )
1841 {
1842  a.print( os );
1843  return os;
1844 }
1845 
1846 inline
1847 ::std::istream&
1848 operator >> ( ::std::istream& is, sc_fxnum_fast_bitref& a )
1849 {
1850  a.scan( is );
1851  return is;
1852 }
1853 
1854 
1862 // constructor
1863 
1864 inline
1865 sc_fxnum_subref::sc_fxnum_subref( sc_fxnum& num_, int from_, int to_ )
1866  : m_num( num_ ), m_from( from_ ), m_to( to_ ),
1867  m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -
1868  sc_min( m_from, m_to ) + 1 ) )
1869 {}
1870 
1871 
1872 // copy constructor
1873 
1874 inline
1875 sc_fxnum_subref::sc_fxnum_subref( const sc_fxnum_subref& a )
1876  : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),
1877  m_bv( *new sc_bv_base( a.m_bv ) )
1878 {}
1879 
1880 
1881 // destructor
1882 
1883 inline
1885 {
1886  delete &m_bv;
1887 }
1888 
1889 
1890 // assignment operators
1891 
1892 inline
1894 sc_fxnum_subref::operator = ( const sc_fxnum_subref& a )
1895 {
1896  if( &a != this )
1897  {
1898  m_bv = static_cast<sc_bv_base>( a );
1899  set();
1900  SC_FXNUM_OBSERVER_WRITE_( m_num )
1901  }
1902  return *this;
1903 }
1904 
1905 inline
1907 sc_fxnum_subref::operator = ( const sc_fxnum_fast_subref& a )
1908 {
1909  m_bv = static_cast<sc_bv_base>( a );
1910  set();
1911  SC_FXNUM_OBSERVER_WRITE_( m_num )
1912  return *this;
1913 }
1914 
1915 #define DEFN_ASN_OP_T(tp) \
1916 inline \
1917 sc_fxnum_subref& \
1918 sc_fxnum_subref::operator = ( tp a ) \
1919 { \
1920  m_bv = a; \
1921  set(); \
1922  SC_FXNUM_OBSERVER_WRITE_( m_num ) \
1923  return *this; \
1924 }
1925 
1926 DEFN_ASN_OP_T(const sc_bv_base&)
1927 DEFN_ASN_OP_T(const sc_lv_base&)
1928 DEFN_ASN_OP_T(const char*)
1929 DEFN_ASN_OP_T(const bool*)
1930 DEFN_ASN_OP_T(const sc_signed&)
1931 DEFN_ASN_OP_T(const sc_unsigned&)
1932 DEFN_ASN_OP_T(const sc_int_base&)
1936 DEFN_ASN_OP_T(int)
1937 DEFN_ASN_OP_T(unsigned int)
1938 DEFN_ASN_OP_T(long)
1939 DEFN_ASN_OP_T(unsigned long)
1940 DEFN_ASN_OP_T(char)
1941 
1942 #undef DEFN_ASN_OP_T
1943 
1944 
1945 #define DEFN_ASN_OP_T(op,tp) \
1946 inline \
1947 sc_fxnum_subref& \
1948 sc_fxnum_subref::operator op ## = ( tp a ) \
1949 { \
1950  SC_FXNUM_OBSERVER_READ_( m_num ) \
1951  get(); \
1952  m_bv = m_bv op a; \
1953  set(); \
1954  SC_FXNUM_OBSERVER_WRITE_( m_num ) \
1955  return *this; \
1956 }
1957 
1958 #define DEFN_ASN_OP(op) \
1959 inline \
1960 sc_fxnum_subref& \
1961 sc_fxnum_subref::operator op ## = ( const sc_fxnum_subref& a ) \
1962 { \
1963  SC_FXNUM_OBSERVER_READ_( m_num ) \
1964  get(); \
1965  m_bv = m_bv op static_cast<sc_bv_base>( a ); \
1966  set(); \
1967  SC_FXNUM_OBSERVER_WRITE_( m_num ) \
1968  return *this; \
1969 } \
1970  \
1971 inline \
1972 sc_fxnum_subref& \
1973 sc_fxnum_subref::operator op ## = ( const sc_fxnum_fast_subref& a ) \
1974 { \
1975  SC_FXNUM_OBSERVER_READ_( m_num ) \
1976  get(); \
1977  m_bv = m_bv op static_cast<sc_bv_base>( a ); \
1978  set(); \
1979  SC_FXNUM_OBSERVER_WRITE_( m_num ) \
1980  return *this; \
1981 } \
1982  \
1983 DEFN_ASN_OP_T(op,const sc_bv_base&) \
1984 DEFN_ASN_OP_T(op,const sc_lv_base&)
1985 
1986 DEFN_ASN_OP(&)
1987 DEFN_ASN_OP(|)
1988 DEFN_ASN_OP(^)
1989 
1990 #undef DEFN_ASN_OP_T
1991 #undef DEFN_ASN_OP
1992 
1993 
1994 // relational operators
1995 
1996 #define DEFN_REL_OP_T(op,tp) \
1997 inline \
1998 bool \
1999 operator op ( const sc_fxnum_subref& a, tp b ) \
2000 { \
2001  return ( static_cast<sc_bv_base>( a ) op b ); \
2002 } \
2003  \
2004 inline \
2005 bool \
2006 operator op ( tp a, const sc_fxnum_subref& b ) \
2007 { \
2008  return ( static_cast<sc_bv_base>( b ) op a ); \
2009 }
2010 
2011 #define DEFN_REL_OP(op) \
2012 inline \
2013 bool \
2014 operator op ( const sc_fxnum_subref& a, const sc_fxnum_subref& b ) \
2015 { \
2016  return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) ); \
2017 } \
2018  \
2019 inline \
2020 bool \
2021 operator op ( const sc_fxnum_subref& a, const sc_fxnum_fast_subref& b ) \
2022 { \
2023  return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) ); \
2024 } \
2025  \
2026 DEFN_REL_OP_T(op,const sc_bv_base&) \
2027 DEFN_REL_OP_T(op,const sc_lv_base&) \
2028 DEFN_REL_OP_T(op,const char*) \
2029 DEFN_REL_OP_T(op,const bool*) \
2030 DEFN_REL_OP_T(op,const sc_signed&) \
2031 DEFN_REL_OP_T(op,const sc_unsigned&) \
2032 DEFN_REL_OP_T(op,int) \
2033 DEFN_REL_OP_T(op,unsigned int) \
2034 DEFN_REL_OP_T(op,long) \
2035 DEFN_REL_OP_T(op,unsigned long)
2036 
2037 DEFN_REL_OP(==)
2038 DEFN_REL_OP(!=)
2039 
2040 #undef DEFN_REL_OP_T
2041 #undef DEFN_REL_OP
2042 
2043 
2044 // reduce functions
2045 
2046 #define DEFN_RED_FNC(fnc) \
2047 inline \
2048 bool \
2049 sc_fxnum_subref::fnc() const \
2050 { \
2051  SC_FXNUM_OBSERVER_READ_( m_num ) \
2052  get(); \
2053  return static_cast<bool>( m_bv.fnc() ); \
2054 }
2055 
2062 
2063 #undef DEFN_RED_FNC
2064 
2065 
2066 // query parameter
2067 
2068 inline
2069 int
2071 {
2072  return m_bv.length();
2073 }
2074 
2075 
2076 // explicit conversions
2077 
2078 inline
2079 int
2081 {
2082  SC_FXNUM_OBSERVER_READ_( m_num )
2083  get();
2084  return m_bv.to_int();
2085 }
2086 
2087 inline
2088 int64
2090 {
2091  SC_FXNUM_OBSERVER_READ_( m_num )
2092  get();
2093  return m_bv.to_int64();
2094 }
2095 
2096 inline
2097 unsigned int
2099 {
2100  SC_FXNUM_OBSERVER_READ_( m_num )
2101  get();
2102  return m_bv.to_uint();
2103 }
2104 
2105 inline
2106 uint64
2108 {
2109  SC_FXNUM_OBSERVER_READ_( m_num )
2110  get();
2111  return m_bv.to_uint64();
2112 }
2113 
2114 inline
2115 long
2117 {
2118  SC_FXNUM_OBSERVER_READ_( m_num )
2119  get();
2120  return m_bv.to_long();
2121 }
2122 
2123 inline
2124 unsigned long
2126 {
2127  SC_FXNUM_OBSERVER_READ_( m_num )
2128  get();
2129  return m_bv.to_ulong();
2130 }
2131 
2132 
2133 #ifdef SC_DT_DEPRECATED
2134 
2135 inline
2136 int
2137 sc_fxnum_subref::to_signed() const
2138 {
2139  return to_int();
2140 }
2141 
2142 inline
2143 unsigned int
2144 sc_fxnum_subref::to_unsigned() const
2145 {
2146  return to_uint();
2147 }
2148 
2149 #endif
2150 
2151 
2152 inline
2153 const std::string
2155 {
2156  get();
2157  return m_bv.to_string();
2158 }
2159 
2160 inline
2161 const std::string
2163 {
2164  get();
2165  return m_bv.to_string( numrep );
2166 }
2167 
2168 inline
2169 const std::string
2170 sc_fxnum_subref::to_string( sc_numrep numrep, bool w_prefix ) const
2171 {
2172  get();
2173  return m_bv.to_string( numrep, w_prefix );
2174 }
2175 
2176 
2177 // implicit conversion
2178 
2179 inline
2180 sc_fxnum_subref::operator sc_bv_base () const
2181 {
2182  SC_FXNUM_OBSERVER_READ_( m_num )
2183  get();
2184  return m_bv;
2185 }
2186 
2187 
2188 inline
2189 ::std::ostream&
2190 operator << ( ::std::ostream& os, const sc_fxnum_subref& a )
2191 {
2192  a.print( os );
2193  return os;
2194 }
2195 
2196 inline
2197 ::std::istream&
2198 operator >> ( ::std::istream& is, sc_fxnum_subref& a )
2199 {
2200  a.scan( is );
2201  return is;
2202 }
2203 
2204 
2212 // constructor
2213 
2214 inline
2215 sc_fxnum_fast_subref::sc_fxnum_fast_subref( sc_fxnum_fast& num_,
2216  int from_, int to_ )
2217  : m_num( num_ ), m_from( from_ ), m_to( to_ ),
2218  m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -
2219  sc_min( m_from, m_to ) + 1 ) )
2220 {}
2221 
2222 
2223 // copy constructor
2224 
2225 inline
2226 sc_fxnum_fast_subref::sc_fxnum_fast_subref( const sc_fxnum_fast_subref& a )
2227  : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),
2228  m_bv( *new sc_bv_base( a.m_bv ) )
2229 {}
2230 
2231 
2232 // destructor
2233 
2234 inline
2236 {
2237  delete &m_bv;
2238 }
2239 
2240 
2241 // assignment operators
2242 
2243 inline
2245 sc_fxnum_fast_subref::operator = ( const sc_fxnum_subref& a )
2246 {
2247  m_bv = static_cast<sc_bv_base>( a );
2248  set();
2250  return *this;
2251 }
2252 
2253 inline
2255 sc_fxnum_fast_subref::operator = ( const sc_fxnum_fast_subref& a )
2256 {
2257  if( &a != this )
2258  {
2259  m_bv = static_cast<sc_bv_base>( a );
2260  set();
2262  }
2263  return *this;
2264 }
2265 
2266 #define DEFN_ASN_OP_T(tp) \
2267 inline \
2268 sc_fxnum_fast_subref& \
2269 sc_fxnum_fast_subref::operator = ( tp a ) \
2270 { \
2271  m_bv = a; \
2272  set(); \
2273  SC_FXNUM_FAST_OBSERVER_WRITE_( m_num ) \
2274  return *this; \
2275 }
2276 
2277 DEFN_ASN_OP_T(const sc_bv_base&)
2278 DEFN_ASN_OP_T(const sc_lv_base&)
2279 DEFN_ASN_OP_T(const char*)
2280 DEFN_ASN_OP_T(const bool*)
2281 DEFN_ASN_OP_T(const sc_signed&)
2282 DEFN_ASN_OP_T(const sc_unsigned&)
2283 DEFN_ASN_OP_T(const sc_int_base&)
2287 DEFN_ASN_OP_T(int)
2288 DEFN_ASN_OP_T(unsigned int)
2289 DEFN_ASN_OP_T(long)
2290 DEFN_ASN_OP_T(unsigned long)
2291 DEFN_ASN_OP_T(char)
2292 
2293 #undef DEFN_ASN_OP_T
2294 
2295 
2296 #define DEFN_ASN_OP_T(op,tp) \
2297 inline \
2298 sc_fxnum_fast_subref& \
2299 sc_fxnum_fast_subref::operator op ## = ( tp a ) \
2300 { \
2301  SC_FXNUM_FAST_OBSERVER_READ_( m_num ) \
2302  get(); \
2303  m_bv = m_bv op a; \
2304  set(); \
2305  SC_FXNUM_FAST_OBSERVER_WRITE_( m_num ) \
2306  return *this; \
2307 }
2308 
2309 #define DEFN_ASN_OP(op) \
2310 inline \
2311 sc_fxnum_fast_subref& \
2312 sc_fxnum_fast_subref::operator op ## = ( const sc_fxnum_subref& a ) \
2313 { \
2314  SC_FXNUM_FAST_OBSERVER_READ_( m_num ) \
2315  get(); \
2316  m_bv = m_bv op static_cast<sc_bv_base>( a ); \
2317  set(); \
2318  SC_FXNUM_FAST_OBSERVER_WRITE_( m_num ) \
2319  return *this; \
2320 } \
2321  \
2322 inline \
2323 sc_fxnum_fast_subref& \
2324 sc_fxnum_fast_subref::operator op ## = ( const sc_fxnum_fast_subref& a ) \
2325 { \
2326  SC_FXNUM_FAST_OBSERVER_READ_( m_num ) \
2327  get(); \
2328  m_bv = m_bv op static_cast<sc_bv_base>( a ); \
2329  set(); \
2330  SC_FXNUM_FAST_OBSERVER_WRITE_( m_num ) \
2331  return *this; \
2332 } \
2333  \
2334 DEFN_ASN_OP_T(op,const sc_bv_base&) \
2335 DEFN_ASN_OP_T(op,const sc_lv_base&)
2336 
2337 DEFN_ASN_OP(&)
2338 DEFN_ASN_OP(|)
2339 DEFN_ASN_OP(^)
2340 
2341 #undef DEFN_ASN_OP_T
2342 #undef DEFN_ASN_OP
2343 
2344 
2345 // relational operators
2346 
2347 #define DEFN_REL_OP_T(op,tp) \
2348 inline \
2349 bool \
2350 operator op ( const sc_fxnum_fast_subref& a, tp b ) \
2351 { \
2352  return ( static_cast<sc_bv_base>( a ) op b ); \
2353 } \
2354  \
2355 inline \
2356 bool \
2357 operator op ( tp a, const sc_fxnum_fast_subref& b ) \
2358 { \
2359  return ( static_cast<sc_bv_base>( b ) op a ); \
2360 }
2361 
2362 #define DEFN_REL_OP(op) \
2363 inline \
2364 bool \
2365 operator op ( const sc_fxnum_fast_subref& a, const sc_fxnum_fast_subref& b ) \
2366 { \
2367  return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) ); \
2368 } \
2369  \
2370 inline \
2371 bool \
2372 operator op ( const sc_fxnum_fast_subref& a, const sc_fxnum_subref& b ) \
2373 { \
2374  return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) ); \
2375 } \
2376  \
2377 DEFN_REL_OP_T(op,const sc_bv_base&) \
2378 DEFN_REL_OP_T(op,const sc_lv_base&) \
2379 DEFN_REL_OP_T(op,const char*) \
2380 DEFN_REL_OP_T(op,const bool*) \
2381 DEFN_REL_OP_T(op,const sc_signed&) \
2382 DEFN_REL_OP_T(op,const sc_unsigned&) \
2383 DEFN_REL_OP_T(op,int) \
2384 DEFN_REL_OP_T(op,unsigned int) \
2385 DEFN_REL_OP_T(op,long) \
2386 DEFN_REL_OP_T(op,unsigned long)
2387 
2388 DEFN_REL_OP(==)
2389 DEFN_REL_OP(!=)
2390 
2391 #undef DEFN_REL_OP_T
2392 #undef DEFN_REL_OP
2393 
2394 
2395 // reduce functions
2396 
2397 #define DEFN_RED_FNC(fnc) \
2398 inline \
2399 bool \
2400 sc_fxnum_fast_subref::fnc() const \
2401 { \
2402  SC_FXNUM_FAST_OBSERVER_READ_( m_num ) \
2403  get(); \
2404  return static_cast<bool>( m_bv.fnc() ); \
2405 }
2406 
2413 
2414 #undef DEFN_RED_FNC
2415 
2416 
2417 // query parameter
2418 
2419 inline
2420 int
2422 {
2423  return m_bv.length();
2424 }
2425 
2426 
2427 // explicit conversions
2428 
2429 inline
2430 int
2432 {
2434  get();
2435  return m_bv.to_int();
2436 }
2437 
2438 inline
2439 int64
2441 {
2443  get();
2444  return m_bv.to_int64();
2445 }
2446 
2447 inline
2448 unsigned int
2450 {
2452  get();
2453  return m_bv.to_uint();
2454 }
2455 
2456 inline
2457 uint64
2459 {
2461  get();
2462  return m_bv.to_uint64();
2463 }
2464 
2465 inline
2466 long
2468 {
2470  get();
2471  return m_bv.to_long();
2472 }
2473 
2474 inline
2475 unsigned long
2477 {
2479  get();
2480  return m_bv.to_ulong();
2481 }
2482 
2483 
2484 #ifdef SC_DT_DEPRECATED
2485 
2486 inline
2487 int
2488 sc_fxnum_fast_subref::to_signed() const
2489 {
2490  return to_int();
2491 }
2492 
2493 inline
2494 unsigned int
2495 sc_fxnum_fast_subref::to_unsigned() const
2496 {
2497  return to_uint();
2498 }
2499 
2500 #endif
2501 
2502 
2503 inline
2504 const std::string
2506 {
2507  get();
2508  return m_bv.to_string();
2509 }
2510 
2511 inline
2512 const std::string
2514 {
2515  get();
2516  return m_bv.to_string( numrep );
2517 }
2518 
2519 inline
2520 const std::string
2521 sc_fxnum_fast_subref::to_string( sc_numrep numrep, bool w_prefix ) const
2522 {
2523  get();
2524  return m_bv.to_string( numrep, w_prefix );
2525 }
2526 
2527 
2528 // implicit conversion
2529 
2530 inline
2531 sc_fxnum_fast_subref::operator sc_bv_base () const
2532 {
2534  get();
2535  return m_bv;
2536 }
2537 
2538 
2539 inline
2540 ::std::ostream&
2541 operator << ( ::std::ostream& os, const sc_fxnum_fast_subref& a )
2542 {
2543  a.print( os );
2544  return os;
2545 }
2546 
2547 inline
2548 ::std::istream&
2549 operator >> ( ::std::istream& is, sc_fxnum_fast_subref& a )
2550 {
2551  a.scan( is );
2552  return is;
2553 }
2554 
2555 
2562 inline
2565 {
2566  return m_observer;
2567 }
2568 
2569 
2570 inline
2571 void
2573 {
2574  SC_ERROR_IF_( ! m_rep->is_normal(), sc_core::SC_ID_INVALID_FX_VALUE_ );
2575 
2576  if( m_params.cast_switch() == SC_ON )
2577  m_rep->cast( m_params, m_q_flag, m_o_flag );
2578 }
2579 
2580 
2581 // constructors
2582 
2583 inline
2584 sc_fxnum::sc_fxnum( const sc_fxtype_params& type_params_,
2585  sc_enc enc_,
2586  const sc_fxcast_switch& cast_sw,
2587  sc_fxnum_observer* observer_ )
2588 : m_rep( new scfx_rep ),
2589  m_params( type_params_, enc_, cast_sw ),
2590  m_q_flag( false ),
2591  m_o_flag( false ),
2592  m_observer( observer_ )
2593 {
2596 }
2597 
2598 #define DEFN_CTOR_T(tp,arg) \
2599 inline \
2600 sc_fxnum::sc_fxnum( tp a, \
2601  const sc_fxtype_params& type_params_, \
2602  sc_enc enc_, \
2603  const sc_fxcast_switch& cast_sw, \
2604  sc_fxnum_observer* observer_ ) \
2605 : m_rep( new scfx_rep( arg ) ), \
2606  m_params( type_params_, enc_, cast_sw ), \
2607  m_q_flag( false ), \
2608  m_o_flag( false ), \
2609  m_observer( observer_ ) \
2610 { \
2611  SC_FXNUM_OBSERVER_DEFAULT_ \
2612  cast(); \
2613  SC_FXNUM_OBSERVER_CONSTRUCT_( *this ) \
2614  SC_FXNUM_OBSERVER_WRITE_( *this ) \
2615 }
2616 
2617 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a)
2618 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,*a.m_rep)
2619 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
2620 #define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp,a.value())
2621 
2622 DEFN_CTOR_T_A(int)
2623 DEFN_CTOR_T_A(unsigned int)
2624 DEFN_CTOR_T_A(long)
2625 DEFN_CTOR_T_A(unsigned long)
2626 DEFN_CTOR_T_A(float)
2627 DEFN_CTOR_T_A(double)
2628 DEFN_CTOR_T_A(const char*)
2629 DEFN_CTOR_T_B(const sc_fxval&)
2630 DEFN_CTOR_T_C(const sc_fxval_fast&)
2631 DEFN_CTOR_T_B(const sc_fxnum&)
2632 DEFN_CTOR_T_C(const sc_fxnum_fast&)
2633 #ifndef SC_FX_EXCLUDE_OTHER
2636 DEFN_CTOR_T_D(const sc_int_base&)
2637 DEFN_CTOR_T_D(const sc_uint_base&)
2638 DEFN_CTOR_T_A(const sc_signed&)
2639 DEFN_CTOR_T_A(const sc_unsigned&)
2640 #endif
2641 
2642 #undef DEFN_CTOR_T
2643 #undef DEFN_CTOR_T_A
2644 #undef DEFN_CTOR_T_B
2645 #undef DEFN_CTOR_T_C
2646 #undef DEFN_CTOR_T_D
2647 
2648 
2649 inline
2651 {
2653  delete m_rep;
2654 }
2655 
2656 
2657 // internal use only;
2658 inline
2659 const scfx_rep*
2661 {
2662  SC_FXNUM_OBSERVER_READ_( *this )
2663  return m_rep;
2664 }
2665 
2666 
2667 // unary operators
2668 
2669 inline
2670 const sc_fxval
2672 {
2673  SC_FXNUM_OBSERVER_READ_( *this )
2674  return sc_fxval( sc_dt::neg_scfx_rep( *m_rep ) );
2675 }
2676 
2677 inline
2678 const sc_fxval
2680 {
2681  SC_FXNUM_OBSERVER_READ_( *this )
2682  return sc_fxval( new scfx_rep( *m_rep ) );
2683 }
2684 
2685 
2686 // unary functions
2687 
2688 inline
2689 void
2690 neg( sc_fxval& c, const sc_fxnum& a )
2691 {
2693  c.set_rep( sc_dt::neg_scfx_rep( *a.m_rep ) );
2694 }
2695 
2696 inline
2697 void
2698 neg( sc_fxnum& c, const sc_fxnum& a )
2699 {
2701  delete c.m_rep;
2702  c.m_rep = sc_dt::neg_scfx_rep( *a.m_rep );
2703  c.cast();
2705 }
2706 
2707 
2708 // binary operators
2709 
2710 #define DEFN_BIN_OP_T(op,fnc,tp) \
2711 inline \
2712 const sc_fxval \
2713 operator op ( const sc_fxnum& a, tp b ) \
2714 { \
2715  SC_FXNUM_OBSERVER_READ_( a ) \
2716  sc_fxval tmp( b ); \
2717  return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() ) ); \
2718 } \
2719  \
2720 inline \
2721 const sc_fxval \
2722 operator op ( tp a, const sc_fxnum& b ) \
2723 { \
2724  SC_FXNUM_OBSERVER_READ_( b ) \
2725  sc_fxval tmp( a ); \
2726  return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep ) ); \
2727 }
2728 
2729 #ifndef SC_FX_EXCLUDE_OTHER
2730 #define DEFN_BIN_OP_OTHER(op,fnc) \
2731 DEFN_BIN_OP_T(op,fnc,int64) \
2732 DEFN_BIN_OP_T(op,fnc,uint64) \
2733 DEFN_BIN_OP_T(op,fnc,const sc_int_base&) \
2734 DEFN_BIN_OP_T(op,fnc,const sc_uint_base&) \
2735 DEFN_BIN_OP_T(op,fnc,const sc_signed&) \
2736 DEFN_BIN_OP_T(op,fnc,const sc_unsigned&)
2737 #else
2738 #define DEFN_BIN_OP_OTHER(op,fnc)
2739 #endif
2740 
2741 #define DEFN_BIN_OP(op,fnc) \
2742 inline \
2743 const sc_fxval \
2744 operator op ( const sc_fxnum& a, const sc_fxnum& b ) \
2745 { \
2746  SC_FXNUM_OBSERVER_READ_( a ) \
2747  SC_FXNUM_OBSERVER_READ_( b ) \
2748  return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \
2749 } \
2750  \
2751 inline \
2752 const sc_fxval \
2753 operator op ( const sc_fxnum& a, const sc_fxval& b ) \
2754 { \
2755  SC_FXNUM_OBSERVER_READ_( a ) \
2756  return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() ) ); \
2757 } \
2758  \
2759 inline \
2760 const sc_fxval \
2761 operator op ( const sc_fxval& a, const sc_fxnum& b ) \
2762 { \
2763  SC_FXNUM_OBSERVER_READ_( b ) \
2764  return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep ) ); \
2765 } \
2766  \
2767 DEFN_BIN_OP_T(op,fnc,int) \
2768 DEFN_BIN_OP_T(op,fnc,unsigned int) \
2769 DEFN_BIN_OP_T(op,fnc,long) \
2770 DEFN_BIN_OP_T(op,fnc,unsigned long) \
2771 DEFN_BIN_OP_T(op,fnc,float) \
2772 DEFN_BIN_OP_T(op,fnc,double) \
2773 DEFN_BIN_OP_T(op,fnc,const char*) \
2774 DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&) \
2775 DEFN_BIN_OP_T(op,fnc,const sc_fxnum_fast&) \
2776 DEFN_BIN_OP_OTHER(op,fnc)
2777 
2778 DEFN_BIN_OP(*,mult)
2779 DEFN_BIN_OP(+,add)
2780 DEFN_BIN_OP(-,sub)
2781 // don't use macros
2782 //DEFN_BIN_OP(/,div)
2783 inline
2784 const sc_fxval
2785 operator / ( const sc_fxnum& a, const sc_fxnum& b )
2786 {
2789  return sc_fxval( sc_dt::div_scfx_rep( *a.m_rep, *b.m_rep ) );
2790 }
2791 
2792 inline
2793 const sc_fxval
2794 operator / ( const sc_fxnum& a, const sc_fxval& b )
2795 {
2797  return sc_fxval( sc_dt::div_scfx_rep( *a.m_rep, *b.get_rep() ) );
2798 }
2799 
2800 inline
2801 const sc_fxval
2802 operator / ( const sc_fxval& a, const sc_fxnum& b )
2803 {
2805  return sc_fxval( sc_dt::div_scfx_rep( *a.get_rep(), *b.m_rep ) );
2806 }
2807 
2808 DEFN_BIN_OP_T(/,div,int)
2809 DEFN_BIN_OP_T(/,div,unsigned int)
2810 DEFN_BIN_OP_T(/,div,long)
2811 DEFN_BIN_OP_T(/,div,unsigned long)
2812 DEFN_BIN_OP_T(/,div,float)
2813 DEFN_BIN_OP_T(/,div,double)
2814 DEFN_BIN_OP_T(/,div,const char*)
2817 //DEFN_BIN_OP_OTHER(/,div)
2818 #ifndef SC_FX_EXCLUDE_OTHER
2821 DEFN_BIN_OP_T(/,div,const sc_int_base&)
2822 DEFN_BIN_OP_T(/,div,const sc_uint_base&)
2823 DEFN_BIN_OP_T(/,div,const sc_signed&)
2824 DEFN_BIN_OP_T(/,div,const sc_unsigned&)
2825 #endif
2826 
2827 #undef DEFN_BIN_OP_T
2828 #undef DEFN_BIN_OP_OTHER
2829 #undef DEFN_BIN_OP
2830 
2831 
2832 inline
2833 const sc_fxval
2834 operator << ( const sc_fxnum& a, int b )
2835 {
2837  return sc_fxval( sc_dt::lsh_scfx_rep( *a.m_rep, b ) );
2838 }
2839 
2840 inline
2841 const sc_fxval
2842 operator >> ( const sc_fxnum& a, int b )
2843 {
2845  return sc_fxval( sc_dt::rsh_scfx_rep( *a.m_rep, b ) );
2846 }
2847 
2848 
2849 // binary functions
2850 
2851 #define DEFN_BIN_FNC_T(fnc,tp) \
2852 inline \
2853 void \
2854 fnc ( sc_fxval& c, const sc_fxnum& a, tp b ) \
2855 { \
2856  SC_FXNUM_OBSERVER_READ_( a ) \
2857  sc_fxval tmp( b ); \
2858  c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() ) ); \
2859 } \
2860  \
2861 inline \
2862 void \
2863 fnc ( sc_fxval& c, tp a, const sc_fxnum& b ) \
2864 { \
2865  SC_FXNUM_OBSERVER_READ_( b ) \
2866  sc_fxval tmp( a ); \
2867  c.set_rep( sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep ) ); \
2868 } \
2869  \
2870 inline \
2871 void \
2872 fnc ( sc_fxnum& c, const sc_fxnum& a, tp b ) \
2873 { \
2874  SC_FXNUM_OBSERVER_READ_( a ) \
2875  sc_fxval tmp( b ); \
2876  delete c.m_rep; \
2877  c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() ); \
2878  c.cast(); \
2879  SC_FXNUM_OBSERVER_WRITE_( c ) \
2880 } \
2881  \
2882 inline \
2883 void \
2884 fnc ( sc_fxnum& c, tp a, const sc_fxnum& b ) \
2885 { \
2886  SC_FXNUM_OBSERVER_READ_( b ) \
2887  sc_fxval tmp( a ); \
2888  delete c.m_rep; \
2889  c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep ); \
2890  c.cast(); \
2891  SC_FXNUM_OBSERVER_WRITE_( c ) \
2892 }
2893 
2894 #ifndef SC_FX_EXCLUDE_OTHER
2895 #define DEFN_BIN_FNC_OTHER(fnc) \
2896 DEFN_BIN_FNC_T(fnc,int64) \
2897 DEFN_BIN_FNC_T(fnc,uint64) \
2898 DEFN_BIN_FNC_T(fnc,const sc_int_base&) \
2899 DEFN_BIN_FNC_T(fnc,const sc_uint_base&) \
2900 DEFN_BIN_FNC_T(fnc,const sc_signed&) \
2901 DEFN_BIN_FNC_T(fnc,const sc_unsigned&)
2902 #else
2903 #define DEFN_BIN_FNC_OTHER(fnc)
2904 #endif
2905 
2906 #define DEFN_BIN_FNC(fnc) \
2907 inline \
2908 void \
2909 fnc ( sc_fxval& c, const sc_fxnum& a, const sc_fxnum& b ) \
2910 { \
2911  SC_FXNUM_OBSERVER_READ_( a ) \
2912  SC_FXNUM_OBSERVER_READ_( b ) \
2913  c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \
2914 } \
2915  \
2916 inline \
2917 void \
2918 fnc ( sc_fxnum& c, const sc_fxnum& a, const sc_fxnum& b ) \
2919 { \
2920  SC_FXNUM_OBSERVER_READ_( a ) \
2921  SC_FXNUM_OBSERVER_READ_( b ) \
2922  delete c.m_rep; \
2923  c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ); \
2924  c.cast(); \
2925  SC_FXNUM_OBSERVER_WRITE_( c ) \
2926 } \
2927  \
2928 inline \
2929 void \
2930 fnc ( sc_fxval& c, const sc_fxnum& a, const sc_fxval& b ) \
2931 { \
2932  SC_FXNUM_OBSERVER_READ_( a ) \
2933  c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() ) ); \
2934 } \
2935  \
2936 inline \
2937 void \
2938 fnc ( sc_fxval& c, const sc_fxval& a, const sc_fxnum& b ) \
2939 { \
2940  SC_FXNUM_OBSERVER_READ_( b ) \
2941  c.set_rep( sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep ) ); \
2942 } \
2943  \
2944 inline \
2945 void \
2946 fnc ( sc_fxnum& c, const sc_fxnum& a, const sc_fxval& b ) \
2947 { \
2948  SC_FXNUM_OBSERVER_READ_( a ) \
2949  delete c.m_rep; \
2950  c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() ); \
2951  c.cast(); \
2952  SC_FXNUM_OBSERVER_WRITE_( c ) \
2953 } \
2954  \
2955 inline \
2956 void \
2957 fnc ( sc_fxnum& c, const sc_fxval& a, const sc_fxnum& b ) \
2958 { \
2959  SC_FXNUM_OBSERVER_READ_( b ) \
2960  delete c.m_rep; \
2961  c.m_rep = sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep ); \
2962  c.cast(); \
2963  SC_FXNUM_OBSERVER_WRITE_( c ) \
2964 } \
2965  \
2966 DEFN_BIN_FNC_T(fnc,int) \
2967 DEFN_BIN_FNC_T(fnc,unsigned int) \
2968 DEFN_BIN_FNC_T(fnc,long) \
2969 DEFN_BIN_FNC_T(fnc,unsigned long) \
2970 DEFN_BIN_FNC_T(fnc,float) \
2971 DEFN_BIN_FNC_T(fnc,double) \
2972 DEFN_BIN_FNC_T(fnc,const char*) \
2973 DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&) \
2974 DEFN_BIN_FNC_T(fnc,const sc_fxnum_fast&) \
2975 DEFN_BIN_FNC_OTHER(fnc)
2976 
2977 DEFN_BIN_FNC(mult)
2979 DEFN_BIN_FNC(add)
2980 DEFN_BIN_FNC(sub)
2981 
2982 #undef DEFN_BIN_FNC_T
2983 #undef DEFN_BIN_FNC_OTHER
2984 #undef DEFN_BIN_FNC
2985 
2986 
2987 inline
2988 void
2989 lshift( sc_fxval& c, const sc_fxnum& a, int b )
2990 {
2992  c.set_rep( sc_dt::lsh_scfx_rep( *a.m_rep, b ) );
2993 }
2994 
2995 inline
2996 void
2997 rshift( sc_fxval& c, const sc_fxnum& a, int b )
2998 {
3000  c.set_rep( sc_dt::rsh_scfx_rep( *a.m_rep, b ) );
3001 }
3002 
3003 inline
3004 void
3005 lshift( sc_fxnum& c, const sc_fxnum& a, int b )
3006 {
3008  delete c.m_rep;
3009  c.m_rep = sc_dt::lsh_scfx_rep( *a.m_rep, b );
3010  c.cast();
3012 }
3013 
3014 inline
3015 void
3016 rshift( sc_fxnum& c, const sc_fxnum& a, int b )
3017 {
3019  delete c.m_rep;
3020  c.m_rep = sc_dt::rsh_scfx_rep( *a.m_rep, b );
3021  c.cast();
3023 }
3024 
3025 
3026 // relational (including equality) operators
3027 
3028 #define DEFN_REL_OP_T(op,ret,tp) \
3029 inline \
3030 bool \
3031 operator op ( const sc_fxnum& a, tp b ) \
3032 { \
3033  SC_FXNUM_OBSERVER_READ_( a ) \
3034  sc_fxval tmp( b ); \
3035  int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.get_rep() ); \
3036  return ( ret ); \
3037 } \
3038  \
3039 inline \
3040 bool \
3041 operator op ( tp a, const sc_fxnum& b ) \
3042 { \
3043  SC_FXNUM_OBSERVER_READ_( b ) \
3044  sc_fxval tmp( a ); \
3045  int result = sc_dt::cmp_scfx_rep( *tmp.get_rep(), *b.m_rep ); \
3046  return ( ret ); \
3047 }
3048 
3049 #ifndef SC_FX_EXCLUDE_OTHER
3050 #define DEFN_REL_OP_OTHER(op,ret) \
3051 DEFN_REL_OP_T(op,ret,int64) \
3052 DEFN_REL_OP_T(op,ret,uint64) \
3053 DEFN_REL_OP_T(op,ret,const sc_int_base&) \
3054 DEFN_REL_OP_T(op,ret,const sc_uint_base&) \
3055 DEFN_REL_OP_T(op,ret,const sc_signed&) \
3056 DEFN_REL_OP_T(op,ret,const sc_unsigned&)
3057 #else
3058 #define DEFN_REL_OP_OTHER(op,ret)
3059 #endif
3060 
3061 #define DEFN_REL_OP(op,ret) \
3062 inline \
3063 bool \
3064 operator op ( const sc_fxnum& a, const sc_fxnum& b ) \
3065 { \
3066  SC_FXNUM_OBSERVER_READ_( a ) \
3067  SC_FXNUM_OBSERVER_READ_( b ) \
3068  int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep ); \
3069  return ( ret ); \
3070 } \
3071  \
3072 inline \
3073 bool \
3074 operator op ( const sc_fxnum& a, const sc_fxval& b ) \
3075 { \
3076  SC_FXNUM_OBSERVER_READ_( a ) \
3077  int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.get_rep() ); \
3078  return ( ret ); \
3079 } \
3080  \
3081 inline \
3082 bool \
3083 operator op ( const sc_fxval& a, const sc_fxnum& b ) \
3084 { \
3085  SC_FXNUM_OBSERVER_READ_( b ) \
3086  int result = sc_dt::cmp_scfx_rep( *a.get_rep(), *b.m_rep ); \
3087  return ( ret ); \
3088 } \
3089  \
3090 DEFN_REL_OP_T(op,ret,int) \
3091 DEFN_REL_OP_T(op,ret,unsigned int) \
3092 DEFN_REL_OP_T(op,ret,long) \
3093 DEFN_REL_OP_T(op,ret,unsigned long) \
3094 DEFN_REL_OP_T(op,ret,float) \
3095 DEFN_REL_OP_T(op,ret,double) \
3096 DEFN_REL_OP_T(op,ret,const char*) \
3097 DEFN_REL_OP_T(op,ret,const sc_fxval_fast&) \
3098 DEFN_REL_OP_T(op,ret,const sc_fxnum_fast&) \
3099 DEFN_REL_OP_OTHER(op,ret)
3100 
3101 DEFN_REL_OP(<,result < 0)
3102 DEFN_REL_OP(<=,result <= 0)
3103 DEFN_REL_OP(>,result > 0 && result != 2)
3104 DEFN_REL_OP(>=,result >= 0 && result != 2)
3105 DEFN_REL_OP(==,result == 0)
3106 DEFN_REL_OP(!=,result != 0)
3107 
3108 #undef DEFN_REL_OP_T
3109 #undef DEFN_REL_OP_OTHER
3110 #undef DEFN_REL_OP
3111 
3112 
3113 // assignment operators
3114 
3115 inline
3116 sc_fxnum&
3117 sc_fxnum::operator = ( const sc_fxnum& a )
3118 {
3119  if( &a != this )
3120  {
3122  *m_rep = *a.m_rep;
3123  cast();
3124  SC_FXNUM_OBSERVER_WRITE_( *this )
3125  }
3126  return *this;
3127 }
3128 
3129 inline
3130 sc_fxnum&
3131 sc_fxnum::operator = ( const sc_fxval& a )
3132 {
3133  *m_rep = *a.get_rep();
3134  cast();
3135  SC_FXNUM_OBSERVER_WRITE_( *this )
3136  return *this;
3137 }
3138 
3139 #define DEFN_ASN_OP_T(tp) \
3140 inline \
3141 sc_fxnum& \
3142 sc_fxnum::operator = ( tp a ) \
3143 { \
3144  sc_fxval tmp( a ); \
3145  *m_rep = *tmp.get_rep(); \
3146  cast(); \
3147  SC_FXNUM_OBSERVER_WRITE_( *this ) \
3148  return *this; \
3149 }
3150 
3151 DEFN_ASN_OP_T(int)
3152 DEFN_ASN_OP_T(unsigned int)
3153 DEFN_ASN_OP_T(long)
3154 DEFN_ASN_OP_T(unsigned long)
3155 DEFN_ASN_OP_T(float)
3156 DEFN_ASN_OP_T(double)
3157 DEFN_ASN_OP_T(const char*)
3160 #ifndef SC_FX_EXCLUDE_OTHER
3163 DEFN_ASN_OP_T(const sc_int_base&)
3165 DEFN_ASN_OP_T(const sc_signed&)
3166 DEFN_ASN_OP_T(const sc_unsigned&)
3167 #endif
3168 
3169 #undef DEFN_ASN_OP_T
3170 
3171 
3172 #define DEFN_ASN_OP_T(op,fnc,tp) \
3173 inline \
3174 sc_fxnum& \
3175 sc_fxnum::operator op ( tp b ) \
3176 { \
3177  SC_FXNUM_OBSERVER_READ_( *this ) \
3178  sc_fxval tmp( b ); \
3179  scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.get_rep() ); \
3180  delete m_rep; \
3181  m_rep = new_rep; \
3182  cast(); \
3183  SC_FXNUM_OBSERVER_WRITE_( *this ) \
3184  return *this; \
3185 }
3186 
3187 #ifndef SC_FX_EXCLUDE_OTHER
3188 #define DEFN_ASN_OP_OTHER(op,fnc) \
3189 DEFN_ASN_OP_T(op,fnc,int64) \
3190 DEFN_ASN_OP_T(op,fnc,uint64) \
3191 DEFN_ASN_OP_T(op,fnc,const sc_int_base&) \
3192 DEFN_ASN_OP_T(op,fnc,const sc_uint_base&) \
3193 DEFN_ASN_OP_T(op,fnc,const sc_signed&) \
3194 DEFN_ASN_OP_T(op,fnc,const sc_unsigned&)
3195 #else
3196 #define DEFN_ASN_OP_OTHER(op,fnc)
3197 #endif
3198 
3199 #define DEFN_ASN_OP(op,fnc) \
3200 inline \
3201 sc_fxnum& \
3202 sc_fxnum::operator op ( const sc_fxnum& b ) \
3203 { \
3204  SC_FXNUM_OBSERVER_READ_( *this ) \
3205  SC_FXNUM_OBSERVER_READ_( b ) \
3206  scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep ); \
3207  delete m_rep; \
3208  m_rep = new_rep; \
3209  cast(); \
3210  SC_FXNUM_OBSERVER_WRITE_( *this ) \
3211  return *this; \
3212 } \
3213  \
3214 inline \
3215 sc_fxnum& \
3216 sc_fxnum::operator op ( const sc_fxval& b ) \
3217 { \
3218  SC_FXNUM_OBSERVER_READ_( *this ) \
3219  scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.get_rep() ); \
3220  delete m_rep; \
3221  m_rep = new_rep; \
3222  cast(); \
3223  SC_FXNUM_OBSERVER_WRITE_( *this ) \
3224  return *this; \
3225 } \
3226  \
3227 DEFN_ASN_OP_T(op,fnc,int) \
3228 DEFN_ASN_OP_T(op,fnc,unsigned int) \
3229 DEFN_ASN_OP_T(op,fnc,long) \
3230 DEFN_ASN_OP_T(op,fnc,unsigned long) \
3231 DEFN_ASN_OP_T(op,fnc,float) \
3232 DEFN_ASN_OP_T(op,fnc,double) \
3233 DEFN_ASN_OP_T(op,fnc,const char*) \
3234 DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&) \
3235 DEFN_ASN_OP_T(op,fnc,const sc_fxnum_fast&) \
3236 DEFN_ASN_OP_OTHER(op,fnc)
3237 
3238 DEFN_ASN_OP(*=,mult)
3239 DEFN_ASN_OP(/=,div)
3240 DEFN_ASN_OP(+=,add)
3241 DEFN_ASN_OP(-=,sub)
3242 
3243 #undef DEFN_ASN_OP_T
3244 #undef DEFN_ASN_OP_OTHER
3245 #undef DEFN_ASN_OP
3246 
3247 
3248 inline
3249 sc_fxnum&
3250 sc_fxnum::operator <<= ( int b )
3251 {
3252  SC_FXNUM_OBSERVER_READ_( *this )
3253  m_rep->lshift( b );
3254  cast();
3255  SC_FXNUM_OBSERVER_WRITE_( *this )
3256  return *this;
3257 }
3258 
3259 inline
3260 sc_fxnum&
3261 sc_fxnum::operator >>= ( int b )
3262 {
3263  SC_FXNUM_OBSERVER_READ_( *this )
3264  m_rep->rshift( b );
3265  cast();
3266  SC_FXNUM_OBSERVER_WRITE_( *this )
3267  return *this;
3268 }
3269 
3270 
3271 // auto-increment and auto-decrement
3272 
3273 inline
3274 const sc_fxval
3276 {
3277  sc_fxval c( *this );
3278  (*this) += 1;
3279  return c;
3280 }
3281 
3282 inline
3283 const sc_fxval
3285 {
3286  sc_fxval c( *this );
3287  (*this) -= 1;
3288  return c;
3289 }
3290 
3291 inline
3292 sc_fxnum&
3294 {
3295  (*this) += 1;
3296  return *this;
3297 }
3298 
3299 inline
3300 sc_fxnum&
3302 {
3303  (*this) -= 1;
3304  return *this;
3305 }
3306 
3307 
3308 // bit selection
3309 
3310 inline
3311 const sc_fxnum_bitref
3313 {
3314  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3315  return sc_fxnum_bitref( const_cast<sc_fxnum&>( *this ),
3316  i - m_params.fwl() );
3317 }
3318 
3319 inline
3322 {
3323  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3324  return sc_fxnum_bitref( *this, i - m_params.fwl() );
3325 }
3326 
3327 inline
3328 const sc_fxnum_bitref
3329 sc_fxnum::bit( int i ) const
3330 {
3331  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3332  return sc_fxnum_bitref( const_cast<sc_fxnum&>( *this ),
3333  i - m_params.fwl() );
3334 }
3335 
3336 inline
3339 {
3340  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3341  return sc_fxnum_bitref( *this, i - m_params.fwl() );
3342 }
3343 
3344 
3345 // part selection
3346 
3347 inline
3348 const sc_fxnum_subref
3349 sc_fxnum::operator () ( int i, int j ) const
3350 {
3351  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3352  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3353 
3354  return sc_fxnum_subref( const_cast<sc_fxnum&>( *this ),
3355  i - m_params.fwl(), j - m_params.fwl() );
3356 }
3357 
3358 inline
3360 sc_fxnum::operator () ( int i, int j )
3361 {
3362  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3363  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3364 
3365  return sc_fxnum_subref( *this, i - m_params.fwl(), j - m_params.fwl() );
3366 }
3367 
3368 inline
3369 const sc_fxnum_subref
3370 sc_fxnum::range( int i, int j ) const
3371 {
3372  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3373  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3374 
3375  return sc_fxnum_subref( const_cast<sc_fxnum&>( *this ),
3376  i - m_params.fwl(), j - m_params.fwl() );
3377 }
3378 
3379 inline
3381 sc_fxnum::range( int i, int j )
3382 {
3383  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3384  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
3385 
3386  return sc_fxnum_subref( *this, i - m_params.fwl(), j - m_params.fwl() );
3387 }
3388 
3389 
3390 inline
3391 const sc_fxnum_subref
3393 {
3394  return this->operator () ( m_params.wl() - 1, 0 );
3395 }
3396 
3397 inline
3400 {
3401  return this->operator () ( m_params.wl() - 1, 0 );
3402 }
3403 
3404 inline
3405 const sc_fxnum_subref
3407 {
3408  return this->range( m_params.wl() - 1, 0 );
3409 }
3410 
3411 inline
3414 {
3415  return this->range( m_params.wl() - 1, 0 );
3416 }
3417 
3418 
3419 // implicit conversion
3420 
3421 inline
3422 sc_fxnum::operator double() const
3423 {
3424  SC_FXNUM_OBSERVER_READ_( *this )
3425  return m_rep->to_double();
3426 }
3427 
3428 
3429 // explicit conversion to primitive types
3430 
3431 inline
3432 short
3434 {
3435  SC_FXNUM_OBSERVER_READ_( *this )
3436  return static_cast<short>( m_rep->to_uint64() );
3437 }
3438 
3439 inline
3440 unsigned short
3442 {
3443  SC_FXNUM_OBSERVER_READ_( *this )
3444  return static_cast<unsigned short>( m_rep->to_uint64() );
3445 }
3446 
3447 inline
3448 int
3450 {
3451  SC_FXNUM_OBSERVER_READ_( *this )
3452  return static_cast<int>( m_rep->to_uint64() );
3453 }
3454 
3455 inline
3456 int64
3458 {
3459  SC_FXNUM_OBSERVER_READ_( *this )
3460  return static_cast<int64>( m_rep->to_uint64() );
3461 }
3462 
3463 inline
3464 unsigned int
3466 {
3467  SC_FXNUM_OBSERVER_READ_( *this )
3468  return static_cast<unsigned int>( m_rep->to_uint64() );
3469 }
3470 
3471 inline
3472 uint64
3474 {
3475  SC_FXNUM_OBSERVER_READ_( *this )
3476  return m_rep->to_uint64();
3477 }
3478 
3479 inline
3480 long
3482 {
3483  SC_FXNUM_OBSERVER_READ_( *this )
3484  return static_cast<long>( m_rep->to_uint64() );
3485 }
3486 
3487 inline
3488 unsigned long
3490 {
3491  SC_FXNUM_OBSERVER_READ_( *this )
3492  return static_cast<unsigned long>( m_rep->to_uint64() );
3493 }
3494 
3495 inline
3496 float
3498 {
3499  SC_FXNUM_OBSERVER_READ_( *this )
3500  return static_cast<float>( m_rep->to_double() );
3501 }
3502 
3503 inline
3504 double
3506 {
3507  SC_FXNUM_OBSERVER_READ_( *this )
3508  return m_rep->to_double();
3509 }
3510 
3511 
3512 // query value
3513 
3514 inline
3515 bool
3517 {
3518  SC_FXNUM_OBSERVER_READ_( *this )
3519  return m_rep->is_neg();
3520 }
3521 
3522 inline
3523 bool
3525 {
3526  SC_FXNUM_OBSERVER_READ_( *this )
3527  return m_rep->is_zero();
3528 }
3529 
3530 // internal use only;
3531 inline
3532 bool
3534 {
3535  SC_FXNUM_OBSERVER_READ_( *this )
3536  return m_rep->is_normal();
3537 }
3538 
3539 inline
3540 bool
3542 {
3543  return m_q_flag;
3544 }
3545 
3546 inline
3547 bool
3549 {
3550  return m_o_flag;
3551 }
3552 
3553 
3554 inline
3555 const sc_fxval
3557 {
3558  SC_FXNUM_OBSERVER_READ_( *this )
3559  return sc_fxval( new scfx_rep( *m_rep ) );
3560 }
3561 
3562 
3563 // query parameters
3564 
3565 inline
3566 int
3568 {
3569  return m_params.wl();
3570 }
3571 
3572 inline
3573 int
3575 {
3576  return m_params.iwl();
3577 }
3578 
3579 inline
3580 sc_q_mode
3582 {
3583  return m_params.q_mode();
3584 }
3585 
3586 inline
3587 sc_o_mode
3589 {
3590  return m_params.o_mode();
3591 }
3592 
3593 inline
3594 int
3596 {
3597  return m_params.n_bits();
3598 }
3599 
3600 
3601 inline
3602 const sc_fxtype_params&
3604 {
3605  return m_params.type_params();
3606 }
3607 
3608 
3609 inline
3610 const sc_fxcast_switch&
3612 {
3613  return m_params.cast_switch();
3614 }
3615 
3616 
3617 // internal use only;
3618 inline
3619 void
3621 {
3622  SC_FXNUM_OBSERVER_READ_( *this );
3623 }
3624 
3625 
3626 // internal use only;
3627 inline
3628 bool
3629 sc_fxnum::get_bit( int i ) const
3630 {
3631  return m_rep->get_bit( i );
3632 }
3633 
3634 
3635 // protected methods and friend functions
3636 
3637 inline
3638 bool
3639 sc_fxnum::set_bit( int i, bool high )
3640 {
3641  if( high )
3642  return m_rep->set( i, m_params );
3643  else
3644  return m_rep->clear( i, m_params );
3645 }
3646 
3647 
3648 inline
3649 bool
3650 sc_fxnum::get_slice( int i, int j, sc_bv_base& bv ) const
3651 {
3652  return m_rep->get_slice( i, j, m_params, bv );
3653 }
3654 
3655 inline
3656 bool
3657 sc_fxnum::set_slice( int i, int j, const sc_bv_base& bv )
3658 {
3659  return m_rep->set_slice( i, j, m_params, bv );
3660 }
3661 
3662 
3663 inline
3664 ::std::ostream&
3665 operator << ( ::std::ostream& os, const sc_fxnum& a )
3666 {
3667  a.print( os );
3668  return os;
3669 }
3670 
3671 inline
3672 ::std::istream&
3673 operator >> ( ::std::istream& is, sc_fxnum& a )
3674 {
3675  a.scan( is );
3676  return is;
3677 }
3678 
3679 
3686 inline
3689 {
3690  return m_observer;
3691 }
3692 
3693 
3694 // constructors
3695 
3696 inline
3697 sc_fxnum_fast::sc_fxnum_fast( const sc_fxtype_params& type_params_,
3698  sc_enc enc_,
3699  const sc_fxcast_switch& cast_sw,
3700  sc_fxnum_fast_observer* observer_ )
3701 : m_val( 0.0 ),
3702  m_params( type_params_, enc_, cast_sw ),
3703  m_q_flag( false ),
3704  m_o_flag( false ),
3705  m_observer( observer_ )
3706 {
3709 }
3710 
3711 inline
3712 sc_fxnum_fast::sc_fxnum_fast( const sc_fxnum_fast& a,
3713  const sc_fxtype_params& type_params_,
3714  sc_enc enc_,
3715  const sc_fxcast_switch& cast_sw,
3716  sc_fxnum_fast_observer* observer_ )
3717 : m_val( a.m_val ),
3718  m_params( type_params_, enc_, cast_sw ),
3719  m_q_flag( false ),
3720  m_o_flag( false ),
3721  m_observer( observer_ )
3722 {
3725  cast();
3728 }
3729 
3730 #define DEFN_CTOR_T(tp,arg) \
3731 inline \
3732 sc_fxnum_fast::sc_fxnum_fast( tp a, \
3733  const sc_fxtype_params& type_params_, \
3734  sc_enc enc_, \
3735  const sc_fxcast_switch& cast_sw, \
3736  sc_fxnum_fast_observer* observer_ ) \
3737 : m_val( arg ), \
3738  m_params( type_params_, enc_, cast_sw ), \
3739  m_q_flag( false ), \
3740  m_o_flag( false ), \
3741  m_observer( observer_ ) \
3742 { \
3743  SC_FXNUM_FAST_OBSERVER_DEFAULT_ \
3744  cast(); \
3745  SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) \
3746  SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
3747 }
3748 
3749 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a ))
3750 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,sc_fxval_fast::from_string( a ))
3751 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
3752 
3753 DEFN_CTOR_T_A(int)
3754 DEFN_CTOR_T_A(unsigned int)
3755 DEFN_CTOR_T_A(long)
3756 DEFN_CTOR_T_A(unsigned long)
3757 DEFN_CTOR_T_A(float)
3758 DEFN_CTOR_T_A(double)
3759 DEFN_CTOR_T_B(const char*)
3760 DEFN_CTOR_T_C(const sc_fxval&)
3762 DEFN_CTOR_T_C(const sc_fxnum&)
3763 #ifndef SC_FX_EXCLUDE_OTHER
3766 DEFN_CTOR_T_C(const sc_int_base&)
3767 DEFN_CTOR_T_C(const sc_uint_base&)
3768 DEFN_CTOR_T_C(const sc_signed&)
3769 DEFN_CTOR_T_C(const sc_unsigned&)
3770 #endif
3771 
3772 #undef DEFN_CTOR_T
3773 #undef DEFN_CTOR_T_A
3774 #undef DEFN_CTOR_T_B
3775 #undef DEFN_CTOR_T_C
3776 #undef DEFN_CTOR_T_D
3777 #undef DEFN_CTOR_T_E
3778 
3779 
3780 inline
3782 {
3784 }
3785 
3786 
3787 // internal use only;
3788 inline
3789 double
3791 {
3793  return m_val;
3794 }
3795 
3796 
3797 // unary operators
3798 
3799 inline
3800 const sc_fxval_fast
3802 {
3804  return sc_fxval_fast( - m_val );
3805 }
3806 
3807 inline
3808 const sc_fxval_fast
3810 {
3812  return sc_fxval_fast( m_val );
3813 }
3814 
3815 
3816 // unary functions
3817 
3818 inline
3819 void
3821 {
3823  c.set_val( - a.m_val );
3824 }
3825 
3826 inline
3827 void
3829 {
3831  c.m_val = - a.m_val;
3832  c.cast();
3834 }
3835 
3836 
3837 // binary operators
3838 
3839 #define DEFN_BIN_OP_T(op,tp) \
3840 inline \
3841 const sc_fxval_fast \
3842 operator op ( const sc_fxnum_fast& a, tp b ) \
3843 { \
3844  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
3845  sc_fxval_fast tmp( b ); \
3846  return sc_fxval_fast( a.m_val op tmp.get_val() ); \
3847 } \
3848  \
3849 inline \
3850 const sc_fxval_fast \
3851 operator op ( tp a, const sc_fxnum_fast& b ) \
3852 { \
3853  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
3854  sc_fxval_fast tmp( a ); \
3855  return sc_fxval_fast( tmp.get_val() op b.m_val ); \
3856 }
3857 
3858 #ifndef SC_FX_EXCLUDE_OTHER
3859 #define DEFN_BIN_OP_OTHER(op) \
3860 DEFN_BIN_OP_T(op,int64) \
3861 DEFN_BIN_OP_T(op,uint64) \
3862 DEFN_BIN_OP_T(op,const sc_int_base&) \
3863 DEFN_BIN_OP_T(op,const sc_uint_base&) \
3864 DEFN_BIN_OP_T(op,const sc_signed&) \
3865 DEFN_BIN_OP_T(op,const sc_unsigned&)
3866 #else
3867 #define DEFN_BIN_OP_OTHER(op)
3868 #endif
3869 
3870 #define DEFN_BIN_OP(op,dummy) \
3871 inline \
3872 const sc_fxval_fast \
3873 operator op ( const sc_fxnum_fast& a, const sc_fxnum_fast& b ) \
3874 { \
3875  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
3876  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
3877  return sc_fxval_fast( a.m_val op b.m_val ); \
3878 } \
3879  \
3880 inline \
3881 const sc_fxval_fast \
3882 operator op ( const sc_fxnum_fast& a, const sc_fxval_fast& b ) \
3883 { \
3884  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
3885  return sc_fxval_fast( a.m_val op b.get_val() ); \
3886 } \
3887  \
3888 inline \
3889 const sc_fxval_fast \
3890 operator op ( const sc_fxval_fast& a, const sc_fxnum_fast& b ) \
3891 { \
3892  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
3893  return sc_fxval_fast( a.get_val() op b.m_val ); \
3894 } \
3895  \
3896 DEFN_BIN_OP_T(op,int) \
3897 DEFN_BIN_OP_T(op,unsigned int) \
3898 DEFN_BIN_OP_T(op,long) \
3899 DEFN_BIN_OP_T(op,unsigned long) \
3900 DEFN_BIN_OP_T(op,float) \
3901 DEFN_BIN_OP_T(op,double) \
3902 DEFN_BIN_OP_T(op,const char*) \
3903 DEFN_BIN_OP_OTHER(op)
3904 
3905 DEFN_BIN_OP(*,mult)
3906 DEFN_BIN_OP(+,add)
3907 DEFN_BIN_OP(-,sub)
3908 //DEFN_BIN_OP(/,div)
3909 inline
3910 const sc_fxval_fast
3912 {
3915  return sc_fxval_fast( a.m_val / b.m_val );
3916 }
3917 
3918 inline
3919 const sc_fxval_fast
3921 {
3923  return sc_fxval_fast( a.m_val / b.get_val() );
3924 }
3925 
3926 inline
3927 const sc_fxval_fast
3929 {
3931  return sc_fxval_fast( a.get_val() / b.m_val );
3932 }
3933 
3934 DEFN_BIN_OP_T(/,int)
3935 DEFN_BIN_OP_T(/,unsigned int)
3936 DEFN_BIN_OP_T(/,long)
3937 DEFN_BIN_OP_T(/,unsigned long)
3938 DEFN_BIN_OP_T(/,float)
3939 DEFN_BIN_OP_T(/,double)
3940 DEFN_BIN_OP_T(/,const char*)
3941 //DEFN_BIN_OP_OTHER(/)
3942 #ifndef SC_FX_EXCLUDE_OTHER
3945 DEFN_BIN_OP_T(/,const sc_int_base&)
3946 DEFN_BIN_OP_T(/,const sc_uint_base&)
3947 DEFN_BIN_OP_T(/,const sc_signed&)
3948 DEFN_BIN_OP_T(/,const sc_unsigned&)
3949 #endif
3950 
3951 #undef DEFN_BIN_OP_T
3952 #undef DEFN_BIN_OP_OTHER
3953 #undef DEFN_BIN_OP
3954 
3955 
3956 inline
3957 const sc_fxval_fast
3958 operator << ( const sc_fxnum_fast& a, int b )
3959 {
3961  return sc_fxval_fast( a.m_val * scfx_pow2( b ) );
3962 }
3963 
3964 inline
3965 const sc_fxval_fast
3966 operator >> ( const sc_fxnum_fast& a, int b )
3967 {
3969  return sc_fxval_fast( a.m_val * scfx_pow2( -b ) );
3970 }
3971 
3972 
3973 // binary functions
3974 
3975 #define DEFN_BIN_FNC_T(fnc,op,tp) \
3976 inline \
3977 void \
3978 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, tp b ) \
3979 { \
3980  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
3981  sc_fxval_fast tmp( b ); \
3982  c.set_val( a.m_val op tmp.get_val() ); \
3983 } \
3984  \
3985 inline \
3986 void \
3987 fnc ( sc_fxval_fast& c, tp a, const sc_fxnum_fast& b ) \
3988 { \
3989  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
3990  sc_fxval_fast tmp( a ); \
3991  c.set_val( tmp.get_val() op b.m_val ); \
3992 } \
3993  \
3994 inline \
3995 void \
3996 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, tp b ) \
3997 { \
3998  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
3999  sc_fxval_fast tmp( b ); \
4000  c.m_val = a.m_val op tmp.get_val(); \
4001  c.cast(); \
4002  SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
4003 } \
4004  \
4005 inline \
4006 void \
4007 fnc ( sc_fxnum_fast& c, tp a, const sc_fxnum_fast& b ) \
4008 { \
4009  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4010  sc_fxval_fast tmp( a ); \
4011  c.m_val = tmp.get_val() op b.m_val; \
4012  c.cast(); \
4013  SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
4014 }
4015 
4016 #ifndef SC_FX_EXCLUDE_OTHER
4017 #define DEFN_BIN_FNC_OTHER(fnc,op) \
4018 DEFN_BIN_FNC_T(fnc,op,int64) \
4019 DEFN_BIN_FNC_T(fnc,op,uint64) \
4020 DEFN_BIN_FNC_T(fnc,op,const sc_int_base&) \
4021 DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&) \
4022 DEFN_BIN_FNC_T(fnc,op,const sc_signed&) \
4023 DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&)
4024 #else
4025 #define DEFN_BIN_FNC_OTHER(fnc,op)
4026 #endif
4027 
4028 #define DEFN_BIN_FNC(fnc,op) \
4029 inline \
4030 void \
4031 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, const sc_fxnum_fast& b ) \
4032 { \
4033  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4034  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4035  c.set_val( a.m_val op b.m_val ); \
4036 } \
4037  \
4038 inline \
4039 void \
4040 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, const sc_fxnum_fast& b ) \
4041 { \
4042  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4043  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4044  c.m_val = a.m_val op b.m_val; \
4045  c.cast(); \
4046  SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
4047 } \
4048  \
4049 inline \
4050 void \
4051 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, const sc_fxval_fast& b ) \
4052 { \
4053  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4054  c.set_val( a.m_val op b.get_val() ); \
4055 } \
4056  \
4057 inline \
4058 void \
4059 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxnum_fast& b ) \
4060 { \
4061  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4062  c.set_val( a.get_val() op b.m_val ); \
4063 } \
4064  \
4065 inline \
4066 void \
4067 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, const sc_fxval_fast& b ) \
4068 { \
4069  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4070  c.m_val = a.m_val op b.get_val(); \
4071  c.cast(); \
4072  SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
4073 } \
4074  \
4075 inline \
4076 void \
4077 fnc ( sc_fxnum_fast& c, const sc_fxval_fast& a, const sc_fxnum_fast& b ) \
4078 { \
4079  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4080  c.m_val = a.get_val() op b.m_val; \
4081  c.cast(); \
4082  SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
4083 } \
4084  \
4085 DEFN_BIN_FNC_T(fnc,op,int) \
4086 DEFN_BIN_FNC_T(fnc,op,unsigned int) \
4087 DEFN_BIN_FNC_T(fnc,op,long) \
4088 DEFN_BIN_FNC_T(fnc,op,unsigned long) \
4089 DEFN_BIN_FNC_T(fnc,op,float) \
4090 DEFN_BIN_FNC_T(fnc,op,double) \
4091 DEFN_BIN_FNC_T(fnc,op,const char*) \
4092 DEFN_BIN_FNC_T(fnc,op,const sc_fxval&) \
4093 DEFN_BIN_FNC_T(fnc,op,const sc_fxnum&) \
4094 DEFN_BIN_FNC_OTHER(fnc,op)
4095 
4096 DEFN_BIN_FNC(mult,*)
4097 DEFN_BIN_FNC(div,/)
4098 DEFN_BIN_FNC(add,+)
4099 DEFN_BIN_FNC(sub,-)
4100 
4101 #undef DEFN_BIN_FNC_T
4102 #undef DEFN_BIN_FNC_OTHER
4103 #undef DEFN_BIN_FNC
4104 
4105 
4106 inline
4107 void
4108 lshift( sc_fxval_fast& c, const sc_fxnum_fast& a, int b )
4109 {
4111  c.set_val( a.m_val * scfx_pow2( b ) );
4112 }
4113 
4114 inline
4115 void
4116 rshift( sc_fxval_fast& c, const sc_fxnum_fast& a, int b )
4117 {
4119  c.set_val( a.m_val * scfx_pow2( -b ) );
4120 }
4121 
4122 inline
4123 void
4124 lshift( sc_fxnum_fast& c, const sc_fxnum_fast& a, int b )
4125 {
4127  c.m_val = a.m_val * scfx_pow2( b );
4128  c.cast();
4130 }
4131 
4132 inline
4133 void
4134 rshift( sc_fxnum_fast& c, const sc_fxnum_fast& a, int b )
4135 {
4137  c.m_val = a.m_val * scfx_pow2( -b );
4138  c.cast();
4140 }
4141 
4142 
4143 // relational (including equality) operators
4144 
4145 #define DEFN_REL_OP_T(op,tp) \
4146 inline \
4147 bool \
4148 operator op ( const sc_fxnum_fast& a, tp b ) \
4149 { \
4150  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4151  sc_fxval_fast tmp( b ); \
4152  return ( a.m_val op tmp.get_val() ); \
4153 } \
4154  \
4155 inline \
4156 bool \
4157 operator op ( tp a, const sc_fxnum_fast& b ) \
4158 { \
4159  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4160  sc_fxval_fast tmp( a ); \
4161  return ( tmp.get_val() op b.m_val ); \
4162 }
4163 
4164 #ifndef SC_FX_EXCLUDE_OTHER
4165 #define DEFN_REL_OP_OTHER(op) \
4166 DEFN_REL_OP_T(op,int64) \
4167 DEFN_REL_OP_T(op,uint64) \
4168 DEFN_REL_OP_T(op,const sc_int_base&) \
4169 DEFN_REL_OP_T(op,const sc_uint_base&) \
4170 DEFN_REL_OP_T(op,const sc_signed&) \
4171 DEFN_REL_OP_T(op,const sc_unsigned&)
4172 #else
4173 #define DEFN_REL_OP_OTHER(op)
4174 #endif
4175 
4176 #define DEFN_REL_OP(op) \
4177 inline \
4178 bool \
4179 operator op ( const sc_fxnum_fast& a, const sc_fxnum_fast& b ) \
4180 { \
4181  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4182  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4183  return ( a.m_val op b.m_val ); \
4184 } \
4185  \
4186 inline \
4187 bool \
4188 operator op ( const sc_fxnum_fast& a, const sc_fxval_fast& b ) \
4189 { \
4190  SC_FXNUM_FAST_OBSERVER_READ_( a ) \
4191  return ( a.m_val op b.get_val() ); \
4192 } \
4193  \
4194 inline \
4195 bool \
4196 operator op ( const sc_fxval_fast& a, const sc_fxnum_fast& b ) \
4197 { \
4198  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4199  return ( a.get_val() op b.m_val ); \
4200 } \
4201  \
4202 DEFN_REL_OP_T(op,int) \
4203 DEFN_REL_OP_T(op,unsigned int) \
4204 DEFN_REL_OP_T(op,long) \
4205 DEFN_REL_OP_T(op,unsigned long) \
4206 DEFN_REL_OP_T(op,float) \
4207 DEFN_REL_OP_T(op,double) \
4208 DEFN_REL_OP_T(op,const char*) \
4209 DEFN_REL_OP_OTHER(op)
4210 
4211 DEFN_REL_OP(<)
4212 DEFN_REL_OP(<=)
4213 DEFN_REL_OP(>)
4214 DEFN_REL_OP(>=)
4215 DEFN_REL_OP(==)
4216 DEFN_REL_OP(!=)
4217 
4218 #undef DEFN_REL_OP_T
4219 #undef DEFN_REL_OP_OTHER
4220 #undef DEFN_REL_OP
4221 
4222 
4223 // assignment operators
4224 
4225 inline
4226 sc_fxnum_fast&
4227 sc_fxnum_fast::operator = ( const sc_fxnum_fast& a )
4228 {
4229  if( &a != this )
4230  {
4232  m_val = a.m_val;
4233  cast();
4235  }
4236  return *this;
4237 }
4238 
4239 inline
4240 sc_fxnum_fast&
4241 sc_fxnum_fast::operator = ( const sc_fxval_fast& a )
4242 {
4243  m_val = a.get_val();
4244  cast();
4246  return *this;
4247 }
4248 
4249 #define DEFN_ASN_OP_T(tp) \
4250 inline \
4251 sc_fxnum_fast& \
4252 sc_fxnum_fast::operator = ( tp a ) \
4253 { \
4254  sc_fxval_fast tmp( a ); \
4255  m_val = tmp.get_val(); \
4256  cast(); \
4257  SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
4258  return *this; \
4259 }
4260 
4261 DEFN_ASN_OP_T(int)
4262 DEFN_ASN_OP_T(unsigned int)
4263 DEFN_ASN_OP_T(long)
4264 DEFN_ASN_OP_T(unsigned long)
4265 DEFN_ASN_OP_T(float)
4266 DEFN_ASN_OP_T(double)
4267 DEFN_ASN_OP_T(const char*)
4268 DEFN_ASN_OP_T(const sc_fxval&)
4269 DEFN_ASN_OP_T(const sc_fxnum&)
4270 #ifndef SC_FX_EXCLUDE_OTHER
4273 DEFN_ASN_OP_T(const sc_int_base&)
4274 DEFN_ASN_OP_T(const sc_uint_base&)
4275 DEFN_ASN_OP_T(const sc_signed&)
4276 DEFN_ASN_OP_T(const sc_unsigned&)
4277 #endif
4278 
4279 #undef DEFN_ASN_OP_T
4280 
4281 
4282 #define DEFN_ASN_OP_T(op,tp) \
4283 inline \
4284 sc_fxnum_fast& \
4285 sc_fxnum_fast::operator op ( tp b ) \
4286 { \
4287  SC_FXNUM_FAST_OBSERVER_READ_( *this ) \
4288  sc_fxval_fast tmp( b ); \
4289  m_val op tmp.get_val(); \
4290  cast(); \
4291  SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
4292  return *this; \
4293 }
4294 
4295 #ifndef SC_FX_EXCLUDE_OTHER
4296 #define DEFN_ASN_OP_OTHER(op) \
4297 DEFN_ASN_OP_T(op,int64) \
4298 DEFN_ASN_OP_T(op,uint64) \
4299 DEFN_ASN_OP_T(op,const sc_int_base&) \
4300 DEFN_ASN_OP_T(op,const sc_uint_base&) \
4301 DEFN_ASN_OP_T(op,const sc_signed&) \
4302 DEFN_ASN_OP_T(op,const sc_unsigned&)
4303 #else
4304 #define DEFN_ASN_OP_OTHER(op)
4305 #endif
4306 
4307 #define DEFN_ASN_OP(op) \
4308 inline \
4309 sc_fxnum_fast& \
4310 sc_fxnum_fast::operator op ( const sc_fxnum_fast& b ) \
4311 { \
4312  SC_FXNUM_FAST_OBSERVER_READ_( *this ) \
4313  SC_FXNUM_FAST_OBSERVER_READ_( b ) \
4314  m_val op b.m_val; \
4315  cast(); \
4316  SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
4317  return *this; \
4318 } \
4319  \
4320 inline \
4321 sc_fxnum_fast& \
4322 sc_fxnum_fast::operator op ( const sc_fxval_fast& b ) \
4323 { \
4324  SC_FXNUM_FAST_OBSERVER_READ_( *this ) \
4325  m_val op b.get_val(); \
4326  cast(); \
4327  SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
4328  return *this; \
4329 } \
4330  \
4331 DEFN_ASN_OP_T(op,int) \
4332 DEFN_ASN_OP_T(op,unsigned int) \
4333 DEFN_ASN_OP_T(op,long) \
4334 DEFN_ASN_OP_T(op,unsigned long) \
4335 DEFN_ASN_OP_T(op,float) \
4336 DEFN_ASN_OP_T(op,double) \
4337 DEFN_ASN_OP_T(op,const char*) \
4338 DEFN_ASN_OP_T(op,const sc_fxval&) \
4339 DEFN_ASN_OP_T(op,const sc_fxnum&) \
4340 DEFN_ASN_OP_OTHER(op)
4341 
4342 DEFN_ASN_OP(*=)
4343 DEFN_ASN_OP(/=)
4344 DEFN_ASN_OP(+=)
4345 DEFN_ASN_OP(-=)
4346 
4347 #undef DEFN_ASN_OP_T
4348 #undef DEFN_ASN_OP_OTHER
4349 #undef DEFN_ASN_OP
4350 
4351 
4352 inline
4353 sc_fxnum_fast&
4354 sc_fxnum_fast::operator <<= ( int b )
4355 {
4357  m_val *= scfx_pow2( b );
4358  cast();
4360  return *this;
4361 }
4362 
4363 inline
4364 sc_fxnum_fast&
4365 sc_fxnum_fast::operator >>= ( int b )
4366 {
4368  m_val *= scfx_pow2( -b );
4369  cast();
4371  return *this;
4372 }
4373 
4374 
4375 // auto-increment and auto-decrement
4376 
4377 inline
4378 const sc_fxval_fast
4380 {
4383  double c = m_val;
4384  m_val = m_val + 1;
4385  cast();
4387  return sc_fxval_fast( c );
4388 }
4389 
4390 inline
4391 const sc_fxval_fast
4393 {
4396  double c = m_val;
4397  m_val = m_val - 1;
4398  cast();
4400  return sc_fxval_fast( c );
4401 }
4402 
4403 inline
4406 {
4408  m_val = m_val + 1;
4409  cast();
4411  return *this;
4412 }
4413 
4414 inline
4417 {
4419  m_val = m_val - 1;
4420  cast();
4422  return *this;
4423 }
4424 
4425 
4426 // bit selection
4427 
4428 inline
4431 {
4432  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4433  return sc_fxnum_fast_bitref( const_cast<sc_fxnum_fast&>( *this ),
4434  i - m_params.fwl() );
4435 }
4436 
4437 inline
4440 {
4441  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4442  return sc_fxnum_fast_bitref( *this, i - m_params.fwl() );
4443 }
4444 
4445 inline
4447 sc_fxnum_fast::bit( int i ) const
4448 {
4449  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4450  return sc_fxnum_fast_bitref( const_cast<sc_fxnum_fast&>( *this ),
4451  i - m_params.fwl() );
4452 }
4453 
4454 inline
4457 {
4458  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4459  return sc_fxnum_fast_bitref( *this, i - m_params.fwl() );
4460 }
4461 
4462 
4463 // part selection
4464 
4465 inline
4467 sc_fxnum_fast::operator () ( int i, int j ) const
4468 {
4469  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4470  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4471 
4472  return sc_fxnum_fast_subref( const_cast<sc_fxnum_fast&>( *this ),
4473  i - m_params.fwl(), j - m_params.fwl() );
4474 }
4475 
4476 inline
4479 {
4480  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4481  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4482 
4483  return sc_fxnum_fast_subref( *this,
4484  i - m_params.fwl(), j - m_params.fwl() );
4485 }
4486 
4487 inline
4489 sc_fxnum_fast::range( int i, int j ) const
4490 {
4491  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4492  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4493 
4494  return sc_fxnum_fast_subref( const_cast<sc_fxnum_fast&>( *this ),
4495  i - m_params.fwl(), j - m_params.fwl() );
4496 }
4497 
4498 inline
4500 sc_fxnum_fast::range( int i, int j )
4501 {
4502  SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4503  SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
4504 
4505  return sc_fxnum_fast_subref( *this,
4506  i - m_params.fwl(), j - m_params.fwl() );
4507 }
4508 
4509 inline
4512 {
4513  return this->operator () ( m_params.wl() - 1, 0 );
4514 }
4515 
4516 inline
4519 {
4520  return this->operator () ( m_params.wl() - 1, 0 );
4521 }
4522 
4523 inline
4526 {
4527  return this->range( m_params.wl() - 1, 0 );
4528 }
4529 
4530 inline
4533 {
4534  return this->range( m_params.wl() - 1, 0 );
4535 }
4536 
4537 
4538 // implicit conversion
4539 
4540 inline
4541 sc_fxnum_fast::operator double() const
4542 {
4544  return m_val;
4545 }
4546 
4547 
4548 // explicit conversion to primitive types
4549 
4550 inline
4551 short
4553 {
4554  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4555  return static_cast<short>( to_uint64() );
4556 }
4557 
4558 inline
4559 unsigned short
4561 {
4562  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4563  return static_cast<unsigned short>( to_uint64() );
4564 }
4565 
4566 inline
4567 int
4569 {
4570  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4571  return static_cast<int>( to_uint64() );
4572 }
4573 
4574 inline
4575 int64
4577 {
4578  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4579  return static_cast<int64>( to_uint64() );
4580 }
4581 
4582 inline
4583 unsigned int
4585 {
4586  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4587  return static_cast<unsigned int>( to_uint64() );
4588 }
4589 
4590 inline
4591 uint64
4593 {
4594  // SC_FXNUM_FAST_OBSERVER_READ_ in is_normal
4595  if (!is_normal())
4596  {
4597  return 0;
4598  }
4599 
4600  int exponent;
4601  double mantissa_dbl = frexp(m_val, &exponent);
4602 
4603  uint64 mantissa = static_cast<uint64>(fabs(mantissa_dbl) * (UINT64_ONE << 53));
4604  exponent -= 53;
4605 
4606  if (!(-64 < exponent && exponent < 64))
4607  {
4608  return 0;
4609  }
4610 
4611  mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
4612  return mantissa_dbl >= 0 ? mantissa : -mantissa;
4613 }
4614 
4615 inline
4616 long
4618 {
4619  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4620  return static_cast<long>( to_uint64() );
4621 }
4622 
4623 inline
4624 unsigned long
4626 {
4627  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
4628  return static_cast<unsigned long>( to_uint64() );
4629 }
4630 
4631 inline
4632 float
4634 {
4636  return static_cast<float>( m_val );
4637 }
4638 
4639 inline
4640 double
4642 {
4644  return m_val;
4645 }
4646 
4647 
4648 // query value
4649 
4650 inline
4651 bool
4653 {
4655  scfx_ieee_double id( m_val );
4656  return ( id.negative() != 0 );
4657 }
4658 
4659 inline
4660 bool
4662 {
4664  scfx_ieee_double id( m_val );
4665  return id.is_zero();
4666 }
4667 
4668 // internal use only;
4669 inline
4670 bool
4672 {
4674  scfx_ieee_double id( m_val );
4675  return ( id.is_normal() || id.is_subnormal() || id.is_zero() );
4676 }
4677 
4678 
4679 inline
4680 bool
4682 {
4683  return m_q_flag;
4684 }
4685 
4686 inline
4687 bool
4689 {
4690  return m_o_flag;
4691 }
4692 
4693 
4694 inline
4695 const sc_fxval_fast
4697 {
4699  return sc_fxval_fast( m_val );
4700 }
4701 
4702 
4703 // query parameters
4704 
4705 inline
4706 int
4708 {
4709  return m_params.wl();
4710 }
4711 
4712 inline
4713 int
4715 {
4716  return m_params.iwl();
4717 }
4718 
4719 inline
4720 sc_q_mode
4722 {
4723  return m_params.q_mode();
4724 }
4725 
4726 inline
4727 sc_o_mode
4729 {
4730  return m_params.o_mode();
4731 }
4732 
4733 inline
4734 int
4736 {
4737  return m_params.n_bits();
4738 }
4739 
4740 
4741 inline
4742 const sc_fxtype_params&
4744 {
4745  return m_params.type_params();
4746 }
4747 
4748 
4749 inline
4750 const sc_fxcast_switch&
4752 {
4753  return m_params.cast_switch();
4754 }
4755 
4756 
4757 // internal use only;
4758 inline
4759 void
4761 {
4763 }
4764 
4765 
4766 inline
4767 ::std::ostream&
4768 operator << ( ::std::ostream& os, const sc_fxnum_fast& a )
4769 {
4770  a.print( os );
4771  return os;
4772 }
4773 
4774 inline
4775 ::std::istream&
4776 operator >> ( ::std::istream& is, sc_fxnum_fast& a )
4777 {
4778  a.scan( is );
4779  return is;
4780 }
4781 
4782 
4789 // public constructors
4790 
4791 inline
4793  sc_fxval_observer* observer_ )
4794 : m_rep( new scfx_rep( *a.get_rep() ) ),
4795  m_observer( observer_ )
4796 {
4799  SC_FXVAL_OBSERVER_WRITE_( *this )
4800 }
4801 
4802 inline
4804  sc_fxval_observer* observer_ )
4805 : m_rep( new scfx_rep( a.to_double() ) ),
4806  m_observer( observer_ )
4807 {
4810  SC_FXVAL_OBSERVER_WRITE_( *this )
4811 }
4812 
4813 
4814 // binary operators
4815 
4816 #define DEFN_BIN_OP_T(op,fnc,tp) \
4817 inline \
4818 const sc_fxval \
4819 operator op ( const sc_fxval& a, tp b ) \
4820 { \
4821  SC_FXVAL_OBSERVER_READ_( a ) \
4822  sc_fxval tmp( b ); \
4823  return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) ); \
4824 } \
4825  \
4826 inline \
4827 const sc_fxval \
4828 operator op ( tp a, const sc_fxval& b ) \
4829 { \
4830  SC_FXVAL_OBSERVER_READ_( b ) \
4831  sc_fxval tmp( a ); \
4832  return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) ); \
4833 }
4834 
4835 #define DEFN_BIN_OP(op,fnc) \
4836 DEFN_BIN_OP_T(op,fnc,const sc_fxnum_fast&)
4837 
4838 DEFN_BIN_OP(*,mult)
4839 DEFN_BIN_OP(+,add)
4840 DEFN_BIN_OP(-,sub)
4841 //DEFN_BIN_OP(/,div)
4842 DEFN_BIN_OP_T(/,div,const sc_fxnum_fast&)
4843 
4844 #undef DEFN_BIN_OP_T
4845 #undef DEFN_BIN_OP
4846 
4847 
4848 // binary functions
4849 
4850 #define DEFN_BIN_FNC_T(fnc,tp) \
4851 inline \
4852 void \
4853 fnc ( sc_fxval& c, const sc_fxval& a, tp b ) \
4854 { \
4855  SC_FXVAL_OBSERVER_READ_( a ) \
4856  sc_fxval tmp( b ); \
4857  delete c.m_rep; \
4858  c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ); \
4859  SC_FXVAL_OBSERVER_WRITE_( c ) \
4860 } \
4861  \
4862 inline \
4863 void \
4864 fnc ( sc_fxval& c, tp a, const sc_fxval& b ) \
4865 { \
4866  SC_FXVAL_OBSERVER_READ_( b ) \
4867  sc_fxval tmp( a ); \
4868  delete c.m_rep; \
4869  c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ); \
4870  SC_FXVAL_OBSERVER_WRITE_( c ) \
4871 }
4872 
4873 #define DEFN_BIN_FNC(fnc) \
4874 DEFN_BIN_FNC_T(fnc,const sc_fxnum_fast&)
4875 
4876 DEFN_BIN_FNC(mult)
4877 DEFN_BIN_FNC(div)
4878 DEFN_BIN_FNC(add)
4879 DEFN_BIN_FNC(sub)
4880 
4881 #undef DEFN_BIN_FNC_T
4882 #undef DEFN_BIN_FNC
4883 
4884 
4885 // relational (including equality) operators
4886 
4887 #define DEFN_REL_OP_T(op,ret,tp) \
4888 inline \
4889 bool \
4890 operator op ( const sc_fxval& a, tp b ) \
4891 { \
4892  SC_FXVAL_OBSERVER_READ_( a ) \
4893  sc_fxval tmp( b ); \
4894  int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep ); \
4895  return ( ret ); \
4896 } \
4897  \
4898 inline \
4899 bool \
4900 operator op ( tp a, const sc_fxval& b ) \
4901 { \
4902  SC_FXVAL_OBSERVER_READ_( b ) \
4903  sc_fxval tmp( a ); \
4904  int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep ); \
4905  return ( ret ); \
4906 }
4907 
4908 
4909 #define DEFN_REL_OP(op,ret) \
4910 DEFN_REL_OP_T(op,ret,const sc_fxnum_fast&)
4911 
4912 DEFN_REL_OP(<,result < 0)
4913 DEFN_REL_OP(<=,result <= 0)
4914 DEFN_REL_OP(>,result > 0 && result != 2)
4915 DEFN_REL_OP(>=,result >= 0 && result != 2)
4916 DEFN_REL_OP(==,result == 0)
4917 DEFN_REL_OP(!=,result != 0)
4918 
4919 #undef DEFN_REL_OP_T
4920 #undef DEFN_REL_OP
4921 
4922 
4923 // assignment operators
4924 
4925 inline
4926 sc_fxval&
4927 sc_fxval::operator = ( const sc_fxnum& a )
4928 {
4929  *m_rep = *a.get_rep();
4930  SC_FXVAL_OBSERVER_WRITE_( *this )
4931  return *this;
4932 }
4933 
4934 #define DEFN_ASN_OP_T(tp) \
4935 inline \
4936 sc_fxval& \
4937 sc_fxval::operator = ( tp b ) \
4938 { \
4939  sc_fxval tmp( b ); \
4940  *m_rep = *tmp.m_rep; \
4941  SC_FXVAL_OBSERVER_WRITE_( *this ) \
4942  return *this; \
4943 }
4944 
4945 DEFN_ASN_OP_T(const sc_fxnum_fast&)
4946 
4947 #undef DEFN_ASN_OP_T
4948 
4949 
4950 #define DEFN_ASN_OP_T(op,fnc,tp) \
4951 inline \
4952 sc_fxval& \
4953 sc_fxval::operator op ( tp b ) \
4954 { \
4955  SC_FXVAL_OBSERVER_READ_( *this ) \
4956  sc_fxval tmp( b ); \
4957  scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep ); \
4958  delete m_rep; \
4959  m_rep = new_rep; \
4960  SC_FXVAL_OBSERVER_WRITE_( *this ) \
4961  return *this; \
4962 }
4963 
4964 #define DEFN_ASN_OP(op,fnc) \
4965 inline \
4966 sc_fxval& \
4967 sc_fxval::operator op ( const sc_fxnum& b ) \
4968 { \
4969  SC_FXVAL_OBSERVER_READ_( *this ) \
4970  scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.get_rep() ); \
4971  delete m_rep; \
4972  m_rep = new_rep; \
4973  SC_FXVAL_OBSERVER_WRITE_( *this ) \
4974  return *this; \
4975 } \
4976  \
4977 DEFN_ASN_OP_T(op,fnc,const sc_fxnum_fast&)
4978 
4979 DEFN_ASN_OP(*=,mult)
4980 DEFN_ASN_OP(/=,div)
4981 DEFN_ASN_OP(+=,add)
4982 DEFN_ASN_OP(-=,sub)
4983 
4984 #undef DEFN_ASN_OP_T
4985 #undef DEFN_ASN_OP
4986 
4987 
4994 // public constructors
4995 
4996 inline
4998  sc_fxval_fast_observer* observer_ )
4999 : m_val( a.to_double() ),
5000  m_observer( observer_ )
5001 {
5005 }
5006 
5007 inline
5009  sc_fxval_fast_observer* observer_ )
5010 : m_val( a.get_val() ),
5011  m_observer( observer_ )
5012 {
5016 }
5017 
5018 
5019 // binary functions
5020 
5021 #define DEFN_BIN_FNC_T(fnc,op,tp) \
5022 inline \
5023 void \
5024 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b ) \
5025 { \
5026  SC_FXVAL_FAST_OBSERVER_READ_( a ) \
5027  sc_fxval_fast tmp( b ); \
5028  c.m_val = a.m_val op tmp.m_val; \
5029  SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
5030 } \
5031  \
5032 inline \
5033 void \
5034 fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b ) \
5035 { \
5036  SC_FXVAL_FAST_OBSERVER_READ_( b ) \
5037  sc_fxval_fast tmp( a ); \
5038  c.m_val = tmp.m_val op b.m_val; \
5039  SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
5040 }
5041 
5042 #define DEFN_BIN_FNC(fnc,op) \
5043 DEFN_BIN_FNC_T(fnc,op,const sc_fxval&) \
5044 DEFN_BIN_FNC_T(fnc,op,const sc_fxnum&)
5045 
5046 DEFN_BIN_FNC(mult,*)
5047 DEFN_BIN_FNC(div,/)
5048 DEFN_BIN_FNC(add,+)
5049 DEFN_BIN_FNC(sub,-)
5050 
5051 #undef DEFN_BIN_FNC_T
5052 #undef DEFN_BIN_FNC
5053 
5054 
5055 // assignment operators
5056 
5057 inline
5059 sc_fxval_fast::operator = ( const sc_fxnum_fast& a )
5060 {
5061  m_val = a.get_val();
5063  return *this;
5064 }
5065 
5066 #define DEFN_ASN_OP_T(tp) \
5067 inline \
5068 sc_fxval_fast& \
5069 sc_fxval_fast::operator = ( tp a ) \
5070 { \
5071  sc_fxval_fast tmp( a ); \
5072  m_val = tmp.m_val; \
5073  SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
5074  return *this; \
5075 }
5076 
5077 DEFN_ASN_OP_T(const sc_fxnum&)
5078 
5079 #undef DEFN_ASN_OP_T
5080 
5081 
5082 #define DEFN_ASN_OP_T(op,tp) \
5083 inline \
5084 sc_fxval_fast& \
5085 sc_fxval_fast::operator op ( tp b ) \
5086 { \
5087  SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
5088  sc_fxval_fast tmp( b ); \
5089  m_val op tmp.m_val; \
5090  SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
5091  return *this; \
5092 }
5093 
5094 #define DEFN_ASN_OP(op) \
5095 inline \
5096 sc_fxval_fast& \
5097 sc_fxval_fast::operator op ( const sc_fxnum_fast& b ) \
5098 { \
5099  SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
5100  m_val op b.get_val(); \
5101  SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
5102  return *this; \
5103 } \
5104  \
5105 DEFN_ASN_OP_T(op,const sc_fxnum&)
5106 
5107 DEFN_ASN_OP(*=)
5108 DEFN_ASN_OP(/=)
5109 DEFN_ASN_OP(+=)
5110 DEFN_ASN_OP(-=)
5111 
5112 #undef DEFN_ASN_OP_T
5113 #undef DEFN_ASN_OP
5114 
5115 } // namespace sc_dt
5116 
5117 
5118 #endif
5119 
5120 // Taf!
int to_int() const
Definition: sc_fxnum.h:4568
#define DECL_ASN_OP_T(op, tp)
Definition: sc_fxnum.h:1226
bool quantization_flag() const
Definition: sc_fxnum.h:4681
const sc_time operator/(const sc_time &, double)
Definition: sc_time.h:413
int wl() const
Definition: sc_fxnum.h:4707
const sc_fxval_fast operator+() const
Definition: sc_fxnum.h:3809
int length() const
Definition: sc_bv_base.h:197
const sc_fxcast_switch & cast_switch() const
Definition: sc_fxnum.h:3611
Base class for the fixed-point types; limited precision.
Definition: sc_fxnum.h:991
friend class sc_fxnum
Definition: sc_fxval.h:98
int64 to_int64() const
Definition: sc_proxy.h:491
unsigned short to_ushort() const
Definition: sc_fxnum.h:4560
#define DECL_BIN_OP(op, dummy)
Definition: sc_fxnum.h:1085
inline ::std::ostream & operator<<(::std::ostream &os, const sc_fifo< T > &a)
Definition: sc_fifo.h:431
int length() const
Definition: sc_fxnum.h:2070
friend const sc_fxval operator<<(const sc_fxnum &, int)
Definition: sc_fxnum.h:2834
const sc_fxnum_fast_subref range() const
Definition: sc_fxnum.h:4525
sc_fxnum_fast_observer * observer() const
Definition: sc_fxnum.h:3688
#define DEFN_REL_OP(op)
Definition: sc_fxnum.h:4909
int64 to_int64() const
Definition: sc_fxnum.h:4576
#define DEFN_RED_FNC(fnc)
Definition: sc_fxnum.h:2397
#define SC_FXVAL_OBSERVER_WRITE_(object)
const T sc_min(const T &a, const T &b)
Definition: sc_macros.h:43
long to_long() const
Definition: sc_fxnum.h:2116
#define DEFN_ASN_OP(op)
Definition: sc_fxnum.h:5094
Fixed-point value types; limited precision.
Definition: sc_fxval.h:439
Convenient interface to union ieee_double.
Definition: scfx_ieee.h:120
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1545
const std::string to_string() const
Definition: sc_fxnum.h:2154
int to_int() const
Definition: sc_proxy.h:494
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:342
sc_enc
Enumeration of sign encodings.
Definition: sc_fxdefs.h:66
long to_long() const
Definition: sc_fxnum.h:4617
friend class sc_fxnum_fast
Definition: sc_fxval.h:442
const sc_fxcast_switch & cast_switch() const
Definition: sc_fxnum.h:4751
bool nor_reduce() const
#define DEFN_CTOR_T_D(tp)
Definition: sc_fxnum.h:2620
#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object)
double to_double() const
void lshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b)
Definition: sc_fxnum.h:4124
sc_o_mode o_mode() const
Definition: sc_fxnum.h:3588
int64_t int64
Definition: sc_nbdefs.h:188
Proxy class for part-selection in class sc_fxnum,.
Definition: sc_fxnum.h:239
Bit class.
Definition: sc_bit.h:92
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1577
int wl() const
Definition: sc_fxnum.h:3567
#define DEFN_CTOR_T_A(tp)
Definition: sc_fxnum.h:3749
#define DEFN_CTOR_T_C(tp)
Definition: sc_fxnum.h:3751
short to_short() const
Definition: sc_fxnum.h:3433
Base class for sc_uint.
Definition: sc_uint_base.h:534
#define SC_FXNUM_OBSERVER_READ_(object)
Fixed-point cast switch class.
const T sc_max(const T &a, const T &b)
Definition: sc_macros.h:51
friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
Definition: sc_fxnum.h:4116
void lshift(int)
int n_bits() const
Definition: scfx_params.h:194
bool set_bit(int, bool)
Definition: sc_fxnum.h:3639
sc_q_mode q_mode() const
Definition: sc_fxnum.h:4721
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1561
int iwl() const
Definition: sc_fxnum.h:4714
sc_fxval_fast(sc_fxval_fast_observer *=0)
Definition: sc_fxval.h:1555
#define SC_FXNUM_FAST_OBSERVER_READ_(object)
uint64 to_uint64() const
Definition: sc_fxnum.h:4592
int64 to_int64() const
Definition: sc_fxnum.h:3457
int fwl() const
Definition: scfx_params.h:173
double get_val() const
Definition: sc_fxnum.h:3790
void scan(::std::istream &=::std::cin)
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:444
Arbitrary precision signed number.
Definition: sc_signed.h:1099
#define DECL_ASN_OP_A(op)
Definition: sc_fxnum.h:455
const sc_time operator-(const sc_time &, const sc_time &)
Definition: sc_time.h:361
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
int n_bits() const
Definition: sc_fxnum.h:4735
const sc_fxval_fast operator-() const
Definition: sc_fxnum.h:3801
bool get_slice(int, int, sc_bv_base &) const
Definition: sc_fxnum.h:3650
Abstract base class for fixed-point types observers; limited precision.
void scan(::std::istream &=::std::cin)
uint64 to_uint64() const
Definition: sc_fxnum.h:3473
uint64_t uint64
Definition: sc_nbdefs.h:189
void observer_read() const
Definition: sc_fxnum.h:4760
Arbitrary precision unsigned number.
Definition: sc_unsigned.h:1001
float to_float() const
Definition: sc_fxnum.h:4633
Base class for the fixed-point types; arbitrary precision.
Definition: sc_fxnum.h:564
bool overflow_flag() const
Definition: sc_fxnum.h:4688
void rshift(int)
void print(::std::ostream &=::std::cout) const
bool get_bit(int) const
Definition: sc_fxnum.h:3629
double scfx_pow2(int exp)
Computes 2.
Definition: scfx_ieee.h:646
Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
Definition: sc_fxnum.h:167
void print(::std::ostream &=::std::cout) const
friend const sc_fxval operator/(const sc_fxnum &, const sc_fxnum &)
Definition: sc_fxnum.h:2785
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1005
int iwl() const
Definition: sc_fxnum.h:3574
void print(::std::ostream &=::std::cout) const
void rshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b)
Definition: sc_fxnum.h:4134
sc_fxnum_fast & operator--()
Definition: sc_fxnum.h:4416
long to_long() const
Definition: sc_proxy.h:500
void set_val(double)
Definition: sc_fxval.h:1635
bool is_neg() const
Definition: sc_fxnum.h:3516
void scan(::std::istream &=::std::cin)
const sc_fxval operator+() const
Definition: sc_fxnum.h:2679
DEFN_BIN_OP_T(/, div, int64) DEFN_BIN_OP_T(/
unsigned int to_uint() const
Definition: sc_fxnum.h:2449
int to_int() const
Definition: sc_fxnum.h:3449
#define DEFN_ASN_OP_T(tp)
Definition: sc_fxnum.h:5082
bool xnor_reduce() const
friend void neg(sc_fxval_fast &, const sc_fxnum_fast &)
Definition: sc_fxnum.h:3820
Base class for sc_int.
Definition: sc_int_base.h:548
Abstract base class for fixed-point value type observers;.
const sc_fxtype_params & type_params() const
Definition: sc_fxnum.h:4743
bool clear(int, const scfx_params &)
const sc_fxnum_fast_bitref bit(int) const
Definition: sc_fxnum.h:4447
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1569
int wl() const
Definition: scfx_params.h:159
float to_float() const
Definition: sc_fxnum.h:3497
Fixed-point value type; arbitrary precision.
Definition: sc_fxval.h:95
SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
Definition: scfx_rep.h:378
const std::string to_string() const
Definition: sc_fxnum.h:2505
const sc_fxnum_fast_bitref operator[](int) const
Definition: sc_fxnum.h:4430
Abstract base class for fixed-point types observers; arbitrary precision.
Arbitrary size logic vector base class.
Definition: sc_lv_base.h:91
inline ::std::istream & operator>>(::std::istream &is, sc_fxnum_fast &a)
Definition: sc_fxnum.h:4776
SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:396
bool set(int, const scfx_params &)
Arbitrary-precision fixed-point implementation class.
Definition: scfx_rep.h:144
Proxy class for part-selection in class sc_fxnum_fast,.
Definition: sc_fxnum.h:402
const sc_fxtype_params & type_params() const
Definition: scfx_params.h:135
unsigned long to_ulong() const
Definition: sc_fxnum.h:2125
int iwl() const
Definition: scfx_params.h:166
double to_double() const
Definition: sc_fxval.h:1427
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1553
int64 to_int64() const
Definition: sc_fxnum.h:2089
void print(::std::ostream &=::std::cout) const
bool is_neg() const
Definition: sc_fxnum.h:4652
bool is_normal() const
Definition: scfx_rep.h:458
#define DECL_BIN_OP_T(op, tp)
Definition: sc_fxnum.h:1069
#define SC_ERROR_IF_(cnd, id)
Definition: sc_fxdefs.h:267
const sc_fxnum_subref operator()() const
Definition: sc_fxnum.h:3392
sc_fmt
Enumeration of formats for character string conversion.
Definition: sc_fxdefs.h:172
bool is_normal() const
Definition: sc_fxnum.h:4671
sc_clock period is zero sc_clock low time is zero sc_fifo< T > cannot have more than one writer bind interface to port failed complete binding failed remove port failed insert primitive channel failed sc_signal< T > cannot have more than one driver resolved port not bound to resolved signal sc_semaphore requires an initial value
friend const sc_fxval_fast operator>>(const sc_fxnum_fast &, int)
Definition: sc_fxnum.h:3966
friend class sc_fxnum_fast_subref
Definition: sc_fxnum.h:998
SC_API const std::string to_string(sc_enc)
unsigned int to_uint() const
Definition: sc_fxnum.h:3465
Abstract base class for fixed-point value type observers;.
SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:405
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
bool set_slice(int, int, const sc_bv_base &)
Definition: sc_fxnum.h:3657
long to_long() const
Definition: sc_fxnum.h:3481
bool overflow_flag() const
Definition: sc_fxnum.h:3548
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
void neg(sc_fxnum_fast &c, const sc_fxnum_fast &a)
Definition: sc_fxnum.h:3828
void set_rep(scfx_rep *)
Definition: sc_fxval.h:872
friend class sc_fxval_fast
Definition: sc_fxnum.h:993
bool get_bit(int) const
Fixed-point type parameters class.
short to_short() const
Definition: sc_fxnum.h:4552
#define DECL_REL_OP(op)
Definition: sc_fxnum.h:1200
friend void rshift(sc_fxval &, const sc_fxnum &, int)
Definition: sc_fxnum.h:2997
uint64 to_uint64() const
sc_numrep
Enumeration of number representations for character string conversion.
Definition: sc_nbdefs.h:97
int to_int() const
Definition: sc_fxnum.h:2080
bool is_normal() const
Definition: sc_fxnum.h:3533
friend class sc_fxnum_bitref
Definition: sc_fxnum.h:568
#define DECL_CTOR_T(tp)
Definition: sc_fxnum.h:1018
void print(::std::ostream &=::std::cout) const
#define SC_FXNUM_OBSERVER_DESTRUCT_(object)
bool is_zero() const
Definition: sc_fxnum.h:3524
#define SC_FXNUM_OBSERVER_WRITE_(object)
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
#define DECL_ASN_OP(op)
Definition: sc_fxnum.h:1241
friend const sc_fxval operator>>(const sc_fxnum &, int)
Definition: sc_fxnum.h:2842
#define DEFN_BIN_FNC(fnc)
Definition: sc_fxnum.h:5042
const sc_time operator+(const sc_time &, const sc_time &)
Definition: sc_time.h:354
uint64 to_uint64() const
Definition: sc_fxnum.h:2458
unsigned long to_ulong() const
Definition: sc_proxy.h:503
sc_fxnum_observer * observer() const
Definition: sc_fxnum.h:2564
#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
#define DEFN_CTOR_T_B(tp)
Definition: sc_fxnum.h:3750
sc_o_mode o_mode() const
Definition: scfx_params.h:187
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:546
friend void neg(sc_fxval &, const sc_fxnum &)
Definition: sc_fxnum.h:2690
unsigned long to_ulong() const
Definition: sc_fxnum.h:4625
uint64 to_uint64() const
Definition: sc_proxy.h:1471
double to_double() const
Definition: sc_fxnum.h:4641
#define SC_FXNUM_FAST_OBSERVER_DEFAULT_
const scfx_rep * get_rep() const
Definition: sc_fxval.h:863
const sc_fxnum_subref range() const
Definition: sc_fxnum.h:3406
#define SC_FXVAL_OBSERVER_DEFAULT_
sc_q_mode
Enumeration of quantization modes.
Definition: sc_fxdefs.h:90
unsigned long to_ulong() const
Definition: sc_fxnum.h:3489
double get_val() const
Definition: sc_fxval.h:1626
bool xor_reduce() const
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
sc_fxnum_fast & operator++()
Definition: sc_fxnum.h:4405
sc_q_mode q_mode() const
Definition: sc_fxnum.h:3581
friend class sc_fxnum_subref
Definition: sc_fxnum.h:569
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
friend const sc_fxval_fast operator/(const sc_fxnum_fast &, const sc_fxnum_fast &)
Definition: sc_fxnum.h:3911
SC_API scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object)
friend class sc_fxval
Definition: sc_fxnum.h:566
sc_fxnum & operator++()
Definition: sc_fxnum.h:3293
#define DECL_BIN_FNC(fnc)
Definition: sc_fxnum.h:1150
unsigned int to_uint() const
Definition: sc_fxnum.h:2098
const sc_fxval operator-() const
Definition: sc_fxnum.h:2671
const sc_fxnum_fast_subref operator()() const
Definition: sc_fxnum.h:4511
bool quantization_flag() const
Definition: sc_fxnum.h:3541
unsigned int to_uint() const
Definition: sc_fxnum.h:4584
const sc_fxval value() const
Definition: sc_fxnum.h:3556
friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
Definition: sc_fxnum.h:4108
bool is_neg() const
Definition: scfx_rep.h:421
unsigned long to_ulong() const
Definition: sc_fxnum.h:2476
#define SC_FXNUM_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
int n_bits() const
Definition: sc_fxnum.h:3595
friend void lshift(sc_fxval &, const sc_fxnum &, int)
Definition: sc_fxnum.h:2989
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:390
sc_o_mode o_mode() const
Definition: sc_fxnum.h:4728
const sc_fxtype_params & type_params() const
Definition: sc_fxnum.h:3603
const sc_fxval_fast value() const
Definition: sc_fxnum.h:4696
friend class sc_fxnum_fast_bitref
Definition: sc_fxnum.h:997
const sc_fxcast_switch & cast_switch() const
Definition: scfx_params.h:149
sc_o_mode
Enumeration of overflow modes.
Definition: sc_fxdefs.h:119
void observer_read() const
Definition: sc_fxnum.h:3620
Arbitrary size logic vector class.
Arbitrary size bit vector base class.
Definition: sc_bv_base.h:80
bool nand_reduce() const
Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
Definition: sc_fxnum.h:96
bool is_zero() const
Definition: scfx_rep.h:428
bool is_zero() const
Definition: sc_fxnum.h:4661
const scfx_rep * get_rep() const
Definition: sc_fxnum.h:2660
unsigned int to_uint() const
Definition: sc_proxy.h:497
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1537
#define DEFN_BIN_OP(op, fnc)
Definition: sc_fxnum.h:4835
void scan(::std::istream &=::std::cin)
void scan(::std::istream &=::std::cin)
bool or_reduce() const
sc_fxval(scfx_rep *)
Definition: sc_fxval.h:784
#define SC_FXNUM_OBSERVER_CONSTRUCT_(object)
uint64 to_uint64() const
Definition: sc_fxnum.h:2107
#define SC_API
Definition: sc_cmnhdr.h:168
inline ::std::istream & operator>>(::std::istream &is, sc_bit &a)
Definition: sc_bit.h:398
sc_fxnum & operator--()
Definition: sc_fxnum.h:3301
double to_double() const
Definition: sc_fxnum.h:3505
const sc_fxnum_bitref operator[](int) const
Definition: sc_fxnum.h:3312
sc_q_mode q_mode() const
Definition: scfx_params.h:180
const sc_fxnum_bitref bit(int) const
Definition: sc_fxnum.h:3329
unsigned short to_ushort() const
Definition: sc_fxnum.h:3441
bool and_reduce() const
static const uint64 UINT64_ONE
Definition: sc_nbdefs.h:198
const std::string to_string() const
Definition: sc_proxy.h:1385