SystemC  2.3.2
Accellera SystemC proof-of-concept library
scfx_other_defs.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_other_defs.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_other_defs.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_OTHER_DEFS_H
48 #define SCFX_OTHER_DEFS_H
49 
50 
56 #include "sysc/tracing/sc_trace.h"
57 
58 
59 namespace sc_dt
60 {
61 
62 #ifdef SC_INCLUDE_FX
63 
68 // assignment operators
69 
70 inline
71 const sc_signed&
72 sc_signed::operator = ( const sc_fxval& v )
73 {
74  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
75  {
76  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
77  "sc_signed::operator = ( const sc_fxval& )" );
78  return *this;
79  }
80 
81  for( int i = 0; i < length(); ++ i )
82  (*this)[i] = v.get_bit( i );
83 
84  return *this;
85 }
86 
87 inline
88 const sc_signed&
89 sc_signed::operator = ( const sc_fxval_fast& v )
90 {
91  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
92  {
93  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
94  "sc_signed::operator = ( const sc_fxval_fast& )" );
95  return *this;
96  }
97 
98  for( int i = 0; i < length(); ++ i )
99  (*this)[i] = v.get_bit( i );
100 
101  return *this;
102 }
103 
104 inline
105 const sc_signed&
106 sc_signed::operator = ( const sc_fxnum& v )
107 {
108  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
109  {
110  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
111  "sc_signed::operator = ( const sc_fxnum& )" );
112  return *this;
113  }
114 
115  for( int i = 0; i < length(); ++ i )
116  (*this)[i] = v.get_bit( i );
117 
118  return *this;
119 }
120 
121 inline
122 const sc_signed&
123 sc_signed::operator = ( const sc_fxnum_fast& v )
124 {
125  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
126  {
127  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
128  "sc_signed::operator = ( const sc_fxnum_fast& )" );
129  return *this;
130  }
131 
132  for( int i = 0; i < length(); ++ i )
133  (*this)[i] = v.get_bit( i );
134 
135  return *this;
136 }
137 
138 
143 // assignment operators
144 
145 inline
146 const sc_unsigned&
147 sc_unsigned::operator = ( const sc_fxval& v )
148 {
149  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
150  {
151  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
152  "sc_unsigned::operator = ( const sc_fxval& )" );
153  return *this;
154  }
155 
156  for( int i = 0; i < length(); ++ i )
157  (*this)[i] = v.get_bit( i );
158 
159  return *this;
160 }
161 
162 inline
163 const sc_unsigned&
164 sc_unsigned::operator = ( const sc_fxval_fast& v )
165 {
166  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
167  {
168  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
169  "sc_unsigned::operator = ( const sc_fxval_fast& )" );
170  return *this;
171  }
172 
173  for( int i = 0; i < length(); ++ i )
174  (*this)[i] = v.get_bit( i );
175 
176  return *this;
177 }
178 
179 inline
180 const sc_unsigned&
181 sc_unsigned::operator = ( const sc_fxnum& v )
182 {
183  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
184  {
185  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
186  "sc_unsigned::operator = ( const sc_fxnum& )" );
187  return *this;
188  }
189 
190  for( int i = 0; i < length(); ++ i )
191  (*this)[i] = v.get_bit( i );
192 
193  return *this;
194 }
195 
196 inline
197 const sc_unsigned&
198 sc_unsigned::operator = ( const sc_fxnum_fast& v )
199 {
200  if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
201  {
202  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
203  "sc_unsigned::operator = ( const sc_fxnum_fast& )" );
204  return *this;
205  }
206 
207  for( int i = 0; i < length(); ++ i )
208  (*this)[i] = v.get_bit( i );
209 
210  return *this;
211 }
212 
213 
218 // assignment operators
219 
220 inline
221 sc_int_base&
222 sc_int_base::operator = ( const sc_fxval& v )
223 {
224  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
225  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
226  "sc_int_base::operator = ( const sc_fxval& )" );
227  return *this;
228  }
229  for( int i = 0; i < m_len; ++ i ) {
230  set( i, v.get_bit( i ) );
231  }
232  extend_sign();
233  return *this;
234 }
235 
236 inline
237 sc_int_base&
238 sc_int_base::operator = ( const sc_fxval_fast& v )
239 {
240  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
241  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
242  "sc_int_base::operator = ( const sc_fxval_fast& )" );
243  return *this;
244  }
245  for( int i = 0; i < m_len; ++ i ) {
246  set( i, v.get_bit( i ) );
247  }
248  extend_sign();
249  return *this;
250 }
251 
252 inline
253 sc_int_base&
254 sc_int_base::operator = ( const sc_fxnum& v )
255 {
256  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
257  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
258  "sc_int_base::operator = ( const sc_fxnum& )" );
259  return *this;
260  }
261  for( int i = 0; i < m_len; ++ i ) {
262  set( i, v.get_bit( i ) );
263  }
264  extend_sign();
265  return *this;
266 }
267 
268 inline
269 sc_int_base&
270 sc_int_base::operator = ( const sc_fxnum_fast& v )
271 {
272  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
273  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
274  "sc_int_base::operator = ( const sc_fxnum_fast& )" );
275  return *this;
276  }
277  for( int i = 0; i < m_len; ++ i ) {
278  set( i, v.get_bit( i ) );
279  }
280  extend_sign();
281  return *this;
282 }
283 
284 
289 // assignment operators
290 
291 inline
292 sc_uint_base&
293 sc_uint_base::operator = ( const sc_fxval& v )
294 {
295  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
296  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
297  "sc_uint_base::operator = ( const sc_fxval& )" );
298  return *this;
299  }
300  for( int i = 0; i < m_len; ++ i ) {
301  set( i, v.get_bit( i ) );
302  }
303  extend_sign();
304  return *this;
305 }
306 
307 inline
308 sc_uint_base&
309 sc_uint_base::operator = ( const sc_fxval_fast& v )
310 {
311  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
312  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
313  "sc_uint_base::operator = ( const sc_fxval_fast& )" );
314  return *this;
315  }
316  for( int i = 0; i < m_len; ++ i ) {
317  set( i, v.get_bit( i ) );
318  }
319  extend_sign();
320  return *this;
321 }
322 
323 inline
324 sc_uint_base&
325 sc_uint_base::operator = ( const sc_fxnum& v )
326 {
327  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
328  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
329  "sc_uint_base::operator = ( const sc_fxnum& )" );
330  return *this;
331  }
332  for( int i = 0; i < m_len; ++ i ) {
333  set( i, v.get_bit( i ) );
334  }
335  extend_sign();
336  return *this;
337 }
338 
339 inline
340 sc_uint_base&
341 sc_uint_base::operator = ( const sc_fxnum_fast& v )
342 {
343  if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
344  SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
345  "sc_uint_base::operator = ( const sc_fxnum_fast& )" );
346  return *this;
347  }
348  for( int i = 0; i < m_len; ++ i ) {
349  set( i, v.get_bit( i ) );
350  }
351  extend_sign();
352  return *this;
353 }
354 
355 
356 #endif
357 
358 
359 } // namespace sc_dt
360 
361 
362 #endif
363 
364 // Taf!
Report ids for the datatypes/fx code.
Arbitrary precision signed arithmetic.
sc_int_base & operator=(int_type v)
Definition: sc_int_base.h:625
sc_uint_base & operator=(uint_type v)
Definition: sc_uint_base.h:610
int length() const
Definition: sc_signed.h:1342
friend class sc_unsigned
Definition: sc_signed.h:1106
An unsigned integer whose length is less than 64 bits.
Arbitrary precision unsigned arithmetic.
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:223
const sc_signed & operator=(const sc_signed &v)
A signed integer whose length is less than 64 bit.
sc_signed(int nb=sc_length_param().len())
const sc_unsigned & operator=(const sc_unsigned &v)