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
54#include "sysc/datatypes/fx/sc_context.h"
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
70class sc_fxtype_params
71{
72public:
73
74             sc_fxtype_params();
75             sc_fxtype_params( int, int );
76             sc_fxtype_params(           sc_q_mode, sc_o_mode, int = 0 );
77             sc_fxtype_params( int, int, sc_q_mode, sc_o_mode, int = 0 );
78             sc_fxtype_params( const sc_fxtype_params& );
79	     sc_fxtype_params( const sc_fxtype_params&,
80			       int, int );
81	     sc_fxtype_params( const sc_fxtype_params&,
82			                 sc_q_mode, sc_o_mode, int = 0 );
83    explicit sc_fxtype_params( sc_without_context );
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
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
122// ----------------------------------------------------------------------------
123//  TYPEDEF : sc_fxtype_context
124//
125//  Context type for the fixed-point type parameters.
126// ----------------------------------------------------------------------------
127
128typedef sc_context<sc_fxtype_params> sc_fxtype_context;
129
130
131// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
132
133inline
134sc_fxtype_params::sc_fxtype_params()
135: m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
136{
137    *this = sc_fxtype_context::default_value();
138}
139
140inline
141sc_fxtype_params::sc_fxtype_params( int wl_, int iwl_ )
142: m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
143{
144    *this = sc_fxtype_context::default_value();
145
146    SC_CHECK_WL_( wl_ );
147    m_wl  = wl_;
148    m_iwl = iwl_;
149}
150
151inline
152sc_fxtype_params::sc_fxtype_params( sc_q_mode q_mode_,
153                                    sc_o_mode o_mode_, int n_bits_ )
154: m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
155{
156    *this = sc_fxtype_context::default_value();
157
158    SC_CHECK_N_BITS_( n_bits_ );
159    m_q_mode = q_mode_;
160    m_o_mode = o_mode_;
161    m_n_bits = n_bits_;
162}
163
164inline
165sc_fxtype_params::sc_fxtype_params( int wl_, int iwl_,
166                                    sc_q_mode q_mode_,
167                                    sc_o_mode o_mode_, int n_bits_ )
168: m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
169{
170    SC_CHECK_WL_( wl_ );
171    SC_CHECK_N_BITS_( n_bits_ );
172    m_wl     = wl_;
173    m_iwl    = iwl_;
174    m_q_mode = q_mode_;
175    m_o_mode = o_mode_;
176    m_n_bits = n_bits_;
177}
178
179inline
180sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a )
181: m_wl( a.m_wl ), m_iwl( a.m_iwl ),
182  m_q_mode( a.m_q_mode ),
183  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
184{}
185
186inline
187sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a,
188				    int wl_, int iwl_ )
189: m_wl( wl_ ), m_iwl( iwl_ ),
190  m_q_mode( a.m_q_mode ),
191  m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
192{}
193
194inline
195sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a,
196				    sc_q_mode q_mode_,
197				    sc_o_mode o_mode_, int n_bits_ )
198: m_wl( a.m_wl ), m_iwl( a.m_iwl ),
199  m_q_mode( q_mode_ ),
200  m_o_mode( o_mode_ ), m_n_bits( n_bits_ )
201{}
202
203inline
204sc_fxtype_params::sc_fxtype_params( sc_without_context )
205: m_wl    ( SC_DEFAULT_WL_ ),
206  m_iwl   ( SC_DEFAULT_IWL_ ),
207  m_q_mode( SC_DEFAULT_Q_MODE_ ),
208  m_o_mode( SC_DEFAULT_O_MODE_ ),
209  m_n_bits( SC_DEFAULT_N_BITS_ )
210{}
211
212
213inline
214sc_fxtype_params&
215sc_fxtype_params::operator = ( const sc_fxtype_params& a )
216{
217    if( &a != this )
218    {
219        m_wl     = a.m_wl;
220	m_iwl    = a.m_iwl;
221	m_q_mode = a.m_q_mode;
222	m_o_mode = a.m_o_mode;
223	m_n_bits = a.m_n_bits;
224    }
225    return *this;
226}
227
228
229inline
230bool
231operator == ( const sc_fxtype_params& a, const sc_fxtype_params& b )
232{
233    return ( a.m_wl     == b.m_wl     &&
234	     a.m_iwl    == b.m_iwl    &&
235	     a.m_q_mode == b.m_q_mode &&
236	     a.m_o_mode == b.m_o_mode &&
237	     a.m_n_bits == b.m_n_bits );
238}
239
240inline
241bool
242operator != ( const sc_fxtype_params& a, const sc_fxtype_params& b )
243{
244    return ( a.m_wl     != b.m_wl     ||
245	     a.m_iwl    != b.m_iwl    ||
246	     a.m_q_mode != b.m_q_mode ||
247	     a.m_o_mode != b.m_o_mode ||
248	     a.m_n_bits != b.m_n_bits );
249}
250
251
252inline
253int
254sc_fxtype_params::wl() const
255{
256    return m_wl;
257}
258
259inline
260void
261sc_fxtype_params::wl( int wl_ )
262{
263    SC_CHECK_WL_( wl_ );
264    m_wl = wl_;
265}
266
267
268inline
269int
270sc_fxtype_params::iwl() const
271{
272    return m_iwl;
273}
274
275inline
276void
277sc_fxtype_params::iwl( int iwl_ )
278{
279    m_iwl = iwl_;
280}
281
282
283inline
284sc_q_mode
285sc_fxtype_params::q_mode() const
286{
287    return m_q_mode;
288}
289
290inline
291void
292sc_fxtype_params::q_mode( sc_q_mode q_mode_ )
293{
294    m_q_mode = q_mode_;
295}
296
297
298inline
299sc_o_mode
300sc_fxtype_params::o_mode() const
301{
302    return m_o_mode;
303}
304
305inline
306void
307sc_fxtype_params::o_mode( sc_o_mode o_mode_ )
308{
309    m_o_mode = o_mode_;
310}
311
312
313inline
314int
315sc_fxtype_params::n_bits() const
316{
317    return m_n_bits;
318}
319
320inline
321void
322sc_fxtype_params::n_bits( int n_bits_ )
323{
324    SC_CHECK_N_BITS_( n_bits_ );
325    m_n_bits = n_bits_;
326}
327
328
329inline
330::std::ostream&
331operator << ( ::std::ostream& os, const sc_fxtype_params& a )
332{
333    a.print( os );
334    return os;
335}
336
337} // namespace sc_dt
338
339
340#endif
341
342// Taf!
343