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 __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
48#define __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
49
50#include "../int/sc_int_base.hh"
51#include "../int/sc_signed.hh"
52#include "../int/sc_uint_base.hh"
53#include "../int/sc_unsigned.hh"
54#include "messages.hh"
55
56namespace sc_dt
57{
58
59// ----------------------------------------------------------------------------
60//  CLASS : sc_signed
61// ----------------------------------------------------------------------------
62
63// assignment operators
64inline const sc_signed &
65sc_signed::operator = (const sc_fxval &v)
66{
67    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
68        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
69                        "sc_signed::operator = ( const sc_fxval& )");
70        return *this;
71    }
72    for (int i = 0; i < length(); ++i)
73        (*this)[i] = v.get_bit(i);
74
75    return *this;
76}
77
78inline const sc_signed &
79sc_signed::operator = (const sc_fxval_fast &v)
80{
81    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
82        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
83                        "sc_signed::operator = ( const sc_fxval_fast& )");
84        return *this;
85    }
86
87    for (int i = 0; i < length(); ++i)
88        (*this)[i] = v.get_bit(i);
89
90    return *this;
91}
92
93inline const sc_signed &
94sc_signed::operator = (const sc_fxnum &v)
95{
96    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
97        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
98                        "sc_signed::operator = ( const sc_fxnum& )");
99        return *this;
100    }
101
102    for (int i = 0; i < length(); ++i)
103        (*this)[i] = v.get_bit(i);
104
105    return *this;
106}
107
108inline const sc_signed &
109sc_signed::operator = (const sc_fxnum_fast &v)
110{
111    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
112        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
113                        "sc_signed::operator = ( const sc_fxnum_fast& )");
114        return *this;
115    }
116
117    for (int i = 0; i < length(); ++i)
118        (*this)[i] = v.get_bit(i);
119
120    return *this;
121}
122
123
124// ----------------------------------------------------------------------------
125//  CLASS : sc_unsigned
126// ----------------------------------------------------------------------------
127
128// assignment operators
129
130inline const sc_unsigned &
131sc_unsigned::operator = (const sc_fxval &v)
132{
133    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
134        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
135                        "sc_unsigned::operator = ( const sc_fxval& )");
136        return *this;
137    }
138
139    for (int i = 0; i < length(); ++i)
140        (*this)[i] = v.get_bit(i);
141
142    return *this;
143}
144
145inline const sc_unsigned &
146sc_unsigned::operator = (const sc_fxval_fast &v)
147{
148    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
149        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
150                        "sc_unsigned::operator = ( const sc_fxval_fast& )");
151        return *this;
152    }
153
154    for (int i = 0; i < length(); ++i)
155        (*this)[i] = v.get_bit(i);
156
157    return *this;
158}
159
160inline const sc_unsigned &
161sc_unsigned::operator = (const sc_fxnum &v)
162{
163    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
164        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
165                        "sc_unsigned::operator = ( const sc_fxnum& )" );
166        return *this;
167    }
168
169    for (int i = 0; i < length(); ++i)
170        (*this)[i] = v.get_bit(i);
171
172    return *this;
173}
174
175inline const sc_unsigned &
176sc_unsigned::operator = (const sc_fxnum_fast &v)
177{
178    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
179        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
180                        "sc_unsigned::operator = ( const sc_fxnum_fast& )" );
181        return *this;
182    }
183
184    for (int i = 0; i < length(); ++i)
185        (*this)[i] = v.get_bit(i);
186
187    return *this;
188}
189
190
191// ----------------------------------------------------------------------------
192//  CLASS : sc_int_base
193// ----------------------------------------------------------------------------
194
195// assignment operators
196
197inline sc_int_base &
198sc_int_base::operator = (const sc_fxval &v)
199{
200    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
201        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
202                        "sc_int_base::operator = ( const sc_fxval& )");
203        return *this;
204    }
205    for (int i = 0; i < m_len; ++i) {
206        set(i, v.get_bit(i));
207    }
208    extend_sign();
209    return *this;
210}
211
212inline sc_int_base &
213sc_int_base::operator = (const sc_fxval_fast &v)
214{
215    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
216        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
217                        "sc_int_base::operator = ( const sc_fxval_fast& )");
218        return *this;
219    }
220    for (int i = 0; i < m_len; ++i) {
221        set(i, v.get_bit(i));
222    }
223    extend_sign();
224    return *this;
225}
226
227inline sc_int_base &
228sc_int_base::operator = (const sc_fxnum &v)
229{
230    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
231        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
232                        "sc_int_base::operator = ( const sc_fxnum& )");
233        return *this;
234    }
235    for (int i = 0; i < m_len; ++i) {
236        set(i, v.get_bit(i));
237    }
238    extend_sign();
239    return *this;
240}
241
242inline sc_int_base &
243sc_int_base::operator = (const sc_fxnum_fast &v)
244{
245    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
246        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
247                        "sc_int_base::operator = ( const sc_fxnum_fast& )");
248        return *this;
249    }
250    for (int i = 0; i < m_len; ++i) {
251        set (i, v.get_bit(i));
252    }
253    extend_sign();
254    return *this;
255}
256
257
258// ----------------------------------------------------------------------------
259//  CLASS : sc_uint_base
260// ----------------------------------------------------------------------------
261
262// assignment operators
263inline sc_uint_base &
264sc_uint_base::operator = (const sc_fxval &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_uint_base::operator = ( const sc_fxval& )");
269        return *this;
270    }
271    for (int i = 0; i < m_len; ++i) {
272        set(i, v.get_bit(i));
273    }
274    extend_sign();
275    return *this;
276}
277
278inline sc_uint_base &
279sc_uint_base::operator = (const sc_fxval_fast &v)
280{
281    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
282        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
283                        "sc_uint_base::operator = ( const sc_fxval_fast& )");
284        return *this;
285    }
286    for (int i = 0; i < m_len; ++i) {
287        set(i, v.get_bit(i));
288    }
289    extend_sign();
290    return *this;
291}
292
293inline sc_uint_base &
294sc_uint_base::operator = (const sc_fxnum &v)
295{
296    if (!v.is_normal()) { /* also triggers OBSERVER_READ call */
297        SC_REPORT_ERROR(sc_core::SC_ID_INVALID_FX_VALUE_,
298                        "sc_uint_base::operator = ( const sc_fxnum& )");
299        return *this;
300    }
301    for (int i = 0; i < m_len; ++i) {
302        set(i, v.get_bit(i));
303    }
304    extend_sign();
305    return *this;
306}
307
308inline sc_uint_base &
309sc_uint_base::operator = (const sc_fxnum_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_fxnum_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} // namespace sc_dt
324
325#endif // __SYSTEMC_EXT_DT_FX_SCFX_OTHER_DEFS_HH__
326