SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_fxtype_params.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_fxtype_params.h -
23 
24  Original Author: Martin Janssen, 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 
36  *****************************************************************************/
37 
38 // $Log: sc_fxtype_params.h,v $
39 // Revision 1.2 2011/08/24 22:05:43 acg
40 // Torsten Maehne: initialization changes to remove warnings.
41 //
42 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
43 // SystemC 2.3
44 //
45 // Revision 1.3 2006/01/13 18:53:58 acg
46 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
47 // the source.
48 //
49 
50 #ifndef SC_FXTYPE_PARAMS_H
51 #define SC_FXTYPE_PARAMS_H
52 
53 
55 
56 
57 namespace sc_dt
58 {
59 
60 // classes defined in this module
61 class sc_fxtype_params;
62 
63 
71 {
72 public:
73 
75  sc_fxtype_params( int, int );
77  sc_fxtype_params( int, int, sc_q_mode, sc_o_mode, int = 0 );
80  int, int );
82  sc_q_mode, sc_o_mode, int = 0 );
84 
85  sc_fxtype_params& operator = ( const sc_fxtype_params& );
86 
87  friend bool operator == ( const sc_fxtype_params&,
88  const sc_fxtype_params& );
89  friend bool operator != ( const sc_fxtype_params&,
90  const sc_fxtype_params& );
91 
92  int wl() const;
93  void wl( int );
94 
95  int iwl() const;
96  void iwl( int );
97 
98  sc_q_mode q_mode() const;
99  void q_mode( sc_q_mode );
100 
101  sc_o_mode o_mode() const;
102  void o_mode( sc_o_mode );
103 
104  int n_bits() const;
105  void n_bits( int );
106 
107  const std::string to_string() const;
108 
109  void print( ::std::ostream& = ::std::cout ) const;
110  void dump( ::std::ostream& = ::std::cout ) const;
111 
112 private:
113 
114  int m_wl;
115  int m_iwl;
116  sc_q_mode m_q_mode;
117  sc_o_mode m_o_mode;
118  int m_n_bits;
119 };
120 
121 } // namespace sc_dt
122 
129 // extern template instantiations
130 namespace sc_core {
131 SC_API_TEMPLATE_DECL_ sc_phash<void*, const sc_dt::sc_fxtype_params*>;
132 } // namespace sc_core
133 
134 namespace sc_dt {
135 
138 typedef sc_context<sc_fxtype_params> sc_fxtype_context;
139 
140 
141 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
142 
143 inline
145 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
146 {
148 }
149 
150 inline
152 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
153 {
155 
156  SC_CHECK_WL_( wl_ );
157  m_wl = wl_;
158  m_iwl = iwl_;
159 }
160 
161 inline
163  sc_o_mode o_mode_, int n_bits_ )
164 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
165 {
167 
168  SC_CHECK_N_BITS_( n_bits_ );
169  m_q_mode = q_mode_;
170  m_o_mode = o_mode_;
171  m_n_bits = n_bits_;
172 }
173 
174 inline
176  sc_q_mode q_mode_,
177  sc_o_mode o_mode_, int n_bits_ )
178 : m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
179 {
180  SC_CHECK_WL_( wl_ );
181  SC_CHECK_N_BITS_( n_bits_ );
182  m_wl = wl_;
183  m_iwl = iwl_;
184  m_q_mode = q_mode_;
185  m_o_mode = o_mode_;
186  m_n_bits = n_bits_;
187 }
188 
189 inline
191 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
192  m_q_mode( a.m_q_mode ),
193  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
194 {}
195 
196 inline
198  int wl_, int iwl_ )
199 : m_wl( wl_ ), m_iwl( iwl_ ),
200  m_q_mode( a.m_q_mode ),
201  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
202 {}
203 
204 inline
206  sc_q_mode q_mode_,
207  sc_o_mode o_mode_, int n_bits_ )
208 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
209  m_q_mode( q_mode_ ),
210  m_o_mode( o_mode_ ), m_n_bits( n_bits_ )
211 {}
212 
213 inline
215 : m_wl ( SC_DEFAULT_WL_ ),
216  m_iwl ( SC_DEFAULT_IWL_ ),
217  m_q_mode( SC_DEFAULT_Q_MODE_ ),
218  m_o_mode( SC_DEFAULT_O_MODE_ ),
219  m_n_bits( SC_DEFAULT_N_BITS_ )
220 {}
221 
222 
223 inline
226 {
227  if( &a != this )
228  {
229  m_wl = a.m_wl;
230  m_iwl = a.m_iwl;
231  m_q_mode = a.m_q_mode;
232  m_o_mode = a.m_o_mode;
233  m_n_bits = a.m_n_bits;
234  }
235  return *this;
236 }
237 
238 
239 inline
240 bool
242 {
243  return ( a.m_wl == b.m_wl &&
244  a.m_iwl == b.m_iwl &&
245  a.m_q_mode == b.m_q_mode &&
246  a.m_o_mode == b.m_o_mode &&
247  a.m_n_bits == b.m_n_bits );
248 }
249 
250 inline
251 bool
253 {
254  return ( a.m_wl != b.m_wl ||
255  a.m_iwl != b.m_iwl ||
256  a.m_q_mode != b.m_q_mode ||
257  a.m_o_mode != b.m_o_mode ||
258  a.m_n_bits != b.m_n_bits );
259 }
260 
261 
262 inline
263 int
265 {
266  return m_wl;
267 }
268 
269 inline
270 void
272 {
273  SC_CHECK_WL_( wl_ );
274  m_wl = wl_;
275 }
276 
277 
278 inline
279 int
281 {
282  return m_iwl;
283 }
284 
285 inline
286 void
288 {
289  m_iwl = iwl_;
290 }
291 
292 
293 inline
294 sc_q_mode
296 {
297  return m_q_mode;
298 }
299 
300 inline
301 void
303 {
304  m_q_mode = q_mode_;
305 }
306 
307 
308 inline
309 sc_o_mode
311 {
312  return m_o_mode;
313 }
314 
315 inline
316 void
318 {
319  m_o_mode = o_mode_;
320 }
321 
322 
323 inline
324 int
326 {
327  return m_n_bits;
328 }
329 
330 inline
331 void
333 {
334  SC_CHECK_N_BITS_( n_bits_ );
335  m_n_bits = n_bits_;
336 }
337 
338 
339 inline
340 ::std::ostream&
341 operator << ( ::std::ostream& os, const sc_fxtype_params& a )
342 {
343  a.print( os );
344  return os;
345 }
346 
347 } // namespace sc_dt
348 
349 
350 #endif
351 
352 // Taf!
sc_context< sc_fxtype_params > sc_fxtype_context
friend bool operator!=(const sc_fxtype_params &, const sc_fxtype_params &)
const sc_o_mode SC_DEFAULT_O_MODE_
Definition: sc_fxdefs.h:204
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:289
Empty class that is used for its type only.
Definition: sc_context.h:89
friend bool operator==(const sc_fxtype_params &, const sc_fxtype_params &)
static const T & default_value()
Definition: sc_context.h:300
const sc_q_mode SC_DEFAULT_Q_MODE_
Definition: sc_fxdefs.h:203
const int SC_DEFAULT_N_BITS_
Definition: sc_fxdefs.h:205
Template context class; co-routine safe.
Definition: sc_context.h:80
void print(::std::ostream &=::std::cout) const
const int SC_DEFAULT_WL_
Definition: sc_fxdefs.h:201
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1005
sc_o_mode o_mode() const
bool operator!=(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:292
Template global variable class; singleton; co-routine safe.
Definition: sc_context.h:79
#define SC_CHECK_WL_(wl)
Definition: sc_fxdefs.h:271
SC_API const std::string to_string(sc_enc)
Fixed-point type parameters class.
const int SC_DEFAULT_IWL_
Definition: sc_fxdefs.h:202
sc_q_mode
Enumeration of quantization modes.
Definition: sc_fxdefs.h:90
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:177
sc_q_mode q_mode() const
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:390
sc_o_mode
Enumeration of overflow modes.
Definition: sc_fxdefs.h:119
sc_fxtype_params & operator=(const sc_fxtype_params &)
#define SC_API
Definition: sc_cmnhdr.h:168
#define SC_CHECK_N_BITS_(n_bits)
Definition: sc_fxdefs.h:275