gem5  v22.1.0.0
sc_int.hh
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 
24  Unlike arbitrary precision, arithmetic and bitwise operations
25  are performed using the native types (hence capped at 64 bits).
26  The sc_int integer is useful when the user does not need
27  arbitrary precision and the performance is superior to
28  sc_bigint/sc_biguint.
29 
30  Original Author: Amit Rao, Synopsys, Inc.
31 
32  *****************************************************************************/
33 
34 /*****************************************************************************
35 
36  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
37  changes you are making here.
38 
39  Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
40  Description of Modification: - Resolved ambiguity with sc_(un)signed.
41  - Merged the code for 64- and 32-bit versions
42  via the constants in sc_nbdefs.h.
43  - Eliminated redundant file inclusions.
44 
45  Name, Affiliation, Date:
46  Description of Modification:
47 
48  *****************************************************************************/
49 
50 // $Log: sc_int.h,v $
51 // Revision 1.2 2011/02/18 20:19:14 acg
52 // Andy Goodrich: updating Copyright notice.
53 //
54 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
55 // SystemC 2.3
56 //
57 // Revision 1.3 2006/01/13 18:49:31 acg
58 // Added $Log command so that CVS check in comments are reproduced in the
59 // source.
60 //
61 
62 #ifndef __SYSTEMC_EXT_DT_INT_SC_INT_HH__
63 #define __SYSTEMC_EXT_DT_INT_SC_INT_HH__
64 
65 #include "sc_int_base.hh"
66 
67 namespace sc_dt
68 {
69 
70 // classes defined in this module
71 template <int W>
72 class sc_int;
73 
74 
75 // ----------------------------------------------------------------------------
76 // CLASS TEMPLATE : sc_int<W>
77 //
78 // Template class sc_int<W> is the interface that the user sees. It is
79 // derived from sc_int_base and most of its methods are just wrappers
80 // that call the corresponding method in the parent class. Note that
81 // the length of sc_int datatype is specified as a template parameter.
82 // ----------------------------------------------------------------------------
83 
84 template <int W>
85 class sc_int : public sc_int_base
86 {
87  public:
88  // constructors
89  sc_int() : sc_int_base(W) {}
91  sc_int(const sc_int<W> &a) : sc_int_base(a) {}
92 
94  {
96  }
98  {
100  }
101  template< class T >
103  {
104  sc_int_base::operator = (a->to_int64());
105  }
107  {
109  }
111  {
113  }
114  explicit sc_int(const sc_fxval &a) : sc_int_base(W)
115  {
117  }
118  explicit sc_int(const sc_fxval_fast &a) : sc_int_base(W)
119  {
121  }
122  explicit sc_int(const sc_fxnum &a) : sc_int_base(W)
123  {
125  }
126  explicit sc_int(const sc_fxnum_fast &a) : sc_int_base(W)
127  {
129  }
131  {
133  }
135  {
137  }
138  sc_int(const char *a) : sc_int_base(W)
139  {
141  }
142  sc_int(unsigned long a) : sc_int_base(W)
143  {
145  }
146  sc_int(long a) : sc_int_base(W)
147  {
149  }
150  sc_int(unsigned int a) : sc_int_base(W)
151  {
153  }
154  sc_int(int a) : sc_int_base(W)
155  {
157  }
159  {
161  }
162  sc_int(double a) : sc_int_base(W)
163  {
165  }
166 
167  // assignment operators
168  sc_int<W> &
170  {
172  return *this;
173  }
174  sc_int<W> &
176  {
178  return *this;
179  }
180  sc_int<W> &
182  {
184  return *this;
185  }
186  sc_int<W> &
188  {
189  m_val = a.m_val;
190  return *this;
191  }
192  template< class T >
193  sc_int<W> &
195  {
196  sc_int_base::operator = (a->to_int64());
197  return *this;
198  }
199  sc_int<W> &
201  {
203  return *this;
204  }
205  sc_int<W> &
207  {
209  return *this;
210  }
211  sc_int<W> &
213  {
215  return *this;
216  }
217  sc_int<W> &
219  {
221  return *this;
222  }
223  sc_int<W> &
225  {
227  return *this;
228  }
230  {
232  return *this;
233  }
234  sc_int<W> &
236  {
238  return *this;
239  }
240  sc_int<W> &
242  {
244  return *this;
245  }
246  sc_int<W> &
247  operator = (const char *a)
248  {
250  return *this;
251  }
252  sc_int<W> &
253  operator = (unsigned long a)
254  {
256  return *this;
257  }
258  sc_int<W> &
260  {
262  return *this;
263  }
264  sc_int<W> &
265  operator = (unsigned int a)
266  {
268  return *this;
269  }
270  sc_int<W> &
272  {
274  return *this;
275  }
276  sc_int<W> &
278  {
280  return *this;
281  }
282  sc_int<W> &
283  operator = (double a)
284  {
286  return *this;
287  }
288 
289  // arithmetic assignment operators
290  sc_int<W> &
292  {
294  return *this;
295  }
296  sc_int<W> &
298  {
300  return *this;
301  }
302  sc_int<W> &
304  {
306  return *this;
307  }
308  sc_int<W> &
310  {
312  return *this;
313  }
314  sc_int<W> &
316  {
318  return *this;
319  }
320 
321  // bitwise assignment operators
322  sc_int<W> &
324  {
326  return *this;
327  }
328  sc_int<W> &
330  {
332  return *this;
333  }
334  sc_int<W> &
336  {
338  return *this;
339  }
340  sc_int<W> &
342  {
344  return *this;
345  }
346  sc_int<W> &
348  {
350  return *this;
351  }
352 
353  // prefix and postfix increment and decrement operators
354  sc_int<W> &
355  operator ++ () // prefix
356  {
358  return *this;
359  }
360  const sc_int<W>
361  operator ++ (int) // postfix
362  {
363  return sc_int<W>(sc_int_base::operator ++ (0));
364  }
365  sc_int<W> &
366  operator -- () // prefix
367  {
369  return *this;
370  }
371  const sc_int<W>
372  operator -- (int) // postfix
373  {
374  return sc_int<W>(sc_int_base::operator -- (0));
375  }
376 };
377 
378 } // namespace sc_dt
379 
380 
381 #endif // __SYSTEMC_EXT_DT_INT_SC_INT_HH__
sc_int_base & operator^=(int_type v)
Definition: sc_int_base.hh:743
sc_int_base & operator/=(int_type v)
Definition: sc_int_base.hh:709
sc_int_base & operator=(int_type v)
Definition: sc_int_base.hh:590
sc_int_base & operator*=(int_type v)
Definition: sc_int_base.hh:701
sc_int_base & operator%=(int_type v)
Definition: sc_int_base.hh:717
sc_int_base & operator&=(int_type v)
Definition: sc_int_base.hh:727
sc_int_base & operator--()
Definition: sc_int_base.hh:787
sc_int_base & operator++()
Definition: sc_int_base.hh:770
sc_int_base & operator|=(int_type v)
Definition: sc_int_base.hh:735
sc_int_base & operator+=(int_type v)
Definition: sc_int_base.hh:685
sc_int_base & operator-=(int_type v)
Definition: sc_int_base.hh:693
sc_int_base & operator<<=(int_type v)
Definition: sc_int_base.hh:752
sc_int_base & operator>>=(int_type v)
Definition: sc_int_base.hh:760
sc_int(const sc_fxnum_fast &a)
Definition: sc_int.hh:126
sc_int< W > & operator++()
Definition: sc_int.hh:355
sc_int(const char *a)
Definition: sc_int.hh:138
sc_int(int a)
Definition: sc_int.hh:154
sc_int(const sc_int< W > &a)
Definition: sc_int.hh:91
sc_int(const sc_lv_base &a)
Definition: sc_int.hh:134
sc_int(const sc_bv_base &a)
Definition: sc_int.hh:130
sc_int< W > & operator|=(int_type v)
Definition: sc_int.hh:329
sc_int(const sc_fxval &a)
Definition: sc_int.hh:114
sc_int< W > & operator<<=(int_type v)
Definition: sc_int.hh:341
sc_int< W > & operator--()
Definition: sc_int.hh:366
sc_int< W > & operator>>=(int_type v)
Definition: sc_int.hh:347
sc_int(unsigned long a)
Definition: sc_int.hh:142
sc_int(const sc_fxval_fast &a)
Definition: sc_int.hh:118
sc_int< W > & operator*=(int_type v)
Definition: sc_int.hh:303
sc_int< W > & operator+=(int_type v)
Definition: sc_int.hh:291
sc_int< W > & operator/=(int_type v)
Definition: sc_int.hh:309
sc_int< W > & operator&=(int_type v)
Definition: sc_int.hh:323
sc_int(const sc_signed &a)
Definition: sc_int.hh:106
sc_int(const sc_int_base &a)
Definition: sc_int.hh:93
sc_int< W > & operator%=(int_type v)
Definition: sc_int.hh:315
sc_int(long a)
Definition: sc_int.hh:146
sc_int(const sc_int_subref_r &a)
Definition: sc_int.hh:97
sc_int(uint64 a)
Definition: sc_int.hh:158
sc_int< W > & operator^=(int_type v)
Definition: sc_int.hh:335
sc_int(const sc_generic_base< T > &a)
Definition: sc_int.hh:102
sc_int< W > & operator=(int_type v)
Definition: sc_int.hh:169
sc_int(int_type v)
Definition: sc_int.hh:90
sc_int(const sc_fxnum &a)
Definition: sc_int.hh:122
sc_int(const sc_unsigned &a)
Definition: sc_int.hh:110
sc_int< W > & operator-=(int_type v)
Definition: sc_int.hh:297
sc_int(double a)
Definition: sc_int.hh:162
sc_int(unsigned int a)
Definition: sc_int.hh:150
Bitfield< 8 > a
Definition: misc_types.hh:66
Bitfield< 0 > v
Definition: pagetable.hh:65
Definition: sc_bit.cc:68
uint64_t uint64
Definition: sc_nbdefs.hh:172
int64 int_type
Definition: sc_nbdefs.hh:206

Generated on Wed Dec 21 2022 10:22:42 for gem5 by doxygen 1.9.1