gem5  v20.1.0.0
sc_fxdefs.hh
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  sc_fxdefs.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_fxdefs.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:57 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_SC_FXDEFS_HH__
48 #define __SYSTEMC_EXT_DT_FX_SC_FXDEFS_HH__
49 
50 #include "../../utils/messages.hh"
51 #include "../../utils/sc_report_handler.hh"
52 #include "../int/sc_nbutils.hh"
53 #include "messages.hh"
54 
55 #if ULONG_MAX > 0xffffffffUL
56 # define SC_LONG_64 1
57 #else
58 # define SC_LONG_64 0
59 #endif
60 
61 namespace sc_dt
62 {
63 
64 // ----------------------------------------------------------------------------
65 // ENUM : sc_enc
66 //
67 // Enumeration of sign encodings.
68 // ----------------------------------------------------------------------------
69 
70 enum sc_enc
71 {
72  SC_TC_, // two's complement
73  SC_US_ // unsigned
74 };
75 
76 const std::string to_string(sc_enc);
77 
78 inline ::std::ostream &
79 operator << (::std::ostream &os, sc_enc enc)
80 {
81  return os << to_string(enc);
82 }
83 
84 
85 // ----------------------------------------------------------------------------
86 // ENUM : sc_q_mode
87 //
88 // Enumeration of quantization modes.
89 // ----------------------------------------------------------------------------
90 
92 {
93  SC_RND, // rounding to plus infinity
94  SC_RND_ZERO, // rounding to zero
95  SC_RND_MIN_INF, // rounding to minus infinity
96  SC_RND_INF, // rounding to infinity
97  SC_RND_CONV, // convergent rounding
98  SC_TRN, // truncation
99  SC_TRN_ZERO // truncation to zero
100 };
101 
102 const std::string to_string(sc_q_mode);
103 
104 inline ::std::ostream &
105 operator << (::std::ostream &os, sc_q_mode q_mode)
106 {
107  return os << to_string(q_mode);
108 }
109 
110 
111 // ----------------------------------------------------------------------------
112 // ENUM : sc_o_mode
113 //
114 // Enumeration of overflow modes.
115 // ----------------------------------------------------------------------------
116 
118 {
119  SC_SAT, // saturation
120  SC_SAT_ZERO, // saturation to zero
121  SC_SAT_SYM, // symmetrical saturation
122  SC_WRAP, // wrap-around (*)
123  SC_WRAP_SM // sign magnitude wrap-around (*)
124 };
125 
126 // (*) uses the number of saturated bits argument, see the documentation.
127 
128 const std::string to_string( sc_o_mode );
129 
130 inline ::std::ostream &
131 operator << (::std::ostream &os, sc_o_mode o_mode)
132 {
133  return os << to_string(o_mode);
134 }
135 
136 
137 // ----------------------------------------------------------------------------
138 // ENUM : sc_switch
139 //
140 // Enumeration of switch states.
141 // ----------------------------------------------------------------------------
142 
144 {
147 };
148 
149 const std::string to_string(sc_switch);
150 
151 inline ::std::ostream &
152 operator << (::std::ostream &os, sc_switch sw)
153 {
154  return os << to_string(sw);
155 }
156 
157 
158 // ----------------------------------------------------------------------------
159 // ENUM : sc_fmt
160 //
161 // Enumeration of formats for character string conversion.
162 // ----------------------------------------------------------------------------
163 
164 enum sc_fmt
165 {
166  SC_F, // fixed
167  SC_E // scientific
168 };
169 
170 const std::string to_string(sc_fmt);
171 
172 inline ::std::ostream &
173 operator << (::std::ostream &os, sc_fmt fmt)
174 {
175  return os << to_string(fmt);
176 }
177 
178 
179 // ----------------------------------------------------------------------------
180 // Built-in & default fixed-point type parameter values.
181 // ----------------------------------------------------------------------------
182 
183 const int SC_BUILTIN_WL_ = 32;
184 const int SC_BUILTIN_IWL_ = 32;
187 const int SC_BUILTIN_N_BITS_ = 0;
188 
194 
195 
196 // ----------------------------------------------------------------------------
197 // Built-in & default fixed-point cast switch parameter values.
198 // ----------------------------------------------------------------------------
199 
202 
203 
204 // ----------------------------------------------------------------------------
205 // Built-in & default fixed-point value type parameter values.
206 // ----------------------------------------------------------------------------
207 
208 const int SC_BUILTIN_DIV_WL_ = 64;
209 const int SC_BUILTIN_CTE_WL_ = 64;
210 const int SC_BUILTIN_MAX_WL_ = 1024;
211 
212 
213 #if defined(SC_FXDIV_WL) && (SC_FXDIV_WL > 0)
214 const int SC_DEFAULT_DIV_WL_ = SC_FXDIV_WL;
215 #else
217 #endif
218 
219 #if defined(SC_FXCTE_WL) && (SC_FXCTE_WL > 0)
220 const int SC_DEFAULT_CTE_WL_ = SC_FXCTE_WL;
221 #else
223 #endif
224 
225 #if defined(SC_FXMAX_WL) && (SC_FXMAX_WL > 0 || SC_FXMAX_WL == -1)
226 const int SC_DEFAULT_MAX_WL_ = SC_FXMAX_WL;
227 #else
229 #endif
230 
231 
232 // ----------------------------------------------------------------------------
233 // Dedicated error reporting and checking.
234 // ----------------------------------------------------------------------------
235 
236 #define SC_ERROR_IF_IMPL_(cnd, id, msg) \
237  do { \
238  if (cnd) { \
239  SC_REPORT_ERROR(id, msg); \
240  sc_core::sc_abort(); /* can't recover from here */ \
241  } \
242  } while ( false )
243 
244 #ifdef DEBUG_SYSTEMC
245 # define SC_ASSERT_(cnd, msg) \
246  SC_ERROR_IF_IMPL_(!(cnd), sc_core::SC_ID_INTERNAL_ERROR_, msg)
247 #else
248 # define SC_ASSERT_(cnd, msg) (void(0))
249 #endif
250 
251 #define SC_ERROR_IF_(cnd,id) SC_ERROR_IF_IMPL_(cnd, id, 0)
252 
253 #define SC_CHECK_WL_(wl) SC_ERROR_IF_((wl) <= 0, sc_core::SC_ID_INVALID_WL_)
254 
255 #define SC_CHECK_N_BITS_(n_bits) \
256  SC_ERROR_IF_((n_bits) < 0, sc_core::SC_ID_INVALID_N_BITS_)
257 
258 #define SC_CHECK_DIV_WL_(div_wl) \
259  SC_ERROR_IF_((div_wl) <= 0, sc_core::SC_ID_INVALID_DIV_WL_)
260 
261 #define SC_CHECK_CTE_WL_(cte_wl) \
262  SC_ERROR_IF_((cte_wl) <= 0, sc_core::SC_ID_INVALID_CTE_WL_)
263 
264 #define SC_CHECK_MAX_WL_(max_wl) \
265  SC_ERROR_IF_((max_wl) <= 0 && (max_wl) != -1, \
266  sc_core::SC_ID_INVALID_MAX_WL_)
267 
268 
269 // ----------------------------------------------------------------------------
270 // Generic observer macros.
271 // ----------------------------------------------------------------------------
272 
273 #define SC_OBSERVER_(object, observer_type, event) \
274 { \
275  if ((object).observer() != 0) { \
276  observer_type observer = (object).lock_observer(); \
277  observer->event((object)); \
278  (object).unlock_observer(observer); \
279  } \
280 }
281 
282 #define SC_OBSERVER_DEFAULT_(observer_type) \
283 { \
284  if (m_observer == 0 && observer_type::default_observer != 0) \
285  m_observer = (*observer_type::default_observer)(); \
286 }
287 
288 } // namespace sc_dt
289 
290 #endif // __SYSTEMC_EXT_DT_FX_SC_FXDEFS_HH__
sc_dt::SC_BUILTIN_CAST_SWITCH_
const sc_switch SC_BUILTIN_CAST_SWITCH_
Definition: sc_fxdefs.hh:200
sc_dt::SC_DEFAULT_DIV_WL_
const int SC_DEFAULT_DIV_WL_
Definition: sc_fxdefs.hh:216
sc_dt::SC_BUILTIN_IWL_
const int SC_BUILTIN_IWL_
Definition: sc_fxdefs.hh:184
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
sc_dt::SC_BUILTIN_Q_MODE_
const sc_q_mode SC_BUILTIN_Q_MODE_
Definition: sc_fxdefs.hh:185
sc_dt::SC_F
@ SC_F
Definition: sc_fxdefs.hh:166
ArmISA::sw
Bitfield< 10 > sw
Definition: miscregs_types.hh:371
sc_dt
Definition: sc_bit.cc:67
sc_dt::SC_DEFAULT_Q_MODE_
const sc_q_mode SC_DEFAULT_Q_MODE_
Definition: sc_fxdefs.hh:191
sc_dt::sc_o_mode
sc_o_mode
Definition: sc_fxdefs.hh:117
sc_dt::to_string
const std::string to_string(sc_enc enc)
Definition: sc_fxdefs.cc:91
sc_dt::operator<<
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
Definition: sc_signed.cc:853
sc_dt::SC_OFF
@ SC_OFF
Definition: sc_fxdefs.hh:145
sc_dt::SC_SAT_ZERO
@ SC_SAT_ZERO
Definition: sc_fxdefs.hh:120
sc_dt::SC_RND_INF
@ SC_RND_INF
Definition: sc_fxdefs.hh:96
sc_dt::sc_enc
sc_enc
Definition: sc_fxdefs.hh:70
sc_dt::SC_DEFAULT_WL_
const int SC_DEFAULT_WL_
Definition: sc_fxdefs.hh:189
sc_dt::SC_ON
@ SC_ON
Definition: sc_fxdefs.hh:146
sc_dt::SC_RND_CONV
@ SC_RND_CONV
Definition: sc_fxdefs.hh:97
sc_dt::SC_E
@ SC_E
Definition: sc_fxdefs.hh:167
sc_dt::sc_fmt
sc_fmt
Definition: sc_fxdefs.hh:164
sc_dt::SC_DEFAULT_CTE_WL_
const int SC_DEFAULT_CTE_WL_
Definition: sc_fxdefs.hh:222
sc_dt::sc_q_mode
sc_q_mode
Definition: sc_fxdefs.hh:91
sc_dt::SC_DEFAULT_IWL_
const int SC_DEFAULT_IWL_
Definition: sc_fxdefs.hh:190
sc_dt::SC_SAT
@ SC_SAT
Definition: sc_fxdefs.hh:119
sc_dt::SC_BUILTIN_N_BITS_
const int SC_BUILTIN_N_BITS_
Definition: sc_fxdefs.hh:187
sc_dt::SC_RND_ZERO
@ SC_RND_ZERO
Definition: sc_fxdefs.hh:94
sc_dt::SC_TRN
@ SC_TRN
Definition: sc_fxdefs.hh:98
sc_dt::SC_WRAP
@ SC_WRAP
Definition: sc_fxdefs.hh:122
sc_dt::SC_BUILTIN_O_MODE_
const sc_o_mode SC_BUILTIN_O_MODE_
Definition: sc_fxdefs.hh:186
sc_dt::SC_SAT_SYM
@ SC_SAT_SYM
Definition: sc_fxdefs.hh:121
messages.hh
sc_dt::SC_RND_MIN_INF
@ SC_RND_MIN_INF
Definition: sc_fxdefs.hh:95
sc_dt::SC_DEFAULT_MAX_WL_
const int SC_DEFAULT_MAX_WL_
Definition: sc_fxdefs.hh:228
sc_dt::SC_BUILTIN_CTE_WL_
const int SC_BUILTIN_CTE_WL_
Definition: sc_fxdefs.hh:209
sc_dt::SC_DEFAULT_O_MODE_
const sc_o_mode SC_DEFAULT_O_MODE_
Definition: sc_fxdefs.hh:192
sc_dt::SC_TC_
@ SC_TC_
Definition: sc_fxdefs.hh:72
sc_dt::sc_switch
sc_switch
Definition: sc_fxdefs.hh:143
sc_dt::SC_BUILTIN_MAX_WL_
const int SC_BUILTIN_MAX_WL_
Definition: sc_fxdefs.hh:210
sc_dt::SC_DEFAULT_N_BITS_
const int SC_DEFAULT_N_BITS_
Definition: sc_fxdefs.hh:193
sc_dt::SC_DEFAULT_CAST_SWITCH_
const sc_switch SC_DEFAULT_CAST_SWITCH_
Definition: sc_fxdefs.hh:201
sc_dt::SC_WRAP_SM
@ SC_WRAP_SM
Definition: sc_fxdefs.hh:123
sc_dt::SC_BUILTIN_DIV_WL_
const int SC_BUILTIN_DIV_WL_
Definition: sc_fxdefs.hh:208
sc_dt::SC_RND
@ SC_RND
Definition: sc_fxdefs.hh:93
sc_dt::SC_BUILTIN_WL_
const int SC_BUILTIN_WL_
Definition: sc_fxdefs.hh:183
sc_dt::SC_US_
@ SC_US_
Definition: sc_fxdefs.hh:73
sc_dt::SC_TRN_ZERO
@ SC_TRN_ZERO
Definition: sc_fxdefs.hh:99

Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17