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