summaryrefslogtreecommitdiff
path: root/src/systemc/ext/dt/fx/sc_fxtype_params.hh
blob: b31b12cdd51757714ee9420217ee2e4f914eab8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*****************************************************************************

  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
  more contributor license agreements.  See the NOTICE file distributed
  with this work for additional information regarding copyright ownership.
  Accellera licenses this file to you under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with the
  License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  implied.  See the License for the specific language governing
  permissions and limitations under the License.

 *****************************************************************************/

/*****************************************************************************

  sc_fxtype_params.h -

  Original Author: Martin Janssen, Synopsys, Inc.

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

// $Log: sc_fxtype_params.h,v $
// Revision 1.2  2011/08/24 22:05:43  acg
//  Torsten Maehne: initialization changes to remove warnings.
//
// Revision 1.1.1.1  2006/12/15 20:20:04  acg
// SystemC 2.3
//
// Revision 1.3  2006/01/13 18:53:58  acg
// Andy Goodrich: added $Log command so that CVS comments are reproduced in
// the source.
//

#ifndef __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__
#define __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAMS_HH__

#include <iostream>

#include "sc_context.hh"
#include "sc_fxdefs.hh"

namespace sc_dt
{

// classes defined in this module
class sc_fxtype_params;

// ----------------------------------------------------------------------------
//  CLASS : sc_fxtype_params
//
//  Fixed-point type parameters class.
// ----------------------------------------------------------------------------

class sc_fxtype_params
{
  public:
    sc_fxtype_params();
    sc_fxtype_params(int, int);
    sc_fxtype_params(sc_q_mode, sc_o_mode, int=0);
    sc_fxtype_params(int, int, sc_q_mode, sc_o_mode, int=0);
    sc_fxtype_params(const sc_fxtype_params &);
    sc_fxtype_params(const sc_fxtype_params &, int, int);
    sc_fxtype_params(const sc_fxtype_params&, sc_q_mode, sc_o_mode, int=0);
    explicit sc_fxtype_params(sc_without_context);

    sc_fxtype_params &operator = (const sc_fxtype_params &);

    friend bool operator == (const sc_fxtype_params &,
                             const sc_fxtype_params &);
    friend bool operator != (const sc_fxtype_params &,
                             const sc_fxtype_params &);

    int wl() const;
    void wl(int);

    int iwl() const;
    void iwl(int);

    sc_q_mode q_mode() const;
    void q_mode(sc_q_mode);

    sc_o_mode o_mode() const;
    void o_mode(sc_o_mode);

    int n_bits() const;
    void n_bits(int);

    const std::string to_string() const;

    void print(::std::ostream & =::std::cout) const;
    void dump(::std::ostream & =::std::cout) const;

  private:
    int m_wl;
    int m_iwl;
    sc_q_mode m_q_mode;
    sc_o_mode m_o_mode;
    int m_n_bits;
};

} // namespace sc_dt

// ----------------------------------------------------------------------------
//  TYPEDEF : sc_fxtype_context
//
//  Context type for the fixed-point type parameters.
// ----------------------------------------------------------------------------

// extern template instantiations
namespace sc_dt
{

extern template class sc_global<sc_fxtype_params>;
extern template class sc_context<sc_fxtype_params>;
typedef sc_context<sc_fxtype_params> sc_fxtype_context;


// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

inline sc_fxtype_params::sc_fxtype_params() :
        m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
{
    *this = sc_fxtype_context::default_value();
}

inline sc_fxtype_params::sc_fxtype_params(int wl_, int iwl_) :
        m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
{
    *this = sc_fxtype_context::default_value();

    SC_CHECK_WL_(wl_);
    m_wl  = wl_;
    m_iwl = iwl_;
}

inline sc_fxtype_params::sc_fxtype_params(
        sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) :
    m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
{
    *this = sc_fxtype_context::default_value();

    SC_CHECK_N_BITS_(n_bits_);
    m_q_mode = q_mode_;
    m_o_mode = o_mode_;
    m_n_bits = n_bits_;
}

inline sc_fxtype_params::sc_fxtype_params(
        int wl_, int iwl_, sc_q_mode q_mode_, sc_o_mode o_mode_, int n_bits_) :
    m_wl(), m_iwl(), m_q_mode(), m_o_mode(), m_n_bits()
{
    SC_CHECK_WL_(wl_);
    SC_CHECK_N_BITS_(n_bits_);
    m_wl = wl_;
    m_iwl = iwl_;
    m_q_mode = q_mode_;
    m_o_mode = o_mode_;
    m_n_bits = n_bits_;
}

inline sc_fxtype_params::sc_fxtype_params(const sc_fxtype_params &a) :
        m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(a.m_q_mode),
        m_o_mode(a.m_o_mode), m_n_bits(a.m_n_bits)
{}

inline sc_fxtype_params::sc_fxtype_params(
        const sc_fxtype_params &a, int wl_, int iwl_) :
    m_wl(wl_), m_iwl(iwl_), m_q_mode(a.m_q_mode), m_o_mode(a.m_o_mode),
    m_n_bits(a.m_n_bits)
{}

inline sc_fxtype_params::sc_fxtype_params(
        const sc_fxtype_params &a, sc_q_mode q_mode_, sc_o_mode o_mode_,
        int n_bits_) :
    m_wl(a.m_wl), m_iwl(a.m_iwl), m_q_mode(q_mode_), m_o_mode(o_mode_),
    m_n_bits(n_bits_)
{}

inline sc_fxtype_params::sc_fxtype_params(sc_without_context) :
    m_wl(SC_DEFAULT_WL_), m_iwl(SC_DEFAULT_IWL_),
    m_q_mode(SC_DEFAULT_Q_MODE_), m_o_mode(SC_DEFAULT_O_MODE_),
    m_n_bits(SC_DEFAULT_N_BITS_)
{}

inline sc_fxtype_params &
sc_fxtype_params::operator = (const sc_fxtype_params &a)
{
    if (&a != this) {
        m_wl = a.m_wl;
        m_iwl = a.m_iwl;
        m_q_mode = a.m_q_mode;
        m_o_mode = a.m_o_mode;
        m_n_bits = a.m_n_bits;
    }
    return *this;
}

inline bool
operator == (const sc_fxtype_params &a, const sc_fxtype_params &b)
{
    return (a.m_wl == b.m_wl && a.m_iwl == b.m_iwl &&
            a.m_q_mode == b.m_q_mode && a.m_o_mode == b.m_o_mode &&
            a.m_n_bits == b.m_n_bits);
}

inline bool
operator != (const sc_fxtype_params &a, const sc_fxtype_params &b)
{
    return (a.m_wl != b.m_wl || a.m_iwl != b.m_iwl ||
            a.m_q_mode != b.m_q_mode || a.m_o_mode != b.m_o_mode ||
            a.m_n_bits != b.m_n_bits );
}

inline int sc_fxtype_params::wl() const { return m_wl; }
inline void
sc_fxtype_params::wl(int wl_)
{
    SC_CHECK_WL_(wl_);
    m_wl = wl_;
}

inline int sc_fxtype_params::iwl() const { return m_iwl; }
inline void sc_fxtype_params::iwl(int iwl_) { m_iwl = iwl_; }


inline sc_q_mode sc_fxtype_params::q_mode() const { return m_q_mode; }
inline void sc_fxtype_params::q_mode(sc_q_mode q_mode_) { m_q_mode = q_mode_; }

inline sc_o_mode sc_fxtype_params::o_mode() const { return m_o_mode; }
inline void sc_fxtype_params::o_mode(sc_o_mode o_mode_) { m_o_mode = o_mode_; }

inline int sc_fxtype_params::n_bits() const { return m_n_bits; }
inline void
sc_fxtype_params::n_bits(int n_bits_)
{
    SC_CHECK_N_BITS_(n_bits_);
    m_n_bits = n_bits_;
}

inline ::std::ostream &
operator << (::std::ostream &os, const sc_fxtype_params &a)
{
    a.print(os);
    return os;
}

} // namespace sc_dt

#endif // __SYSTEMC_EXT_DT_FX_SC_FXTYPE_PARAM_HH__