SystemC  Recoding Infrastructure for SystemC v0.6.0 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
scfx_rep.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  scfx_rep.h -
21 
22  Original Author: Robert Graulich, Synopsys, Inc.
23  Martin Janssen, Synopsys, Inc.
24 
25  *****************************************************************************/
26 
27 /*****************************************************************************
28 
29  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
30  changes you are making here.
31 
32  Name, Affiliation, Date:
33  Description of Modification:
34 
35  *****************************************************************************/
36 
37 // $Log: scfx_rep.h,v $
38 // Revision 1.6 2011/08/24 22:05:43 acg
39 // Torsten Maehne: initialization changes to remove warnings.
40 //
41 // Revision 1.5 2011/07/25 10:20:29 acg
42 // Andy Goodrich: check in aftermath of call to automake.
43 //
44 // Revision 1.4 2010/12/07 20:09:08 acg
45 // Andy Goodrich: Philipp Hartmann's constructor disambiguation fix
46 //
47 // Revision 1.3 2010/08/03 15:54:52 acg
48 // Andy Goodrich: formatting.
49 //
50 // Revision 1.2 2010/03/15 18:29:01 acg
51 // Andy Goodrich: Moved default argument specifications from friend
52 // declarations to the actual function signatures.
53 //
54 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
55 // SystemC 2.3
56 //
57 // Revision 1.4 2006/03/13 20:24:27 acg
58 // Andy Goodrich: Addition of function declarations, e.g., neg_scfx_rep(),
59 // to keep gcc 4.x happy.
60 //
61 // Revision 1.3 2006/01/13 18:53:58 acg
62 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
63 // the source.
64 //
65 
66 #ifndef SCFX_REP_H
67 #define SCFX_REP_H
68 
69 
70 #include <climits>
71 
75 
76 
77 namespace sc_dt
78 {
79 
80 // classes defined in this module
81 class scfx_index;
82 class scfx_rep;
83 
84 // forward class declarations
85 class sc_bv_base;
86 class sc_signed;
87 class sc_unsigned;
88 
89 // function declarations
90 void multiply( scfx_rep&, const scfx_rep&, const scfx_rep&,
91  int max_wl = SC_DEFAULT_MAX_WL_ );
92 scfx_rep* neg_scfx_rep( const scfx_rep& );
93 scfx_rep* mult_scfx_rep( const scfx_rep&, const scfx_rep&,
94  int max_wl = SC_DEFAULT_MAX_WL_ );
95 scfx_rep* div_scfx_rep( const scfx_rep&, const scfx_rep&,
96  int max_wl = SC_DEFAULT_DIV_WL_ );
97 scfx_rep* add_scfx_rep( const scfx_rep&, const scfx_rep&,
98  int max_wl = SC_DEFAULT_MAX_WL_ );
99 scfx_rep* sub_scfx_rep( const scfx_rep&, const scfx_rep&,
100  int max_wl = SC_DEFAULT_MAX_WL_ );
101 scfx_rep* lsh_scfx_rep( const scfx_rep&, int );
102 scfx_rep* rsh_scfx_rep( const scfx_rep&, int );
103 int cmp_scfx_rep( const scfx_rep&, const scfx_rep& );
104 
105 
106 const int min_mant = 4;
107 
108 const int bits_in_int = sizeof(int) * CHAR_BIT;
109 const int bits_in_word = sizeof(word) * CHAR_BIT;
110 
114 // 08/03/2015 GL.
116  static pthread_mutex_t m_mutex;
117  explicit scfx_rep_list_lock();
119 };
120 
124 // 08/03/2015 GL.
126  static pthread_mutex_t m_mutex;
127  explicit scfx_rep_pow10_fx_lock();
129 };
130 
134 // 08/04/2015 GL.
136  static pthread_mutex_t m_mutex;
137  explicit scfx_rep_scfx_string_lock();
139 };
140 
141 
142 // ----------------------------------------------------------------------------
143 // CLASS : scfx_index
144 // ----------------------------------------------------------------------------
145 
147 {
148 
149 public:
150 
151  scfx_index( int wi_, int bi_ ) : m_wi( wi_ ), m_bi( bi_ ) {}
152 
153  int wi() const { return m_wi; }
154  int bi() const { return m_bi; }
155 
156  void wi( int wi_ ) { m_wi = wi_; }
157 
158 private:
159 
160  int m_wi;
161  int m_bi;
162 
163 };
164 
165 
166 // ----------------------------------------------------------------------------
167 // CLASS : scfx_rep
168 //
169 // Arbitrary-precision fixed-point implementation class.
170 // ----------------------------------------------------------------------------
171 
172 class scfx_rep
173 {
174  enum state
175  {
176  normal,
177  infinity,
178  not_a_number
179  };
180 
181 public:
182 
183  // constructors
184 
185  scfx_rep();
186  explicit scfx_rep( int );
187  explicit scfx_rep( unsigned int );
188  explicit scfx_rep( long );
189  explicit scfx_rep( unsigned long );
190  explicit scfx_rep( double );
191  explicit scfx_rep( const char* );
192  explicit scfx_rep( int64 );
193  explicit scfx_rep( uint64 );
194  explicit scfx_rep( const sc_signed& );
195  explicit scfx_rep( const sc_unsigned& );
196 
197 
198  // copy constructor
199 
200  scfx_rep( const scfx_rep& );
201 
202 
203  // destructor
204 
205  ~scfx_rep();
206 
207 
208  void* operator new( std::size_t );
209  void operator delete( void*, std::size_t );
210 
211 
212  void from_string( const char*, int );
213 
214  double to_double() const;
215 
216  const char* to_string( sc_numrep,
217  int,
218  sc_fmt,
219  const scfx_params* = 0 ) const;
220 
221 
222  // assignment operator
223 
224  void operator = ( const scfx_rep& );
225 
226  friend void multiply( scfx_rep&, const scfx_rep&, const scfx_rep&, int );
227 
228  friend scfx_rep* neg_scfx_rep( const scfx_rep& );
229  friend scfx_rep* mult_scfx_rep( const scfx_rep&, const scfx_rep&, int );
230  friend scfx_rep* div_scfx_rep( const scfx_rep&, const scfx_rep&, int );
231  friend scfx_rep* add_scfx_rep( const scfx_rep&, const scfx_rep&, int );
232  friend scfx_rep* sub_scfx_rep( const scfx_rep&, const scfx_rep&, int );
233  friend scfx_rep* lsh_scfx_rep( const scfx_rep&, int );
234  friend scfx_rep* rsh_scfx_rep( const scfx_rep&, int );
235 
236  void lshift( int );
237  void rshift( int );
238 
239  friend int cmp_scfx_rep( const scfx_rep&, const scfx_rep& );
240 
241  void cast( const scfx_params&, bool&, bool& );
242 
243  bool is_neg() const;
244  bool is_zero() const;
245  bool is_nan() const;
246  bool is_inf() const;
247  bool is_normal() const;
248 
249  void set_zero( int = 1 );
250  void set_nan();
251  void set_inf( int );
252 
253  bool get_bit( int ) const;
254  bool set( int, const scfx_params& );
255  bool clear( int, const scfx_params& );
256 
257  bool get_slice( int, int, const scfx_params&, sc_bv_base& ) const;
258  bool set_slice( int, int, const scfx_params&, const sc_bv_base& );
259 
260  void print( ::std::ostream& ) const;
261  void dump( ::std::ostream& ) const;
262 
263  void get_type( int&, int&, sc_enc& ) const;
264 
265  friend scfx_rep* quantization_scfx_rep( const scfx_rep&,
266  const scfx_params&,
267  bool& );
268  friend scfx_rep* overflow_scfx_rep( const scfx_rep&,
269  const scfx_params&,
270  bool& );
271 
272  bool rounding_flag() const;
273 
274 private:
275 
276  friend void align( const scfx_rep&, const scfx_rep&, int&, int&,
278  friend int compare_msw( const scfx_rep&, const scfx_rep& );
279  friend int compare_msw_ff( const scfx_rep& lhs, const scfx_rep& rhs );
280  unsigned int divide_by_ten();
281  int find_lsw() const;
282  int find_msw() const;
283  void find_sw();
284  void multiply_by_ten();
285  void normalize( int );
286  scfx_mant* resize( int, int ) const;
287  void set_bin( int );
288  void set_oct( int, int );
289  void set_hex( int, int );
290  void shift_left( int );
291  void shift_right( int );
292 
293  const scfx_index calc_indices( int ) const;
294 
295  void o_extend( const scfx_index&, sc_enc );
296  bool o_bit_at( const scfx_index& ) const;
297  bool o_zero_left( const scfx_index& ) const;
298  bool o_zero_right( const scfx_index& ) const;
299  void o_set_low( const scfx_index&, sc_enc );
300  void o_set_high( const scfx_index&, const scfx_index&, sc_enc, int = 1 );
301  void o_set( const scfx_index&, const scfx_index&, sc_enc, bool );
302  void o_invert( const scfx_index& );
303  bool q_bit( const scfx_index& ) const;
304  void q_clear( const scfx_index& );
305  void q_incr( const scfx_index& );
306  bool q_odd( const scfx_index& ) const;
307  bool q_zero( const scfx_index& ) const;
308 
309  void resize_to( int, int = 0 );
310  int size() const;
311  void toggle_tc();
312 
313  friend void print_dec( scfx_string&, const scfx_rep&, int, sc_fmt );
314  friend void print_other( scfx_string&, const scfx_rep&, sc_numrep, int,
315  sc_fmt, const scfx_params* );
316 
317  void quantization( const scfx_params&, bool& );
318  void overflow( const scfx_params&, bool& );
319 
320  friend int compare_abs( const scfx_rep&, const scfx_rep& );
321 
322  void round( int );
323 
324 private:
325 
326  scfx_mant m_mant; // mantissa (bits of the value).
327  int m_wp; // index of highest order word in value.
328  int m_sign; // sign of value.
329  state m_state; // value state, e.g., normal, inf, etc.
330  int m_msw; // index of most significant non-zero word.
331  int m_lsw; // index of least significant non-zero word.
332  bool m_r_flag; // true if founding occurred.
333 
334 };
335 
336 
337 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
338 
339 inline
340 void
342 {
343  m_mant.clear();
344  m_wp = m_msw = m_lsw = 0;
345  m_sign = sign;
346  m_state = normal;
347 }
348 
349 inline
350 void
352 {
353  m_mant.resize_to( min_mant );
354  m_state = not_a_number;
355 }
356 
357 inline
358 void
359 scfx_rep::set_inf( int sign )
360 {
361  m_mant.resize_to( min_mant );
362  m_state = infinity;
363  m_sign = sign;
364 }
365 
366 
367 // constructors
368 
369 inline
370 scfx_rep::scfx_rep( const char* s )
371 : m_mant( min_mant ), m_wp( 2 ), m_sign( 1 ), m_state( normal ),
372  m_msw(0), m_lsw(0), m_r_flag( false )
373 {
375 }
376 
377 
378 // destructor
379 
380 inline
382 {}
383 
384 
385 // assignment operator
386 
387 inline
388 void
390 {
391  if( &f != this )
392  {
393  m_mant = f.m_mant;
394  m_wp = f.m_wp;
395  m_sign = f.m_sign;
396  m_state = f.m_state;
397  m_msw = f.m_msw;
398  m_lsw = f.m_lsw;
399  round( SC_DEFAULT_MAX_WL_ );
400  }
401 }
402 
403 inline
404 scfx_rep*
406 {
407  scfx_rep& c = *new scfx_rep( a );
408  c.m_sign = - c.m_sign;
409  return &c;
410 }
411 
412 inline
413 scfx_rep*
414 mult_scfx_rep( const scfx_rep& a, const scfx_rep& b, int max_wl )
415 {
416  scfx_rep& c = *new scfx_rep;
417  sc_dt::multiply( c, a, b, max_wl );
418  return &c;
419 }
420 
421 inline
422 scfx_rep*
423 lsh_scfx_rep( const scfx_rep& a, int b )
424 {
425  scfx_rep& c = *new scfx_rep( a );
426  c.lshift( b );
427  return &c;
428 }
429 
430 inline
431 scfx_rep*
432 rsh_scfx_rep( const scfx_rep& a, int b )
433 {
434  scfx_rep& c = *new scfx_rep( a );
435  c.rshift( b );
436  return &c;
437 }
438 
439 inline
440 int
441 scfx_rep::size() const
442 {
443  return m_mant.size();
444 }
445 
446 inline
447 bool
449 {
450  return ( m_sign == -1 );
451 }
452 
453 inline
454 bool
456 {
457  if( m_state != normal )
458  return false;
459 
460  for( int i = 0; i < size(); i ++ )
461  {
462  if( m_mant[i] )
463  return false;
464  }
465 
466  return true;
467 }
468 
469 inline
470 bool
472 {
473  return ( m_state == not_a_number );
474 }
475 
476 inline
477 bool
479 {
480  return ( m_state == infinity );
481 }
482 
483 inline
484 bool
486 {
487  return ( m_state == normal );
488 }
489 
490 inline
491 scfx_rep*
493  const scfx_params& params,
494  bool& q_flag )
495 {
496  scfx_rep& c = *new scfx_rep( a );
497  c.quantization( params, q_flag );
498  return &c;
499 }
500 
501 inline
502 scfx_rep*
504  const scfx_params& params,
505  bool& o_flag )
506 {
507  scfx_rep& c = *new scfx_rep( a );
508  c.overflow( params, o_flag );
509  return &c;
510 }
511 
512 inline
513 bool
515 {
516  return m_r_flag;
517 }
518 
519 inline
520 void
521 scfx_rep::resize_to( int new_size, int restore )
522 {
523  if( restore == -1 )
524  {
525  int size_incr = new_size - size();
526  m_wp += size_incr;
527  m_msw += size_incr;
528  m_lsw += size_incr;
529  }
530  m_mant.resize_to( new_size, restore );
531 }
532 
533 inline
534 const scfx_index
535 scfx_rep::calc_indices( int n ) const
536 {
537  int wi = n / bits_in_word + m_wp;
538  int bi = n % bits_in_word;
539 
540  if( bi < 0 )
541  {
542  bi += bits_in_word;
543  -- wi;
544  }
545 
546  return scfx_index( wi, bi );
547 }
548 
549 inline
550 void
551 scfx_rep::o_extend( const scfx_index& x, sc_enc enc )
552 {
553  int wi = x.wi();
554  int bi = x.bi();
555 
556  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
557 
558  if( enc == SC_US_ || ( m_mant[wi] & ( ((word)1) << bi ) ) == 0 )
559  {
560  if( bi != bits_in_word - 1 )
561  m_mant[wi] &= ~( ((word)-1) << ( bi + 1 ) );
562  for( int i = wi + 1; i < size(); ++ i )
563  m_mant[i] = 0;
564  m_sign = 1;
565  }
566  else
567  {
568  if( bi != bits_in_word - 1 )
569  m_mant[wi] |= ( ((word)-1) << ( bi + 1 ) );
570  for( int i = wi + 1; i < size(); ++ i )
571  m_mant[i] = static_cast<word>( -1 );
572  m_sign = -1;
573  }
574 }
575 
576 inline
577 bool
578 scfx_rep::o_bit_at( const scfx_index& x ) const
579 {
580  int wi = x.wi();
581  int bi = x.bi();
582 
583  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
584 
585  return ( m_mant[wi] & ( ((word)1) << bi ) ) != 0;
586 }
587 
588 inline
589 bool
590 scfx_rep::o_zero_left( const scfx_index& x ) const
591 {
592  int wi = x.wi();
593  int bi = x.bi();
594 
595  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
596 
597  bool zero = true;
598  if( bi != bits_in_word - 1 )
599  zero = ( m_mant[wi] & ( ((word)-1) << ( bi + 1 ) ) ) == 0;
600  for( int i = wi + 1; i < size(); ++ i )
601  zero = zero && m_mant[i] == 0;
602 
603  return zero;
604 }
605 
606 inline
607 bool
608 scfx_rep::o_zero_right( const scfx_index& x ) const
609 {
610  int wi = x.wi();
611  int bi = x.bi();
612 
613  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
614 
615  bool zero = ( m_mant[wi] & ~( ((word)-1) << bi ) ) == 0;
616  for( int i = wi - 1; i >= 0; -- i )
617  zero = zero && m_mant[i] == 0;
618 
619  return zero;
620 }
621 
622 inline
623 void
624 scfx_rep::o_set_low( const scfx_index& x, sc_enc enc )
625 {
626  int wi = x.wi();
627  int bi = x.bi();
628 
629  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
630 
631  m_mant.clear();
632 
633  if( enc == SC_TC_ )
634  {
635  m_mant[wi] |= ( ((word)1) << bi );
636  m_sign = -1;
637  }
638  else
639  m_sign = 1;
640 }
641 
642 inline
643 void
644 scfx_rep::o_set_high( const scfx_index& x, const scfx_index& x2,
645  sc_enc enc, int sign )
646 {
647  int wi = x.wi();
648  int bi = x.bi();
649  int wi2 = x2.wi();
650  int bi2 = x2.bi();
651 
652  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
653  SC_ASSERT_( wi2 >= 0 && wi2 < size(), "word index out of range" );
654 
655  int i;
656 
657  for( i = 0; i < size(); ++ i )
658  m_mant[i] = static_cast<word>( -1 );
659 
660  m_mant[wi] &= ~( ((word)-1) << bi );
661  for( i = wi + 1; i < size(); ++ i )
662  m_mant[i] = 0;
663 
664  m_mant[wi2] &= ( ((word)-1) << bi2 );
665  for( i = wi2 - 1; i >= 0; -- i )
666  m_mant[i] = 0;
667 
668  if( enc == SC_TC_ )
669  m_sign = sign;
670  else
671  {
672  m_mant[wi] |= ( ((word)1) << bi );
673  m_sign = 1;
674  }
675 }
676 
677 inline
678 void
679 scfx_rep::o_set( const scfx_index& x, const scfx_index& x3,
680  sc_enc enc, bool under )
681 {
682  int wi = x.wi();
683  int bi = x.bi();
684  int wi3 = x3.wi();
685  int bi3 = x3.bi();
686 
687  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
688  SC_ASSERT_( wi3 >= 0 && wi3 < size(), "word index out of range" );
689 
690  if( bi3 != bits_in_word - 1 )
691  {
692  if( under )
693  m_mant[wi3] &= ~( ((word)-1) << ( bi3 + 1 ) );
694  else
695  m_mant[wi3] |= ( ((word)-1) << ( bi3 + 1 ) );
696  }
697  for( int i = wi3 + 1; i < size(); ++ i )
698  {
699  if( under )
700  m_mant[i] = 0;
701  else
702  m_mant[i] = static_cast<word>( -1 );
703  }
704 
705  if( enc == SC_TC_ )
706  {
707  if( under )
708  m_mant[wi] |= ( ((word)1) << bi );
709  else
710  m_mant[wi] &= ~( ((word)1) << bi );
711  }
712 }
713 
714 inline
715 void
716 scfx_rep::o_invert( const scfx_index& x2 )
717 {
718  int wi2 = x2.wi();
719  int bi2 = x2.bi();
720 
721  m_mant[wi2] ^= ( ((word)-1) << bi2 );
722  for( int i = wi2 + 1; i < size(); ++ i )
723  m_mant[i] = ~ m_mant[i];
724 }
725 
726 inline
727 bool
728 scfx_rep::q_bit( const scfx_index& x ) const
729 {
730  int wi = x.wi();
731  int bi = x.bi();
732 
733  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
734 
735  if( bi != 0 )
736  return ( m_mant[wi] & ( ((word)1) << ( bi - 1 ) ) ) != 0;
737  else if( wi != 0 )
738  return ( m_mant[wi - 1] & ( ((word)1) << ( bits_in_word - 1 ) ) ) != 0;
739  else
740  return false;
741 }
742 
743 inline
744 void
745 scfx_rep::q_clear( const scfx_index& x )
746 {
747  int wi = x.wi();
748  int bi = x.bi();
749 
750  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
751 
752  m_mant[wi] &= ( ((word)-1) << bi );
753  for( int i = wi - 1; i >= 0; -- i )
754  m_mant[i] = 0;
755 }
756 
757 inline
758 void
759 scfx_rep::q_incr( const scfx_index& x )
760 {
761  int wi = x.wi();
762  int bi = x.bi();
763 
764  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
765 
766  word old_val = m_mant[wi];
767  m_mant[wi] += ( ((word)1) << bi );
768  if( m_mant[wi] <= old_val )
769  {
770  if( wi + 1 == size() )
771  resize_to( size() + 1, 1 );
772 
773  for( int i = wi + 1; i < size(); ++ i )
774  {
775  if( ++ m_mant[i] != 0 )
776  break;
777  }
778  }
779 }
780 
781 inline
782 bool
783 scfx_rep::q_odd( const scfx_index& x ) const
784 {
785  int wi = x.wi();
786  int bi = x.bi();
787 
788  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
789 
790  return ( m_mant[wi] & ( ((word)1) << bi ) ) != 0;
791 }
792 
793 inline
794 bool
795 scfx_rep::q_zero( const scfx_index& x ) const
796 {
797  int wi = x.wi();
798  int bi = x.bi();
799 
800  SC_ASSERT_( wi >= 0 && wi < size(), "word index out of range" );
801 
802  bool zero;
803 
804  if( bi != 0 )
805  {
806  zero = ( m_mant[wi] & ~( ((word)-1) << (bi - 1) ) ) == 0;
807  for( int i = wi - 1; i >= 0; -- i )
808  zero = zero && m_mant[i] == 0;
809  }
810  else if( wi != 0 )
811  {
812  zero = ( m_mant[wi - 1] & ~( ((word)-1) << (bits_in_word - 1) ) ) == 0;
813  for( int i = wi - 2; i >= 0; -- i )
814  zero = zero && m_mant[i] == 0;
815  }
816  else
817  zero = true;
818 
819  return zero;
820 }
821 
822 inline
823 int
824 scfx_rep::find_lsw() const
825 {
826  for( int i = 0; i < size(); i ++ )
827  {
828  if( m_mant[i] )
829  return i;
830  }
831  return 0;
832 }
833 
834 inline
835 int
836 scfx_rep::find_msw() const
837 {
838  for( int i = size() - 1; i >= 0; i -- )
839  {
840  if( m_mant[i] )
841  return i;
842  }
843  return 0;
844 }
845 
846 inline
847 void
848 scfx_rep::find_sw()
849 {
850  m_lsw = find_lsw();
851  m_msw = find_msw();
852 }
853 
854 inline
855 void
856 scfx_rep::toggle_tc()
857 {
858  if( is_neg() )
859  {
860  complement( m_mant, m_mant, m_mant.size() );
861  inc( m_mant );
862  }
863 }
864 
865 } // namespace sc_dt
866 
867 
868 #endif
869 
870 // Taf!
friend scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void set_nan()
Definition: scfx_rep.h:351
void inc(scfx_mant &mant)
Definition: scfx_mant.h:373
scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
const int bits_in_word
Definition: scfx_rep.h:109
friend scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void from_string(const char *, int)
const char * to_string(sc_numrep, int, sc_fmt, const scfx_params *=0) const
static pthread_mutex_t m_mutex
Definition: scfx_rep.h:126
void print(::std::ostream &) const
scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
void rshift(int)
#define SC_ASSERT_(cnd, msg)
Definition: sc_fxdefs.h:254
void cast(const scfx_params &, bool &, bool &)
friend scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
A scoped mutex for static scfx_rep_node* list.
Definition: scfx_rep.h:115
sc_numrep
Definition: sc_nbdefs.h:91
void get_type(int &, int &, sc_enc &) const
int64_t int64
Definition: sc_nbdefs.h:182
friend scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int)
friend void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int)
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:432
bool clear(int, const scfx_params &)
friend int compare_abs(const scfx_rep &, const scfx_rep &)
friend scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void set_inf(int)
Definition: scfx_rep.h:359
bool is_nan() const
Definition: scfx_rep.h:471
void operator=(const scfx_rep &)
Definition: scfx_rep.h:389
const int min_mant
Definition: scfx_rep.h:106
bool get_bit(int) const
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Definition: scfx_rep.h:423
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &o_flag)
Definition: scfx_rep.h:503
int size() const
Definition: scfx_mant.h:132
double to_double() const
bool is_inf() const
Definition: scfx_rep.h:478
scfx_rep * neg_scfx_rep(const scfx_rep &)
Definition: scfx_rep.h:405
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1003
scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
Definition: scfx_rep.h:414
A scoped mutex for scfx_rep::to_string.
Definition: scfx_rep.h:135
friend scfx_rep * neg_scfx_rep(const scfx_rep &)
sc_enc
Definition: sc_fxdefs.h:63
void dump(::std::ostream &) const
void set_zero(int=1)
Definition: scfx_rep.h:341
int bi() const
Definition: scfx_rep.h:154
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
scfx_index(int wi_, int bi_)
Definition: scfx_rep.h:151
bool is_normal() const
Definition: scfx_rep.h:485
friend int compare_msw(const scfx_rep &, const scfx_rep &)
bool rounding_flag() const
Definition: scfx_rep.h:514
friend void align(const scfx_rep &, const scfx_rep &, int &, int &, scfx_mant_ref &, scfx_mant_ref &)
uint64_t uint64
Definition: sc_nbdefs.h:183
bool set(int, const scfx_params &)
scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
friend int compare_msw_ff(const scfx_rep &lhs, const scfx_rep &rhs)
friend void print_dec(scfx_string &, const scfx_rep &, int, sc_fmt)
const int bits_in_int
Definition: scfx_rep.h:108
int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
bool is_zero() const
Definition: scfx_rep.h:455
static pthread_mutex_t m_mutex
Definition: scfx_rep.h:116
static pthread_mutex_t m_mutex
Definition: scfx_rep.h:136
const int SC_DEFAULT_MAX_WL_
Definition: sc_fxdefs.h:239
unsigned int word
Definition: scfx_mant.h:65
void lshift(int)
void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params &params, bool &q_flag)
Definition: scfx_rep.h:492
A scoped mutex for static scfx_pow10 pow10_fx.
Definition: scfx_rep.h:125
friend void print_other(scfx_string &, const scfx_rep &, sc_numrep, int, sc_fmt, const scfx_params *)
void resize_to(int, int=0)
Definition: scfx_mant.h:243
int wi() const
Definition: scfx_rep.h:153
const int SC_DEFAULT_DIV_WL_
Definition: sc_fxdefs.h:227
bool is_neg() const
Definition: scfx_rep.h:448
void complement(scfx_mant &target, const scfx_mant &source, int size)
Definition: scfx_mant.h:358
void wi(int wi_)
Definition: scfx_rep.h:156
friend int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
friend scfx_rep * overflow_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
Definition: scfx_rep.h:503
const int SC_DEFAULT_CTE_WL_
Definition: sc_fxdefs.h:233
friend scfx_rep * quantization_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
Definition: scfx_rep.h:492
friend scfx_rep * lsh_scfx_rep(const scfx_rep &, int)