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
51#include "sysc/datatypes/fx/sc_fx_ids.h"
52#include "sysc/datatypes/int/sc_signed.h"
53#include "sysc/datatypes/int/sc_unsigned.h"
54#include "sysc/datatypes/int/sc_int_base.h"
55#include "sysc/datatypes/int/sc_uint_base.h"
56#include "sysc/tracing/sc_trace.h"
57
58
59namespace sc_dt
60{
61
62#ifdef SC_INCLUDE_FX
63
64// ----------------------------------------------------------------------------
65//  CLASS : sc_signed
66// ----------------------------------------------------------------------------
67
68// assignment operators
69
70inline
71const sc_signed&
72sc_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    }
79
80    for( int i = 0; i < length(); ++ i )
81	(*this)[i] = v.get_bit( i );
82
83    return *this;
84}
85
86inline
87const sc_signed&
88sc_signed::operator = ( const sc_fxval_fast& v )
89{
90    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
91    {
92	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
93			 "sc_signed::operator = ( const sc_fxval_fast& )" );
94    }
95
96    for( int i = 0; i < length(); ++ i )
97	(*this)[i] = v.get_bit( i );
98
99    return *this;
100}
101
102inline
103const sc_signed&
104sc_signed::operator = ( const sc_fxnum& v )
105{
106    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
107    {
108	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
109			 "sc_signed::operator = ( const sc_fxnum& )" );
110    }
111
112    for( int i = 0; i < length(); ++ i )
113	(*this)[i] = v.get_bit( i );
114
115    return *this;
116}
117
118inline
119const sc_signed&
120sc_signed::operator = ( const sc_fxnum_fast& v )
121{
122    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
123    {
124	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
125			 "sc_signed::operator = ( const sc_fxnum_fast& )" );
126    }
127
128    for( int i = 0; i < length(); ++ i )
129	(*this)[i] = v.get_bit( i );
130
131    return *this;
132}
133
134
135// ----------------------------------------------------------------------------
136//  CLASS : sc_unsigned
137// ----------------------------------------------------------------------------
138
139// assignment operators
140
141inline
142const sc_unsigned&
143sc_unsigned::operator = ( const sc_fxval& v )
144{
145    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
146    {
147	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
148			 "sc_unsigned::operator = ( const sc_fxval& )" );
149    }
150
151    for( int i = 0; i < length(); ++ i )
152	(*this)[i] = v.get_bit( i );
153
154    return *this;
155}
156
157inline
158const sc_unsigned&
159sc_unsigned::operator = ( const sc_fxval_fast& v )
160{
161    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
162    {
163	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
164			 "sc_unsigned::operator = ( const sc_fxval_fast& )" );
165    }
166
167    for( int i = 0; i < length(); ++ i )
168	(*this)[i] = v.get_bit( i );
169
170    return *this;
171}
172
173inline
174const sc_unsigned&
175sc_unsigned::operator = ( const sc_fxnum& v )
176{
177    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
178    {
179	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
180			 "sc_unsigned::operator = ( const sc_fxnum& )" );
181    }
182
183    for( int i = 0; i < length(); ++ i )
184	(*this)[i] = v.get_bit( i );
185
186    return *this;
187}
188
189inline
190const sc_unsigned&
191sc_unsigned::operator = ( const sc_fxnum_fast& v )
192{
193    if( ! v.is_normal() ) /* also triggers OBSERVER_READ call */
194    {
195	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
196			 "sc_unsigned::operator = ( const sc_fxnum_fast& )" );
197    }
198
199    for( int i = 0; i < length(); ++ i )
200	(*this)[i] = v.get_bit( i );
201
202    return *this;
203}
204
205
206// ----------------------------------------------------------------------------
207//  CLASS : sc_int_base
208// ----------------------------------------------------------------------------
209
210#ifndef _32BIT_
211#define NUM_WIDTH LLWIDTH
212#else
213#define NUM_WIDTH INTWIDTH
214#endif
215
216
217// assignment operators
218
219inline
220sc_int_base&
221sc_int_base::operator = ( const sc_fxval& v )
222{
223    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
224	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
225			 "sc_int_base::operator = ( const sc_fxval& )" );
226    }
227    for( int i = 0; i < m_len; ++ i ) {
228	set( i, v.get_bit( i ) );
229    }
230    extend_sign();
231    return *this;
232}
233
234inline
235sc_int_base&
236sc_int_base::operator = ( const sc_fxval_fast& v )
237{
238    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
239	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
240			 "sc_int_base::operator = ( const sc_fxval_fast& )" );
241    }
242    for( int i = 0; i < m_len; ++ i ) {
243	set( i, v.get_bit( i ) );
244    }
245    extend_sign();
246    return *this;
247}
248
249inline
250sc_int_base&
251sc_int_base::operator = ( const sc_fxnum& v )
252{
253    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
254	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
255			 "sc_int_base::operator = ( const sc_fxnum& )" );
256    }
257    for( int i = 0; i < m_len; ++ i ) {
258	set( i, v.get_bit( i ) );
259    }
260    extend_sign();
261    return *this;
262}
263
264inline
265sc_int_base&
266sc_int_base::operator = ( const sc_fxnum_fast& v )
267{
268    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
269	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
270			 "sc_int_base::operator = ( const sc_fxnum_fast& )" );
271    }
272    for( int i = 0; i < m_len; ++ i ) {
273	set( i, v.get_bit( i ) );
274    }
275    extend_sign();
276    return *this;
277}
278
279#undef NUM_WIDTH
280
281
282// ----------------------------------------------------------------------------
283//  CLASS : sc_uint_base
284// ----------------------------------------------------------------------------
285
286// assignment operators
287
288inline
289sc_uint_base&
290sc_uint_base::operator = ( const sc_fxval& v )
291{
292    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
293	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
294			 "sc_uint_base::operator = ( const sc_fxval& )" );
295    }
296    for( int i = 0; i < m_len; ++ i ) {
297	set( i, v.get_bit( i ) );
298    }
299    extend_sign();
300    return *this;
301}
302
303inline
304sc_uint_base&
305sc_uint_base::operator = ( const sc_fxval_fast& v )
306{
307    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
308	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
309			 "sc_uint_base::operator = ( const sc_fxval_fast& )" );
310    }
311    for( int i = 0; i < m_len; ++ i ) {
312	set( i, v.get_bit( i ) );
313    }
314    extend_sign();
315    return *this;
316}
317
318inline
319sc_uint_base&
320sc_uint_base::operator = ( const sc_fxnum& v )
321{
322    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
323	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
324			 "sc_uint_base::operator = ( const sc_fxnum& )" );
325    }
326    for( int i = 0; i < m_len; ++ i ) {
327	set( i, v.get_bit( i ) );
328    }
329    extend_sign();
330    return *this;
331}
332
333inline
334sc_uint_base&
335sc_uint_base::operator = ( const sc_fxnum_fast& v )
336{
337    if( ! v.is_normal() ) { /* also triggers OBSERVER_READ call */
338	SC_REPORT_ERROR( sc_core::SC_ID_INVALID_FX_VALUE_,
339			 "sc_uint_base::operator = ( const sc_fxnum_fast& )" );
340    }
341    for( int i = 0; i < m_len; ++ i ) {
342	set( i, v.get_bit( i ) );
343    }
344    extend_sign();
345    return *this;
346}
347
348
349#endif
350
351
352// ----------------------------------------------------------------------------
353//  FUNCTION : sc_trace
354// ----------------------------------------------------------------------------
355
356inline
357void
358sc_trace( sc_core::sc_trace_file* tf,
359	  const sc_fxval& object, const std::string& name )
360{
361    if( tf )
362	tf->trace( object, name );
363}
364
365inline
366void
367sc_trace( sc_core::sc_trace_file* tf,
368	  const sc_fxval* object, const std::string& name )
369{
370    if( tf )
371	tf->trace( *object, name );
372}
373
374inline
375void
376sc_trace( sc_core::sc_trace_file* tf,
377	  const sc_fxval_fast& object, const std::string& name )
378{
379    if( tf )
380	tf->trace( object, name );
381}
382
383inline
384void
385sc_trace( sc_core::sc_trace_file* tf,
386	  const sc_fxval_fast* object, const std::string& name )
387{
388    if( tf )
389	tf->trace( *object, name );
390}
391
392inline
393void
394sc_trace( sc_core::sc_trace_file* tf,
395	  const sc_fxnum& object, const std::string& name )
396{
397    if( tf )
398	tf->trace( object, name );
399}
400
401inline
402void
403sc_trace( sc_core::sc_trace_file* tf,
404	  const sc_fxnum* object, const std::string& name )
405{
406    if( tf )
407	tf->trace( *object, name );
408}
409
410inline
411void
412sc_trace( sc_core::sc_trace_file* tf,
413	  const sc_fxnum_fast& object, const std::string& name )
414{
415    if( tf )
416	tf->trace( object, name );
417}
418
419inline
420void
421sc_trace( sc_core::sc_trace_file* tf,
422	  const sc_fxnum_fast* object, const std::string& name )
423{
424    if( tf )
425	tf->trace( *object, name );
426}
427
428} // namespace sc_dt
429
430
431#endif
432
433// Taf!
434