SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_proxy.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_proxy.h -- Proxy base class for vector data types.
21 
22  This class is created for several purposes:
23  1) hiding operators from the global namespace that would be
24  otherwise found by Koenig lookup
25  2) avoiding repeating the same operations in every class
26  including proxies that could also be achieved by common
27  base class, but this method allows
28  3) improve performance by using non-virtual functions
29 
30  Original Author: Gene Bushuyev, Synopsys, Inc.
31 
32  *****************************************************************************/
33 
34 /*****************************************************************************
35 
36  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
37  changes you are making here.
38 
39  Name, Affiliation, Date:
40  Description of Modification:
41 
42  *****************************************************************************/
43 
44 // $Log: sc_proxy.h,v $
45 // Revision 1.3 2010/12/07 20:09:07 acg
46 // Andy Goodrich: Fix for returning enough data
47 //
48 // Revision 1.2 2009/02/28 00:26:14 acg
49 // Andy Goodrich: bug fixes.
50 //
51 // Revision 1.1.1.1 2006/12/15 20:31:36 acg
52 // SystemC 2.2
53 //
54 // Revision 1.3 2006/01/13 18:53:53 acg
55 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
56 // the source.
57 //
58 
59 #ifndef SC_PROXY_H
60 #define SC_PROXY_H
61 
62 
63 #include "sysc/kernel/sc_cmnhdr.h"
64 #include "sysc/utils/sc_iostream.h"
72 #include "sysc/kernel/sc_macros.h"
73 
74 
75 namespace sc_dt
76 {
77 
78 // classes defined in this module
79 template <class X> class sc_proxy;
80 
81 // forward class declarations
82 class sc_bv_base;
83 class sc_lv_base;
84 template <class X> class sc_bitref_r;
85 template <class X> class sc_bitref;
86 template <class X> class sc_subref_r;
87 template <class X> class sc_subref;
88 template <class X, class Y> class sc_concref_r;
89 template <class X, class Y> class sc_concref;
90 
91 
92 const int SC_DIGIT_SIZE = BITS_PER_BYTE * sizeof( sc_digit );
93 
97 
98 
99 // assignment functions; forward declarations
100 
101 template <class X, class Y>
102 inline
103 void
104 assign_p_( sc_proxy<X>& px, const sc_proxy<Y>& py );
105 
106 // Vector types that are not derived from sc_proxy must have a length()
107 // function and an operator [].
108 
109 template <class X, class T>
110 inline
111 void
112 assign_v_( sc_proxy<X>& px, const T& a );
113 
114 
115 // other functions; forward declarations
116 
117 const std::string convert_to_bin( const char* s );
118 const std::string convert_to_fmt( const std::string& s, sc_numrep numrep, bool );
119 
120 // ----------------------------------------------------------------------------
121 // CLASS TEMPLATE : sc_proxy_traits
122 //
123 // Template traits helper to select the correct bit/value/vector_types for
124 // sc_proxy-based vector classes.
125 //
126 // All types derived from/based on a bit-vector contain typedef to a plain bool,
127 // all others point to the sc_logic_value_t/sc_logic/sc_lv_base types.
128 // ----------------------------------------------------------------------------
129 
130 template<typename X> struct sc_proxy_traits;
131 
132 template<> struct sc_proxy_traits<sc_bv_base>
133 {
135  typedef bool value_type;
136  typedef bool bit_type;
138  typedef traits_type type;
139 };
140 
141 template<> struct sc_proxy_traits<sc_lv_base>
142 {
147  typedef traits_type type;
148 };
149 
150 
151 template<typename X> struct sc_proxy_traits<sc_bitref_r<X> >
152  : sc_proxy_traits<X> {};
153 
154 template<typename X> struct sc_proxy_traits<sc_bitref<X> >
155  : sc_proxy_traits<X> {};
156 
157 
158 template<typename X> struct sc_proxy_traits<sc_subref_r<X> >
159  : sc_proxy_traits<X> {};
160 
161 template<typename X> struct sc_proxy_traits<sc_subref<X> >
162  : sc_proxy_traits<X> {};
163 
164 
165 template<typename X> struct sc_proxy_traits<sc_proxy<X> >
166  : sc_proxy_traits<X> {};
167 
168 
169 template< typename X, typename Y > struct sc_mixed_proxy_traits_helper
170  : sc_proxy_traits<sc_lv_base> {}; // logic vector by default
171 
172 template<typename X> struct sc_mixed_proxy_traits_helper<X,X>
173  : X {};
174 
175 
176 template<typename X, typename Y> struct sc_proxy_traits< sc_concref_r<X,Y> >
177  : sc_mixed_proxy_traits_helper< typename X::traits_type::type
178  , typename Y::traits_type::type >
179 {};
180 
181 template<typename X, typename Y> struct sc_proxy_traits<sc_concref<X,Y> >
182  : sc_mixed_proxy_traits_helper< typename X::traits_type::type
183  , typename Y::traits_type::type >
184 {};
185 
186 
187 // ----------------------------------------------------------------------------
188 // CLASS TEMPLATE : sc_proxy
189 //
190 // Base class template for bit/logic vector classes.
191 // (Barton/Nackmann implementation)
192 // ----------------------------------------------------------------------------
193 
194 template <class X>
195 class sc_proxy // #### : public sc_value_base
196 {
197 public:
199  typedef typename traits_type::bit_type bit_type;
200 
201  // virtual destructor
202 
203  virtual ~sc_proxy() {}
204 
205 
206  // casts
207 
209  { return SCAST<X&>( *this ); }
210 
211  const X& back_cast() const
212  { return SCAST<const X&>( *this ); }
213 
214 
215  // assignment operators
216 
217  template <class Y>
218  X& assign_( const sc_proxy<Y>& a )
219  { assign_p_( *this, a ); return back_cast(); }
220 
221  X& assign_( const char* a );
222  X& assign_( const bool* a );
223  X& assign_( const sc_logic* a );
224 
225  X& assign_( const sc_unsigned& a )
226  { assign_v_( *this, a ); return back_cast(); }
227 
228  X& assign_( const sc_signed& a )
229  { assign_v_( *this, a ); return back_cast(); }
230 
231  X& assign_( const sc_uint_base& a )
232  { return assign_( (uint64) a ); }
233 
234  X& assign_( const sc_int_base& a )
235  { return assign_( (int64) a ); }
236 
237  X& assign_( unsigned int a );
238  X& assign_( int a );
239 
240  X& assign_( unsigned long a );
241 
242  X& assign_( long a );
243 
244  X& assign_( uint64 a );
245  X& assign_( int64 a );
246 
247 
248  // bitwise operators and functions
249 
250  // bitwise complement
251 
252  X& b_not();
253 
254  const sc_lv_base operator ~ () const;
255 
256 
257  // bitwise and
258 
259  X& operator &= ( const char* b );
260  X& operator &= ( const bool* b );
261  X& operator &= ( const sc_logic* b );
262  X& operator &= ( const sc_unsigned& b );
263  X& operator &= ( const sc_signed& b );
264 
266  { return operator &= ( (uint64) b ); }
267 
269  { return operator &= ( (int64) b ); }
270 
271  X& operator &= ( unsigned long b );
272  X& operator &= ( long b );
273 
274  X& operator &= ( unsigned int b )
275  { return operator &= ( (unsigned long) b ); }
276 
277  X& operator &= ( int b )
278  { return operator &= ( (long) b ); }
279 
280  X& operator &= ( uint64 b );
281  X& operator &= ( int64 b );
282 
283 
284  const sc_lv_base operator & ( const char* b ) const;
285  const sc_lv_base operator & ( const bool* b ) const;
286  const sc_lv_base operator & ( const sc_logic* b ) const;
287  const sc_lv_base operator & ( const sc_unsigned& b ) const;
288  const sc_lv_base operator & ( const sc_signed& b ) const;
289  const sc_lv_base operator & ( const sc_uint_base& b ) const;
290  const sc_lv_base operator & ( const sc_int_base& b ) const;
291  const sc_lv_base operator & ( unsigned long b ) const;
292  const sc_lv_base operator & ( long b ) const;
293  const sc_lv_base operator & ( unsigned int b ) const;
294  const sc_lv_base operator & ( int b ) const;
295  const sc_lv_base operator & ( uint64 b ) const;
296  const sc_lv_base operator & ( int64 b ) const;
297 
298 
299  // bitwise or
300 
301  X& operator |= ( const char* b );
302  X& operator |= ( const bool* b );
303  X& operator |= ( const sc_logic* b );
304  X& operator |= ( const sc_unsigned& b );
305  X& operator |= ( const sc_signed& b );
306 
308  { return operator |= ( (uint64) b ); }
309 
311  { return operator |= ( (int64) b ); }
312 
313  X& operator |= ( unsigned long b );
314  X& operator |= ( long b );
315 
316  X& operator |= ( unsigned int b )
317  { return operator |= ( (unsigned long) b ); }
318 
319  X& operator |= ( int b )
320  { return operator |= ( (long) b ); }
321 
322  X& operator |= ( uint64 b );
323  X& operator |= ( int64 b );
324 
325 
326  const sc_lv_base operator | ( const char* b ) const;
327  const sc_lv_base operator | ( const bool* b ) const;
328  const sc_lv_base operator | ( const sc_logic* b ) const;
329  const sc_lv_base operator | ( const sc_unsigned& b ) const;
330  const sc_lv_base operator | ( const sc_signed& b ) const;
331  const sc_lv_base operator | ( const sc_uint_base& b ) const;
332  const sc_lv_base operator | ( const sc_int_base& b ) const;
333  const sc_lv_base operator | ( unsigned long b ) const;
334  const sc_lv_base operator | ( long b ) const;
335  const sc_lv_base operator | ( unsigned int b ) const;
336  const sc_lv_base operator | ( int b ) const;
337  const sc_lv_base operator | ( uint64 b ) const;
338  const sc_lv_base operator | ( int64 b ) const;
339 
340 
341  // bitwise xor
342 
343  X& operator ^= ( const char* b );
344  X& operator ^= ( const bool* b );
345  X& operator ^= ( const sc_logic* b );
346  X& operator ^= ( const sc_unsigned& b );
347  X& operator ^= ( const sc_signed& b );
348 
350  { return operator ^= ( (uint64) b ); }
351 
353  { return operator ^= ( (int64) b ); }
354 
355  X& operator ^= ( unsigned long b );
356  X& operator ^= ( long b );
357 
358  X& operator ^= ( unsigned int b )
359  { return operator ^= ( (unsigned long) b ); }
360 
361  X& operator ^= ( int b )
362  { return operator ^= ( (long) b ); }
363 
364  X& operator ^= ( uint64 b );
365  X& operator ^= ( int64 b );
366 
367 
368  const sc_lv_base operator ^ ( const char* b ) const;
369  const sc_lv_base operator ^ ( const bool* b ) const;
370  const sc_lv_base operator ^ ( const sc_logic* b ) const;
371  const sc_lv_base operator ^ ( const sc_unsigned& b ) const;
372  const sc_lv_base operator ^ ( const sc_signed& b ) const;
373  const sc_lv_base operator ^ ( const sc_uint_base& b ) const;
374  const sc_lv_base operator ^ ( const sc_int_base& b ) const;
375  const sc_lv_base operator ^ ( unsigned long b ) const;
376  const sc_lv_base operator ^ ( long b ) const;
377  const sc_lv_base operator ^ ( unsigned int b ) const;
378  const sc_lv_base operator ^ ( int b ) const;
379  const sc_lv_base operator ^ ( uint64 b ) const;
380  const sc_lv_base operator ^ ( int64 b ) const;
381 
382 
383  // bitwise left shift
384 
385  X& operator <<= ( int n );
386 
387  const sc_lv_base operator << ( int n ) const;
388 
389 
390  // bitwise right shift
391 
392  X& operator >>= ( int n );
393 
394  const sc_lv_base operator >> ( int n ) const;
395 
396 
397  // bitwise left rotate
398 
399  X& lrotate( int n );
400 
401 
402  // bitwise right rotate
403 
404  X& rrotate( int n );
405 
406 
407  // bitwise reverse
408 
409  X& reverse();
410 
411 
412  // bit selection
413 
415  { return sc_bitref<X>( back_cast(), i ); }
416 
418  { return sc_bitref_r<X>( back_cast(), i ); }
419 
420  sc_bitref<X> bit( int i )
421  { return sc_bitref<X>( back_cast(), i ); }
422 
423  sc_bitref_r<X> bit( int i ) const
424  { return sc_bitref_r<X>( back_cast(), i ); }
425 
426 
427  // part selection
428 
429  sc_subref<X> operator () ( int hi, int lo )
430  { return sc_subref<X>( back_cast(), hi, lo ); }
431 
432  sc_subref_r<X> operator () ( int hi, int lo ) const
433  { return sc_subref_r<X>( back_cast(), hi, lo ); }
434 
435  sc_subref<X> range( int hi, int lo )
436  { return sc_subref<X>( back_cast(), hi, lo ); }
437 
438  sc_subref_r<X> range( int hi, int lo ) const
439  { return sc_subref_r<X>( back_cast(), hi, lo ); }
440 
441 
442  // reduce functions
443 
445 
447  { return sc_logic::not_table[and_reduce()]; }
448 
449  sc_logic_value_t or_reduce() const;
450 
452  { return sc_logic::not_table[or_reduce()]; }
453 
455 
457  { return sc_logic::not_table[xor_reduce()]; }
458 
459 
460  // relational operators
461 
462  bool operator == ( const char* b ) const;
463  bool operator == ( const bool* b ) const;
464  bool operator == ( const sc_logic* b ) const;
465  bool operator == ( const sc_unsigned& b ) const;
466  bool operator == ( const sc_signed& b ) const;
467  bool operator == ( const sc_uint_base& b ) const;
468  bool operator == ( const sc_int_base& b ) const;
469  bool operator == ( unsigned long b ) const;
470  bool operator == ( long b ) const;
471  bool operator == ( unsigned int b ) const;
472  bool operator == ( int b ) const;
473  bool operator == ( uint64 b ) const;
474  bool operator == ( int64 b ) const;
475 
476 
477  // explicit conversions to character string
478 
479  const std::string to_string() const;
480  const std::string to_string( sc_numrep ) const;
481  const std::string to_string( sc_numrep, bool ) const;
482 
483 
484  // explicit conversions
485 
486  inline int64 to_int64() const
487  { return to_anything_signed(); }
488  inline uint64 to_uint64() const;
489  int to_int() const
490  { return (int)to_anything_signed(); }
491 
492  unsigned int to_uint() const
493  { return (unsigned int)to_anything_unsigned(); }
494 
495  long to_long() const
496  { return (long)to_anything_signed(); }
497 
498  unsigned long to_ulong() const
499  { return (unsigned long)to_anything_unsigned(); }
500 
501 #ifdef SC_DT_DEPRECATED
502 
503  int to_signed() const
504  { return to_int(); }
505 
506  sc_digit to_unsigned() const
507  { return to_uint(); }
508 
509 #endif
510 
511 
512  // other methods
513 
514  void print( ::std::ostream& os = ::std::cout ) const
515  {
516  // the test below will force printing in binary if decimal is
517  // specified.
518  if ( sc_io_base(os, SC_DEC) == SC_DEC )
519  os << to_string();
520  else
521  os << to_string(sc_io_base(os,SC_BIN),sc_io_show_base(os));
522  }
523 
524  void scan( ::std::istream& is = ::std::cin );
525 
526 protected:
527 
528  void check_bounds( int n ) const; // check if bit n accessible
529  void check_wbounds( int n ) const; // check if word n accessible
530 
532  int64 to_anything_signed() const;
533 };
534 
535 
536 // ----------------------------------------------------------------------------
537 
538 // bitwise operators and functions
539 
540 // bitwise and
541 
542 template <class X, class Y>
543 inline
544 X&
545 operator &= ( sc_proxy<X>& px, const sc_proxy<Y>& py );
546 
547 
548 template <class X, class Y>
549 inline
550 const sc_lv_base
551 operator & ( const sc_proxy<X>& px, const sc_proxy<Y>& py );
552 
553 
554 #define DECL_BITWISE_AND_OP_T(tp) \
555 template <class X> \
556 inline \
557 const sc_lv_base \
558 operator & ( tp b, const sc_proxy<X>& px );
559 
560 DECL_BITWISE_AND_OP_T(const char*)
561 DECL_BITWISE_AND_OP_T(const bool*)
562 DECL_BITWISE_AND_OP_T(const sc_logic*)
563 DECL_BITWISE_AND_OP_T(const sc_unsigned&)
564 DECL_BITWISE_AND_OP_T(const sc_signed&)
565 DECL_BITWISE_AND_OP_T(const sc_uint_base&)
566 DECL_BITWISE_AND_OP_T(const sc_int_base&)
567 DECL_BITWISE_AND_OP_T(unsigned long)
569 DECL_BITWISE_AND_OP_T(unsigned int)
573 
574 #undef DECL_BITWISE_AND_OP_T
575 
576 
577 // bitwise or
578 
579 template <class X, class Y>
580 inline
581 X&
582 operator |= ( sc_proxy<X>& px, const sc_proxy<Y>& py );
583 
584 
585 template <class X, class Y>
586 inline
587 const sc_lv_base
588 operator | ( const sc_proxy<X>& px, const sc_proxy<Y>& py );
589 
590 
591 #define DECL_BITWISE_OR_OP_T(tp) \
592 template <class X> \
593 inline \
594 const sc_lv_base \
595 operator | ( tp a, const sc_proxy<X>& px );
596 
597 DECL_BITWISE_OR_OP_T(const char*)
598 DECL_BITWISE_OR_OP_T(const bool*)
599 DECL_BITWISE_OR_OP_T(const sc_logic*)
600 DECL_BITWISE_OR_OP_T(const sc_unsigned&)
601 DECL_BITWISE_OR_OP_T(const sc_signed&)
602 DECL_BITWISE_OR_OP_T(const sc_uint_base&)
603 DECL_BITWISE_OR_OP_T(const sc_int_base&)
604 DECL_BITWISE_OR_OP_T(unsigned long)
606 DECL_BITWISE_OR_OP_T(unsigned int)
610 
611 #undef DECL_BITWISE_OR_OP_T
612 
613 
614 // bitwise xor
615 
616 template <class X, class Y>
617 inline
618 X&
619 operator ^= ( sc_proxy<X>& px, const sc_proxy<Y>& py );
620 
621 
622 template <class X, class Y>
623 inline
624 const sc_lv_base
625 operator ^ ( const sc_proxy<X>& px, const sc_proxy<Y>& py );
626 
627 
628 #define DECL_BITWISE_XOR_OP_T(tp) \
629 template <class X> \
630 inline \
631 const sc_lv_base \
632 operator ^ ( tp a, const sc_proxy<X>& px );
633 
634 DECL_BITWISE_XOR_OP_T(const char*)
635 DECL_BITWISE_XOR_OP_T(const bool*)
636 DECL_BITWISE_XOR_OP_T(const sc_logic*)
637 DECL_BITWISE_XOR_OP_T(const sc_unsigned&)
638 DECL_BITWISE_XOR_OP_T(const sc_signed&)
639 DECL_BITWISE_XOR_OP_T(const sc_uint_base&)
640 DECL_BITWISE_XOR_OP_T(const sc_int_base&)
641 DECL_BITWISE_XOR_OP_T(unsigned long)
643 DECL_BITWISE_XOR_OP_T(unsigned int)
647 
648 #undef DECL_BITWISE_XOR_OP_T
649 
650 
651 // relational operators
652 
653 template <class X, class Y>
654 inline
655 bool
656 operator == ( const sc_proxy<X>& px, const sc_proxy<Y>& py );
657 
658 template <class X, class Y>
659 inline
660 bool
661 operator != ( const sc_proxy<X>& px, const sc_proxy<Y>& py );
662 
663 
664 #define DECL_REL_OP_T(tp) \
665 template <class X> \
666 inline \
667 bool \
668 operator == ( tp b, const sc_proxy<X>& px ); \
669  \
670 template <class X> \
671 inline \
672 bool \
673 operator != ( const sc_proxy<X>& px, tp b ); \
674  \
675 template <class X> \
676 inline \
677 bool \
678 operator != ( tp b, const sc_proxy<X>& px );
679 
680 DECL_REL_OP_T(const char*)
681 DECL_REL_OP_T(const bool*)
682 DECL_REL_OP_T(const sc_logic*)
683 DECL_REL_OP_T(const sc_unsigned&)
684 DECL_REL_OP_T(const sc_signed&)
685 DECL_REL_OP_T(const sc_uint_base&)
686 DECL_REL_OP_T(const sc_int_base&)
687 DECL_REL_OP_T(unsigned long)
688 DECL_REL_OP_T(long)
689 DECL_REL_OP_T(unsigned int)
690 DECL_REL_OP_T(int)
693 
694 #undef DECL_REL_OP_T
695 
696 
697 // l-value concatenation
698 
699 // Due to the fact that temporary objects cannot be passed to non-const
700 // references, we have to enumerate, use call by value, and use dynamic
701 // memory allocation (and deallocation).
702 
703 
704 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
705 
706 template <class X>
707 inline
708 void
709 get_words_( const X& x, int wi, sc_digit& x_dw, sc_digit& x_cw )
710 {
711  x_dw = x.get_word( wi );
712  x_cw = x.get_cword( wi );
713 }
714 
715 template <class X>
716 inline
717 void
718 set_words_( X& x, int wi, sc_digit x_dw, sc_digit x_cw )
719 {
720  x.set_word( wi, x_dw );
721  x.set_cword( wi, x_cw );
722 }
723 
724 template <class X>
725 inline
726 void
727 extend_sign_w_( X& x, int wi, bool sign )
728 {
729  int sz = x.size();
730  unsigned int sgn = (sign ? ~SC_DIGIT_ZERO : SC_DIGIT_ZERO);
731  for( int i = wi; i < sz; ++ i ) {
732  set_words_( x, i, sgn, SC_DIGIT_ZERO );
733  }
734 }
735 
736 
737 // assignment functions
738 
739 template <class X, class Y>
740 inline
741 void
743 {
744  if( (void*) &px != (void*) &py ) {
745  X& x = px.back_cast();
746  const Y& y = py.back_cast();
747  int sz = x.size();
748  int min_sz = sc_min( sz, y.size() );
749  int i = 0;
750  for( ; i < min_sz; ++ i ) {
751  set_words_( x, i, y.get_word( i ), y.get_cword( i ) );
752  }
753  // extend with zeros
754  extend_sign_w_( x, i, false );
755  x.clean_tail();
756  }
757 }
758 
759 // Vector types that are not derived from sc_proxy, sc_int_base,
760 // sc_uint_base, sc_signed, or sc_unsigned, must have a length()
761 // function and an operator []. The vector argument type must support
762 // accessing bits that are beyond the msb. The vector argument type
763 // decides what to do there (e.g. sign extension or zero padding).
764 
765 template <class X, class T>
766 inline
767 void
768 assign_v_( sc_proxy<X>& px, const T& a )
769 {
770  X& x = px.back_cast();
771  int i;
772  int len_x = x.length();
773  int len_a = a.length();
774  if ( len_a > len_x ) len_a = len_x;
775  for( i = 0 ; i < len_a; ++ i ) {
776  x.set_bit( i, sc_logic_value_t( (bool) a[i] ) );
777  }
778  for( ; i < len_x; ++ i ) {
779  x.set_bit( i, sc_logic_value_t( false ) );
780  }
781 }
782 
783 template <class X>
784 inline
785 void
787 {
788  X& x = px.back_cast();
789  int i;
790  bool sign = a < 0;
791  int len_x = x.length();
792  int len_a = a.length();
793  if ( len_a > len_x ) len_a = len_x;
794  for( i = 0 ; i < len_a; ++ i ) {
795  x.set_bit( i, sc_logic_value_t( (bool) a[i] ) );
796  }
797  for( ; i < len_x; ++ i ) {
798  x.set_bit( i, sc_logic_value_t( sign ) );
799  }
800 }
801 
802 template <class X>
803 inline
804 void
806 {
807  X& x = px.back_cast();
808  int i;
809  bool sign = a < 0;
810  int len_x = x.length();
811  int len_a = a.length();
812  if ( len_a > len_x ) len_a = len_x;
813  for( i = 0 ; i < len_a; ++ i ) {
814  x.set_bit( i, sc_logic_value_t( (bool) a[i] ) );
815  }
816  for( ; i < len_x; ++ i ) {
817  x.set_bit( i, sc_logic_value_t( sign ) );
818  }
819 }
820 
821 template <class X>
822 inline
823 void
825 {
826  X& x = px.back_cast();
827  int i;
828  int len_x = x.length();
829  int len_a = a.length();
830  if ( len_a > len_x ) len_a = len_x;
831  for( i = 0 ; i < len_a; ++ i ) {
832  x.set_bit( i, sc_logic_value_t( (bool) a[i] ) );
833  }
834  for( ; i < len_x; ++ i ) {
835  x.set_bit( i, sc_logic_value_t( false ) );
836  }
837 }
838 
839 template <class X>
840 inline
841 void
843 {
844  X& x = px.back_cast();
845  int i;
846  int len_x = x.length();
847  int len_a = a.length();
848  if ( len_a > len_x ) len_a = len_x;
849  for( i = 0 ; i < len_a; ++ i ) {
850  x.set_bit( i, sc_logic_value_t( (bool) a[i] ) );
851  }
852  for( ; i < len_x; ++ i ) {
853  x.set_bit( i, sc_logic_value_t( false ) );
854  }
855 }
856 
857 
858 // assignment operators
859 
860 template <class X>
861 inline
862 X&
863 sc_proxy<X>::assign_( const char* a )
864 {
865  X& x = back_cast();
866  std::string s = convert_to_bin( a );
867  int len = x.length();
868  int s_len = s.length() - 1;
869  int min_len = sc_min( len, s_len );
870  int i = 0;
871  for( ; i < min_len; ++ i ) {
872  char c = s[s_len - i - 1];
873  x.set_bit( i, sc_logic::char_to_logic[(int)c] );
874  }
875  // if formatted, fill the rest with sign(s), otherwise fill with zeros
876  sc_logic_value_t fill = (s[s_len] == 'F' ? sc_logic_value_t( s[0] - '0' )
877  : sc_logic_value_t( 0 ));
878  for( ; i < len; ++ i ) {
879  x.set_bit( i, fill );
880  }
881  return x;
882 }
883 
884 template <class X>
885 inline
886 X&
887 sc_proxy<X>::assign_( const bool* a )
888 {
889  // the length of 'a' must be larger than or equal to the length of 'this'
890  X& x = back_cast();
891  int len = x.length();
892  for( int i = 0; i < len; ++ i ) {
893  x.set_bit( i, sc_logic_value_t( a[i] ) );
894  }
895  return x;
896 }
897 
898 template <class X>
899 inline
900 X&
902 {
903  // the length of 'a' must be larger than or equal to the length of 'this'
904  X& x = back_cast();
905  int len = x.length();
906  for( int i = 0; i < len; ++ i ) {
907  x.set_bit( i, a[i].value() );
908  }
909  return x;
910 }
911 
912 template <class X>
913 inline
914 X&
915 sc_proxy<X>::assign_( unsigned int a )
916 {
917  X& x = back_cast();
918  set_words_( x, 0, (sc_digit)a, SC_DIGIT_ZERO );
919  // extend with zeros
920  extend_sign_w_( x, 1, false );
921  x.clean_tail();
922  return x;
923 }
924 
925 template <class X>
926 inline
927 X&
929 {
930  X& x = back_cast();
931  set_words_( x, 0, (sc_digit) a, SC_DIGIT_ZERO );
932  // extend with sign(a)
933  extend_sign_w_( x, 1, (a < 0) );
934  x.clean_tail();
935  return x;
936 }
937 
938 #if defined(SC_LONG_64)
939  template <class X>
940  inline
941  X&
942  sc_proxy<X>::assign_( unsigned long a )
943  {
944  X& x = back_cast();
945  set_words_( x, 0, ((sc_digit) a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO );
946  if( x.size() > 1 ) {
947  set_words_( x, 1,
948  ((sc_digit) (a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
949  SC_DIGIT_ZERO );
950  // extend with zeros
951  extend_sign_w_( x, 2, false );
952  }
953  x.clean_tail();
954  return x;
955  }
956 
957  template <class X>
958  inline
959  X&
960  sc_proxy<X>::assign_( long a )
961  {
962  X& x = back_cast();
963  set_words_( x, 0, ((sc_digit) a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO );
964  if( x.size() > 1 ) {
965  set_words_( x, 1,
966  ((sc_digit) ((uint64) a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
967  SC_DIGIT_ZERO );
968  // extend with sign(a)
969  extend_sign_w_( x, 2, (a < 0) );
970  }
971  x.clean_tail();
972  return x;
973  }
974 
975 #else
976  template <class X>
977  inline
978  X&
979  sc_proxy<X>::assign_( unsigned long a )
980  {
981  X& x = back_cast();
982  set_words_( x, 0, (sc_digit)a, SC_DIGIT_ZERO );
983  // extend with zeros
984  extend_sign_w_( x, 1, false );
985  x.clean_tail();
986  return x;
987  }
988 
989  template <class X>
990  inline
991  X&
993  {
994  X& x = back_cast();
995  set_words_( x, 0, (sc_digit) a, SC_DIGIT_ZERO );
996  // extend with sign(a)
997  extend_sign_w_( x, 1, (a < 0) );
998  x.clean_tail();
999  return x;
1000  }
1001 #endif
1002 template <class X>
1003 inline
1004 X&
1006 {
1007  X& x = back_cast();
1008  set_words_( x, 0, ((sc_digit) a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO );
1009  if( x.size() > 1 ) {
1010  set_words_( x, 1,
1011  ((sc_digit) (a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
1012  SC_DIGIT_ZERO );
1013  // extend with zeros
1014  extend_sign_w_( x, 2, false );
1015  }
1016  x.clean_tail();
1017  return x;
1018 }
1019 
1020 template <class X>
1021 inline
1022 X&
1024 {
1025  X& x = back_cast();
1026  set_words_( x, 0, ((sc_digit) a & ~SC_DIGIT_ZERO), SC_DIGIT_ZERO );
1027  if( x.size() > 1 ) {
1028  set_words_( x, 1,
1029  ((sc_digit) ((uint64) a >> SC_DIGIT_SIZE) & ~SC_DIGIT_ZERO),
1030  SC_DIGIT_ZERO );
1031  // extend with sign(a)
1032  extend_sign_w_( x, 2, (a < 0) );
1033  }
1034  x.clean_tail();
1035  return x;
1036 }
1037 
1038 
1039 // bitwise operators and functions
1040 
1041 // bitwise complement
1042 
1043 template <class X>
1044 inline
1045 X&
1047 {
1048  X& x = back_cast();
1049  int sz = x.size();
1050  for( int i = 0; i < sz; ++ i ) {
1051  sc_digit x_dw, x_cw;
1052  get_words_( x, i, x_dw, x_cw );
1053  x.set_word( i, x_cw | ~x_dw );
1054  }
1055  x.clean_tail();
1056  return x;
1057 }
1058 
1059 
1060 // bitwise and
1061 
1062 template <class X, class Y>
1063 inline
1064 X&
1066 {
1067  X& x = px.back_cast();
1068  const Y& y = py.back_cast();
1069  assert( x.length() == y.length() );
1070  int sz = x.size();
1071  for( int i = 0; i < sz; ++ i ) {
1072  sc_digit x_dw, x_cw, y_dw, y_cw;
1073  get_words_( x, i, x_dw, x_cw );
1074  get_words_( y, i, y_dw, y_cw );
1075  sc_digit cw = (x_dw & y_cw) | (x_cw & y_dw) | (x_cw & y_cw);
1076  sc_digit dw = cw | (x_dw & y_dw);
1077  set_words_( x, i, dw, cw );
1078  }
1079  // tail cleaning not needed
1080  return x;
1081 }
1082 
1083 
1084 // bitwise or
1085 
1086 template <class X, class Y>
1087 inline
1088 X&
1090 {
1091  X& x = px.back_cast();
1092  const Y& y = py.back_cast();
1093  assert( x.length() == y.length() );
1094  int sz = x.size();
1095  for( int i = 0; i < sz; ++ i ) {
1096  sc_digit x_dw, x_cw, y_dw, y_cw;
1097  get_words_( x, i, x_dw, x_cw );
1098  get_words_( y, i, y_dw, y_cw );
1099  sc_digit cw = (x_cw & y_cw) | (x_cw & ~y_dw) | (~x_dw & y_cw);
1100  sc_digit dw = cw | x_dw | y_dw;
1101  set_words_( x, i, dw, cw );
1102  }
1103  // tail cleaning not needed
1104  return x;
1105 }
1106 
1107 
1108 // bitwise xor
1109 
1110 template <class X, class Y>
1111 inline
1112 X&
1114 {
1115  X& x = a.back_cast();
1116  const Y& y = b.back_cast();
1117  assert( x.length() == y.length() );
1118  int sz = x.size();
1119  for( int i = 0; i < sz; ++ i ) {
1120  sc_digit x_dw, x_cw, y_dw, y_cw;
1121  get_words_( x, i, x_dw, x_cw );
1122  get_words_( y, i, y_dw, y_cw );
1123  sc_digit cw = x_cw | y_cw;
1124  sc_digit dw = cw | (x_dw ^ y_dw);
1125  set_words_( x, i, dw, cw );
1126  }
1127  // tail cleaning not needed
1128  return x;
1129 }
1130 
1131 
1132 // bitwise left shift
1133 
1134 template <class X>
1135 inline
1136 X&
1138 {
1139  X& x = back_cast();
1140  if( n < 0 ) {
1141  char msg[BUFSIZ];
1142  std::sprintf( msg,
1143  "left shift operation is only allowed with positive "
1144  "shift values, shift value = %d", n );
1146  }
1147  if( n >= x.length() ) {
1148  extend_sign_w_( x, 0, false );
1149  // no tail cleaning needed
1150  return x;
1151  }
1152  int sz = x.size();
1153  int wn = n / SC_DIGIT_SIZE;
1154  int bn = n % SC_DIGIT_SIZE;
1155  if( wn != 0 ) {
1156  // shift words
1157  int i = sz - 1;
1158  for( ; i >= wn; -- i ) {
1159  set_words_( x, i, x.get_word( i - wn ), x.get_cword( i - wn ) );
1160  }
1161  for( ; i >= 0; -- i ) {
1163  }
1164  }
1165  if( bn != 0 ) {
1166  // shift bits
1167  for( int i = sz - 1; i >= 1; -- i ) {
1168  sc_digit x_dw, x_cw;
1169  get_words_( x, i, x_dw, x_cw );
1170  x_dw <<= bn;
1171  x_dw |= x.get_word( i - 1 ) >> (SC_DIGIT_SIZE - bn);
1172  x_cw <<= bn;
1173  x_cw |= x.get_cword( i - 1 ) >> (SC_DIGIT_SIZE - bn);
1174  set_words_( x, i, x_dw, x_cw );
1175  }
1176  sc_digit x_dw, x_cw;
1177  get_words_( x, 0, x_dw, x_cw );
1178  x_dw <<= bn;
1179  x_cw <<= bn;
1180  set_words_( x, 0, x_dw, x_cw );
1181  }
1182  x.clean_tail();
1183  return x;
1184 }
1185 
1186 
1187 // bitwise right shift
1188 
1189 
1190 template <class X>
1191 inline
1192 X&
1194 {
1195  X& x = back_cast();
1196  if( n < 0 ) {
1197  char msg[BUFSIZ];
1198  std::sprintf( msg,
1199  "right shift operation is only allowed with positive "
1200  "shift values, shift value = %d", n );
1202  }
1203  if( n >= x.length() ) {
1204  extend_sign_w_( x, 0, false );
1205  // no tail cleaning needed
1206  return x;
1207  }
1208  int sz = x.size();
1209  int wn = n / SC_DIGIT_SIZE;
1210  int bn = n % SC_DIGIT_SIZE;
1211  if( wn != 0 ) {
1212  // shift words
1213  int i = 0;
1214  for( ; i < (sz - wn); ++ i ) {
1215  set_words_( x, i, x.get_word( i + wn ), x.get_cword( i + wn ) );
1216  }
1217  for( ; i < sz; ++ i ) {
1219  }
1220  }
1221  if( bn != 0 ) {
1222  // shift bits
1223  for( int i = 0; i < (sz - 1); ++ i ) {
1224  sc_digit x_dw, x_cw;
1225  get_words_( x, i, x_dw, x_cw );
1226  x_dw >>= bn;
1227  x_dw |= x.get_word( i + 1 ) << (SC_DIGIT_SIZE - bn);
1228  x_cw >>= bn;
1229  x_cw |= x.get_cword( i + 1 ) << (SC_DIGIT_SIZE - bn);
1230  set_words_( x, i, x_dw, x_cw );
1231  }
1232  sc_digit x_dw, x_cw;
1233  get_words_( x, sz - 1, x_dw, x_cw );
1234  x_dw >>= bn;
1235  x_cw >>= bn;
1236  set_words_( x, sz - 1, x_dw, x_cw );
1237  }
1238  x.clean_tail();
1239  return x;
1240 }
1241 
1242 
1243 // bitwise left rotate
1244 
1245 template <class X>
1246 inline
1247 const sc_lv_base
1248 lrotate( const sc_proxy<X>& x, int n );
1249 
1250 
1251 // bitwise right rotate
1252 
1253 template <class X>
1254 inline
1255 const sc_lv_base
1256 rrotate( const sc_proxy<X>& x, int n );
1257 
1258 
1259 // bitwise reverse
1260 
1261 template <class X>
1262 inline
1263 X&
1265 {
1266  X& x = back_cast();
1267  int len = x.length();
1268  int half_len = len / 2;
1269  for( int i = 0, j = len - 1; i < half_len; ++ i, --j ) {
1270  sc_logic_value_t t = x.get_bit( i );
1271  x.set_bit( i, x.get_bit( j ) );
1272  x.set_bit( j, t );
1273  }
1274  return x;
1275 }
1276 
1277 template <class X>
1278 inline
1279 const sc_lv_base
1280 reverse( const sc_proxy<X>& a );
1281 
1282 
1283 // reduce functions
1284 
1285 template <class X>
1286 inline
1289 {
1290  const X& x = back_cast();
1291  sc_logic_value_t result = sc_logic_value_t( 1 );
1292  int len = x.length();
1293  for( int i = 0; i < len; ++ i ) {
1294  result = sc_logic::and_table[result][x.get_bit( i )];
1295  }
1296  return result;
1297 }
1298 
1299 template <class X>
1300 inline
1303 {
1304  const X& x = back_cast();
1305  sc_logic_value_t result = sc_logic_value_t( 0 );
1306  int len = x.length();
1307  for( int i = 0; i < len; ++ i ) {
1308  result = sc_logic::or_table[result][x.get_bit( i )];
1309  }
1310  return result;
1311 }
1312 
1313 template <class X>
1314 inline
1317 {
1318  const X& x = back_cast();
1319  sc_logic_value_t result = sc_logic_value_t( 0 );
1320  int len = x.length();
1321  for( int i = 0; i < len; ++ i ) {
1322  result = sc_logic::xor_table[result][x.get_bit( i )];
1323  }
1324  return result;
1325 }
1326 
1327 
1328 // relational operators
1329 
1330 template <class X, class Y>
1331 inline
1332 bool
1333 operator != ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
1334 {
1335  return !( px == py );
1336 }
1337 
1338 
1339 #define DEFN_REL_OP_T(tp) \
1340 template <class X> \
1341 inline \
1342 bool \
1343 operator == ( tp b, const sc_proxy<X>& px ) \
1344 { \
1345  return ( px == b ); \
1346 } \
1347  \
1348 template <class X> \
1349 inline \
1350 bool \
1351 operator != ( const sc_proxy<X>& px, tp b ) \
1352 { \
1353  return !( px == b ); \
1354 } \
1355  \
1356 template <class X> \
1357 inline \
1358 bool \
1359 operator != ( tp b, const sc_proxy<X>& px ) \
1360 { \
1361  return !( px == b ); \
1362 }
1363 
1364 DEFN_REL_OP_T(const char*)
1365 DEFN_REL_OP_T(const bool*)
1366 DEFN_REL_OP_T(const sc_logic*)
1367 DEFN_REL_OP_T(const sc_unsigned&)
1368 DEFN_REL_OP_T(const sc_signed&)
1369 DEFN_REL_OP_T(const sc_uint_base&)
1370 DEFN_REL_OP_T(const sc_int_base&)
1371 DEFN_REL_OP_T(unsigned long)
1372 DEFN_REL_OP_T(long)
1373 DEFN_REL_OP_T(unsigned int)
1374 DEFN_REL_OP_T(int)
1377 
1378 #undef DEFN_REL_OP_T
1379 
1380 
1381 // explicit conversions to character string
1382 
1383 template <class X>
1384 inline
1385 const std::string
1387 {
1388  const X& x = back_cast();
1389  int len = x.length();
1390  std::string s; // ( len + 1 );
1391  for( int i = 0; i < len; ++ i ) {
1392  s += sc_logic::logic_to_char[x.get_bit( len - i - 1 )];
1393  }
1394  return s;
1395 }
1396 
1397 template <class X>
1398 inline
1399 const std::string
1401 {
1402  return convert_to_fmt( to_string(), numrep, true );
1403 }
1404 
1405 template <class X>
1406 inline
1407 const std::string
1408 sc_proxy<X>::to_string( sc_numrep numrep, bool w_prefix ) const
1409 {
1410  return convert_to_fmt( to_string(), numrep, w_prefix );
1411 }
1412 
1413 
1414 // other methods
1415 
1416 template <class X>
1417 inline
1418 void
1419 sc_proxy<X>::scan( ::std::istream& is )
1420 {
1421  std::string s;
1422  is >> s;
1423  back_cast() = s.c_str();
1424 }
1425 
1426 
1427 template <class X>
1428 inline
1429 void
1430 sc_proxy<X>::check_bounds( int n ) const // check if bit n accessible
1431 {
1432  if( n < 0 || n >= back_cast().length() ) {
1434  }
1435 }
1436 
1437 template <class X>
1438 inline
1439 void
1440 sc_proxy<X>::check_wbounds( int n ) const // check if word n accessible
1441 {
1442  if( n < 0 || n >= back_cast().size() ) {
1444  }
1445 }
1446 
1447 
1448 template <class X>
1449 inline
1450 sc_digit
1452 {
1453  // only 0 word is returned
1454  // can't convert logic values other than 0 and 1
1455  const X& x = back_cast();
1456  int len = x.length();
1457  if( x.get_cword( 0 ) != SC_DIGIT_ZERO ) {
1458  SC_REPORT_WARNING( sc_core::SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, 0 );
1459  }
1460  sc_digit w = x.get_word( 0 );
1461  if( len >= SC_DIGIT_SIZE ) {
1462  return w;
1463  }
1464  return ( w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)) );
1465 }
1466 
1467 template <class X>
1468 inline
1469 uint64
1471 {
1472  // words 1 and 0 returned.
1473  // can't convert logic values other than 0 and 1
1474  const X& x = back_cast();
1475  int len = x.length();
1476  if( x.get_cword( 0 ) != SC_DIGIT_ZERO ) {
1477  SC_REPORT_WARNING( sc_core::SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, 0 );
1478  }
1479  uint64 w = x.get_word( 0 );
1480  if( len > SC_DIGIT_SIZE )
1481  {
1482  if( x.get_cword( 1 ) != SC_DIGIT_ZERO ) {
1483  SC_REPORT_WARNING( sc_core::SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, 0 );
1484  }
1485  uint64 w1 = x.get_word( 1 );
1486  w = w | (w1 << SC_DIGIT_SIZE);
1487  return w;
1488  }
1489  else if( len == SC_DIGIT_SIZE )
1490  {
1491  return w;
1492  }
1493  else
1494  {
1495  return ( w & (~SC_DIGIT_ZERO >> (SC_DIGIT_SIZE - len)) );
1496  }
1497 }
1498 
1499 template <class X>
1500 inline
1501 int64
1503 {
1504  const X& x = back_cast();
1505  int len = x.length();
1506  int64 w = 0;
1507 
1508  if( len > SC_DIGIT_SIZE )
1509  {
1510  if( x.get_cword( 1 ) != SC_DIGIT_ZERO )
1511  SC_REPORT_WARNING( sc_core::SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, 0 );
1512  w = x.get_word(1);
1513  }
1514  if( x.get_cword( 0 ) != SC_DIGIT_ZERO )
1515  SC_REPORT_WARNING( sc_core::SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, 0 );
1516  w = (w << SC_DIGIT_SIZE) | x.get_word( 0 );
1517  if( len >= 64 ) {
1518  return w;
1519  }
1520 
1521  uint64 zero = 0;
1522  sc_logic_value_t sgn = x.get_bit( len - 1 );
1523  if( sgn == 0 ) {
1524  return (int64)( w & (~zero >> (64 - len)) );
1525  } else {
1526  return (int64)( w | (~zero << len) );
1527  }
1528 }
1529 
1530 
1531 // ----------------------------------------------------------------------------
1532 
1533 // functional notation for the reduce methods
1534 
1535 template <class X>
1536 inline
1539 {
1540  return a.and_reduce();
1541 }
1542 
1543 template <class X>
1544 inline
1547 {
1548  return a.nand_reduce();
1549 }
1550 
1551 template <class X>
1552 inline
1555 {
1556  return a.or_reduce();
1557 }
1558 
1559 template <class X>
1560 inline
1563 {
1564  return a.nor_reduce();
1565 }
1566 
1567 template <class X>
1568 inline
1571 {
1572  return a.xor_reduce();
1573 }
1574 
1575 template <class X>
1576 inline
1579 {
1580  return a.xnor_reduce();
1581 }
1582 
1583 
1584 // ----------------------------------------------------------------------------
1585 
1586 template <class X>
1587 inline
1588 ::std::ostream&
1589 operator << ( ::std::ostream& os, const sc_proxy<X>& a )
1590 {
1591  a.print( os );
1592  return os;
1593 }
1594 
1595 template <class X>
1596 inline
1597 ::std::istream&
1598 operator >> ( ::std::istream& is, sc_proxy<X>& a )
1599 {
1600  a.scan( is );
1601  return is;
1602 }
1603 
1604 } // namespace sc_dt
1605 
1606 
1607 #endif
sc_subref_r< X > range(int hi, int lo) const
Definition: sc_proxy.h:438
int64 to_int64() const
Definition: sc_proxy.h:486
sc_logic_value_t xnor_reduce() const
Definition: sc_proxy.h:456
X & b_and_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:1065
X & assign_(const sc_unsigned &a)
Definition: sc_proxy.h:225
const X & back_cast() const
Definition: sc_proxy.h:211
const sc_bit operator|(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:332
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:213
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:583
const std::string convert_to_fmt(const std::string &s, sc_numrep numrep, bool)
#define DECL_BITWISE_AND_OP_T(tp)
Definition: sc_proxy.h:554
const sc_bit operator^(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:335
X & b_or_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:1089
sc_numrep
Definition: sc_nbdefs.h:91
int64_t int64
Definition: sc_nbdefs.h:182
void set_words_(X &x, int wi, sc_digit x_dw, sc_digit x_cw)
Definition: sc_proxy.h:718
const sc_digit SC_DIGIT_TWO
Definition: sc_proxy.h:96
const std::string to_string() const
Definition: sc_proxy.h:1386
sc_logic_value_t nand_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1546
X & assign_(const sc_int_base &a)
Definition: sc_proxy.h:234
X & operator>>=(int n)
Definition: sc_proxy.h:1193
X & assign_(const sc_signed &a)
Definition: sc_proxy.h:228
sc_logic_value_t xor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1570
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:481
bool sc_io_show_base(systemc_ostream &)
Definition: sc_nbutils.h:112
sc_logic_value_t or_reduce() const
Definition: sc_proxy.h:1302
sc_subref< X > range(int hi, int lo)
Definition: sc_proxy.h:435
virtual ~sc_proxy()
Definition: sc_proxy.h:203
int length() const
Definition: sc_unsigned.h:1226
static const char logic_to_char[4]
Definition: sc_logic.h:155
sc_digit to_anything_unsigned() const
Definition: sc_proxy.h:1451
#define SC_REPORT_WARNING(msg_type, msg)
Definition: sc_report.h:209
X & back_cast()
Definition: sc_proxy.h:208
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1003
unsigned int sc_digit
Definition: sc_nbdefs.h:173
bool operator!=(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:286
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:283
sc_logic_value_t nor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1562
unsigned int to_uint() const
Definition: sc_proxy.h:492
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:379
#define BITS_PER_BYTE
Definition: sc_nbdefs.h:121
#define DECL_BITWISE_XOR_OP_T(tp)
Definition: sc_proxy.h:628
sc_numrep sc_io_base(systemc_ostream &, sc_numrep)
Definition: sc_nbutils.h:107
#define DECL_BITWISE_OR_OP_T(tp)
Definition: sc_proxy.h:591
const sc_digit SC_DIGIT_ONE
Definition: sc_proxy.h:95
sc_proxy_traits< sc_lv_base > traits_type
Definition: sc_proxy.h:143
traits_type::bit_type bit_type
Definition: sc_proxy.h:199
static const sc_logic_value_t xor_table[4][4]
Definition: sc_logic.h:158
inline::std::istream & operator>>(::std::istream &is, sc_bit &a)
Definition: sc_bit.h:394
void assign_v_(sc_proxy< X > &px, const T &a)
Definition: sc_proxy.h:768
int to_int() const
Definition: sc_proxy.h:489
const sc_lv_base operator^(const char *b) const
const sc_lv_base operator~() const
Definition: sc_lv_base.h:367
sc_logic_value_t or_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1554
static const sc_logic_value_t or_table[4][4]
Definition: sc_logic.h:157
int length() const
Definition: sc_signed.h:1326
void get_words_(const X &x, int wi, sc_digit &x_dw, sc_digit &x_cw)
Definition: sc_proxy.h:709
const T sc_min(const T &a, const T &b)
Definition: sc_macros.h:37
X & assign_(const sc_proxy< Y > &a)
Definition: sc_proxy.h:218
int length() const
Definition: sc_int_base.h:766
const sc_digit SC_DIGIT_ZERO
Definition: sc_proxy.h:94
sc_logic_value_t nor_reduce() const
Definition: sc_proxy.h:451
uint64_t uint64
Definition: sc_nbdefs.h:183
X & operator<<=(int n)
Definition: sc_proxy.h:1137
unsigned long to_ulong() const
Definition: sc_proxy.h:498
sc_subref< X > operator()(int hi, int lo)
Definition: sc_proxy.h:429
sc_logic_value_t and_reduce() const
Definition: sc_proxy.h:1288
void assign_p_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:742
X & b_xor_assign_(sc_proxy< X > &a, const sc_proxy< Y > &b)
Definition: sc_proxy.h:1113
const sc_lv_base operator<<(int n) const
Definition: sc_lv_base.h:685
sc_proxy_traits< X >::type traits_type
Definition: sc_proxy.h:198
#define DEFN_REL_OP_T(tp)
Definition: sc_proxy.h:1339
int64 to_anything_signed() const
Definition: sc_proxy.h:1502
bool operator==(const char *b) const
sc_bitref< X > operator[](int i)
Definition: sc_proxy.h:414
const int SC_DIGIT_SIZE
Definition: sc_proxy.h:92
static const sc_logic_value_t char_to_logic[128]
Definition: sc_logic.h:154
X & rrotate(int n)
Definition: sc_lv_base.h:749
void check_bounds(int n) const
Definition: sc_proxy.h:1430
X & operator|=(const char *b)
#define DECL_REL_OP_T(tp)
Definition: sc_proxy.h:664
static const sc_logic_value_t and_table[4][4]
Definition: sc_logic.h:156
void print(::std::ostream &os=::std::cout) const
Definition: sc_proxy.h:514
sc_logic_value_t nand_reduce() const
Definition: sc_proxy.h:446
const std::string convert_to_bin(const char *s)
const sc_lv_base lrotate(const sc_proxy< X > &x, int n)
Definition: sc_lv_base.h:737
X & operator&=(const char *b)
sc_bitref_r< X > bit(int i) const
Definition: sc_proxy.h:423
X & assign_(const sc_uint_base &a)
Definition: sc_proxy.h:231
sc_logic_value_t xnor_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1578
X & lrotate(int n)
Definition: sc_lv_base.h:710
void extend_sign_w_(X &x, int wi, bool sign)
Definition: sc_proxy.h:727
sc_logic_value_t and_reduce(const sc_proxy< X > &a)
Definition: sc_proxy.h:1538
const char SC_ID_OUT_OF_BOUNDS_[]
const sc_lv_base operator&(const char *b) const
const sc_lv_base rrotate(const sc_proxy< X > &x, int n)
Definition: sc_lv_base.h:776
sc_clock period is zero sc_clock low time is zero sc_fifo< T > cannot have more than one writer bind interface to port failed complete binding failed remove port failed insert primitive channel failed sc_signal< T > cannot have more than one driver resolved port not bound to resolved signal sc_semaphore requires an initial value
X & operator^=(const char *b)
sc_logic_value_t xor_reduce() const
Definition: sc_proxy.h:1316
void scan(::std::istream &is=::std::cin)
Definition: sc_proxy.h:1419
static const sc_logic_value_t not_table[4]
Definition: sc_logic.h:159
const sc_lv_base operator|(const char *b) const
const sc_lv_base reverse(const sc_proxy< X > &x)
Definition: sc_lv_base.h:788
sc_bitref< X > bit(int i)
Definition: sc_proxy.h:420
const sc_bit operator&(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:329
const std::string to_string(sc_enc)
const sc_lv_base operator>>(int n) const
Definition: sc_lv_base.h:698
sc_logic_value_t
Definition: sc_logic.h:85
void check_wbounds(int n) const
Definition: sc_proxy.h:1440
long to_long() const
Definition: sc_proxy.h:495
sc_proxy_traits< sc_bv_base > traits_type
Definition: sc_proxy.h:134
int length() const
Definition: sc_uint_base.h:751
uint64 to_uint64() const
Definition: sc_proxy.h:1470