SystemC  Recoding Infrastructure for SystemC v0.6.3 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_fxtype_params.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_fxtype_params.h -
21 
22  Original Author: Martin Janssen, Synopsys, Inc.
23 
24  *****************************************************************************/
25 
26 /*****************************************************************************
27 
28  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
29  changes you are making here.
30 
31  Name, Affiliation, Date:
32  Description of Modification:
33 
34  *****************************************************************************/
35 
36 // $Log: sc_fxtype_params.h,v $
37 // Revision 1.2 2011/08/24 22:05:43 acg
38 // Torsten Maehne: initialization changes to remove warnings.
39 //
40 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
41 // SystemC 2.3
42 //
43 // Revision 1.3 2006/01/13 18:53:58 acg
44 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
45 // the source.
46 //
47 
48 #ifndef SC_FXTYPE_PARAMS_H
49 #define SC_FXTYPE_PARAMS_H
50 
51 
53 
54 
55 namespace sc_dt
56 {
57 
58 // classes defined in this module
59 class sc_fxtype_params;
60 
61 
62 // ----------------------------------------------------------------------------
63 // CLASS : sc_fxtype_params
64 //
65 // Fixed-point type parameters class.
66 // ----------------------------------------------------------------------------
67 
69 {
70 public:
71 
73  sc_fxtype_params( int, int );
75  sc_fxtype_params( int, int, sc_q_mode, sc_o_mode, int = 0 );
78  int, int );
80  sc_q_mode, sc_o_mode, int = 0 );
82 
84 
85  friend bool operator == ( const sc_fxtype_params&,
86  const sc_fxtype_params& );
87  friend bool operator != ( const sc_fxtype_params&,
88  const sc_fxtype_params& );
89 
90  int wl() const;
91  void wl( int );
92 
93  int iwl() const;
94  void iwl( int );
95 
96  sc_q_mode q_mode() const;
97  void q_mode( sc_q_mode );
98 
99  sc_o_mode o_mode() const;
100  void o_mode( sc_o_mode );
101 
102  int n_bits() const;
103  void n_bits( int );
104 
105  const std::string to_string() const;
106 
107  void print( ::std::ostream& = ::std::cout ) const;
108  void dump( ::std::ostream& = ::std::cout ) const;
109 
110 private:
111 
112  int m_wl;
113  int m_iwl;
114  sc_q_mode m_q_mode;
115  sc_o_mode m_o_mode;
116  int m_n_bits;
117 };
118 
119 
120 // ----------------------------------------------------------------------------
121 // TYPEDEF : sc_fxtype_context
122 //
123 // Context type for the fixed-point type parameters.
124 // ----------------------------------------------------------------------------
125 
127 
128 
129 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
130 
131 inline
133 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
134 {
136 }
137 
138 inline
140 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
141 {
143 
144  SC_CHECK_WL_( wl_ );
145  m_wl = wl_;
146  m_iwl = iwl_;
147 }
148 
149 inline
151  sc_o_mode o_mode_, int n_bits_ )
152 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
153 {
155 
156  SC_CHECK_N_BITS_( n_bits_ );
157  m_q_mode = q_mode_;
158  m_o_mode = o_mode_;
159  m_n_bits = n_bits_;
160 }
161 
162 inline
164  sc_q_mode q_mode_,
165  sc_o_mode o_mode_, int n_bits_ )
166 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
167 {
168  SC_CHECK_WL_( wl_ );
169  SC_CHECK_N_BITS_( n_bits_ );
170  m_wl = wl_;
171  m_iwl = iwl_;
172  m_q_mode = q_mode_;
173  m_o_mode = o_mode_;
174  m_n_bits = n_bits_;
175 }
176 
177 inline
179 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
180  m_q_mode( a.m_q_mode ),
181  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
182 {}
183 
184 inline
186  int wl_, int iwl_ )
187 : m_wl( wl_ ), m_iwl( iwl_ ),
188  m_q_mode( a.m_q_mode ),
189  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
190 {}
191 
192 inline
194  sc_q_mode q_mode_,
195  sc_o_mode o_mode_, int n_bits_ )
196 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
197  m_q_mode( q_mode_ ),
198  m_o_mode( o_mode_ ), m_n_bits( n_bits_ )
199 {}
200 
201 inline
203 : m_wl ( SC_DEFAULT_WL_ ),
204  m_iwl ( SC_DEFAULT_IWL_ ),
205  m_q_mode( SC_DEFAULT_Q_MODE_ ),
206  m_o_mode( SC_DEFAULT_O_MODE_ ),
207  m_n_bits( SC_DEFAULT_N_BITS_ )
208 {}
209 
210 
211 inline
214 {
215  if( &a != this )
216  {
217  m_wl = a.m_wl;
218  m_iwl = a.m_iwl;
219  m_q_mode = a.m_q_mode;
220  m_o_mode = a.m_o_mode;
221  m_n_bits = a.m_n_bits;
222  }
223  return *this;
224 }
225 
226 
227 inline
228 bool
230 {
231  return ( a.m_wl == b.m_wl &&
232  a.m_iwl == b.m_iwl &&
233  a.m_q_mode == b.m_q_mode &&
234  a.m_o_mode == b.m_o_mode &&
235  a.m_n_bits == b.m_n_bits );
236 }
237 
238 inline
239 bool
241 {
242  return ( a.m_wl != b.m_wl ||
243  a.m_iwl != b.m_iwl ||
244  a.m_q_mode != b.m_q_mode ||
245  a.m_o_mode != b.m_o_mode ||
246  a.m_n_bits != b.m_n_bits );
247 }
248 
249 
250 inline
251 int
253 {
254  return m_wl;
255 }
256 
257 inline
258 void
260 {
261  SC_CHECK_WL_( wl_ );
262  m_wl = wl_;
263 }
264 
265 
266 inline
267 int
269 {
270  return m_iwl;
271 }
272 
273 inline
274 void
276 {
277  m_iwl = iwl_;
278 }
279 
280 
281 inline
282 sc_q_mode
284 {
285  return m_q_mode;
286 }
287 
288 inline
289 void
291 {
292  m_q_mode = q_mode_;
293 }
294 
295 
296 inline
297 sc_o_mode
299 {
300  return m_o_mode;
301 }
302 
303 inline
304 void
306 {
307  m_o_mode = o_mode_;
308 }
309 
310 
311 inline
312 int
314 {
315  return m_n_bits;
316 }
317 
318 inline
319 void
321 {
322  SC_CHECK_N_BITS_( n_bits_ );
323  m_n_bits = n_bits_;
324 }
325 
326 
327 inline
328 ::std::ostream&
329 operator << ( ::std::ostream& os, const sc_fxtype_params& a )
330 {
331  a.print( os );
332  return os;
333 }
334 
335 } // namespace sc_dt
336 
337 
338 #endif
339 
340 // Taf!
sc_context< sc_fxtype_params > sc_fxtype_context
sc_o_mode o_mode() const
#define SC_CHECK_N_BITS_(n_bits)
Definition: sc_fxdefs.h:267
const std::string to_string() const
const int SC_DEFAULT_WL_
Definition: sc_fxdefs.h:198
static const T & default_value()
Definition: sc_context.h:296
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1003
bool operator!=(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:286
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:283
const int SC_DEFAULT_IWL_
Definition: sc_fxdefs.h:199
void dump(::std::ostream &=::std::cout) const
sc_o_mode
Definition: sc_fxdefs.h:116
sc_fxtype_params & operator=(const sc_fxtype_params &)
#define SC_CHECK_WL_(wl)
Definition: sc_fxdefs.h:264
sc_q_mode q_mode() const
const int SC_DEFAULT_N_BITS_
Definition: sc_fxdefs.h:202
void print(::std::ostream &=::std::cout) const
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:386
sc_q_mode
Definition: sc_fxdefs.h:87
friend bool operator==(const sc_fxtype_params &, const sc_fxtype_params &)
const sc_q_mode SC_DEFAULT_Q_MODE_
Definition: sc_fxdefs.h:200
const sc_o_mode SC_DEFAULT_O_MODE_
Definition: sc_fxdefs.h:201
friend bool operator!=(const sc_fxtype_params &, const sc_fxtype_params &)