scfx_params.hh (12853:e23d6f09069a) scfx_params.hh (13325:86323e6cc8ec)
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 scfx_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: scfx_params.h,v $
39// Revision 1.1.1.1 2006/12/15 20:20:04 acg
40// SystemC 2.3
41//
42// Revision 1.3 2006/01/13 18:53:58 acg
43// Andy Goodrich: added $Log command so that CVS comments are reproduced in
44// the source.
45//
46
47#ifndef __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
48#define __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
49
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 scfx_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: scfx_params.h,v $
39// Revision 1.1.1.1 2006/12/15 20:20:04 acg
40// SystemC 2.3
41//
42// Revision 1.3 2006/01/13 18:53:58 acg
43// Andy Goodrich: added $Log command so that CVS comments are reproduced in
44// the source.
45//
46
47#ifndef __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
48#define __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
49
50#include "messages.hh"
50#include "sc_fxcast_switch.hh"
51#include "sc_fxtype_params.hh"
52
53namespace sc_dt
54{
55
56// classes defined in this module
57class scfx_params;
58
59
60// ----------------------------------------------------------------------------
61// CLASS : scfx_params
62//
63// ...
64// ----------------------------------------------------------------------------
65
66class scfx_params
67{
68 public:
69 // constructor
70 scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &);
71
72 // query functions
73 const sc_fxtype_params &type_params() const;
74 sc_enc enc() const;
75 const sc_fxcast_switch &cast_switch() const;
76
77 // shortcuts
78 int wl() const;
79 int iwl() const;
80 int fwl() const;
81 sc_q_mode q_mode() const;
82 sc_o_mode o_mode() const;
83 int n_bits() const;
84
85 // dump content
86 void dump(::std::ostream &) const;
87
88 private:
89 sc_fxtype_params m_type_params;
90 sc_enc m_enc;
91 sc_fxcast_switch m_cast_switch;
92};
93
94
95// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
96
97// constructor
98inline scfx_params::scfx_params(const sc_fxtype_params &type_params_,
99 sc_enc enc_,
100 const sc_fxcast_switch &cast_sw) :
101 m_type_params(type_params_), m_enc(enc_), m_cast_switch(cast_sw)
102{
103 if (m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM) {
51#include "sc_fxcast_switch.hh"
52#include "sc_fxtype_params.hh"
53
54namespace sc_dt
55{
56
57// classes defined in this module
58class scfx_params;
59
60
61// ----------------------------------------------------------------------------
62// CLASS : scfx_params
63//
64// ...
65// ----------------------------------------------------------------------------
66
67class scfx_params
68{
69 public:
70 // constructor
71 scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &);
72
73 // query functions
74 const sc_fxtype_params &type_params() const;
75 sc_enc enc() const;
76 const sc_fxcast_switch &cast_switch() const;
77
78 // shortcuts
79 int wl() const;
80 int iwl() const;
81 int fwl() const;
82 sc_q_mode q_mode() const;
83 sc_o_mode o_mode() const;
84 int n_bits() const;
85
86 // dump content
87 void dump(::std::ostream &) const;
88
89 private:
90 sc_fxtype_params m_type_params;
91 sc_enc m_enc;
92 sc_fxcast_switch m_cast_switch;
93};
94
95
96// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
97
98// constructor
99inline scfx_params::scfx_params(const sc_fxtype_params &type_params_,
100 sc_enc enc_,
101 const sc_fxcast_switch &cast_sw) :
102 m_type_params(type_params_), m_enc(enc_), m_cast_switch(cast_sw)
103{
104 if (m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM) {
104 SC_REPORT_ERROR("invalid overflow mode",
105 "SC_WRAP_SM not defined for unsigned numbers");
105 SC_REPORT_ERROR(sc_core::SC_ID_INVALID_O_MODE_,
106 sc_core::SC_ID_WRAP_SM_NOT_DEFINED_);
106 // may continue, if suppressed
107 }
108}
109
110// query functions
111inline const sc_fxtype_params &
112scfx_params::type_params() const
113{
114 return m_type_params;
115}
116
117inline sc_enc
118scfx_params::enc() const
119{
120 return m_enc;
121}
122
123inline const sc_fxcast_switch &
124scfx_params::cast_switch() const
125{
126 return m_cast_switch;
127}
128
129// shortcuts
130inline int
131scfx_params::wl() const
132{
133 return m_type_params.wl();
134}
135
136inline int
137scfx_params::iwl() const
138{
139 return m_type_params.iwl();
140}
141
142inline int
143scfx_params::fwl() const
144{
145 return (m_type_params.wl() - m_type_params.iwl());
146}
147
148inline sc_q_mode
149scfx_params::q_mode() const
150{
151 return m_type_params.q_mode();
152}
153
154inline sc_o_mode
155scfx_params::o_mode() const
156{
157 return m_type_params.o_mode();
158}
159
160inline int
161scfx_params::n_bits() const
162{
163 return m_type_params.n_bits();
164}
165
166// dump content
167inline void
168scfx_params::dump(::std::ostream &os) const
169{
170 os << "scfx_params" << ::std::endl;
171 os << "(" << ::std::endl;
172 os << "type_params = ";
173 m_type_params.dump( os );
174 os << "enc = " << m_enc << ::std::endl;
175 os << "cast_switch = ";
176 m_cast_switch.dump( os );
177 os << ")" << ::std::endl;
178}
179
180} // namespace sc_dt
181
182#endif // __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__
107 // may continue, if suppressed
108 }
109}
110
111// query functions
112inline const sc_fxtype_params &
113scfx_params::type_params() const
114{
115 return m_type_params;
116}
117
118inline sc_enc
119scfx_params::enc() const
120{
121 return m_enc;
122}
123
124inline const sc_fxcast_switch &
125scfx_params::cast_switch() const
126{
127 return m_cast_switch;
128}
129
130// shortcuts
131inline int
132scfx_params::wl() const
133{
134 return m_type_params.wl();
135}
136
137inline int
138scfx_params::iwl() const
139{
140 return m_type_params.iwl();
141}
142
143inline int
144scfx_params::fwl() const
145{
146 return (m_type_params.wl() - m_type_params.iwl());
147}
148
149inline sc_q_mode
150scfx_params::q_mode() const
151{
152 return m_type_params.q_mode();
153}
154
155inline sc_o_mode
156scfx_params::o_mode() const
157{
158 return m_type_params.o_mode();
159}
160
161inline int
162scfx_params::n_bits() const
163{
164 return m_type_params.n_bits();
165}
166
167// dump content
168inline void
169scfx_params::dump(::std::ostream &os) const
170{
171 os << "scfx_params" << ::std::endl;
172 os << "(" << ::std::endl;
173 os << "type_params = ";
174 m_type_params.dump( os );
175 os << "enc = " << m_enc << ::std::endl;
176 os << "cast_switch = ";
177 m_cast_switch.dump( os );
178 os << ")" << ::std::endl;
179}
180
181} // namespace sc_dt
182
183#endif // __SYSTEMC_EXT_DT_FX_SCFX_PARAMS_HH__