summaryrefslogtreecommitdiff
path: root/src/systemc/ext/dt/fx/scfx_params.hh
blob: dd5c9b69579e0083598d7273b082fa29ece5ca6b (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
/*****************************************************************************

  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.

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

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

  scfx_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: scfx_params.h,v $
// 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_SCFX_PARAMS_HH__
#define __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__

#include "sc_fxcast_switch.hh"
#include "sc_fxtype_params.hh"

namespace sc_dt
{

// classes defined in this module
class scfx_params;


// ----------------------------------------------------------------------------
//  CLASS : scfx_params
//
//  ...
// ----------------------------------------------------------------------------

class scfx_params
{
  public:
    // constructor
    scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &);

    // query functions
    const sc_fxtype_params &type_params() const;
    sc_enc enc() const;
    const sc_fxcast_switch &cast_switch() const;

    // shortcuts
    int wl() const;
    int iwl() const;
    int fwl() const;
    sc_q_mode q_mode() const;
    sc_o_mode o_mode() const;
    int n_bits() const;

    // dump content
    void dump(::std::ostream &) const;

  private:
    sc_fxtype_params m_type_params;
    sc_enc m_enc;
    sc_fxcast_switch m_cast_switch;
};


// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

// constructor
inline scfx_params::scfx_params(const sc_fxtype_params &type_params_,
                                sc_enc enc_,
                                const sc_fxcast_switch &cast_sw) :
    m_type_params(type_params_), m_enc(enc_), m_cast_switch(cast_sw)
{
    if (m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM) {
        SC_REPORT_ERROR("invalid overflow mode",
                        "SC_WRAP_SM not defined for unsigned numbers");
        // may continue, if suppressed
    }
}

// query functions
inline const sc_fxtype_params &
scfx_params::type_params() const
{
    return m_type_params;
}

inline sc_enc
scfx_params::enc() const
{
    return m_enc;
}

inline const sc_fxcast_switch &
scfx_params::cast_switch() const
{
    return m_cast_switch;
}

// shortcuts
inline int
scfx_params::wl() const
{
    return m_type_params.wl();
}

inline int
scfx_params::iwl() const
{
    return m_type_params.iwl();
}

inline int
scfx_params::fwl() const
{
    return (m_type_params.wl() - m_type_params.iwl());
}

inline sc_q_mode
scfx_params::q_mode() const
{
    return m_type_params.q_mode();
}

inline sc_o_mode
scfx_params::o_mode() const
{
    return m_type_params.o_mode();
}

inline int
scfx_params::n_bits() const
{
    return m_type_params.n_bits();
}

// dump content
inline void
scfx_params::dump(::std::ostream &os) const
{
    os << "scfx_params" << ::std::endl;
    os << "(" << ::std::endl;
    os << "type_params = ";
    m_type_params.dump( os );
    os << "enc         = " << m_enc << ::std::endl;
    os << "cast_switch = ";
    m_cast_switch.dump( os );
    os << ")" << ::std::endl;
}

} // namespace sc_dt

#endif // __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__