SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_lv_base.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_lv_base.h -- Arbitrary size logic vector class.
23
24 Original Author: Gene Bushuyev, Synopsys, Inc.
25
26 *****************************************************************************/
27
28/*****************************************************************************
29
30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31 changes you are making here.
32
33 Name, Affiliation, Date:
34 Description of Modification:
35 Andy Goodrich, Forte Design Systems
36 Fixed bug in clean_tail for sizes that are modulo 32, which caused
37 zeroing of values.
38
39 *****************************************************************************/
40
41// $Log: sc_lv_base.h,v $
42// Revision 1.4 2011/08/26 22:32:00 acg
43// Torsten Maehne: added parentheses to make opearator ordering more obvious.
44//
45// Revision 1.3 2010/01/27 19:41:29 acg
46// Andy Goodrich: fix 8 instances of sc_concref constructor invocations
47// that failed to indicate that their arguments should be freed when the
48// object was freed.
49//
50// Revision 1.2 2009/02/28 00:26:14 acg
51// Andy Goodrich: bug fixes.
52//
53// Revision 1.2 2007/03/14 17:47:49 acg
54// Andy Goodrich: Formatting.
55//
56// Revision 1.1.1.1 2006/12/15 20:31:36 acg
57// SystemC 2.2
58//
59// Revision 1.3 2006/01/13 18:53:53 acg
60// Andy Goodrich: added $Log command so that CVS comments are reproduced in
61// the source.
62//
63
64#ifndef SC_LV_BASE_H
65#define SC_LV_BASE_H
66
67
72
73
74namespace sc_dt
75{
76
77// classes defined in this module
78class sc_lv_base;
79
80
81// ----------------------------------------------------------------------------
82// CLASS : sc_lv_base
83//
84// Arbitrary size logic vector base class.
85// ----------------------------------------------------------------------------
86
88 : public sc_proxy<sc_lv_base>
89{
90 friend class sc_bv_base;
91
92
93 void init( int length_, const sc_logic& init_value = SC_LOGIC_X );
94
95 void assign_from_string( const std::string& );
96
97public:
98
99 // typedefs
100
102 typedef base_type::value_type value_type;
103
104
105 // constructors
106
107 explicit sc_lv_base( int length_ = sc_length_param().len() )
108 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
109 { init( length_ ); }
110
111 explicit sc_lv_base( const sc_logic& a,
112 int length_ = sc_length_param().len() )
113 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
114 { init( length_, a ); }
115
116 sc_lv_base( const char* a );
117
118 sc_lv_base( const char* a, int length_ );
119
120 template <class X>
122 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
123 { init( a.back_cast().length() ); base_type::assign_( a ); }
124
126
127#ifdef SC_DT_DEPRECATED
128
129 explicit sc_lv_base( const sc_unsigned& a )
130 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
131 { init( a.length() ); base_type::assign_( a ); }
132
133 explicit sc_lv_base( const sc_signed& a )
134 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
135 { init( a.length() ); base_type::assign_( a ); }
136
137 explicit sc_lv_base( const sc_uint_base& a )
138 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
139 { init( a.length() ); base_type::assign_( a ); }
140
141 explicit sc_lv_base( const sc_int_base& a )
142 : m_len( 0 ), m_size( 0 ), m_data( 0 ), m_ctrl( 0 )
143 { init( a.length() ); base_type::assign_( a ); }
144
145#endif
146
147
148 // destructor
149
150 virtual ~sc_lv_base()
151 { if ( m_data != m_base_vec ) { delete [] m_data; } }
152
153
154 // assignment operators
155
156 template <class X>
157 sc_lv_base& operator = ( const sc_proxy<X>& a )
158 { assign_p_( *this, a ); return *this; }
159
160 sc_lv_base& operator = ( const sc_lv_base& a )
161 { assign_p_( *this, a ); return *this; }
162
163 sc_lv_base& operator = ( const char* a );
164
165 sc_lv_base& operator = ( const bool* a )
166 { base_type::assign_( a ); return *this; }
167
168 sc_lv_base& operator = ( const sc_logic* a )
169 { base_type::assign_( a ); return *this; }
170
171 sc_lv_base& operator = ( const sc_unsigned& a )
172 { base_type::assign_( a ); return *this; }
173
174 sc_lv_base& operator = ( const sc_signed& a )
175 { base_type::assign_( a ); return *this; }
176
177 sc_lv_base& operator = ( const sc_uint_base& a )
178 { base_type::assign_( a ); return *this; }
179
180 sc_lv_base& operator = ( const sc_int_base& a )
181 { base_type::assign_( a ); return *this; }
182
183 sc_lv_base& operator = ( unsigned long a )
184 { base_type::assign_( a ); return *this; }
185
186 sc_lv_base& operator = ( long a )
187 { base_type::assign_( a ); return *this; }
188
189 sc_lv_base& operator = ( unsigned int a )
190 { base_type::assign_( a ); return *this; }
191
192 sc_lv_base& operator = ( int a )
193 { base_type::assign_( a ); return *this; }
194
195 sc_lv_base& operator = ( uint64 a )
196 { base_type::assign_( a ); return *this; }
197
198 sc_lv_base& operator = ( int64 a )
199 { base_type::assign_( a ); return *this; }
200
201 // common methods
202
203 int length() const
204 { return m_len; }
205
206 int size() const
207 { return m_size; }
208
209 value_type get_bit( int i ) const;
210 void set_bit( int i, value_type value );
211
212 sc_digit get_word( int wi ) const
213 { return m_data[wi]; }
214
215 // note the test for out of range access here. this is necessary
216 // because of the hair-brained way concatenations are set up.
217 // an extend_sign on a concatenation uses the whole length of
218 // the concatenation to determine how many words to set.
219 void set_word( int wi, sc_digit w )
220 { sc_assert ( wi < m_size ); m_data[wi] = w; }
221
222
223 sc_digit get_cword( int wi ) const
224 { return m_ctrl[wi]; }
225
226 void set_cword( int wi, sc_digit w )
227 { sc_assert( wi < m_size ); m_ctrl[wi] = w; }
228
229 void clean_tail();
230
231
232 // other methods
233
234 bool is_01() const;
235
236protected:
237
238 int m_len; // length in bits
239 int m_size; // size of the data array
240 sc_digit* m_data; // data array
241 sc_digit* m_ctrl; // dito (control part)
243};
244
245
246// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
247
248#if 0
249
250// bitwise left rotate
251
252inline
254lrotate( const sc_lv_base& x, int n )
255{
256 sc_lv_base a( x );
257 return a.lrotate( n );
258}
259
260
261// bitwise right rotate
262
263inline
265rrotate( const sc_lv_base& x, int n )
266{
267 sc_lv_base a( x );
268 return a.rrotate( n );
269}
270
271#endif
272
273
274inline
277{
278 int wi = i / SC_DIGIT_SIZE;
279 int bi = i % SC_DIGIT_SIZE;
280 return value_type( ((m_data[wi] >> bi) & SC_DIGIT_ONE) |
281 (((m_ctrl[wi] >> bi) << 1) & SC_DIGIT_TWO) );
282}
283
284inline
285void
287{
288 int wi = i / SC_DIGIT_SIZE; // word index
289 int bi = i % SC_DIGIT_SIZE; // bit index
290 sc_digit mask = SC_DIGIT_ONE << bi;
291 m_data[wi] |= mask; // set bit to 1
292 m_ctrl[wi] |= mask; // set bit to 1
293 m_data[wi] &= (value&1) << bi | ~mask;
294 m_ctrl[wi] &= value >> 1 << bi | ~mask;
295}
296
297
298inline
299void
301{
302 int wi = m_size - 1;
303 int bi = m_len % SC_DIGIT_SIZE;
304 sc_digit mask = ~SC_DIGIT_ZERO;
305 if ( bi != 0 ) { mask = mask >> (SC_DIGIT_SIZE - bi); }
306 if ( mask )
307 {
308 m_data[wi] &= mask;
309 m_ctrl[wi] &= mask;
310 }
311}
312
313
314// ----------------------------------------------------------------------------
315// CLASS TEMPLATE : sc_proxy
316//
317// Base class template for bit/logic vector classes.
318// (Barton/Nackmann implementation)
319// ----------------------------------------------------------------------------
320
321// bitwise operators and functions
322
323// bitwise complement
324
325template <class X>
326inline
329{
330 sc_lv_base a( back_cast() );
331 return a.b_not();
332}
333
334
335// bitwise and
336
337template <class X, class Y>
338inline
339X&
341{
342 X& x = px.back_cast();
343 sc_lv_base a( x.length() );
344 a = py.back_cast();
345 return b_and_assign_( x, a );
346}
347
348
349#define DEFN_BITWISE_AND_ASN_OP_T(tp) \
350template <class X> \
351inline \
352X& \
353sc_proxy<X>::operator &= ( tp b ) \
354{ \
355 X& x = back_cast(); \
356 sc_lv_base a( x.length() ); \
357 a = b; \
358 return b_and_assign_( x, a ); \
359}
360
361DEFN_BITWISE_AND_ASN_OP_T(const char*)
362DEFN_BITWISE_AND_ASN_OP_T(const bool*)
364DEFN_BITWISE_AND_ASN_OP_T(const sc_unsigned&)
365DEFN_BITWISE_AND_ASN_OP_T(const sc_signed&)
366DEFN_BITWISE_AND_ASN_OP_T(unsigned long)
370
371#undef DEFN_BITWISE_AND_ASN_OP_T
372
373
374template <class X, class Y>
375inline
376sc_lv_base
377operator & ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
378{
379 const X& x = px.back_cast();
380 const Y& y = py.back_cast();
381 if ( x.length() >= y.length() ) {
382 sc_lv_base a( x );
383 return ( a &= y );
384 }
385 else {
386 sc_lv_base a( y );
387 return ( a &= x );
388 }
389}
391#define DEFN_BITWISE_AND_OP_T_NATIVE(tp) \
392template <class X> \
393inline \
394sc_lv_base \
395sc_proxy<X>::operator & ( tp b ) const \
396{ \
397 sc_lv_base x( back_cast() ); \
398 return ( x &= b ); \
399}
400DEFN_BITWISE_AND_OP_T_NATIVE(unsigned long)
406#undef DEFN_BITWISE_AND_OP_T_NATIVE
408#define DEFN_BITWISE_AND_OP_T_SYSTEMC(tp) \
409template <class X> \
410inline \
411sc_lv_base \
412sc_proxy<X>::operator & ( tp b ) const \
413{ \
414 sc_lv_base x( back_cast() ); \
415 sc_lv_base y( b.length() ); \
416 y = b; \
417 return ( x & y ); \
418}
419DEFN_BITWISE_AND_OP_T_SYSTEMC(const sc_unsigned&)
420DEFN_BITWISE_AND_OP_T_SYSTEMC(const sc_signed&)
421DEFN_BITWISE_AND_OP_T_SYSTEMC(const sc_uint_base&)
422DEFN_BITWISE_AND_OP_T_SYSTEMC(const sc_int_base&)
423#undef DEFN_BITWISE_AND_OP_T_SYSTEMC
424
425
426#define DEFN_BITWISE_AND_OP_T_A(tp) \
427template <class X> \
428inline \
429sc_lv_base \
430sc_proxy<X>::operator & ( tp b ) const \
431{ \
432 sc_lv_base a( back_cast() ); \
433 return ( a &= b ); \
434}
435
436DEFN_BITWISE_AND_OP_T_A(const char*)
437DEFN_BITWISE_AND_OP_T_A(const bool*)
439
440#undef DEFN_BITWISE_AND_OP_T_A
441
442
443#define DEFN_BITWISE_AND_OP_T_B(tp) \
444template <class X> \
445inline \
446sc_lv_base \
447operator & ( tp b, const sc_proxy<X>& px ) \
448{ \
449 return ( px & b ); \
450}
451
452DEFN_BITWISE_AND_OP_T_B(const char*)
453DEFN_BITWISE_AND_OP_T_B(const bool*)
455DEFN_BITWISE_AND_OP_T_B(const sc_unsigned&)
456DEFN_BITWISE_AND_OP_T_B(const sc_signed&)
457DEFN_BITWISE_AND_OP_T_B(const sc_uint_base&)
458DEFN_BITWISE_AND_OP_T_B(const sc_int_base&)
459DEFN_BITWISE_AND_OP_T_B(unsigned long)
461DEFN_BITWISE_AND_OP_T_B(unsigned int)
465
466#undef DEFN_BITWISE_AND_OP_T_B
467
468
469// bitwise or
470
471template <class X, class Y>
472inline
473X&
475{
476 X& x = px.back_cast();
477 sc_lv_base a( x.length() );
478 a = py.back_cast();
479 return b_or_assign_( x, a );
480}
481
482
483#define DEFN_BITWISE_OR_ASN_OP_T(tp) \
484template <class X> \
485inline \
486X& \
487sc_proxy<X>::operator |= ( tp b ) \
488{ \
489 X& x = back_cast(); \
490 sc_lv_base a( x.length() ); \
491 a = b; \
492 return b_or_assign_( x, a ); \
493}
494
495DEFN_BITWISE_OR_ASN_OP_T(const char*)
496DEFN_BITWISE_OR_ASN_OP_T(const bool*)
498DEFN_BITWISE_OR_ASN_OP_T(const sc_unsigned&)
499DEFN_BITWISE_OR_ASN_OP_T(const sc_signed&)
500DEFN_BITWISE_OR_ASN_OP_T(unsigned long)
504
505#undef DEFN_BITWISE_OR_ASN_OP_T
506
507
508template <class X, class Y>
509inline
510sc_lv_base
511operator | ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
512{
513 const X& x = px.back_cast();
514 const Y& y = py.back_cast();
515 if ( x.length() >= y.length() ) {
516 sc_lv_base a( x );
517 return ( a |= y );
518 }
519 else {
520 sc_lv_base a( y );
521 return ( a |= x );
522 }
523}
524
525#define DEFN_BITWISE_OR_OP_T_NATIVE(tp) \
526template <class X> \
527inline \
528sc_lv_base \
529sc_proxy<X>::operator | ( tp b ) const \
530{ \
531 sc_lv_base x( back_cast() ); \
532 if ( sizeof(tp)*8 > static_cast<unsigned>(x.length()) ) { \
533 sc_lv_base y( sizeof(tp)*8 ); \
534 y = x; \
535 return y |= b; \
536 } else { \
537 return ( x |= b ); \
538 } \
539}
540DEFN_BITWISE_OR_OP_T_NATIVE(unsigned long)
542DEFN_BITWISE_OR_OP_T_NATIVE(unsigned int)
546#undef DEFN_BITWISE_OR_OP_T_NATIVE
547
548#define DEFN_BITWISE_OR_OP_T_SYSTEMC(tp) \
549template <class X> \
550inline \
551sc_lv_base \
552sc_proxy<X>::operator | ( tp b ) const \
553{ \
554 sc_lv_base x( back_cast() ); \
555 sc_lv_base y( b.length() ); \
556 y = b; \
557 return ( x | y ); \
558}
559DEFN_BITWISE_OR_OP_T_SYSTEMC(const sc_unsigned&)
560DEFN_BITWISE_OR_OP_T_SYSTEMC(const sc_signed&)
561DEFN_BITWISE_OR_OP_T_SYSTEMC(const sc_uint_base&)
562DEFN_BITWISE_OR_OP_T_SYSTEMC(const sc_int_base&)
563#undef DEFN_BITWISE_OR_OP_T_SYSTEMC
564
565#define DEFN_BITWISE_OR_OP_T_A(tp) \
566template <class X> \
567inline \
568sc_lv_base \
569sc_proxy<X>::operator | ( tp b ) const \
570{ \
571 sc_lv_base a( back_cast() ); \
572 return ( a |= b ); \
573}
574
575DEFN_BITWISE_OR_OP_T_A(const char*)
576DEFN_BITWISE_OR_OP_T_A(const bool*)
578
579#undef DEFN_BITWISE_OR_OP_T_A
580
581
582#define DEFN_BITWISE_OR_OP_T_B(tp) \
583template <class X> \
584inline \
585sc_lv_base \
586operator | ( tp b, const sc_proxy<X>& px ) \
587{ \
588 return ( px | b ); \
589}
590
591DEFN_BITWISE_OR_OP_T_B(const char*)
592DEFN_BITWISE_OR_OP_T_B(const bool*)
594DEFN_BITWISE_OR_OP_T_B(const sc_unsigned&)
595DEFN_BITWISE_OR_OP_T_B(const sc_signed&)
596DEFN_BITWISE_OR_OP_T_B(const sc_uint_base&)
597DEFN_BITWISE_OR_OP_T_B(const sc_int_base&)
598DEFN_BITWISE_OR_OP_T_B(unsigned long)
600DEFN_BITWISE_OR_OP_T_B(unsigned int)
604
605#undef DEFN_BITWISE_OR_OP_T_B
606
607
608// bitwise xor
609
610template <class X, class Y>
611inline
612X&
614{
615 X& x = px.back_cast();
616 sc_lv_base a( x.length() );
617 a = py.back_cast();
618 return b_xor_assign_( x, a );
619}
620
621
622#define DEFN_BITWISE_XOR_ASN_OP_T(tp) \
623template <class X> \
624inline \
625X& \
626sc_proxy<X>::operator ^= ( tp b ) \
627{ \
628 X& x = back_cast(); \
629 sc_lv_base a( x.length() ); \
630 a = b; \
631 return b_xor_assign_( x, a ); \
632}
633
634DEFN_BITWISE_XOR_ASN_OP_T(const char*)
635DEFN_BITWISE_XOR_ASN_OP_T(const bool*)
637DEFN_BITWISE_XOR_ASN_OP_T(const sc_unsigned&)
638DEFN_BITWISE_XOR_ASN_OP_T(const sc_signed&)
639DEFN_BITWISE_XOR_ASN_OP_T(unsigned long)
643
644#undef DEFN_BITWISE_XOR_ASN_OP_T
645
646
647template <class X, class Y>
648inline
649sc_lv_base
650operator ^ ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
651{
652 const X& x = px.back_cast();
653 const Y& y = py.back_cast();
654 if ( x.length() >= y.length() ) {
655 sc_lv_base a( x );
656 return ( a ^= y );
657 }
658 else {
659 sc_lv_base a( y );
660 return ( a ^= x );
661 }
662}
663
664#define DEFN_BITWISE_XOR_OP_T_NATIVE(tp) \
665template <class X> \
666inline \
667sc_lv_base \
668sc_proxy<X>::operator ^ ( tp b ) const \
669{ \
670 sc_lv_base x( back_cast() ); \
671 if ( sizeof(tp)*8 > static_cast<unsigned>(x.length()) ) { \
672 sc_lv_base y( sizeof(tp)*8 ); \
673 y = x; \
674 return y ^= b; \
675 } else { \
676 return ( x ^= b ); \
677 } \
678}
679DEFN_BITWISE_XOR_OP_T_NATIVE(unsigned long)
685#undef DEFN_BITWISE_XOR_OP_T_NATIVE
686
687#define DEFN_BITWISE_XOR_OP_T_SYSTEMC(tp) \
688template <class X> \
689inline \
690sc_lv_base \
691sc_proxy<X>::operator ^ ( tp b ) const \
692{ \
693 sc_lv_base x( back_cast() ); \
694 sc_lv_base y( b.length() ); \
695 y = b; \
696 return ( x ^ y ); \
697}
698DEFN_BITWISE_XOR_OP_T_SYSTEMC(const sc_unsigned&)
699DEFN_BITWISE_XOR_OP_T_SYSTEMC(const sc_signed&)
700DEFN_BITWISE_XOR_OP_T_SYSTEMC(const sc_uint_base&)
701DEFN_BITWISE_XOR_OP_T_SYSTEMC(const sc_int_base&)
702#undef DEFN_BITWISE_XOR_OP_T_SYSTEMC
703
704
705#define DEFN_BITWISE_XOR_OP_T_A(tp) \
706template <class X> \
707inline \
708sc_lv_base \
709sc_proxy<X>::operator ^ ( tp b ) const \
710{ \
711 sc_lv_base a( back_cast() ); \
712 return ( a ^= b ); \
713}
714
715DEFN_BITWISE_XOR_OP_T_A(const char*)
716DEFN_BITWISE_XOR_OP_T_A(const bool*)
718
719#undef DEFN_BITWISE_XOR_OP_T_A
720
721
722#define DEFN_BITWISE_XOR_OP_T_B(tp) \
723template <class X> \
724inline \
725sc_lv_base \
726operator ^ ( tp b, const sc_proxy<X>& px ) \
727{ \
728 return ( px ^ b ); \
729}
730
731DEFN_BITWISE_XOR_OP_T_B(const char*)
732DEFN_BITWISE_XOR_OP_T_B(const bool*)
734DEFN_BITWISE_XOR_OP_T_B(const sc_unsigned&)
735DEFN_BITWISE_XOR_OP_T_B(const sc_signed&)
736DEFN_BITWISE_XOR_OP_T_B(const sc_uint_base&)
737DEFN_BITWISE_XOR_OP_T_B(const sc_int_base&)
738DEFN_BITWISE_XOR_OP_T_B(unsigned long)
740DEFN_BITWISE_XOR_OP_T_B(unsigned int)
744
745#undef DEFN_BITWISE_XOR_OP_T_B
746
747
748// bitwise left shift
749
750template <class X>
751inline
753sc_proxy<X>::operator << ( int n ) const
754{
755 sc_lv_base a( back_cast().length()+n );
756 a = back_cast();
757 return ( a <<= n );
758}
759
760
761// bitwise right shift
762
763template <class X>
764inline
767{
768 sc_lv_base a( back_cast() );
769 return ( a >>= n );
770}
771
772
773// bitwise left rotate
774
775template <class X>
776inline
777X&
779{
780 X& x = back_cast();
781 if( n < 0 ) {
782 sc_proxy_out_of_bounds( "left rotate operation is only allowed with "
783 "positive rotate values, rotate value = ", n );
784 return x;
785 }
786 int len = x.length();
787 n %= len;
788 // x = (x << n) | (x >> (len - n));
789 sc_lv_base a( x << n );
790 sc_lv_base b( x >> (len - n) );
791 int sz = x.size();
792 for( int i = 0; i < sz; ++ i ) {
793 x.set_word( i, a.get_word( i ) | b.get_word( i ) );
794 x.set_cword( i, a.get_cword( i ) | b.get_cword( i ) );
795 }
796 x.clean_tail();
797 return x;
798}
799
800template <class X>
801inline
803lrotate( const sc_proxy<X>& x, int n )
804{
805 sc_lv_base a( x.back_cast() );
806 return a.lrotate( n );
807}
808
809
810// bitwise right rotate
811
812template <class X>
813inline
814X&
816{
817 X& x = back_cast();
818 if( n < 0 ) {
819 sc_proxy_out_of_bounds( "right rotate operation is only allowed with "
820 "positive rotate values, rotate value = ", n );
821 return x;
822 }
823 int len = x.length();
824 n %= len;
825 // x = (x >> n) | (x << (len - n));
826 sc_lv_base a( x >> n );
827 sc_lv_base b( x << (len - n) );
828 int sz = x.size();
829 for( int i = 0; i < sz; ++ i ) {
830 x.set_word( i, a.get_word( i ) | b.get_word( i ) );
831 x.set_cword( i, a.get_cword( i ) | b.get_cword( i ) );
832 }
833 x.clean_tail();
834 return x;
835}
836
837template <class X>
838inline
840rrotate( const sc_proxy<X>& x, int n )
841{
842 sc_lv_base a( x.back_cast() );
843 return a.rrotate( n );
844}
845
846
847// bitwise reverse
848
849template <class X>
850inline
851sc_lv_base
853{
854 sc_lv_base a( x.back_cast() );
855 return a.reverse();
856}
857
858
859// relational operators
860
861template <class X, class Y>
862inline
863bool
864operator == ( const sc_proxy<X>& px, const sc_proxy<Y>& py )
865{
866 const X& x = px.back_cast();
867 const Y& y = py.back_cast();
868 int x_len = x.length();
869 int y_len = y.length();
870 if( x_len != y_len ) {
871 return false;
872 }
873 int sz = x.size();
874 for( int i = 0; i < sz; ++ i ) {
875 if( x.get_word( i ) != y.get_word( i ) ||
876 x.get_cword( i ) != y.get_cword( i ) ) {
877 return false;
878 }
879 }
880 return true;
881}
882
883
884#define DEFN_REL_OP_T(tp) \
885template <class X> \
886inline \
887bool \
888sc_proxy<X>::operator == ( tp b ) const \
889{ \
890 const X& x = back_cast(); \
891 sc_lv_base y( x.length() ); \
892 y = b; \
893 return ( x == y ); \
894}
895
896DEFN_REL_OP_T(const char*)
897DEFN_REL_OP_T(const bool*)
899DEFN_REL_OP_T(const sc_unsigned&)
900DEFN_REL_OP_T(const sc_signed&)
901DEFN_REL_OP_T(const sc_uint_base&)
902DEFN_REL_OP_T(const sc_int_base&)
903DEFN_REL_OP_T(unsigned long)
904DEFN_REL_OP_T(long)
905DEFN_REL_OP_T(unsigned int)
906DEFN_REL_OP_T(int)
909
910#undef DEFN_REL_OP_T
911
912
913// ----------------------------------------------------------------------------
914// CLASS TEMPLATE : sc_bitref_r<X>
915//
916// Proxy class for sc_proxy bit selection (r-value only).
917// ----------------------------------------------------------------------------
918
919// r-value concatenation operators and functions
920
921template <class T>
922inline
923sc_concref_r<sc_bitref_r<T>,sc_lv_base>
924operator , ( sc_bitref_r<T> a, const char* b )
925{
927 *a.clone(), *new sc_lv_base( b ), 3 );
928}
929
930template <class T>
931inline
932sc_concref_r<sc_lv_base,sc_bitref_r<T> >
933operator , ( const char* a, sc_bitref_r<T> b )
934{
936 *new sc_lv_base( a ), *b.clone(), 3 );
937}
938
939template <class T>
940inline
941sc_concref_r<sc_bitref_r<T>,sc_lv_base>
943{
945 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
946}
947
948template <class T>
949inline
950sc_concref_r<sc_lv_base,sc_bitref_r<T> >
952{
954 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
955}
956
957template <class T>
958inline
959sc_concref_r<sc_bitref_r<T>,sc_bv_base>
961{
963 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
964}
965
966template <class T>
967inline
968sc_concref_r<sc_bv_base,sc_bitref_r<T> >
970{
972 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
973}
974
975
976template <class T>
977inline
978sc_concref_r<sc_bitref_r<T>,sc_lv_base>
979concat( sc_bitref_r<T> a, const char* b )
980{
982 *a.clone(), *new sc_lv_base( b ), 3 );
983}
984
985template <class T>
986inline
987sc_concref_r<sc_lv_base,sc_bitref_r<T> >
988concat( const char* a, sc_bitref_r<T> b )
989{
991 *new sc_lv_base( a ), *b.clone(), 3 );
992}
993
994template <class T>
995inline
996sc_concref_r<sc_bitref_r<T>,sc_lv_base>
998{
1000 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1001}
1002
1003template <class T>
1004inline
1005sc_concref_r<sc_lv_base,sc_bitref_r<T> >
1007{
1009 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1010}
1011
1012template <class T>
1013inline
1014sc_concref_r<sc_bitref_r<T>,sc_bv_base>
1016{
1018 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1019}
1020
1021template <class T>
1022inline
1023sc_concref_r<sc_bv_base,sc_bitref_r<T> >
1025{
1027 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1028}
1029
1030
1031#ifdef SC_DT_MIXED_COMMA_OPERATORS
1032
1033template <class T>
1034inline
1035sc_concref_r<sc_bitref_r<T>,sc_lv_base>
1036operator , ( sc_bitref<T> a, const char* b )
1037{
1039 *a.clone(), *new sc_lv_base( b ), 3 );
1040}
1041
1042template <class T>
1043inline
1044sc_concref_r<sc_lv_base,sc_bitref_r<T> >
1045operator , ( const char* a, sc_bitref<T> b )
1046{
1048 *new sc_lv_base( a ), *b.clone(), 3 );
1049}
1050
1051template <class T>
1052inline
1053sc_concref_r<sc_bitref_r<T>,sc_lv_base>
1055{
1057 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1058}
1059
1060template <class T>
1061inline
1062sc_concref_r<sc_lv_base,sc_bitref_r<T> >
1064{
1066 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1067}
1068
1069template <class T>
1070inline
1071sc_concref_r<sc_bitref_r<T>,sc_bv_base>
1073{
1075 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1076}
1077
1078template <class T>
1079inline
1080sc_concref_r<sc_bv_base,sc_bitref_r<T> >
1082{
1084 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1085}
1086
1087
1088template <class T>
1089inline
1090sc_concref_r<sc_bitref_r<T>,sc_lv_base>
1091concat( sc_bitref<T> a, const char* b )
1092{
1094 *a.clone(), *new sc_lv_base( b ), 3 );
1095}
1096
1097template <class T>
1098inline
1099sc_concref_r<sc_lv_base,sc_bitref_r<T> >
1100concat( const char* a, sc_bitref<T> b )
1101{
1103 *new sc_lv_base( a ), *b.clone(), 3 );
1104}
1105
1106template <class T>
1107inline
1108sc_concref_r<sc_bitref_r<T>,sc_lv_base>
1110{
1112 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1113}
1114
1115template <class T>
1116inline
1117sc_concref_r<sc_lv_base,sc_bitref_r<T> >
1119{
1121 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1122}
1123
1124template <class T>
1125inline
1126sc_concref_r<sc_bitref_r<T>,sc_bv_base>
1128{
1130 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1131}
1132
1133template <class T>
1134inline
1135sc_concref_r<sc_bv_base,sc_bitref_r<T> >
1137{
1139 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1140}
1141
1142#endif
1143
1144
1145// ----------------------------------------------------------------------------
1146// CLASS TEMPLATE : sc_subref_r<X>
1147//
1148// Proxy class for sc_proxy part selection (r-value only).
1149// ----------------------------------------------------------------------------
1150
1151// r-value concatenation operators and functions
1152
1153template <class T>
1154inline
1155sc_concref_r<sc_subref_r<T>,sc_lv_base>
1157{
1159 *a.clone(), *new sc_lv_base( b ), 3 );
1160}
1161
1162template <class T>
1163inline
1164sc_concref_r<sc_lv_base,sc_subref_r<T> >
1166{
1168 *new sc_lv_base( a ), *b.clone(), 3 );
1169}
1170
1171template <class T>
1172inline
1173sc_concref_r<sc_subref_r<T>,sc_lv_base>
1175{
1177 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1178}
1179
1180template <class T>
1181inline
1182sc_concref_r<sc_lv_base,sc_subref_r<T> >
1184{
1186 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1187}
1188
1189template <class T>
1190inline
1191sc_concref_r<sc_subref_r<T>,sc_bv_base>
1193{
1195 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1196}
1197
1198template <class T>
1199inline
1200sc_concref_r<sc_bv_base,sc_subref_r<T> >
1202{
1204 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1205}
1206
1207
1208template <class T>
1209inline
1210sc_concref_r<sc_subref_r<T>,sc_lv_base>
1211concat( sc_subref_r<T> a, const char* b )
1212{
1214 *a.clone(), *new sc_lv_base( b ), 3 );
1215}
1216
1217template <class T>
1218inline
1219sc_concref_r<sc_lv_base,sc_subref_r<T> >
1220concat( const char* a, sc_subref_r<T> b )
1221{
1223 *new sc_lv_base( a ), *b.clone(), 3 );
1224}
1225
1226template <class T>
1227inline
1228sc_concref_r<sc_subref_r<T>,sc_lv_base>
1230{
1232 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1233}
1234
1235template <class T>
1236inline
1237sc_concref_r<sc_lv_base,sc_subref_r<T> >
1239{
1241 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1242}
1243
1244template <class T>
1245inline
1246sc_concref_r<sc_subref_r<T>,sc_bv_base>
1248{
1250 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1251}
1252
1253template <class T>
1254inline
1255sc_concref_r<sc_bv_base,sc_subref_r<T> >
1257{
1259 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1260}
1261
1262
1263#ifdef SC_DT_MIXED_COMMA_OPERATORS
1264
1265template <class T>
1266inline
1267sc_concref_r<sc_subref_r<T>,sc_lv_base>
1268operator , ( sc_subref<T> a, const char* b )
1269{
1271 *a.clone(), *new sc_lv_base( b ), 3 );
1272}
1273
1274template <class T>
1275inline
1276sc_concref_r<sc_lv_base,sc_subref_r<T> >
1277operator , ( const char* a, sc_subref<T> b )
1278{
1280 *new sc_lv_base( a ), *b.clone(), 3 );
1281}
1282
1283template <class T>
1284inline
1285sc_concref_r<sc_subref_r<T>,sc_lv_base>
1287{
1289 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1290}
1291
1292template <class T>
1293inline
1294sc_concref_r<sc_lv_base,sc_subref_r<T> >
1296{
1298 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1299}
1300
1301template <class T>
1302inline
1303sc_concref_r<sc_subref_r<T>,sc_bv_base>
1305{
1307 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1308}
1309
1310template <class T>
1311inline
1312sc_concref_r<sc_bv_base,sc_subref_r<T> >
1314{
1316 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1317}
1318
1319
1320template <class T>
1321inline
1322sc_concref_r<sc_subref_r<T>,sc_lv_base>
1323concat( sc_subref<T> a, const char* b )
1324{
1326 *a.clone(), *new sc_lv_base( b ), 3 );
1327}
1328
1329template <class T>
1330inline
1331sc_concref_r<sc_lv_base,sc_subref_r<T> >
1332concat( const char* a, sc_subref<T> b )
1333{
1335 *new sc_lv_base( a ), *b.clone(), 3 );
1336}
1337
1338template <class T>
1339inline
1340sc_concref_r<sc_subref_r<T>,sc_lv_base>
1342{
1344 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1345}
1346
1347template <class T>
1348inline
1349sc_concref_r<sc_lv_base,sc_subref_r<T> >
1351{
1353 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1354}
1355
1356template <class T>
1357inline
1358sc_concref_r<sc_subref_r<T>,sc_bv_base>
1360{
1362 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1363}
1364
1365template <class T>
1366inline
1367sc_concref_r<sc_bv_base,sc_subref_r<T> >
1369{
1371 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1372}
1373
1374#endif
1375
1376
1377// ----------------------------------------------------------------------------
1378// CLASS TEMPLATE : sc_subref<X>
1379//
1380// Proxy class for sc_proxy part selection (r-value and l-value).
1381// ----------------------------------------------------------------------------
1382
1383template <class X>
1384inline
1385sc_subref<X>&
1387{
1388 sc_lv_base t( b ); // (partial) self assignment protection
1389 int len = sc_min( this->length(), t.length() );
1390 if( ! this->reversed() ) {
1391 for( int i = len - 1; i >= 0; -- i ) {
1392 this->m_obj.set_bit( this->m_lo + i, t[i].value() );
1393 }
1394 } else {
1395 for( int i = len - 1; i >= 0; -- i ) {
1396 this->m_obj.set_bit( this->m_lo - i, t[i].value() );
1397 }
1398 }
1399 return *this;
1400}
1401
1402template <class X>
1403inline
1406{
1407 sc_lv_base t( b ); // (partial) self assignment protection
1408 int len = sc_min( this->length(), t.length() );
1409 if( ! this->reversed() ) {
1410 for( int i = len - 1; i >= 0; -- i ) {
1411 this->m_obj.set_bit( this->m_lo + i, t[i].value() );
1412 }
1413 } else {
1414 for( int i = len - 1; i >= 0; -- i ) {
1415 this->m_obj.set_bit( this->m_lo - i, t[i].value() );
1416 }
1417 }
1418 return *this;
1419}
1420
1421
1422// ----------------------------------------------------------------------------
1423// CLASS TEMPLATE : sc_concref_r<X,Y>
1424//
1425// Proxy class for sc_proxy concatenation (r-value only).
1426// ----------------------------------------------------------------------------
1427
1428// r-value concatenation operators and functions
1429
1430template <class T1, class T2>
1431inline
1434{
1436 *a.clone(), *new sc_lv_base( b ), 3 );
1437}
1438
1439template <class T1, class T2>
1440inline
1441sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1443{
1445 *new sc_lv_base( a ), *b.clone(), 3 );
1446}
1447
1448template <class T1, class T2>
1449inline
1450sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1452{
1454 *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1455}
1456
1457template <class T1, class T2>
1458inline
1459sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1461{
1463 *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1464}
1465
1466template <class T1, class T2>
1467inline
1468sc_concref_r<sc_concref_r<T1,T2>,sc_bv_base>
1470{
1472 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1473}
1474
1475template <class T1, class T2>
1476inline
1477sc_concref_r<sc_bv_base,sc_concref_r<T1,T2> >
1479{
1481 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1482}
1483
1484
1485template <class T1, class T2>
1486inline
1487sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1489{
1491 ( *a.clone(), *new sc_lv_base( b ), 3 );
1492}
1493
1494template <class T1, class T2>
1495inline
1496sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1498{
1500 ( *new sc_lv_base( a ), *b.clone(), 3 );
1501}
1502
1503template <class T1, class T2>
1504inline
1505sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1507{
1509 ( *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1510}
1511
1512template <class T1, class T2>
1513inline
1514sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1516{
1518 ( *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1519}
1520
1521template <class T1, class T2>
1522inline
1523sc_concref_r<sc_concref_r<T1,T2>,sc_bv_base>
1525{
1527 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1528}
1529
1530template <class T1, class T2>
1531inline
1532sc_concref_r<sc_bv_base,sc_concref_r<T1,T2> >
1534{
1536 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1537}
1538
1539
1540#ifdef SC_DT_MIXED_COMMA_OPERATORS
1541
1542template <class T1, class T2>
1543inline
1544sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1546{
1548 ( *a.clone(), *new sc_lv_base( b ), 3 );
1549}
1550
1551template <class T1, class T2>
1552inline
1553sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1555{
1557 ( *new sc_lv_base( a ), *b.clone(), 3 );
1558}
1559
1560template <class T1, class T2>
1561inline
1562sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1564{
1566 ( *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1567}
1568
1569template <class T1, class T2>
1570inline
1571sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1573{
1575 ( *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1576}
1577
1578template <class T1, class T2>
1579inline
1580sc_concref_r<sc_concref_r<T1,T2>,sc_bv_base>
1582{
1584 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1585}
1586
1587template <class T1, class T2>
1588inline
1589sc_concref_r<sc_bv_base,sc_concref_r<T1,T2> >
1591{
1593 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1594}
1595
1596
1597template <class T1, class T2>
1598inline
1599sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1600concat( sc_concref<T1,T2> a, const char* b )
1601{
1603 ( *a.clone(), *new sc_lv_base( b ), 3 );
1604}
1605
1606template <class T1, class T2>
1607inline
1608sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1609concat( const char* a, sc_concref<T1,T2> b )
1610{
1612 ( *new sc_lv_base( a ), *b.clone(), 3 );
1613}
1614
1615template <class T1, class T2>
1616inline
1617sc_concref_r<sc_concref_r<T1,T2>,sc_lv_base>
1619{
1621 ( *a.clone(), *new sc_lv_base( b, 1 ), 3 );
1622}
1623
1624template <class T1, class T2>
1625inline
1626sc_concref_r<sc_lv_base,sc_concref_r<T1,T2> >
1628{
1630 ( *new sc_lv_base( a, 1 ), *b.clone(), 3 );
1631}
1632
1633template <class T1, class T2>
1634inline
1635sc_concref_r<sc_concref_r<T1,T2>,sc_bv_base>
1637{
1639 ( *a.clone(), *new sc_bv_base( b, 1 ), 3 );
1640}
1641
1642template <class T1, class T2>
1643inline
1644sc_concref_r<sc_bv_base,sc_concref_r<T1,T2> >
1646{
1648 ( *new sc_bv_base( a, 1 ), *b.clone(), 3 );
1649}
1650
1651#endif
1652
1653
1654// ----------------------------------------------------------------------------
1655// CLASS TEMPLATE : sc_proxy<T>
1656//
1657// Base class template for bit/logic vector classes.
1658// (Barton/Nackmann implementation)
1659// ----------------------------------------------------------------------------
1660
1661// r-value concatenation operators and functions
1662
1663template <class T>
1664inline
1665sc_concref_r<T,sc_lv_base>
1666operator , ( const sc_proxy<T>& a, const char* b )
1667{
1669 ( a.back_cast(), *new sc_lv_base( b ), 2 );
1670}
1671
1672template <class T>
1673inline
1674sc_concref_r<sc_lv_base,T>
1675operator , ( const char* a, const sc_proxy<T>& b )
1676{
1678 ( *new sc_lv_base( a ), b.back_cast(), 1 );
1679}
1680
1681template <class T>
1682inline
1683sc_concref_r<T,sc_lv_base>
1685{
1687 ( a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
1688}
1689
1690template <class T>
1691inline
1692sc_concref_r<sc_lv_base,T>
1694{
1696 ( *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
1697}
1698
1699template <class T>
1700inline
1701sc_concref_r<T,sc_bv_base>
1702operator , ( const sc_proxy<T>& a, bool b )
1703{
1705 ( a.back_cast(), *new sc_bv_base( b, 1 ), 2 );
1706}
1707
1708template <class T>
1709inline
1710sc_concref_r<sc_bv_base,T>
1711operator , ( bool a, const sc_proxy<T>& b )
1712{
1714 ( *new sc_bv_base( a, 1 ), b.back_cast(), 1 );
1715}
1716
1717
1718template <class T>
1719inline
1720sc_concref_r<T,sc_lv_base>
1721concat( const sc_proxy<T>& a, const char* b )
1722{
1724 ( a.back_cast(), *new sc_lv_base( b ), 2 );
1725}
1726
1727template <class T>
1728inline
1729sc_concref_r<sc_lv_base,T>
1730concat( const char* a, const sc_proxy<T>& b )
1731{
1733 ( *new sc_lv_base( a ), b.back_cast(), 1 );
1734}
1735
1736template <class T>
1737inline
1738sc_concref_r<T,sc_lv_base>
1739concat( const sc_proxy<T>& a, const sc_logic& b )
1740{
1742 ( a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
1743}
1744
1745template <class T>
1746inline
1747sc_concref_r<sc_lv_base,T>
1748concat( const sc_logic& a, const sc_proxy<T>& b )
1749{
1751 ( *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
1752}
1753
1754template <class T>
1755inline
1756sc_concref_r<T,sc_bv_base>
1757concat( const sc_proxy<T>& a, bool b )
1758{
1760 ( a.back_cast(), *new sc_bv_base( b, 1 ), 2 );
1761}
1762
1763template <class T>
1764inline
1765sc_concref_r<sc_bv_base,T>
1766concat( bool a, const sc_proxy<T>& b )
1767{
1769 ( *new sc_bv_base( a, 1 ), b.back_cast(), 1 );
1770}
1771
1772
1773#ifdef SC_DT_MIXED_COMMA_OPERATORS
1774
1775template <class T>
1776inline
1777sc_concref_r<T,sc_lv_base>
1778operator , ( sc_proxy<T>& a, const char* b )
1779{
1781 ( a.back_cast(), *new sc_lv_base( b ), 2 );
1782}
1783
1784template <class T>
1785inline
1786sc_concref_r<sc_lv_base,T>
1787operator , ( const char* a, sc_proxy<T>& b )
1788{
1790 ( *new sc_lv_base( a ), b.back_cast(), 1 );
1791}
1792
1793template <class T>
1794inline
1795sc_concref_r<T,sc_lv_base>
1797{
1799 ( a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
1800}
1801
1802template <class T>
1803inline
1804sc_concref_r<sc_lv_base,T>
1806{
1808 ( *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
1809}
1810
1811template <class T>
1812inline
1813sc_concref_r<T,sc_bv_base>
1815{
1817 ( a.back_cast(), *new sc_bv_base( b, 1 ), 2 );
1818}
1819
1820template <class T>
1821inline
1822sc_concref_r<sc_bv_base,T>
1824{
1826 ( *new sc_bv_base( a, 1 ), b.back_cast(), 1 );
1827}
1828
1829
1830template <class T>
1831inline
1832sc_concref_r<T,sc_lv_base>
1833concat( sc_proxy<T>& a, const char* b )
1834{
1836 ( a.back_cast(), *new sc_lv_base( b ), 2 );
1837}
1838
1839template <class T>
1840inline
1841sc_concref_r<sc_lv_base,T>
1842concat( const char* a, sc_proxy<T>& b )
1843{
1845 ( *new sc_lv_base( a ), b.back_cast(), 1 );
1846}
1847
1848template <class T>
1849inline
1850sc_concref_r<T,sc_lv_base>
1852{
1854 ( a.back_cast(), *new sc_lv_base( b, 1 ), 2 );
1855}
1856
1857template <class T>
1858inline
1859sc_concref_r<sc_lv_base,T>
1861{
1863 ( *new sc_lv_base( a, 1 ), b.back_cast(), 1 );
1864}
1865
1866template <class T>
1867inline
1868sc_concref_r<T,sc_bv_base>
1870{
1872 ( a.back_cast(), *new sc_bv_base( b, 1 ), 2 );
1873}
1874
1875template <class T>
1876inline
1877sc_concref_r<sc_bv_base,T>
1879{
1881 ( *new sc_bv_base( a, 1 ), b.back_cast(), 1 );
1882}
1883
1884#endif
1885
1886// extern template instantiations
1889
1890} // namespace sc_dt
1891
1892
1893#endif
#define DEFN_BITWISE_AND_OP_T_B(tp)
Definition: sc_lv_base.h:443
#define DEFN_BITWISE_AND_OP_T_A(tp)
Definition: sc_lv_base.h:426
#define DEFN_BITWISE_AND_ASN_OP_T(tp)
Definition: sc_lv_base.h:349
#define DEFN_BITWISE_AND_OP_T_NATIVE(tp)
Definition: sc_lv_base.h:391
#define DEFN_BITWISE_XOR_OP_T_SYSTEMC(tp)
Definition: sc_lv_base.h:687
#define DEFN_BITWISE_OR_OP_T_B(tp)
Definition: sc_lv_base.h:582
#define DEFN_BITWISE_OR_OP_T_A(tp)
Definition: sc_lv_base.h:565
#define DEFN_BITWISE_XOR_ASN_OP_T(tp)
Definition: sc_lv_base.h:622
#define DEFN_BITWISE_XOR_OP_T_A(tp)
Definition: sc_lv_base.h:705
#define DEFN_BITWISE_AND_OP_T_SYSTEMC(tp)
Definition: sc_lv_base.h:408
#define DEFN_BITWISE_OR_OP_T_NATIVE(tp)
Definition: sc_lv_base.h:525
#define DEFN_BITWISE_XOR_OP_T_B(tp)
Definition: sc_lv_base.h:722
#define DEFN_BITWISE_XOR_OP_T_NATIVE(tp)
Definition: sc_lv_base.h:664
#define DEFN_BITWISE_OR_ASN_OP_T(tp)
Definition: sc_lv_base.h:483
#define DEFN_REL_OP_T(tp)
Definition: sc_lv_base.h:884
#define DEFN_BITWISE_OR_OP_T_SYSTEMC(tp)
Definition: sc_lv_base.h:548
#define SC_BASE_VEC_DIGITS
Definition: sc_nbdefs.h:127
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:157
#define SC_API
Definition: sc_cmnhdr.h:148
#define sc_assert(expr)
Definition: sc_report.h:248
const sc_digit SC_DIGIT_ONE
Definition: sc_proxy.h:98
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:474
sc_lv_base lrotate(const sc_proxy< X > &x, int n)
Definition: sc_lv_base.h:803
const int SC_DIGIT_SIZE
Definition: sc_proxy.h:95
SC_API const sc_logic SC_LOGIC_X
X & b_or_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:1093
sc_bit operator&(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:331
sc_bit operator^(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:337
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:613
template class SC_API sc_proxy< sc_bv_base >
unsigned long long uint64
Definition: sc_nbdefs.h:216
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:285
const T sc_min(const T &a, const T &b)
Definition: sc_macros.h:40
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > concat(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
sc_concref_r< sc_bitref_r< T1 >, sc_bitref_r< T2 > > operator,(sc_bitref_r< T1 >, sc_bitref_r< T2 >)
SC_API void sc_proxy_out_of_bounds(const char *msg=NULL, int64 val=0)
X & b_and_assign_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:1069
class SC_API sc_logic
Definition: sc_signal_ifs.h:39
template class SC_API sc_proxy< sc_lv_base >
sc_lv_base reverse(const sc_proxy< X > &x)
Definition: sc_lv_base.h:852
X & b_xor_assign_(sc_proxy< X > &a, const sc_proxy< Y > &b)
Definition: sc_proxy.h:1117
sc_lv_base rrotate(const sc_proxy< X > &x, int n)
Definition: sc_lv_base.h:840
void assign_p_(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_proxy.h:746
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
Definition: sc_lv_base.h:340
const sc_digit SC_DIGIT_TWO
Definition: sc_proxy.h:99
unsigned int sc_digit
Definition: sc_nbdefs.h:161
uint64 const sc_uint_base int b
Definition: sc_fxval.h:955
sc_bit operator|(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:334
long long int64
Definition: sc_nbdefs.h:215
sc_core::sc_signal_in_if< T > & value(const T &val)
Definition: sc_stub.h:217
sc_bitref_r< T > * clone() const
sc_bitref< X > * clone() const
sc_subref_r< X > * clone() const
sc_subref< X > & operator=(const sc_proxy< Y > &a)
sc_subref< X > * clone() const
sc_concref_r< X, Y > * clone() const
sc_concref< X, Y > * clone() const
int length() const
Definition: sc_lv_base.h:203
sc_proxy< sc_lv_base > base_type
Definition: sc_lv_base.h:101
void set_bit(int i, value_type value)
Definition: sc_lv_base.h:286
sc_digit get_word(int wi) const
Definition: sc_lv_base.h:212
base_type::value_type value_type
Definition: sc_lv_base.h:102
void set_word(int wi, sc_digit w)
Definition: sc_lv_base.h:219
sc_digit get_cword(int wi) const
Definition: sc_lv_base.h:223
virtual ~sc_lv_base()
Definition: sc_lv_base.h:150
sc_lv_base(int length_=sc_length_param().len())
Definition: sc_lv_base.h:107
void set_cword(int wi, sc_digit w)
Definition: sc_lv_base.h:226
bool is_01() const
sc_lv_base(const sc_proxy< X > &a)
Definition: sc_lv_base.h:121
sc_digit * m_data
Definition: sc_lv_base.h:240
sc_lv_base(const char *a, int length_)
sc_lv_base(const char *a)
sc_lv_base(const sc_logic &a, int length_=sc_length_param().len())
Definition: sc_lv_base.h:111
sc_digit * m_ctrl
Definition: sc_lv_base.h:241
value_type get_bit(int i) const
Definition: sc_lv_base.h:276
int size() const
Definition: sc_lv_base.h:206
sc_lv_base(const sc_lv_base &a)
X & lrotate(int n)
Definition: sc_lv_base.h:778
sc_lv_base operator>>(int n) const
Definition: sc_lv_base.h:766
sc_lv_base operator<<(int n) const
Definition: sc_lv_base.h:753
sc_lv_base operator~() const
Definition: sc_lv_base.h:328
X & back_cast()
Definition: sc_proxy.h:211
X & rrotate(int n)
Definition: sc_lv_base.h:815
int length() const
Definition: sc_signed.h:807
int length() const
Definition: sc_unsigned.h:808