SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_fxdefs.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  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 SC_FXDEFS_H
48 #define SC_FXDEFS_H
49 
50 
51 #include "sysc/kernel/sc_cmnhdr.h"
52 #include "sysc/utils/sc_machine.h"
55 
56 
57 namespace sc_dt
58 {
59 
66 enum sc_enc
67 {
69  SC_US_ // unsigned
70 };
71 
72 
73 SC_API const std::string to_string( sc_enc );
74 
75 
76 inline
77 ::std::ostream&
78 operator << ( ::std::ostream& os, sc_enc enc )
79 {
80  return os << to_string( enc );
81 }
82 
83 
91 {
98  SC_TRN_ZERO // truncation to zero
99 };
100 
101 
102 SC_API const std::string to_string( sc_q_mode );
103 
104 
105 inline
106 ::std::ostream&
107 operator << ( ::std::ostream& os, sc_q_mode q_mode )
108 {
109  return os << to_string( q_mode );
110 }
111 
112 
120 {
125  SC_WRAP_SM // sign magnitude wrap-around (*)
126 };
127 
128 // (*) uses the number of saturated bits argument, see the documentation.
129 
130 
131 SC_API const std::string to_string( sc_o_mode );
132 
133 
134 inline
135 ::std::ostream&
136 operator << ( ::std::ostream& os, sc_o_mode o_mode )
137 {
138  return os << to_string( o_mode );
139 }
140 
141 
149 {
152 };
153 
154 
155 SC_API const std::string to_string( sc_switch );
156 
157 
158 inline
159 ::std::ostream&
160 operator << ( ::std::ostream& os, sc_switch sw )
161 {
162  return os << to_string( sw );
163 }
164 
165 
172 enum sc_fmt
173 {
175  SC_E // scientific
176 };
177 
178 
179 SC_API const std::string to_string( sc_fmt );
180 
181 
182 inline
183 ::std::ostream&
184 operator << ( ::std::ostream& os, sc_fmt fmt )
185 {
186  return os << to_string( fmt );
187 }
188 
189 
194 const int SC_BUILTIN_WL_ = 32;
195 const int SC_BUILTIN_IWL_ = 32;
198 const int SC_BUILTIN_N_BITS_ = 0;
199 
200 
206 
207 
213 
214 
216 
217 
222 const int SC_BUILTIN_DIV_WL_ = 64;
223 const int SC_BUILTIN_CTE_WL_ = 64;
224 const int SC_BUILTIN_MAX_WL_ = 1024;
225 
226 
227 #if defined( SC_FXDIV_WL ) && ( SC_FXDIV_WL > 0 )
228 const int SC_DEFAULT_DIV_WL_ = SC_FXDIV_WL;
229 #else
230 const int SC_DEFAULT_DIV_WL_ = SC_BUILTIN_DIV_WL_;
231 #endif
232 
233 #if defined( SC_FXCTE_WL ) && ( SC_FXCTE_WL > 0 )
234 const int SC_DEFAULT_CTE_WL_ = SC_FXCTE_WL;
235 #else
236 const int SC_DEFAULT_CTE_WL_ = SC_BUILTIN_CTE_WL_;
237 #endif
238 
239 #if defined( SC_FXMAX_WL ) && ( SC_FXMAX_WL > 0 || SC_FXMAX_WL == -1 )
240 const int SC_DEFAULT_MAX_WL_ = SC_FXMAX_WL;
241 #else
242 const int SC_DEFAULT_MAX_WL_ = SC_BUILTIN_MAX_WL_;
243 #endif
244 
245 
251 #define SC_ERROR_IF_IMPL_(cnd,id,msg) \
252  do { \
253  if( cnd ) { \
254  SC_REPORT_ERROR( id, msg ); \
255  sc_core::sc_abort(); /* can't recover from here */ \
256  } \
257  } while( false )
258 
259 #ifdef DEBUG_SYSTEMC
260 # define SC_ASSERT_(cnd,msg) \
261  SC_ERROR_IF_IMPL_(!(cnd), sc_core::SC_ID_INTERNAL_ERROR_, msg )
262 #else
263 # define SC_ASSERT_(cnd,msg) (void(0))
264 #endif
265 
267 #define SC_ERROR_IF_(cnd,id) \
268  SC_ERROR_IF_IMPL_( cnd, id, 0 )
269 
271 #define SC_CHECK_WL_(wl) \
272  SC_ERROR_IF_( (wl) <= 0, sc_core::SC_ID_INVALID_WL_ )
273 
275 #define SC_CHECK_N_BITS_(n_bits) \
276  SC_ERROR_IF_( (n_bits) < 0, sc_core::SC_ID_INVALID_N_BITS_ )
277 
279 #define SC_CHECK_DIV_WL_(div_wl) \
280  SC_ERROR_IF_( (div_wl) <= 0, sc_core::SC_ID_INVALID_DIV_WL_ )
281 
283 #define SC_CHECK_CTE_WL_(cte_wl) \
284  SC_ERROR_IF_( (cte_wl) <= 0, sc_core::SC_ID_INVALID_CTE_WL_ )
285 
287 #define SC_CHECK_MAX_WL_(max_wl) \
288  SC_ERROR_IF_( (max_wl) <= 0 && (max_wl) != -1, \
289  sc_core::SC_ID_INVALID_MAX_WL_ )
290 
291 
297 #define SC_OBSERVER_(object,observer_type,event) \
298 { \
299  if( (object).observer() != 0 ) \
300  { \
301  observer_type observer = (object).lock_observer(); \
302  observer->event( (object) ); \
303  (object).unlock_observer( observer ); \
304  } \
305 }
306 
308 #define SC_OBSERVER_DEFAULT_(observer_type) \
309 { \
310  if( m_observer == 0 && observer_type::default_observer != 0 ) \
311  m_observer = (*observer_type::default_observer)(); \
312 }
313 
314 } // namespace sc_dt
315 
316 
317 #endif
318 
319 // Taf!
fixed
Definition: sc_fxdefs.h:174
saturation
Definition: sc_fxdefs.h:121
const int SC_BUILTIN_IWL_
Definition: sc_fxdefs.h:195
Report ids for the datatypes/fx code.
saturation to zero
Definition: sc_fxdefs.h:122
const sc_o_mode SC_DEFAULT_O_MODE_
Definition: sc_fxdefs.h:204
const int SC_BUILTIN_WL_
Definition: sc_fxdefs.h:194
sc_switch
Enumeration of switch states.
Definition: sc_fxdefs.h:148
sc_enc
Enumeration of sign encodings.
Definition: sc_fxdefs.h:66
const sc_o_mode SC_BUILTIN_O_MODE_
Definition: sc_fxdefs.h:197
const sc_q_mode SC_DEFAULT_Q_MODE_
Definition: sc_fxdefs.h:203
const int SC_DEFAULT_N_BITS_
Definition: sc_fxdefs.h:205
rounding to zero
Definition: sc_fxdefs.h:93
const int SC_BUILTIN_CTE_WL_
Definition: sc_fxdefs.h:223
const int SC_DEFAULT_WL_
Definition: sc_fxdefs.h:201
const int SC_BUILTIN_N_BITS_
Definition: sc_fxdefs.h:198
External and friend functions for both sc_signed and.
sc_fmt
Enumeration of formats for character string conversion.
Definition: sc_fxdefs.h:172
SC_API const std::string to_string(sc_enc)
rounding to infinity
Definition: sc_fxdefs.h:95
wrap-around (*)
Definition: sc_fxdefs.h:124
const sc_switch SC_DEFAULT_CAST_SWITCH_
Definition: sc_fxdefs.h:215
const int SC_BUILTIN_MAX_WL_
Definition: sc_fxdefs.h:224
rounding to plus infinity
Definition: sc_fxdefs.h:92
convergent rounding
Definition: sc_fxdefs.h:96
const int SC_DEFAULT_IWL_
Definition: sc_fxdefs.h:202
symmetrical saturation
Definition: sc_fxdefs.h:123
const sc_switch SC_BUILTIN_CAST_SWITCH_
Definition: sc_fxdefs.h:212
truncation
Definition: sc_fxdefs.h:97
two&#39;s complement
Definition: sc_fxdefs.h:68
sc_q_mode
Enumeration of quantization modes.
Definition: sc_fxdefs.h:90
const sc_q_mode SC_BUILTIN_Q_MODE_
Definition: sc_fxdefs.h:196
const int SC_DEFAULT_MAX_WL_
Definition: sc_fxdefs.h:242
rounding to minus infinity
Definition: sc_fxdefs.h:94
Machine-dependent Environment Settings.
const int SC_BUILTIN_DIV_WL_
Definition: sc_fxdefs.h:222
inline ::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:390
sc_o_mode
Enumeration of overflow modes.
Definition: sc_fxdefs.h:119
const int SC_DEFAULT_DIV_WL_
Definition: sc_fxdefs.h:230
#define SC_API
Definition: sc_cmnhdr.h:168
const int SC_DEFAULT_CTE_WL_
Definition: sc_fxdefs.h:236