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