SystemC  2.3.2
Accellera SystemC proof-of-concept library
scfx_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  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 SCFX_PARAMS_H
48 #define SCFX_PARAMS_H
49 
50 
54 
55 
56 namespace sc_dt
57 {
58 
59 // classes defined in this module
60 class scfx_params;
61 
62 
68 {
69 
70 public:
71 
72  // constructor
73 
75  sc_enc,
76  const sc_fxcast_switch& );
77 
78 
79  // query functions
80 
81  const sc_fxtype_params& type_params() const;
82  sc_enc enc() const;
83  const sc_fxcast_switch& cast_switch() const;
84 
85 
86  // shortcuts
87 
88  int wl() const;
89  int iwl() const;
90  int fwl() const;
91  sc_q_mode q_mode() const;
92  sc_o_mode o_mode() const;
93  int n_bits() const;
94 
95 
96  // dump content
97 
98  void dump( ::std::ostream& ) const;
99 
100 private:
101 
102  sc_fxtype_params m_type_params;
103  sc_enc m_enc;
104  sc_fxcast_switch m_cast_switch;
105 
106 };
107 
108 
109 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
110 
111 // constructor
112 
113 inline
115  sc_enc enc_,
116  const sc_fxcast_switch& cast_sw )
117 : m_type_params( type_params_ ),
118  m_enc( enc_ ),
119  m_cast_switch( cast_sw )
120 {
121  if( m_enc == SC_US_ && m_type_params.o_mode() == SC_WRAP_SM )
122  {
123  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_O_MODE_,
124  "SC_WRAP_SM not defined for unsigned numbers" );
125  // may continue, if suppressed
126  }
127 
128 }
129 
130 
131 // query functions
132 
133 inline
134 const sc_fxtype_params&
136 {
137  return m_type_params;
138 }
139 
140 inline
141 sc_enc
143 {
144  return m_enc;
145 }
146 
147 inline
148 const sc_fxcast_switch&
150 {
151  return m_cast_switch;
152 }
153 
154 
155 // shortcuts
156 
157 inline
158 int
160 {
161  return m_type_params.wl();
162 }
163 
164 inline
165 int
167 {
168  return m_type_params.iwl();
169 }
170 
171 inline
172 int
174 {
175  return ( m_type_params.wl() - m_type_params.iwl() );
176 }
177 
178 inline
179 sc_q_mode
181 {
182  return m_type_params.q_mode();
183 }
184 
185 inline
186 sc_o_mode
188 {
189  return m_type_params.o_mode();
190 }
191 
192 inline
193 int
195 {
196  return m_type_params.n_bits();
197 }
198 
199 
200 // dump content
201 
202 inline
203 void
204 scfx_params::dump( ::std::ostream& os ) const
205 {
206  os << "scfx_params" << ::std::endl;
207  os << "(" << ::std::endl;
208  os << "type_params = ";
209  m_type_params.dump( os );
210  os << "enc = " << m_enc << ::std::endl;
211  os << "cast_switch = ";
212  m_cast_switch.dump( os );
213  os << ")" << ::std::endl;
214 }
215 
216 } // namespace sc_dt
217 
218 
219 #endif
220 
221 // Taf!
Report ids for the datatypes/fx code.
scfx_params(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &)
Definition: scfx_params.h:114
void dump(::std::ostream &=::std::cout) const
sc_enc
Enumeration of sign encodings.
Definition: sc_fxdefs.h:66
Fixed-point cast switch class.
int n_bits() const
Definition: scfx_params.h:194
int fwl() const
Definition: scfx_params.h:173
sc_o_mode o_mode() const
void dump(::std::ostream &) const
Definition: scfx_params.h:204
int wl() const
Definition: scfx_params.h:159
const sc_fxtype_params & type_params() const
Definition: scfx_params.h:135
int iwl() const
Definition: scfx_params.h:166
Fixed-point type parameters class.
void dump(::std::ostream &=::std::cout) const
sc_o_mode o_mode() const
Definition: scfx_params.h:187
sc_q_mode
Enumeration of quantization modes.
Definition: sc_fxdefs.h:90
sc_q_mode q_mode() const
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:223
sc_enc enc() const
Definition: scfx_params.h:142
const sc_fxcast_switch & cast_switch() const
Definition: scfx_params.h:149
sc_o_mode
Enumeration of overflow modes.
Definition: sc_fxdefs.h:119
#define SC_API
Definition: sc_cmnhdr.h:168
sc_q_mode q_mode() const
Definition: scfx_params.h:180