SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_fxval.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_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 SC_FXVAL_H
54#define SC_FXVAL_H
55
56
63
64#ifdef SC_FXVAL_IMPLICIT_CONV
65# define SCFX_EXPLICIT_ // nothing
66#else
67# define SCFX_EXPLICIT_ explicit
68#endif
69#ifdef SC_FXVAL_IMPLICIT_OTHER
70# define SCFX_EXPLICIT_OTHER_
71#else
72# define SCFX_EXPLICIT_OTHER_ explicit
73#endif
74
75namespace sc_dt
76{
77
78// classes defined in this module
79class sc_fxval;
80class sc_fxval_fast;
81
82// forward class declarations
83class sc_fxnum;
84class sc_fxnum_fast;
85
86
87// ----------------------------------------------------------------------------
88// CLASS : sc_fxval
89//
90// Fixed-point value type; arbitrary precision.
91// ----------------------------------------------------------------------------
92
94{
95
96 friend class sc_fxnum;
97
98protected:
99
100 sc_fxval_observer* observer() const;
101
102public:
103
104 // internal use only;
105 explicit sc_fxval( scfx_rep* );
106
107
108 explicit sc_fxval( sc_fxval_observer* = 0 );
116 sc_fxval( const sc_fxval&, sc_fxval_observer* = 0 );
118 sc_fxval( const sc_fxnum&, sc_fxval_observer* = 0 );
126
127 ~sc_fxval();
128
129
130 // internal use only;
131 const scfx_rep* get_rep() const;
132 void set_rep( scfx_rep* );
133
134
135 // unary operators
136
137 sc_fxval operator - () const;
138 const sc_fxval& operator + () const;
139
140
141 // unary functions
142
143 friend void neg( sc_fxval&, const sc_fxval& );
144
145
146 // binary operators
147
148#define DECL_BIN_OP_T(op,tp) \
149 friend sc_fxval operator op ( const sc_fxval&, tp ); \
150 friend sc_fxval operator op ( tp, const sc_fxval& );
151
152#define DECL_BIN_OP_OTHER(op) \
153 DECL_BIN_OP_T(op,int64) \
154 DECL_BIN_OP_T(op,uint64) \
155 DECL_BIN_OP_T(op,const sc_int_base&) \
156 DECL_BIN_OP_T(op,const sc_uint_base&) \
157 DECL_BIN_OP_T(op,const sc_signed&) \
158 DECL_BIN_OP_T(op,const sc_unsigned&)
159
160#define DECL_BIN_OP(op,dummy) \
161 friend sc_fxval operator op ( const sc_fxval&, const sc_fxval& ); \
162 DECL_BIN_OP_T(op,int) \
163 DECL_BIN_OP_T(op,unsigned int) \
164 DECL_BIN_OP_T(op,long) \
165 DECL_BIN_OP_T(op,unsigned long) \
166 DECL_BIN_OP_T(op,float) \
167 DECL_BIN_OP_T(op,double) \
168 DECL_BIN_OP_T(op,const char*) \
169 DECL_BIN_OP_T(op,const sc_fxval_fast&) \
170 DECL_BIN_OP_T(op,const sc_fxnum_fast&) \
171 DECL_BIN_OP_OTHER(op)
172
173 DECL_BIN_OP(*,mult)
174 DECL_BIN_OP(+,add)
175 DECL_BIN_OP(-,sub)
176// declaration below doesn't compile with BCB5 (E2206)
177// DECL_BIN_OP(/,div)
178// previous macro expanded
179 friend sc_fxval operator / ( const sc_fxval&, const sc_fxval& );
180 DECL_BIN_OP_T(/,int)
181 DECL_BIN_OP_T(/,unsigned int)
182 DECL_BIN_OP_T(/,long)
183 DECL_BIN_OP_T(/,unsigned long)
184 DECL_BIN_OP_T(/,float)
185 DECL_BIN_OP_T(/,double)
186 DECL_BIN_OP_T(/,const char*)
189// DECL_BIN_OP_OTHER(/)
193 DECL_BIN_OP_T(/,const sc_uint_base&) \
195 DECL_BIN_OP_T(/,const sc_unsigned&)
196
197
198#undef DECL_BIN_OP_T
199#undef DECL_BIN_OP_OTHER
200#undef DECL_BIN_OP
201
202 friend sc_fxval operator << ( const sc_fxval&, int );
203 friend sc_fxval operator >> ( const sc_fxval&, int );
204
205
206 // binary functions
207
208#define DECL_BIN_FNC_T(fnc,tp) \
209 friend void fnc ( sc_fxval&, const sc_fxval&, tp ); \
210 friend void fnc ( sc_fxval&, tp, const sc_fxval& );
211
212#define DECL_BIN_FNC_OTHER(fnc) \
213 DECL_BIN_FNC_T(fnc,int64) \
214 DECL_BIN_FNC_T(fnc,uint64) \
215 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
216 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
217 DECL_BIN_FNC_T(fnc,const sc_signed&) \
218 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
219
220#define DECL_BIN_FNC(fnc) \
221 friend void fnc ( sc_fxval&, const sc_fxval&, const sc_fxval& ); \
222 DECL_BIN_FNC_T(fnc,int) \
223 DECL_BIN_FNC_T(fnc,unsigned int) \
224 DECL_BIN_FNC_T(fnc,long) \
225 DECL_BIN_FNC_T(fnc,unsigned long) \
226 DECL_BIN_FNC_T(fnc,float) \
227 DECL_BIN_FNC_T(fnc,double) \
228 DECL_BIN_FNC_T(fnc,const char*) \
229 DECL_BIN_FNC_T(fnc,const sc_fxval_fast&) \
230 DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&) \
231 DECL_BIN_FNC_OTHER(fnc)
232
233 DECL_BIN_FNC(mult)
235 DECL_BIN_FNC(add)
236 DECL_BIN_FNC(sub)
237
238#undef DECL_BIN_FNC_T
239#undef DECL_BIN_FNC_OTHER
240#undef DECL_BIN_FNC
241
242 friend void lshift( sc_fxval&, const sc_fxval&, int );
243 friend void rshift( sc_fxval&, const sc_fxval&, int );
244
245
246 // relational (including equality) operators
247
248#define DECL_REL_OP_T(op,tp) \
249 friend bool operator op ( const sc_fxval&, tp ); \
250 friend bool operator op ( tp, const sc_fxval& );
251
252#define DECL_REL_OP_OTHER(op) \
253 DECL_REL_OP_T(op,int64) \
254 DECL_REL_OP_T(op,uint64) \
255 DECL_REL_OP_T(op,const sc_int_base&) \
256 DECL_REL_OP_T(op,const sc_uint_base&) \
257 DECL_REL_OP_T(op,const sc_signed&) \
258 DECL_REL_OP_T(op,const sc_unsigned&)
259
260#define DECL_REL_OP(op) \
261 friend bool operator op ( const sc_fxval&, const sc_fxval& ); \
262 DECL_REL_OP_T(op,int) \
263 DECL_REL_OP_T(op,unsigned int) \
264 DECL_REL_OP_T(op,long) \
265 DECL_REL_OP_T(op,unsigned long) \
266 DECL_REL_OP_T(op,float) \
267 DECL_REL_OP_T(op,double) \
268 DECL_REL_OP_T(op,const char*) \
269 DECL_REL_OP_T(op,const sc_fxval_fast&) \
270 DECL_REL_OP_T(op,const sc_fxnum_fast&) \
271 DECL_REL_OP_OTHER(op)
272
273 DECL_REL_OP(<)
274 DECL_REL_OP(<=)
275 DECL_REL_OP(>)
276 DECL_REL_OP(>=)
277 DECL_REL_OP(==)
278 DECL_REL_OP(!=)
279
280#undef DECL_REL_OP_T
281#undef DECL_REL_OP_OTHER
282#undef DECL_REL_OP
283
284
285 // assignment operators
286
287#define DECL_ASN_OP_T(op,tp) \
288 sc_fxval& operator op( tp );
289
290#define DECL_ASN_OP_OTHER(op) \
291 DECL_ASN_OP_T(op,int64) \
292 DECL_ASN_OP_T(op,uint64) \
293 DECL_ASN_OP_T(op,const sc_int_base&) \
294 DECL_ASN_OP_T(op,const sc_uint_base&) \
295 DECL_ASN_OP_T(op,const sc_signed&) \
296 DECL_ASN_OP_T(op,const sc_unsigned&)
297
298#define DECL_ASN_OP(op) \
299 DECL_ASN_OP_T(op,int) \
300 DECL_ASN_OP_T(op,unsigned int) \
301 DECL_ASN_OP_T(op,long) \
302 DECL_ASN_OP_T(op,unsigned long) \
303 DECL_ASN_OP_T(op,float) \
304 DECL_ASN_OP_T(op,double) \
305 DECL_ASN_OP_T(op,const char*) \
306 DECL_ASN_OP_T(op,const sc_fxval&) \
307 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
308 DECL_ASN_OP_T(op,const sc_fxnum&) \
309 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
310 DECL_ASN_OP_OTHER(op)
311
312 DECL_ASN_OP(=)
313
314 DECL_ASN_OP(*=)
315 DECL_ASN_OP(/=)
316 DECL_ASN_OP(+=)
317 DECL_ASN_OP(-=)
318
319 DECL_ASN_OP_T(<<=,int)
320 DECL_ASN_OP_T(>>=,int)
321
322#undef DECL_ASN_OP_T
323#undef DECL_ASN_OP_OTHER
324#undef DECL_ASN_OP
325
326
327 // auto-increment and auto-decrement
328
329 sc_fxval operator ++ ( int );
330 sc_fxval operator -- ( int );
331
332 sc_fxval& operator ++ ();
333 sc_fxval& operator -- ();
334
335
336 // implicit conversion
337
338 operator double() const; // necessary evil!
339
340
341 // explicit conversion to primitive types
342
343 short to_short() const;
344 unsigned short to_ushort() const;
345 int to_int() const;
346 unsigned int to_uint() const;
347 long to_long() const;
348 unsigned long to_ulong() const;
349 int64 to_int64() const;
350 uint64 to_uint64() const;
351 float to_float() const;
352 double to_double() const;
353
354
355 // explicit conversion to character string
356
357 std::string to_string() const;
358 std::string to_string( sc_numrep ) const;
359 std::string to_string( sc_numrep, bool ) const;
360 std::string to_string( sc_fmt ) const;
361 std::string to_string( sc_numrep, sc_fmt ) const;
362 std::string to_string( sc_numrep, bool, sc_fmt ) const;
363
364 std::string to_dec() const;
365 std::string to_bin() const;
366 std::string to_oct() const;
367 std::string to_hex() const;
368
369
370 // query value
371
372 bool is_neg() const;
373 bool is_zero() const;
374 bool is_nan() const;
375 bool is_inf() const;
376 bool is_normal() const;
377
378 bool rounding_flag() const;
379
380
381 // print or dump content
382
383 void print( ::std::ostream& = ::std::cout ) const;
384 void scan( ::std::istream& = ::std::cin );
385 void dump( ::std::ostream& = ::std::cout ) const;
386
387
388 // internal use only;
389 bool get_bit( int ) const;
390
391protected:
392
395
396
397 void get_type( int&, int&, sc_enc& ) const;
398
399 sc_fxval quantization( const scfx_params&, bool& ) const;
400 sc_fxval overflow( const scfx_params&, bool& ) const;
401
402private:
403
404 scfx_rep* m_rep;
405
406 mutable sc_fxval_observer* m_observer;
407
408};
409
410
411// ----------------------------------------------------------------------------
412// CLASS : sc_fxval_fast
413//
414// Fixed-point value type; limited precision.
415// ----------------------------------------------------------------------------
416
418{
419
420 friend class sc_fxnum_fast;
421
422protected:
423
424 sc_fxval_fast_observer* observer() const;
425
426public:
427
428 explicit sc_fxval_fast( sc_fxval_fast_observer* = 0 );
446
448
449 // internal use only;
450 double get_val() const;
451 void set_val( double );
452
453
454 // unary operators
455
457 const sc_fxval_fast& operator + () const;
458
459
460 // unary functions
461
462 friend void neg( sc_fxval_fast&, const sc_fxval_fast& );
463
464
465 // binary operators
466
467#define DECL_BIN_OP_T(op,tp) \
468 friend sc_fxval_fast operator op ( const sc_fxval_fast&, tp ); \
469 friend sc_fxval_fast operator op ( tp, const sc_fxval_fast& );
470
471#define DECL_BIN_OP_OTHER(op) \
472 DECL_BIN_OP_T(op,int64) \
473 DECL_BIN_OP_T(op,uint64) \
474 DECL_BIN_OP_T(op,const sc_int_base&) \
475 DECL_BIN_OP_T(op,const sc_uint_base&) \
476 DECL_BIN_OP_T(op,const sc_signed&) \
477 DECL_BIN_OP_T(op,const sc_unsigned&)
478
479#define DECL_BIN_OP(op,dummy) \
480 friend sc_fxval_fast operator op ( const sc_fxval_fast&, \
481 const sc_fxval_fast& ); \
482 DECL_BIN_OP_T(op,int) \
483 DECL_BIN_OP_T(op,unsigned int) \
484 DECL_BIN_OP_T(op,long) \
485 DECL_BIN_OP_T(op,unsigned long) \
486 DECL_BIN_OP_T(op,float) \
487 DECL_BIN_OP_T(op,double) \
488 DECL_BIN_OP_T(op,const char*) \
489 DECL_BIN_OP_OTHER(op)
490
491 DECL_BIN_OP(*,mult)
492 DECL_BIN_OP(+,add)
493 DECL_BIN_OP(-,sub)
494// don't use macro
495// DECL_BIN_OP(/,div)
496 friend sc_fxval_fast operator / ( const sc_fxval_fast&,
497 const sc_fxval_fast& );
498 DECL_BIN_OP_T(/,int)
499 DECL_BIN_OP_T(/,unsigned int)
500 DECL_BIN_OP_T(/,long)
501 DECL_BIN_OP_T(/,unsigned long)
502 DECL_BIN_OP_T(/,float)
503 DECL_BIN_OP_T(/,double)
504 DECL_BIN_OP_T(/,const char*)
505// DECL_BIN_OP_OTHER(/)
509 DECL_BIN_OP_T(/,const sc_uint_base&) \
511 DECL_BIN_OP_T(/,const sc_unsigned&)
512
513#undef DECL_BIN_OP_T
514#undef DECL_BIN_OP_OTHER
515#undef DECL_BIN_OP
516
518 friend sc_fxval_fast operator >> ( const sc_fxval_fast&, int );
519
520
521 // binary functions
522
523#define DECL_BIN_FNC_T(fnc,tp) \
524 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, tp ); \
525 friend void fnc ( sc_fxval_fast&, tp, const sc_fxval_fast& );
526
527#define DECL_BIN_FNC_OTHER(fnc) \
528 DECL_BIN_FNC_T(fnc,int64) \
529 DECL_BIN_FNC_T(fnc,uint64) \
530 DECL_BIN_FNC_T(fnc,const sc_int_base&) \
531 DECL_BIN_FNC_T(fnc,const sc_uint_base&) \
532 DECL_BIN_FNC_T(fnc,const sc_signed&) \
533 DECL_BIN_FNC_T(fnc,const sc_unsigned&)
534
535#define DECL_BIN_FNC(fnc) \
536 friend void fnc ( sc_fxval_fast&, const sc_fxval_fast&, \
537 const sc_fxval_fast& ); \
538 DECL_BIN_FNC_T(fnc,int) \
539 DECL_BIN_FNC_T(fnc,unsigned int) \
540 DECL_BIN_FNC_T(fnc,long) \
541 DECL_BIN_FNC_T(fnc,unsigned long) \
542 DECL_BIN_FNC_T(fnc,float) \
543 DECL_BIN_FNC_T(fnc,double) \
544 DECL_BIN_FNC_T(fnc,const char*) \
545 DECL_BIN_FNC_T(fnc,const sc_fxval&) \
546 DECL_BIN_FNC_T(fnc,const sc_fxnum&) \
547 DECL_BIN_FNC_OTHER(fnc)
548
549 DECL_BIN_FNC(mult)
551 DECL_BIN_FNC(add)
552 DECL_BIN_FNC(sub)
553
554#undef DECL_BIN_FNC_T
555#undef DECL_BIN_FNC_OTHER
556#undef DECL_BIN_FNC
557
558 friend void lshift( sc_fxval_fast&, const sc_fxval_fast&, int );
559 friend void rshift( sc_fxval_fast&, const sc_fxval_fast&, int );
560
561
562 // relational (including equality) operators
563
564#define DECL_REL_OP_T(op,tp) \
565 friend bool operator op ( const sc_fxval_fast&, tp ); \
566 friend bool operator op ( tp, const sc_fxval_fast& );
567
568#define DECL_REL_OP_OTHER(op) \
569 DECL_REL_OP_T(op,int64) \
570 DECL_REL_OP_T(op,uint64) \
571 DECL_REL_OP_T(op,const sc_int_base&) \
572 DECL_REL_OP_T(op,const sc_uint_base&) \
573 DECL_REL_OP_T(op,const sc_signed&) \
574 DECL_REL_OP_T(op,const sc_unsigned&)
575
576#define DECL_REL_OP(op) \
577 friend bool operator op ( const sc_fxval_fast&, const sc_fxval_fast& ); \
578 DECL_REL_OP_T(op,int) \
579 DECL_REL_OP_T(op,unsigned int) \
580 DECL_REL_OP_T(op,long) \
581 DECL_REL_OP_T(op,unsigned long) \
582 DECL_REL_OP_T(op,float) \
583 DECL_REL_OP_T(op,double) \
584 DECL_REL_OP_T(op,const char*) \
585 DECL_REL_OP_OTHER(op)
586
587 DECL_REL_OP(<)
588 DECL_REL_OP(<=)
589 DECL_REL_OP(>)
590 DECL_REL_OP(>=)
591 DECL_REL_OP(==)
592 DECL_REL_OP(!=)
593
594#undef DECL_REL_OP_T
595#undef DECL_REL_OP_OTHER
596#undef DECL_REL_OP
597
598
599 // assignment operators
600
601#define DECL_ASN_OP_T(op,tp) \
602 sc_fxval_fast& operator op( tp );
603
604#define DECL_ASN_OP_OTHER(op) \
605 DECL_ASN_OP_T(op,int64) \
606 DECL_ASN_OP_T(op,uint64) \
607 DECL_ASN_OP_T(op,const sc_int_base&) \
608 DECL_ASN_OP_T(op,const sc_uint_base&) \
609 DECL_ASN_OP_T(op,const sc_signed&) \
610 DECL_ASN_OP_T(op,const sc_unsigned&)
611
612#define DECL_ASN_OP(op) \
613 DECL_ASN_OP_T(op,int) \
614 DECL_ASN_OP_T(op,unsigned int) \
615 DECL_ASN_OP_T(op,long) \
616 DECL_ASN_OP_T(op,unsigned long) \
617 DECL_ASN_OP_T(op,float) \
618 DECL_ASN_OP_T(op,double) \
619 DECL_ASN_OP_T(op,const char*) \
620 DECL_ASN_OP_T(op,const sc_fxval&) \
621 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
622 DECL_ASN_OP_T(op,const sc_fxnum&) \
623 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
624 DECL_ASN_OP_OTHER(op)
625
626 DECL_ASN_OP(=)
627
628 DECL_ASN_OP(*=)
629 DECL_ASN_OP(/=)
630 DECL_ASN_OP(+=)
631 DECL_ASN_OP(-=)
632
633 DECL_ASN_OP_T(<<=,int)
634 DECL_ASN_OP_T(>>=,int)
635
636#undef DECL_ASN_OP_T
637#undef DECL_ASN_OP_OTHER
638#undef DECL_ASN_OP
639
640
641 // auto-increment and auto-decrement
642
643 sc_fxval_fast operator ++ ( int );
644 sc_fxval_fast operator -- ( int );
645
646 sc_fxval_fast& operator ++ ();
647 sc_fxval_fast& operator -- ();
648
649
650 // implicit conversion
651
652 operator double() const; // necessary evil!
653
654
655 // explicit conversion to primitive types
656
657 short to_short() const;
658 unsigned short to_ushort() const;
659 int to_int() const;
660 unsigned int to_uint() const;
661 long to_long() const;
662 unsigned long to_ulong() const;
663 int64 to_int64() const;
664 uint64 to_uint64() const;
665 float to_float() const;
666 double to_double() const;
667
668
669 // explicit conversion to character string
670
671 std::string to_string() const;
672 std::string to_string( sc_numrep ) const;
673 std::string to_string( sc_numrep, bool ) const;
674 std::string to_string( sc_fmt ) const;
675 std::string to_string( sc_numrep, sc_fmt ) const;
676 std::string to_string( sc_numrep, bool, sc_fmt ) const;
677
678 std::string to_dec() const;
679 std::string to_bin() const;
680 std::string to_oct() const;
681 std::string to_hex() const;
682
683
684 // query value
685
686 bool is_neg() const;
687 bool is_zero() const;
688 bool is_nan() const;
689 bool is_inf() const;
690 bool is_normal() const;
691
692 bool rounding_flag() const;
693
694
695 // print or dump content
696
697 void print( ::std::ostream& = ::std::cout ) const;
698 void scan( ::std::istream& = ::std::cin );
699 void dump( ::std::ostream& = ::std::cout ) const;
700
701
702 // internal use only;
703 bool get_bit( int ) const;
704
705protected:
706
709
710
711 static double from_string( const char* );
712
713private:
714
715 double m_val;
716
717 mutable sc_fxval_fast_observer* m_observer;
718
719};
720
721
722// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
723
724// ----------------------------------------------------------------------------
725// CLASS : sc_fxval
726//
727// Fixed-point value type; arbitrary precision.
728// ----------------------------------------------------------------------------
729
730// protected method
731
732inline
735{
736 return m_observer;
737}
738
739
740// internal use only;
741inline
743: m_rep( a != 0 ? a : new scfx_rep ),
744 m_observer( 0 )
745{}
746
747
748// public constructors
749
750inline
752: m_rep( new scfx_rep ),
753 m_observer( observer_ )
754{
757}
758
759inline
761 sc_fxval_observer* observer_ )
762: m_rep( new scfx_rep( *a.m_rep ) ),
763 m_observer( observer_ )
764{
769}
770
771#define DEFN_CTOR_T(tp,arg) \
772inline \
773sc_fxval::sc_fxval( tp a, \
774 sc_fxval_observer* observer_ ) \
775: m_rep( new scfx_rep( arg ) ), \
776 m_observer( observer_ ) \
777{ \
778 SC_FXVAL_OBSERVER_DEFAULT_ \
779 SC_FXVAL_OBSERVER_CONSTRUCT_( *this ) \
780 SC_FXVAL_OBSERVER_WRITE_( *this ) \
781}
782
783#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a)
784#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,a.to_double())
785#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.value())
786
787DEFN_CTOR_T_A(int)
788DEFN_CTOR_T_A(unsigned int)
789DEFN_CTOR_T_A(long)
790DEFN_CTOR_T_A(unsigned long)
791DEFN_CTOR_T_A(float)
792DEFN_CTOR_T_A(double)
793DEFN_CTOR_T_A(const char*)
801
802#undef DEFN_CTOR_T
803#undef DEFN_CTOR_T_A
804#undef DEFN_CTOR_T_B
805#undef DEFN_CTOR_T_C
806
807
808inline
810{
812 delete m_rep;
813}
814
815
816// internal use only;
817inline
818const scfx_rep*
820{
822 return m_rep;
823}
824
825// internal use only;
826inline
827void
829{
830 delete m_rep;
831 m_rep = rep_;
833}
834
835
836// unary operators
837
838inline
841{
843 return sc_fxval( sc_dt::neg_scfx_rep( *m_rep ) );
844}
845
846inline
847const sc_fxval&
849{
850 // SC_FXVAL_OBSERVER_READ_( *this )
851 return *this;
852}
853
854
855// unary functions
856
857inline
858void
859neg( sc_fxval& c, const sc_fxval& a )
860{
862 delete c.m_rep;
863 c.m_rep = sc_dt::neg_scfx_rep( *a.m_rep );
865}
866
867
868// binary operators
869
870#define DEFN_BIN_OP_T(op,fnc,tp) \
871inline \
872sc_fxval \
873operator op ( const sc_fxval& a, tp b ) \
874{ \
875 SC_FXVAL_OBSERVER_READ_( a ) \
876 sc_fxval tmp( b ); \
877 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) ); \
878} \
879 \
880inline \
881sc_fxval \
882operator op ( tp a, const sc_fxval& b ) \
883{ \
884 SC_FXVAL_OBSERVER_READ_( b ) \
885 sc_fxval tmp( a ); \
886 return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) ); \
887}
888
889#define DEFN_BIN_OP_OTHER(op,fnc) \
890DEFN_BIN_OP_T(op,fnc,int64) \
891DEFN_BIN_OP_T(op,fnc,uint64) \
892DEFN_BIN_OP_T(op,fnc,const sc_int_base&) \
893DEFN_BIN_OP_T(op,fnc,const sc_uint_base&) \
894DEFN_BIN_OP_T(op,fnc,const sc_signed&) \
895DEFN_BIN_OP_T(op,fnc,const sc_unsigned&)
896
897#define DEFN_BIN_OP(op,fnc) \
898inline \
899sc_fxval \
900operator op ( const sc_fxval& a, const sc_fxval& b ) \
901{ \
902 SC_FXVAL_OBSERVER_READ_( a ) \
903 SC_FXVAL_OBSERVER_READ_( b ) \
904 return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) ); \
905} \
906 \
907DEFN_BIN_OP_T(op,fnc,int) \
908DEFN_BIN_OP_T(op,fnc,unsigned int) \
909DEFN_BIN_OP_T(op,fnc,long) \
910DEFN_BIN_OP_T(op,fnc,unsigned long) \
911DEFN_BIN_OP_T(op,fnc,float) \
912DEFN_BIN_OP_T(op,fnc,double) \
913DEFN_BIN_OP_T(op,fnc,const char*) \
914DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&) \
915DEFN_BIN_OP_OTHER(op,fnc)
916
917DEFN_BIN_OP(*,mult)
918DEFN_BIN_OP(+,add)
919DEFN_BIN_OP(-,sub)
920// don't use macro
921//DEFN_BIN_OP(/,div)
922inline
924operator / ( const sc_fxval& a, const sc_fxval& b )
925{
928 return sc_fxval( sc_dt::div_scfx_rep( *a.m_rep, *b.m_rep ) );
929}
930
931DEFN_BIN_OP_T(/,div,int)
932DEFN_BIN_OP_T(/,div,unsigned int)
933DEFN_BIN_OP_T(/,div,long)
934DEFN_BIN_OP_T(/,div,unsigned long)
935DEFN_BIN_OP_T(/,div,float)
936DEFN_BIN_OP_T(/,div,double)
937DEFN_BIN_OP_T(/,div,const char*)
939//DEFN_BIN_OP_OTHER(/,div)
946
947#undef DEFN_BIN_OP_T
948#undef DEFN_BIN_OP_OTHER
949#undef DEFN_BIN_OP
950
951
952inline
954operator << ( const sc_fxval& a, int b )
955{
957 return sc_fxval( sc_dt::lsh_scfx_rep( *a.m_rep, b ) );
958}
959
960inline
961sc_fxval
962operator >> ( const sc_fxval& a, int b )
963{
965 return sc_fxval( sc_dt::rsh_scfx_rep( *a.m_rep, b ) );
966}
967
968
969// binary functions
970
971#define DEFN_BIN_FNC_T(fnc,tp) \
972inline \
973void \
974fnc ( sc_fxval& c, const sc_fxval& a, tp b ) \
975{ \
976 SC_FXVAL_OBSERVER_READ_( a ) \
977 sc_fxval tmp( b ); \
978 delete c.m_rep; \
979 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ); \
980 SC_FXVAL_OBSERVER_WRITE_( c ) \
981} \
982 \
983inline \
984void \
985fnc ( sc_fxval& c, tp a, const sc_fxval& b ) \
986{ \
987 SC_FXVAL_OBSERVER_READ_( b ) \
988 sc_fxval tmp( a ); \
989 delete c.m_rep; \
990 c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ); \
991 SC_FXVAL_OBSERVER_WRITE_( c ) \
992}
993
994#define DEFN_BIN_FNC_OTHER(fnc) \
995DEFN_BIN_FNC_T(fnc,int64) \
996DEFN_BIN_FNC_T(fnc,uint64) \
997DEFN_BIN_FNC_T(fnc,const sc_int_base&) \
998DEFN_BIN_FNC_T(fnc,const sc_uint_base&) \
999DEFN_BIN_FNC_T(fnc,const sc_signed&) \
1000DEFN_BIN_FNC_T(fnc,const sc_unsigned&)
1001
1002#define DEFN_BIN_FNC(fnc) \
1003inline \
1004void \
1005fnc( sc_fxval& c, const sc_fxval& a, const sc_fxval& b ) \
1006{ \
1007 SC_FXVAL_OBSERVER_READ_( a ) \
1008 SC_FXVAL_OBSERVER_READ_( b ) \
1009 delete c.m_rep; \
1010 c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ); \
1011 SC_FXVAL_OBSERVER_WRITE_( c ) \
1012} \
1013 \
1014DEFN_BIN_FNC_T(fnc,int) \
1015DEFN_BIN_FNC_T(fnc,unsigned int) \
1016DEFN_BIN_FNC_T(fnc,long) \
1017DEFN_BIN_FNC_T(fnc,unsigned long) \
1018DEFN_BIN_FNC_T(fnc,float) \
1019DEFN_BIN_FNC_T(fnc,double) \
1020DEFN_BIN_FNC_T(fnc,const char*) \
1021DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&) \
1022DEFN_BIN_FNC_OTHER(fnc)
1023
1024DEFN_BIN_FNC(mult)
1026DEFN_BIN_FNC(add)
1027DEFN_BIN_FNC(sub)
1028
1029#undef DEFN_BIN_FNC_T
1030#undef DEFN_BIN_FNC_OTHER
1031#undef DEFN_BIN_FNC
1032
1033
1034inline
1035void
1036lshift( sc_fxval& c, const sc_fxval& a, int b )
1037{
1039 delete c.m_rep;
1040 c.m_rep = sc_dt::lsh_scfx_rep( *a.m_rep, b );
1042}
1043
1044inline
1045void
1046rshift( sc_fxval& c, const sc_fxval& a, int b )
1047{
1049 delete c.m_rep;
1050 c.m_rep = sc_dt::rsh_scfx_rep( *a.m_rep, b );
1052}
1053
1054
1055// relational (including equality) operators
1056
1057#define DEFN_REL_OP_T(op,ret,tp) \
1058inline \
1059bool \
1060operator op ( const sc_fxval& a, tp b ) \
1061{ \
1062 SC_FXVAL_OBSERVER_READ_( a ) \
1063 sc_fxval tmp( b ); \
1064 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep ); \
1065 return ( ret ); \
1066} \
1067 \
1068inline \
1069bool \
1070operator op ( tp a, const sc_fxval& b ) \
1071{ \
1072 SC_FXVAL_OBSERVER_READ_( b ) \
1073 sc_fxval tmp( a ); \
1074 int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep ); \
1075 return ( ret ); \
1076}
1077
1078#define DEFN_REL_OP_OTHER(op,ret) \
1079DEFN_REL_OP_T(op,ret,int64) \
1080DEFN_REL_OP_T(op,ret,uint64) \
1081DEFN_REL_OP_T(op,ret,const sc_int_base&) \
1082DEFN_REL_OP_T(op,ret,const sc_uint_base&) \
1083DEFN_REL_OP_T(op,ret,const sc_signed&) \
1084DEFN_REL_OP_T(op,ret,const sc_unsigned&)
1085
1086#define DEFN_REL_OP(op,ret) \
1087inline \
1088bool \
1089operator op ( const sc_fxval& a, const sc_fxval& b) \
1090{ \
1091 SC_FXVAL_OBSERVER_READ_( a ) \
1092 SC_FXVAL_OBSERVER_READ_( b ) \
1093 int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep ); \
1094 return ( ret ); \
1095} \
1096 \
1097DEFN_REL_OP_T(op,ret,int) \
1098DEFN_REL_OP_T(op,ret,unsigned int) \
1099DEFN_REL_OP_T(op,ret,long) \
1100DEFN_REL_OP_T(op,ret,unsigned long) \
1101DEFN_REL_OP_T(op,ret,float) \
1102DEFN_REL_OP_T(op,ret,double) \
1103DEFN_REL_OP_T(op,ret,const char*) \
1104DEFN_REL_OP_T(op,ret,const sc_fxval_fast&) \
1105DEFN_REL_OP_OTHER(op,ret)
1106
1107DEFN_REL_OP(<,result < 0)
1108DEFN_REL_OP(<=,result <= 0)
1109DEFN_REL_OP(>,result > 0 && result != 2)
1110DEFN_REL_OP(>=,result >= 0 && result != 2)
1111DEFN_REL_OP(==,result == 0)
1112DEFN_REL_OP(!=,result != 0)
1113
1114#undef DEFN_REL_OP_T
1115#undef DEFN_REL_OP_OTHER
1116#undef DEFN_REL_OP
1117
1118
1119// assignment operators
1120
1121inline
1122sc_fxval&
1123sc_fxval::operator = ( const sc_fxval& a )
1124{
1125 if( &a != this )
1126 {
1128 *m_rep = *a.m_rep;
1130 }
1131 return *this;
1132}
1133
1134#define DEFN_ASN_OP_T(tp) \
1135inline \
1136sc_fxval& \
1137sc_fxval::operator = ( tp b ) \
1138{ \
1139 sc_fxval tmp( b ); \
1140 *m_rep = *tmp.m_rep; \
1141 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1142 return *this; \
1143}
1144
1145DEFN_ASN_OP_T(int)
1146DEFN_ASN_OP_T(unsigned int)
1147DEFN_ASN_OP_T(long)
1148DEFN_ASN_OP_T(unsigned long)
1149DEFN_ASN_OP_T(float)
1150DEFN_ASN_OP_T(double)
1151DEFN_ASN_OP_T(const char*)
1152DEFN_ASN_OP_T(const sc_fxval_fast&)
1155DEFN_ASN_OP_T(const sc_int_base&)
1156DEFN_ASN_OP_T(const sc_uint_base&)
1157DEFN_ASN_OP_T(const sc_signed&)
1158DEFN_ASN_OP_T(const sc_unsigned&)
1159
1160#undef DEFN_ASN_OP_T
1161
1162
1163#define DEFN_ASN_OP_T(op,fnc,tp) \
1164inline \
1165sc_fxval& \
1166sc_fxval::operator op ( tp b ) \
1167{ \
1168 SC_FXVAL_OBSERVER_READ_( *this ) \
1169 sc_fxval tmp( b ); \
1170 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep ); \
1171 delete m_rep; \
1172 m_rep = new_rep; \
1173 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1174 return *this; \
1175}
1176
1177#define DEFN_ASN_OP_OTHER(op,fnc) \
1178DEFN_ASN_OP_T(op,fnc,int64) \
1179DEFN_ASN_OP_T(op,fnc,uint64) \
1180DEFN_ASN_OP_T(op,fnc,const sc_int_base&) \
1181DEFN_ASN_OP_T(op,fnc,const sc_uint_base&) \
1182DEFN_ASN_OP_T(op,fnc,const sc_signed&) \
1183DEFN_ASN_OP_T(op,fnc,const sc_unsigned&)
1184
1185#define DEFN_ASN_OP(op,fnc) \
1186inline \
1187sc_fxval& \
1188sc_fxval::operator op ( const sc_fxval& b ) \
1189{ \
1190 SC_FXVAL_OBSERVER_READ_( *this ) \
1191 SC_FXVAL_OBSERVER_READ_( b ) \
1192 scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep ); \
1193 delete m_rep; \
1194 m_rep = new_rep; \
1195 SC_FXVAL_OBSERVER_WRITE_( *this ) \
1196 return *this; \
1197} \
1198 \
1199DEFN_ASN_OP_T(op,fnc,int) \
1200DEFN_ASN_OP_T(op,fnc,unsigned int) \
1201DEFN_ASN_OP_T(op,fnc,long) \
1202DEFN_ASN_OP_T(op,fnc,unsigned long) \
1203DEFN_ASN_OP_T(op,fnc,float) \
1204DEFN_ASN_OP_T(op,fnc,double) \
1205DEFN_ASN_OP_T(op,fnc,const char*) \
1206DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&) \
1207DEFN_ASN_OP_OTHER(op,fnc)
1208
1209DEFN_ASN_OP(*=,mult)
1210DEFN_ASN_OP(/=,div)
1211DEFN_ASN_OP(+=,add)
1212DEFN_ASN_OP(-=,sub)
1213
1214#undef DEFN_ASN_OP_T
1215#undef DEFN_ASN_OP_OTHER
1216#undef DEFN_ASN_OP
1217
1218
1219inline
1220sc_fxval&
1221sc_fxval::operator <<= ( int b )
1222{
1224 m_rep->lshift( b );
1226 return *this;
1227}
1228
1229inline
1230sc_fxval&
1231sc_fxval::operator >>= ( int b )
1232{
1234 m_rep->rshift( b );
1236 return *this;
1237}
1238
1239
1240// auto-increment and auto-decrement
1241
1242inline
1244sc_fxval::operator ++ ( int )
1245{
1246 sc_fxval c = *this;
1247 (*this) += 1;
1248 return c;
1249}
1250
1251inline
1254{
1255 sc_fxval c = *this;
1256 (*this) -= 1;
1257 return c;
1258}
1259
1260inline
1261sc_fxval&
1263{
1264 (*this) += 1;
1265 return *this;
1266}
1267
1268inline
1269sc_fxval&
1271{
1272 (*this) -= 1;
1273 return *this;
1274}
1275
1276
1277// implicit conversion
1278
1279inline
1280sc_fxval::operator double() const
1281{
1283 return m_rep->to_double();
1284}
1285
1286
1287// explicit conversion to primitive types
1288
1289inline
1290short
1292{
1294 return static_cast<short>( m_rep->to_uint64() );
1295}
1296
1297inline
1298unsigned short
1300{
1302 return static_cast<unsigned short>( m_rep->to_uint64() );
1303}
1304
1305inline
1306int
1308{
1310 return static_cast<int>( m_rep->to_uint64() );
1311}
1312
1313inline
1314int64
1316{
1318 return static_cast<int64>( m_rep->to_uint64() );
1319}
1320
1321inline
1322unsigned int
1324{
1326 return static_cast<unsigned int>( m_rep->to_uint64() );
1327}
1328
1329inline
1330uint64
1332{
1334 return m_rep->to_uint64();
1335}
1336
1337inline
1338long
1340{
1342 return static_cast<long>( m_rep->to_uint64() );
1343}
1344
1345inline
1346unsigned long
1348{
1350 return static_cast<unsigned long>( m_rep->to_uint64() );
1351}
1352
1353inline
1354float
1356{
1358 return static_cast<float>( m_rep->to_double() );
1359}
1360
1361inline
1362double
1364{
1366 return m_rep->to_double();
1367}
1368
1369
1370// query value
1371
1372inline
1373bool
1375{
1377 return m_rep->is_neg();
1378}
1379
1380inline
1381bool
1383{
1385 return m_rep->is_zero();
1386}
1387
1388inline
1389bool
1391{
1393 return m_rep->is_nan();
1394}
1395
1396inline
1397bool
1399{
1401 return m_rep->is_inf();
1402}
1403
1404inline
1405bool
1407{
1409 return m_rep->is_normal();
1410}
1411
1412
1413inline
1414bool
1416{
1417 return m_rep->rounding_flag();
1418}
1419
1420
1421// internal use only;
1422inline
1423bool
1424sc_fxval::get_bit( int i ) const
1425{
1426 return m_rep->get_bit( i );
1427}
1428
1429
1430// protected methods and friend functions
1431
1432inline
1433void
1434sc_fxval::get_type( int& wl, int& iwl, sc_enc& enc ) const
1435{
1436 m_rep->get_type( wl, iwl, enc );
1437}
1438
1439
1440inline
1442sc_fxval::quantization( const scfx_params& params, bool& q_flag ) const
1443{
1444 return sc_fxval( sc_dt::quantization_scfx_rep( *m_rep, params, q_flag ) );
1445}
1446
1447inline
1449sc_fxval::overflow( const scfx_params& params, bool& o_flag ) const
1450{
1451 return sc_fxval( sc_dt::overflow_scfx_rep( *m_rep, params, o_flag ) );
1452}
1453
1454
1455inline
1456::std::ostream&
1457operator << ( ::std::ostream& os, const sc_fxval& a )
1458{
1459 a.print( os );
1460 return os;
1461}
1462
1463inline
1464::std::istream&
1465operator >> ( ::std::istream& is, sc_fxval& a )
1466{
1467 a.scan( is );
1468 return is;
1469}
1470
1471
1472// ----------------------------------------------------------------------------
1473// CLASS : sc_fxval_fast
1474//
1475// Fixed-point value type; limited precision.
1476// ----------------------------------------------------------------------------
1477
1478// protected method
1479
1480inline
1481sc_fxval_fast_observer*
1483{
1484 return m_observer;
1485}
1486
1487
1488// public constructors
1489
1490inline
1492: m_val( 0.0 ),
1493 m_observer( observer_ )
1494{
1497}
1498
1499inline
1501 sc_fxval_fast_observer* observer_ )
1502: m_val( a.m_val ),
1503 m_observer( observer_ )
1504{
1509}
1510
1511#define DEFN_CTOR_T(tp,arg) \
1512inline \
1513sc_fxval_fast::sc_fxval_fast( tp a, \
1514 sc_fxval_fast_observer* observer_ ) \
1515: m_val( arg ), \
1516 m_observer( observer_ ) \
1517{ \
1518 SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
1519 SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this ) \
1520 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1521}
1522
1523#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a ))
1524#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,from_string( a ))
1525#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
1526
1527DEFN_CTOR_T_A(int)
1528DEFN_CTOR_T_A(unsigned int)
1529DEFN_CTOR_T_A(long)
1530DEFN_CTOR_T_A(unsigned long)
1531DEFN_CTOR_T_A(float)
1532DEFN_CTOR_T_A(double)
1533DEFN_CTOR_T_B(const char*)
1534DEFN_CTOR_T_C(const sc_fxval&)
1537DEFN_CTOR_T_C(const sc_int_base&)
1538DEFN_CTOR_T_C(const sc_uint_base&)
1539DEFN_CTOR_T_C(const sc_signed&)
1540DEFN_CTOR_T_C(const sc_unsigned&)
1541
1542#undef DEFN_CTOR_T
1543#undef DEFN_CTOR_T_A
1544#undef DEFN_CTOR_T_B
1545#undef DEFN_CTOR_T_C
1546#undef DEFN_CTOR_T_D
1547#undef DEFN_CTOR_T_E
1548
1549
1550inline
1552{
1554}
1555
1556
1557// internal use only;
1558inline
1559double
1561{
1563 return m_val;
1564}
1565
1566// internal use only;
1567inline
1568void
1570{
1571 m_val = val_;
1573}
1574
1575
1576// unary operators
1577
1578inline
1581{
1583 return sc_fxval_fast( - m_val );
1584}
1585
1586inline
1587const sc_fxval_fast&
1589{
1590 // SC_FXVAL_FAST_OBSERVER_READ_( *this )
1591 return *this;
1592}
1593
1594
1595// unary functions
1596
1597inline
1598void
1600{
1602 c.m_val = - a.m_val;
1604}
1605
1606
1607// binary operators
1608
1609#define DEFN_BIN_OP_T(op,tp) \
1610inline \
1611sc_fxval_fast \
1612operator op ( const sc_fxval_fast& a, tp b ) \
1613{ \
1614 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1615 sc_fxval_fast tmp( b ); \
1616 return sc_fxval_fast( a.m_val op tmp.m_val ); \
1617} \
1618 \
1619inline \
1620sc_fxval_fast \
1621operator op ( tp a, const sc_fxval_fast& b ) \
1622{ \
1623 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1624 sc_fxval_fast tmp( a ); \
1625 return sc_fxval_fast( tmp.m_val op b.m_val ); \
1626}
1627
1628#define DEFN_BIN_OP_OTHER(op) \
1629DEFN_BIN_OP_T(op,int64) \
1630DEFN_BIN_OP_T(op,uint64) \
1631DEFN_BIN_OP_T(op,const sc_int_base&) \
1632DEFN_BIN_OP_T(op,const sc_uint_base&) \
1633DEFN_BIN_OP_T(op,const sc_signed&) \
1634DEFN_BIN_OP_T(op,const sc_unsigned&)
1635
1636#define DEFN_BIN_OP(op,dummy) \
1637inline \
1638sc_fxval_fast \
1639operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1640{ \
1641 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1642 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1643 return sc_fxval_fast( a.m_val op b.m_val ); \
1644} \
1645 \
1646DEFN_BIN_OP_T(op,int) \
1647DEFN_BIN_OP_T(op,unsigned int) \
1648DEFN_BIN_OP_T(op,long) \
1649DEFN_BIN_OP_T(op,unsigned long) \
1650DEFN_BIN_OP_T(op,float) \
1651DEFN_BIN_OP_T(op,double) \
1652DEFN_BIN_OP_T(op,const char*) \
1653DEFN_BIN_OP_OTHER(op)
1654
1655DEFN_BIN_OP(*,mult)
1656DEFN_BIN_OP(+,add)
1657DEFN_BIN_OP(-,sub)
1658//DEFN_BIN_OP(/,div)
1659inline
1660sc_fxval_fast
1662{
1665 return sc_fxval_fast( a.m_val / b.m_val );
1666}
1667
1668DEFN_BIN_OP_T(/,int)
1669DEFN_BIN_OP_T(/,unsigned int)
1670DEFN_BIN_OP_T(/,long)
1671DEFN_BIN_OP_T(/,unsigned long)
1672DEFN_BIN_OP_T(/,float)
1673DEFN_BIN_OP_T(/,double)
1674DEFN_BIN_OP_T(/,const char*)
1675//DEFN_BIN_OP_OTHER(/)
1678DEFN_BIN_OP_T(/,const sc_int_base&)
1680DEFN_BIN_OP_T(/,const sc_signed&)
1681DEFN_BIN_OP_T(/,const sc_unsigned&)
1682
1683
1684#undef DEFN_BIN_OP_T
1685#undef DEFN_BIN_OP_OTHER
1686#undef DEFN_BIN_OP
1687
1688
1689inline
1691operator << ( const sc_fxval_fast& a, int b )
1692{
1694 return sc_fxval_fast( a.m_val * scfx_pow2( b ) );
1695}
1696
1697inline
1698sc_fxval_fast
1700{
1702 return sc_fxval_fast( a.m_val * scfx_pow2( -b ) );
1703}
1704
1705
1706// binary functions
1707
1708#define DEFN_BIN_FNC_T(fnc,op,tp) \
1709inline \
1710void \
1711fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b ) \
1712{ \
1713 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1714 sc_fxval_fast tmp( b ); \
1715 c.m_val = a.m_val op tmp.m_val; \
1716 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1717} \
1718 \
1719inline \
1720void \
1721fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b ) \
1722{ \
1723 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1724 sc_fxval_fast tmp( a ); \
1725 c.m_val = tmp.m_val op b.m_val; \
1726 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1727}
1728
1729#define DEFN_BIN_FNC_OTHER(fnc,op) \
1730DEFN_BIN_FNC_T(fnc,op,int64) \
1731DEFN_BIN_FNC_T(fnc,op,uint64) \
1732DEFN_BIN_FNC_T(fnc,op,const sc_int_base&) \
1733DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&) \
1734DEFN_BIN_FNC_T(fnc,op,const sc_signed&) \
1735DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&)
1736
1737#define DEFN_BIN_FNC(fnc,op) \
1738inline \
1739void \
1740fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1741{ \
1742 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1743 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1744 c.m_val = a.m_val op b.m_val; \
1745 SC_FXVAL_FAST_OBSERVER_WRITE_( c ) \
1746} \
1747 \
1748DEFN_BIN_FNC_T(fnc,op,int) \
1749DEFN_BIN_FNC_T(fnc,op,unsigned int) \
1750DEFN_BIN_FNC_T(fnc,op,long) \
1751DEFN_BIN_FNC_T(fnc,op,unsigned long) \
1752DEFN_BIN_FNC_T(fnc,op,float) \
1753DEFN_BIN_FNC_T(fnc,op,double) \
1754DEFN_BIN_FNC_T(fnc,op,const char*) \
1755DEFN_BIN_FNC_OTHER(fnc,op)
1756
1757DEFN_BIN_FNC(mult,*)
1759DEFN_BIN_FNC(add,+)
1760DEFN_BIN_FNC(sub,-)
1761
1762#undef DEFN_BIN_FNC_T
1763#undef DEFN_BIN_FNC_OTHER
1764#undef DEFN_BIN_FNC
1765
1766
1767inline
1768void
1770{
1772 c.m_val = a.m_val * scfx_pow2( b );
1774}
1775
1776inline
1777void
1779{
1781 c.m_val = a.m_val * scfx_pow2( -b );
1783}
1784
1785
1786// relational (including equality) operators
1787
1788#define DEFN_REL_OP_T(op,tp) \
1789inline \
1790bool \
1791operator op ( const sc_fxval_fast& a, tp b ) \
1792{ \
1793 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1794 sc_fxval_fast tmp( b ); \
1795 return ( a.m_val op tmp.m_val ); \
1796} \
1797 \
1798inline \
1799bool \
1800operator op ( tp a, const sc_fxval_fast& b ) \
1801{ \
1802 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1803 sc_fxval_fast tmp( a ); \
1804 return ( tmp.m_val op b.m_val ); \
1805}
1806
1807#define DEFN_REL_OP_OTHER(op) \
1808DEFN_REL_OP_T(op,int64) \
1809DEFN_REL_OP_T(op,uint64) \
1810DEFN_REL_OP_T(op,const sc_int_base&) \
1811DEFN_REL_OP_T(op,const sc_uint_base&) \
1812DEFN_REL_OP_T(op,const sc_signed&) \
1813DEFN_REL_OP_T(op,const sc_unsigned&)
1814
1815#define DEFN_REL_OP(op) \
1816inline \
1817bool \
1818operator op ( const sc_fxval_fast& a, const sc_fxval_fast& b ) \
1819{ \
1820 SC_FXVAL_FAST_OBSERVER_READ_( a ) \
1821 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1822 return ( a.m_val op b.m_val ); \
1823} \
1824 \
1825DEFN_REL_OP_T(op,int) \
1826DEFN_REL_OP_T(op,unsigned int) \
1827DEFN_REL_OP_T(op,long) \
1828DEFN_REL_OP_T(op,unsigned long) \
1829DEFN_REL_OP_T(op,float) \
1830DEFN_REL_OP_T(op,double) \
1831DEFN_REL_OP_T(op,const char*) \
1832DEFN_REL_OP_OTHER(op)
1833
1834DEFN_REL_OP(<)
1835DEFN_REL_OP(<=)
1836DEFN_REL_OP(>)
1837DEFN_REL_OP(>=)
1838DEFN_REL_OP(==)
1839DEFN_REL_OP(!=)
1840
1841#undef DEFN_REL_OP_T
1842#undef DEFN_REL_OP_OTHER
1843#undef DEFN_REL_OP
1844
1845
1846// assignment operators
1847
1848inline
1849sc_fxval_fast&
1850sc_fxval_fast::operator = ( const sc_fxval_fast& a )
1851{
1852 if( &a != this )
1853 {
1855 m_val = a.m_val;
1857 }
1858 return *this;
1859}
1860
1861#define DEFN_ASN_OP_T(tp) \
1862inline \
1863sc_fxval_fast& \
1864sc_fxval_fast::operator = ( tp a ) \
1865{ \
1866 sc_fxval_fast tmp( a ); \
1867 m_val = tmp.m_val; \
1868 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1869 return *this; \
1870}
1871
1872DEFN_ASN_OP_T(int)
1873DEFN_ASN_OP_T(unsigned int)
1874DEFN_ASN_OP_T(long)
1875DEFN_ASN_OP_T(unsigned long)
1876DEFN_ASN_OP_T(float)
1877DEFN_ASN_OP_T(double)
1878DEFN_ASN_OP_T(const char*)
1879DEFN_ASN_OP_T(const sc_fxval&)
1882DEFN_ASN_OP_T(const sc_int_base&)
1883DEFN_ASN_OP_T(const sc_uint_base&)
1884DEFN_ASN_OP_T(const sc_signed&)
1885DEFN_ASN_OP_T(const sc_unsigned&)
1886
1887#undef DEFN_ASN_OP_T
1888
1889
1890#define DEFN_ASN_OP_T(op,tp) \
1891inline \
1892sc_fxval_fast& \
1893sc_fxval_fast::operator op ( tp b ) \
1894{ \
1895 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
1896 sc_fxval_fast tmp( b ); \
1897 m_val op tmp.m_val; \
1898 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1899 return *this; \
1900}
1901
1902#define DEFN_ASN_OP_OTHER(op) \
1903DEFN_ASN_OP_T(op,int64) \
1904DEFN_ASN_OP_T(op,uint64) \
1905DEFN_ASN_OP_T(op,const sc_int_base&) \
1906DEFN_ASN_OP_T(op,const sc_uint_base&) \
1907DEFN_ASN_OP_T(op,const sc_signed&) \
1908DEFN_ASN_OP_T(op,const sc_unsigned&)
1909
1910#define DEFN_ASN_OP(op) \
1911inline \
1912sc_fxval_fast& \
1913sc_fxval_fast::operator op ( const sc_fxval_fast& b ) \
1914{ \
1915 SC_FXVAL_FAST_OBSERVER_READ_( *this ) \
1916 SC_FXVAL_FAST_OBSERVER_READ_( b ) \
1917 m_val op b.m_val; \
1918 SC_FXVAL_FAST_OBSERVER_WRITE_( *this ) \
1919 return *this; \
1920} \
1921 \
1922DEFN_ASN_OP_T(op,int) \
1923DEFN_ASN_OP_T(op,unsigned int) \
1924DEFN_ASN_OP_T(op,long) \
1925DEFN_ASN_OP_T(op,unsigned long) \
1926DEFN_ASN_OP_T(op,float) \
1927DEFN_ASN_OP_T(op,double) \
1928DEFN_ASN_OP_T(op,const char*) \
1929DEFN_ASN_OP_T(op,const sc_fxval&) \
1930DEFN_ASN_OP_OTHER(op)
1931
1932DEFN_ASN_OP(*=)
1933DEFN_ASN_OP(/=)
1934DEFN_ASN_OP(+=)
1935DEFN_ASN_OP(-=)
1936
1937#undef DEFN_ASN_OP_T
1938#undef DEFN_ASN_OP_OTHER
1939#undef DEFN_ASN_OP
1940
1941
1942inline
1943sc_fxval_fast&
1944sc_fxval_fast::operator <<= ( int b )
1945{
1947 m_val *= scfx_pow2( b );
1949 return *this;
1950}
1951
1952inline
1953sc_fxval_fast&
1954sc_fxval_fast::operator >>= ( int b )
1955{
1957 m_val *= scfx_pow2( -b );
1959 return *this;
1960}
1961
1962
1963// auto-increment and auto-decrement
1964
1965inline
1967sc_fxval_fast::operator ++ ( int )
1968{
1971 double c = m_val;
1972 m_val = m_val + 1;
1974 return sc_fxval_fast( c );
1975}
1976
1977inline
1980{
1983 double c = m_val;
1984 m_val = m_val - 1;
1986 return sc_fxval_fast( c );
1987}
1988
1989inline
1992{
1994 m_val = m_val + 1;
1996 return *this;
1997}
1998
1999inline
2002{
2004 m_val = m_val - 1;
2006 return *this;
2007}
2008
2009
2010// implicit conversion
2011
2012inline
2013sc_fxval_fast::operator double() const
2014{
2016 return m_val;
2017}
2018
2019
2020// explicit conversion to primitive types
2021
2022inline
2023short
2025{
2026 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2027 return static_cast<short>( to_uint64() );
2028}
2029
2030inline
2031unsigned short
2033{
2034 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2035 return static_cast<unsigned short>( to_uint64() );
2036}
2037
2038inline
2039int64
2041{
2042 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2043 return static_cast<int64>( to_uint64() );
2044}
2045
2046inline
2047int
2049{
2050 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2051 return static_cast<int>( to_uint64() );
2052}
2053
2054inline
2055unsigned int
2057{
2058 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2059 return static_cast<unsigned int>( to_uint64() );
2060}
2061
2062inline
2063uint64
2065{
2066 // SC_FXVAL_FAST_OBSERVER_READ_ in is_normal
2067 if (!is_normal())
2068 {
2069 return 0;
2070 }
2071
2072 int exponent;
2073 double mantissa_dbl = frexp(m_val, &exponent);
2074
2075 uint64 mantissa = static_cast<uint64>(fabs(mantissa_dbl) * (UINT64_ONE << 53));
2076 exponent -= 53;
2077
2078 if (!(-64 < exponent && exponent < 64))
2079 {
2080 return 0;
2081 }
2082
2083 mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
2084 return mantissa_dbl >= 0 ? mantissa : -mantissa;
2085}
2086
2087inline
2088long
2090{
2091 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2092 return static_cast<long>( to_uint64() );
2093}
2094
2095inline
2096unsigned long
2098{
2099 // SC_FXVAL_FAST_OBSERVER_READ_ in to_uint64
2100 return static_cast<unsigned long>( to_uint64() );
2101}
2102
2103inline
2104float
2106{
2108 return static_cast<float>( m_val );
2109}
2110
2111inline
2112double
2114{
2116 return m_val;
2117}
2118
2119
2120// query value
2121
2122inline
2123bool
2125{
2127 scfx_ieee_double id( m_val );
2128 return ( id.negative() != 0 );
2129}
2130
2131inline
2132bool
2134{
2136 scfx_ieee_double id( m_val );
2137 return id.is_zero();
2138}
2139
2140inline
2141bool
2143{
2145 scfx_ieee_double id( m_val );
2146 return id.is_nan();
2147}
2148
2149inline
2150bool
2152{
2154 scfx_ieee_double id( m_val );
2155 return id.is_inf();
2156}
2157
2158inline
2159bool
2161{
2163 scfx_ieee_double id( m_val );
2164 return ( id.is_normal() || id.is_subnormal() || id.is_zero() );
2165}
2166
2167
2168inline
2169bool
2171{
2172 // does not apply to sc_fxval_fast; included for API compatibility
2173 return false;
2174}
2175
2176
2177inline
2178::std::ostream&
2179operator << ( ::std::ostream& os, const sc_fxval_fast& a )
2180{
2181 a.print( os );
2182 return os;
2183}
2184
2185inline
2186::std::istream&
2187operator >> ( ::std::istream& is, sc_fxval_fast& a )
2188{
2189 a.scan( is );
2190 return is;
2191}
2192
2193} // namespace sc_dt
2194
2195#undef SCFX_EXPLICIT_
2196#undef SCFX_EXPLICIT_OTHER_
2197
2198#endif
2199
2200// Taf!
#define DECL_BIN_FNC(fnc)
Definition: sc_fxval.h:535
#define DECL_BIN_OP_T(op, tp)
Definition: sc_fxval.h:467
#define DEFN_REL_OP(op, ret)
Definition: sc_fxval.h:1815
#define DEFN_BIN_FNC(fnc)
Definition: sc_fxval.h:1737
#define DEFN_BIN_OP(op, fnc)
Definition: sc_fxval.h:1636
#define DEFN_CTOR_T_B(tp)
Definition: sc_fxval.h:1524
#define SCFX_EXPLICIT_
Definition: sc_fxval.h:67
#define DEFN_CTOR_T_C(tp)
Definition: sc_fxval.h:1525
#define DEFN_CTOR_T_A(tp)
Definition: sc_fxval.h:1523
#define DEFN_ASN_OP(op, fnc)
Definition: sc_fxval.h:1910
#define SCFX_EXPLICIT_OTHER_
Definition: sc_fxval.h:72
#define DEFN_ASN_OP_T(tp)
Definition: sc_fxval.h:1890
#define DECL_ASN_OP_T(op, tp)
Definition: sc_fxval.h:601
#define DECL_REL_OP(op)
Definition: sc_fxval.h:576
#define DECL_BIN_OP(op, dummy)
Definition: sc_fxval.h:479
#define DECL_ASN_OP(op)
Definition: sc_fxval.h:612
#define SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
#define SC_FXVAL_OBSERVER_READ_(object)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
#define SC_API
Definition: sc_cmnhdr.h:148
sc_enc
Definition: sc_fxdefs.h:67
bool is_inf(double v)
Definition: sc_nbutils.h:229
bool is_nan(double v)
Definition: sc_nbutils.h:222
void neg(sc_fxval &c, const sc_fxnum &a)
Definition: sc_fxnum.h:2758
SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
Definition: scfx_rep.h:378
const sc_big_op_info< WL, true, WR, true >::add_result operator+(const sc_bigint< WL > &left, const sc_bigint< WR > &right)
Definition: sc_big_ops.h:125
sc_numrep
Definition: sc_string.h:56
sc_fxval operator/(const sc_fxnum &a, const sc_fxnum &b)
Definition: sc_fxnum.h:2849
unsigned long long uint64
Definition: sc_nbdefs.h:216
const sc_big_op_info< WL, true, WR, true >::sub_result operator-(const sc_bigint< WL > &left, const sc_bigint< WR > &right)
Definition: sc_big_ops.h:884
SC_API scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
Definition: sc_fxnum.h:3055
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
Definition: sc_fxnum.h:3047
SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:396
double scfx_pow2(int exp)
Definition: scfx_ieee.h:645
DEFN_BIN_OP_T(/, div, int64) DEFN_BIN_OP_T(/
inline::std::istream & operator>>(::std::istream &is, sc_bit &a)
Definition: sc_bit.h:396
SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:405
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:388
uint64 const sc_uint_base int b
Definition: sc_fxval.h:955
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &q_flag)
Definition: scfx_rep.h:465
constexpr uint64 UINT64_ONE
Definition: sc_nbdefs.h:219
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &o_flag)
Definition: scfx_rep.h:476
long long int64
Definition: sc_nbdefs.h:215
std::string to_dec() const
bool get_bit(int) const
Definition: sc_fxval.h:1424
std::string to_bin() const
std::string to_hex() const
const scfx_rep * get_rep() const
Definition: sc_fxval.h:819
SCFX_EXPLICIT_ sc_fxval(float, sc_fxval_observer *=0)
std::string to_string(sc_numrep, bool) const
std::string to_oct() const
bool is_neg() const
Definition: sc_fxval.h:1374
sc_fxval quantization(const scfx_params &, bool &) const
Definition: sc_fxval.h:1442
sc_fxval(scfx_rep *)
Definition: sc_fxval.h:742
int to_int() const
Definition: sc_fxval.h:1307
int64 to_int64() const
Definition: sc_fxval.h:1315
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_int_base &, sc_fxval_observer *=0)
long to_long() const
Definition: sc_fxval.h:1339
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_signed &, sc_fxval_observer *=0)
sc_fxval & operator--()
Definition: sc_fxval.h:1270
void set_rep(scfx_rep *)
Definition: sc_fxval.h:828
sc_fxval & operator++()
Definition: sc_fxval.h:1262
bool is_zero() const
Definition: sc_fxval.h:1382
std::string to_string(sc_numrep, sc_fmt) const
const sc_fxval & operator+() const
Definition: sc_fxval.h:848
unsigned int to_uint() const
Definition: sc_fxval.h:1323
void scan(::std::istream &=::std::cin)
short to_short() const
Definition: sc_fxval.h:1291
double to_double() const
Definition: sc_fxval.h:1363
sc_fxval overflow(const scfx_params &, bool &) const
Definition: sc_fxval.h:1449
void unlock_observer(sc_fxval_observer *) const
SCFX_EXPLICIT_OTHER_ sc_fxval(int64, sc_fxval_observer *=0)
float to_float() const
Definition: sc_fxval.h:1355
SCFX_EXPLICIT_ sc_fxval(double, sc_fxval_observer *=0)
sc_fxval operator-() const
Definition: sc_fxval.h:840
unsigned long to_ulong() const
Definition: sc_fxval.h:1347
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_uint_base &, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(unsigned long, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(long, sc_fxval_observer *=0)
std::string to_string() const
bool is_inf() const
Definition: sc_fxval.h:1398
friend void lshift(sc_fxval &, const sc_fxval &, int)
Definition: sc_fxval.h:1036
sc_fxval_observer * lock_observer() const
std::string to_string(sc_fmt) const
SCFX_EXPLICIT_OTHER_ sc_fxval(const sc_unsigned &, sc_fxval_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval(uint64, sc_fxval_observer *=0)
friend sc_fxval operator>>(const sc_fxval &, int)
Definition: sc_fxval.h:962
sc_fxval_observer * observer() const
Definition: sc_fxval.h:734
void print(::std::ostream &=::std::cout) const
bool rounding_flag() const
Definition: sc_fxval.h:1415
bool is_normal() const
Definition: sc_fxval.h:1406
unsigned short to_ushort() const
Definition: sc_fxval.h:1299
bool is_nan() const
Definition: sc_fxval.h:1390
uint64 to_uint64() const
Definition: sc_fxval.h:1331
std::string to_string(sc_numrep, bool, sc_fmt) const
SCFX_EXPLICIT_ sc_fxval(unsigned int, sc_fxval_observer *=0)
SCFX_EXPLICIT_ sc_fxval(const char *, sc_fxval_observer *=0)
void dump(::std::ostream &=::std::cout) const
std::string to_string(sc_numrep) const
void get_type(int &, int &, sc_enc &) const
Definition: sc_fxval.h:1434
friend void rshift(sc_fxval &, const sc_fxval &, int)
Definition: sc_fxval.h:1046
SCFX_EXPLICIT_ sc_fxval(int, sc_fxval_observer *=0)
sc_fxval(const sc_fxval_fast &, sc_fxval_observer *=0)
void print(::std::ostream &=::std::cout) const
std::string to_string(sc_numrep) const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_uint_base &, sc_fxval_fast_observer *=0)
std::string to_string(sc_numrep, sc_fmt) const
SCFX_EXPLICIT_ sc_fxval_fast(long, sc_fxval_fast_observer *=0)
int64 to_int64() const
Definition: sc_fxval.h:2040
sc_fxval_fast_observer * lock_observer() const
std::string to_string(sc_numrep, bool, sc_fmt) const
double get_val() const
Definition: sc_fxval.h:1560
std::string to_string() const
static double from_string(const char *)
std::string to_string(sc_numrep, bool) const
uint64 to_uint64() const
Definition: sc_fxval.h:2064
double to_double() const
Definition: sc_fxval.h:2113
void dump(::std::ostream &=::std::cout) const
std::string to_hex() const
SCFX_EXPLICIT_ sc_fxval_fast(int, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_signed &, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_ sc_fxval_fast(float, sc_fxval_fast_observer *=0)
sc_fxval_fast_observer * observer() const
Definition: sc_fxval.h:1482
bool get_bit(int) const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(int64, sc_fxval_fast_observer *=0)
void scan(::std::istream &=::std::cin)
std::string to_string(sc_fmt) const
unsigned short to_ushort() const
Definition: sc_fxval.h:2032
bool is_zero() const
Definition: sc_fxval.h:2133
unsigned long to_ulong() const
Definition: sc_fxval.h:2097
long to_long() const
Definition: sc_fxval.h:2089
std::string to_oct() const
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(uint64, sc_fxval_fast_observer *=0)
void unlock_observer(sc_fxval_fast_observer *) const
SCFX_EXPLICIT_ sc_fxval_fast(unsigned long, sc_fxval_fast_observer *=0)
short to_short() const
Definition: sc_fxval.h:2024
float to_float() const
Definition: sc_fxval.h:2105
void set_val(double)
Definition: sc_fxval.h:1569
SCFX_EXPLICIT_ sc_fxval_fast(double, sc_fxval_fast_observer *=0)
sc_fxval_fast(sc_fxval_fast_observer *=0)
Definition: sc_fxval.h:1491
std::string to_bin() const
const sc_fxval_fast & operator+() const
Definition: sc_fxval.h:1588
friend sc_fxval_fast operator>>(const sc_fxval_fast &, int)
Definition: sc_fxval.h:1699
std::string to_dec() const
bool is_nan() const
Definition: sc_fxval.h:2142
bool rounding_flag() const
Definition: sc_fxval.h:2170
SCFX_EXPLICIT_ sc_fxval_fast(unsigned int, sc_fxval_fast_observer *=0)
bool is_normal() const
Definition: sc_fxval.h:2160
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_unsigned &, sc_fxval_fast_observer *=0)
SCFX_EXPLICIT_OTHER_ sc_fxval_fast(const sc_int_base &, sc_fxval_fast_observer *=0)
bool is_inf() const
Definition: sc_fxval.h:2151
int to_int() const
Definition: sc_fxval.h:2048
sc_fxval_fast & operator--()
Definition: sc_fxval.h:2001
unsigned int to_uint() const
Definition: sc_fxval.h:2056
sc_fxval_fast operator-() const
Definition: sc_fxval.h:1580
SCFX_EXPLICIT_ sc_fxval_fast(const char *, sc_fxval_fast_observer *=0)
sc_fxval_fast & operator++()
Definition: sc_fxval.h:1991
bool is_neg() const
Definition: sc_fxval.h:2124
sc_fxval_fast(const sc_fxval &, sc_fxval_fast_observer *=0)
bool is_inf() const
Definition: scfx_rep.h:451
bool rounding_flag() const
Definition: scfx_rep.h:487
uint64 to_uint64() const
bool get_bit(int) const
void get_type(int &, int &, sc_enc &) const
bool is_nan() const
Definition: scfx_rep.h:444
double to_double() const
bool is_normal() const
Definition: scfx_rep.h:458
bool is_neg() const
Definition: scfx_rep.h:421
bool is_zero() const
Definition: scfx_rep.h:428