gem5  v20.1.0.0
sc_fxval.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_fxval.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_fxval.h,v $
39 // Revision 1.3 2011/01/19 18:57:40 acg
40 // Andy Goodrich: changes for IEEE_1666_2011.
41 //
42 // Revision 1.2 2010/12/07 20:09:08 acg
43 // Andy Goodrich: Philipp Hartmann's constructor disambiguation fix
44 //
45 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
46 // SystemC 2.3
47 //
48 // Revision 1.3 2006/01/13 18:53:58 acg
49 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
50 // the source.
51 //
52 
53 #ifndef __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
54 #define __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
55 
56 #include <iostream>
57 
58 #include "../int/sc_int_base.hh"
59 #include "../int/sc_signed.hh"
60 #include "../int/sc_uint_base.hh"
61 #include "../int/sc_unsigned.hh"
62 #include "sc_fxval_observer.hh"
63 #include "scfx_rep.hh"
64 
65 #define SCFX_EXPLICIT_ explicit
66 #define SCFX_EXPLICIT_OTHER_ explicit
67 
68 namespace sc_dt
69 {
70 
71 // classes defined in this module
72 class sc_fxval;
73 class sc_fxval_fast;
74 
75 // forward class declarations
76 class sc_fxnum;
77 class sc_fxnum_fast;
78 
79 
80 // ----------------------------------------------------------------------------
81 // CLASS : sc_fxval
82 //
83 // Fixed-point value type; arbitrary precision.
84 // ----------------------------------------------------------------------------
85 
86 class sc_fxval
87 {
88  friend class sc_fxnum;
89 
90  protected:
91  sc_fxval_observer* observer() const;
92 
93  public:
94  // internal use only;
95  explicit sc_fxval(scfx_rep *);
96 
97  explicit sc_fxval(sc_fxval_observer * =0);
98  explicit sc_fxval(int, sc_fxval_observer * =0);
99  explicit sc_fxval(unsigned int, sc_fxval_observer * =0);
100  explicit sc_fxval(long, sc_fxval_observer * =0);
101  explicit sc_fxval(unsigned long, sc_fxval_observer * =0);
102  explicit sc_fxval(float, sc_fxval_observer* = 0);
103  explicit sc_fxval(double, sc_fxval_observer* = 0);
104  explicit sc_fxval(const char *, sc_fxval_observer* = 0);
105  sc_fxval(const sc_fxval &, sc_fxval_observer* = 0);
107  sc_fxval(const sc_fxnum &, sc_fxval_observer* = 0);
109 
110  explicit sc_fxval(int64, sc_fxval_observer* = 0);
111  explicit sc_fxval(uint64, sc_fxval_observer* = 0);
112  explicit sc_fxval(const sc_int_base &, sc_fxval_observer* = 0);
113  explicit sc_fxval(const sc_uint_base &, sc_fxval_observer* = 0);
114  explicit sc_fxval(const sc_signed &, sc_fxval_observer* = 0);
115  explicit sc_fxval(const sc_unsigned &, sc_fxval_observer* = 0);
116 
117  ~sc_fxval();
118 
119  // internal use only;
120  const scfx_rep *get_rep() const;
121  void set_rep(scfx_rep *);
122 
123  // unary operators
124  const sc_fxval operator - () const;
125  const sc_fxval &operator + () const;
126 
127  // unary functions
128  friend void neg(sc_fxval &, const sc_fxval &);
129 
130  // binary operators
131 #define DECL_BIN_OP_T(op,tp) \
132  friend const sc_fxval operator op (const sc_fxval &, tp); \
133  friend const sc_fxval operator op (tp, const sc_fxval &);
134 
135 #define DECL_BIN_OP_OTHER(op) \
136  DECL_BIN_OP_T(op, int64) \
137  DECL_BIN_OP_T(op, uint64) \
138  DECL_BIN_OP_T(op, const sc_int_base &) \
139  DECL_BIN_OP_T(op, const sc_uint_base &) \
140  DECL_BIN_OP_T(op, const sc_signed &) \
141  DECL_BIN_OP_T(op, const sc_unsigned &)
142 
143 #define DECL_BIN_OP(op, dummy) \
144  friend const sc_fxval operator op (const sc_fxval &, const sc_fxval &); \
145  DECL_BIN_OP_T(op, int) \
146  DECL_BIN_OP_T(op, unsigned int) \
147  DECL_BIN_OP_T(op, long) \
148  DECL_BIN_OP_T(op, unsigned long) \
149  DECL_BIN_OP_T(op, float) \
150  DECL_BIN_OP_T(op, double) \
151  DECL_BIN_OP_T(op, const char *) \
152  DECL_BIN_OP_T(op, const sc_fxval_fast &) \
153  DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
154  DECL_BIN_OP_OTHER(op)
155 
156  DECL_BIN_OP(*, mult)
157  DECL_BIN_OP(+, add)
158  DECL_BIN_OP(-, sub)
159 // declaration below doesn't compile with BCB5 (E2206)
160 // DECL_BIN_OP(/, div)
161 // previous macro expanded
162  friend const sc_fxval operator / (const sc_fxval &, const sc_fxval &);
163  DECL_BIN_OP_T(/, int)
164  DECL_BIN_OP_T(/, unsigned int)
165  DECL_BIN_OP_T(/, long)
166  DECL_BIN_OP_T(/, unsigned long)
167  DECL_BIN_OP_T(/, float)
168  DECL_BIN_OP_T(/, double)
169  DECL_BIN_OP_T(/, const char *)
170  DECL_BIN_OP_T(/, const sc_fxval_fast &)
171  DECL_BIN_OP_T(/, const sc_fxnum_fast &)
172 // DECL_BIN_OP_OTHER(/)
173 
174  DECL_BIN_OP_T(/, int64)
176  DECL_BIN_OP_T(/, const sc_int_base &)
177  DECL_BIN_OP_T(/, const sc_uint_base &)
178  DECL_BIN_OP_T(/, const sc_signed &)
179  DECL_BIN_OP_T(/, const sc_unsigned &)
180 
181 #undef DECL_BIN_OP_T
182 #undef DECL_BIN_OP_OTHER
183 #undef DECL_BIN_OP
184 
185  friend const sc_fxval operator << (const sc_fxval &, int);
186  friend const sc_fxval operator >> (const sc_fxval &, int);
187 
188  // binary functions
189 #define DECL_BIN_FNC_T(fnc, tp) \
190  friend void fnc (sc_fxval &, const sc_fxval &, tp); \
191  friend void fnc (sc_fxval &, tp, const sc_fxval &);
192 
193 #define DECL_BIN_FNC_OTHER(fnc) \
194  DECL_BIN_FNC_T(fnc, int64) \
195  DECL_BIN_FNC_T(fnc, uint64) \
196  DECL_BIN_FNC_T(fnc, const sc_int_base &) \
197  DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
198  DECL_BIN_FNC_T(fnc, const sc_signed &) \
199  DECL_BIN_FNC_T(fnc, const sc_unsigned &)
200 
201 #define DECL_BIN_FNC(fnc) \
202  friend void fnc (sc_fxval &, const sc_fxval &, const sc_fxval &); \
203  DECL_BIN_FNC_T(fnc, int) \
204  DECL_BIN_FNC_T(fnc, unsigned int) \
205  DECL_BIN_FNC_T(fnc, long) \
206  DECL_BIN_FNC_T(fnc, unsigned long) \
207  DECL_BIN_FNC_T(fnc, float) \
208  DECL_BIN_FNC_T(fnc, double) \
209  DECL_BIN_FNC_T(fnc, const char *) \
210  DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
211  DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
212  DECL_BIN_FNC_OTHER(fnc)
213 
214  DECL_BIN_FNC(mult)
215  DECL_BIN_FNC(div)
216  DECL_BIN_FNC(add)
217  DECL_BIN_FNC(sub)
218 
219 #undef DECL_BIN_FNC_T
220 #undef DECL_BIN_FNC_OTHER
221 #undef DECL_BIN_FNC
222 
223  friend void lshift(sc_fxval &, const sc_fxval &, int);
224  friend void rshift(sc_fxval &, const sc_fxval &, int);
225 
226  // relational (including equality) operators
227 #define DECL_REL_OP_T(op, tp) \
228  friend bool operator op (const sc_fxval &, tp); \
229  friend bool operator op (tp, const sc_fxval &);
230 
231 #define DECL_REL_OP_OTHER(op) \
232  DECL_REL_OP_T(op, int64) \
233  DECL_REL_OP_T(op, uint64) \
234  DECL_REL_OP_T(op, const sc_int_base &) \
235  DECL_REL_OP_T(op, const sc_uint_base &) \
236  DECL_REL_OP_T(op, const sc_signed &) \
237  DECL_REL_OP_T(op, const sc_unsigned &)
238 
239 #define DECL_REL_OP(op) \
240  friend bool operator op (const sc_fxval &, const sc_fxval &); \
241  DECL_REL_OP_T(op, int) \
242  DECL_REL_OP_T(op, unsigned int) \
243  DECL_REL_OP_T(op, long) \
244  DECL_REL_OP_T(op, unsigned long) \
245  DECL_REL_OP_T(op, float) \
246  DECL_REL_OP_T(op, double) \
247  DECL_REL_OP_T(op, const char *) \
248  DECL_REL_OP_T(op, const sc_fxval_fast &) \
249  DECL_REL_OP_T(op, const sc_fxnum_fast &) \
250  DECL_REL_OP_OTHER(op)
251 
252  DECL_REL_OP(<)
253  DECL_REL_OP(<=)
254  DECL_REL_OP(>)
255  DECL_REL_OP(>=)
256  DECL_REL_OP(==)
257  DECL_REL_OP(!=)
258 
259 #undef DECL_REL_OP_T
260 #undef DECL_REL_OP_OTHER
261 #undef DECL_REL_OP
262 
263  // assignment operators
264 #define DECL_ASN_OP_T(op, tp) sc_fxval &operator op(tp);
265 
266 #define DECL_ASN_OP_OTHER(op) \
267  DECL_ASN_OP_T(op, int64) \
268  DECL_ASN_OP_T(op, uint64) \
269  DECL_ASN_OP_T(op, const sc_int_base &) \
270  DECL_ASN_OP_T(op, const sc_uint_base &) \
271  DECL_ASN_OP_T(op, const sc_signed &) \
272  DECL_ASN_OP_T(op, const sc_unsigned &)
273 
274 #define DECL_ASN_OP(op) \
275  DECL_ASN_OP_T(op, int) \
276  DECL_ASN_OP_T(op, unsigned int) \
277  DECL_ASN_OP_T(op, long) \
278  DECL_ASN_OP_T(op, unsigned long) \
279  DECL_ASN_OP_T(op, float) \
280  DECL_ASN_OP_T(op, double) \
281  DECL_ASN_OP_T(op, const char *) \
282  DECL_ASN_OP_T(op, const sc_fxval &) \
283  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
284  DECL_ASN_OP_T(op, const sc_fxnum &) \
285  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
286  DECL_ASN_OP_OTHER(op)
287 
288  DECL_ASN_OP(=)
289 
290  DECL_ASN_OP(*=)
291  DECL_ASN_OP(/=)
292  DECL_ASN_OP(+=)
293  DECL_ASN_OP(-=)
294 
295  DECL_ASN_OP_T(<<=, int)
296  DECL_ASN_OP_T(>>=, int)
297 
298 #undef DECL_ASN_OP_T
299 #undef DECL_ASN_OP_OTHER
300 #undef DECL_ASN_OP
301 
302  // auto-increment and auto-decrement
303  const sc_fxval operator ++ (int);
304  const sc_fxval operator -- (int);
305 
308 
309  // implicit conversion
310  operator double() const; // necessary evil!
311 
312  // explicit conversion to primitive types
313  short to_short() const;
314  unsigned short to_ushort() const;
315  int to_int() const;
316  unsigned int to_uint() const;
317  long to_long() const;
318  unsigned long to_ulong() const;
319  int64 to_int64() const;
320  uint64 to_uint64() const;
321  float to_float() const;
322  double to_double() const;
323 
324  // explicit conversion to character string
325  const std::string to_string() const;
326  const std::string to_string(sc_numrep) const;
327  const std::string to_string(sc_numrep, bool) const;
328  const std::string to_string(sc_fmt) const;
329  const std::string to_string(sc_numrep, sc_fmt) const;
330  const std::string to_string(sc_numrep, bool, sc_fmt) const;
331 
332  const std::string to_dec() const;
333  const std::string to_bin() const;
334  const std::string to_oct() const;
335  const std::string to_hex() const;
336 
337  // query value
338  bool is_neg() const;
339  bool is_zero() const;
340  bool is_nan() const;
341  bool is_inf() const;
342  bool is_normal() const;
343 
344  bool rounding_flag() const;
345 
346  // print or dump content
347  void print(::std::ostream & =::std::cout) const;
348  void scan(::std::istream & =::std::cin);
349  void dump(::std::ostream & =::std::cout) const;
350 
351  // internal use only;
352  bool get_bit(int) const;
353 
354  protected:
356  void unlock_observer(sc_fxval_observer *) const;
357 
358  void get_type(int &, int &, sc_enc &) const;
359 
360  const sc_fxval quantization(const scfx_params &, bool &) const;
361  const sc_fxval overflow(const scfx_params &, bool &) const;
362 
363  private:
365 
367 };
368 
369 
370 // ----------------------------------------------------------------------------
371 // CLASS : sc_fxval_fast
372 //
373 // Fixed-point value type; limited precision.
374 // ----------------------------------------------------------------------------
375 
377 {
378  friend class sc_fxnum_fast;
379 
380  protected:
382 
383  public:
384  explicit sc_fxval_fast(sc_fxval_fast_observer * =0);
385  explicit sc_fxval_fast(int, sc_fxval_fast_observer * =0);
386  explicit sc_fxval_fast(unsigned int, sc_fxval_fast_observer * =0);
387  explicit sc_fxval_fast(long, sc_fxval_fast_observer * =0);
388  explicit sc_fxval_fast(unsigned long, sc_fxval_fast_observer * =0);
389  explicit sc_fxval_fast(float, sc_fxval_fast_observer * =0);
390  explicit sc_fxval_fast(double, sc_fxval_fast_observer * =0);
391  explicit sc_fxval_fast(const char *, sc_fxval_fast_observer * =0);
396 
399  explicit sc_fxval_fast(const sc_int_base &, sc_fxval_fast_observer * =0);
400  explicit sc_fxval_fast(const sc_uint_base &, sc_fxval_fast_observer * =0);
401  explicit sc_fxval_fast(const sc_signed &, sc_fxval_fast_observer * =0);
402  explicit sc_fxval_fast(const sc_unsigned &, sc_fxval_fast_observer * =0);
403 
404  ~sc_fxval_fast();
405 
406  // internal use only;
407  double get_val() const;
408  void set_val(double);
409 
410  // unary operators
411  const sc_fxval_fast operator - () const;
412  const sc_fxval_fast & operator + () const;
413 
414  // unary functions
415  friend void neg(sc_fxval_fast &, const sc_fxval_fast &);
416 
417  // binary operators
418 #define DECL_BIN_OP_T(op, tp) \
419  friend const sc_fxval_fast operator op (const sc_fxval_fast &, tp); \
420  friend const sc_fxval_fast operator op (tp, const sc_fxval_fast &);
421 
422 #define DECL_BIN_OP_OTHER(op) \
423  DECL_BIN_OP_T(op, int64) \
424  DECL_BIN_OP_T(op, uint64) \
425  DECL_BIN_OP_T(op, const sc_int_base &) \
426  DECL_BIN_OP_T(op, const sc_uint_base &) \
427  DECL_BIN_OP_T(op, const sc_signed &) \
428  DECL_BIN_OP_T(op, const sc_unsigned &)
429 
430 #define DECL_BIN_OP(op, dummy) \
431  friend const sc_fxval_fast operator op (const sc_fxval_fast &, \
432  const sc_fxval_fast &); \
433  DECL_BIN_OP_T(op, int) \
434  DECL_BIN_OP_T(op, unsigned int) \
435  DECL_BIN_OP_T(op, long) \
436  DECL_BIN_OP_T(op, unsigned long) \
437  DECL_BIN_OP_T(op, float) \
438  DECL_BIN_OP_T(op, double) \
439  DECL_BIN_OP_T(op, const char *) \
440  DECL_BIN_OP_OTHER(op)
441 
442  DECL_BIN_OP(*, mult)
443  DECL_BIN_OP(+, add)
444  DECL_BIN_OP(-, sub)
445 // don't use macro
446 // DECL_BIN_OP(/, div)
447  friend const sc_fxval_fast operator / (const sc_fxval_fast &,
448  const sc_fxval_fast &);
449  DECL_BIN_OP_T(/, int)
450  DECL_BIN_OP_T(/, unsigned int)
451  DECL_BIN_OP_T(/, long)
452  DECL_BIN_OP_T(/, unsigned long)
453  DECL_BIN_OP_T(/, float)
454  DECL_BIN_OP_T(/, double)
455  DECL_BIN_OP_T(/, const char *)
456 // DECL_BIN_OP_OTHER(/)
457 
458  DECL_BIN_OP_T(/, int64) \
459  DECL_BIN_OP_T(/, uint64) \
460  DECL_BIN_OP_T(/, const sc_int_base &) \
461  DECL_BIN_OP_T(/, const sc_uint_base &) \
462  DECL_BIN_OP_T(/, const sc_signed &) \
463  DECL_BIN_OP_T(/, const sc_unsigned &)
464 
465 #undef DECL_BIN_OP_T
466 #undef DECL_BIN_OP_OTHER
467 #undef DECL_BIN_OP
468 
469  friend const sc_fxval_fast operator << (const sc_fxval_fast &, int);
470  friend const sc_fxval_fast operator >> (const sc_fxval_fast &, int);
471 
472  // binary functions
473 #define DECL_BIN_FNC_T(fnc, tp) \
474  friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, tp); \
475  friend void fnc (sc_fxval_fast &, tp, const sc_fxval_fast &);
476 
477 #define DECL_BIN_FNC_OTHER(fnc) \
478  DECL_BIN_FNC_T(fnc, int64) \
479  DECL_BIN_FNC_T(fnc, uint64) \
480  DECL_BIN_FNC_T(fnc, const sc_int_base &) \
481  DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
482  DECL_BIN_FNC_T(fnc, const sc_signed &) \
483  DECL_BIN_FNC_T(fnc, const sc_unsigned &)
484 
485 #define DECL_BIN_FNC(fnc) \
486  friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, \
487  const sc_fxval_fast &); \
488  DECL_BIN_FNC_T(fnc, int) \
489  DECL_BIN_FNC_T(fnc, unsigned int) \
490  DECL_BIN_FNC_T(fnc, long) \
491  DECL_BIN_FNC_T(fnc, unsigned long) \
492  DECL_BIN_FNC_T(fnc, float) \
493  DECL_BIN_FNC_T(fnc, double) \
494  DECL_BIN_FNC_T(fnc, const char *) \
495  DECL_BIN_FNC_T(fnc, const sc_fxval &) \
496  DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
497  DECL_BIN_FNC_OTHER(fnc)
498 
499  DECL_BIN_FNC(mult)
500  DECL_BIN_FNC(div)
501  DECL_BIN_FNC(add)
502  DECL_BIN_FNC(sub)
503 
504 #undef DECL_BIN_FNC_T
505 #undef DECL_BIN_FNC_OTHER
506 #undef DECL_BIN_FNC
507 
508  friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int);
509  friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int);
510 
511  // relational (including equality) operators
512 #define DECL_REL_OP_T(op, tp) \
513  friend bool operator op (const sc_fxval_fast &, tp); \
514  friend bool operator op (tp, const sc_fxval_fast &);
515 
516 #define DECL_REL_OP_OTHER(op) \
517  DECL_REL_OP_T(op, int64) \
518  DECL_REL_OP_T(op, uint64) \
519  DECL_REL_OP_T(op, const sc_int_base &) \
520  DECL_REL_OP_T(op, const sc_uint_base &) \
521  DECL_REL_OP_T(op, const sc_signed &) \
522  DECL_REL_OP_T(op, const sc_unsigned &)
523 
524 #define DECL_REL_OP(op) \
525  friend bool operator op (const sc_fxval_fast &, const sc_fxval_fast &); \
526  DECL_REL_OP_T(op, int) \
527  DECL_REL_OP_T(op, unsigned int) \
528  DECL_REL_OP_T(op, long) \
529  DECL_REL_OP_T(op, unsigned long) \
530  DECL_REL_OP_T(op, float) \
531  DECL_REL_OP_T(op, double) \
532  DECL_REL_OP_T(op, const char *) \
533  DECL_REL_OP_OTHER(op)
534 
535  DECL_REL_OP(<)
536  DECL_REL_OP(<=)
537  DECL_REL_OP(>)
538  DECL_REL_OP(>=)
539  DECL_REL_OP(==)
540  DECL_REL_OP(!=)
541 
542 #undef DECL_REL_OP_T
543 #undef DECL_REL_OP_OTHER
544 #undef DECL_REL_OP
545 
546  // assignment operators
547 #define DECL_ASN_OP_T(op, tp) sc_fxval_fast &operator op(tp);
548 
549 #define DECL_ASN_OP_OTHER(op) \
550  DECL_ASN_OP_T(op, int64) \
551  DECL_ASN_OP_T(op, uint64) \
552  DECL_ASN_OP_T(op, const sc_int_base &) \
553  DECL_ASN_OP_T(op, const sc_uint_base &) \
554  DECL_ASN_OP_T(op, const sc_signed &) \
555  DECL_ASN_OP_T(op, const sc_unsigned &)
556 
557 #define DECL_ASN_OP(op) \
558  DECL_ASN_OP_T(op, int) \
559  DECL_ASN_OP_T(op, unsigned int) \
560  DECL_ASN_OP_T(op, long) \
561  DECL_ASN_OP_T(op, unsigned long) \
562  DECL_ASN_OP_T(op, float) \
563  DECL_ASN_OP_T(op, double) \
564  DECL_ASN_OP_T(op, const char *) \
565  DECL_ASN_OP_T(op, const sc_fxval &) \
566  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
567  DECL_ASN_OP_T(op, const sc_fxnum &) \
568  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
569  DECL_ASN_OP_OTHER(op)
570 
571  DECL_ASN_OP(=)
572 
573  DECL_ASN_OP(*=)
574  DECL_ASN_OP(/=)
575  DECL_ASN_OP(+=)
576  DECL_ASN_OP(-=)
577 
578  DECL_ASN_OP_T(<<=, int)
579  DECL_ASN_OP_T(>>=, int)
580 
581 #undef DECL_ASN_OP_T
582 #undef DECL_ASN_OP_OTHER
583 #undef DECL_ASN_OP
584 
585  // auto-increment and auto-decrement
586  const sc_fxval_fast operator ++ (int);
587  const sc_fxval_fast operator -- (int);
588 
591 
592  // implicit conversion
593  operator double() const; // necessary evil!
594 
595  // explicit conversion to primitive types
596  short to_short() const;
597  unsigned short to_ushort() const;
598  int to_int() const;
599  unsigned int to_uint() const;
600  long to_long() const;
601  unsigned long to_ulong() const;
602  int64 to_int64() const;
603  uint64 to_uint64() const;
604  float to_float() const;
605  double to_double() const;
606 
607  // explicit conversion to character string
608  const std::string to_string() const;
609  const std::string to_string(sc_numrep) const;
610  const std::string to_string(sc_numrep, bool) const;
611  const std::string to_string(sc_fmt) const;
612  const std::string to_string(sc_numrep, sc_fmt) const;
613  const std::string to_string(sc_numrep, bool, sc_fmt) const;
614 
615  const std::string to_dec() const;
616  const std::string to_bin() const;
617  const std::string to_oct() const;
618  const std::string to_hex() const;
619 
620  // query value
621  bool is_neg() const;
622  bool is_zero() const;
623  bool is_nan() const;
624  bool is_inf() const;
625  bool is_normal() const;
626 
627  bool rounding_flag() const;
628 
629  // print or dump content
630  void print(::std::ostream & =::std::cout) const;
631  void scan(::std::istream & =::std::cin);
632  void dump(::std::ostream & =::std::cout) const;
633 
634  // internal use only;
635  bool get_bit(int) const;
636 
637  protected:
638  sc_fxval_fast_observer *lock_observer() const;
639  void unlock_observer(sc_fxval_fast_observer *) const;
640 
641  static double from_string(const char *);
642  private:
643  double m_val;
644 
646 };
647 
648 
649 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
650 
651 // ----------------------------------------------------------------------------
652 // CLASS : sc_fxval
653 //
654 // Fixed-point value type; arbitrary precision.
655 // ----------------------------------------------------------------------------
656 
657 // protected method
658 
660 
661 // internal use only;
663  m_rep(a != 0 ? a : new scfx_rep), m_observer(0)
664 {}
665 
666 
667 // public constructors
668 
670  m_rep(new scfx_rep), m_observer(observer_)
671 {
674 }
675 
676 inline sc_fxval::sc_fxval(const sc_fxval &a, sc_fxval_observer *observer_) :
677  m_rep(new scfx_rep(*a.m_rep)), m_observer(observer_)
678 {
683 }
684 
685 #define DEFN_CTOR_T(tp, arg) \
686 inline sc_fxval::sc_fxval(tp a, sc_fxval_observer *observer_) : \
687  m_rep(new scfx_rep(arg)), m_observer(observer_) \
688 { \
689  SC_FXVAL_OBSERVER_DEFAULT_ \
690  SC_FXVAL_OBSERVER_CONSTRUCT_(*this) \
691  SC_FXVAL_OBSERVER_WRITE_(*this) \
692 }
693 
694 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
695 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, a.to_double())
696 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.value())
697 
698 DEFN_CTOR_T_A(int)
699 DEFN_CTOR_T_A(unsigned int)
700 DEFN_CTOR_T_A(long)
701 DEFN_CTOR_T_A(unsigned long)
702 DEFN_CTOR_T_A(float)
703 DEFN_CTOR_T_A(double)
704 DEFN_CTOR_T_A(const char *)
706 
709 DEFN_CTOR_T_C(const sc_int_base &)
711 DEFN_CTOR_T_A(const sc_signed &)
712 DEFN_CTOR_T_A(const sc_unsigned &)
713 
714 #undef DEFN_CTOR_T
715 #undef DEFN_CTOR_T_A
716 #undef DEFN_CTOR_T_B
717 #undef DEFN_CTOR_T_C
718 
720 {
722  delete m_rep;
723 }
724 
725 // internal use only;
726 inline const scfx_rep *
728 {
730  return m_rep;
731 }
732 
733 // internal use only;
734 inline void
736 {
737  delete m_rep;
738  m_rep = rep_;
740 }
741 
742 // unary operators
743 inline const sc_fxval
745 {
748 }
749 
750 inline const sc_fxval &
752 {
753  // SC_FXVAL_OBSERVER_READ_(*this)
754  return *this;
755 }
756 
757 // unary functions
758 inline void
760 {
762  delete c.m_rep;
763  c.m_rep = sc_dt::neg_scfx_rep(*a.m_rep);
765 }
766 
767 // binary operators
768 #define DEFN_BIN_OP_T(op, fnc, tp) \
769 inline const sc_fxval \
770 operator op (const sc_fxval &a, tp b) \
771 { \
772  SC_FXVAL_OBSERVER_READ_(a) \
773  sc_fxval tmp(b); \
774  return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
775 } \
776  \
777 inline \
778 const sc_fxval \
779 operator op (tp a, const sc_fxval &b) \
780 { \
781  SC_FXVAL_OBSERVER_READ_(b) \
782  sc_fxval tmp(a); \
783  return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
784 }
785 
786 #define DEFN_BIN_OP_OTHER(op, fnc) \
787 DEFN_BIN_OP_T(op, fnc, int64) \
788 DEFN_BIN_OP_T(op, fnc, uint64) \
789 DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
790 DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
791 DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
792 DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
793 
794 #define DEFN_BIN_OP(op, fnc) \
795 inline const sc_fxval \
796 operator op (const sc_fxval &a, const sc_fxval &b) \
797 { \
798  SC_FXVAL_OBSERVER_READ_(a) \
799  SC_FXVAL_OBSERVER_READ_(b) \
800  return sc_fxval(sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep)); \
801 } \
802  \
803 DEFN_BIN_OP_T(op, fnc, int) \
804 DEFN_BIN_OP_T(op, fnc, unsigned int) \
805 DEFN_BIN_OP_T(op, fnc, long) \
806 DEFN_BIN_OP_T(op, fnc, unsigned long) \
807 DEFN_BIN_OP_T(op, fnc, float) \
808 DEFN_BIN_OP_T(op, fnc, double) \
809 DEFN_BIN_OP_T(op, fnc, const char *) \
810 DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
811 DEFN_BIN_OP_OTHER(op, fnc)
812 
813 DEFN_BIN_OP(*, mult)
814 DEFN_BIN_OP(+, add)
815 DEFN_BIN_OP(-, sub)
816 // don't use macro
817 //DEFN_BIN_OP(/, div)
818 inline const sc_fxval
819 operator / (const sc_fxval &a, const sc_fxval &b)
820 {
823  return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.m_rep));
824 }
825 
826 DEFN_BIN_OP_T(/, div, int)
827 DEFN_BIN_OP_T(/, div, unsigned int)
828 DEFN_BIN_OP_T(/, div, long)
829 DEFN_BIN_OP_T(/, div, unsigned long)
830 DEFN_BIN_OP_T(/, div, float)
831 DEFN_BIN_OP_T(/, div, double)
832 DEFN_BIN_OP_T(/, div, const char *)
833 DEFN_BIN_OP_T(/, div, const sc_fxval_fast &)
834 //DEFN_BIN_OP_OTHER(/, div)
835 
836 DEFN_BIN_OP_T(/, div, int64)
837 DEFN_BIN_OP_T(/, div, uint64)
838 DEFN_BIN_OP_T(/, div, const sc_int_base &)
839 DEFN_BIN_OP_T(/, div, const sc_uint_base &)
840 DEFN_BIN_OP_T(/, div, const sc_signed &)
841 DEFN_BIN_OP_T(/, div, const sc_unsigned &)
842 
843 #undef DEFN_BIN_OP_T
844 #undef DEFN_BIN_OP_OTHER
845 #undef DEFN_BIN_OP
846 
847 inline const sc_fxval
848 operator << (const sc_fxval &a, int b)
849 {
851  return sc_fxval(sc_dt::lsh_scfx_rep(*a.m_rep, b));
852 }
853 
854 inline const sc_fxval
855 operator >> (const sc_fxval &a, int b)
856 {
858  return sc_fxval(sc_dt::rsh_scfx_rep(*a.m_rep, b));
859 }
860 
861 // binary functions
862 #define DEFN_BIN_FNC_T(fnc, tp) \
863 inline void \
864 fnc (sc_fxval &c, const sc_fxval &a, tp b) \
865 { \
866  SC_FXVAL_OBSERVER_READ_(a) \
867  sc_fxval tmp(b); \
868  delete c.m_rep; \
869  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
870  SC_FXVAL_OBSERVER_WRITE_(c) \
871 } \
872  \
873 inline void \
874 fnc (sc_fxval &c, tp a, const sc_fxval &b) \
875 { \
876  SC_FXVAL_OBSERVER_READ_(b) \
877  sc_fxval tmp(a); \
878  delete c.m_rep; \
879  c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
880  SC_FXVAL_OBSERVER_WRITE_(c) \
881 }
882 
883 #define DEFN_BIN_FNC_OTHER(fnc) \
884 DEFN_BIN_FNC_T(fnc, int64) \
885 DEFN_BIN_FNC_T(fnc, uint64) \
886 DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
887 DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
888 DEFN_BIN_FNC_T(fnc, const sc_signed &) \
889 DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
890 
891 #define DEFN_BIN_FNC(fnc) \
892 inline void \
893 fnc(sc_fxval &c, const sc_fxval &a, const sc_fxval &b) \
894 { \
895  SC_FXVAL_OBSERVER_READ_(a) \
896  SC_FXVAL_OBSERVER_READ_(b) \
897  delete c.m_rep; \
898  c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
899  SC_FXVAL_OBSERVER_WRITE_(c) \
900 } \
901  \
902 DEFN_BIN_FNC_T(fnc, int) \
903 DEFN_BIN_FNC_T(fnc, unsigned int) \
904 DEFN_BIN_FNC_T(fnc, long) \
905 DEFN_BIN_FNC_T(fnc, unsigned long) \
906 DEFN_BIN_FNC_T(fnc, float) \
907 DEFN_BIN_FNC_T(fnc, double) \
908 DEFN_BIN_FNC_T(fnc, const char *) \
909 DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
910 DEFN_BIN_FNC_OTHER(fnc)
911 
912 DEFN_BIN_FNC(mult)
913 DEFN_BIN_FNC(div)
914 DEFN_BIN_FNC(add)
915 DEFN_BIN_FNC(sub)
916 
917 #undef DEFN_BIN_FNC_T
918 #undef DEFN_BIN_FNC_OTHER
919 #undef DEFN_BIN_FNC
920 
921 inline void
922 lshift(sc_fxval &c, const sc_fxval &a, int b)
923 {
925  delete c.m_rep;
926  c.m_rep = sc_dt::lsh_scfx_rep(*a.m_rep, b);
928 }
929 
930 inline void
931 rshift(sc_fxval &c, const sc_fxval &a, int b)
932 {
934  delete c.m_rep;
935  c.m_rep = sc_dt::rsh_scfx_rep(*a.m_rep, b);
937 }
938 
939 // relational (including equality) operators
940 #define DEFN_REL_OP_T(op, ret, tp) \
941 inline bool \
942 operator op (const sc_fxval &a, tp b) \
943 { \
944  SC_FXVAL_OBSERVER_READ_(a) \
945  sc_fxval tmp(b); \
946  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
947  return (ret); \
948 } \
949  \
950 inline bool \
951 operator op (tp a, const sc_fxval &b) \
952 { \
953  SC_FXVAL_OBSERVER_READ_(b) \
954  sc_fxval tmp(a); \
955  int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
956  return (ret); \
957 }
958 
959 #define DEFN_REL_OP_OTHER(op, ret) \
960 DEFN_REL_OP_T(op, ret, int64) \
961 DEFN_REL_OP_T(op, ret, uint64) \
962 DEFN_REL_OP_T(op, ret, const sc_int_base &) \
963 DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
964 DEFN_REL_OP_T(op, ret, const sc_signed &) \
965 DEFN_REL_OP_T(op, ret, const sc_unsigned &)
966 
967 #define DEFN_REL_OP(op, ret) \
968 inline bool \
969 operator op (const sc_fxval &a, const sc_fxval &b) \
970 { \
971  SC_FXVAL_OBSERVER_READ_(a) \
972  SC_FXVAL_OBSERVER_READ_(b) \
973  int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
974  return (ret); \
975 } \
976  \
977 DEFN_REL_OP_T(op, ret, int) \
978 DEFN_REL_OP_T(op, ret, unsigned int) \
979 DEFN_REL_OP_T(op, ret, long) \
980 DEFN_REL_OP_T(op, ret, unsigned long) \
981 DEFN_REL_OP_T(op, ret, float) \
982 DEFN_REL_OP_T(op, ret, double) \
983 DEFN_REL_OP_T(op, ret, const char *) \
984 DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
985 DEFN_REL_OP_OTHER(op, ret)
986 
987 DEFN_REL_OP(<, result < 0)
988 DEFN_REL_OP(<=, result <= 0)
989 DEFN_REL_OP(>, result > 0 && result != 2)
990 DEFN_REL_OP(>=, result >= 0 && result != 2)
991 DEFN_REL_OP(==, result == 0)
992 DEFN_REL_OP(!=, result != 0)
993 
994 #undef DEFN_REL_OP_T
995 #undef DEFN_REL_OP_OTHER
996 #undef DEFN_REL_OP
997 
998 // assignment operators
999 inline sc_fxval &
1000 sc_fxval::operator = (const sc_fxval &a)
1001 {
1002  if (&a != this) {
1004  *m_rep = *a.m_rep;
1006  }
1007  return *this;
1008 }
1009 
1010 #define DEFN_ASN_OP_T(tp) \
1011 inline sc_fxval & \
1012 sc_fxval::operator = (tp b) \
1013 { \
1014  sc_fxval tmp(b); \
1015  *m_rep = *tmp.m_rep; \
1016  SC_FXVAL_OBSERVER_WRITE_(*this) \
1017  return *this; \
1018 }
1019 
1020 DEFN_ASN_OP_T(int)
1021 DEFN_ASN_OP_T(unsigned int)
1022 DEFN_ASN_OP_T(long)
1023 DEFN_ASN_OP_T(unsigned long)
1024 DEFN_ASN_OP_T(float)
1025 DEFN_ASN_OP_T(double)
1026 DEFN_ASN_OP_T(const char *)
1027 DEFN_ASN_OP_T(const sc_fxval_fast &)
1028 
1031 DEFN_ASN_OP_T(const sc_int_base &)
1032 DEFN_ASN_OP_T(const sc_uint_base &)
1033 DEFN_ASN_OP_T(const sc_signed &)
1034 DEFN_ASN_OP_T(const sc_unsigned &)
1035 
1036 #undef DEFN_ASN_OP_T
1037 
1038 #define DEFN_ASN_OP_T(op, fnc, tp) \
1039 inline sc_fxval & \
1040 sc_fxval::operator op (tp b) \
1041 { \
1042  SC_FXVAL_OBSERVER_READ_(*this) \
1043  sc_fxval tmp(b); \
1044  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
1045  delete m_rep; \
1046  m_rep = new_rep; \
1047  SC_FXVAL_OBSERVER_WRITE_(*this) \
1048  return *this; \
1049 }
1050 
1051 #define DEFN_ASN_OP_OTHER(op, fnc) \
1052 DEFN_ASN_OP_T(op, fnc, int64) \
1053 DEFN_ASN_OP_T(op, fnc, uint64) \
1054 DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
1055 DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
1056 DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
1057 DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
1058 
1059 #define DEFN_ASN_OP(op, fnc) \
1060 inline sc_fxval & \
1061 sc_fxval::operator op (const sc_fxval &b) \
1062 { \
1063  SC_FXVAL_OBSERVER_READ_(*this) \
1064  SC_FXVAL_OBSERVER_READ_(b) \
1065  scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
1066  delete m_rep; \
1067  m_rep = new_rep; \
1068  SC_FXVAL_OBSERVER_WRITE_(*this) \
1069  return *this; \
1070 } \
1071  \
1072 DEFN_ASN_OP_T(op, fnc, int) \
1073 DEFN_ASN_OP_T(op, fnc, unsigned int) \
1074 DEFN_ASN_OP_T(op, fnc, long) \
1075 DEFN_ASN_OP_T(op, fnc, unsigned long) \
1076 DEFN_ASN_OP_T(op, fnc, float) \
1077 DEFN_ASN_OP_T(op, fnc, double) \
1078 DEFN_ASN_OP_T(op, fnc, const char *) \
1079 DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
1080 DEFN_ASN_OP_OTHER(op, fnc)
1081 
1082 DEFN_ASN_OP(*=, mult)
1083 DEFN_ASN_OP(/=, div)
1084 DEFN_ASN_OP(+=, add)
1085 DEFN_ASN_OP(-=, sub)
1086 
1087 #undef DEFN_ASN_OP_T
1088 #undef DEFN_ASN_OP_OTHER
1089 #undef DEFN_ASN_OP
1090 
1091 inline sc_fxval &
1092 sc_fxval::operator <<= (int b)
1093 {
1095  m_rep->lshift(b);
1097  return *this;
1098 }
1099 
1100 inline sc_fxval &
1101 sc_fxval::operator >>= (int b)
1102 {
1104  m_rep->rshift(b);
1106  return *this;
1107 }
1108 
1109 // auto-increment and auto-decrement
1110 inline const sc_fxval
1111 sc_fxval::operator ++ (int)
1112 {
1113  sc_fxval c = *this;
1114  (*this) += 1;
1115  return c;
1116 }
1117 
1118 inline const sc_fxval
1120 {
1121  sc_fxval c = *this;
1122  (*this) -= 1;
1123  return c;
1124 }
1125 
1126 inline sc_fxval &
1128 {
1129  (*this) += 1;
1130  return *this;
1131 }
1132 
1133 inline sc_fxval &
1135 {
1136  (*this) -= 1;
1137  return *this;
1138 }
1139 
1140 // implicit conversion
1141 inline sc_fxval::operator double() const
1142 {
1144  return m_rep->to_double();
1145 }
1146 
1147 // explicit conversion to primitive types
1148 inline short
1150 {
1152  return static_cast<short>(m_rep->to_uint64());
1153 }
1154 
1155 inline unsigned short
1157 {
1159  return static_cast<unsigned short>(m_rep->to_uint64());
1160 }
1161 
1162 inline int
1164 {
1166  return static_cast<int>(m_rep->to_uint64());
1167 }
1168 
1169 inline int64
1171 {
1173  return static_cast<int64>(m_rep->to_uint64());
1174 }
1175 
1176 inline unsigned int
1178 {
1180  return static_cast<unsigned int>(m_rep->to_uint64());
1181 }
1182 
1183 inline uint64
1185 {
1187  return m_rep->to_uint64();
1188 }
1189 
1190 inline long
1192 {
1194  return static_cast<long>(m_rep->to_uint64());
1195 }
1196 
1197 inline unsigned long
1199 {
1201  return static_cast<unsigned long>(m_rep->to_uint64());
1202 }
1203 
1204 inline float
1206 {
1208  return static_cast<float>(m_rep->to_double());
1209 }
1210 
1211 inline double
1213 {
1215  return m_rep->to_double();
1216 }
1217 
1218 // query value
1219 inline bool
1221 {
1223  return m_rep->is_neg();
1224 }
1225 
1226 inline bool
1228 {
1230  return m_rep->is_zero();
1231 }
1232 
1233 inline bool
1235 {
1237  return m_rep->is_nan();
1238 }
1239 
1240 inline bool
1242 {
1244  return m_rep->is_inf();
1245 }
1246 
1247 inline bool
1249 {
1251  return m_rep->is_normal();
1252 }
1253 
1254 inline bool
1256 {
1257  return m_rep->rounding_flag();
1258 }
1259 
1260 // internal use only;
1261 inline bool
1263 {
1264  return m_rep->get_bit(i);
1265 }
1266 
1267 // protected methods and friend functions
1268 inline void
1269 sc_fxval::get_type(int &wl, int &iwl, sc_enc &enc) const
1270 {
1271  m_rep->get_type(wl, iwl, enc);
1272 }
1273 
1274 inline const sc_fxval
1275 sc_fxval::quantization(const scfx_params &params, bool &q_flag) const
1276 {
1277  return sc_fxval(sc_dt::quantization_scfx_rep(*m_rep, params, q_flag));
1278 }
1279 
1280 inline const sc_fxval
1281 sc_fxval::overflow(const scfx_params &params, bool &o_flag) const
1282 {
1283  return sc_fxval(sc_dt::overflow_scfx_rep(*m_rep, params, o_flag));
1284 }
1285 
1286 inline ::std::ostream &
1287 operator << (::std::ostream &os, const sc_fxval &a)
1288 {
1289  a.print(os);
1290  return os;
1291 }
1292 
1293 inline ::std::istream &
1294 operator >> (::std::istream &is, sc_fxval &a)
1295 {
1296  a.scan(is);
1297  return is;
1298 }
1299 
1300 
1301 // ----------------------------------------------------------------------------
1302 // CLASS : sc_fxval_fast
1303 //
1304 // Fixed-point value type; limited precision.
1305 // ----------------------------------------------------------------------------
1306 
1307 // protected method
1308 inline sc_fxval_fast_observer *
1310 {
1311  return m_observer;
1312 }
1313 
1314 
1315 // public constructors
1317  m_val(0.0), m_observer(observer_)
1318 {
1321 }
1322 
1324  sc_fxval_fast_observer *observer_) :
1325  m_val(a.m_val), m_observer(observer_)
1326 {
1331 }
1332 
1333 #define DEFN_CTOR_T(tp, arg) \
1334 inline sc_fxval_fast::sc_fxval_fast( \
1335  tp a, sc_fxval_fast_observer * observer_) : \
1336  m_val(arg), m_observer(observer_) \
1337 { \
1338  SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
1339  SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this) \
1340  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1341 }
1342 
1343 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
1344 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, from_string(a))
1345 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
1346 
1347 DEFN_CTOR_T_A(int)
1348 DEFN_CTOR_T_A(unsigned int)
1349 DEFN_CTOR_T_A(long)
1350 DEFN_CTOR_T_A(unsigned long)
1351 DEFN_CTOR_T_A(float)
1352 DEFN_CTOR_T_A(double)
1353 DEFN_CTOR_T_B(const char *)
1354 DEFN_CTOR_T_C(const sc_fxval &)
1355 
1358 DEFN_CTOR_T_C(const sc_int_base &)
1359 DEFN_CTOR_T_C(const sc_uint_base &)
1360 DEFN_CTOR_T_C(const sc_signed &)
1361 DEFN_CTOR_T_C(const sc_unsigned &)
1362 
1363 #undef DEFN_CTOR_T
1364 #undef DEFN_CTOR_T_A
1365 #undef DEFN_CTOR_T_B
1366 #undef DEFN_CTOR_T_C
1367 #undef DEFN_CTOR_T_D
1368 #undef DEFN_CTOR_T_E
1369 
1371 {
1373 }
1374 
1375 // internal use only;
1376 inline double
1378 {
1380  return m_val;
1381 }
1382 
1383 // internal use only;
1384 inline void
1386 {
1387  m_val = val_;
1389 }
1390 
1391 // unary operators
1392 inline const sc_fxval_fast
1394 {
1396  return sc_fxval_fast(-m_val);
1397 }
1398 
1399 inline const sc_fxval_fast &
1401 {
1402  // SC_FXVAL_FAST_OBSERVER_READ_(*this)
1403  return *this;
1404 }
1405 
1406 // unary functions
1407 inline void
1409 {
1411  c.m_val = - a.m_val;
1413 }
1414 
1415 // binary operators
1416 #define DEFN_BIN_OP_T(op, tp) \
1417 inline const sc_fxval_fast \
1418 operator op (const sc_fxval_fast &a, tp b) \
1419 { \
1420  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1421  sc_fxval_fast tmp(b); \
1422  return sc_fxval_fast(a.m_val op tmp.m_val); \
1423 } \
1424  \
1425 inline const sc_fxval_fast \
1426 operator op (tp a, const sc_fxval_fast &b) \
1427 { \
1428  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1429  sc_fxval_fast tmp(a); \
1430  return sc_fxval_fast(tmp.m_val op b.m_val); \
1431 }
1432 
1433 #define DEFN_BIN_OP_OTHER(op) \
1434 DEFN_BIN_OP_T(op, int64) \
1435 DEFN_BIN_OP_T(op, uint64) \
1436 DEFN_BIN_OP_T(op, const sc_int_base &) \
1437 DEFN_BIN_OP_T(op, const sc_uint_base &) \
1438 DEFN_BIN_OP_T(op, const sc_signed &) \
1439 DEFN_BIN_OP_T(op, const sc_unsigned &)
1440 
1441 #define DEFN_BIN_OP(op, dummy) \
1442 inline const sc_fxval_fast \
1443 operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
1444 { \
1445  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1446  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1447  return sc_fxval_fast(a.m_val op b.m_val); \
1448 } \
1449  \
1450 DEFN_BIN_OP_T(op, int) \
1451 DEFN_BIN_OP_T(op, unsigned int) \
1452 DEFN_BIN_OP_T(op, long) \
1453 DEFN_BIN_OP_T(op, unsigned long) \
1454 DEFN_BIN_OP_T(op, float) \
1455 DEFN_BIN_OP_T(op, double) \
1456 DEFN_BIN_OP_T(op, const char *) \
1457 DEFN_BIN_OP_OTHER(op)
1458 
1459 DEFN_BIN_OP(*, mult)
1460 DEFN_BIN_OP(+, add)
1461 DEFN_BIN_OP(-, sub)
1462 //DEFN_BIN_OP(/, div)
1463 inline const sc_fxval_fast
1465 {
1468  return sc_fxval_fast(a.m_val / b.m_val);
1469 }
1470 
1471 DEFN_BIN_OP_T(/, int)
1472 DEFN_BIN_OP_T(/, unsigned int)
1473 DEFN_BIN_OP_T(/, long)
1474 DEFN_BIN_OP_T(/, unsigned long)
1475 DEFN_BIN_OP_T(/, float)
1476 DEFN_BIN_OP_T(/, double)
1477 DEFN_BIN_OP_T(/, const char *)
1478 //DEFN_BIN_OP_OTHER(/)
1479 
1480 DEFN_BIN_OP_T(/, int64)
1482 DEFN_BIN_OP_T(/, const sc_int_base &)
1483 DEFN_BIN_OP_T(/, const sc_uint_base &)
1484 DEFN_BIN_OP_T(/, const sc_signed &)
1485 DEFN_BIN_OP_T(/, const sc_unsigned &)
1486 
1487 
1488 #undef DEFN_BIN_OP_T
1489 #undef DEFN_BIN_OP_OTHER
1490 #undef DEFN_BIN_OP
1491 
1492 
1493 inline const sc_fxval_fast
1495 {
1497  return sc_fxval_fast(a.m_val * scfx_pow2(b));
1498 }
1499 
1500 inline const sc_fxval_fast
1502 {
1504  return sc_fxval_fast(a.m_val * scfx_pow2(-b));
1505 }
1506 
1507 // binary functions
1508 #define DEFN_BIN_FNC_T(fnc, op, tp) \
1509 inline void \
1510 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
1511 { \
1512  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1513  sc_fxval_fast tmp(b); \
1514  c.m_val = a.m_val op tmp.m_val; \
1515  SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1516 } \
1517  \
1518 inline void \
1519 fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
1520 { \
1521  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1522  sc_fxval_fast tmp(a); \
1523  c.m_val = tmp.m_val op b.m_val; \
1524  SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1525 }
1526 
1527 #define DEFN_BIN_FNC_OTHER(fnc, op) \
1528 DEFN_BIN_FNC_T(fnc, op, int64) \
1529 DEFN_BIN_FNC_T(fnc, op, uint64) \
1530 DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
1531 DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
1532 DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
1533 DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
1534 
1535 #define DEFN_BIN_FNC(fnc, op) \
1536 inline void \
1537 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxval_fast &b) \
1538 { \
1539  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1540  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1541  c.m_val = a.m_val op b.m_val; \
1542  SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1543 } \
1544  \
1545 DEFN_BIN_FNC_T(fnc, op, int) \
1546 DEFN_BIN_FNC_T(fnc, op, unsigned int) \
1547 DEFN_BIN_FNC_T(fnc, op, long) \
1548 DEFN_BIN_FNC_T(fnc, op, unsigned long) \
1549 DEFN_BIN_FNC_T(fnc, op, float) \
1550 DEFN_BIN_FNC_T(fnc, op, double) \
1551 DEFN_BIN_FNC_T(fnc, op, const char *) \
1552 DEFN_BIN_FNC_OTHER(fnc, op)
1553 
1554 DEFN_BIN_FNC(mult, *)
1555 DEFN_BIN_FNC(div, /)
1556 DEFN_BIN_FNC(add, +)
1557 DEFN_BIN_FNC(sub, -)
1558 
1559 #undef DEFN_BIN_FNC_T
1560 #undef DEFN_BIN_FNC_OTHER
1561 #undef DEFN_BIN_FNC
1562 
1563 inline void
1565 {
1567  c.m_val = a.m_val * scfx_pow2(b);
1569 }
1570 
1571 inline void
1573 {
1575  c.m_val = a.m_val * scfx_pow2(-b);
1577 }
1578 
1579 // relational (including equality) operators
1580 #define DEFN_REL_OP_T(op, tp) \
1581 inline bool \
1582 operator op (const sc_fxval_fast &a, tp b) \
1583 { \
1584  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1585  sc_fxval_fast tmp(b); \
1586  return (a.m_val op tmp.m_val); \
1587 } \
1588  \
1589 inline bool \
1590 operator op (tp a, const sc_fxval_fast &b) \
1591 { \
1592  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1593  sc_fxval_fast tmp(a); \
1594  return (tmp.m_val op b.m_val); \
1595 }
1596 
1597 #define DEFN_REL_OP_OTHER(op) \
1598 DEFN_REL_OP_T(op, int64) \
1599 DEFN_REL_OP_T(op, uint64) \
1600 DEFN_REL_OP_T(op, const sc_int_base &) \
1601 DEFN_REL_OP_T(op, const sc_uint_base &) \
1602 DEFN_REL_OP_T(op, const sc_signed &) \
1603 DEFN_REL_OP_T(op, const sc_unsigned &)
1604 
1605 #define DEFN_REL_OP(op) \
1606 inline bool \
1607 operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
1608 { \
1609  SC_FXVAL_FAST_OBSERVER_READ_(a) \
1610  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1611  return (a.m_val op b.m_val); \
1612 } \
1613  \
1614 DEFN_REL_OP_T(op, int) \
1615 DEFN_REL_OP_T(op, unsigned int) \
1616 DEFN_REL_OP_T(op, long) \
1617 DEFN_REL_OP_T(op, unsigned long) \
1618 DEFN_REL_OP_T(op, float) \
1619 DEFN_REL_OP_T(op, double) \
1620 DEFN_REL_OP_T(op, const char *) \
1621 DEFN_REL_OP_OTHER(op)
1622 
1623 DEFN_REL_OP(<)
1624 DEFN_REL_OP(<=)
1625 DEFN_REL_OP(>)
1626 DEFN_REL_OP(>=)
1627 DEFN_REL_OP(==)
1628 DEFN_REL_OP(!=)
1629 
1630 #undef DEFN_REL_OP_T
1631 #undef DEFN_REL_OP_OTHER
1632 #undef DEFN_REL_OP
1633 
1634 // assignment operators
1635 inline sc_fxval_fast &
1636 sc_fxval_fast::operator = (const sc_fxval_fast &a)
1637 {
1638  if (&a != this) {
1640  m_val = a.m_val;
1642  }
1643  return *this;
1644 }
1645 
1646 #define DEFN_ASN_OP_T(tp) \
1647 inline sc_fxval_fast & \
1648 sc_fxval_fast::operator = (tp a) \
1649 { \
1650  sc_fxval_fast tmp(a); \
1651  m_val = tmp.m_val; \
1652  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1653  return *this; \
1654 }
1655 
1656 DEFN_ASN_OP_T(int)
1657 DEFN_ASN_OP_T(unsigned int)
1658 DEFN_ASN_OP_T(long)
1659 DEFN_ASN_OP_T(unsigned long)
1660 DEFN_ASN_OP_T(float)
1661 DEFN_ASN_OP_T(double)
1662 DEFN_ASN_OP_T(const char *)
1663 DEFN_ASN_OP_T(const sc_fxval &)
1664 
1667 DEFN_ASN_OP_T(const sc_int_base &)
1668 DEFN_ASN_OP_T(const sc_uint_base &)
1669 DEFN_ASN_OP_T(const sc_signed &)
1670 DEFN_ASN_OP_T(const sc_unsigned &)
1671 
1672 #undef DEFN_ASN_OP_T
1673 
1674 #define DEFN_ASN_OP_T(op, tp) \
1675 inline sc_fxval_fast & \
1676 sc_fxval_fast::operator op (tp b) \
1677 { \
1678  SC_FXVAL_FAST_OBSERVER_READ_(*this) \
1679  sc_fxval_fast tmp(b); \
1680  m_val op tmp.m_val; \
1681  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1682  return *this; \
1683 }
1684 
1685 #define DEFN_ASN_OP_OTHER(op) \
1686 DEFN_ASN_OP_T(op, int64) \
1687 DEFN_ASN_OP_T(op, uint64) \
1688 DEFN_ASN_OP_T(op, const sc_int_base &) \
1689 DEFN_ASN_OP_T(op, const sc_uint_base &) \
1690 DEFN_ASN_OP_T(op, const sc_signed &) \
1691 DEFN_ASN_OP_T(op, const sc_unsigned &)
1692 
1693 #define DEFN_ASN_OP(op) \
1694 inline sc_fxval_fast & \
1695 sc_fxval_fast::operator op (const sc_fxval_fast &b) \
1696 { \
1697  SC_FXVAL_FAST_OBSERVER_READ_(*this) \
1698  SC_FXVAL_FAST_OBSERVER_READ_(b) \
1699  m_val op b.m_val; \
1700  SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1701  return *this; \
1702 } \
1703  \
1704 DEFN_ASN_OP_T(op, int) \
1705 DEFN_ASN_OP_T(op, unsigned int) \
1706 DEFN_ASN_OP_T(op, long) \
1707 DEFN_ASN_OP_T(op, unsigned long) \
1708 DEFN_ASN_OP_T(op, float) \
1709 DEFN_ASN_OP_T(op, double) \
1710 DEFN_ASN_OP_T(op, const char *) \
1711 DEFN_ASN_OP_T(op, const sc_fxval &) \
1712 DEFN_ASN_OP_OTHER(op)
1713 
1714 DEFN_ASN_OP(*=)
1715 DEFN_ASN_OP(/=)
1716 DEFN_ASN_OP(+=)
1717 DEFN_ASN_OP(-=)
1718 
1719 #undef DEFN_ASN_OP_T
1720 #undef DEFN_ASN_OP_OTHER
1721 #undef DEFN_ASN_OP
1722 
1723 inline sc_fxval_fast &
1724 sc_fxval_fast::operator <<= (int b)
1725 {
1727  m_val *= scfx_pow2(b);
1729  return *this;
1730 }
1731 
1732 inline sc_fxval_fast &
1733 sc_fxval_fast::operator >>= (int b)
1734 {
1736  m_val *= scfx_pow2(-b);
1738  return *this;
1739 }
1740 
1741 // auto-increment and auto-decrement
1742 inline const sc_fxval_fast
1743 sc_fxval_fast::operator ++ (int)
1744 {
1747  double c = m_val;
1748  m_val = m_val + 1;
1750  return sc_fxval_fast(c);
1751 }
1752 
1753 inline const sc_fxval_fast
1755 {
1758  double c = m_val;
1759  m_val = m_val - 1;
1761  return sc_fxval_fast(c);
1762 }
1763 
1764 inline sc_fxval_fast &
1766 {
1768  m_val = m_val + 1;
1770  return *this;
1771 }
1772 
1773 inline sc_fxval_fast &
1775 {
1777  m_val = m_val - 1;
1779  return *this;
1780 }
1781 
1782 // implicit conversion
1783 inline sc_fxval_fast::operator double() const
1784 {
1786  return m_val;
1787 }
1788 
1789 // explicit conversion to primitive types
1790 inline short
1792 {
1793  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1794  return static_cast<short>(to_uint64());
1795 }
1796 
1797 inline unsigned short
1799 {
1800  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1801  return static_cast<unsigned short>(to_uint64());
1802 }
1803 
1804 inline int64
1806 {
1807  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1808  return static_cast<int64>(to_uint64());
1809 }
1810 
1811 inline int
1813 {
1814  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1815  return static_cast<int>(to_uint64());
1816 }
1817 
1818 inline unsigned int
1820 {
1821  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1822  return static_cast<unsigned int>(to_uint64());
1823 }
1824 
1825 inline uint64
1827 {
1828  // SC_FXVAL_FAST_OBSERVER_READ_ in is_normal
1829  if (!is_normal()) {
1830  return 0;
1831  }
1832 
1833  int exponent;
1834  double mantissa_dbl = frexp(m_val, &exponent);
1835 
1836  uint64 mantissa = static_cast<uint64>(
1837  fabs(mantissa_dbl) * (UINT64_ONE << 53));
1838  exponent -= 53;
1839 
1840  if (!(-64 < exponent && exponent < 64)) {
1841  return 0;
1842  }
1843 
1844  mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
1845  return mantissa_dbl >= 0 ? mantissa : -mantissa;
1846 }
1847 
1848 inline long
1850 {
1851  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1852  return static_cast<long>(to_uint64());
1853 }
1854 
1855 inline unsigned long
1857 {
1858  // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
1859  return static_cast<unsigned long>(to_uint64());
1860 }
1861 
1862 inline float
1864 {
1866  return static_cast<float>(m_val);
1867 }
1868 
1869 inline double
1871 {
1873  return m_val;
1874 }
1875 
1876 // query value
1877 inline bool
1879 {
1882  return (id.negative() != 0);
1883 }
1884 
1885 inline bool
1887 {
1890  return id.is_zero();
1891 }
1892 
1893 inline bool
1895 {
1898  return id.is_nan();
1899 }
1900 
1901 inline bool
1903 {
1906  return id.is_inf();
1907 }
1908 
1909 inline bool
1911 {
1914  return (id.is_normal() || id.is_subnormal() || id.is_zero());
1915 }
1916 
1917 inline bool
1919 {
1920  // does not apply to sc_fxval_fast; included for API compatibility
1921  return false;
1922 }
1923 
1924 inline ::std::ostream &
1925 operator << (::std::ostream &os, const sc_fxval_fast &a)
1926 {
1927  a.print(os);
1928  return os;
1929 }
1930 
1931 inline ::std::istream &
1932 operator >> (::std::istream &is, sc_fxval_fast &a)
1933 {
1934  a.scan(is);
1935  return is;
1936 }
1937 
1938 } // namespace sc_dt
1939 
1940 #undef SCFX_EXPLICIT_
1941 #undef SCFX_EXPLICIT_OTHER_
1942 
1943 #endif // __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
sc_dt::sc_fxval_fast::to_uint
unsigned int to_uint() const
Definition: sc_fxval.hh:1819
sc_dt::sc_fxval::to_float
float to_float() const
Definition: sc_fxval.hh:1205
sc_dt::sc_fxval::to_long
long to_long() const
Definition: sc_fxval.hh:1191
sc_dt::sc_fxval_fast::operator/
const friend sc_fxval_fast operator/(const sc_fxval_fast &, const sc_fxval_fast &)
Definition: sc_fxval.hh:1464
sc_dt::sc_fxval::is_normal
bool is_normal() const
Definition: sc_fxval.hh:1248
sc_dt::sc_fxval_fast_observer
Definition: sc_fxval_observer.hh:164
sc_dt::sc_fxval_fast::set_val
void set_val(double)
Definition: sc_fxval.hh:1385
sc_dt::sc_fxval::operator/
const friend sc_fxval operator/(const sc_fxval &, const sc_fxval &)
Definition: sc_fxval.hh:819
sc_dt::sc_fxval::get_bit
bool get_bit(int) const
Definition: sc_fxval.hh:1262
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
sc_dt::sc_fxval_fast::from_string
static double from_string(const char *)
Definition: sc_fxval.cc:659
sc_dt::sc_fxval_fast::operator--
sc_fxval_fast & operator--()
Definition: sc_fxval.hh:1774
sc_dt::sc_fxval_fast::to_long
long to_long() const
Definition: sc_fxval.hh:1849
sc_dt::scfx_rep
Definition: scfx_rep.hh:169
sc_dt::sc_fxval::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxval.cc:173
sc_dt::sc_fxval::to_int
int to_int() const
Definition: sc_fxval.hh:1163
sc_dt::sc_fxval::rounding_flag
bool rounding_flag() const
Definition: sc_fxval.hh:1255
sc_dt::sc_fxval::to_oct
const std::string to_oct() const
Definition: sc_fxval.cc:148
sc_dt
Definition: sc_bit.cc:67
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_dt::scfx_params
Definition: scfx_params.hh:98
sc_dt::sc_fxval_fast::to_float
float to_float() const
Definition: sc_fxval.hh:1863
SC_FXVAL_FAST_OBSERVER_CONSTRUCT_
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxval_observer.hh:126
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
sc_dt::sc_fxval::unlock_observer
void unlock_observer(sc_fxval_observer *) const
Definition: sc_fxval.cc:200
sc_fxval_observer.hh
sc_dt::sc_fxval_fast::operator+
const sc_fxval_fast & operator+() const
Definition: sc_fxval.hh:1400
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_fxval::rshift
friend void rshift(sc_fxval &, const sc_fxval &, int)
Definition: sc_fxval.hh:931
sc_dt::sc_fxval_fast::observer
sc_fxval_fast_observer * observer() const
Definition: sc_fxval.hh:1309
sc_dt::sc_fxval
Definition: sc_fxval.hh:86
sc_dt::operator<<
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
Definition: sc_signed.cc:853
DECL_REL_OP
#define DECL_REL_OP(op)
Definition: sc_fxval.hh:524
SC_FXVAL_FAST_OBSERVER_DESTRUCT_
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
Definition: sc_fxval_observer.hh:127
sc_dt::sc_fxval::operator-
const sc_fxval operator-() const
Definition: sc_fxval.hh:744
sc_dt::sc_fxval_fast::m_val
double m_val
Definition: sc_fxval.hh:643
DEFN_CTOR_T_A
#define DEFN_CTOR_T_A(tp)
Definition: sc_fxval.hh:1343
sc_dt::sc_int_base
Definition: sc_int_base.hh:494
sc_dt::sc_fxval_fast::get_val
double get_val() const
Definition: sc_fxval.hh:1377
sc_dt::sc_fxval::m_rep
scfx_rep * m_rep
Definition: sc_fxval.hh:364
SC_FXVAL_FAST_OBSERVER_READ_
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
Definition: sc_fxval_observer.hh:128
sc_dt::sc_fxval_fast::operator++
sc_fxval_fast & operator++()
Definition: sc_fxval.hh:1765
sc_dt::sc_fxval_fast::to_ushort
unsigned short to_ushort() const
Definition: sc_fxval.hh:1798
sc_dt::sc_fxval::operator>>
const friend sc_fxval operator>>(const sc_fxval &, int)
Definition: sc_fxval.hh:855
sc_dt::operator/
sc_signed operator/(const sc_unsigned &u, const sc_int_base &v)
Definition: sc_signed.cc:698
sc_dt::sc_fxval::overflow
const sc_fxval overflow(const scfx_params &, bool &) const
Definition: sc_fxval.hh:1281
sc_dt::scfx_pow2
double scfx_pow2(int exp)
Definition: scfx_ieee.hh:599
sc_dt::sc_fxval_fast::is_inf
bool is_inf() const
Definition: sc_fxval.hh:1902
sc_dt::sc_fxval::to_ushort
unsigned short to_ushort() const
Definition: sc_fxval.hh:1156
DEFN_BIN_FNC
#define DEFN_BIN_FNC(fnc)
Definition: sc_fxval.hh:1535
sc_dt::sc_fxval::operator--
sc_fxval & operator--()
Definition: sc_fxval.hh:1134
sc_dt::sc_fxval_fast::to_string
const std::string to_string() const
Definition: sc_fxval.cc:503
sc_dt::sc_fxval_fast::to_oct
const std::string to_oct() const
Definition: sc_fxval.cc:553
sc_dt::scfx_rep::to_double
double to_double() const
Definition: scfx_rep.cc:754
DEFN_BIN_OP
#define DEFN_BIN_OP(op, fnc)
Definition: sc_fxval.hh:1441
sc_dt::sc_signed
Definition: sc_signed.hh:984
sc_dt::sc_fxval_fast::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxval.cc:574
sc_dt::sc_fxval::quantization
const sc_fxval quantization(const scfx_params &, bool &) const
Definition: sc_fxval.hh:1275
sc_dt::sc_fxval::to_short
short to_short() const
Definition: sc_fxval.hh:1149
sc_dt::sc_fxval::to_double
double to_double() const
Definition: sc_fxval.hh:1212
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_fxval_fast::get_bit
bool get_bit(int) const
Definition: sc_fxval.cc:600
sc_dt::sc_fxval::neg
friend void neg(sc_fxval &, const sc_fxval &)
Definition: sc_fxval.hh:759
sc_dt::sc_fxval::to_int64
int64 to_int64() const
Definition: sc_fxval.hh:1170
sc_dt::sc_fxval_fast::to_int
int to_int() const
Definition: sc_fxval.hh:1812
sc_dt::scfx_rep::get_bit
bool get_bit(int) const
Definition: scfx_rep.cc:2360
SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_OBSERVER_DEFAULT_
Definition: sc_fxval_observer.hh:124
sc_dt::quantization_scfx_rep
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &q_flag)
Definition: scfx_rep.hh:427
sc_dt::sc_fxval_fast::to_int64
int64 to_int64() const
Definition: sc_fxval.hh:1805
sc_dt::sc_fxval_fast::operator>>
const friend sc_fxval_fast operator>>(const sc_fxval_fast &, int)
Definition: sc_fxval.hh:1501
sc_dt::sc_fxval_fast::to_dec
const std::string to_dec() const
Definition: sc_fxval.cc:541
sc_dt::sc_fxval::to_dec
const std::string to_dec() const
Definition: sc_fxval.cc:136
SC_FXVAL_OBSERVER_DESTRUCT_
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
Definition: sc_fxval_observer.hh:121
sc_dt::sc_fxval_fast::operator-
const sc_fxval_fast operator-() const
Definition: sc_fxval.hh:1393
DEFN_BIN_OP_T
#define DEFN_BIN_OP_T(op, fnc, tp)
Definition: sc_fxval.hh:1416
sc_dt::sc_fxval_observer
Definition: sc_fxval_observer.hh:142
sc_dt::sc_fmt
sc_fmt
Definition: sc_fxdefs.hh:164
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
sc_dt::sc_fxval::to_hex
const std::string to_hex() const
Definition: sc_fxval.cc:154
sc_dt::UINT64_ONE
static const uint64 UINT64_ONE
Definition: sc_nbdefs.hh:210
DECL_BIN_OP
#define DECL_BIN_OP(op, dummy)
Definition: sc_fxval.hh:430
sc_dt::sc_fxval_fast::to_hex
const std::string to_hex() const
Definition: sc_fxval.cc:559
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_dt::sc_fxval::get_rep
const scfx_rep * get_rep() const
Definition: sc_fxval.hh:727
sc_dt::neg
void neg(sc_fxval &c, const sc_fxnum &a)
Definition: sc_fxnum.hh:2270
SC_FXVAL_FAST_OBSERVER_WRITE_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
Definition: sc_fxval_observer.hh:129
sc_dt::neg_scfx_rep
scfx_rep * neg_scfx_rep(const scfx_rep &)
Definition: scfx_rep.hh:371
sc_dt::sc_fxval_fast::is_nan
bool is_nan() const
Definition: sc_fxval.hh:1894
sc_dt::sc_fxval_fast::to_uint64
uint64 to_uint64() const
Definition: sc_fxval.hh:1826
sc_dt::sc_fxval_fast::is_normal
bool is_normal() const
Definition: sc_fxval.hh:1910
sc_dt::lshift
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
Definition: sc_fxnum.hh:2536
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_dt::sc_fxval::get_type
void get_type(int &, int &, sc_enc &) const
Definition: sc_fxval.hh:1269
sc_dt::scfx_rep::to_uint64
uint64 to_uint64() const
Definition: scfx_rep.cc:866
sc_dt::sc_fxval_fast::lock_observer
sc_fxval_fast_observer * lock_observer() const
Definition: sc_fxval.cc:637
sc_dt::sc_fxval_fast::is_neg
bool is_neg() const
Definition: sc_fxval.hh:1878
sc_dt::sc_fxval::to_ulong
unsigned long to_ulong() const
Definition: sc_fxval.hh:1198
DECL_BIN_FNC
#define DECL_BIN_FNC(fnc)
Definition: sc_fxval.hh:485
sc_dt::sc_fxval_fast::rounding_flag
bool rounding_flag() const
Definition: sc_fxval.hh:1918
DEFN_ASN_OP_T
#define DEFN_ASN_OP_T(tp)
Definition: sc_fxval.hh:1674
sc_dt::scfx_rep::is_nan
bool is_nan() const
Definition: scfx_rep.hh:420
sc_dt::sc_fxval::to_uint
unsigned int to_uint() const
Definition: sc_fxval.hh:1177
DEFN_CTOR_T_B
#define DEFN_CTOR_T_B(tp)
Definition: sc_fxval.hh:1344
sc_dt::sc_fxval::lshift
friend void lshift(sc_fxval &, const sc_fxval &, int)
Definition: sc_fxval.hh:922
sc_dt::int64
int64_t int64
Definition: sc_nbdefs.hh:205
sc_dt::sc_fxval::m_observer
sc_fxval_observer * m_observer
Definition: sc_fxval.hh:366
sc_dt::sc_fxval_fast::to_bin
const std::string to_bin() const
Definition: sc_fxval.cc:547
SC_FXVAL_OBSERVER_WRITE_
#define SC_FXVAL_OBSERVER_WRITE_(object)
Definition: sc_fxval_observer.hh:123
sc_dt::scfx_rep::is_zero
bool is_zero() const
Definition: scfx_rep.hh:407
sc_dt::sc_fxval::is_inf
bool is_inf() const
Definition: sc_fxval.hh:1241
sc_dt::sc_fxval_fast::DECL_BIN_OP_T
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/
sc_dt::sc_fxval::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxval.cc:162
SC_FXVAL_OBSERVER_READ_
#define SC_FXVAL_OBSERVER_READ_(object)
Definition: sc_fxval_observer.hh:122
sc_dt::sc_fxval_fast::to_ulong
unsigned long to_ulong() const
Definition: sc_fxval.hh:1856
sc_dt::sc_uint_base
Definition: sc_uint_base.hh:465
DECL_ASN_OP
#define DECL_ASN_OP(op)
Definition: sc_fxval.hh:557
sc_dt::sc_fxval_fast::is_zero
bool is_zero() const
Definition: sc_fxval.hh:1886
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_fxval
#define sc_fxval
Definition: fx_precision_double.h:65
sc_dt::sc_fxval_fast::rshift
friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int)
Definition: sc_fxval.hh:1572
sc_dt::sc_fxval_fast::print
void print(::std::ostream &=::std::cout) const
Definition: sc_fxval.cc:568
sc_dt::sc_fxval::lock_observer
sc_fxval_observer * lock_observer() const
Definition: sc_fxval.cc:191
sc_dt::operator>>
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
Definition: sc_signed.cc:866
sc_dt::sc_fxval_fast::to_short
short to_short() const
Definition: sc_fxval.hh:1791
sc_dt::sc_fxval::to_bin
const std::string to_bin() const
Definition: sc_fxval.cc:142
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
sc_dt::sc_fxval::operator+
const sc_fxval & operator+() const
Definition: sc_fxval.hh:751
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
sc_dt::sc_fxval_fast::unlock_observer
void unlock_observer(sc_fxval_fast_observer *) const
Definition: sc_fxval.cc:646
sc_dt::sc_fxval::observer
sc_fxval_observer * observer() const
Definition: sc_fxval.hh:659
DECL_ASN_OP_T
#define DECL_ASN_OP_T(op, tp)
Definition: sc_fxval.hh:547
sc_dt::sc_fxval::~sc_fxval
~sc_fxval()
Definition: sc_fxval.hh:719
sc_dt::sc_fxval::is_neg
bool is_neg() const
Definition: sc_fxval.hh:1220
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_dt::sc_fxval::operator<<
const friend sc_fxval operator<<(const sc_fxval &, int)
Definition: sc_fxval.hh:848
sc_dt::scfx_rep::is_inf
bool is_inf() const
Definition: scfx_rep.hh:422
DEFN_ASN_OP
#define DEFN_ASN_OP(op, fnc)
Definition: sc_fxval.hh:1693
sc_dt::sc_fxval_fast::m_observer
sc_fxval_fast_observer * m_observer
Definition: sc_fxval.hh:645
sc_dt::sc_fxval::set_rep
void set_rep(scfx_rep *)
Definition: sc_fxval.hh:735
sc_dt::sc_fxval_fast::~sc_fxval_fast
~sc_fxval_fast()
Definition: sc_fxval.hh:1370
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
sc_dt::sc_fxval::to_string
const std::string to_string() const
Definition: sc_fxval.cc:99
DEFN_CTOR_T_C
#define DEFN_CTOR_T_C(tp)
Definition: sc_fxval.hh:1345
scfx_rep.hh
sc_dt::sc_fxval_fast::dump
void dump(::std::ostream &=::std::cout) const
Definition: sc_fxval.cc:582
sc_dt::scfx_rep::is_normal
bool is_normal() const
Definition: scfx_rep.hh:424
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::overflow_scfx_rep
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &o_flag)
Definition: scfx_rep.hh:436
sc_dt::sc_fxval_fast::lshift
friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int)
Definition: sc_fxval.hh:1564
sc_dt::sc_fxval::scan
void scan(::std::istream &=::std::cin)
Definition: sc_fxval.cc:165
DEFN_REL_OP
#define DEFN_REL_OP(op, ret)
Definition: sc_fxval.hh:1605
sc_dt::scfx_rep::rounding_flag
bool rounding_flag() const
Definition: scfx_rep.hh:443
SC_FXVAL_OBSERVER_CONSTRUCT_
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
Definition: sc_fxval_observer.hh:120
DECL_BIN_OP_T
#define DECL_BIN_OP_T(op, tp)
Definition: sc_fxval.hh:418
sc_dt::rsh_scfx_rep
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.hh:395
sc_dt::sc_fxval_fast::neg
friend void neg(sc_fxval_fast &, const sc_fxval_fast &)
Definition: sc_fxval.hh:1408
sc_dt::scfx_rep::get_type
void get_type(int &, int &, sc_enc &) const
Definition: scfx_rep.cc:2570
sc_dt::sc_fxval::to_uint64
uint64 to_uint64() const
Definition: sc_fxval.hh:1184
sc_dt::sc_fxval_fast::sc_fxval_fast
sc_fxval_fast(sc_fxval_fast_observer *=0)
Definition: sc_fxval.hh:1316
sc_dt::sc_fxval::is_zero
bool is_zero() const
Definition: sc_fxval.hh:1227
sc_dt::sc_fxval::is_nan
bool is_nan() const
Definition: sc_fxval.hh:1234
sc_dt::sc_fxval_fast::to_double
double to_double() const
Definition: sc_fxval.hh:1870
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
sc_dt::sc_fxval::operator++
sc_fxval & operator++()
Definition: sc_fxval.hh:1127

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