SystemC  2.3.1
Accellera SystemC proof-of-concept library
scfx_other_defs.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  scfx_other_defs.h -
21 
22  Original Author: Martin Janssen, Synopsys, Inc.
23 
24  *****************************************************************************/
25 
26 /*****************************************************************************
27 
28  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
29  changes you are making here.
30 
31  Name, Affiliation, Date:
32  Description of Modification:
33 
34  *****************************************************************************/
35 
36 // $Log: scfx_other_defs.h,v $
37 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
38 // SystemC 2.3
39 //
40 // Revision 1.3 2006/01/13 18:53:58 acg
41 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
42 // the source.
43 //
44 
45 #ifndef SCFX_OTHER_DEFS_H
46 #define SCFX_OTHER_DEFS_H
47 
48 
54 #include "sysc/tracing/sc_trace.h"
55 
56 
57 namespace sc_dt
58 {
59 
60 #ifdef SC_INCLUDE_FX
61 
62 // ----------------------------------------------------------------------------
63 // CLASS : sc_signed
64 // ----------------------------------------------------------------------------
65 
66 // assignment operators
67 
68 inline
69 const sc_signed&
70 sc_signed::operator = ( const sc_fxval& v )
71 {
72  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
73  {
74  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
75  "sc_signed::operator = ( const sc_fxval& )" );
76  }
77 
78  for( int i = 0; i < length(); ++ i )
79  (*this)[i] = v.get_bit( i );
80 
81  return *this;
82 }
83 
84 inline
85 const sc_signed&
86 sc_signed::operator = ( const sc_fxval_fast& v )
87 {
88  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
89  {
90  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
91  "sc_signed::operator = ( const sc_fxval_fast& )" );
92  }
93 
94  for( int i = 0; i < length(); ++ i )
95  (*this)[i] = v.get_bit( i );
96 
97  return *this;
98 }
99 
100 inline
101 const sc_signed&
102 sc_signed::operator = ( const sc_fxnum& v )
103 {
104  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
105  {
106  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
107  "sc_signed::operator = ( const sc_fxnum& )" );
108  }
109 
110  for( int i = 0; i < length(); ++ i )
111  (*this)[i] = v.get_bit( i );
112 
113  return *this;
114 }
115 
116 inline
117 const sc_signed&
118 sc_signed::operator = ( const sc_fxnum_fast& v )
119 {
120  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
121  {
122  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
123  "sc_signed::operator = ( const sc_fxnum_fast& )" );
124  }
125 
126  for( int i = 0; i < length(); ++ i )
127  (*this)[i] = v.get_bit( i );
128 
129  return *this;
130 }
131 
132 
133 // ----------------------------------------------------------------------------
134 // CLASS : sc_unsigned
135 // ----------------------------------------------------------------------------
136 
137 // assignment operators
138 
139 inline
140 const sc_unsigned&
141 sc_unsigned::operator = ( const sc_fxval& v )
142 {
143  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
144  {
145  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
146  "sc_unsigned::operator = ( const sc_fxval& )" );
147  }
148 
149  for( int i = 0; i < length(); ++ i )
150  (*this)[i] = v.get_bit( i );
151 
152  return *this;
153 }
154 
155 inline
156 const sc_unsigned&
157 sc_unsigned::operator = ( const sc_fxval_fast& v )
158 {
159  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
160  {
161  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
162  "sc_unsigned::operator = ( const sc_fxval_fast& )" );
163  }
164 
165  for( int i = 0; i < length(); ++ i )
166  (*this)[i] = v.get_bit( i );
167 
168  return *this;
169 }
170 
171 inline
172 const sc_unsigned&
173 sc_unsigned::operator = ( const sc_fxnum& v )
174 {
175  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
176  {
177  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
178  "sc_unsigned::operator = ( const sc_fxnum& )" );
179  }
180 
181  for( int i = 0; i < length(); ++ i )
182  (*this)[i] = v.get_bit( i );
183 
184  return *this;
185 }
186 
187 inline
188 const sc_unsigned&
189 sc_unsigned::operator = ( const sc_fxnum_fast& v )
190 {
191  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
192  {
193  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
194  "sc_unsigned::operator = ( const sc_fxnum_fast& )" );
195  }
196 
197  for( int i = 0; i < length(); ++ i )
198  (*this)[i] = v.get_bit( i );
199 
200  return *this;
201 }
202 
203 
204 // ----------------------------------------------------------------------------
205 // CLASS : sc_int_base
206 // ----------------------------------------------------------------------------
207 
208 #ifndef _32BIT_
209 #define NUM_WIDTH LLWIDTH
210 #else
211 #define NUM_WIDTH INTWIDTH
212 #endif
213 
214 
215 // assignment operators
216 
217 inline
218 sc_int_base&
219 sc_int_base::operator = ( const sc_fxval& v )
220 {
221  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
222  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
223  "sc_int_base::operator = ( const sc_fxval& )" );
224  }
225  for( int i = 0; i < m_len; ++ i ) {
226  set( i, v.get_bit( i ) );
227  }
228  extend_sign();
229  return *this;
230 }
231 
232 inline
233 sc_int_base&
234 sc_int_base::operator = ( const sc_fxval_fast& v )
235 {
236  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
237  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
238  "sc_int_base::operator = ( const sc_fxval_fast& )" );
239  }
240  for( int i = 0; i < m_len; ++ i ) {
241  set( i, v.get_bit( i ) );
242  }
243  extend_sign();
244  return *this;
245 }
246 
247 inline
248 sc_int_base&
249 sc_int_base::operator = ( const sc_fxnum& v )
250 {
251  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
252  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
253  "sc_int_base::operator = ( const sc_fxnum& )" );
254  }
255  for( int i = 0; i < m_len; ++ i ) {
256  set( i, v.get_bit( i ) );
257  }
258  extend_sign();
259  return *this;
260 }
261 
262 inline
263 sc_int_base&
264 sc_int_base::operator = ( const sc_fxnum_fast& v )
265 {
266  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
267  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
268  "sc_int_base::operator = ( const sc_fxnum_fast& )" );
269  }
270  for( int i = 0; i < m_len; ++ i ) {
271  set( i, v.get_bit( i ) );
272  }
273  extend_sign();
274  return *this;
275 }
276 
277 #undef NUM_WIDTH
278 
279 
280 // ----------------------------------------------------------------------------
281 // CLASS : sc_uint_base
282 // ----------------------------------------------------------------------------
283 
284 // assignment operators
285 
286 inline
287 sc_uint_base&
288 sc_uint_base::operator = ( const sc_fxval& v )
289 {
290  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
291  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
292  "sc_uint_base::operator = ( const sc_fxval& )" );
293  }
294  for( int i = 0; i < m_len; ++ i ) {
295  set( i, v.get_bit( i ) );
296  }
297  extend_sign();
298  return *this;
299 }
300 
301 inline
302 sc_uint_base&
303 sc_uint_base::operator = ( const sc_fxval_fast& v )
304 {
305  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
306  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
307  "sc_uint_base::operator = ( const sc_fxval_fast& )" );
308  }
309  for( int i = 0; i < m_len; ++ i ) {
310  set( i, v.get_bit( i ) );
311  }
312  extend_sign();
313  return *this;
314 }
315 
316 inline
317 sc_uint_base&
318 sc_uint_base::operator = ( const sc_fxnum& v )
319 {
320  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
321  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
322  "sc_uint_base::operator = ( const sc_fxnum& )" );
323  }
324  for( int i = 0; i < m_len; ++ i ) {
325  set( i, v.get_bit( i ) );
326  }
327  extend_sign();
328  return *this;
329 }
330 
331 inline
332 sc_uint_base&
333 sc_uint_base::operator = ( const sc_fxnum_fast& v )
334 {
335  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
336  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
337  "sc_uint_base::operator = ( const sc_fxnum_fast& )" );
338  }
339  for( int i = 0; i < m_len; ++ i ) {
340  set( i, v.get_bit( i ) );
341  }
342  extend_sign();
343  return *this;
344 }
345 
346 
347 #endif
348 
349 
350 // ----------------------------------------------------------------------------
351 // FUNCTION : sc_trace
352 // ----------------------------------------------------------------------------
353 
354 inline
355 void
357  const sc_fxval& object, const std::string& name )
358 {
359  if( tf )
360  tf->trace( object, name );
361 }
362 
363 inline
364 void
366  const sc_fxval* object, const std::string& name )
367 {
368  if( tf )
369  tf->trace( *object, name );
370 }
371 
372 inline
373 void
375  const sc_fxval_fast& object, const std::string& name )
376 {
377  if( tf )
378  tf->trace( object, name );
379 }
380 
381 inline
382 void
384  const sc_fxval_fast* object, const std::string& name )
385 {
386  if( tf )
387  tf->trace( *object, name );
388 }
389 
390 inline
391 void
393  const sc_fxnum& object, const std::string& name )
394 {
395  if( tf )
396  tf->trace( object, name );
397 }
398 
399 inline
400 void
402  const sc_fxnum* object, const std::string& name )
403 {
404  if( tf )
405  tf->trace( *object, name );
406 }
407 
408 inline
409 void
411  const sc_fxnum_fast& object, const std::string& name )
412 {
413  if( tf )
414  tf->trace( object, name );
415 }
416 
417 inline
418 void
420  const sc_fxnum_fast* object, const std::string& name )
421 {
422  if( tf )
423  tf->trace( *object, name );
424 }
425 
426 } // namespace sc_dt
427 
428 
429 #endif
430 
431 // Taf!
sc_int_base & operator=(int_type v)
Definition: sc_int_base.h:614
virtual void trace(const unsigned int &object, const std::string &name, const char **enum_literals)=0
int length() const
Definition: sc_signed.h:1326
void set(int i)
Definition: sc_int_base.h:757
int length() const
Definition: sc_unsigned.h:1226
const sc_signed & operator=(const sc_signed &v)
sc_uint_base & operator=(uint_type v)
Definition: sc_uint_base.h:599
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:213
void sc_trace(sc_core::sc_trace_file *tf, const sc_fxval &object, const std::string &name)
const sc_unsigned & operator=(const sc_unsigned &v)