SystemC 3.0.0
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
57namespace sc_dt
58{
59
60// classes defined in this module
61class sc_fxtype_params;
62
63
64// ----------------------------------------------------------------------------
65// CLASS : sc_fxtype_params
66//
67// Fixed-point type parameters class.
68// ----------------------------------------------------------------------------
69
71{
72public:
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 std::string to_string() const;
108
109 void print( ::std::ostream& = ::std::cout ) const;
110 void dump( ::std::ostream& = ::std::cout ) const;
111
112private:
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
123// ----------------------------------------------------------------------------
124// TYPEDEF : sc_fxtype_context
125//
126// Context type for the fixed-point type parameters.
127// ----------------------------------------------------------------------------
128
129// extern template instantiations
130namespace sc_core {
131SC_API_TEMPLATE_DECL_ sc_phash<void*, const sc_dt::sc_fxtype_params*>;
132} // namespace sc_core
133
134namespace sc_dt {
135
139
140
141// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
142
143inline
145: m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
146{
148}
149
150inline
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
161inline
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
174inline
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
189inline
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
196inline
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
204inline
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
213inline
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
223inline
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
239inline
240bool
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
250inline
251bool
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
262inline
263int
265{
266 return m_wl;
267}
268
269inline
270void
272{
273 SC_CHECK_WL_( wl_ );
274 m_wl = wl_;
275}
276
277
278inline
279int
281{
282 return m_iwl;
283}
284
285inline
286void
288{
289 m_iwl = iwl_;
290}
291
292
293inline
296{
297 return m_q_mode;
298}
299
300inline
301void
303{
304 m_q_mode = q_mode_;
305}
306
307
308inline
311{
312 return m_o_mode;
313}
314
315inline
316void
318{
319 m_o_mode = o_mode_;
320}
321
322
323inline
324int
326{
327 return m_n_bits;
328}
329
330inline
331void
333{
334 SC_CHECK_N_BITS_( n_bits_ );
335 m_n_bits = n_bits_;
336}
337
338
339inline
340::std::ostream&
341operator << ( ::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!
#define SC_CHECK_WL_(wl)
Definition: sc_fxdefs.h:268
#define SC_CHECK_N_BITS_(n_bits)
Definition: sc_fxdefs.h:271
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:157
#define SC_API
Definition: sc_cmnhdr.h:148
const int SC_DEFAULT_WL_
Definition: sc_fxdefs.h:201
sc_q_mode
Definition: sc_fxdefs.h:91
template class SC_API sc_global< sc_fxtype_params >
const sc_q_mode SC_DEFAULT_Q_MODE_
Definition: sc_fxdefs.h:203
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:285
const int SC_DEFAULT_IWL_
Definition: sc_fxdefs.h:202
sc_context< sc_fxtype_params > sc_fxtype_context
const sc_o_mode SC_DEFAULT_O_MODE_
Definition: sc_fxdefs.h:204
template class SC_API sc_context< sc_fxtype_params >
bool operator!=(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:288
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:388
uint64 const sc_uint_base int b
Definition: sc_fxval.h:955
sc_o_mode
Definition: sc_fxdefs.h:120
const int SC_DEFAULT_N_BITS_
Definition: sc_fxdefs.h:205
static const T & default_value()
Definition: sc_context.h:300
void dump(::std::ostream &=::std::cout) const
std::string to_string() const
sc_fxtype_params & operator=(const sc_fxtype_params &)
void print(::std::ostream &=::std::cout) const
sc_o_mode o_mode() const
sc_q_mode q_mode() const