SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_int.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_int.h -- A signed integer whose length is less than 64 bits.
23 */
38 /*****************************************************************************
39 
40  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
41  changes you are making here.
42 
43  Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
44  Description of Modification: - Resolved ambiguity with sc_(un)signed.
45  - Merged the code for 64- and 32-bit versions
46  via the constants in sc_nbdefs.h.
47  - Eliminated redundant file inclusions.
48 
49  Name, Affiliation, Date:
50  Description of Modification:
51 
52  *****************************************************************************/
53 
54 // $Log: sc_int.h,v $
55 // Revision 1.2 2011/02/18 20:19:14 acg
56 // Andy Goodrich: updating Copyright notice.
57 //
58 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
59 // SystemC 2.3
60 //
61 // Revision 1.3 2006/01/13 18:49:31 acg
62 // Added $Log command so that CVS check in comments are reproduced in the
63 // source.
64 //
65 
66 #ifndef SC_INT_H
67 #define SC_INT_H
68 
69 
71 
72 
73 namespace sc_dt
74 {
75 
76 // classes defined in this module
77 template <int W> class sc_int;
78 
79 
90 template <int W>
91 class sc_int
92  : public sc_int_base
93 {
94 public:
95 
96  // constructors
97 
99  : sc_int_base( W )
100  {}
101 
103  : sc_int_base( v, W )
104  {}
105 
106  sc_int( const sc_int<W>& a )
107  : sc_int_base( a )
108  {}
109 
110  sc_int( const sc_int_base& a )
111  : sc_int_base( W )
112  { sc_int_base::operator = ( a ); }
113 
115  : sc_int_base( W )
116  { sc_int_base::operator = ( a ); }
117 
118  template< class T >
120  : sc_int_base( W )
121  { sc_int_base::operator = ( a->to_int64() ); }
122 
123  sc_int( const sc_signed& a )
124  : sc_int_base( W )
125  { sc_int_base::operator = ( a ); }
126 
127  sc_int( const sc_unsigned& a )
128  : sc_int_base( W )
129  { sc_int_base::operator = ( a ); }
130 
131 #ifdef SC_INCLUDE_FX
132 
133  explicit sc_int( const sc_fxval& a )
134  : sc_int_base( W )
135  { sc_int_base::operator = ( a ); }
136 
137  explicit sc_int( const sc_fxval_fast& a )
138  : sc_int_base( W )
139  { sc_int_base::operator = ( a ); }
140 
141  explicit sc_int( const sc_fxnum& a )
142  : sc_int_base( W )
143  { sc_int_base::operator = ( a ); }
144 
145  explicit sc_int( const sc_fxnum_fast& a )
146  : sc_int_base( W )
147  { sc_int_base::operator = ( a ); }
148 
149 #endif
150 
151  sc_int( const sc_bv_base& a )
152  : sc_int_base( W )
153  { sc_int_base::operator = ( a ); }
154 
155  sc_int( const sc_lv_base& a )
156  : sc_int_base( W )
157  { sc_int_base::operator = ( a ); }
158 
159  sc_int( const char* a )
160  : sc_int_base( W )
161  { sc_int_base::operator = ( a ); }
162 
163  sc_int( unsigned long a )
164  : sc_int_base( W )
165  { sc_int_base::operator = ( a ); }
166 
167  sc_int( long a )
168  : sc_int_base( W )
169  { sc_int_base::operator = ( a ); }
170 
171  sc_int( unsigned int a )
172  : sc_int_base( W )
173  { sc_int_base::operator = ( a ); }
174 
175  sc_int( int a )
176  : sc_int_base( W )
177  { sc_int_base::operator = ( a ); }
178 
180  : sc_int_base( W )
181  { sc_int_base::operator = ( a ); }
182 
183  sc_int( double a )
184  : sc_int_base( W )
185  { sc_int_base::operator = ( a ); }
186 
187 
188  // assignment operators
189 
191  { sc_int_base::operator = ( v ); return *this; }
192 
194  { sc_int_base::operator = ( a ); return *this; }
195 
197  { sc_int_base::operator = ( a ); return *this; }
198 
200  { m_val = a.m_val; return *this; }
201 
202  template< class T >
204  { sc_int_base::operator = ( a->to_int64() ); return *this; }
205 
207  { sc_int_base::operator = ( a ); return *this; }
208 
210  { sc_int_base::operator = ( a ); return *this; }
211 
212 #ifdef SC_INCLUDE_FX
213 
214  sc_int<W>& operator = ( const sc_fxval& a )
215  { sc_int_base::operator = ( a ); return *this; }
216 
217  sc_int<W>& operator = ( const sc_fxval_fast& a )
218  { sc_int_base::operator = ( a ); return *this; }
219 
220  sc_int<W>& operator = ( const sc_fxnum& a )
221  { sc_int_base::operator = ( a ); return *this; }
222 
223  sc_int<W>& operator = ( const sc_fxnum_fast& a )
224  { sc_int_base::operator = ( a ); return *this; }
225 
226 #endif
227 
229  { sc_int_base::operator = ( a ); return *this; }
230 
232  { sc_int_base::operator = ( a ); return *this; }
233 
234  sc_int<W>& operator = ( const char* a )
235  { sc_int_base::operator = ( a ); return *this; }
236 
237  sc_int<W>& operator = ( unsigned long a )
238  { sc_int_base::operator = ( a ); return *this; }
239 
241  { sc_int_base::operator = ( a ); return *this; }
242 
243  sc_int<W>& operator = ( unsigned int a )
244  { sc_int_base::operator = ( a ); return *this; }
245 
247  { sc_int_base::operator = ( a ); return *this; }
248 
250  { sc_int_base::operator = ( a ); return *this; }
251 
252  sc_int<W>& operator = ( double a )
253  { sc_int_base::operator = ( a ); return *this; }
254 
255 
256  // arithmetic assignment operators
257 
259  { sc_int_base::operator += ( v ); return *this; }
260 
262  { sc_int_base::operator -= ( v ); return *this; }
263 
265  { sc_int_base::operator *= ( v ); return *this; }
266 
268  { sc_int_base::operator /= ( v ); return *this; }
269 
271  { sc_int_base::operator %= ( v ); return *this; }
272 
273 
274  // bitwise assignment operators
275 
277  { sc_int_base::operator &= ( v ); return *this; }
278 
280  { sc_int_base::operator |= ( v ); return *this; }
281 
283  { sc_int_base::operator ^= ( v ); return *this; }
284 
285 
287  { sc_int_base::operator <<= ( v ); return *this; }
288 
290  { sc_int_base::operator >>= ( v ); return *this; }
291 
292 
293  // prefix and postfix increment and decrement operators
294 
295  sc_int<W>& operator ++ () // prefix
296  { sc_int_base::operator ++ (); return *this; }
297 
298  const sc_int<W> operator ++ ( int ) // postfix
299  { return sc_int<W>( sc_int_base::operator ++ ( 0 ) ); }
300 
301  sc_int<W>& operator -- () // prefix
302  { sc_int_base::operator -- (); return *this; }
303 
304  const sc_int<W> operator -- ( int ) // postfix
305  { return sc_int<W>( sc_int_base::operator -- ( 0 ) ); }
306 };
307 
308 } // namespace sc_dt
309 
310 
311 #endif
312 
313 // Taf!
Base class for the fixed-point types; limited precision.
Definition: sc_fxnum.h:991
sc_int_base & operator<<=(int_type v)
Definition: sc_int_base.h:702
sc_int< W > & operator-=(int_type v)
Definition: sc_int.h:261
sc_int(uint64 a)
Definition: sc_int.h:179
Proxy class for sc_int part selection (r-value only).
Definition: sc_int_base.h:325
Fixed-point value types; limited precision.
Definition: sc_fxval.h:439
sc_int(long a)
Definition: sc_int.h:167
sc_int(const sc_int_base &a)
Definition: sc_int.h:110
sc_int(const sc_int_subref_r &a)
Definition: sc_int.h:114
sc_int_base & operator=(int_type v)
Definition: sc_int_base.h:625
sc_int_base & operator*=(int_type v)
Definition: sc_int_base.h:680
sc_int(const sc_unsigned &a)
Definition: sc_int.h:127
sc_int_base & operator%=(int_type v)
Definition: sc_int_base.h:686
sc_int(const sc_int< W > &a)
Definition: sc_int.h:106
Arbitrary precision signed number.
Definition: sc_signed.h:1099
sc_int(unsigned long a)
Definition: sc_int.h:163
sc_int_base & operator-=(int_type v)
Definition: sc_int_base.h:677
sc_int< W > & operator>>=(int_type v)
Definition: sc_int.h:289
sc_int(unsigned int a)
Definition: sc_int.h:171
sc_int_base & operator^=(int_type v)
Definition: sc_int_base.h:698
sc_int_base(int w=sc_length_param().len())
Definition: sc_int_base.h:585
sc_int_base & operator/=(int_type v)
Definition: sc_int_base.h:683
uint64_t uint64
Definition: sc_nbdefs.h:189
Arbitrary precision unsigned number.
Definition: sc_unsigned.h:1001
Base class for the fixed-point types; arbitrary precision.
Definition: sc_fxnum.h:564
sc_int_base & operator>>=(int_type v)
Definition: sc_int_base.h:705
Base class for sc_int.
Definition: sc_int_base.h:548
sc_int(int a)
Definition: sc_int.h:175
Fixed-point value type; arbitrary precision.
Definition: sc_fxval.h:95
Arbitrary size logic vector base class.
Definition: sc_lv_base.h:91
sc_int< W > & operator=(int_type v)
Definition: sc_int.h:190
int64 int_type
Definition: sc_nbdefs.h:233
Template class sc_int<W> is the interface that the user sees.
Definition: sc_int.h:77
sc_int_base & operator++()
Definition: sc_int_base.h:711
sc_int< W > & operator|=(int_type v)
Definition: sc_int.h:279
sc_int< W > & operator*=(int_type v)
Definition: sc_int.h:264
Proxy class for user-defined value classes and other classes that.
sc_int(const char *a)
Definition: sc_int.h:159
sc_int< W > & operator<<=(int_type v)
Definition: sc_int.h:286
sc_int(int_type v)
Definition: sc_int.h:102
sc_int_base & operator--()
Definition: sc_int_base.h:717
sc_int(const sc_generic_base< T > &a)
Definition: sc_int.h:119
sc_int_base & operator+=(int_type v)
Definition: sc_int_base.h:674
sc_int< W > & operator--()
Definition: sc_int.h:301
sc_int< W > & operator%=(int_type v)
Definition: sc_int.h:270
sc_int(double a)
Definition: sc_int.h:183
sc_int(const sc_bv_base &a)
Definition: sc_int.h:151
sc_int(const sc_signed &a)
Definition: sc_int.h:123
sc_int(const sc_lv_base &a)
Definition: sc_int.h:155
sc_int< W > & operator++()
Definition: sc_int.h:295
sc_int_base & operator|=(int_type v)
Definition: sc_int_base.h:695
sc_int< W > & operator+=(int_type v)
Definition: sc_int.h:258
sc_int_base & operator&=(int_type v)
Definition: sc_int_base.h:692
sc_int< W > & operator^=(int_type v)
Definition: sc_int.h:282
Arbitrary size bit vector base class.
Definition: sc_bv_base.h:80
sc_int< W > & operator/=(int_type v)
Definition: sc_int.h:267
A signed integer whose length is less than 64 bit.
sc_int< W > & operator&=(int_type v)
Definition: sc_int.h:276