gem5  v20.1.0.0
sc_fxnum.hh
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_fxnum.h -
23 
24  Original Author: Martin Janssen, Synopsys, Inc.
25 
26  *****************************************************************************/
27 
28 /*****************************************************************************
29 
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32 
33  Name, Affiliation, Date:
34  Description of Modification:
35 
36  *****************************************************************************/
37 
38 // $Log: sc_fxnum.h,v $
39 // Revision 1.5 2011/08/29 18:04:32 acg
40 // Philipp A. Hartmann: miscellaneous clean ups.
41 //
42 // Revision 1.4 2011/08/24 22:05:43 acg
43 // Torsten Maehne: initialization changes to remove warnings.
44 //
45 // Revision 1.3 2011/01/19 18:57:40 acg
46 // Andy Goodrich: changes for IEEE_1666_2011.
47 //
48 // Revision 1.2 2009/03/09 17:26:46 acg
49 // Andy Goodrich: removed ; from namespace { }
50 //
51 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
52 // SystemC 2.3
53 //
54 // Revision 1.3 2006/01/13 18:53:58 acg
55 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
56 // the source.
57 //
58 
59 #ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
60 #define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
61 
62 #include <iostream>
63 
64 #include "../bit/sc_lv_base.hh"
65 #include "messages.hh"
66 #include "sc_fxnum_observer.hh"
67 #include "sc_fxval.hh"
68 #include "scfx_params.hh"
69 
70 namespace sc_gem5
71 {
72 
73 template <typename T, typename B>
74 class TraceValFxnumBase;
75 
76 } // namespace sc_core
77 
78 
79 namespace sc_dt
80 {
81 
82 // classes defined in this module
83 class sc_fxnum_bitref;
84 class sc_fxnum_fast_bitref;
85 class sc_fxnum_subref;
86 class sc_fxnum_fast_subref;
87 class sc_fxnum;
88 class sc_fxnum_fast;
89 
90 
91 // ----------------------------------------------------------------------------
92 // CLASS : sc_fxnum_bitref
93 //
94 // Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
95 // ----------------------------------------------------------------------------
96 
98 {
99  friend class sc_fxnum;
100  friend class sc_fxnum_fast_bitref;
101 
102  bool get() const;
103  void set(bool);
104 
105  // constructor
106  sc_fxnum_bitref(sc_fxnum &, int);
107 
108  public:
109  // copy constructor
111 
112  // assignment operators
113 #define DECL_ASN_OP_T(op, tp) \
114  sc_fxnum_bitref &operator op (tp);
115 
116 #define DECL_ASN_OP(op) \
117  DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
118  DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
119  DECL_ASN_OP_T(op, const sc_bit &) \
120  DECL_ASN_OP_T(op, bool)
121 
122  DECL_ASN_OP(=)
123 
124  DECL_ASN_OP(&=)
125  DECL_ASN_OP(|=)
126  DECL_ASN_OP(^=)
127 
128 #undef DECL_ASN_OP_T
129 #undef DECL_ASN_OP
130 
131  // implicit conversion
132  operator bool() const;
133 
134  // print or dump content
135  void print(::std::ostream & =::std::cout) const;
136  void scan(::std::istream & =::std::cin);
137  void dump(::std::ostream & =::std::cout) const;
138 
139  private:
141  int m_idx;
142 
143  private:
144  // disabled
145  sc_fxnum_bitref();
146 };
147 
148 
149 // ----------------------------------------------------------------------------
150 // CLASS : sc_fxnum_fast_bitref
151 //
152 // Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
153 // ----------------------------------------------------------------------------
154 
156 {
157  friend class sc_fxnum_fast;
158  friend class sc_fxnum_bitref;
159 
160  bool get() const;
161  void set(bool);
162 
163  // constructor
165 
166  public:
167  // copy constructor
169 
170  // assignment operators
171 #define DECL_ASN_OP_T(op, tp) sc_fxnum_fast_bitref &operator op (tp);
172 
173 #define DECL_ASN_OP(op) \
174  DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
175  DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
176  DECL_ASN_OP_T(op, const sc_bit &) \
177  DECL_ASN_OP_T(op, bool)
178 
179  DECL_ASN_OP(=)
180 
181  DECL_ASN_OP(&=)
182  DECL_ASN_OP(|=)
183  DECL_ASN_OP(^=)
184 
185 #undef DECL_ASN_OP_T
186 #undef DECL_ASN_OP
187 
188  // implicit conversion
189  operator bool() const;
190 
191  // print or dump content
192  void print(::std::ostream & =::std::cout) const;
193  void scan(::std::istream & =::std::cin);
194  void dump(::std::ostream & =::std::cout) const;
195 
196  private:
198  int m_idx;
199 
200  private:
201  // Disabled
203 };
204 
205 
206 // ----------------------------------------------------------------------------
207 // CLASS : sc_fxnum_subref
208 //
209 // Proxy class for part-selection in class sc_fxnum,
210 // behaves like sc_bv_base.
211 // ----------------------------------------------------------------------------
212 
214 {
215  friend class sc_fxnum;
216  friend class sc_fxnum_fast_subref;
217 
218  bool get() const;
219  bool set();
220 
221  // constructor
222  sc_fxnum_subref(sc_fxnum &, int, int);
223 
224  public:
225  // copy constructor
227 
228  // destructor
230 
231  // assignment operators
232 #define DECL_ASN_OP_T(tp) \
233  sc_fxnum_subref &operator = (tp);
234 
237  DECL_ASN_OP_T(const sc_bv_base &)
238  DECL_ASN_OP_T(const sc_lv_base &)
239  DECL_ASN_OP_T(const char *)
240  DECL_ASN_OP_T(const bool *)
241  DECL_ASN_OP_T(const sc_signed &)
242  DECL_ASN_OP_T(const sc_unsigned &)
243  DECL_ASN_OP_T(const sc_int_base &)
244  DECL_ASN_OP_T(const sc_uint_base &)
247  DECL_ASN_OP_T(int)
248  DECL_ASN_OP_T(unsigned int)
249  DECL_ASN_OP_T(long)
250  DECL_ASN_OP_T(unsigned long)
251  DECL_ASN_OP_T(char)
252 
253 #undef DECL_ASN_OP_T
254 
255 #define DECL_ASN_OP_T_A(op, tp) \
256  sc_fxnum_subref &operator op ## = (tp);
257 
258 #define DECL_ASN_OP_A(op) \
259  DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
260  DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
261  DECL_ASN_OP_T_A(op, const sc_bv_base &) \
262  DECL_ASN_OP_T_A(op, const sc_lv_base &)
263 
264  DECL_ASN_OP_A( &)
265  DECL_ASN_OP_A(|)
266  DECL_ASN_OP_A(^)
267 
268 #undef DECL_ASN_OP_T_A
269 #undef DECL_ASN_OP_A
270 
271  // relational operators
272 #define DECL_REL_OP_T(op, tp) \
273  friend bool operator op (const sc_fxnum_subref &, tp); \
274  friend bool operator op (tp, const sc_fxnum_subref &);
275 
276 #define DECL_REL_OP(op) \
277  friend bool operator op (const sc_fxnum_subref &, \
278  const sc_fxnum_subref &); \
279  friend bool operator op (const sc_fxnum_subref &, \
280  const sc_fxnum_fast_subref &); \
281  DECL_REL_OP_T(op, const sc_bv_base &) \
282  DECL_REL_OP_T(op, const sc_lv_base &) \
283  DECL_REL_OP_T(op, const char *) \
284  DECL_REL_OP_T(op, const bool *) \
285  DECL_REL_OP_T(op, const sc_signed &) \
286  DECL_REL_OP_T(op, const sc_unsigned &) \
287  DECL_REL_OP_T(op, int) \
288  DECL_REL_OP_T(op, unsigned int) \
289  DECL_REL_OP_T(op, long) \
290  DECL_REL_OP_T(op, unsigned long)
291 
292  DECL_REL_OP(==)
293  DECL_REL_OP(!=)
294 
295 #undef DECL_REL_OP_T
296 #undef DECL_REL_OP
297 
298  // reduce functions
299  bool and_reduce() const;
300  bool nand_reduce() const;
301  bool or_reduce() const;
302  bool nor_reduce() const;
303  bool xor_reduce() const;
304  bool xnor_reduce() const;
305 
306  // query parameter
307  int length() const;
308 
309  // explicit conversions
310  int to_int() const;
311  unsigned int to_uint() const;
312  long to_long() const;
313  unsigned long to_ulong() const;
314  int64 to_int64() const;
315  uint64 to_uint64() const;
316 
317  const std::string to_string() const;
318  const std::string to_string(sc_numrep) const;
319  const std::string to_string(sc_numrep, bool) const;
320 
321  // implicit conversion
322  operator sc_bv_base() const;
323 
324  // print or dump content
325  void print(::std::ostream & =::std::cout) const;
326  void scan(::std::istream & =::std::cin);
327  void dump(::std::ostream & =::std::cout) const;
328 
329  private:
331  int m_from;
332  int m_to;
333 
335 
336  private:
337  // Disabled
338  sc_fxnum_subref();
339 };
340 
341 
342 // ----------------------------------------------------------------------------
343 // CLASS : sc_fxnum_fast_subref
344 //
345 // Proxy class for part-selection in class sc_fxnum_fast,
346 // behaves like sc_bv_base.
347 // ----------------------------------------------------------------------------
348 
350 {
351  friend class sc_fxnum_fast;
352  friend class sc_fxnum_subref;
353 
354  bool get() const;
355  bool set();
356 
357  // constructor
358  sc_fxnum_fast_subref(sc_fxnum_fast &, int, int);
359 
360  public:
361  // copy constructor
363 
364  // destructor
366 
367  // assignment operators
368 #define DECL_ASN_OP_T(tp) \
369  sc_fxnum_fast_subref &operator = (tp);
370 
373  DECL_ASN_OP_T(const sc_bv_base &)
374  DECL_ASN_OP_T(const sc_lv_base &)
375  DECL_ASN_OP_T(const char *)
376  DECL_ASN_OP_T(const bool *)
377  DECL_ASN_OP_T(const sc_signed &)
378  DECL_ASN_OP_T(const sc_unsigned &)
379  DECL_ASN_OP_T(const sc_int_base &)
380  DECL_ASN_OP_T(const sc_uint_base &)
383  DECL_ASN_OP_T(int)
384  DECL_ASN_OP_T(unsigned int)
385  DECL_ASN_OP_T(long)
386  DECL_ASN_OP_T(unsigned long)
387  DECL_ASN_OP_T(char)
388 
389 #undef DECL_ASN_OP_T
390 
391 #define DECL_ASN_OP_T_A(op, tp) sc_fxnum_fast_subref &operator op ## = (tp);
392 
393 #define DECL_ASN_OP_A(op) \
394  DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
395  DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
396  DECL_ASN_OP_T_A(op, const sc_bv_base &) \
397  DECL_ASN_OP_T_A(op, const sc_lv_base &)
398 
399  DECL_ASN_OP_A(&)
400  DECL_ASN_OP_A(|)
401  DECL_ASN_OP_A(^)
402 
403 #undef DECL_ASN_OP_T_A
404 #undef DECL_ASN_OP_A
405 
406  // relational operators
407 #define DECL_REL_OP_T(op, tp) \
408  friend bool operator op (const sc_fxnum_fast_subref &, tp); \
409  friend bool operator op (tp, const sc_fxnum_fast_subref &);
410 
411 #define DECL_REL_OP(op) \
412  friend bool operator op (const sc_fxnum_fast_subref &, \
413  const sc_fxnum_fast_subref &); \
414  friend bool operator op (const sc_fxnum_fast_subref &, \
415  const sc_fxnum_subref &); \
416  DECL_REL_OP_T(op, const sc_bv_base &) \
417  DECL_REL_OP_T(op, const sc_lv_base &) \
418  DECL_REL_OP_T(op, const char *) \
419  DECL_REL_OP_T(op, const bool *) \
420  DECL_REL_OP_T(op, const sc_signed &) \
421  DECL_REL_OP_T(op, const sc_unsigned &) \
422  DECL_REL_OP_T(op, int) \
423  DECL_REL_OP_T(op, unsigned int) \
424  DECL_REL_OP_T(op, long) \
425  DECL_REL_OP_T(op, unsigned long)
426 
427  DECL_REL_OP(==)
428  DECL_REL_OP(!=)
429 
430 #undef DECL_REL_OP_T
431 #undef DECL_REL_OP
432 
433  // reduce functions
434  bool and_reduce() const;
435  bool nand_reduce() const;
436  bool or_reduce() const;
437  bool nor_reduce() const;
438  bool xor_reduce() const;
439  bool xnor_reduce() const;
440 
441  // query parameter
442  int length() const;
443 
444  // explicit conversions
445  int to_int() const;
446  unsigned int to_uint() const;
447  long to_long() const;
448  unsigned long to_ulong() const;
449  int64 to_int64() const;
450  uint64 to_uint64() const;
451 
452  const std::string to_string() const;
453  const std::string to_string(sc_numrep) const;
454  const std::string to_string(sc_numrep, bool) const;
455 
456  // implicit conversion
457  operator sc_bv_base() const;
458 
459  // print or dump content
460  void print(::std::ostream & =::std::cout) const;
461  void scan(::std::istream & =::std::cin);
462  void dump(::std::ostream & =::std::cout) const;
463 
464  private:
466  int m_from;
467  int m_to;
468 
470 
471  private:
472  // Disabled
474 };
475 
476 
477 // ----------------------------------------------------------------------------
478 // CLASS : sc_fxnum
479 //
480 // Base class for the fixed-point types; arbitrary precision.
481 // ----------------------------------------------------------------------------
482 
483 class sc_fxnum
484 {
485  friend class sc_fxval;
486 
487  friend class sc_fxnum_bitref;
488  friend class sc_fxnum_subref;
489  friend class sc_fxnum_fast_bitref;
490  friend class sc_fxnum_fast_subref;
491 
492  template <typename T, typename B>
494 
495  protected:
496  sc_fxnum_observer *observer() const;
497 
498  void cast();
499 
500  // constructors
503 
504 #define DECL_CTOR_T(tp) \
505  sc_fxnum(tp, const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, \
506  sc_fxnum_observer *);
507 
508  DECL_CTOR_T(int)
509  DECL_CTOR_T(unsigned int)
510  DECL_CTOR_T(long)
511  DECL_CTOR_T(unsigned long)
512  DECL_CTOR_T(float)
513  DECL_CTOR_T(double)
514  DECL_CTOR_T(const char *)
515  DECL_CTOR_T(const sc_fxval &)
516  DECL_CTOR_T(const sc_fxval_fast &)
517  DECL_CTOR_T(const sc_fxnum &)
518  DECL_CTOR_T(const sc_fxnum_fast &)
519 
522  DECL_CTOR_T(const sc_int_base &)
523  DECL_CTOR_T(const sc_uint_base &)
524  DECL_CTOR_T(const sc_signed &)
525  DECL_CTOR_T(const sc_unsigned &)
526 
527 #undef DECL_CTOR_T
528 
529  ~sc_fxnum();
530 
531  // internal use only;
532  const scfx_rep *get_rep() const;
533 
534  public:
535  // unary operators
536  const sc_fxval operator - () const;
537  const sc_fxval operator + () const;
538 
539  // unary functions
540  friend void neg(sc_fxval &, const sc_fxnum &);
541  friend void neg(sc_fxnum &, const sc_fxnum &);
542 
543  // binary operators
544 #define DECL_BIN_OP_T(op, tp) \
545  friend const sc_fxval operator op (const sc_fxnum &, tp); \
546  friend const sc_fxval operator op (tp, const sc_fxnum &);
547 
548 #define DECL_BIN_OP_OTHER(op) \
549  DECL_BIN_OP_T(op, int64) \
550  DECL_BIN_OP_T(op, uint64) \
551  DECL_BIN_OP_T(op, const sc_int_base &) \
552  DECL_BIN_OP_T(op, const sc_uint_base &) \
553  DECL_BIN_OP_T(op, const sc_signed &) \
554  DECL_BIN_OP_T(op, const sc_unsigned &)
555 
556 #define DECL_BIN_OP(op, dummy) \
557  friend const sc_fxval operator op (const sc_fxnum &, const sc_fxnum &); \
558  DECL_BIN_OP_T(op, int) \
559  DECL_BIN_OP_T(op, unsigned int) \
560  DECL_BIN_OP_T(op, long) \
561  DECL_BIN_OP_T(op, unsigned long) \
562  DECL_BIN_OP_T(op, float) \
563  DECL_BIN_OP_T(op, double) \
564  DECL_BIN_OP_T(op, const char *) \
565  DECL_BIN_OP_T(op, const sc_fxval &) \
566  DECL_BIN_OP_T(op, const sc_fxval_fast &) \
567  DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
568  DECL_BIN_OP_OTHER(op)
569 
570  DECL_BIN_OP(*, mult)
571  DECL_BIN_OP(+, add)
572  DECL_BIN_OP(-, sub)
573 // don't use macros
574 // DECL_BIN_OP(/, div)
575  friend const sc_fxval operator / (const sc_fxnum &, const sc_fxnum &);
576  DECL_BIN_OP_T(/, int)
577  DECL_BIN_OP_T(/, unsigned int)
578  DECL_BIN_OP_T(/, long)
579  DECL_BIN_OP_T(/, unsigned long)
580  DECL_BIN_OP_T(/, float)
581  DECL_BIN_OP_T(/, double)
582  DECL_BIN_OP_T(/, const char *)
583  DECL_BIN_OP_T(/, const sc_fxval &)
584  DECL_BIN_OP_T(/, const sc_fxval_fast &)
585  DECL_BIN_OP_T(/, const sc_fxnum_fast &)
586 // DECL_BIN_OP_OTHER(op)
587 
588  DECL_BIN_OP_T(/, int64)
590  DECL_BIN_OP_T(/, const sc_int_base &)
591  DECL_BIN_OP_T(/, const sc_uint_base &)
592  DECL_BIN_OP_T(/, const sc_signed &)
593  DECL_BIN_OP_T(/, const sc_unsigned &)
594 
595 #undef DECL_BIN_OP_T
596 #undef DECL_BIN_OP_OTHER
597 #undef DECL_BIN_OP
598 
599  friend const sc_fxval operator << (const sc_fxnum &, int);
600  friend const sc_fxval operator >> (const sc_fxnum &, int);
601 
602  // binary functions
603 #define DECL_BIN_FNC_T(fnc, tp) \
604  friend void fnc (sc_fxval &, const sc_fxnum &, tp); \
605  friend void fnc (sc_fxval &, tp, const sc_fxnum &); \
606  friend void fnc (sc_fxnum &, const sc_fxnum &, tp); \
607  friend void fnc (sc_fxnum &, tp, const sc_fxnum &);
608 
609 #define DECL_BIN_FNC_OTHER(fnc) \
610  DECL_BIN_FNC_T(fnc, int64) \
611  DECL_BIN_FNC_T(fnc, uint64) \
612  DECL_BIN_FNC_T(fnc, const sc_int_base &) \
613  DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
614  DECL_BIN_FNC_T(fnc, const sc_signed &) \
615  DECL_BIN_FNC_T(fnc, const sc_unsigned &)
616 
617 #define DECL_BIN_FNC(fnc) \
618  friend void fnc (sc_fxval &, const sc_fxnum &, const sc_fxnum &); \
619  friend void fnc (sc_fxnum &, const sc_fxnum &, const sc_fxnum &); \
620  DECL_BIN_FNC_T(fnc, int) \
621  DECL_BIN_FNC_T(fnc, unsigned int) \
622  DECL_BIN_FNC_T(fnc, long) \
623  DECL_BIN_FNC_T(fnc, unsigned long) \
624  DECL_BIN_FNC_T(fnc, float) \
625  DECL_BIN_FNC_T(fnc, double) \
626  DECL_BIN_FNC_T(fnc, const char *) \
627  DECL_BIN_FNC_T(fnc, const sc_fxval &) \
628  DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
629  DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
630  DECL_BIN_FNC_OTHER(fnc)
631 
632  DECL_BIN_FNC(mult)
633  DECL_BIN_FNC(div)
634  DECL_BIN_FNC(add)
635  DECL_BIN_FNC(sub)
636 
637 #undef DECL_BIN_FNC_T
638 #undef DECL_BIN_FNC_OTHER
639 #undef DECL_BIN_FNC
640 
641  friend void lshift(sc_fxval &, const sc_fxnum &, int);
642  friend void rshift(sc_fxval &, const sc_fxnum &, int);
643  friend void lshift(sc_fxnum &, const sc_fxnum &, int);
644  friend void rshift(sc_fxnum &, const sc_fxnum &, int);
645 
646  // relational (including equality) operators
647 #define DECL_REL_OP_T(op, tp) \
648  friend bool operator op (const sc_fxnum &, tp); \
649  friend bool operator op (tp, const sc_fxnum &);
650 
651 #define DECL_REL_OP_OTHER(op) \
652  DECL_REL_OP_T(op, int64) \
653  DECL_REL_OP_T(op, uint64) \
654  DECL_REL_OP_T(op, const sc_int_base &) \
655  DECL_REL_OP_T(op, const sc_uint_base &) \
656  DECL_REL_OP_T(op, const sc_signed &) \
657  DECL_REL_OP_T(op, const sc_unsigned &)
658 
659 #define DECL_REL_OP(op) \
660  friend bool operator op (const sc_fxnum &, const sc_fxnum &); \
661  DECL_REL_OP_T(op, int) \
662  DECL_REL_OP_T(op, unsigned int) \
663  DECL_REL_OP_T(op, long) \
664  DECL_REL_OP_T(op, unsigned long) \
665  DECL_REL_OP_T(op, float) \
666  DECL_REL_OP_T(op, double) \
667  DECL_REL_OP_T(op, const char *) \
668  DECL_REL_OP_T(op, const sc_fxval &) \
669  DECL_REL_OP_T(op, const sc_fxval_fast &) \
670  DECL_REL_OP_T(op, const sc_fxnum_fast &) \
671  DECL_REL_OP_OTHER(op)
672 
673  DECL_REL_OP(<)
674  DECL_REL_OP(<=)
675  DECL_REL_OP(>)
676  DECL_REL_OP(>=)
677  DECL_REL_OP(==)
678  DECL_REL_OP(!=)
679 
680 #undef DECL_REL_OP_T
681 #undef DECL_REL_OP_OTHER
682 #undef DECL_REL_OP
683 
684  // assignment operators
685 #define DECL_ASN_OP_T(op, tp) \
686  sc_fxnum &operator op(tp);
687 
688 #define DECL_ASN_OP_OTHER(op) \
689  DECL_ASN_OP_T(op, int64) \
690  DECL_ASN_OP_T(op, uint64) \
691  DECL_ASN_OP_T(op, const sc_int_base &) \
692  DECL_ASN_OP_T(op, const sc_uint_base &) \
693  DECL_ASN_OP_T(op, const sc_signed &) \
694  DECL_ASN_OP_T(op, const sc_unsigned &)
695 
696 #define DECL_ASN_OP(op) \
697  DECL_ASN_OP_T(op, int) \
698  DECL_ASN_OP_T(op, unsigned int) \
699  DECL_ASN_OP_T(op, long) \
700  DECL_ASN_OP_T(op, unsigned long) \
701  DECL_ASN_OP_T(op, float) \
702  DECL_ASN_OP_T(op, double) \
703  DECL_ASN_OP_T(op, const char *) \
704  DECL_ASN_OP_T(op, const sc_fxval &) \
705  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
706  DECL_ASN_OP_T(op, const sc_fxnum &) \
707  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
708  DECL_ASN_OP_OTHER(op)
709 
710  DECL_ASN_OP(=)
711 
712  DECL_ASN_OP(*=)
713  DECL_ASN_OP(/=)
714  DECL_ASN_OP(+=)
715  DECL_ASN_OP(-=)
716 
717  DECL_ASN_OP_T(<<=, int)
718  DECL_ASN_OP_T(>>=, int)
719 
720 #undef DECL_ASN_OP_T
721 #undef DECL_ASN_OP_OTHER
722 #undef DECL_ASN_OP
723 
724  // auto-increment and auto-decrement
725  const sc_fxval operator ++ (int);
726  const sc_fxval operator -- (int);
727 
730 
731  // bit selection
732  const sc_fxnum_bitref operator [] (int) const;
734 
735  const sc_fxnum_bitref bit(int) const;
736  sc_fxnum_bitref bit(int);
737 
738  // part selection
739  const sc_fxnum_subref operator () (int, int) const;
740  sc_fxnum_subref operator () (int, int);
741 
742  const sc_fxnum_subref range(int, int) const;
743  sc_fxnum_subref range(int, int);
744 
745  const sc_fxnum_subref operator () () const;
747 
748  const sc_fxnum_subref range() const;
750 
751  // implicit conversion
752  operator double() const; // necessary evil!
753 
754  // explicit conversion to primitive types
755  short to_short() const;
756  unsigned short to_ushort() const;
757  int to_int() const;
758  unsigned int to_uint() const;
759  long to_long() const;
760  unsigned long to_ulong() const;
761  int64 to_int64() const;
762  uint64 to_uint64() const;
763  float to_float() const;
764  double to_double() const;
765 
766  // explicit conversion to character string
767  const std::string to_string() const;
768  const std::string to_string(sc_numrep) const;
769  const std::string to_string(sc_numrep, bool) const;
770  const std::string to_string(sc_fmt) const;
771  const std::string to_string(sc_numrep, sc_fmt) const;
772  const std::string to_string(sc_numrep, bool, sc_fmt) const;
773 
774  const std::string to_dec() const;
775  const std::string to_bin() const;
776  const std::string to_oct() const;
777  const std::string to_hex() const;
778 
779  // query value
780  bool is_neg() const;
781  bool is_zero() const;
782 
783  // internal use only;
784  bool is_normal() const;
785 
786  bool quantization_flag() const;
787  bool overflow_flag() const;
788 
789  const sc_fxval value() const;
790 
791  // query parameters
792  int wl() const;
793  int iwl() const;
794  sc_q_mode q_mode() const;
795  sc_o_mode o_mode() const;
796  int n_bits() const;
797 
798  const sc_fxtype_params &type_params() const;
799 
800  const sc_fxcast_switch &cast_switch() const;
801 
802  // print or dump content
803  void print(::std::ostream & =::std::cout) const;
804  void scan(::std::istream & =::std::cin);
805  void dump(::std::ostream & =::std::cout) const;
806 
807  // internal use only;
808  void observer_read() const;
809 
810  // internal use only;
811  bool get_bit(int) const;
812 
813  protected:
814  bool set_bit(int, bool);
815 
816  bool get_slice(int, int, sc_bv_base &) const;
817  bool set_slice(int, int, const sc_bv_base &);
818 
820  void unlock_observer(sc_fxnum_observer *) const;
821 
822  private:
824 
826  bool m_q_flag;
827  bool m_o_flag;
828 
830 
831  private:
832  // disabled
833  sc_fxnum();
834  sc_fxnum(const sc_fxnum &);
835 };
836 
837 
838 // ----------------------------------------------------------------------------
839 // CLASS : sc_fxnum_fast
840 //
841 // Base class for the fixed-point types; limited precision.
842 // ----------------------------------------------------------------------------
843 
845 {
846  friend class sc_fxval_fast;
847 
848  friend class sc_fxnum_bitref;
849  friend class sc_fxnum_subref;
850  friend class sc_fxnum_fast_bitref;
851  friend class sc_fxnum_fast_subref;
852 
853  template <typename T, typename B>
855 
856  protected:
858 
859  void cast();
860 
861  // constructors
864 
865 #define DECL_CTOR_T(tp) \
866  sc_fxnum_fast(tp, const sc_fxtype_params &, sc_enc, \
867  const sc_fxcast_switch &, sc_fxnum_fast_observer *);
868 
869  DECL_CTOR_T(int)
870  DECL_CTOR_T(unsigned int)
871  DECL_CTOR_T(long)
872  DECL_CTOR_T(unsigned long)
873  DECL_CTOR_T(float)
874  DECL_CTOR_T(double)
875  DECL_CTOR_T(const char *)
876  DECL_CTOR_T(const sc_fxval &)
877  DECL_CTOR_T(const sc_fxval_fast &)
878  DECL_CTOR_T(const sc_fxnum &)
879  DECL_CTOR_T(const sc_fxnum_fast &)
880 
883  DECL_CTOR_T(const sc_int_base &)
884  DECL_CTOR_T(const sc_uint_base &)
885  DECL_CTOR_T(const sc_signed &)
886  DECL_CTOR_T(const sc_unsigned &)
887 
888 #undef DECL_CTOR_T
889  ~sc_fxnum_fast();
890 
891  // internal use only;
892  double get_val() const;
893 
894  public:
895  // unary operators
896  const sc_fxval_fast operator - () const;
897  const sc_fxval_fast operator + () const;
898 
899  // unary functions
900  friend void neg(sc_fxval_fast &, const sc_fxnum_fast &);
901  friend void neg(sc_fxnum_fast &, const sc_fxnum_fast &);
902 
903 
904  // binary operators
905 #define DECL_BIN_OP_T(op, tp) \
906  friend const sc_fxval_fast operator op (const sc_fxnum_fast &, tp); \
907  friend const sc_fxval_fast operator op (tp, const sc_fxnum_fast &);
908 
909 #define DECL_BIN_OP_OTHER(op) \
910  DECL_BIN_OP_T(op, int64) \
911  DECL_BIN_OP_T(op, uint64) \
912  DECL_BIN_OP_T(op, const sc_int_base &) \
913  DECL_BIN_OP_T(op, const sc_uint_base &) \
914  DECL_BIN_OP_T(op, const sc_signed &) \
915  DECL_BIN_OP_T(op, const sc_unsigned &)
916 
917 #define DECL_BIN_OP(op, dummy) \
918  friend const sc_fxval_fast operator op (const sc_fxnum_fast &, \
919  const sc_fxnum_fast &); \
920  DECL_BIN_OP_T(op, int) \
921  DECL_BIN_OP_T(op, unsigned int) \
922  DECL_BIN_OP_T(op, long) \
923  DECL_BIN_OP_T(op, unsigned long) \
924  DECL_BIN_OP_T(op, float) \
925  DECL_BIN_OP_T(op, double) \
926  DECL_BIN_OP_T(op, const char *) \
927  DECL_BIN_OP_T(op, const sc_fxval_fast &) \
928  DECL_BIN_OP_OTHER(op)
929 
930  DECL_BIN_OP(*, mult)
931  DECL_BIN_OP(+, add)
932  DECL_BIN_OP(-, sub)
933 // DECL_BIN_OP(/, div)
934  friend const sc_fxval_fast operator / (const sc_fxnum_fast &,
935  const sc_fxnum_fast &);
936  DECL_BIN_OP_T(/, int)
937  DECL_BIN_OP_T(/, unsigned int)
938  DECL_BIN_OP_T(/, long)
939  DECL_BIN_OP_T(/, unsigned long)
940  DECL_BIN_OP_T(/, float)
941  DECL_BIN_OP_T(/, double)
942  DECL_BIN_OP_T(/, const char *)
943  DECL_BIN_OP_T(/, const sc_fxval_fast &)
944 // DECL_BIN_OP_OTHER(op)
945 
946  DECL_BIN_OP_T(/, int64) \
947  DECL_BIN_OP_T(/, uint64) \
948  DECL_BIN_OP_T(/, const sc_int_base &) \
949  DECL_BIN_OP_T(/, const sc_uint_base &) \
950  DECL_BIN_OP_T(/, const sc_signed &) \
951  DECL_BIN_OP_T(/, const sc_unsigned &)
952 
953 #undef DECL_BIN_OP_T
954 #undef DECL_BIN_OP_OTHER
955 #undef DECL_BIN_OP
956 
957  friend const sc_fxval_fast operator << (const sc_fxnum_fast &, int);
958  friend const sc_fxval_fast operator >> (const sc_fxnum_fast &, int);
959 
960  // binary functions
961 #define DECL_BIN_FNC_T(fnc, tp) \
962  friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, tp); \
963  friend void fnc (sc_fxval_fast &, tp, const sc_fxnum_fast &); \
964  friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, tp); \
965  friend void fnc (sc_fxnum_fast &, tp, const sc_fxnum_fast &);
966 
967 #define DECL_BIN_FNC_OTHER(fnc) \
968  DECL_BIN_FNC_T(fnc, int64) \
969  DECL_BIN_FNC_T(fnc, uint64) \
970  DECL_BIN_FNC_T(fnc, const sc_int_base &) \
971  DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
972  DECL_BIN_FNC_T(fnc, const sc_signed &) \
973  DECL_BIN_FNC_T(fnc, const sc_unsigned &)
974 
975 #define DECL_BIN_FNC(fnc) \
976  friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, \
977  const sc_fxnum_fast &); \
978  friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, \
979  const sc_fxnum_fast &); \
980  DECL_BIN_FNC_T(fnc, int) \
981  DECL_BIN_FNC_T(fnc, unsigned int) \
982  DECL_BIN_FNC_T(fnc, long) \
983  DECL_BIN_FNC_T(fnc, unsigned long) \
984  DECL_BIN_FNC_T(fnc, float) \
985  DECL_BIN_FNC_T(fnc, double) \
986  DECL_BIN_FNC_T(fnc, const char *) \
987  DECL_BIN_FNC_T(fnc, const sc_fxval &) \
988  DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
989  DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
990  DECL_BIN_FNC_OTHER(fnc)
991 
992  DECL_BIN_FNC(mult)
993  DECL_BIN_FNC(div)
994  DECL_BIN_FNC(add)
995  DECL_BIN_FNC(sub)
996 
997 #undef DECL_BIN_FNC_T
998 #undef DECL_BIN_FNC_OTHER
999 #undef DECL_BIN_FNC
1000 
1001  friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int);
1002  friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int);
1003  friend void lshift(sc_fxnum_fast &, const sc_fxnum_fast &, int);
1004  friend void rshift(sc_fxnum_fast &, const sc_fxnum_fast &, int);
1005 
1006  // relational (including equality) operators
1007 #define DECL_REL_OP_T(op, tp) \
1008  friend bool operator op (const sc_fxnum_fast &, tp); \
1009  friend bool operator op (tp, const sc_fxnum_fast &);
1010 
1011 #define DECL_REL_OP_OTHER(op) \
1012  DECL_REL_OP_T(op, int64) \
1013  DECL_REL_OP_T(op, uint64) \
1014  DECL_REL_OP_T(op, const sc_int_base &) \
1015  DECL_REL_OP_T(op, const sc_uint_base &) \
1016  DECL_REL_OP_T(op, const sc_signed &) \
1017  DECL_REL_OP_T(op, const sc_unsigned &)
1018 
1019 #define DECL_REL_OP(op) \
1020  friend bool operator op (const sc_fxnum_fast &, const sc_fxnum_fast &); \
1021  DECL_REL_OP_T(op, int) \
1022  DECL_REL_OP_T(op, unsigned int) \
1023  DECL_REL_OP_T(op, long) \
1024  DECL_REL_OP_T(op, unsigned long) \
1025  DECL_REL_OP_T(op, float) \
1026  DECL_REL_OP_T(op, double) \
1027  DECL_REL_OP_T(op, const char *) \
1028  DECL_REL_OP_T(op, const sc_fxval_fast &) \
1029  DECL_REL_OP_OTHER(op)
1030 
1031  DECL_REL_OP(<)
1032  DECL_REL_OP(<=)
1033  DECL_REL_OP(>)
1034  DECL_REL_OP(>=)
1035  DECL_REL_OP(==)
1036  DECL_REL_OP(!=)
1037 
1038 #undef DECL_REL_OP_T
1039 #undef DECL_REL_OP_OTHER
1040 #undef DECL_REL_OP
1041 
1042  // assignment operators
1043 #define DECL_ASN_OP_T(op, tp) sc_fxnum_fast &operator op(tp);
1044 
1045 #define DECL_ASN_OP_OTHER(op) \
1046  DECL_ASN_OP_T(op, int64) \
1047  DECL_ASN_OP_T(op, uint64) \
1048  DECL_ASN_OP_T(op, const sc_int_base &) \
1049  DECL_ASN_OP_T(op, const sc_uint_base &) \
1050  DECL_ASN_OP_T(op, const sc_signed &) \
1051  DECL_ASN_OP_T(op, const sc_unsigned &)
1052 
1053 #define DECL_ASN_OP(op) \
1054  DECL_ASN_OP_T(op, int) \
1055  DECL_ASN_OP_T(op, unsigned int) \
1056  DECL_ASN_OP_T(op, long) \
1057  DECL_ASN_OP_T(op, unsigned long) \
1058  DECL_ASN_OP_T(op, float) \
1059  DECL_ASN_OP_T(op, double) \
1060  DECL_ASN_OP_T(op, const char *) \
1061  DECL_ASN_OP_T(op, const sc_fxval &) \
1062  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
1063  DECL_ASN_OP_T(op, const sc_fxnum &) \
1064  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
1065  DECL_ASN_OP_OTHER(op)
1066 
1067  DECL_ASN_OP(=)
1068 
1069  DECL_ASN_OP(*=)
1070  DECL_ASN_OP(/=)
1071  DECL_ASN_OP(+=)
1072  DECL_ASN_OP(-=)
1073 
1074  DECL_ASN_OP_T(<<=, int)
1075  DECL_ASN_OP_T(>>=, int)
1076 
1077 #undef DECL_ASN_OP_T
1078 #undef DECL_ASN_OP_OTHER
1079 #undef DECL_ASN_OP
1080 
1081  // auto-increment and auto-decrement
1082  const sc_fxval_fast operator ++ (int);
1083  const sc_fxval_fast operator -- (int);
1084 
1087 
1088  // bit selection
1089  const sc_fxnum_fast_bitref operator [] (int) const;
1091 
1092  const sc_fxnum_fast_bitref bit(int) const;
1094 
1095  // part selection
1096  const sc_fxnum_fast_subref operator () (int, int) const;
1098 
1099  const sc_fxnum_fast_subref range(int, int) const;
1100  sc_fxnum_fast_subref range(int, int);
1101 
1102 
1103  const sc_fxnum_fast_subref operator () () const;
1105 
1106  const sc_fxnum_fast_subref range() const;
1108 
1109  // implicit conversion
1110  operator double() const; // necessary evil!
1111 
1112  // explicit conversion to primitive types
1113  short to_short() const;
1114  unsigned short to_ushort() const;
1115  int to_int() const;
1116  unsigned int to_uint() const;
1117  long to_long() const;
1118  unsigned long to_ulong() const;
1119  int64 to_int64() const;
1120  uint64 to_uint64() const;
1121  float to_float() const;
1122  double to_double() const;
1123 
1124  // explicit conversion to character string
1125  const std::string to_string() const;
1126  const std::string to_string(sc_numrep) const;
1127  const std::string to_string(sc_numrep, bool) const;
1128  const std::string to_string(sc_fmt) const;
1129  const std::string to_string(sc_numrep, sc_fmt) const;
1130  const std::string to_string(sc_numrep, bool, sc_fmt) const;
1131 
1132  const std::string to_dec() const;
1133  const std::string to_bin() const;
1134  const std::string to_oct() const;
1135  const std::string to_hex() const;
1136 
1137  // query value
1138  bool is_neg() const;
1139  bool is_zero() const;
1140 
1141  // internal use only;
1142  bool is_normal() const;
1143 
1144  bool quantization_flag() const;
1145  bool overflow_flag() const;
1146 
1147  const sc_fxval_fast value() const;
1148 
1149  // query parameters
1150  int wl() const;
1151  int iwl() const;
1152  sc_q_mode q_mode() const;
1153  sc_o_mode o_mode() const;
1154  int n_bits() const;
1155 
1156  const sc_fxtype_params &type_params() const;
1157 
1158  const sc_fxcast_switch &cast_switch() const;
1159 
1160  // print or dump content
1161  void print(::std::ostream & =::std::cout) const;
1162  void scan(::std::istream & =::std::cin);
1163  void dump(::std::ostream & =::std::cout) const;
1164 
1165  // internal use only;
1166  void observer_read() const;
1167 
1168  // internal use only;
1169  bool get_bit(int) const;
1170 
1171  protected:
1172  bool set_bit(int, bool);
1173 
1174  bool get_slice(int, int, sc_bv_base &) const;
1175  bool set_slice(int, int, const sc_bv_base &);
1176 
1177  sc_fxnum_fast_observer *lock_observer() const;
1178  void unlock_observer(sc_fxnum_fast_observer *) const;
1179 
1180  private:
1181  double m_val;
1182 
1184  bool m_q_flag;
1185  bool m_o_flag;
1186 
1188 
1189  private:
1190  // Disabled
1191  sc_fxnum_fast();
1192  sc_fxnum_fast(const sc_fxnum_fast &);
1193 };
1194 
1195 
1196 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
1197 
1198 // ----------------------------------------------------------------------------
1199 // CLASS : sc_fxnum_bitref
1200 //
1201 // Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
1202 // ----------------------------------------------------------------------------
1203 
1204 // constructor
1205 
1206 inline
1208  m_num(num_), m_idx(idx_)
1209 {}
1210 
1211 // copy constructor
1213  m_num(a.m_num), m_idx(a.m_idx)
1214 {}
1215 
1216 // assignment operators
1217 inline sc_fxnum_bitref &
1218 sc_fxnum_bitref::operator = (const sc_fxnum_bitref &a)
1219 {
1220  if (&a != this) {
1221  SC_FXNUM_OBSERVER_READ_(a.m_num)
1222  set(a.get());
1224  }
1225  return *this;
1226 }
1227 
1228 inline sc_fxnum_bitref &
1229 sc_fxnum_bitref::operator = (const sc_fxnum_fast_bitref &a)
1230 {
1232  set(a.get());
1234  return *this;
1235 }
1236 
1237 inline sc_fxnum_bitref &
1238 sc_fxnum_bitref::operator = (const sc_bit &a)
1239 {
1240  set(static_cast<bool>(a));
1242  return *this;
1243 }
1244 
1245 inline sc_fxnum_bitref &
1246 sc_fxnum_bitref::operator = (bool a)
1247 {
1248  set(a);
1250  return *this;
1251 }
1252 
1253 inline sc_fxnum_bitref &
1255 {
1257  SC_FXNUM_OBSERVER_READ_(b.m_num)
1258  set(get() && b.get());
1260  return *this;
1261 }
1262 
1263 inline sc_fxnum_bitref &
1264 sc_fxnum_bitref::operator &= (const sc_fxnum_fast_bitref &b)
1265 {
1268  set(get() && b.get());
1270  return *this;
1271 }
1272 
1273 inline sc_fxnum_bitref &
1274 sc_fxnum_bitref::operator &= (const sc_bit &b)
1275 {
1277  set(get() && static_cast<bool>(b));
1279  return *this;
1280 }
1281 
1282 inline sc_fxnum_bitref &
1284 {
1286  set(get() && b);
1288  return *this;
1289 }
1290 
1291 
1292 inline sc_fxnum_bitref &
1294 {
1296  SC_FXNUM_OBSERVER_READ_(b.m_num)
1297  set(get() || b.get());
1299  return *this;
1300 }
1301 
1302 inline sc_fxnum_bitref &
1303 sc_fxnum_bitref::operator |= (const sc_fxnum_fast_bitref &b)
1304 {
1307  set(get() || b.get());
1309  return *this;
1310 }
1311 
1312 inline sc_fxnum_bitref &
1313 sc_fxnum_bitref::operator |= (const sc_bit &b)
1314 {
1316  set(get() || static_cast<bool>(b));
1318  return *this;
1319 }
1320 
1321 inline sc_fxnum_bitref &
1323 {
1325  set(get() || b);
1327  return *this;
1328 }
1329 
1330 
1331 inline sc_fxnum_bitref &
1333 {
1335  SC_FXNUM_OBSERVER_READ_(b.m_num)
1336  set(get() != b.get());
1338  return *this;
1339 }
1340 
1341 inline sc_fxnum_bitref &
1342 sc_fxnum_bitref::operator ^= (const sc_fxnum_fast_bitref &b)
1343 {
1346  set(get() != b.get());
1348  return *this;
1349 }
1350 
1351 inline sc_fxnum_bitref &
1352 sc_fxnum_bitref::operator ^= (const sc_bit &b)
1353 {
1355  set(get() != static_cast<bool>(b));
1357  return *this;
1358 }
1359 
1360 inline sc_fxnum_bitref &
1362 {
1364  set(get() != b);
1366  return *this;
1367 }
1368 
1369 // implicit conversion
1370 inline sc_fxnum_bitref::operator bool() const
1371 {
1373  return get();
1374 }
1375 
1376 inline ::std::ostream &
1377 operator << (::std::ostream &os, const sc_fxnum_bitref &a)
1378 {
1379  a.print(os);
1380  return os;
1381 }
1382 
1383 inline ::std::istream &
1384 operator >> (::std::istream &is, sc_fxnum_bitref &a)
1385 {
1386  a.scan(is);
1387  return is;
1388 }
1389 
1390 
1391 // ----------------------------------------------------------------------------
1392 // CLASS : sc_fxnum_fast_bitref
1393 //
1394 // Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
1395 // ----------------------------------------------------------------------------
1396 
1397 // constructor
1399  sc_fxnum_fast &num_, int idx_) : m_num(num_), m_idx(idx_)
1400 {}
1401 
1402 // copy constructor
1404  const sc_fxnum_fast_bitref &a) : m_num(a.m_num), m_idx(a.m_idx)
1405 {}
1406 
1407 // assignment operators
1408 inline sc_fxnum_fast_bitref &
1409 sc_fxnum_fast_bitref::operator = (const sc_fxnum_bitref &a)
1410 {
1411  SC_FXNUM_OBSERVER_READ_(a.m_num)
1412  set(a.get());
1414  return *this;
1415 }
1416 
1417 inline sc_fxnum_fast_bitref &
1418 sc_fxnum_fast_bitref::operator = (const sc_fxnum_fast_bitref &a)
1419 {
1420  if (&a != this) {
1422  set(a.get());
1424  }
1425  return *this;
1426 }
1427 
1428 inline sc_fxnum_fast_bitref &
1429 sc_fxnum_fast_bitref::operator = (const sc_bit &a)
1430 {
1431  set(static_cast<bool>(a));
1433  return *this;
1434 }
1435 
1436 inline sc_fxnum_fast_bitref &
1437 sc_fxnum_fast_bitref::operator = (bool a)
1438 {
1439  set(a);
1441  return *this;
1442 }
1443 
1444 
1445 inline sc_fxnum_fast_bitref &
1447 {
1449  SC_FXNUM_OBSERVER_READ_(b.m_num)
1450  set(get() && b.get());
1452  return *this;
1453 }
1454 
1455 inline sc_fxnum_fast_bitref &
1456 sc_fxnum_fast_bitref::operator &= (const sc_fxnum_fast_bitref &b)
1457 {
1460  set(get() && b.get());
1462  return *this;
1463 }
1464 
1465 inline sc_fxnum_fast_bitref &
1466 sc_fxnum_fast_bitref::operator &= (const sc_bit &b)
1467 {
1469  set(get() && static_cast<bool>(b));
1471  return *this;
1472 }
1473 
1474 inline sc_fxnum_fast_bitref &
1476 {
1478  set(get() && b);
1480  return *this;
1481 }
1482 
1483 
1484 inline sc_fxnum_fast_bitref &
1486 {
1488  SC_FXNUM_OBSERVER_READ_(b.m_num)
1489  set(get() || b.get());
1491  return *this;
1492 }
1493 
1494 inline sc_fxnum_fast_bitref &
1495 sc_fxnum_fast_bitref::operator |= (const sc_fxnum_fast_bitref &b)
1496 {
1499  set(get() || b.get());
1501  return *this;
1502 }
1503 
1504 inline sc_fxnum_fast_bitref &
1505 sc_fxnum_fast_bitref::operator |= (const sc_bit &b)
1506 {
1508  set(get() || static_cast<bool>(b));
1510  return *this;
1511 }
1512 
1513 inline sc_fxnum_fast_bitref &
1515 {
1517  set(get() || b);
1519  return *this;
1520 }
1521 
1522 
1523 inline sc_fxnum_fast_bitref &
1525 {
1527  SC_FXNUM_OBSERVER_READ_(b.m_num)
1528  set(get() != b.get());
1530  return *this;
1531 }
1532 
1533 inline sc_fxnum_fast_bitref &
1534 sc_fxnum_fast_bitref::operator ^= (const sc_fxnum_fast_bitref &b)
1535 {
1538  set(get() != b.get());
1540  return *this;
1541 }
1542 
1543 inline sc_fxnum_fast_bitref &
1544 sc_fxnum_fast_bitref::operator ^= (const sc_bit &b)
1545 {
1547  set(get() != static_cast<bool>(b));
1549  return *this;
1550 }
1551 
1552 inline sc_fxnum_fast_bitref &
1554 {
1556  set(get() != b);
1558  return *this;
1559 }
1560 
1561 
1562 // implicit conversion
1563 inline sc_fxnum_fast_bitref::operator bool() const
1564 {
1566  return get();
1567 }
1568 
1569 inline ::std::ostream &
1570 operator << (::std::ostream &os, const sc_fxnum_fast_bitref &a)
1571 {
1572  a.print(os);
1573  return os;
1574 }
1575 
1576 inline ::std::istream &
1578 {
1579  a.scan(is);
1580  return is;
1581 }
1582 
1583 
1584 // ----------------------------------------------------------------------------
1585 // CLASS : sc_fxnum_subref
1586 //
1587 // Proxy class for part-selection in class sc_fxnum,
1588 // behaves like sc_bv_base.
1589 // ----------------------------------------------------------------------------
1590 
1591 // constructor
1592 inline sc_fxnum_subref::sc_fxnum_subref(sc_fxnum &num_, int from_, int to_) :
1593  m_num(num_), m_from(from_), m_to(to_),
1594  m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
1595 {}
1596 
1597 // copy constructor
1599  m_num(a.m_num), m_from(a.m_from), m_to(a.m_to),
1600  m_bv(*new sc_bv_base(a.m_bv))
1601 {}
1602 
1603 // destructor
1605 {
1606  delete &m_bv;
1607 }
1608 
1609 // assignment operators
1610 inline sc_fxnum_subref &
1611 sc_fxnum_subref::operator = (const sc_fxnum_subref &a)
1612 {
1613  if (&a != this) {
1614  m_bv = static_cast<sc_bv_base>(a);
1615  set();
1617  }
1618  return *this;
1619 }
1620 
1621 inline sc_fxnum_subref &
1622 sc_fxnum_subref::operator = (const sc_fxnum_fast_subref &a)
1623 {
1624  m_bv = static_cast<sc_bv_base>(a);
1625  set();
1627  return *this;
1628 }
1629 
1630 #define DEFN_ASN_OP_T(tp) \
1631 inline sc_fxnum_subref & \
1632 sc_fxnum_subref::operator = (tp a) \
1633 { \
1634  m_bv = a; \
1635  set(); \
1636  SC_FXNUM_OBSERVER_WRITE_(m_num) \
1637  return *this; \
1638 }
1639 
1640 DEFN_ASN_OP_T(const sc_bv_base &)
1641 DEFN_ASN_OP_T(const sc_lv_base &)
1642 DEFN_ASN_OP_T(const char *)
1643 DEFN_ASN_OP_T(const bool *)
1644 DEFN_ASN_OP_T(const sc_signed &)
1645 DEFN_ASN_OP_T(const sc_unsigned &)
1646 DEFN_ASN_OP_T(const sc_int_base &)
1647 DEFN_ASN_OP_T(const sc_uint_base &)
1650 DEFN_ASN_OP_T(int)
1651 DEFN_ASN_OP_T(unsigned int)
1652 DEFN_ASN_OP_T(long)
1653 DEFN_ASN_OP_T(unsigned long)
1654 DEFN_ASN_OP_T(char)
1655 
1656 #undef DEFN_ASN_OP_T
1657 
1658 #define DEFN_ASN_OP_T(op, tp) \
1659 inline sc_fxnum_subref & \
1660 sc_fxnum_subref::operator op ## = (tp a) \
1661 { \
1662  SC_FXNUM_OBSERVER_READ_(m_num) \
1663  get(); \
1664  m_bv = m_bv op a; \
1665  set(); \
1666  SC_FXNUM_OBSERVER_WRITE_(m_num) \
1667  return *this; \
1668 }
1669 
1670 #define DEFN_ASN_OP(op) \
1671 inline sc_fxnum_subref & \
1672 sc_fxnum_subref::operator op ## = (const sc_fxnum_subref &a) \
1673 { \
1674  SC_FXNUM_OBSERVER_READ_(m_num) \
1675  get(); \
1676  m_bv = m_bv op static_cast<sc_bv_base>(a); \
1677  set(); \
1678  SC_FXNUM_OBSERVER_WRITE_(m_num) \
1679  return *this; \
1680 } \
1681  \
1682 inline sc_fxnum_subref & \
1683 sc_fxnum_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
1684 { \
1685  SC_FXNUM_OBSERVER_READ_(m_num) \
1686  get(); \
1687  m_bv = m_bv op static_cast<sc_bv_base>(a); \
1688  set(); \
1689  SC_FXNUM_OBSERVER_WRITE_(m_num) \
1690  return *this; \
1691 } \
1692  \
1693 DEFN_ASN_OP_T(op, const sc_bv_base &) \
1694 DEFN_ASN_OP_T(op, const sc_lv_base &)
1695 
1696 DEFN_ASN_OP( &)
1697 DEFN_ASN_OP(|)
1698 DEFN_ASN_OP(^)
1699 
1700 #undef DEFN_ASN_OP_T
1701 #undef DEFN_ASN_OP
1702 
1703 // relational operators
1704 #define DEFN_REL_OP_T(op, tp) \
1705 inline bool \
1706 operator op (const sc_fxnum_subref &a, tp b) \
1707 { \
1708  return (static_cast<sc_bv_base>(a) op b); \
1709 } \
1710  \
1711 inline bool \
1712 operator op (tp a, const sc_fxnum_subref &b) \
1713 { \
1714  return (static_cast<sc_bv_base>(b) op a); \
1715 }
1716 
1717 #define DEFN_REL_OP(op) \
1718 inline bool \
1719 operator op (const sc_fxnum_subref &a, const sc_fxnum_subref &b) \
1720 { \
1721  return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
1722 } \
1723  \
1724 inline bool \
1725 operator op (const sc_fxnum_subref &a, const sc_fxnum_fast_subref &b) \
1726 { \
1727  return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
1728 } \
1729  \
1730 DEFN_REL_OP_T(op, const sc_bv_base &) \
1731 DEFN_REL_OP_T(op, const sc_lv_base &) \
1732 DEFN_REL_OP_T(op, const char *) \
1733 DEFN_REL_OP_T(op, const bool *) \
1734 DEFN_REL_OP_T(op, const sc_signed &) \
1735 DEFN_REL_OP_T(op, const sc_unsigned &) \
1736 DEFN_REL_OP_T(op, int) \
1737 DEFN_REL_OP_T(op, unsigned int) \
1738 DEFN_REL_OP_T(op, long) \
1739 DEFN_REL_OP_T(op, unsigned long)
1740 
1741 DEFN_REL_OP(==)
1742 DEFN_REL_OP(!=)
1743 
1744 #undef DEFN_REL_OP_T
1745 #undef DEFN_REL_OP
1746 
1747 
1748 // reduce functions
1749 
1750 #define DEFN_RED_FNC(fnc) \
1751 inline bool \
1752 sc_fxnum_subref::fnc() const \
1753 { \
1754  SC_FXNUM_OBSERVER_READ_(m_num) \
1755  get(); \
1756  return static_cast<bool>(m_bv.fnc()); \
1757 }
1758 
1765 
1766 #undef DEFN_RED_FNC
1767 
1768 // query parameter
1769 inline int
1771 {
1772  return m_bv.length();
1773 }
1774 
1775 // explicit conversions
1776 inline int
1778 {
1780  get();
1781  return m_bv.to_int();
1782 }
1783 
1784 inline int64
1786 {
1788  get();
1789  return m_bv.to_int64();
1790 }
1791 
1792 inline unsigned int
1794 {
1796  get();
1797  return m_bv.to_uint();
1798 }
1799 
1800 inline uint64
1802 {
1804  get();
1805  return m_bv.to_uint64();
1806 }
1807 
1808 inline long
1810 {
1812  get();
1813  return m_bv.to_long();
1814 }
1815 
1816 inline unsigned long
1818 {
1820  get();
1821  return m_bv.to_ulong();
1822 }
1823 
1824 
1825 inline const std::string
1827 {
1828  get();
1829  return m_bv.to_string();
1830 }
1831 
1832 inline const std::string
1834 {
1835  get();
1836  return m_bv.to_string(numrep);
1837 }
1838 
1839 inline const std::string
1840 sc_fxnum_subref::to_string(sc_numrep numrep, bool w_prefix) const
1841 {
1842  get();
1843  return m_bv.to_string(numrep, w_prefix);
1844 }
1845 
1846 
1847 // implicit conversion
1848 inline sc_fxnum_subref::operator sc_bv_base () const
1849 {
1851  get();
1852  return m_bv;
1853 }
1854 
1855 
1856 inline ::std::ostream &
1857 operator << (::std::ostream &os, const sc_fxnum_subref &a)
1858 {
1859  a.print(os);
1860  return os;
1861 }
1862 
1863 inline ::std::istream &
1864 operator >> (::std::istream &is, sc_fxnum_subref &a)
1865 {
1866  a.scan(is);
1867  return is;
1868 }
1869 
1870 
1871 // ----------------------------------------------------------------------------
1872 // CLASS : sc_fxnum_fast_subref
1873 //
1874 // Proxy class for part-selection in class sc_fxnum_fast,
1875 // behaves like sc_bv_base.
1876 // ----------------------------------------------------------------------------
1877 
1878 // constructor
1879 
1881  sc_fxnum_fast &num_, int from_, int to_) :
1882  m_num(num_), m_from(from_), m_to(to_),
1883  m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
1884 {}
1885 
1886 
1887 // copy constructor
1889  const sc_fxnum_fast_subref &a) :
1890  m_num(a.m_num), m_from(a.m_from), m_to(a.m_to),
1891  m_bv(*new sc_bv_base(a.m_bv))
1892 {}
1893 
1894 
1895 // destructor
1897 {
1898  delete &m_bv;
1899 }
1900 
1901 
1902 // assignment operators
1903 inline sc_fxnum_fast_subref &
1904 sc_fxnum_fast_subref::operator = (const sc_fxnum_subref &a)
1905 {
1906  m_bv = static_cast<sc_bv_base>(a);
1907  set();
1909  return *this;
1910 }
1911 
1912 inline sc_fxnum_fast_subref &
1913 sc_fxnum_fast_subref::operator = (const sc_fxnum_fast_subref &a)
1914 {
1915  if (&a != this) {
1916  m_bv = static_cast<sc_bv_base>(a);
1917  set();
1919  }
1920  return *this;
1921 }
1922 
1923 #define DEFN_ASN_OP_T(tp) \
1924 inline sc_fxnum_fast_subref & \
1925 sc_fxnum_fast_subref::operator = (tp a) \
1926 { \
1927  m_bv = a; \
1928  set(); \
1929  SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1930  return *this; \
1931 }
1932 
1933 DEFN_ASN_OP_T(const sc_bv_base &)
1934 DEFN_ASN_OP_T(const sc_lv_base &)
1935 DEFN_ASN_OP_T(const char *)
1936 DEFN_ASN_OP_T(const bool *)
1937 DEFN_ASN_OP_T(const sc_signed &)
1938 DEFN_ASN_OP_T(const sc_unsigned &)
1939 DEFN_ASN_OP_T(const sc_int_base &)
1940 DEFN_ASN_OP_T(const sc_uint_base &)
1943 DEFN_ASN_OP_T(int)
1944 DEFN_ASN_OP_T(unsigned int)
1945 DEFN_ASN_OP_T(long)
1946 DEFN_ASN_OP_T(unsigned long)
1947 DEFN_ASN_OP_T(char)
1948 
1949 #undef DEFN_ASN_OP_T
1950 
1951 
1952 #define DEFN_ASN_OP_T(op, tp) \
1953 inline sc_fxnum_fast_subref & \
1954 sc_fxnum_fast_subref::operator op ## = (tp a) \
1955 { \
1956  SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1957  get(); \
1958  m_bv = m_bv op a; \
1959  set(); \
1960  SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1961  return *this; \
1962 }
1963 
1964 #define DEFN_ASN_OP(op) \
1965 inline sc_fxnum_fast_subref & \
1966 sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_subref &a) \
1967 { \
1968  SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1969  get(); \
1970  m_bv = m_bv op static_cast<sc_bv_base>(a); \
1971  set(); \
1972  SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1973  return *this; \
1974 } \
1975  \
1976 inline sc_fxnum_fast_subref & \
1977 sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
1978 { \
1979  SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1980  get(); \
1981  m_bv = m_bv op static_cast<sc_bv_base>(a); \
1982  set(); \
1983  SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1984  return *this; \
1985 } \
1986  \
1987 DEFN_ASN_OP_T(op, const sc_bv_base &) \
1988 DEFN_ASN_OP_T(op, const sc_lv_base &)
1989 
1990 DEFN_ASN_OP(&)
1991 DEFN_ASN_OP(|)
1992 DEFN_ASN_OP(^)
1993 
1994 #undef DEFN_ASN_OP_T
1995 #undef DEFN_ASN_OP
1996 
1997 
1998 // relational operators
1999 
2000 #define DEFN_REL_OP_T(op, tp) \
2001 inline bool \
2002 operator op (const sc_fxnum_fast_subref &a, tp b) \
2003 { \
2004  return (static_cast<sc_bv_base>(a) op b); \
2005 } \
2006  \
2007 inline bool \
2008 operator op (tp a, const sc_fxnum_fast_subref &b) \
2009 { \
2010  return (static_cast<sc_bv_base>(b) op a); \
2011 }
2012 
2013 #define DEFN_REL_OP(op) \
2014 inline bool \
2015 operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_fast_subref &b) \
2016 { \
2017  return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
2018 } \
2019  \
2020 inline bool \
2021 operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_subref &b) \
2022 { \
2023  return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
2024 } \
2025  \
2026 DEFN_REL_OP_T(op, const sc_bv_base &) \
2027 DEFN_REL_OP_T(op, const sc_lv_base &) \
2028 DEFN_REL_OP_T(op, const char *) \
2029 DEFN_REL_OP_T(op, const bool *) \
2030 DEFN_REL_OP_T(op, const sc_signed &) \
2031 DEFN_REL_OP_T(op, const sc_unsigned &) \
2032 DEFN_REL_OP_T(op, int) \
2033 DEFN_REL_OP_T(op, unsigned int) \
2034 DEFN_REL_OP_T(op, long) \
2035 DEFN_REL_OP_T(op, unsigned long)
2036 
2037 DEFN_REL_OP(==)
2038 DEFN_REL_OP(!=)
2039 
2040 #undef DEFN_REL_OP_T
2041 #undef DEFN_REL_OP
2042 
2043 // reduce functions
2044 #define DEFN_RED_FNC(fnc) \
2045 inline bool \
2046 sc_fxnum_fast_subref::fnc() const \
2047 { \
2048  SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
2049  get(); \
2050  return static_cast<bool>(m_bv.fnc()); \
2051 }
2052 
2059 
2060 #undef DEFN_RED_FNC
2061 
2062 // query parameter
2063 inline int
2065 {
2066  return m_bv.length();
2067 }
2068 
2069 // explicit conversions
2070 inline int
2072 {
2074  get();
2075  return m_bv.to_int();
2076 }
2077 
2078 inline int64
2080 {
2082  get();
2083  return m_bv.to_int64();
2084 }
2085 
2086 inline unsigned int
2088 {
2090  get();
2091  return m_bv.to_uint();
2092 }
2093 
2094 inline uint64
2096 {
2098  get();
2099  return m_bv.to_uint64();
2100 }
2101 
2102 inline long
2104 {
2106  get();
2107  return m_bv.to_long();
2108 }
2109 
2110 inline unsigned long
2112 {
2114  get();
2115  return m_bv.to_ulong();
2116 }
2117 
2118 inline const std::string
2120 {
2121  get();
2122  return m_bv.to_string();
2123 }
2124 
2125 inline const std::string
2127 {
2128  get();
2129  return m_bv.to_string(numrep);
2130 }
2131 
2132 inline const std::string
2133 sc_fxnum_fast_subref::to_string(sc_numrep numrep, bool w_prefix) const
2134 {
2135  get();
2136  return m_bv.to_string(numrep, w_prefix);
2137 }
2138 
2139 
2140 // implicit conversion
2141 inline sc_fxnum_fast_subref::operator sc_bv_base () const
2142 {
2144  get();
2145  return m_bv;
2146 }
2147 
2148 inline ::std::ostream &
2149 operator << (::std::ostream &os, const sc_fxnum_fast_subref &a)
2150 {
2151  a.print(os);
2152  return os;
2153 }
2154 
2155 inline ::std::istream &
2157 {
2158  a.scan(is);
2159  return is;
2160 }
2161 
2162 
2163 // ----------------------------------------------------------------------------
2164 // CLASS : sc_fxnum
2165 //
2166 // Base class for the fixed-point types; arbitrary precision.
2167 // ----------------------------------------------------------------------------
2168 
2169 inline sc_fxnum_observer *
2171 {
2172  return m_observer;
2173 }
2174 
2175 inline void
2177 {
2179 
2180  if (m_params.cast_switch() == SC_ON)
2182 }
2183 
2184 // constructors
2185 inline sc_fxnum::sc_fxnum(const sc_fxtype_params &type_params_,
2186  sc_enc enc_, const sc_fxcast_switch &cast_sw,
2187  sc_fxnum_observer *observer_) :
2188  m_rep(new scfx_rep), m_params(type_params_, enc_, cast_sw),
2189  m_q_flag(false), m_o_flag(false), m_observer(observer_)
2190 {
2193 }
2194 
2195 #define DEFN_CTOR_T(tp, arg) \
2196 inline sc_fxnum::sc_fxnum(tp a, const sc_fxtype_params &type_params_, \
2197  sc_enc enc_, const sc_fxcast_switch &cast_sw, \
2198  sc_fxnum_observer *observer_) : \
2199  m_rep(new scfx_rep(arg)), m_params(type_params_, enc_, cast_sw), \
2200  m_q_flag(false), m_o_flag(false), m_observer(observer_) \
2201 { \
2202  SC_FXNUM_OBSERVER_DEFAULT_ \
2203  cast(); \
2204  SC_FXNUM_OBSERVER_CONSTRUCT_(*this) \
2205  SC_FXNUM_OBSERVER_WRITE_(*this) \
2206 }
2207 
2208 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
2209 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, *a.m_rep)
2210 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
2211 #define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp, a.value())
2212 
2213 DEFN_CTOR_T_A(int)
2214 DEFN_CTOR_T_A(unsigned int)
2215 DEFN_CTOR_T_A(long)
2216 DEFN_CTOR_T_A(unsigned long)
2217 DEFN_CTOR_T_A(float)
2218 DEFN_CTOR_T_A(double)
2219 DEFN_CTOR_T_A(const char *)
2220 DEFN_CTOR_T_B(const sc_fxval &)
2221 DEFN_CTOR_T_C(const sc_fxval_fast &)
2222 DEFN_CTOR_T_B(const sc_fxnum &)
2223 DEFN_CTOR_T_C(const sc_fxnum_fast &)
2224 #ifndef SC_FX_EXCLUDE_OTHER
2227 DEFN_CTOR_T_D(const sc_int_base &)
2228 DEFN_CTOR_T_D(const sc_uint_base &)
2229 DEFN_CTOR_T_A(const sc_signed &)
2230 DEFN_CTOR_T_A(const sc_unsigned &)
2231 #endif
2232 
2233 #undef DEFN_CTOR_T
2234 #undef DEFN_CTOR_T_A
2235 #undef DEFN_CTOR_T_B
2236 #undef DEFN_CTOR_T_C
2237 #undef DEFN_CTOR_T_D
2238 
2240 {
2242  delete m_rep;
2243 }
2244 
2245 // internal use only;
2246 inline const scfx_rep *
2248 {
2250  return m_rep;
2251 }
2252 
2253 // unary operators
2254 inline const sc_fxval
2256 {
2259 }
2260 
2261 inline const sc_fxval
2263 {
2265  return sc_fxval(new scfx_rep(*m_rep));
2266 }
2267 
2268 // unary functions
2269 inline void
2271 {
2273  c.set_rep(sc_dt::neg_scfx_rep(*a.m_rep));
2274 }
2275 
2276 inline void
2278 {
2280  delete c.m_rep;
2281  c.m_rep = sc_dt::neg_scfx_rep(*a.m_rep);
2282  c.cast();
2284 }
2285 
2286 // binary operators
2287 #define DEFN_BIN_OP_T(op, fnc, tp) \
2288 inline const sc_fxval \
2289 operator op (const sc_fxnum &a, tp b) \
2290 { \
2291  SC_FXNUM_OBSERVER_READ_(a) \
2292  sc_fxval tmp(b); \
2293  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
2294 } \
2295  \
2296 inline const sc_fxval \
2297 operator op (tp a, const sc_fxnum &b) \
2298 { \
2299  SC_FXNUM_OBSERVER_READ_(b) \
2300  sc_fxval tmp(a); \
2301  return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
2302 }
2303 
2304 #ifndef SC_FX_EXCLUDE_OTHER
2305 #define DEFN_BIN_OP_OTHER(op, fnc) \
2306 DEFN_BIN_OP_T(op, fnc, int64) \
2307 DEFN_BIN_OP_T(op, fnc, uint64) \
2308 DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
2309 DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
2310 DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
2311 DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
2312 #else
2313 #define DEFN_BIN_OP_OTHER(op, fnc)
2314 #endif
2315 
2316 #define DEFN_BIN_OP(op, fnc) \
2317 inline const sc_fxval \
2318 operator op (const sc_fxnum &a, const sc_fxnum &b) \
2319 { \
2320  SC_FXNUM_OBSERVER_READ_(a) \
2321  SC_FXNUM_OBSERVER_READ_(b) \
2322  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
2323 } \
2324  \
2325 inline const sc_fxval \
2326 operator op (const sc_fxnum &a, const sc_fxval &b) \
2327 { \
2328  SC_FXNUM_OBSERVER_READ_(a) \
2329  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
2330 } \
2331  \
2332 inline const sc_fxval \
2333 operator op (const sc_fxval &a, const sc_fxnum &b) \
2334 { \
2335  SC_FXNUM_OBSERVER_READ_(b) \
2336  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
2337 } \
2338  \
2339 DEFN_BIN_OP_T(op, fnc, int) \
2340 DEFN_BIN_OP_T(op, fnc, unsigned int) \
2341 DEFN_BIN_OP_T(op, fnc, long) \
2342 DEFN_BIN_OP_T(op, fnc, unsigned long) \
2343 DEFN_BIN_OP_T(op, fnc, float) \
2344 DEFN_BIN_OP_T(op, fnc, double) \
2345 DEFN_BIN_OP_T(op, fnc, const char *) \
2346 DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
2347 DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) \
2348 DEFN_BIN_OP_OTHER(op, fnc)
2349 
2350 DEFN_BIN_OP(*, mult)
2351 DEFN_BIN_OP(+, add)
2352 DEFN_BIN_OP(-, sub)
2353 // don't use macros
2354 //DEFN_BIN_OP(/, div)
2355 inline const sc_fxval
2357 {
2360  return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.m_rep));
2361 }
2362 
2363 inline const sc_fxval
2365 {
2367  return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.get_rep()));
2368 }
2369 
2370 inline const sc_fxval
2372 {
2374  return sc_fxval(sc_dt::div_scfx_rep(*a.get_rep(), *b.m_rep));
2375 }
2376 
2377 DEFN_BIN_OP_T(/, div, int)
2378 DEFN_BIN_OP_T(/, div, unsigned int)
2379 DEFN_BIN_OP_T(/, div, long)
2380 DEFN_BIN_OP_T(/, div, unsigned long)
2381 DEFN_BIN_OP_T(/, div, float)
2382 DEFN_BIN_OP_T(/, div, double)
2383 DEFN_BIN_OP_T(/, div, const char *)
2384 DEFN_BIN_OP_T(/, div, const sc_fxval_fast &)
2385 DEFN_BIN_OP_T(/, div, const sc_fxnum_fast &)
2386 //DEFN_BIN_OP_OTHER(/, div)
2387 
2388 DEFN_BIN_OP_T(/, div, int64)
2389 DEFN_BIN_OP_T(/, div, uint64)
2390 DEFN_BIN_OP_T(/, div, const sc_int_base &)
2391 DEFN_BIN_OP_T(/, div, const sc_uint_base &)
2392 DEFN_BIN_OP_T(/, div, const sc_signed &)
2393 DEFN_BIN_OP_T(/, div, const sc_unsigned &)
2394 
2395 #undef DEFN_BIN_OP_T
2396 #undef DEFN_BIN_OP_OTHER
2397 #undef DEFN_BIN_OP
2398 
2399 inline const sc_fxval
2400 operator << (const sc_fxnum &a, int b)
2401 {
2403  return sc_fxval(sc_dt::lsh_scfx_rep(*a.m_rep, b));
2404 }
2405 
2406 inline const sc_fxval
2407 operator >> (const sc_fxnum &a, int b)
2408 {
2410  return sc_fxval(sc_dt::rsh_scfx_rep(*a.m_rep, b));
2411 }
2412 
2413 // binary functions
2414 #define DEFN_BIN_FNC_T(fnc, tp) \
2415 inline void \
2416 fnc (sc_fxval &c, const sc_fxnum &a, tp b) \
2417 { \
2418  SC_FXNUM_OBSERVER_READ_(a) \
2419  sc_fxval tmp(b); \
2420  c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
2421 } \
2422  \
2423 inline void \
2424 fnc (sc_fxval &c, tp a, const sc_fxnum &b) \
2425 { \
2426  SC_FXNUM_OBSERVER_READ_(b) \
2427  sc_fxval tmp(a); \
2428  c.set_rep(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
2429 } \
2430  \
2431 inline void \
2432 fnc (sc_fxnum &c, const sc_fxnum &a, tp b) \
2433 { \
2434  SC_FXNUM_OBSERVER_READ_(a) \
2435  sc_fxval tmp(b); \
2436  delete c.m_rep; \
2437  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep()); \
2438  c.cast(); \
2439  SC_FXNUM_OBSERVER_WRITE_(c) \
2440 } \
2441  \
2442 inline void \
2443 fnc (sc_fxnum &c, tp a, const sc_fxnum &b) \
2444 { \
2445  SC_FXNUM_OBSERVER_READ_(b) \
2446  sc_fxval tmp(a); \
2447  delete c.m_rep; \
2448  c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep); \
2449  c.cast(); \
2450  SC_FXNUM_OBSERVER_WRITE_(c) \
2451 }
2452 
2453 #define DEFN_BIN_FNC_OTHER(fnc) \
2454 DEFN_BIN_FNC_T(fnc, int64) \
2455 DEFN_BIN_FNC_T(fnc, uint64) \
2456 DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
2457 DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
2458 DEFN_BIN_FNC_T(fnc, const sc_signed &) \
2459 DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
2460 
2461 #define DEFN_BIN_FNC(fnc) \
2462 inline void \
2463 fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxnum &b) \
2464 { \
2465  SC_FXNUM_OBSERVER_READ_(a) \
2466  SC_FXNUM_OBSERVER_READ_(b) \
2467  c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
2468 } \
2469  \
2470 inline void \
2471 fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxnum &b) \
2472 { \
2473  SC_FXNUM_OBSERVER_READ_(a) \
2474  SC_FXNUM_OBSERVER_READ_(b) \
2475  delete c.m_rep; \
2476  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
2477  c.cast(); \
2478  SC_FXNUM_OBSERVER_WRITE_(c) \
2479 } \
2480  \
2481 inline void \
2482 fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxval &b) \
2483 { \
2484  SC_FXNUM_OBSERVER_READ_(a) \
2485  c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
2486 } \
2487  \
2488 inline void \
2489 fnc (sc_fxval &c, const sc_fxval &a, const sc_fxnum &b) \
2490 { \
2491  SC_FXNUM_OBSERVER_READ_(b) \
2492  c.set_rep(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
2493 } \
2494  \
2495 inline void \
2496 fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxval &b) \
2497 { \
2498  SC_FXNUM_OBSERVER_READ_(a) \
2499  delete c.m_rep; \
2500  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep()); \
2501  c.cast(); \
2502  SC_FXNUM_OBSERVER_WRITE_(c) \
2503 } \
2504  \
2505 inline void \
2506 fnc (sc_fxnum &c, const sc_fxval &a, const sc_fxnum &b) \
2507 { \
2508  SC_FXNUM_OBSERVER_READ_(b) \
2509  delete c.m_rep; \
2510  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep); \
2511  c.cast(); \
2512  SC_FXNUM_OBSERVER_WRITE_(c) \
2513 } \
2514  \
2515 DEFN_BIN_FNC_T(fnc, int) \
2516 DEFN_BIN_FNC_T(fnc, unsigned int) \
2517 DEFN_BIN_FNC_T(fnc, long) \
2518 DEFN_BIN_FNC_T(fnc, unsigned long) \
2519 DEFN_BIN_FNC_T(fnc, float) \
2520 DEFN_BIN_FNC_T(fnc, double) \
2521 DEFN_BIN_FNC_T(fnc, const char *) \
2522 DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
2523 DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
2524 DEFN_BIN_FNC_OTHER(fnc)
2525 
2526 DEFN_BIN_FNC(mult)
2527 DEFN_BIN_FNC(div)
2528 DEFN_BIN_FNC(add)
2529 DEFN_BIN_FNC(sub)
2530 
2531 #undef DEFN_BIN_FNC_T
2532 #undef DEFN_BIN_FNC_OTHER
2533 #undef DEFN_BIN_FNC
2534 
2535 inline void
2536 lshift(sc_fxval &c, const sc_fxnum &a, int b)
2537 {
2539  c.set_rep(sc_dt::lsh_scfx_rep(*a.m_rep, b));
2540 }
2541 
2542 inline void
2543 rshift(sc_fxval &c, const sc_fxnum &a, int b)
2544 {
2546  c.set_rep(sc_dt::rsh_scfx_rep(*a.m_rep, b));
2547 }
2548 
2549 inline void
2550 lshift(sc_fxnum &c, const sc_fxnum &a, int b)
2551 {
2553  delete c.m_rep;
2554  c.m_rep = sc_dt::lsh_scfx_rep(*a.m_rep, b);
2555  c.cast();
2557 }
2558 
2559 inline void
2560 rshift(sc_fxnum &c, const sc_fxnum &a, int b)
2561 {
2563  delete c.m_rep;
2564  c.m_rep = sc_dt::rsh_scfx_rep(*a.m_rep, b);
2565  c.cast();
2567 }
2568 
2569 // relational (including equality) operators
2570 #define DEFN_REL_OP_T(op, ret, tp) \
2571 inline bool \
2572 operator op (const sc_fxnum &a, tp b) \
2573 { \
2574  SC_FXNUM_OBSERVER_READ_(a) \
2575  sc_fxval tmp(b); \
2576  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.get_rep()); \
2577  return (ret); \
2578 } \
2579  \
2580 inline bool \
2581 operator op (tp a, const sc_fxnum &b) \
2582 { \
2583  SC_FXNUM_OBSERVER_READ_(b) \
2584  sc_fxval tmp(a); \
2585  int result = sc_dt::cmp_scfx_rep(*tmp.get_rep(), *b.m_rep); \
2586  return (ret); \
2587 }
2588 
2589 #define DEFN_REL_OP_OTHER(op, ret) \
2590 DEFN_REL_OP_T(op, ret, int64) \
2591 DEFN_REL_OP_T(op, ret, uint64) \
2592 DEFN_REL_OP_T(op, ret, const sc_int_base &) \
2593 DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
2594 DEFN_REL_OP_T(op, ret, const sc_signed &) \
2595 DEFN_REL_OP_T(op, ret, const sc_unsigned &)
2596 
2597 #define DEFN_REL_OP(op, ret) \
2598 inline bool \
2599 operator op (const sc_fxnum &a, const sc_fxnum &b) \
2600 { \
2601  SC_FXNUM_OBSERVER_READ_(a) \
2602  SC_FXNUM_OBSERVER_READ_(b) \
2603  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
2604  return (ret); \
2605 } \
2606  \
2607 inline bool \
2608 operator op (const sc_fxnum &a, const sc_fxval &b) \
2609 { \
2610  SC_FXNUM_OBSERVER_READ_(a) \
2611  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.get_rep()); \
2612  return (ret); \
2613 } \
2614  \
2615 inline bool \
2616 operator op (const sc_fxval &a, const sc_fxnum &b) \
2617 { \
2618  SC_FXNUM_OBSERVER_READ_(b) \
2619  int result = sc_dt::cmp_scfx_rep(*a.get_rep(), *b.m_rep); \
2620  return (ret); \
2621 } \
2622  \
2623 DEFN_REL_OP_T(op, ret, int) \
2624 DEFN_REL_OP_T(op, ret, unsigned int) \
2625 DEFN_REL_OP_T(op, ret, long) \
2626 DEFN_REL_OP_T(op, ret, unsigned long) \
2627 DEFN_REL_OP_T(op, ret, float) \
2628 DEFN_REL_OP_T(op, ret, double) \
2629 DEFN_REL_OP_T(op, ret, const char *) \
2630 DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
2631 DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) \
2632 DEFN_REL_OP_OTHER(op, ret)
2633 
2634 DEFN_REL_OP(<, result < 0)
2635 DEFN_REL_OP(<=, result <= 0)
2636 DEFN_REL_OP(>, result > 0 && result != 2)
2637 DEFN_REL_OP(>=, result >= 0 && result != 2)
2638 DEFN_REL_OP(==, result == 0)
2639 DEFN_REL_OP(!=, result != 0)
2640 
2641 #undef DEFN_REL_OP_T
2642 #undef DEFN_REL_OP_OTHER
2643 #undef DEFN_REL_OP
2644 
2645 // assignment operators
2646 inline sc_fxnum &
2647 sc_fxnum::operator = (const sc_fxnum &a)
2648 {
2649  if (&a != this) {
2651  *m_rep = *a.m_rep;
2652  cast();
2654  }
2655  return *this;
2656 }
2657 
2658 inline sc_fxnum &
2659 sc_fxnum::operator = (const sc_fxval &a)
2660 {
2661  *m_rep = *a.get_rep();
2662  cast();
2664  return *this;
2665 }
2666 
2667 #define DEFN_ASN_OP_T(tp) \
2668 inline sc_fxnum & \
2669 sc_fxnum::operator = (tp a) \
2670 { \
2671  sc_fxval tmp(a); \
2672  *m_rep = *tmp.get_rep(); \
2673  cast(); \
2674  SC_FXNUM_OBSERVER_WRITE_(*this) \
2675  return *this; \
2676 }
2677 
2678 DEFN_ASN_OP_T(int)
2679 DEFN_ASN_OP_T(unsigned int)
2680 DEFN_ASN_OP_T(long)
2681 DEFN_ASN_OP_T(unsigned long)
2682 DEFN_ASN_OP_T(float)
2683 DEFN_ASN_OP_T(double)
2684 DEFN_ASN_OP_T(const char *)
2685 DEFN_ASN_OP_T(const sc_fxval_fast &)
2686 DEFN_ASN_OP_T(const sc_fxnum_fast &)
2687 
2690 DEFN_ASN_OP_T(const sc_int_base &)
2691 DEFN_ASN_OP_T(const sc_uint_base &)
2692 DEFN_ASN_OP_T(const sc_signed &)
2693 DEFN_ASN_OP_T(const sc_unsigned &)
2694 
2695 #undef DEFN_ASN_OP_T
2696 
2697 
2698 #define DEFN_ASN_OP_T(op, fnc, tp) \
2699 inline sc_fxnum & \
2700 sc_fxnum::operator op (tp b) \
2701 { \
2702  SC_FXNUM_OBSERVER_READ_(*this) \
2703  sc_fxval tmp(b); \
2704  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.get_rep()); \
2705  delete m_rep; \
2706  m_rep = new_rep; \
2707  cast(); \
2708  SC_FXNUM_OBSERVER_WRITE_(*this) \
2709  return *this; \
2710 }
2711 
2712 #define DEFN_ASN_OP_OTHER(op, fnc) \
2713 DEFN_ASN_OP_T(op, fnc, int64) \
2714 DEFN_ASN_OP_T(op, fnc, uint64) \
2715 DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
2716 DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
2717 DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
2718 DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
2719 
2720 #define DEFN_ASN_OP(op, fnc) \
2721 inline sc_fxnum & \
2722 sc_fxnum::operator op (const sc_fxnum &b) \
2723 { \
2724  SC_FXNUM_OBSERVER_READ_(*this) \
2725  SC_FXNUM_OBSERVER_READ_(b) \
2726  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
2727  delete m_rep; \
2728  m_rep = new_rep; \
2729  cast(); \
2730  SC_FXNUM_OBSERVER_WRITE_(*this) \
2731  return *this; \
2732 } \
2733  \
2734 inline sc_fxnum & \
2735 sc_fxnum::operator op (const sc_fxval &b) \
2736 { \
2737  SC_FXNUM_OBSERVER_READ_(*this) \
2738  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
2739  delete m_rep; \
2740  m_rep = new_rep; \
2741  cast(); \
2742  SC_FXNUM_OBSERVER_WRITE_(*this) \
2743  return *this; \
2744 } \
2745  \
2746 DEFN_ASN_OP_T(op, fnc, int) \
2747 DEFN_ASN_OP_T(op, fnc, unsigned int) \
2748 DEFN_ASN_OP_T(op, fnc, long) \
2749 DEFN_ASN_OP_T(op, fnc, unsigned long) \
2750 DEFN_ASN_OP_T(op, fnc, float) \
2751 DEFN_ASN_OP_T(op, fnc, double) \
2752 DEFN_ASN_OP_T(op, fnc, const char *) \
2753 DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
2754 DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) \
2755 DEFN_ASN_OP_OTHER(op, fnc)
2756 
2757 DEFN_ASN_OP(*=, mult)
2758 DEFN_ASN_OP(/=, div)
2759 DEFN_ASN_OP(+=, add)
2760 DEFN_ASN_OP(-=, sub)
2761 
2762 #undef DEFN_ASN_OP_T
2763 #undef DEFN_ASN_OP_OTHER
2764 #undef DEFN_ASN_OP
2765 
2766 
2767 inline sc_fxnum &
2768 sc_fxnum::operator <<= (int b)
2769 {
2771  m_rep->lshift(b);
2772  cast();
2774  return *this;
2775 }
2776 
2777 inline sc_fxnum &
2778 sc_fxnum::operator >>= (int b)
2779 {
2781  m_rep->rshift(b);
2782  cast();
2784  return *this;
2785 }
2786 
2787 // auto-increment and auto-decrement
2788 inline const sc_fxval
2789 sc_fxnum::operator ++ (int)
2790 {
2791  sc_fxval c(*this);
2792  (*this) += 1;
2793  return c;
2794 }
2795 
2796 inline const sc_fxval
2798 {
2799  sc_fxval c(*this);
2800  (*this) -= 1;
2801  return c;
2802 }
2803 
2804 inline sc_fxnum &
2806 {
2807  (*this) += 1;
2808  return *this;
2809 }
2810 
2811 inline sc_fxnum &
2813 {
2814  (*this) -= 1;
2815  return *this;
2816 }
2817 
2818 // bit selection
2819 inline const sc_fxnum_bitref
2821 {
2823  return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2824  i - m_params.fwl());
2825 }
2826 
2827 inline sc_fxnum_bitref
2829 {
2831  return sc_fxnum_bitref(*this, i - m_params.fwl());
2832 }
2833 
2834 inline const sc_fxnum_bitref
2835 sc_fxnum::bit(int i) const
2836 {
2838  return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2839  i - m_params.fwl());
2840 }
2841 
2842 inline sc_fxnum_bitref
2844 {
2846  return sc_fxnum_bitref(*this, i - m_params.fwl());
2847 }
2848 
2849 // part selection
2850 
2851 inline const sc_fxnum_subref
2852 sc_fxnum::operator () (int i, int j) const
2853 {
2856 
2857  return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2858  i - m_params.fwl(), j - m_params.fwl());
2859 }
2860 
2861 inline sc_fxnum_subref
2863 {
2866 
2867  return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2868 }
2869 
2870 inline const sc_fxnum_subref
2871 sc_fxnum::range(int i, int j) const
2872 {
2875 
2876  return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2877  i - m_params.fwl(), j - m_params.fwl());
2878 }
2879 
2880 inline sc_fxnum_subref
2882 {
2885 
2886  return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2887 }
2888 
2889 
2890 inline const sc_fxnum_subref
2892 {
2893  return this->operator () (m_params.wl() - 1, 0);
2894 }
2895 
2896 inline sc_fxnum_subref
2898 {
2899  return this->operator () (m_params.wl() - 1, 0);
2900 }
2901 
2902 inline const sc_fxnum_subref
2904 {
2905  return this->range(m_params.wl() - 1, 0);
2906 }
2907 
2908 inline sc_fxnum_subref
2910 {
2911  return this->range(m_params.wl() - 1, 0);
2912 }
2913 
2914 // implicit conversion
2915 inline sc_fxnum::operator double() const
2916 {
2918  return m_rep->to_double();
2919 }
2920 
2921 // explicit conversion to primitive types
2922 inline short
2924 {
2926  return static_cast<short>(m_rep->to_uint64());
2927 }
2928 
2929 inline unsigned short
2931 {
2933  return static_cast<unsigned short>(m_rep->to_uint64());
2934 }
2935 
2936 inline int
2938 {
2940  return static_cast<int>(m_rep->to_uint64());
2941 }
2942 
2943 inline int64
2945 {
2947  return static_cast<int64>(m_rep->to_uint64());
2948 }
2949 
2950 inline unsigned int
2952 {
2954  return static_cast<unsigned int>(m_rep->to_uint64());
2955 }
2956 
2957 inline uint64
2959 {
2961  return m_rep->to_uint64();
2962 }
2963 
2964 inline long
2966 {
2968  return static_cast<long>(m_rep->to_uint64());
2969 }
2970 
2971 inline unsigned long
2973 {
2975  return static_cast<unsigned long>(m_rep->to_uint64());
2976 }
2977 
2978 inline float
2980 {
2982  return static_cast<float>(m_rep->to_double());
2983 }
2984 
2985 inline double
2987 {
2989  return m_rep->to_double();
2990 }
2991 
2992 // query value
2993 inline bool
2995 {
2997  return m_rep->is_neg();
2998 }
2999 
3000 inline bool
3002 {
3004  return m_rep->is_zero();
3005 }
3006 
3007 // internal use only;
3008 inline bool
3010 {
3012  return m_rep->is_normal();
3013 }
3014 
3015 inline bool
3017 {
3018  return m_q_flag;
3019 }
3020 
3021 inline bool
3023 {
3024  return m_o_flag;
3025 }
3026 
3027 
3028 inline const sc_fxval
3030 {
3032  return sc_fxval(new scfx_rep(*m_rep));
3033 }
3034 
3035 // query parameters
3036 inline int
3038 {
3039  return m_params.wl();
3040 }
3041 
3042 inline int
3044 {
3045  return m_params.iwl();
3046 }
3047 
3048 inline sc_q_mode
3050 {
3051  return m_params.q_mode();
3052 }
3053 
3054 inline sc_o_mode
3056 {
3057  return m_params.o_mode();
3058 }
3059 
3060 inline int
3062 {
3063  return m_params.n_bits();
3064 }
3065 
3066 inline const sc_fxtype_params &
3068 {
3069  return m_params.type_params();
3070 }
3071 
3072 inline const sc_fxcast_switch &
3074 {
3075  return m_params.cast_switch();
3076 }
3077 
3078 // internal use only;
3079 inline void
3081 {
3082  SC_FXNUM_OBSERVER_READ_(*this);
3083 }
3084 
3085 // internal use only;
3086 inline bool
3088 {
3089  return m_rep->get_bit(i);
3090 }
3091 
3092 // protected methods and friend functions
3093 inline bool
3094 sc_fxnum::set_bit(int i, bool high)
3095 {
3096  if (high)
3097  return m_rep->set(i, m_params);
3098  else
3099  return m_rep->clear(i, m_params);
3100 }
3101 
3102 inline bool
3103 sc_fxnum::get_slice(int i, int j, sc_bv_base &bv) const
3104 {
3105  return m_rep->get_slice(i, j, m_params, bv);
3106 }
3107 
3108 inline bool
3109 sc_fxnum::set_slice(int i, int j, const sc_bv_base &bv)
3110 {
3111  return m_rep->set_slice(i, j, m_params, bv);
3112 }
3113 
3114 inline ::std::ostream &
3115 operator << (::std::ostream &os, const sc_fxnum &a)
3116 {
3117  a.print(os);
3118  return os;
3119 }
3120 
3121 inline ::std::istream &
3122 operator >> (::std::istream &is, sc_fxnum &a)
3123 {
3124  a.scan(is);
3125  return is;
3126 }
3127 
3128 
3129 // ----------------------------------------------------------------------------
3130 // CLASS : sc_fxnum_fast
3131 //
3132 // Base class for the fixed-point types; limited precision.
3133 // ----------------------------------------------------------------------------
3134 
3135 inline sc_fxnum_fast_observer *
3137 {
3138  return m_observer;
3139 }
3140 
3141 
3142 // constructors
3144  sc_enc enc_,
3145  const sc_fxcast_switch &cast_sw,
3146  sc_fxnum_fast_observer *observer_) :
3147  m_val(0.0), m_params(type_params_, enc_, cast_sw), m_q_flag(false),
3148  m_o_flag(false), m_observer(observer_)
3149 {
3152 }
3153 
3155  const sc_fxtype_params &type_params_,
3156  sc_enc enc_,
3157  const sc_fxcast_switch &cast_sw,
3158  sc_fxnum_fast_observer *observer_) :
3159  m_val(a.m_val), m_params(type_params_, enc_, cast_sw), m_q_flag(false),
3160  m_o_flag(false), m_observer(observer_)
3161 {
3164  cast();
3167 }
3168 
3169 #define DEFN_CTOR_T(tp, arg) \
3170 inline sc_fxnum_fast::sc_fxnum_fast( \
3171  tp a, const sc_fxtype_params &type_params_, sc_enc enc_, \
3172  const sc_fxcast_switch &cast_sw, \
3173  sc_fxnum_fast_observer *observer_) : \
3174  m_val(arg), m_params(type_params_, enc_, cast_sw), m_q_flag(false), \
3175  m_o_flag(false), m_observer(observer_) \
3176 { \
3177  SC_FXNUM_FAST_OBSERVER_DEFAULT_ \
3178  cast(); \
3179  SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) \
3180  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3181 }
3182 
3183 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
3184 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, sc_fxval_fast::from_string(a))
3185 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
3186 
3187 DEFN_CTOR_T_A(int)
3188 DEFN_CTOR_T_A(unsigned int)
3189 DEFN_CTOR_T_A(long)
3190 DEFN_CTOR_T_A(unsigned long)
3191 DEFN_CTOR_T_A(float)
3192 DEFN_CTOR_T_A(double)
3193 DEFN_CTOR_T_B(const char *)
3194 DEFN_CTOR_T_C(const sc_fxval &)
3196 DEFN_CTOR_T_C(const sc_fxnum &)
3197 
3200 DEFN_CTOR_T_C(const sc_int_base &)
3201 DEFN_CTOR_T_C(const sc_uint_base &)
3202 DEFN_CTOR_T_C(const sc_signed &)
3203 DEFN_CTOR_T_C(const sc_unsigned &)
3204 
3205 #undef DEFN_CTOR_T
3206 #undef DEFN_CTOR_T_A
3207 #undef DEFN_CTOR_T_B
3208 #undef DEFN_CTOR_T_C
3209 #undef DEFN_CTOR_T_D
3210 #undef DEFN_CTOR_T_E
3211 
3213 {
3215 }
3216 
3217 // internal use only;
3218 inline double
3220 {
3222  return m_val;
3223 }
3224 
3225 // unary operators
3226 inline const sc_fxval_fast
3228 {
3230  return sc_fxval_fast(- m_val);
3231 }
3232 
3233 inline const sc_fxval_fast
3235 {
3237  return sc_fxval_fast(m_val);
3238 }
3239 
3240 // unary functions
3241 inline void
3243 {
3245  c.set_val(- a.m_val);
3246 }
3247 
3248 inline void
3250 {
3252  c.m_val = - a.m_val;
3253  c.cast();
3255 }
3256 
3257 // binary operators
3258 #define DEFN_BIN_OP_T(op, tp) \
3259 inline const sc_fxval_fast \
3260 operator op (const sc_fxnum_fast &a, tp b) \
3261 { \
3262  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3263  sc_fxval_fast tmp(b); \
3264  return sc_fxval_fast(a.m_val op tmp.get_val()); \
3265 } \
3266  \
3267 inline const sc_fxval_fast \
3268 operator op (tp a, const sc_fxnum_fast &b) \
3269 { \
3270  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3271  sc_fxval_fast tmp(a); \
3272  return sc_fxval_fast(tmp.get_val() op b.m_val); \
3273 }
3274 
3275 #define DEFN_BIN_OP_OTHER(op) \
3276 DEFN_BIN_OP_T(op, int64) \
3277 DEFN_BIN_OP_T(op, uint64) \
3278 DEFN_BIN_OP_T(op, const sc_int_base &) \
3279 DEFN_BIN_OP_T(op, const sc_uint_base &) \
3280 DEFN_BIN_OP_T(op, const sc_signed &) \
3281 DEFN_BIN_OP_T(op, const sc_unsigned &)
3282 
3283 #define DEFN_BIN_OP(op, dummy) \
3284 inline const sc_fxval_fast \
3285 operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3286 { \
3287  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3288  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3289  return sc_fxval_fast(a.m_val op b.m_val); \
3290 } \
3291  \
3292 inline const sc_fxval_fast \
3293 operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3294 { \
3295  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3296  return sc_fxval_fast(a.m_val op b.get_val()); \
3297 } \
3298  \
3299 inline const sc_fxval_fast \
3300 operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3301 { \
3302  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3303  return sc_fxval_fast(a.get_val() op b.m_val); \
3304 } \
3305  \
3306 DEFN_BIN_OP_T(op, int) \
3307 DEFN_BIN_OP_T(op, unsigned int) \
3308 DEFN_BIN_OP_T(op, long) \
3309 DEFN_BIN_OP_T(op, unsigned long) \
3310 DEFN_BIN_OP_T(op, float) \
3311 DEFN_BIN_OP_T(op, double) \
3312 DEFN_BIN_OP_T(op, const char *) \
3313 DEFN_BIN_OP_OTHER(op)
3314 
3315 DEFN_BIN_OP(*, mult)
3316 DEFN_BIN_OP(+, add)
3317 DEFN_BIN_OP(-, sub)
3318 //DEFN_BIN_OP(/, div)
3319 inline const sc_fxval_fast
3321 {
3324  return sc_fxval_fast(a.m_val / b.m_val);
3325 }
3326 
3327 inline const sc_fxval_fast
3329 {
3331  return sc_fxval_fast(a.m_val / b.get_val());
3332 }
3333 
3334 inline const sc_fxval_fast
3336 {
3338  return sc_fxval_fast(a.get_val() / b.m_val);
3339 }
3340 
3341 DEFN_BIN_OP_T(/, int)
3342 DEFN_BIN_OP_T(/, unsigned int)
3343 DEFN_BIN_OP_T(/, long)
3344 DEFN_BIN_OP_T(/, unsigned long)
3345 DEFN_BIN_OP_T(/, float)
3346 DEFN_BIN_OP_T(/, double)
3347 DEFN_BIN_OP_T(/, const char *)
3348 //DEFN_BIN_OP_OTHER(/)
3349 
3350 DEFN_BIN_OP_T(/, int64)
3352 DEFN_BIN_OP_T(/, const sc_int_base &)
3353 DEFN_BIN_OP_T(/, const sc_uint_base &)
3354 DEFN_BIN_OP_T(/, const sc_signed &)
3355 DEFN_BIN_OP_T(/, const sc_unsigned &)
3356 
3357 #undef DEFN_BIN_OP_T
3358 #undef DEFN_BIN_OP_OTHER
3359 #undef DEFN_BIN_OP
3360 
3361 inline const sc_fxval_fast
3363 {
3365  return sc_fxval_fast(a.m_val *scfx_pow2(b));
3366 }
3367 
3368 inline const sc_fxval_fast
3370 {
3372  return sc_fxval_fast(a.m_val *scfx_pow2(-b));
3373 }
3374 
3375 // binary functions
3376 #define DEFN_BIN_FNC_T(fnc, op, tp) \
3377 inline void \
3378 fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, tp b) \
3379 { \
3380  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3381  sc_fxval_fast tmp(b); \
3382  c.set_val(a.m_val op tmp.get_val()); \
3383 } \
3384  \
3385 inline void \
3386 fnc (sc_fxval_fast &c, tp a, const sc_fxnum_fast &b) \
3387 { \
3388  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3389  sc_fxval_fast tmp(a); \
3390  c.set_val(tmp.get_val() op b.m_val); \
3391 } \
3392  \
3393 inline void \
3394 fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, tp b) \
3395 { \
3396  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3397  sc_fxval_fast tmp(b); \
3398  c.m_val = a.m_val op tmp.get_val(); \
3399  c.cast(); \
3400  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3401 } \
3402  \
3403 inline void \
3404 fnc (sc_fxnum_fast &c, tp a, const sc_fxnum_fast &b) \
3405 { \
3406  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3407  sc_fxval_fast tmp(a); \
3408  c.m_val = tmp.get_val() op b.m_val; \
3409  c.cast(); \
3410  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3411 }
3412 
3413 #define DEFN_BIN_FNC_OTHER(fnc, op) \
3414 DEFN_BIN_FNC_T(fnc, op, int64) \
3415 DEFN_BIN_FNC_T(fnc, op, uint64) \
3416 DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
3417 DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
3418 DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
3419 DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
3420 
3421 #define DEFN_BIN_FNC(fnc, op) \
3422 inline void \
3423 fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3424 { \
3425  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3426  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3427  c.set_val(a.m_val op b.m_val); \
3428 } \
3429  \
3430 inline void \
3431 fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3432 { \
3433  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3434  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3435  c.m_val = a.m_val op b.m_val; \
3436  c.cast(); \
3437  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3438 } \
3439  \
3440 inline void \
3441 fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3442 { \
3443  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3444  c.set_val(a.m_val op b.get_val()); \
3445 } \
3446  \
3447 inline void \
3448 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3449 { \
3450  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3451  c.set_val(a.get_val() op b.m_val); \
3452 } \
3453  \
3454 inline void \
3455 fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3456 { \
3457  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3458  c.m_val = a.m_val op b.get_val(); \
3459  c.cast(); \
3460  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3461 } \
3462  \
3463 inline void \
3464 fnc (sc_fxnum_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3465 { \
3466  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3467  c.m_val = a.get_val() op b.m_val; \
3468  c.cast(); \
3469  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3470 } \
3471  \
3472 DEFN_BIN_FNC_T(fnc, op, int) \
3473 DEFN_BIN_FNC_T(fnc, op, unsigned int) \
3474 DEFN_BIN_FNC_T(fnc, op, long) \
3475 DEFN_BIN_FNC_T(fnc, op, unsigned long) \
3476 DEFN_BIN_FNC_T(fnc, op, float) \
3477 DEFN_BIN_FNC_T(fnc, op, double) \
3478 DEFN_BIN_FNC_T(fnc, op, const char *) \
3479 DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
3480 DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) \
3481 DEFN_BIN_FNC_OTHER(fnc, op)
3482 
3483 DEFN_BIN_FNC(mult, *)
3484 DEFN_BIN_FNC(div, /)
3485 DEFN_BIN_FNC(add, +)
3486 DEFN_BIN_FNC(sub, -)
3487 
3488 #undef DEFN_BIN_FNC_T
3489 #undef DEFN_BIN_FNC_OTHER
3490 #undef DEFN_BIN_FNC
3491 
3492 inline void
3494 {
3496  c.set_val(a.m_val * scfx_pow2(b));
3497 }
3498 
3499 inline void
3501 {
3503  c.set_val(a.m_val * scfx_pow2(-b));
3504 }
3505 
3506 inline void
3508 {
3510  c.m_val = a.m_val * scfx_pow2(b);
3511  c.cast();
3513 }
3514 
3515 inline void
3517 {
3519  c.m_val = a.m_val * scfx_pow2(-b);
3520  c.cast();
3522 }
3523 
3524 // relational (including equality) operators
3525 #define DEFN_REL_OP_T(op, tp) \
3526 inline bool \
3527 operator op (const sc_fxnum_fast &a, tp b) \
3528 { \
3529  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3530  sc_fxval_fast tmp(b); \
3531  return (a.m_val op tmp.get_val()); \
3532 } \
3533  \
3534 inline bool \
3535 operator op (tp a, const sc_fxnum_fast &b) \
3536 { \
3537  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3538  sc_fxval_fast tmp(a); \
3539  return (tmp.get_val() op b.m_val); \
3540 }
3541 
3542 #define DEFN_REL_OP_OTHER(op) \
3543 DEFN_REL_OP_T(op, int64) \
3544 DEFN_REL_OP_T(op, uint64) \
3545 DEFN_REL_OP_T(op, const sc_int_base &) \
3546 DEFN_REL_OP_T(op, const sc_uint_base &) \
3547 DEFN_REL_OP_T(op, const sc_signed &) \
3548 DEFN_REL_OP_T(op, const sc_unsigned &)
3549 
3550 #define DEFN_REL_OP(op) \
3551 inline bool \
3552 operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3553 { \
3554  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3555  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3556  return (a.m_val op b.m_val); \
3557 } \
3558  \
3559 inline bool \
3560 operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3561 { \
3562  SC_FXNUM_FAST_OBSERVER_READ_(a) \
3563  return (a.m_val op b.get_val()); \
3564 } \
3565  \
3566 inline bool \
3567 operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3568 { \
3569  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3570  return (a.get_val() op b.m_val); \
3571 } \
3572  \
3573 DEFN_REL_OP_T(op, int) \
3574 DEFN_REL_OP_T(op, unsigned int) \
3575 DEFN_REL_OP_T(op, long) \
3576 DEFN_REL_OP_T(op, unsigned long) \
3577 DEFN_REL_OP_T(op, float) \
3578 DEFN_REL_OP_T(op, double) \
3579 DEFN_REL_OP_T(op, const char *) \
3580 DEFN_REL_OP_OTHER(op)
3581 
3582 DEFN_REL_OP(<)
3583 DEFN_REL_OP(<=)
3584 DEFN_REL_OP(>)
3585 DEFN_REL_OP(>=)
3586 DEFN_REL_OP(==)
3587 DEFN_REL_OP(!=)
3588 
3589 #undef DEFN_REL_OP_T
3590 #undef DEFN_REL_OP_OTHER
3591 #undef DEFN_REL_OP
3592 
3593 // assignment operators
3594 
3595 inline sc_fxnum_fast &
3596 sc_fxnum_fast::operator = (const sc_fxnum_fast &a)
3597 {
3598  if (&a != this) {
3600  m_val = a.m_val;
3601  cast();
3603  }
3604  return *this;
3605 }
3606 
3607 inline sc_fxnum_fast &
3608 sc_fxnum_fast::operator = (const sc_fxval_fast &a)
3609 {
3610  m_val = a.get_val();
3611  cast();
3613  return *this;
3614 }
3615 
3616 #define DEFN_ASN_OP_T(tp) \
3617 inline sc_fxnum_fast & \
3618 sc_fxnum_fast::operator = (tp a) \
3619 { \
3620  sc_fxval_fast tmp(a); \
3621  m_val = tmp.get_val(); \
3622  cast(); \
3623  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3624  return *this; \
3625 }
3626 
3627 DEFN_ASN_OP_T(int)
3628 DEFN_ASN_OP_T(unsigned int)
3629 DEFN_ASN_OP_T(long)
3630 DEFN_ASN_OP_T(unsigned long)
3631 DEFN_ASN_OP_T(float)
3632 DEFN_ASN_OP_T(double)
3633 DEFN_ASN_OP_T(const char *)
3634 DEFN_ASN_OP_T(const sc_fxval &)
3635 DEFN_ASN_OP_T(const sc_fxnum &)
3636 
3639 DEFN_ASN_OP_T(const sc_int_base &)
3640 DEFN_ASN_OP_T(const sc_uint_base &)
3641 DEFN_ASN_OP_T(const sc_signed &)
3642 DEFN_ASN_OP_T(const sc_unsigned &)
3643 
3644 #undef DEFN_ASN_OP_T
3645 
3646 #define DEFN_ASN_OP_T(op, tp) \
3647 inline sc_fxnum_fast & \
3648 sc_fxnum_fast::operator op (tp b) \
3649 { \
3650  SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3651  sc_fxval_fast tmp(b); \
3652  m_val op tmp.get_val(); \
3653  cast(); \
3654  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3655  return *this; \
3656 }
3657 
3658 #define DEFN_ASN_OP_OTHER(op) \
3659 DEFN_ASN_OP_T(op, int64) \
3660 DEFN_ASN_OP_T(op, uint64) \
3661 DEFN_ASN_OP_T(op, const sc_int_base &) \
3662 DEFN_ASN_OP_T(op, const sc_uint_base &) \
3663 DEFN_ASN_OP_T(op, const sc_signed &) \
3664 DEFN_ASN_OP_T(op, const sc_unsigned &)
3665 
3666 #define DEFN_ASN_OP(op) \
3667 inline sc_fxnum_fast & \
3668 sc_fxnum_fast::operator op (const sc_fxnum_fast &b) \
3669 { \
3670  SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3671  SC_FXNUM_FAST_OBSERVER_READ_(b) \
3672  m_val op b.m_val; \
3673  cast(); \
3674  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3675  return *this; \
3676 } \
3677  \
3678 inline sc_fxnum_fast & \
3679 sc_fxnum_fast::operator op (const sc_fxval_fast &b) \
3680 { \
3681  SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3682  m_val op b.get_val(); \
3683  cast(); \
3684  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3685  return *this; \
3686 } \
3687  \
3688 DEFN_ASN_OP_T(op, int) \
3689 DEFN_ASN_OP_T(op, unsigned int) \
3690 DEFN_ASN_OP_T(op, long) \
3691 DEFN_ASN_OP_T(op, unsigned long) \
3692 DEFN_ASN_OP_T(op, float) \
3693 DEFN_ASN_OP_T(op, double) \
3694 DEFN_ASN_OP_T(op, const char *) \
3695 DEFN_ASN_OP_T(op, const sc_fxval &) \
3696 DEFN_ASN_OP_T(op, const sc_fxnum &) \
3697 DEFN_ASN_OP_OTHER(op)
3698 
3699 DEFN_ASN_OP(*=)
3700 DEFN_ASN_OP(/=)
3701 DEFN_ASN_OP(+=)
3702 DEFN_ASN_OP(-=)
3703 
3704 #undef DEFN_ASN_OP_T
3705 #undef DEFN_ASN_OP_OTHER
3706 #undef DEFN_ASN_OP
3707 
3708 inline sc_fxnum_fast &
3709 sc_fxnum_fast::operator <<= (int b)
3710 {
3712  m_val *= scfx_pow2(b);
3713  cast();
3715  return *this;
3716 }
3717 
3718 inline sc_fxnum_fast &
3719 sc_fxnum_fast::operator >>= (int b)
3720 {
3722  m_val *= scfx_pow2(-b);
3723  cast();
3725  return *this;
3726 }
3727 
3728 // auto-increment and auto-decrement
3729 inline const sc_fxval_fast
3730 sc_fxnum_fast::operator ++ (int)
3731 {
3734  double c = m_val;
3735  m_val = m_val + 1;
3736  cast();
3738  return sc_fxval_fast(c);
3739 }
3740 
3741 inline const sc_fxval_fast
3743 {
3746  double c = m_val;
3747  m_val = m_val - 1;
3748  cast();
3750  return sc_fxval_fast(c);
3751 }
3752 
3753 inline sc_fxnum_fast &
3755 {
3757  m_val = m_val + 1;
3758  cast();
3760  return *this;
3761 }
3762 
3763 inline sc_fxnum_fast &
3765 {
3767  m_val = m_val - 1;
3768  cast();
3770  return *this;
3771 }
3772 
3773 // bit selection
3774 inline const sc_fxnum_fast_bitref
3776 {
3778  return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3779  i - m_params.fwl());
3780 }
3781 
3782 inline sc_fxnum_fast_bitref
3784 {
3786  return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3787 }
3788 
3789 inline const sc_fxnum_fast_bitref
3791 {
3793  return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3794  i - m_params.fwl());
3795 }
3796 
3797 inline sc_fxnum_fast_bitref
3799 {
3801  return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3802 }
3803 
3804 // part selection
3805 inline const sc_fxnum_fast_subref
3807 {
3810 
3811  return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3812  i - m_params.fwl(), j - m_params.fwl());
3813 }
3814 
3815 inline sc_fxnum_fast_subref
3817 {
3820 
3821  return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3822 }
3823 
3824 inline const sc_fxnum_fast_subref
3825 sc_fxnum_fast::range(int i, int j) const
3826 {
3829 
3830  return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3831  i - m_params.fwl(), j - m_params.fwl());
3832 }
3833 
3834 inline sc_fxnum_fast_subref
3836 {
3839 
3840  return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3841 }
3842 
3843 inline const sc_fxnum_fast_subref
3845 {
3846  return this->operator () (m_params.wl() - 1, 0);
3847 }
3848 
3849 inline sc_fxnum_fast_subref
3851 {
3852  return this->operator () (m_params.wl() - 1, 0);
3853 }
3854 
3855 inline const sc_fxnum_fast_subref
3857 {
3858  return this->range(m_params.wl() - 1, 0);
3859 }
3860 
3861 inline sc_fxnum_fast_subref
3863 {
3864  return this->range(m_params.wl() - 1, 0);
3865 }
3866 
3867 // implicit conversion
3868 inline sc_fxnum_fast::operator double() const
3869 {
3871  return m_val;
3872 }
3873 
3874 // explicit conversion to primitive types
3875 inline short
3877 {
3878  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3879  return static_cast<short>(to_uint64());
3880 }
3881 
3882 inline unsigned short
3884 {
3885  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3886  return static_cast<unsigned short>(to_uint64());
3887 }
3888 
3889 inline int
3891 {
3892  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3893  return static_cast<int>(to_uint64());
3894 }
3895 
3896 inline int64
3898 {
3899  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3900  return static_cast<int64>(to_uint64());
3901 }
3902 
3903 inline unsigned int
3905 {
3906  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3907  return static_cast<unsigned int>(to_uint64());
3908 }
3909 
3910 inline uint64
3912 {
3913  // SC_FXNUM_FAST_OBSERVER_READ_ in is_normal
3914  if (!is_normal()) {
3915  return 0;
3916  }
3917 
3918  int exponent;
3919  double mantissa_dbl = frexp(m_val, &exponent);
3920 
3921  uint64 mantissa = static_cast<uint64>(fabs(mantissa_dbl) *
3922  (UINT64_ONE << 53));
3923  exponent -= 53;
3924 
3925  if (!(-64 < exponent && exponent < 64)) {
3926  return 0;
3927  }
3928 
3929  mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
3930  return mantissa_dbl >= 0 ? mantissa : -mantissa;
3931 }
3932 
3933 inline long
3935 {
3936  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3937  return static_cast<long>(to_uint64());
3938 }
3939 
3940 inline unsigned long
3942 {
3943  // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64
3944  return static_cast<unsigned long>(to_uint64());
3945 }
3946 
3947 inline float
3949 {
3951  return static_cast<float>(m_val);
3952 }
3953 
3954 inline double
3956 {
3958  return m_val;
3959 }
3960 
3961 // query value
3962 inline bool
3964 {
3967  return (id.negative() != 0);
3968 }
3969 
3970 inline bool
3972 {
3975  return id.is_zero();
3976 }
3977 
3978 // internal use only;
3979 inline bool
3981 {
3984  return (id.is_normal() || id.is_subnormal() || id.is_zero());
3985 }
3986 
3987 inline bool
3989 {
3990  return m_q_flag;
3991 }
3992 
3993 inline bool
3995 {
3996  return m_o_flag;
3997 }
3998 
3999 inline const sc_fxval_fast
4001 {
4003  return sc_fxval_fast(m_val);
4004 }
4005 
4006 // query parameters
4007 inline int
4009 {
4010  return m_params.wl();
4011 }
4012 
4013 inline int
4015 {
4016  return m_params.iwl();
4017 }
4018 
4019 inline sc_q_mode
4021 {
4022  return m_params.q_mode();
4023 }
4024 
4025 inline sc_o_mode
4027 {
4028  return m_params.o_mode();
4029 }
4030 
4031 inline int
4033 {
4034  return m_params.n_bits();
4035 }
4036 
4037 inline const sc_fxtype_params &
4039 {
4040  return m_params.type_params();
4041 }
4042 
4043 inline const sc_fxcast_switch &
4045 {
4046  return m_params.cast_switch();
4047 }
4048 
4049 // internal use only;
4050 inline void
4052 {
4054 }
4055 
4056 inline ::std::ostream &
4057 operator << (::std::ostream &os, const sc_fxnum_fast &a)
4058 {
4059  a.print(os);
4060  return os;
4061 }
4062 
4063 inline ::std::istream &
4064 operator >> (::std::istream &is, sc_fxnum_fast &a)
4065 {
4066  a.scan(is);
4067  return is;
4068 }
4069 
4070 
4071 // ----------------------------------------------------------------------------
4072 // CLASS : sc_fxval
4073 //
4074 // Fixed-point value type; arbitrary precision.
4075 // ----------------------------------------------------------------------------
4076 
4077 // public constructors
4078 inline sc_fxval::sc_fxval(const sc_fxnum &a, sc_fxval_observer *observer_) :
4079  m_rep(new scfx_rep(*a.get_rep())), m_observer(observer_)
4080 {
4084 }
4085 
4087  sc_fxval_observer *observer_) :
4088  m_rep(new scfx_rep(a.to_double())), m_observer(observer_)
4089 {
4093 }
4094 
4095 // binary operators
4096 #define DEFN_BIN_OP_T(op, fnc, tp) \
4097 inline const sc_fxval \
4098 operator op (const sc_fxval &a, tp b) \
4099 { \
4100  SC_FXVAL_OBSERVER_READ_(a) \
4101  sc_fxval tmp(b); \
4102  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
4103 } \
4104  \
4105 inline const sc_fxval \
4106 operator op (tp a, const sc_fxval &b) \
4107 { \
4108  SC_FXVAL_OBSERVER_READ_(b) \
4109  sc_fxval tmp(a); \
4110  return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
4111 }
4112 
4113 #define DEFN_BIN_OP(op, fnc) \
4114 DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &)
4115 
4116 DEFN_BIN_OP(*, mult)
4117 DEFN_BIN_OP(+, add)
4118 DEFN_BIN_OP(-, sub)
4119 //DEFN_BIN_OP(/, div)
4120 DEFN_BIN_OP_T(/, div, const sc_fxnum_fast &)
4121 
4122 #undef DEFN_BIN_OP_T
4123 #undef DEFN_BIN_OP
4124 
4125 
4126 // binary functions
4127 #define DEFN_BIN_FNC_T(fnc, tp) \
4128 inline void \
4129 fnc (sc_fxval &c, const sc_fxval &a, tp b) \
4130 { \
4131  SC_FXVAL_OBSERVER_READ_(a) \
4132  sc_fxval tmp(b); \
4133  delete c.m_rep; \
4134  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
4135  SC_FXVAL_OBSERVER_WRITE_(c) \
4136 } \
4137  \
4138 inline void \
4139 fnc (sc_fxval &c, tp a, const sc_fxval &b) \
4140 { \
4141  SC_FXVAL_OBSERVER_READ_(b) \
4142  sc_fxval tmp(a); \
4143  delete c.m_rep; \
4144  c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
4145  SC_FXVAL_OBSERVER_WRITE_(c) \
4146 }
4147 
4148 #define DEFN_BIN_FNC(fnc) \
4149 DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &)
4150 
4151 DEFN_BIN_FNC(mult)
4152 DEFN_BIN_FNC(div)
4153 DEFN_BIN_FNC(add)
4154 DEFN_BIN_FNC(sub)
4155 
4156 #undef DEFN_BIN_FNC_T
4157 #undef DEFN_BIN_FNC
4158 
4159 
4160 // relational (including equality) operators
4161 #define DEFN_REL_OP_T(op, ret, tp) \
4162 inline bool \
4163 operator op (const sc_fxval &a, tp b) \
4164 { \
4165  SC_FXVAL_OBSERVER_READ_(a) \
4166  sc_fxval tmp(b); \
4167  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
4168  return (ret); \
4169 } \
4170  \
4171 inline bool \
4172 operator op (tp a, const sc_fxval &b) \
4173 { \
4174  SC_FXVAL_OBSERVER_READ_(b) \
4175  sc_fxval tmp(a); \
4176  int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
4177  return (ret); \
4178 }
4179 
4180 #define DEFN_REL_OP(op, ret) \
4181 DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &)
4182 
4183 DEFN_REL_OP(<, result < 0)
4184 DEFN_REL_OP(<=, result <= 0)
4185 DEFN_REL_OP(>, result > 0 && result != 2)
4186 DEFN_REL_OP(>=, result >= 0 && result != 2)
4187 DEFN_REL_OP(==, result == 0)
4188 DEFN_REL_OP(!=, result != 0)
4189 
4190 #undef DEFN_REL_OP_T
4191 #undef DEFN_REL_OP
4192 
4193 // assignment operators
4194 inline sc_fxval &
4195 sc_fxval::operator = (const sc_fxnum &a)
4196 {
4197  *m_rep = *a.get_rep();
4199  return *this;
4200 }
4201 
4202 #define DEFN_ASN_OP_T(tp) \
4203 inline sc_fxval & \
4204 sc_fxval::operator = (tp b) \
4205 { \
4206  sc_fxval tmp(b); \
4207  *m_rep = *tmp.m_rep; \
4208  SC_FXVAL_OBSERVER_WRITE_(*this) \
4209  return *this; \
4210 }
4211 
4212 DEFN_ASN_OP_T(const sc_fxnum_fast &)
4213 
4214 #undef DEFN_ASN_OP_T
4215 
4216 #define DEFN_ASN_OP_T(op, fnc, tp) \
4217 inline sc_fxval & \
4218 sc_fxval::operator op (tp b) \
4219 { \
4220  SC_FXVAL_OBSERVER_READ_(*this) \
4221  sc_fxval tmp(b); \
4222  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
4223  delete m_rep; \
4224  m_rep = new_rep; \
4225  SC_FXVAL_OBSERVER_WRITE_(*this) \
4226  return *this; \
4227 }
4228 
4229 #define DEFN_ASN_OP(op, fnc) \
4230 inline sc_fxval & \
4231 sc_fxval::operator op (const sc_fxnum &b) \
4232 { \
4233  SC_FXVAL_OBSERVER_READ_(*this) \
4234  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
4235  delete m_rep; \
4236  m_rep = new_rep; \
4237  SC_FXVAL_OBSERVER_WRITE_(*this) \
4238  return *this; \
4239 } \
4240  \
4241 DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &)
4242 
4243 DEFN_ASN_OP(*=, mult)
4244 DEFN_ASN_OP(/=, div)
4245 DEFN_ASN_OP(+=, add)
4246 DEFN_ASN_OP(-=, sub)
4247 
4248 #undef DEFN_ASN_OP_T
4249 #undef DEFN_ASN_OP
4250 
4251 
4252 // ----------------------------------------------------------------------------
4253 // CLASS : sc_fxval_fast
4254 //
4255 // Fixed-point value types; limited precision.
4256 // ----------------------------------------------------------------------------
4257 
4258 // public constructors
4259 
4260 inline
4262  sc_fxval_fast_observer *observer_) :
4263  m_val(a.to_double()), m_observer(observer_)
4264 {
4268 }
4269 
4271  sc_fxval_fast_observer *observer_) :
4272  m_val(a.get_val()), m_observer(observer_)
4273 {
4277 }
4278 
4279 
4280 // binary functions
4281 #define DEFN_BIN_FNC_T(fnc, op, tp) \
4282 inline void \
4283 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
4284 { \
4285  SC_FXVAL_FAST_OBSERVER_READ_(a) \
4286  sc_fxval_fast tmp(b); \
4287  c.m_val = a.m_val op tmp.m_val; \
4288  SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
4289 } \
4290  \
4291 inline void \
4292 fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
4293 { \
4294  SC_FXVAL_FAST_OBSERVER_READ_(b) \
4295  sc_fxval_fast tmp(a); \
4296  c.m_val = tmp.m_val op b.m_val; \
4297  SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
4298 }
4299 
4300 #define DEFN_BIN_FNC(fnc, op) \
4301 DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
4302 DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &)
4303 
4304 DEFN_BIN_FNC(mult, *)
4305 DEFN_BIN_FNC(div, /)
4306 DEFN_BIN_FNC(add, +)
4307 DEFN_BIN_FNC(sub, -)
4308 
4309 #undef DEFN_BIN_FNC_T
4310 #undef DEFN_BIN_FNC
4311 
4312 
4313 // assignment operators
4314 inline sc_fxval_fast &
4315 sc_fxval_fast::operator = (const sc_fxnum_fast &a)
4316 {
4317  m_val = a.get_val();
4319  return *this;
4320 }
4321 
4322 #define DEFN_ASN_OP_T(tp) \
4323 inline sc_fxval_fast & \
4324 sc_fxval_fast::operator = (tp a) \
4325 { \
4326  sc_fxval_fast tmp(a); \
4327  m_val = tmp.m_val; \
4328  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4329  return *this; \
4330 }
4331 
4332 DEFN_ASN_OP_T(const sc_fxnum &)
4333 
4334 #undef DEFN_ASN_OP_T
4335 
4336 #define DEFN_ASN_OP_T(op, tp) \
4337 inline sc_fxval_fast & \
4338 sc_fxval_fast::operator op (tp b) \
4339 { \
4340  SC_FXVAL_FAST_OBSERVER_READ_(*this) \
4341  sc_fxval_fast tmp(b); \
4342  m_val op tmp.m_val; \
4343  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4344  return *this; \
4345 }
4346 
4347 #define DEFN_ASN_OP(op) \
4348 inline sc_fxval_fast & \
4349 sc_fxval_fast::operator op (const sc_fxnum_fast &b) \
4350 { \
4351  SC_FXVAL_FAST_OBSERVER_READ_(*this) \
4352  m_val op b.get_val(); \
4353  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4354  return *this; \
4355 } \
4356  \
4357 DEFN_ASN_OP_T(op, const sc_fxnum &)
4358 
4359 DEFN_ASN_OP(*=)
4360 DEFN_ASN_OP(/=)
4361 DEFN_ASN_OP(+=)
4362 DEFN_ASN_OP(-=)
4363 
4364 #undef DEFN_ASN_OP_T
4365 #undef DEFN_ASN_OP
4366 
4367 } // namespace sc_dt
4368 
4369 #endif // __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
sc_dt::sc_fxnum::sc_fxnum_bitref
friend class sc_fxnum_bitref
Definition: sc_fxnum.hh:487
sc_dt::sc_fxnum_fast::m_q_flag
bool m_q_flag
Definition: sc_fxnum.hh:1184
sc_dt::sc_fxnum_subref::to_string
const std::string to_string() const
Definition: sc_fxnum.hh:1826
sc_dt::sc_fxnum_fast_subref::sc_fxnum_fast_subref
sc_fxnum_fast_subref()
sc_dt::sc_fxval_fast_observer
Definition: sc_fxval_observer.hh:164
DECL_ASN_OP
#define DECL_ASN_OP(op)
Definition: sc_fxnum.hh:1053
sc_dt::sc_fxnum::observer
sc_fxnum_observer * observer() const
Definition: sc_fxnum.hh:2170
sc_dt::sc_fxnum::to_uint64
uint64 to_uint64() const
Definition: sc_fxnum.hh:2958
sc_dt::scfx_params::q_mode
sc_q_mode q_mode() const
Definition: scfx_params.hh:181
sc_dt::sc_fxnum_fast::to_ulong
unsigned long to_ulong() const
Definition: sc_fxnum.hh:3941
sc_dt::sc_fxnum_fast_subref::to_ulong
unsigned long to_ulong() const
Definition: sc_fxnum.hh:2111
sc_dt::sc_fxnum::to_double
double to_double() const
Definition: sc_fxnum.hh:2986
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
sc_dt::sc_proxy::to_int64
int64 to_int64() const
Definition: sc_proxy.hh:466
sc_dt::sc_fxnum_fast_bitref::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:135
sc_dt::sc_fxnum::observer_read
void observer_read() const
Definition: sc_fxnum.hh:3080
sc_dt::sc_fxnum_fast_subref::to_uint
unsigned int to_uint() const
Definition: sc_fxnum.hh:2087
sc_dt::sc_fxnum::operator+
const sc_fxval operator+() const
Definition: sc_fxnum.hh:2262
sc_dt::sc_fxnum_subref::sc_fxnum_subref
sc_fxnum_subref()
sc_dt::sc_fxnum_fast_subref
Definition: sc_fxnum.hh:349
sc_dt::sc_fxnum::to_ushort
unsigned short to_ushort() const
Definition: sc_fxnum.hh:2930
sc_dt::sc_fxnum_fast::~sc_fxnum_fast
~sc_fxnum_fast()
Definition: sc_fxnum.hh:3212
DEFN_CTOR_T_C
#define DEFN_CTOR_T_C(tp)
Definition: sc_fxnum.hh:3185
sc_dt::sc_fxnum_fast::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:709
sc_dt::sc_fxnum_subref::m_from
int m_from
Definition: sc_fxnum.hh:331
sc_dt::sc_fxnum_fast::operator()
const sc_fxnum_fast_subref operator()() const
Definition: sc_fxnum.hh:3844
sc_dt::scfx_rep
Definition: scfx_rep.hh:169
sc_dt::operator|=
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.hh:450
sc_dt::sc_fxnum_bitref
Definition: sc_fxnum.hh:97
sc_dt::sc_fxnum::sc_fxval
friend class sc_fxval
Definition: sc_fxnum.hh:485
sc_dt::sc_fxnum_fast::set_bit
bool set_bit(int, bool)
Definition: sc_fxnum.cc:773
sc_dt::sc_fxnum_fast::is_zero
bool is_zero() const
Definition: sc_fxnum.hh:3971
sc_dt::sc_fxnum_bitref::get
bool get() const
Definition: sc_fxnum.cc:99
sc_dt::sc_fxnum_subref::m_bv
sc_bv_base & m_bv
Definition: sc_fxnum.hh:334
sc_dt::sc_fxnum_subref::to_ulong
unsigned long to_ulong() const
Definition: sc_fxnum.hh:1817
sc_gem5::TraceValFxnumBase
Definition: sc_fxnum.hh:105
sc_dt::sc_bv_base::length
int length() const
Definition: sc_bv_base.hh:248
sc_dt::sc_fxnum_fast::is_neg
bool is_neg() const
Definition: sc_fxnum.hh:3963
sc_dt::sc_fxnum_fast_subref::to_long
long to_long() const
Definition: sc_fxnum.hh:2103
sc_dt::sc_fxnum_fast::cast
void cast()
Definition: sc_fxnum.cc:596
SC_FXNUM_OBSERVER_CONSTRUCT_
#define SC_FXNUM_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxnum_observer.hh:120
sc_dt::sc_fxnum_fast_subref::xnor_reduce
bool xnor_reduce() const
sc_dt
Definition: sc_bit.cc:67
SC_FXNUM_FAST_OBSERVER_DESTRUCT_
#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object)
Definition: sc_fxnum_observer.hh:127
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_dt::sc_fxnum::set_bit
bool set_bit(int, bool)
Definition: sc_fxnum.hh:3094
sc_dt::sc_fxnum_fast_subref::nand_reduce
bool nand_reduce() const
sc_dt::sc_fxnum_fast::sc_fxnum_fast
sc_fxnum_fast()
sc_dt::sc_fxnum::to_short
short to_short() const
Definition: sc_fxnum.hh:2923
sc_dt::scfx_params
Definition: scfx_params.hh:98
sc_dt::sc_fxnum_fast::sc_fxnum_fast_subref
friend class sc_fxnum_fast_subref
Definition: sc_fxnum.hh:851
sc_dt::sc_fxnum::q_mode
sc_q_mode q_mode() const
Definition: sc_fxnum.hh:3049
SC_FXVAL_FAST_OBSERVER_CONSTRUCT_
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxval_observer.hh:126
sc_dt::sc_fxnum_fast::to_float
float to_float() const
Definition: sc_fxnum.hh:3948
sc_dt::div_scfx_rep
scfx_rep * div_scfx_rep(const scfx_rep &lhs, const scfx_rep &rhs, int div_wl)
Definition: scfx_rep.cc:1527
DEFN_CTOR_T_D
#define DEFN_CTOR_T_D(tp)
Definition: sc_fxnum.hh:2211
DEFN_CTOR_T_A
#define DEFN_CTOR_T_A(tp)
Definition: sc_fxnum.hh:3183
sc_dt::scfx_rep::clear
bool clear(int, const scfx_params &)
Definition: scfx_rep.cc:2429
sc_dt::scfx_params::o_mode
sc_o_mode o_mode() const
Definition: scfx_params.hh:187
SC_FXVAL_FAST_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
Definition: sc_fxval_observer.hh:130
sc_dt::scfx_rep::is_neg
bool is_neg() const
Definition: scfx_rep.hh:404
sc_dt::sc_fxnum_fast
Definition: sc_fxnum.hh:844
sc_dt::sc_fxnum_fast::to_short
short to_short() const
Definition: sc_fxnum.hh:3876
sc_dt::sc_fxnum_fast_bitref::m_idx
int m_idx
Definition: sc_fxnum.hh:198
sc_dt::sc_fxnum::to_oct
const std::string to_oct() const
Definition: sc_fxnum.cc:310
sc_dt::sc_o_mode
sc_o_mode
Definition: sc_fxdefs.hh:117
sc_dt::sc_fxval
Definition: sc_fxval.hh:86
sc_dt::sc_fxnum::m_params
scfx_params m_params
Definition: sc_fxnum.hh:825
sc_dt::sc_fxnum::get_slice
bool get_slice(int, int, sc_bv_base &) const
Definition: sc_fxnum.hh:3103
sc_dt::sc_fxnum_subref::m_num
sc_fxnum & m_num
Definition: sc_fxnum.hh:330
sc_dt::operator<<
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
Definition: sc_signed.cc:853
sc_dt::sc_fxnum::operator>>
const friend sc_fxval operator>>(const sc_fxnum &, int)
Definition: sc_fxnum.hh:2407
sc_dt::sc_fxnum::sc_fxnum
sc_fxnum()
sc_dt::sc_fxnum_fast::observer_read
void observer_read() const
Definition: sc_fxnum.hh:4051
sc_dt::sc_bv_base
Definition: sc_bv_base.hh:105
sc_dt::sc_fxnum_fast::o_mode
sc_o_mode o_mode() const
Definition: sc_fxnum.hh:4026
sc_dt::sc_fxval_fast::m_val
double m_val
Definition: sc_fxval.hh:643
sc_dt::sc_fxnum::m_observer
sc_fxnum_observer * m_observer
Definition: sc_fxnum.hh:829
sc_dt::sc_fxnum_fast_subref::set
bool set()
Definition: sc_fxnum.cc:217
sc_dt::sc_int_base
Definition: sc_int_base.hh:494
sc_dt::sc_fxnum::iwl
int iwl() const
Definition: sc_fxnum.hh:3043
sc_dt::sc_fxval::m_rep
scfx_rep * m_rep
Definition: sc_fxval.hh:364
sc_dt::sc_proxy::to_ulong
unsigned long to_ulong() const
Definition: sc_proxy.hh:479
sc_dt::sc_fxnum::to_bin
const std::string to_bin() const
Definition: sc_fxnum.cc:304
sc_dt::sc_fxnum_subref::xor_reduce
bool xor_reduce() const
sc_dt::scfx_params::wl
int wl() const
Definition: scfx_params.hh:163
sc_dt::sc_fxnum_subref::and_reduce
bool and_reduce() const
sc_dt::operator&=
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.hh:359
sc_dt::sc_fxnum_fast_subref::to_string
const std::string to_string() const
Definition: sc_fxnum.hh:2119
sc_dt::operator/
sc_signed operator/(const sc_unsigned &u, const sc_int_base &v)
Definition: sc_signed.cc:698
sc_dt::sc_fxnum_fast::to_hex
const std::string to_hex() const
Definition: sc_fxnum.cc:696
sc_dt::sc_fxnum_fast::to_string
const std::string to_string() const
Definition: sc_fxnum.cc:639
sc_dt::scfx_pow2
double scfx_pow2(int exp)
Definition: scfx_ieee.hh:599
sc_dt::sc_fxnum_fast::to_bin
const std::string to_bin() const
Definition: sc_fxnum.cc:684
sc_dt::sc_fxnum_fast::lock_observer
sc_fxnum_fast_observer * lock_observer() const
Definition: sc_fxnum.cc:884
sc_dt::sc_fxnum::~sc_fxnum
~sc_fxnum()
Definition: sc_fxnum.hh:2239
sc_dt::sc_fxnum_observer
Definition: sc_fxnum_observer.hh:141
sc_dt::scfx_rep::to_double
double to_double() const
Definition: scfx_rep.cc:754
sc_dt::sc_fxnum_bitref::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:114
sc_dt::sc_signed
Definition: sc_signed.hh:984
sc_dt::sc_fxnum::operator-
const sc_fxval operator-() const
Definition: sc_fxnum.hh:2255
sc_dt::sc_fxnum::neg
friend void neg(sc_fxval &, const sc_fxnum &)
Definition: sc_fxnum.hh:2270
sc_dt::sc_fxnum::m_rep
scfx_rep * m_rep
Definition: sc_fxnum.hh:823
MipsISA::is
Bitfield< 24, 22 > is
Definition: pra_constants.hh:232
sc_dt::sc_enc
sc_enc
Definition: sc_fxdefs.hh:70
sc_dt::sc_fxnum_subref::to_int64
int64 to_int64() const
Definition: sc_fxnum.hh:1785
sc_dt::sc_fxnum_fast::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:703
sc_dt::xor_reduce
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1402
sc_dt::sc_fxnum_fast_subref::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:224
DECL_BIN_OP
#define DECL_BIN_OP(op, dummy)
Definition: sc_fxnum.hh:917
sc_dt::sc_fxnum_fast_bitref::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:138
sc_dt::sc_fxnum::n_bits
int n_bits() const
Definition: sc_fxnum.hh:3061
sc_dt::sc_fxnum_fast::m_val
double m_val
Definition: sc_fxnum.hh:1181
sc_dt::SC_ON
@ SC_ON
Definition: sc_fxdefs.hh:146
sc_dt::sc_fxnum_subref::xnor_reduce
bool xnor_reduce() const
sc_dt::sc_fxnum::set_slice
bool set_slice(int, int, const sc_bv_base &)
Definition: sc_fxnum.hh:3109
sc_dt::sc_fxnum_subref::to_uint64
uint64 to_uint64() const
Definition: sc_fxnum.hh:1801
SC_FXNUM_FAST_OBSERVER_CONSTRUCT_
#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxnum_observer.hh:126
DECL_BIN_OP_T
#define DECL_BIN_OP_T(op, tp)
Definition: sc_fxnum.hh:905
sc_dt::scfx_rep::get_bit
bool get_bit(int) const
Definition: scfx_rep.cc:2360
sc_dt::xnor_reduce
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1409
sc_dt::sc_fxnum_bitref::sc_fxnum_bitref
sc_fxnum_bitref()
SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_OBSERVER_DEFAULT_
Definition: sc_fxval_observer.hh:124
sc_core::SC_ID_OUT_OF_RANGE_
const char SC_ID_OUT_OF_RANGE_[]
Definition: messages.cc:42
sc_dt::sc_fxnum::range
const sc_fxnum_subref range() const
Definition: sc_fxnum.hh:2903
sc_dt::sc_fxtype_params
Definition: sc_fxtype_params.hh:101
sc_dt::sc_fxnum_fast::operator+
const sc_fxval_fast operator+() const
Definition: sc_fxnum.hh:3234
sc_dt::or_reduce
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1388
sc_dt::scfx_rep::cast
void cast(const scfx_params &, bool &, bool &)
Definition: scfx_rep.cc:2056
sc_dt::sc_fxnum_fast::n_bits
int n_bits() const
Definition: sc_fxnum.hh:4032
sc_dt::scfx_params::n_bits
int n_bits() const
Definition: scfx_params.hh:193
sc_dt::sc_fxnum_fast::observer
sc_fxnum_fast_observer * observer() const
Definition: sc_fxnum.hh:3136
sc_dt::sc_fxnum_fast_subref::~sc_fxnum_fast_subref
~sc_fxnum_fast_subref()
Definition: sc_fxnum.hh:1896
sc_dt::sc_proxy::to_string
const std::string to_string() const
Definition: sc_proxy.hh:1240
DEFN_CTOR_T_B
#define DEFN_CTOR_T_B(tp)
Definition: sc_fxnum.hh:3184
DEFN_BIN_OP_T
#define DEFN_BIN_OP_T(op, fnc, tp)
Definition: sc_fxnum.hh:4096
sc_dt::sc_fxnum_subref::nand_reduce
bool nand_reduce() const
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
sc_dt::sc_fxnum::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:330
sc_dt::sc_fxnum::operator/
const friend sc_fxval operator/(const sc_fxnum &, const sc_fxnum &)
Definition: sc_fxnum.hh:2356
sc_dt::sc_fxnum_fast::get_bit
bool get_bit(int) const
Definition: sc_fxnum.cc:737
sc_dt::sc_fxnum_bitref::m_idx
int m_idx
Definition: sc_fxnum.hh:141
sc_dt::sc_fxnum::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:324
sc_dt::sc_fxnum::operator--
sc_fxnum & operator--()
Definition: sc_fxnum.hh:2812
sc_dt::sc_fxval_observer
Definition: sc_fxval_observer.hh:142
DECL_ASN_OP_A
#define DECL_ASN_OP_A(op)
Definition: sc_fxnum.hh:393
sc_dt::sc_fxnum_fast::get_slice
bool get_slice(int, int, sc_bv_base &) const
Definition: sc_fxnum.cc:802
sc_dt::sc_fmt
sc_fmt
Definition: sc_fxdefs.hh:164
sc_dt::sc_fxnum::operator()
const sc_fxnum_subref operator()() const
Definition: sc_fxnum.hh:2891
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
SC_FXNUM_OBSERVER_WRITE_
#define SC_FXNUM_OBSERVER_WRITE_(object)
Definition: sc_fxnum_observer.hh:123
sc_dt::sc_fxnum_fast_observer
Definition: sc_fxnum_observer.hh:163
sc_dt::sc_fxnum_fast::operator-
const sc_fxval_fast operator-() const
Definition: sc_fxnum.hh:3227
sc_dt::sc_fxnum_fast::m_params
scfx_params m_params
Definition: sc_fxnum.hh:1183
sc_dt::UINT64_ONE
static const uint64 UINT64_ONE
Definition: sc_nbdefs.hh:210
sc_dt::sc_fxnum_fast::to_long
long to_long() const
Definition: sc_fxnum.hh:3934
sc_core::SC_ID_INVALID_FX_VALUE_
const char SC_ID_INVALID_FX_VALUE_[]
Definition: messages.cc:40
sc_dt::nand_reduce
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1381
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_dt::sc_q_mode
sc_q_mode
Definition: sc_fxdefs.hh:91
sc_dt::sc_fxnum_subref::or_reduce
bool or_reduce() const
sc_dt::sc_fxnum_fast_subref::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:231
sc_dt::sc_fxnum_fast::to_oct
const std::string to_oct() const
Definition: sc_fxnum.cc:690
sc_dt::neg
void neg(sc_fxval &c, const sc_fxnum &a)
Definition: sc_fxnum.hh:2270
sc_dt::sc_fxnum_fast::operator>>
const friend sc_fxval_fast operator>>(const sc_fxnum_fast &, int)
Definition: sc_fxnum.hh:3369
DEFN_BIN_FNC
#define DEFN_BIN_FNC(fnc)
Definition: sc_fxnum.hh:4300
sc_dt::scfx_params::fwl
int fwl() const
Definition: scfx_params.hh:175
SC_FXVAL_FAST_OBSERVER_WRITE_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
Definition: sc_fxval_observer.hh:129
sc_dt::sc_fxnum_fast_subref::and_reduce
bool and_reduce() const
sc_dt::sc_fxnum_bitref::set
void set(bool)
Definition: sc_fxnum.cc:100
sc_dt::sc_fxnum_fast_subref::to_uint64
uint64 to_uint64() const
Definition: sc_fxnum.hh:2095
sc_dt::neg_scfx_rep
scfx_rep * neg_scfx_rep(const scfx_rep &)
Definition: scfx_rep.hh:371
sc_dt::sc_fxnum::to_string
const std::string to_string() const
Definition: sc_fxnum.cc:259
sc_dt::sc_proxy::to_uint
unsigned int to_uint() const
Definition: sc_proxy.hh:471
sc_dt::sc_fxnum_fast::operator--
sc_fxnum_fast & operator--()
Definition: sc_fxnum.hh:3764
sc_dt::sc_fxnum_subref::nor_reduce
bool nor_reduce() const
sc_dt::lshift
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
Definition: sc_fxnum.hh:2536
SC_FXNUM_OBSERVER_DESTRUCT_
#define SC_FXNUM_OBSERVER_DESTRUCT_(object)
Definition: sc_fxnum_observer.hh:121
sc_dt::sc_fxnum_fast_bitref
Definition: sc_fxnum.hh:155
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_dt::sc_fxnum::to_int
int to_int() const
Definition: sc_fxnum.hh:2937
sc_dt::sc_fxnum::rshift
friend void rshift(sc_fxval &, const sc_fxnum &, int)
Definition: sc_fxnum.hh:2543
sc_dt::sc_fxnum_fast::DECL_BIN_OP_T
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/
sc_dt::sc_fxnum::operator<<
const friend sc_fxval operator<<(const sc_fxnum &, int)
Definition: sc_fxnum.hh:2400
sc_dt::scfx_rep::to_uint64
uint64 to_uint64() const
Definition: scfx_rep.cc:866
sc_dt::sc_fxnum_fast::set_slice
bool set_slice(int, int, const sc_bv_base &)
Definition: sc_fxnum.cc:849
sc_dt::sc_fxnum_subref::m_to
int m_to
Definition: sc_fxnum.hh:332
SC_FXNUM_OBSERVER_READ_
#define SC_FXNUM_OBSERVER_READ_(object)
Definition: sc_fxnum_observer.hh:122
sc_dt::scfx_rep::set
bool set(int, const scfx_params &)
Definition: scfx_rep.cc:2390
sc_dt::sc_bit
Definition: sc_bit.hh:118
sc_dt::sc_fxnum_fast_bitref::sc_fxnum_bitref
friend class sc_fxnum_bitref
Definition: sc_fxnum.hh:158
sc_dt::sc_fxnum::get_bit
bool get_bit(int) const
Definition: sc_fxnum.hh:3087
sc_dt::scfx_rep::set_slice
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
Definition: scfx_rep.cc:2486
DEFN_ASN_OP_T
#define DEFN_ASN_OP_T(tp)
Definition: sc_fxnum.hh:4336
sc_dt::sc_fxnum_subref::to_uint
unsigned int to_uint() const
Definition: sc_fxnum.hh:1793
sc_fxnum_observer.hh
sc_dt::sc_proxy::to_int
int to_int() const
Definition: sc_proxy.hh:468
SC_FXNUM_OBSERVER_DEFAULT_
#define SC_FXNUM_OBSERVER_DEFAULT_
Definition: sc_fxnum_observer.hh:124
sc_dt::sc_fxnum_bitref::sc_fxnum
friend class sc_fxnum
Definition: sc_fxnum.hh:99
sc_dt::sc_fxnum_fast::operator[]
const sc_fxnum_fast_bitref operator[](int) const
Definition: sc_fxnum.hh:3775
sc_dt::sc_fxnum_fast::to_ushort
unsigned short to_ushort() const
Definition: sc_fxnum.hh:3883
sc_dt::sc_fxnum_fast_subref::m_from
int m_from
Definition: sc_fxnum.hh:466
DECL_REL_OP
#define DECL_REL_OP(op)
Definition: sc_fxnum.hh:1019
sc_dt::sc_fxcast_switch
Definition: sc_fxcast_switch.hh:102
sc_dt::scfx_params::type_params
const sc_fxtype_params & type_params() const
Definition: scfx_params.hh:144
sc_dt::sc_fxnum::overflow_flag
bool overflow_flag() const
Definition: sc_fxnum.hh:3022
DECL_ASN_OP_T
#define DECL_ASN_OP_T(op, tp)
Definition: sc_fxnum.hh:1043
sc_dt::sc_fxnum::to_hex
const std::string to_hex() const
Definition: sc_fxnum.cc:316
DECL_CTOR_T
#define DECL_CTOR_T(tp)
Definition: sc_fxnum.hh:865
sc_dt::sc_fxnum::lock_observer
sc_fxnum_observer * lock_observer() const
Definition: sc_fxnum.cc:359
sc_dt::int64
int64_t int64
Definition: sc_nbdefs.hh:205
sc_dt::sc_fxnum_fast::is_normal
bool is_normal() const
Definition: sc_fxnum.hh:3980
SC_FXNUM_FAST_OBSERVER_READ_
#define SC_FXNUM_FAST_OBSERVER_READ_(object)
Definition: sc_fxnum_observer.hh:128
sc_dt::nor_reduce
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1395
sc_dt::sc_fxnum_fast::unlock_observer
void unlock_observer(sc_fxnum_fast_observer *) const
Definition: sc_fxnum.cc:893
sc_dt::sc_fxnum_fast::sc_fxnum_fast_bitref
friend class sc_fxnum_fast_bitref
Definition: sc_fxnum.hh:850
sc_dt::sc_fxnum_fast::to_uint
unsigned int to_uint() const
Definition: sc_fxnum.hh:3904
sc_dt::sc_fxnum::operator++
sc_fxnum & operator++()
Definition: sc_fxnum.hh:2805
sc_dt::sc_fxnum_subref::to_long
long to_long() const
Definition: sc_fxnum.hh:1809
SC_FXVAL_OBSERVER_WRITE_
#define SC_FXVAL_OBSERVER_WRITE_(object)
Definition: sc_fxval_observer.hh:123
sc_dt::sc_fxnum_fast_bitref::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:146
sc_dt::scfx_rep::is_zero
bool is_zero() const
Definition: scfx_rep.hh:407
sc_dt::sc_fxnum_fast::lshift
friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
Definition: sc_fxnum.hh:3493
DEFN_REL_OP
#define DEFN_REL_OP(op)
Definition: sc_fxnum.hh:4180
sc_dt::sc_fxnum::get_rep
const scfx_rep * get_rep() const
Definition: sc_fxnum.hh:2247
sc_dt::sc_fxnum_fast::m_o_flag
bool m_o_flag
Definition: sc_fxnum.hh:1185
messages.hh
sc_dt::sc_fxnum_fast_subref::nor_reduce
bool nor_reduce() const
sc_dt::sc_min
const T sc_min(const T &a, const T &b)
Definition: functions.hh:59
sc_dt::sc_uint_base
Definition: sc_uint_base.hh:465
sc_dt::sc_fxnum_subref::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:184
sc_dt::sc_fxnum_fast::to_uint64
uint64 to_uint64() const
Definition: sc_fxnum.hh:3911
sc_dt::sc_fxnum::o_mode
sc_o_mode o_mode() const
Definition: sc_fxnum.hh:3055
sc_dt::sc_fxnum_fast::bit
const sc_fxnum_fast_bitref bit(int) const
Definition: sc_fxnum.hh:3790
sc_dt::sc_fxnum_fast_subref::or_reduce
bool or_reduce() const
sc_dt::sc_fxnum::to_dec
const std::string to_dec() const
Definition: sc_fxnum.cc:298
sc_dt::sc_fxnum_fast_subref::to_int64
int64 to_int64() const
Definition: sc_fxnum.hh:2079
sc_dt::sc_fxnum_bitref::sc_fxnum_fast_bitref
friend class sc_fxnum_fast_bitref
Definition: sc_fxnum.hh:100
sc_dt::sc_fxnum::wl
int wl() const
Definition: sc_fxnum.hh:3037
sc_dt::rshift
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
Definition: sc_fxnum.hh:2543
sc_dt::sc_fxval::sc_fxval
sc_fxval(scfx_rep *)
Definition: sc_fxval.hh:662
sc_dt::sc_numrep
sc_numrep
Definition: sc_nbdefs.hh:115
sc_dt::sc_fxnum_fast::cast_switch
const sc_fxcast_switch & cast_switch() const
Definition: sc_fxnum.hh:4044
SC_FXNUM_FAST_OBSERVER_WRITE_
#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
Definition: sc_fxnum_observer.hh:129
sc_dt::sc_lv_base
Definition: sc_lv_base.hh:118
sc_dt::sc_proxy::to_long
long to_long() const
Definition: sc_proxy.hh:476
sc_dt::sc_fxnum::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:338
sc_dt::sc_fxnum_bitref::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:103
sc_dt::sc_fxnum_fast_bitref::get
bool get() const
Definition: sc_fxnum.cc:131
sc_fxval
#define sc_fxval
Definition: fx_precision_double.h:65
sc_dt::sc_fxnum_subref::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:177
sc_dt::sc_fxnum_fast_subref::to_int
int to_int() const
Definition: sc_fxnum.hh:2071
sc_dt::sc_fxnum_fast::q_mode
sc_q_mode q_mode() const
Definition: sc_fxnum.hh:4020
sc_dt::sc_fxnum_fast_subref::length
int length() const
Definition: sc_fxnum.hh:2064
sc_dt::operator>>
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
Definition: sc_signed.cc:866
sc_dt::sc_fxnum::to_long
long to_long() const
Definition: sc_fxnum.hh:2965
sc_dt::sc_fxnum_fast::range
const sc_fxnum_fast_subref range() const
Definition: sc_fxnum.hh:3856
sc_dt::sc_max
const T sc_max(const T &a, const T &b)
Definition: functions.hh:56
sc_dt::sc_fxnum::is_zero
bool is_zero() const
Definition: sc_fxnum.hh:3001
sc_dt::sc_fxnum_fast_bitref::m_num
sc_fxnum_fast & m_num
Definition: sc_fxnum.hh:197
sc_dt::sc_fxnum_fast::operator++
sc_fxnum_fast & operator++()
Definition: sc_fxnum.hh:3754
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
sc_dt::sc_fxnum_fast_subref::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:238
sc_dt::sc_fxnum_fast::get_val
double get_val() const
Definition: sc_fxnum.hh:3219
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
sc_dt::sc_fxnum::m_o_flag
bool m_o_flag
Definition: sc_fxnum.hh:827
sc_dt::sc_fxnum_fast::to_dec
const std::string to_dec() const
Definition: sc_fxnum.cc:678
sc_dt::sc_fxnum_fast::value
const sc_fxval_fast value() const
Definition: sc_fxnum.hh:4000
sc_dt::sc_fxnum_subref::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:191
sc_dt::sc_fxnum_fast::type_params
const sc_fxtype_params & type_params() const
Definition: sc_fxnum.hh:4038
sc_dt::sc_fxnum_subref::length
int length() const
Definition: sc_fxnum.hh:1770
sc_dt::sc_fxnum::type_params
const sc_fxtype_params & type_params() const
Definition: sc_fxnum.hh:3067
sc_dt::sc_proxy::to_uint64
uint64 to_uint64() const
Definition: sc_proxy.hh:1315
sc_dt::sc_fxnum::to_ulong
unsigned long to_ulong() const
Definition: sc_fxnum.hh:2972
sc_dt::sc_fxnum_fast::operator/
const friend sc_fxval_fast operator/(const sc_fxnum_fast &, const sc_fxnum_fast &)
Definition: sc_fxnum.hh:3320
sc_dt::and_reduce
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.hh:1374
sc_dt::sc_fxnum_fast::iwl
int iwl() const
Definition: sc_fxnum.hh:4014
sc_dt::operator^=
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.hh:541
DECL_BIN_FNC
#define DECL_BIN_FNC(fnc)
Definition: sc_fxnum.hh:975
sc_dt::sc_fxnum_fast::to_int64
int64 to_int64() const
Definition: sc_fxnum.hh:3897
sc_dt::sc_fxnum_fast::neg
friend void neg(sc_fxval_fast &, const sc_fxnum_fast &)
Definition: sc_fxnum.hh:3242
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_dt::sc_fxnum::lshift
friend void lshift(sc_fxval &, const sc_fxnum &, int)
Definition: sc_fxnum.hh:2536
sc_dt::sc_fxnum::sc_fxnum_subref
friend class sc_fxnum_subref
Definition: sc_fxnum.hh:488
sc_dt::sc_fxnum::m_q_flag
bool m_q_flag
Definition: sc_fxnum.hh:826
sc_dt::sc_fxnum_fast::to_int
int to_int() const
Definition: sc_fxnum.hh:3890
sc_dt::sc_fxnum_subref::~sc_fxnum_subref
~sc_fxnum_subref()
Definition: sc_fxnum.hh:1604
sc_dt::sc_fxnum::is_neg
bool is_neg() const
Definition: sc_fxnum.hh:2994
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
sc_gem5
Definition: sc_clock.cc:42
sc_dt::sc_fxnum::bit
const sc_fxnum_bitref bit(int) const
Definition: sc_fxnum.hh:2835
sc_dt::scfx_params::iwl
int iwl() const
Definition: scfx_params.hh:169
sc_dt::sc_fxnum::unlock_observer
void unlock_observer(sc_fxnum_observer *) const
Definition: sc_fxnum.cc:368
sc_dt::sc_fxnum_subref
Definition: sc_fxnum.hh:213
SC_FXNUM_FAST_OBSERVER_DEFAULT_
#define SC_FXNUM_FAST_OBSERVER_DEFAULT_
Definition: sc_fxnum_observer.hh:130
DEFN_BIN_OP
#define DEFN_BIN_OP(op, fnc)
Definition: sc_fxnum.hh:4113
sc_dt::scfx_rep::is_normal
bool is_normal() const
Definition: scfx_rep.hh:424
sc_dt::sc_fxnum_fast_subref::m_bv
sc_bv_base & m_bv
Definition: sc_fxnum.hh:469
sc_dt::scfx_ieee_double
Definition: scfx_ieee.hh:146
sc_dt::lsh_scfx_rep
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.hh:387
sc_dt::sc_fxnum::to_uint
unsigned int to_uint() const
Definition: sc_fxnum.hh:2951
sc_dt::sc_fxnum::to_int64
int64 to_int64() const
Definition: sc_fxnum.hh:2944
sc_dt::sc_fxnum_fast::wl
int wl() const
Definition: sc_fxnum.hh:4008
scfx_params.hh
sc_dt::sc_fxnum_fast_subref::xor_reduce
bool xor_reduce() const
sc_dt::sc_fxnum::is_normal
bool is_normal() const
Definition: sc_fxnum.hh:3009
sc_dt::sc_fxnum::to_float
float to_float() const
Definition: sc_fxnum.hh:2979
SC_ERROR_IF_
#define SC_ERROR_IF_(cnd, id)
Definition: sc_fxdefs.hh:251
sc_dt::sc_fxnum_fast_subref::get
bool get() const
Definition: sc_fxnum.cc:211
SC_FXVAL_OBSERVER_CONSTRUCT_
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxval_observer.hh:120
sc_dt::sc_fxnum_fast_bitref::sc_fxnum_fast_bitref
sc_fxnum_fast_bitref()
sc_dt::sc_fxnum_subref::to_int
int to_int() const
Definition: sc_fxnum.hh:1777
sc_dt::sc_fxnum_fast::quantization_flag
bool quantization_flag() const
Definition: sc_fxnum.hh:3988
DEFN_ASN_OP
#define DEFN_ASN_OP(op)
Definition: sc_fxnum.hh:4347
sc_fxval.hh
sc_dt::sc_fxnum_subref::set
bool set()
Definition: sc_fxnum.cc:170
sc_dt::rsh_scfx_rep
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.hh:395
sc_dt::sc_fxnum_fast::m_observer
sc_fxnum_fast_observer * m_observer
Definition: sc_fxnum.hh:1187
sc_dt::sc_fxnum_fast_subref::m_to
int m_to
Definition: sc_fxnum.hh:467
sc_dt::sc_fxnum_fast::to_double
double to_double() const
Definition: sc_fxnum.hh:3955
sc_dt::sc_fxnum_bitref::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxnum.cc:106
sc_dt::sc_fxnum_fast::overflow_flag
bool overflow_flag() const
Definition: sc_fxnum.hh:3994
sc_dt::sc_fxval_fast::sc_fxval_fast
sc_fxval_fast(sc_fxval_fast_observer *=0)
Definition: sc_fxval.hh:1316
sc_dt::sc_fxnum::cast
void cast()
Definition: sc_fxnum.hh:2176
sc_dt::scfx_params::cast_switch
const sc_fxcast_switch & cast_switch() const
Definition: scfx_params.hh:156
sc_dt::sc_fxnum::quantization_flag
bool quantization_flag() const
Definition: sc_fxnum.hh:3016
sc_dt::sc_fxnum_fast::sc_fxval_fast
friend class sc_fxval_fast
Definition: sc_fxnum.hh:846
sc_dt::sc_fxnum_fast_subref::m_num
sc_fxnum_fast & m_num
Definition: sc_fxnum.hh:465
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
sc_dt::sc_fxnum_fast::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxnum.cc:717
sc_dt::sc_fxnum_subref::get
bool get() const
Definition: sc_fxnum.cc:164
sc_dt::sc_fxnum::cast_switch
const sc_fxcast_switch & cast_switch() const
Definition: sc_fxnum.hh:3073
sc_dt::scfx_rep::get_slice
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
Definition: scfx_rep.cc:2465
sc_dt::sc_fxnum::operator[]
const sc_fxnum_bitref operator[](int) const
Definition: sc_fxnum.hh:2820
sc_dt::sc_fxnum::value
const sc_fxval value() const
Definition: sc_fxnum.hh:3029
sc_dt::sc_fxnum_bitref::m_num
sc_fxnum & m_num
Definition: sc_fxnum.hh:140
DEFN_RED_FNC
#define DEFN_RED_FNC(fnc)
Definition: sc_fxnum.hh:2044
sc_dt::sc_fxnum_fast::rshift
friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
Definition: sc_fxnum.hh:3500
sc_dt::sc_fxnum_fast_bitref::set
void set(bool)
Definition: sc_fxnum.cc:132

Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17