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_ufix.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_ufix.h,v $
39 // Revision 1.2 2011/01/20 22:52:30 acg
40 // Andy Goodrich: Add float constructors.
41 //
42 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
43 // SystemC 2.3
44 //
45 // Revision 1.3 2006/01/13 18:53:58 acg
46 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
47 // the source.
48 //
49
50 #ifndef SC_UFIX_H
51 #define SC_UFIX_H
52
53
54 #include "sysc/datatypes/fx/sc_fxnum.h"
55
56
57 namespace sc_dt
58 {
59
60 // classes defined in this module
61 class sc_ufix;
62 class sc_ufix_fast;
63
64
65 // ----------------------------------------------------------------------------
66 // CLASS : sc_ufix
67 //
68 // "Unconstrained" unsigned fixed-point class; arbitrary precision.
69 // ----------------------------------------------------------------------------
70
71 class SC_API sc_ufix : public sc_fxnum
72 {
73
74 public:
75
76 // constructors
77
78 explicit sc_ufix( sc_fxnum_observer* = 0 );
79 sc_ufix( int, int,
80 sc_fxnum_observer* = 0 );
81 sc_ufix( sc_q_mode, sc_o_mode,
82 sc_fxnum_observer* = 0 );
83 sc_ufix( sc_q_mode, sc_o_mode, int,
84 sc_fxnum_observer* = 0 );
85 sc_ufix( int, int, sc_q_mode, sc_o_mode,
86 sc_fxnum_observer* = 0 );
87 sc_ufix( int, int, sc_q_mode, sc_o_mode, int,
88 sc_fxnum_observer* = 0 );
89 explicit sc_ufix( const sc_fxcast_switch&,
90 sc_fxnum_observer* = 0 );
91 sc_ufix( int, int,
92 const sc_fxcast_switch&,
93 sc_fxnum_observer* = 0 );
94 sc_ufix( sc_q_mode, sc_o_mode,
95 const sc_fxcast_switch&,
96 sc_fxnum_observer* = 0 );
97 sc_ufix( sc_q_mode, sc_o_mode, int,
98 const sc_fxcast_switch&,
99 sc_fxnum_observer* = 0 );
100 sc_ufix( int, int, sc_q_mode, sc_o_mode,
101 const sc_fxcast_switch&,
102 sc_fxnum_observer* = 0 );
103 sc_ufix( int, int, sc_q_mode, sc_o_mode, int,
104 const sc_fxcast_switch&,
105 sc_fxnum_observer* = 0 );
106 explicit sc_ufix( const sc_fxtype_params&,
107 sc_fxnum_observer* = 0 );
108 sc_ufix( const sc_fxtype_params&,
109 const sc_fxcast_switch&,
110 sc_fxnum_observer* = 0 );
111
112 #define DECL_CTORS_T(tp) \
113 sc_ufix( tp, \
114 int, int, \
115 sc_fxnum_observer* = 0 ); \
116 sc_ufix( tp, \
117 sc_q_mode, sc_o_mode, \
118 sc_fxnum_observer* = 0 ); \
119 sc_ufix( tp, \
120 sc_q_mode, sc_o_mode, int, \
121 sc_fxnum_observer* = 0 ); \
122 sc_ufix( tp, \
123 int, int, sc_q_mode, sc_o_mode, \
124 sc_fxnum_observer* = 0 ); \
125 sc_ufix( tp, \
126 int, int, sc_q_mode, sc_o_mode, int, \
127 sc_fxnum_observer* = 0 ); \
128 sc_ufix( tp, \
129 const sc_fxcast_switch&, \
130 sc_fxnum_observer* = 0 ); \
131 sc_ufix( tp, \
132 int, int, \
133 const sc_fxcast_switch&, \
134 sc_fxnum_observer* = 0 ); \
135 sc_ufix( tp, \
136 sc_q_mode, sc_o_mode, \
137 const sc_fxcast_switch&, \
138 sc_fxnum_observer* = 0 ); \
139 sc_ufix( tp, \
140 sc_q_mode, sc_o_mode, int, \
141 const sc_fxcast_switch&, \
142 sc_fxnum_observer* = 0 ); \
143 sc_ufix( tp, \
144 int, int, sc_q_mode, sc_o_mode, \
145 const sc_fxcast_switch&, \
146 sc_fxnum_observer* = 0 ); \
147 sc_ufix( tp, \
148 int, int, sc_q_mode, sc_o_mode, int, \
149 const sc_fxcast_switch&, \
150 sc_fxnum_observer* = 0 ); \
151 sc_ufix( tp, \
152 const sc_fxtype_params&, \
153 sc_fxnum_observer* = 0 ); \
154 sc_ufix( tp, \
155 const sc_fxtype_params&, \
156 const sc_fxcast_switch&, \
157 sc_fxnum_observer* = 0 );
158
159 #define DECL_CTORS_T_A(tp) \
160 sc_ufix( tp, \
161 sc_fxnum_observer* = 0 ); \
162 DECL_CTORS_T(tp)
163
164 #define DECL_CTORS_T_B(tp) \
165 explicit sc_ufix( tp, \
166 sc_fxnum_observer* = 0 ); \
167 DECL_CTORS_T(tp)
168
169 DECL_CTORS_T_A(int)
170 DECL_CTORS_T_A(unsigned int)
171 DECL_CTORS_T_A(long)
172 DECL_CTORS_T_A(unsigned long)
173 DECL_CTORS_T_A(float)
174 DECL_CTORS_T_A(double)
175 DECL_CTORS_T_A(const char*)
176 DECL_CTORS_T_A(const sc_fxval&)
177 DECL_CTORS_T_A(const sc_fxval_fast&)
178 DECL_CTORS_T_A(const sc_fxnum&)
179 DECL_CTORS_T_A(const sc_fxnum_fast&)
180 #ifndef SC_FX_EXCLUDE_OTHER
181 DECL_CTORS_T_B(int64)
182 DECL_CTORS_T_B(uint64)
183 DECL_CTORS_T_B(const sc_int_base&)
184 DECL_CTORS_T_B(const sc_uint_base&)
185 DECL_CTORS_T_B(const sc_signed&)
186 DECL_CTORS_T_B(const sc_unsigned&)
187 #endif
188
189 #undef DECL_CTORS_T
190 #undef DECL_CTORS_T_A
191 #undef DECL_CTORS_T_B
192
193 // copy constructor
194
195 sc_ufix( const sc_ufix& );
196
197
198 // unary bitwise operators
199
200 const sc_ufix operator ~ () const;
201
202
203 // unary bitwise functions
204
205 friend void b_not( sc_ufix&, const sc_ufix& );
206
207
208 // binary bitwise operators
209
210 friend const sc_ufix operator & ( const sc_ufix&, const sc_ufix& );
211 friend const sc_ufix operator & ( const sc_ufix&, const sc_ufix_fast& );
212 friend const sc_ufix operator & ( const sc_ufix_fast&, const sc_ufix& );
213 friend const sc_ufix operator | ( const sc_ufix&, const sc_ufix& );
214 friend const sc_ufix operator | ( const sc_ufix&, const sc_ufix_fast& );
215 friend const sc_ufix operator | ( const sc_ufix_fast&, const sc_ufix& );
216 friend const sc_ufix operator ^ ( const sc_ufix&, const sc_ufix& );
217 friend const sc_ufix operator ^ ( const sc_ufix&, const sc_ufix_fast& );
218 friend const sc_ufix operator ^ ( const sc_ufix_fast&, const sc_ufix& );
219
220
221 // binary bitwise functions
222
223 friend void b_and( sc_ufix&, const sc_ufix&, const sc_ufix& );
224 friend void b_and( sc_ufix&, const sc_ufix&, const sc_ufix_fast& );
225 friend void b_and( sc_ufix&, const sc_ufix_fast&, const sc_ufix& );
226 friend void b_or ( sc_ufix&, const sc_ufix&, const sc_ufix& );
227 friend void b_or ( sc_ufix&, const sc_ufix&, const sc_ufix_fast& );
228 friend void b_or ( sc_ufix&, const sc_ufix_fast&, const sc_ufix& );
229 friend void b_xor( sc_ufix&, const sc_ufix&, const sc_ufix& );
230 friend void b_xor( sc_ufix&, const sc_ufix&, const sc_ufix_fast& );
231 friend void b_xor( sc_ufix&, const sc_ufix_fast&, const sc_ufix& );
232
233
234 // assignment operators
235
236 sc_ufix& operator = ( const sc_ufix& );
237
238 #define DECL_ASN_OP_T(op,tp) \
239 sc_ufix& operator op ( tp );
240
241 #ifndef SC_FX_EXCLUDE_OTHER
242 #define DECL_ASN_OP_OTHER(op) \
243 DECL_ASN_OP_T(op,int64) \
244 DECL_ASN_OP_T(op,uint64) \
245 DECL_ASN_OP_T(op,const sc_int_base&) \
246 DECL_ASN_OP_T(op,const sc_uint_base&) \
247 DECL_ASN_OP_T(op,const sc_signed&) \
248 DECL_ASN_OP_T(op,const sc_unsigned&)
249 #else
250 #define DECL_ASN_OP_OTHER(op)
251 #endif
252
253 #define DECL_ASN_OP(op) \
254 DECL_ASN_OP_T(op,int) \
255 DECL_ASN_OP_T(op,unsigned int) \
256 DECL_ASN_OP_T(op,long) \
257 DECL_ASN_OP_T(op,unsigned long) \
258 DECL_ASN_OP_T(op,float) \
259 DECL_ASN_OP_T(op,double) \
260 DECL_ASN_OP_T(op,const char*) \
261 DECL_ASN_OP_T(op,const sc_fxval&) \
262 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
263 DECL_ASN_OP_T(op,const sc_fxnum&) \
264 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
265 DECL_ASN_OP_OTHER(op)
266
267 DECL_ASN_OP(=)
268
269 DECL_ASN_OP(*=)
270 DECL_ASN_OP(/=)
271 DECL_ASN_OP(+=)
272 DECL_ASN_OP(-=)
273
274 DECL_ASN_OP_T(<<=,int)
275 DECL_ASN_OP_T(>>=,int)
276
277 DECL_ASN_OP_T(&=,const sc_ufix&)
278 DECL_ASN_OP_T(&=,const sc_ufix_fast&)
279 DECL_ASN_OP_T(|=,const sc_ufix&)
280 DECL_ASN_OP_T(|=,const sc_ufix_fast&)
281 DECL_ASN_OP_T(^=,const sc_ufix&)
282 DECL_ASN_OP_T(^=,const sc_ufix_fast&)
283
284 #undef DECL_ASN_OP_T
285 #undef DECL_ASN_OP_OTHER
286 #undef DECL_ASN_OP
287
288
289 // auto-increment and auto-decrement
290
291 const sc_fxval operator ++ ( int );
292 const sc_fxval operator -- ( int );
293
294 sc_ufix& operator ++ ();
295 sc_ufix& operator -- ();
296
297 };
298
299
300 // ----------------------------------------------------------------------------
301 // CLASS : sc_ufix_fast
302 //
303 // "Unconstrained" unsigned fixed-point class; limited precision.
304 // ----------------------------------------------------------------------------
305
306 class SC_API sc_ufix_fast : public sc_fxnum_fast
307 {
308
309 public:
310
311 // constructors
312
313 explicit sc_ufix_fast( sc_fxnum_fast_observer* = 0 );
314 sc_ufix_fast( int, int,
315 sc_fxnum_fast_observer* = 0 );
316 sc_ufix_fast( sc_q_mode, sc_o_mode,
317 sc_fxnum_fast_observer* = 0 );
318 sc_ufix_fast( sc_q_mode, sc_o_mode, int,
319 sc_fxnum_fast_observer* = 0 );
320 sc_ufix_fast( int, int, sc_q_mode, sc_o_mode,
321 sc_fxnum_fast_observer* = 0 );
322 sc_ufix_fast( int, int, sc_q_mode, sc_o_mode, int,
323 sc_fxnum_fast_observer* = 0 );
324 explicit sc_ufix_fast( const sc_fxcast_switch&,
325 sc_fxnum_fast_observer* = 0 );
326 sc_ufix_fast( int, int,
327 const sc_fxcast_switch&,
328 sc_fxnum_fast_observer* = 0 );
329 sc_ufix_fast( sc_q_mode, sc_o_mode,
330 const sc_fxcast_switch&,
331 sc_fxnum_fast_observer* = 0 );
332 sc_ufix_fast( sc_q_mode, sc_o_mode, int,
333 const sc_fxcast_switch&,
334 sc_fxnum_fast_observer* = 0 );
335 sc_ufix_fast( int, int, sc_q_mode, sc_o_mode,
336 const sc_fxcast_switch&,
337 sc_fxnum_fast_observer* = 0 );
338 sc_ufix_fast( int, int, sc_q_mode, sc_o_mode, int,
339 const sc_fxcast_switch&,
340 sc_fxnum_fast_observer* = 0 );
341 explicit sc_ufix_fast( const sc_fxtype_params&,
342 sc_fxnum_fast_observer* = 0 );
343 sc_ufix_fast( const sc_fxtype_params&,
344 const sc_fxcast_switch&,
345 sc_fxnum_fast_observer* = 0 );
346
347 #define DECL_CTORS_T(tp) \
348 sc_ufix_fast( tp, \
349 int, int, \
350 sc_fxnum_fast_observer* = 0 ); \
351 sc_ufix_fast( tp, \
352 sc_q_mode, sc_o_mode, \
353 sc_fxnum_fast_observer* = 0 ); \
354 sc_ufix_fast( tp, \
355 sc_q_mode, sc_o_mode, int, \
356 sc_fxnum_fast_observer* = 0 ); \
357 sc_ufix_fast( tp, \
358 int, int, sc_q_mode, sc_o_mode, \
359 sc_fxnum_fast_observer* = 0 ); \
360 sc_ufix_fast( tp, \
361 int, int, sc_q_mode, sc_o_mode, int, \
362 sc_fxnum_fast_observer* = 0 ); \
363 sc_ufix_fast( tp, \
364 const sc_fxcast_switch&, \
365 sc_fxnum_fast_observer* = 0 ); \
366 sc_ufix_fast( tp, \
367 int, int, \
368 const sc_fxcast_switch&, \
369 sc_fxnum_fast_observer* = 0 ); \
370 sc_ufix_fast( tp, \
371 sc_q_mode, sc_o_mode, \
372 const sc_fxcast_switch&, \
373 sc_fxnum_fast_observer* = 0 ); \
374 sc_ufix_fast( tp, \
375 sc_q_mode, sc_o_mode, int, \
376 const sc_fxcast_switch&, \
377 sc_fxnum_fast_observer* = 0 ); \
378 sc_ufix_fast( tp, \
379 int, int, sc_q_mode, sc_o_mode, \
380 const sc_fxcast_switch&, \
381 sc_fxnum_fast_observer* = 0 ); \
382 sc_ufix_fast( tp, \
383 int, int, sc_q_mode, sc_o_mode, int, \
384 const sc_fxcast_switch&, \
385 sc_fxnum_fast_observer* = 0 ); \
386 sc_ufix_fast( tp, \
387 const sc_fxtype_params&, \
388 sc_fxnum_fast_observer* = 0 ); \
389 sc_ufix_fast( tp, \
390 const sc_fxtype_params&, \
391 const sc_fxcast_switch&, \
392 sc_fxnum_fast_observer* = 0 );
393
394 #define DECL_CTORS_T_A(tp) \
395 sc_ufix_fast( tp, \
396 sc_fxnum_fast_observer* = 0 ); \
397 DECL_CTORS_T(tp)
398
399 #define DECL_CTORS_T_B(tp) \
400 explicit sc_ufix_fast( tp, \
401 sc_fxnum_fast_observer* = 0 ); \
402 DECL_CTORS_T(tp)
403
404 DECL_CTORS_T_A(int)
405 DECL_CTORS_T_A(unsigned int)
406 DECL_CTORS_T_A(long)
407 DECL_CTORS_T_A(unsigned long)
408 DECL_CTORS_T_A(float)
409 DECL_CTORS_T_A(double)
410 DECL_CTORS_T_A(const char*)
411 DECL_CTORS_T_A(const sc_fxval&)
412 DECL_CTORS_T_A(const sc_fxval_fast&)
413 DECL_CTORS_T_A(const sc_fxnum&)
414 DECL_CTORS_T_A(const sc_fxnum_fast&)
415 #ifndef SC_FX_EXCLUDE_OTHER
416 DECL_CTORS_T_B(int64)
417 DECL_CTORS_T_B(uint64)
418 DECL_CTORS_T_B(const sc_int_base&)
419 DECL_CTORS_T_B(const sc_uint_base&)
420 DECL_CTORS_T_B(const sc_signed&)
421 DECL_CTORS_T_B(const sc_unsigned&)
422 #endif
423
424 #undef DECL_CTORS_T
425 #undef DECL_CTORS_T_A
426 #undef DECL_CTORS_T_B
427
428 // copy constructor
429
430 sc_ufix_fast( const sc_ufix_fast& );
431
432
433 // unary bitwise operators
434
435 const sc_ufix_fast operator ~ () const;
436
437
438 // unary bitwise functions
439
440 friend void b_not( sc_ufix_fast&, const sc_ufix_fast& );
441
442
443 // binary bitwise operators
444
445 friend const sc_ufix_fast operator & ( const sc_ufix_fast&,
446 const sc_ufix_fast& );
447 friend const sc_ufix_fast operator ^ ( const sc_ufix_fast&,
448 const sc_ufix_fast& );
449 friend const sc_ufix_fast operator | ( const sc_ufix_fast&,
450 const sc_ufix_fast& );
451
452
453 // binary bitwise functions
454
455 friend void b_and( sc_ufix_fast&, const sc_ufix_fast&,
456 const sc_ufix_fast& );
457 friend void b_or ( sc_ufix_fast&, const sc_ufix_fast&,
458 const sc_ufix_fast& );
459 friend void b_xor( sc_ufix_fast&, const sc_ufix_fast&,
460 const sc_ufix_fast& );
461
462
463 // assignment operators
464
465 sc_ufix_fast& operator = ( const sc_ufix_fast& );
466
467 #define DECL_ASN_OP_T(op,tp) \
468 sc_ufix_fast& operator op ( tp );
469
470 #ifndef SC_FX_EXCLUDE_OTHER
471 #define DECL_ASN_OP_OTHER(op) \
472 DECL_ASN_OP_T(op,int64) \
473 DECL_ASN_OP_T(op,uint64) \
474 DECL_ASN_OP_T(op,const sc_int_base&) \
475 DECL_ASN_OP_T(op,const sc_uint_base&) \
476 DECL_ASN_OP_T(op,const sc_signed&) \
477 DECL_ASN_OP_T(op,const sc_unsigned&)
478 #else
479 #define DECL_ASN_OP_OTHER(op)
480 #endif
481
482 #define DECL_ASN_OP(op) \
483 DECL_ASN_OP_T(op,int) \
484 DECL_ASN_OP_T(op,unsigned int) \
485 DECL_ASN_OP_T(op,long) \
486 DECL_ASN_OP_T(op,unsigned long) \
487 DECL_ASN_OP_T(op,float) \
488 DECL_ASN_OP_T(op,double) \
489 DECL_ASN_OP_T(op,const char*) \
490 DECL_ASN_OP_T(op,const sc_fxval&) \
491 DECL_ASN_OP_T(op,const sc_fxval_fast&) \
492 DECL_ASN_OP_T(op,const sc_fxnum&) \
493 DECL_ASN_OP_T(op,const sc_fxnum_fast&) \
494 DECL_ASN_OP_OTHER(op)
495
496 DECL_ASN_OP(=)
497
498 DECL_ASN_OP(*=)
499 DECL_ASN_OP(/=)
500 DECL_ASN_OP(+=)
501 DECL_ASN_OP(-=)
502
503 DECL_ASN_OP_T(<<=,int)
504 DECL_ASN_OP_T(>>=,int)
505
506 DECL_ASN_OP_T(&=,const sc_ufix&)
507 DECL_ASN_OP_T(&=,const sc_ufix_fast&)
508 DECL_ASN_OP_T(|=,const sc_ufix&)
509 DECL_ASN_OP_T(|=,const sc_ufix_fast&)
510 DECL_ASN_OP_T(^=,const sc_ufix&)
511 DECL_ASN_OP_T(^=,const sc_ufix_fast&)
512
513 #undef DECL_ASN_OP_T
514 #undef DECL_ASN_OP_OTHER
515 #undef DECL_ASN_OP
516
517
518 // auto-increment and auto-decrement
519
520 const sc_fxval_fast operator ++ ( int );
521 const sc_fxval_fast operator -- ( int );
522
523 sc_ufix_fast& operator ++ ();
524 sc_ufix_fast& operator -- ();
525
526 };
527
528
529 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
530
531 // ----------------------------------------------------------------------------
532 // CLASS : sc_ufix
533 //
534 // "Unconstrained" unsigned fixed-point class; arbitrary precision.
535 // ----------------------------------------------------------------------------
536
537 // constructors
538
539 inline
sc_ufix(sc_fxnum_observer * observer_)540 sc_ufix::sc_ufix( sc_fxnum_observer* observer_ )
541 : sc_fxnum( sc_fxtype_params(),
542 SC_US_,
543 sc_fxcast_switch(),
544 observer_ )
545 {}
546
547 inline
sc_ufix(int wl_,int iwl_,sc_fxnum_observer * observer_)548 sc_ufix::sc_ufix( int wl_, int iwl_,
549 sc_fxnum_observer* observer_ )
550 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
551 SC_US_,
552 sc_fxcast_switch(),
553 observer_ )
554 {}
555
556 inline
sc_ufix(sc_q_mode qm,sc_o_mode om,sc_fxnum_observer * observer_)557 sc_ufix::sc_ufix( sc_q_mode qm, sc_o_mode om,
558 sc_fxnum_observer* observer_ )
559 : sc_fxnum( sc_fxtype_params( qm, om ),
560 SC_US_,
561 sc_fxcast_switch(),
562 observer_ )
563 {}
564
565 inline
sc_ufix(sc_q_mode qm,sc_o_mode om,int nb,sc_fxnum_observer * observer_)566 sc_ufix::sc_ufix( sc_q_mode qm, sc_o_mode om, int nb,
567 sc_fxnum_observer* observer_ )
568 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
569 SC_US_,
570 sc_fxcast_switch(),
571 observer_ )
572 {}
573
574 inline
sc_ufix(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,sc_fxnum_observer * observer_)575 sc_ufix::sc_ufix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
576 sc_fxnum_observer* observer_ )
577 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
578 SC_US_,
579 sc_fxcast_switch(),
580 observer_ )
581 {}
582
583 inline
sc_ufix(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,int nb,sc_fxnum_observer * observer_)584 sc_ufix::sc_ufix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
585 sc_fxnum_observer* observer_ )
586 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
587 SC_US_,
588 sc_fxcast_switch(),
589 observer_ )
590 {}
591
592 inline
sc_ufix(const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)593 sc_ufix::sc_ufix( const sc_fxcast_switch& cast_sw,
594 sc_fxnum_observer* observer_ )
595 : sc_fxnum( sc_fxtype_params(),
596 SC_US_,
597 cast_sw,
598 observer_ )
599 {}
600
601 inline
sc_ufix(int wl_,int iwl_,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)602 sc_ufix::sc_ufix( int wl_, int iwl_,
603 const sc_fxcast_switch& cast_sw,
604 sc_fxnum_observer* observer_ )
605 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
606 SC_US_,
607 cast_sw,
608 observer_ )
609 {}
610
611 inline
sc_ufix(sc_q_mode qm,sc_o_mode om,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)612 sc_ufix::sc_ufix( sc_q_mode qm, sc_o_mode om,
613 const sc_fxcast_switch& cast_sw,
614 sc_fxnum_observer* observer_ )
615 : sc_fxnum( sc_fxtype_params( qm, om ),
616 SC_US_,
617 cast_sw,
618 observer_ )
619 {}
620
621 inline
sc_ufix(sc_q_mode qm,sc_o_mode om,int nb,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)622 sc_ufix::sc_ufix( sc_q_mode qm, sc_o_mode om, int nb,
623 const sc_fxcast_switch& cast_sw,
624 sc_fxnum_observer* observer_ )
625 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
626 SC_US_,
627 cast_sw,
628 observer_ )
629 {}
630
631 inline
sc_ufix(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)632 sc_ufix::sc_ufix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
633 const sc_fxcast_switch& cast_sw,
634 sc_fxnum_observer* observer_ )
635 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
636 SC_US_,
637 cast_sw,
638 observer_ )
639 {}
640
641 inline
sc_ufix(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,int nb,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)642 sc_ufix::sc_ufix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
643 const sc_fxcast_switch& cast_sw,
644 sc_fxnum_observer* observer_ )
645 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
646 SC_US_,
647 cast_sw,
648 observer_ )
649 {}
650
651 inline
sc_ufix(const sc_fxtype_params & type_params_,sc_fxnum_observer * observer_)652 sc_ufix::sc_ufix( const sc_fxtype_params& type_params_,
653 sc_fxnum_observer* observer_ )
654 : sc_fxnum( type_params_,
655 SC_US_,
656 sc_fxcast_switch(),
657 observer_ )
658 {}
659
660 inline
sc_ufix(const sc_fxtype_params & type_params_,const sc_fxcast_switch & cast_sw,sc_fxnum_observer * observer_)661 sc_ufix::sc_ufix( const sc_fxtype_params& type_params_,
662 const sc_fxcast_switch& cast_sw,
663 sc_fxnum_observer* observer_ )
664 : sc_fxnum( type_params_,
665 SC_US_,
666 cast_sw,
667 observer_ )
668 {}
669
670 #define DEFN_CTORS_T_A(tp) \
671 inline \
672 sc_ufix::sc_ufix( tp a, \
673 sc_fxnum_observer* observer_ ) \
674 : sc_fxnum( a, \
675 sc_fxtype_params(), \
676 SC_US_, \
677 sc_fxcast_switch(), \
678 observer_ ) \
679 {} \
680 \
681 inline \
682 sc_ufix::sc_ufix( tp a, \
683 int wl_, int iwl_, \
684 sc_fxnum_observer* observer_ ) \
685 : sc_fxnum( a, \
686 sc_fxtype_params( wl_, iwl_ ), \
687 SC_US_, \
688 sc_fxcast_switch(), \
689 observer_ ) \
690 {} \
691 \
692 inline \
693 sc_ufix::sc_ufix( tp a, \
694 sc_q_mode qm, sc_o_mode om, \
695 sc_fxnum_observer* observer_ ) \
696 : sc_fxnum( a, \
697 sc_fxtype_params( qm, om ), \
698 SC_US_, \
699 sc_fxcast_switch(), \
700 observer_ ) \
701 {} \
702 \
703 inline \
704 sc_ufix::sc_ufix( tp a, \
705 sc_q_mode qm, sc_o_mode om, int nb, \
706 sc_fxnum_observer* observer_ ) \
707 : sc_fxnum( a, \
708 sc_fxtype_params( qm, om, nb ), \
709 SC_US_, \
710 sc_fxcast_switch(), \
711 observer_ ) \
712 {} \
713 \
714 inline \
715 sc_ufix::sc_ufix( tp a, \
716 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
717 sc_fxnum_observer* observer_ ) \
718 : sc_fxnum( a, \
719 sc_fxtype_params( wl_, iwl_, qm, om ), \
720 SC_US_, \
721 sc_fxcast_switch(), \
722 observer_ ) \
723 {} \
724 \
725 inline \
726 sc_ufix::sc_ufix( tp a, \
727 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
728 sc_fxnum_observer* observer_ ) \
729 : sc_fxnum( a, \
730 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
731 SC_US_, \
732 sc_fxcast_switch(), \
733 observer_ ) \
734 {} \
735 \
736 inline \
737 sc_ufix::sc_ufix( tp a, \
738 const sc_fxcast_switch& cast_sw, \
739 sc_fxnum_observer* observer_ ) \
740 : sc_fxnum( a, \
741 sc_fxtype_params(), \
742 SC_US_, \
743 cast_sw, \
744 observer_ ) \
745 {} \
746 \
747 inline \
748 sc_ufix::sc_ufix( tp a, \
749 int wl_, int iwl_, \
750 const sc_fxcast_switch& cast_sw, \
751 sc_fxnum_observer* observer_ ) \
752 : sc_fxnum( a, \
753 sc_fxtype_params( wl_, iwl_ ), \
754 SC_US_, \
755 cast_sw, \
756 observer_ ) \
757 {} \
758 \
759 inline \
760 sc_ufix::sc_ufix( tp a, \
761 sc_q_mode qm, sc_o_mode om, \
762 const sc_fxcast_switch& cast_sw, \
763 sc_fxnum_observer* observer_ ) \
764 : sc_fxnum( a, \
765 sc_fxtype_params( qm, om ), \
766 SC_US_, \
767 cast_sw, \
768 observer_ ) \
769 {} \
770 \
771 inline \
772 sc_ufix::sc_ufix( tp a, \
773 sc_q_mode qm, sc_o_mode om, int nb, \
774 const sc_fxcast_switch& cast_sw, \
775 sc_fxnum_observer* observer_ ) \
776 : sc_fxnum( a, \
777 sc_fxtype_params( qm, om, nb ), \
778 SC_US_, \
779 cast_sw, \
780 observer_ ) \
781 {} \
782 \
783 inline \
784 sc_ufix::sc_ufix( tp a, \
785 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
786 const sc_fxcast_switch& cast_sw, \
787 sc_fxnum_observer* observer_ ) \
788 : sc_fxnum( a, \
789 sc_fxtype_params( wl_, iwl_, qm, om ), \
790 SC_US_, \
791 cast_sw, \
792 observer_ ) \
793 {} \
794 \
795 inline \
796 sc_ufix::sc_ufix( tp a, \
797 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
798 const sc_fxcast_switch& cast_sw, \
799 sc_fxnum_observer* observer_ ) \
800 : sc_fxnum( a, \
801 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
802 SC_US_, \
803 cast_sw, \
804 observer_ ) \
805 {} \
806 \
807 inline \
808 sc_ufix::sc_ufix( tp a, \
809 const sc_fxtype_params& type_params_, \
810 sc_fxnum_observer* observer_ ) \
811 : sc_fxnum( a, \
812 type_params_, \
813 SC_US_, \
814 sc_fxcast_switch(), \
815 observer_ ) \
816 {} \
817 \
818 inline \
819 sc_ufix::sc_ufix( tp a, \
820 const sc_fxtype_params& type_params_, \
821 const sc_fxcast_switch& cast_sw, \
822 sc_fxnum_observer* observer_ ) \
823 : sc_fxnum( a, \
824 type_params_, \
825 SC_US_, \
826 cast_sw, \
827 observer_ ) \
828 {}
829
830 #define DEFN_CTORS_T_B(tp) \
831 inline \
832 sc_ufix::sc_ufix( tp a, \
833 sc_fxnum_observer* observer_ ) \
834 : sc_fxnum( a, \
835 a.type_params(), \
836 SC_US_, \
837 sc_fxcast_switch(), \
838 observer_ ) \
839 {} \
840 \
841 inline \
842 sc_ufix::sc_ufix( tp a, \
843 int wl_, int iwl_, \
844 sc_fxnum_observer* observer_ ) \
845 : sc_fxnum( a, \
846 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \
847 SC_US_, \
848 sc_fxcast_switch(), \
849 observer_ ) \
850 {} \
851 \
852 inline \
853 sc_ufix::sc_ufix( tp a, \
854 sc_q_mode qm, sc_o_mode om, \
855 sc_fxnum_observer* observer_ ) \
856 : sc_fxnum( a, \
857 sc_fxtype_params( a.type_params(), qm, om ), \
858 SC_US_, \
859 sc_fxcast_switch(), \
860 observer_ ) \
861 {} \
862 \
863 inline \
864 sc_ufix::sc_ufix( tp a, \
865 sc_q_mode qm, sc_o_mode om, int nb, \
866 sc_fxnum_observer* observer_ ) \
867 : sc_fxnum( a, \
868 sc_fxtype_params( a.type_params(), qm, om, nb ), \
869 SC_US_, \
870 sc_fxcast_switch(), \
871 observer_ ) \
872 {} \
873 \
874 inline \
875 sc_ufix::sc_ufix( tp a, \
876 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
877 sc_fxnum_observer* observer_ ) \
878 : sc_fxnum( a, \
879 sc_fxtype_params( wl_, iwl_, qm, om ), \
880 SC_US_, \
881 sc_fxcast_switch(), \
882 observer_ ) \
883 {} \
884 \
885 inline \
886 sc_ufix::sc_ufix( tp a, \
887 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
888 sc_fxnum_observer* observer_ ) \
889 : sc_fxnum( a, \
890 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
891 SC_US_, \
892 sc_fxcast_switch(), \
893 observer_ ) \
894 {} \
895 \
896 inline \
897 sc_ufix::sc_ufix( tp a, \
898 const sc_fxcast_switch& cast_sw, \
899 sc_fxnum_observer* observer_ ) \
900 : sc_fxnum( a, \
901 a.type_params(), \
902 SC_US_, \
903 cast_sw, \
904 observer_ ) \
905 {} \
906 \
907 inline \
908 sc_ufix::sc_ufix( tp a, \
909 int wl_, int iwl_, \
910 const sc_fxcast_switch& cast_sw, \
911 sc_fxnum_observer* observer_ ) \
912 : sc_fxnum( a, \
913 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \
914 SC_US_, \
915 cast_sw, \
916 observer_ ) \
917 {} \
918 \
919 inline \
920 sc_ufix::sc_ufix( tp a, \
921 sc_q_mode qm, sc_o_mode om, \
922 const sc_fxcast_switch& cast_sw, \
923 sc_fxnum_observer* observer_ ) \
924 : sc_fxnum( a, \
925 sc_fxtype_params( a.type_params(), qm, om ), \
926 SC_US_, \
927 cast_sw, \
928 observer_ ) \
929 {} \
930 \
931 inline \
932 sc_ufix::sc_ufix( tp a, \
933 sc_q_mode qm, sc_o_mode om, int nb, \
934 const sc_fxcast_switch& cast_sw, \
935 sc_fxnum_observer* observer_ ) \
936 : sc_fxnum( a, \
937 sc_fxtype_params( a.type_params(), qm, om, nb ), \
938 SC_US_, \
939 cast_sw, \
940 observer_ ) \
941 {} \
942 \
943 inline \
944 sc_ufix::sc_ufix( tp a, \
945 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
946 const sc_fxcast_switch& cast_sw, \
947 sc_fxnum_observer* observer_ ) \
948 : sc_fxnum( a, \
949 sc_fxtype_params( wl_, iwl_, qm, om ), \
950 SC_US_, \
951 cast_sw, \
952 observer_ ) \
953 {} \
954 \
955 inline \
956 sc_ufix::sc_ufix( tp a, \
957 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
958 const sc_fxcast_switch& cast_sw, \
959 sc_fxnum_observer* observer_ ) \
960 : sc_fxnum( a, \
961 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
962 SC_US_, \
963 cast_sw, \
964 observer_ ) \
965 {} \
966 \
967 inline \
968 sc_ufix::sc_ufix( tp a, \
969 const sc_fxtype_params& type_params_, \
970 sc_fxnum_observer* observer_ ) \
971 : sc_fxnum( a, \
972 type_params_, \
973 SC_US_, \
974 sc_fxcast_switch(), \
975 observer_ ) \
976 {} \
977 \
978 inline \
979 sc_ufix::sc_ufix( tp a, \
980 const sc_fxtype_params& type_params_, \
981 const sc_fxcast_switch& cast_sw, \
982 sc_fxnum_observer* observer_ ) \
983 : sc_fxnum( a, \
984 type_params_, \
985 SC_US_, \
986 cast_sw, \
987 observer_ ) \
988 {}
989
990 DEFN_CTORS_T_A(int)
DEFN_CTORS_T_A(unsigned int)991 DEFN_CTORS_T_A(unsigned int)
992 DEFN_CTORS_T_A(long)
993 DEFN_CTORS_T_A(unsigned long)
994 DEFN_CTORS_T_A(float)
995 DEFN_CTORS_T_A(double)
996 DEFN_CTORS_T_A(const char*)
997 DEFN_CTORS_T_A(const sc_fxval&)
998 DEFN_CTORS_T_A(const sc_fxval_fast&)
999 DEFN_CTORS_T_B(const sc_fxnum&)
1000 DEFN_CTORS_T_B(const sc_fxnum_fast&)
1001 #ifndef SC_FX_EXCLUDE_OTHER
1002 DEFN_CTORS_T_A(int64)
1003 DEFN_CTORS_T_A(uint64)
1004 DEFN_CTORS_T_A(const sc_int_base&)
1005 DEFN_CTORS_T_A(const sc_uint_base&)
1006 DEFN_CTORS_T_A(const sc_signed&)
1007 DEFN_CTORS_T_A(const sc_unsigned&)
1008 #endif
1009
1010 #undef DEFN_CTORS_T_A
1011 #undef DEFN_CTORS_T_B
1012
1013 // copy constructor
1014
1015 inline
1016 sc_ufix::sc_ufix( const sc_ufix& a )
1017 : sc_fxnum( a,
1018 a.type_params(),
1019 SC_US_,
1020 sc_fxcast_switch(),
1021 0 )
1022 {}
1023
1024
1025 // unary bitwise operators
1026
1027 inline
1028 const sc_ufix
1029 sc_ufix::operator ~ () const
1030 {
1031 SC_FXNUM_OBSERVER_READ_( *this )
1032 int iwl_c = iwl();
1033 int wl_c = wl();
1034 sc_ufix c( wl_c, iwl_c );
1035 for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
1036 c.set_bit( i, ! get_bit( i ) );
1037 return sc_ufix( c, wl_c, iwl_c );
1038 }
1039
1040
1041 // unary bitwise functions
1042
1043 inline
1044 void
b_not(sc_ufix & c,const sc_ufix & a)1045 b_not( sc_ufix& c, const sc_ufix& a )
1046 {
1047 SC_FXNUM_OBSERVER_READ_( a )
1048 int iwl_c = c.iwl();
1049 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
1050 c.set_bit( i, ! a.get_bit( i ) );
1051 c.cast();
1052 SC_FXNUM_OBSERVER_WRITE_( c )
1053 }
1054
1055
1056 // binary bitwise operators
1057
1058 #define DEFN_BIN_OP_T(op,op2,tp1,tp2) \
1059 inline \
1060 const sc_ufix \
1061 operator op ( const tp1& a, const tp2& b ) \
1062 { \
1063 a.observer_read(); \
1064 b.observer_read(); \
1065 int iwl_a = a.iwl(); \
1066 int iwl_b = b.iwl(); \
1067 int iwl_c = sc_max( iwl_a, iwl_b ); \
1068 int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b ); \
1069 sc_ufix c( iwl_c + fwl_c, iwl_c ); \
1070 for( int i = -fwl_c; i < iwl_c; ++ i ) \
1071 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \
1072 return sc_ufix( c, iwl_c + fwl_c, iwl_c ); \
1073 }
1074
1075 DEFN_BIN_OP_T(&,&&,sc_ufix,sc_ufix)
1076 DEFN_BIN_OP_T(&,&&,sc_ufix,sc_ufix_fast)
1077 DEFN_BIN_OP_T(&,&&,sc_ufix_fast,sc_ufix)
1078
1079 DEFN_BIN_OP_T(|,||,sc_ufix,sc_ufix)
1080 DEFN_BIN_OP_T(|,||,sc_ufix,sc_ufix_fast)
1081 DEFN_BIN_OP_T(|,||,sc_ufix_fast,sc_ufix)
1082
1083 DEFN_BIN_OP_T(^,!=,sc_ufix,sc_ufix)
1084 DEFN_BIN_OP_T(^,!=,sc_ufix,sc_ufix_fast)
1085 DEFN_BIN_OP_T(^,!=,sc_ufix_fast,sc_ufix)
1086
1087 #undef DEFN_BIN_OP_T
1088
1089
1090 // binary bitwise functions
1091
1092 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2) \
1093 inline \
1094 void \
1095 fnc ( sc_ufix& c, const tp1& a, const tp2& b ) \
1096 { \
1097 a.observer_read(); \
1098 b.observer_read(); \
1099 int iwl_c = c.iwl(); \
1100 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) \
1101 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \
1102 c.cast(); \
1103 SC_FXNUM_OBSERVER_WRITE_( c ) \
1104 }
1105
1106 DEFN_BIN_FNC_T(b_and,&&,sc_ufix,sc_ufix)
1107 DEFN_BIN_FNC_T(b_and,&&,sc_ufix,sc_ufix_fast)
1108 DEFN_BIN_FNC_T(b_and,&&,sc_ufix_fast,sc_ufix)
1109
1110 DEFN_BIN_FNC_T(b_or,||,sc_ufix,sc_ufix)
1111 DEFN_BIN_FNC_T(b_or,||,sc_ufix,sc_ufix_fast)
1112 DEFN_BIN_FNC_T(b_or,||,sc_ufix_fast,sc_ufix)
1113
1114 DEFN_BIN_FNC_T(b_xor,!=,sc_ufix,sc_ufix)
1115 DEFN_BIN_FNC_T(b_xor,!=,sc_ufix,sc_ufix_fast)
1116 DEFN_BIN_FNC_T(b_xor,!=,sc_ufix_fast,sc_ufix)
1117
1118 #undef DEFN_BIN_FNC_T
1119
1120
1121 // assignment operators
1122
1123 inline
1124 sc_ufix&
1125 sc_ufix::operator = ( const sc_ufix& a )
1126 {
1127 sc_fxnum::operator = ( a );
1128 return *this;
1129 }
1130
1131 #define DEFN_ASN_OP_T(op,tp) \
1132 inline \
1133 sc_ufix& \
1134 sc_ufix::operator op ( tp a ) \
1135 { \
1136 sc_fxnum::operator op( a ); \
1137 return *this; \
1138 }
1139
1140 #ifndef SC_FX_EXCLUDE_OTHER
1141 #define DEFN_ASN_OP_OTHER(op) \
1142 DEFN_ASN_OP_T(op,int64) \
1143 DEFN_ASN_OP_T(op,uint64) \
1144 DEFN_ASN_OP_T(op,const sc_int_base&) \
1145 DEFN_ASN_OP_T(op,const sc_uint_base&) \
1146 DEFN_ASN_OP_T(op,const sc_signed&) \
1147 DEFN_ASN_OP_T(op,const sc_unsigned&)
1148 #else
1149 #define DEFN_ASN_OP_OTHER(op)
1150 #endif
1151
1152 #define DEFN_ASN_OP(op) \
1153 DEFN_ASN_OP_T(op,int) \
1154 DEFN_ASN_OP_T(op,unsigned int) \
1155 DEFN_ASN_OP_T(op,long) \
1156 DEFN_ASN_OP_T(op,unsigned long) \
1157 DEFN_ASN_OP_T(op,float) \
1158 DEFN_ASN_OP_T(op,double) \
1159 DEFN_ASN_OP_T(op,const char*) \
1160 DEFN_ASN_OP_T(op,const sc_fxval&) \
1161 DEFN_ASN_OP_T(op,const sc_fxval_fast&) \
1162 DEFN_ASN_OP_T(op,const sc_fxnum&) \
1163 DEFN_ASN_OP_T(op,const sc_fxnum_fast&) \
1164 DEFN_ASN_OP_OTHER(op)
1165
1166 DEFN_ASN_OP(=)
1167
1168 DEFN_ASN_OP(*=)
1169 DEFN_ASN_OP(/=)
1170 DEFN_ASN_OP(+=)
1171 DEFN_ASN_OP(-=)
1172
1173 DEFN_ASN_OP_T(<<=,int)
1174 DEFN_ASN_OP_T(>>=,int)
1175
1176 #undef DEFN_ASN_OP_T
1177 #undef DEFN_ASN_OP_OTHER
1178 #undef DEFN_ASN_OP
1179
1180
1181 #define DEFN_ASN_OP_T(op,op2,tp) \
1182 inline \
1183 sc_ufix& \
1184 sc_ufix::operator op ( const tp& b ) \
1185 { \
1186 SC_FXNUM_OBSERVER_READ_( *this ) \
1187 b.observer_read(); \
1188 int iwl_c = iwl(); \
1189 for( int i = iwl_c - wl(); i < iwl_c; ++ i ) \
1190 set_bit( i, get_bit( i ) op2 b.get_bit( i ) ); \
1191 cast(); \
1192 SC_FXNUM_OBSERVER_WRITE_( *this ) \
1193 return *this; \
1194 }
1195
1196 DEFN_ASN_OP_T(&=,&&,sc_ufix)
1197 DEFN_ASN_OP_T(&=,&&,sc_ufix_fast)
1198 DEFN_ASN_OP_T(|=,||,sc_ufix)
1199 DEFN_ASN_OP_T(|=,||,sc_ufix_fast)
1200 DEFN_ASN_OP_T(^=,!=,sc_ufix)
1201 DEFN_ASN_OP_T(^=,!=,sc_ufix_fast)
1202
1203 #undef DEFN_ASN_OP_T
1204
1205
1206 // auto-increment and auto-decrement
1207
1208 inline
1209 const sc_fxval
1210 sc_ufix::operator ++ ( int )
1211 {
1212 return sc_fxval( sc_fxnum::operator ++ ( 0 ) );
1213 }
1214
1215 inline
1216 const sc_fxval
1217 sc_ufix::operator -- ( int )
1218 {
1219 return sc_fxval( sc_fxnum::operator -- ( 0 ) );
1220 }
1221
1222 inline
1223 sc_ufix&
1224 sc_ufix::operator ++ ()
1225 {
1226 sc_fxnum::operator ++ ();
1227 return *this;
1228 }
1229
1230 inline
1231 sc_ufix&
1232 sc_ufix::operator -- ()
1233 {
1234 sc_fxnum::operator -- ();
1235 return *this;
1236 }
1237
1238
1239 // ----------------------------------------------------------------------------
1240 // CLASS : sc_ufix_fast
1241 //
1242 // "Unconstrained" unsigned fixed-point class; limited precision.
1243 // ----------------------------------------------------------------------------
1244
1245 // constructors
1246
1247 inline
sc_ufix_fast(sc_fxnum_fast_observer * observer_)1248 sc_ufix_fast::sc_ufix_fast( sc_fxnum_fast_observer* observer_ )
1249 : sc_fxnum_fast( sc_fxtype_params(),
1250 SC_US_,
1251 sc_fxcast_switch(),
1252 observer_ )
1253 {}
1254
1255 inline
sc_ufix_fast(int wl_,int iwl_,sc_fxnum_fast_observer * observer_)1256 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_,
1257 sc_fxnum_fast_observer* observer_ )
1258 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
1259 SC_US_,
1260 sc_fxcast_switch(),
1261 observer_ )
1262 {}
1263
1264 inline
sc_ufix_fast(sc_q_mode qm,sc_o_mode om,sc_fxnum_fast_observer * observer_)1265 sc_ufix_fast::sc_ufix_fast( sc_q_mode qm, sc_o_mode om,
1266 sc_fxnum_fast_observer* observer_ )
1267 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
1268 SC_US_,
1269 sc_fxcast_switch(),
1270 observer_ )
1271 {}
1272
1273 inline
sc_ufix_fast(sc_q_mode qm,sc_o_mode om,int nb,sc_fxnum_fast_observer * observer_)1274 sc_ufix_fast::sc_ufix_fast( sc_q_mode qm, sc_o_mode om, int nb,
1275 sc_fxnum_fast_observer* observer_ )
1276 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
1277 SC_US_,
1278 sc_fxcast_switch(),
1279 observer_ )
1280 {}
1281
1282 inline
sc_ufix_fast(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,sc_fxnum_fast_observer * observer_)1283 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
1284 sc_fxnum_fast_observer* observer_ )
1285 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
1286 SC_US_,
1287 sc_fxcast_switch(),
1288 observer_ )
1289 {}
1290
1291 inline
sc_ufix_fast(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,int nb,sc_fxnum_fast_observer * observer_)1292 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_,
1293 sc_q_mode qm, sc_o_mode om, int nb,
1294 sc_fxnum_fast_observer* observer_ )
1295 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
1296 SC_US_,
1297 sc_fxcast_switch(),
1298 observer_ )
1299 {}
1300
1301 inline
sc_ufix_fast(const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1302 sc_ufix_fast::sc_ufix_fast( const sc_fxcast_switch& cast_sw,
1303 sc_fxnum_fast_observer* observer_ )
1304 : sc_fxnum_fast( sc_fxtype_params(),
1305 SC_US_,
1306 cast_sw,
1307 observer_ )
1308 {}
1309
1310 inline
sc_ufix_fast(int wl_,int iwl_,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1311 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_,
1312 const sc_fxcast_switch& cast_sw,
1313 sc_fxnum_fast_observer* observer_ )
1314 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
1315 SC_US_,
1316 cast_sw,
1317 observer_ )
1318 {}
1319
1320 inline
sc_ufix_fast(sc_q_mode qm,sc_o_mode om,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1321 sc_ufix_fast::sc_ufix_fast( sc_q_mode qm, sc_o_mode om,
1322 const sc_fxcast_switch& cast_sw,
1323 sc_fxnum_fast_observer* observer_ )
1324 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
1325 SC_US_,
1326 cast_sw,
1327 observer_ )
1328 {}
1329
1330 inline
sc_ufix_fast(sc_q_mode qm,sc_o_mode om,int nb,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1331 sc_ufix_fast::sc_ufix_fast( sc_q_mode qm, sc_o_mode om, int nb,
1332 const sc_fxcast_switch& cast_sw,
1333 sc_fxnum_fast_observer* observer_ )
1334 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
1335 SC_US_,
1336 cast_sw,
1337 observer_ )
1338 {}
1339
1340 inline
sc_ufix_fast(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1341 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
1342 const sc_fxcast_switch& cast_sw,
1343 sc_fxnum_fast_observer* observer_ )
1344 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
1345 SC_US_,
1346 cast_sw,
1347 observer_ )
1348 {}
1349
1350 inline
sc_ufix_fast(int wl_,int iwl_,sc_q_mode qm,sc_o_mode om,int nb,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1351 sc_ufix_fast::sc_ufix_fast( int wl_, int iwl_,
1352 sc_q_mode qm, sc_o_mode om, int nb,
1353 const sc_fxcast_switch& cast_sw,
1354 sc_fxnum_fast_observer* observer_ )
1355 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
1356 SC_US_,
1357 cast_sw,
1358 observer_ )
1359 {}
1360
1361 inline
sc_ufix_fast(const sc_fxtype_params & type_params_,sc_fxnum_fast_observer * observer_)1362 sc_ufix_fast::sc_ufix_fast( const sc_fxtype_params& type_params_,
1363 sc_fxnum_fast_observer* observer_ )
1364 : sc_fxnum_fast( type_params_,
1365 SC_US_,
1366 sc_fxcast_switch(),
1367 observer_ )
1368 {}
1369
1370 inline
sc_ufix_fast(const sc_fxtype_params & type_params_,const sc_fxcast_switch & cast_sw,sc_fxnum_fast_observer * observer_)1371 sc_ufix_fast::sc_ufix_fast( const sc_fxtype_params& type_params_,
1372 const sc_fxcast_switch& cast_sw,
1373 sc_fxnum_fast_observer* observer_ )
1374 : sc_fxnum_fast( type_params_,
1375 SC_US_,
1376 cast_sw,
1377 observer_ )
1378 {}
1379
1380 #define DEFN_CTORS_T_A(tp) \
1381 inline \
1382 sc_ufix_fast::sc_ufix_fast( tp a, \
1383 sc_fxnum_fast_observer* observer_ ) \
1384 : sc_fxnum_fast( a, \
1385 sc_fxtype_params(), \
1386 SC_US_, \
1387 sc_fxcast_switch(), \
1388 observer_ ) \
1389 {} \
1390 \
1391 inline \
1392 sc_ufix_fast::sc_ufix_fast( tp a, \
1393 int wl_, int iwl_, \
1394 sc_fxnum_fast_observer* observer_ ) \
1395 : sc_fxnum_fast( a, \
1396 sc_fxtype_params( wl_, iwl_ ), \
1397 SC_US_, \
1398 sc_fxcast_switch(), \
1399 observer_ ) \
1400 {} \
1401 \
1402 inline \
1403 sc_ufix_fast::sc_ufix_fast( tp a, \
1404 sc_q_mode qm, sc_o_mode om, \
1405 sc_fxnum_fast_observer* observer_ ) \
1406 : sc_fxnum_fast( a, \
1407 sc_fxtype_params( qm, om ), \
1408 SC_US_, \
1409 sc_fxcast_switch(), \
1410 observer_ ) \
1411 {} \
1412 \
1413 inline \
1414 sc_ufix_fast::sc_ufix_fast( tp a, \
1415 sc_q_mode qm, sc_o_mode om, int nb, \
1416 sc_fxnum_fast_observer* observer_ ) \
1417 : sc_fxnum_fast( a, \
1418 sc_fxtype_params( qm, om, nb ), \
1419 SC_US_, \
1420 sc_fxcast_switch(), \
1421 observer_ ) \
1422 {} \
1423 \
1424 inline \
1425 sc_ufix_fast::sc_ufix_fast( tp a, \
1426 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1427 sc_fxnum_fast_observer* observer_ ) \
1428 : sc_fxnum_fast( a, \
1429 sc_fxtype_params( wl_, iwl_, qm, om ), \
1430 SC_US_, \
1431 sc_fxcast_switch(), \
1432 observer_ ) \
1433 {} \
1434 \
1435 inline \
1436 sc_ufix_fast::sc_ufix_fast( tp a, \
1437 int wl_, int iwl_, \
1438 sc_q_mode qm, sc_o_mode om, int nb, \
1439 sc_fxnum_fast_observer* observer_ ) \
1440 : sc_fxnum_fast( a, \
1441 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
1442 SC_US_, \
1443 sc_fxcast_switch(), \
1444 observer_ ) \
1445 {} \
1446 \
1447 inline \
1448 sc_ufix_fast::sc_ufix_fast( tp a, \
1449 const sc_fxcast_switch& cast_sw, \
1450 sc_fxnum_fast_observer* observer_ ) \
1451 : sc_fxnum_fast( a, \
1452 sc_fxtype_params(), \
1453 SC_US_, \
1454 cast_sw, \
1455 observer_ ) \
1456 {} \
1457 \
1458 inline \
1459 sc_ufix_fast::sc_ufix_fast( tp a, \
1460 int wl_, int iwl_, \
1461 const sc_fxcast_switch& cast_sw, \
1462 sc_fxnum_fast_observer* observer_ ) \
1463 : sc_fxnum_fast( a, \
1464 sc_fxtype_params( wl_, iwl_ ), \
1465 SC_US_, \
1466 cast_sw, \
1467 observer_ ) \
1468 {} \
1469 \
1470 inline \
1471 sc_ufix_fast::sc_ufix_fast( tp a, \
1472 sc_q_mode qm, sc_o_mode om, \
1473 const sc_fxcast_switch& cast_sw, \
1474 sc_fxnum_fast_observer* observer_ ) \
1475 : sc_fxnum_fast( a, \
1476 sc_fxtype_params( qm, om ), \
1477 SC_US_, \
1478 cast_sw, \
1479 observer_ ) \
1480 {} \
1481 \
1482 inline \
1483 sc_ufix_fast::sc_ufix_fast( tp a, \
1484 sc_q_mode qm, sc_o_mode om, int nb, \
1485 const sc_fxcast_switch& cast_sw, \
1486 sc_fxnum_fast_observer* observer_ ) \
1487 : sc_fxnum_fast( a, \
1488 sc_fxtype_params( qm, om, nb ), \
1489 SC_US_, \
1490 cast_sw, \
1491 observer_ ) \
1492 {} \
1493 \
1494 inline \
1495 sc_ufix_fast::sc_ufix_fast( tp a, \
1496 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1497 const sc_fxcast_switch& cast_sw, \
1498 sc_fxnum_fast_observer* observer_ ) \
1499 : sc_fxnum_fast( a, \
1500 sc_fxtype_params( wl_, iwl_, qm, om ), \
1501 SC_US_, \
1502 cast_sw, \
1503 observer_ ) \
1504 {} \
1505 \
1506 inline \
1507 sc_ufix_fast::sc_ufix_fast( tp a, \
1508 int wl_, int iwl_, \
1509 sc_q_mode qm, sc_o_mode om, int nb, \
1510 const sc_fxcast_switch& cast_sw, \
1511 sc_fxnum_fast_observer* observer_ ) \
1512 : sc_fxnum_fast( a, \
1513 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
1514 SC_US_, \
1515 cast_sw, \
1516 observer_ ) \
1517 {} \
1518 \
1519 inline \
1520 sc_ufix_fast::sc_ufix_fast( tp a, \
1521 const sc_fxtype_params& type_params_, \
1522 sc_fxnum_fast_observer* observer_ ) \
1523 : sc_fxnum_fast( a, \
1524 type_params_, \
1525 SC_US_, \
1526 sc_fxcast_switch(), \
1527 observer_ ) \
1528 {} \
1529 \
1530 inline \
1531 sc_ufix_fast::sc_ufix_fast( tp a, \
1532 const sc_fxtype_params& type_params_, \
1533 const sc_fxcast_switch& cast_sw, \
1534 sc_fxnum_fast_observer* observer_ ) \
1535 : sc_fxnum_fast( a, \
1536 type_params_, \
1537 SC_US_, \
1538 cast_sw, \
1539 observer_ ) \
1540 {}
1541
1542 #define DEFN_CTORS_T_B(tp) \
1543 inline \
1544 sc_ufix_fast::sc_ufix_fast( tp a, \
1545 sc_fxnum_fast_observer* observer_ ) \
1546 : sc_fxnum_fast( a, \
1547 a.type_params(), \
1548 SC_US_, \
1549 sc_fxcast_switch(), \
1550 observer_ ) \
1551 {} \
1552 \
1553 inline \
1554 sc_ufix_fast::sc_ufix_fast( tp a, \
1555 int wl_, int iwl_, \
1556 sc_fxnum_fast_observer* observer_ ) \
1557 : sc_fxnum_fast( a, \
1558 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \
1559 SC_US_, \
1560 sc_fxcast_switch(), \
1561 observer_ ) \
1562 {} \
1563 \
1564 inline \
1565 sc_ufix_fast::sc_ufix_fast( tp a, \
1566 sc_q_mode qm, sc_o_mode om, \
1567 sc_fxnum_fast_observer* observer_ ) \
1568 : sc_fxnum_fast( a, \
1569 sc_fxtype_params( a.type_params(), qm, om ), \
1570 SC_US_, \
1571 sc_fxcast_switch(), \
1572 observer_ ) \
1573 {} \
1574 \
1575 inline \
1576 sc_ufix_fast::sc_ufix_fast( tp a, \
1577 sc_q_mode qm, sc_o_mode om, int nb, \
1578 sc_fxnum_fast_observer* observer_ ) \
1579 : sc_fxnum_fast( a, \
1580 sc_fxtype_params( a.type_params(), qm, om, nb ), \
1581 SC_US_, \
1582 sc_fxcast_switch(), \
1583 observer_ ) \
1584 {} \
1585 \
1586 inline \
1587 sc_ufix_fast::sc_ufix_fast( tp a, \
1588 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1589 sc_fxnum_fast_observer* observer_ ) \
1590 : sc_fxnum_fast( a, \
1591 sc_fxtype_params( wl_, iwl_, qm, om ), \
1592 SC_US_, \
1593 sc_fxcast_switch(), \
1594 observer_ ) \
1595 {} \
1596 \
1597 inline \
1598 sc_ufix_fast::sc_ufix_fast( tp a, \
1599 int wl_, int iwl_, \
1600 sc_q_mode qm, sc_o_mode om, int nb, \
1601 sc_fxnum_fast_observer* observer_ ) \
1602 : sc_fxnum_fast( a, \
1603 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
1604 SC_US_, \
1605 sc_fxcast_switch(), \
1606 observer_ ) \
1607 {} \
1608 \
1609 inline \
1610 sc_ufix_fast::sc_ufix_fast( tp a, \
1611 const sc_fxcast_switch& cast_sw, \
1612 sc_fxnum_fast_observer* observer_ ) \
1613 : sc_fxnum_fast( a, \
1614 a.type_params(), \
1615 SC_US_, \
1616 cast_sw, \
1617 observer_ ) \
1618 {} \
1619 \
1620 inline \
1621 sc_ufix_fast::sc_ufix_fast( tp a, \
1622 int wl_, int iwl_, \
1623 const sc_fxcast_switch& cast_sw, \
1624 sc_fxnum_fast_observer* observer_ ) \
1625 : sc_fxnum_fast( a, \
1626 sc_fxtype_params( a.type_params(), wl_, iwl_ ), \
1627 SC_US_, \
1628 cast_sw, \
1629 observer_ ) \
1630 {} \
1631 \
1632 inline \
1633 sc_ufix_fast::sc_ufix_fast( tp a, \
1634 sc_q_mode qm, sc_o_mode om, \
1635 const sc_fxcast_switch& cast_sw, \
1636 sc_fxnum_fast_observer* observer_ ) \
1637 : sc_fxnum_fast( a, \
1638 sc_fxtype_params( a.type_params(), qm, om ), \
1639 SC_US_, \
1640 cast_sw, \
1641 observer_ ) \
1642 {} \
1643 \
1644 inline \
1645 sc_ufix_fast::sc_ufix_fast( tp a, \
1646 sc_q_mode qm, sc_o_mode om, int nb, \
1647 const sc_fxcast_switch& cast_sw, \
1648 sc_fxnum_fast_observer* observer_ ) \
1649 : sc_fxnum_fast( a, \
1650 sc_fxtype_params( a.type_params(), qm, om, nb ), \
1651 SC_US_, \
1652 cast_sw, \
1653 observer_ ) \
1654 {} \
1655 \
1656 inline \
1657 sc_ufix_fast::sc_ufix_fast( tp a, \
1658 int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1659 const sc_fxcast_switch& cast_sw, \
1660 sc_fxnum_fast_observer* observer_ ) \
1661 : sc_fxnum_fast( a, \
1662 sc_fxtype_params( wl_, iwl_, qm, om ), \
1663 SC_US_, \
1664 cast_sw, \
1665 observer_ ) \
1666 {} \
1667 \
1668 inline \
1669 sc_ufix_fast::sc_ufix_fast( tp a, \
1670 int wl_, int iwl_, \
1671 sc_q_mode qm, sc_o_mode om, int nb, \
1672 const sc_fxcast_switch& cast_sw, \
1673 sc_fxnum_fast_observer* observer_ ) \
1674 : sc_fxnum_fast( a, \
1675 sc_fxtype_params( wl_, iwl_, qm, om, nb ), \
1676 SC_US_, \
1677 cast_sw, \
1678 observer_ ) \
1679 {} \
1680 \
1681 inline \
1682 sc_ufix_fast::sc_ufix_fast( tp a, \
1683 const sc_fxtype_params& type_params_, \
1684 sc_fxnum_fast_observer* observer_ ) \
1685 : sc_fxnum_fast( a, \
1686 type_params_, \
1687 SC_US_, \
1688 sc_fxcast_switch(), \
1689 observer_ ) \
1690 {} \
1691 \
1692 inline \
1693 sc_ufix_fast::sc_ufix_fast( tp a, \
1694 const sc_fxtype_params& type_params_, \
1695 const sc_fxcast_switch& cast_sw, \
1696 sc_fxnum_fast_observer* observer_ ) \
1697 : sc_fxnum_fast( a, \
1698 type_params_, \
1699 SC_US_, \
1700 cast_sw, \
1701 observer_ ) \
1702 {}
1703
1704 DEFN_CTORS_T_A(int)
DEFN_CTORS_T_A(unsigned int)1705 DEFN_CTORS_T_A(unsigned int)
1706 DEFN_CTORS_T_A(long)
1707 DEFN_CTORS_T_A(unsigned long)
1708 DEFN_CTORS_T_A(float)
1709 DEFN_CTORS_T_A(double)
1710 DEFN_CTORS_T_A(const char*)
1711 DEFN_CTORS_T_A(const sc_fxval&)
1712 DEFN_CTORS_T_A(const sc_fxval_fast&)
1713 DEFN_CTORS_T_B(const sc_fxnum&)
1714 DEFN_CTORS_T_B(const sc_fxnum_fast&)
1715 #ifndef SC_FX_EXCLUDE_OTHER
1716 DEFN_CTORS_T_A(int64)
1717 DEFN_CTORS_T_A(uint64)
1718 DEFN_CTORS_T_A(const sc_int_base&)
1719 DEFN_CTORS_T_A(const sc_uint_base&)
1720 DEFN_CTORS_T_A(const sc_signed&)
1721 DEFN_CTORS_T_A(const sc_unsigned&)
1722 #endif
1723
1724 #undef DEFN_CTORS_T_A
1725 #undef DEFN_CTORS_T_B
1726
1727 // copy constructor
1728
1729 inline
1730 sc_ufix_fast::sc_ufix_fast( const sc_ufix_fast& a )
1731 : sc_fxnum_fast( a,
1732 a.type_params(),
1733 SC_US_,
1734 sc_fxcast_switch(),
1735 0 )
1736 {}
1737
1738
1739 // unary bitwise operators
1740
1741 inline
1742 const sc_ufix_fast
1743 sc_ufix_fast::operator ~ () const
1744 {
1745 SC_FXNUM_FAST_OBSERVER_READ_( *this )
1746 int iwl_c = iwl();
1747 int wl_c = wl();
1748 sc_ufix_fast c( wl_c, iwl_c );
1749 for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
1750 c.set_bit( i, ! get_bit( i ) );
1751 return sc_ufix_fast( c, wl_c, iwl_c );
1752 }
1753
1754
1755 // unary bitwise functions
1756
1757 inline
1758 void
b_not(sc_ufix_fast & c,const sc_ufix_fast & a)1759 b_not( sc_ufix_fast& c, const sc_ufix_fast& a )
1760 {
1761 SC_FXNUM_FAST_OBSERVER_READ_( a )
1762 int iwl_c = c.iwl();
1763 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
1764 c.set_bit( i, ! a.get_bit( i ) );
1765 c.cast();
1766 SC_FXNUM_FAST_OBSERVER_WRITE_( c )
1767 }
1768
1769
1770 // binary bitwise operators
1771
1772 #define DEFN_BIN_OP_T(op,op2,tp1,tp2) \
1773 inline \
1774 const sc_ufix_fast \
1775 operator op ( const tp1& a, const tp2& b ) \
1776 { \
1777 a.observer_read(); \
1778 b.observer_read(); \
1779 int iwl_a = a.iwl(); \
1780 int iwl_b = b.iwl(); \
1781 int iwl_c = sc_max( iwl_a, iwl_b ); \
1782 int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b ); \
1783 sc_ufix_fast c( iwl_c + fwl_c, iwl_c ); \
1784 for( int i = -fwl_c; i < iwl_c; ++ i ) \
1785 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \
1786 return sc_ufix_fast( c, iwl_c + fwl_c, iwl_c ); \
1787 }
1788
1789 DEFN_BIN_OP_T(&,&&,sc_ufix_fast,sc_ufix_fast)
1790 DEFN_BIN_OP_T(|,||,sc_ufix_fast,sc_ufix_fast)
1791 DEFN_BIN_OP_T(^,!=,sc_ufix_fast,sc_ufix_fast)
1792
1793 #undef DEFN_BIN_OP_T
1794
1795
1796 // binary bitwise functions
1797
1798 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2) \
1799 inline \
1800 void \
1801 fnc ( sc_ufix_fast& c, const tp1& a, const tp2& b ) \
1802 { \
1803 a.observer_read(); \
1804 b.observer_read(); \
1805 int iwl_c = c.iwl(); \
1806 for( int i = iwl_c - c.wl(); i < iwl_c; ++ i ) \
1807 c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) ); \
1808 c.cast(); \
1809 SC_FXNUM_FAST_OBSERVER_WRITE_( c ) \
1810 }
1811
1812 DEFN_BIN_FNC_T(b_and,&&,sc_ufix_fast,sc_ufix_fast)
1813 DEFN_BIN_FNC_T(b_or,||,sc_ufix_fast,sc_ufix_fast)
1814 DEFN_BIN_FNC_T(b_xor,!=,sc_ufix_fast,sc_ufix_fast)
1815
1816 #undef DEFN_BIN_FNC_T
1817
1818
1819 // assignment operators
1820
1821 inline
1822 sc_ufix_fast&
1823 sc_ufix_fast::operator = ( const sc_ufix_fast& a )
1824 {
1825 sc_fxnum_fast::operator = ( a );
1826 return *this;
1827 }
1828
1829 #define DEFN_ASN_OP_T(op,tp) \
1830 inline \
1831 sc_ufix_fast& \
1832 sc_ufix_fast::operator op ( tp a ) \
1833 { \
1834 sc_fxnum_fast::operator op( a ); \
1835 return *this; \
1836 }
1837
1838 #ifndef SC_FX_EXCLUDE_OTHER
1839 #define DEFN_ASN_OP_OTHER(op) \
1840 DEFN_ASN_OP_T(op,int64) \
1841 DEFN_ASN_OP_T(op,uint64) \
1842 DEFN_ASN_OP_T(op,const sc_int_base&) \
1843 DEFN_ASN_OP_T(op,const sc_uint_base&) \
1844 DEFN_ASN_OP_T(op,const sc_signed&) \
1845 DEFN_ASN_OP_T(op,const sc_unsigned&)
1846 #else
1847 #define DEFN_ASN_OP_OTHER(op)
1848 #endif
1849
1850 #define DEFN_ASN_OP(op) \
1851 DEFN_ASN_OP_T(op,int) \
1852 DEFN_ASN_OP_T(op,unsigned int) \
1853 DEFN_ASN_OP_T(op,long) \
1854 DEFN_ASN_OP_T(op,unsigned long) \
1855 DEFN_ASN_OP_T(op,float) \
1856 DEFN_ASN_OP_T(op,double) \
1857 DEFN_ASN_OP_T(op,const char*) \
1858 DEFN_ASN_OP_T(op,const sc_fxval&) \
1859 DEFN_ASN_OP_T(op,const sc_fxval_fast&) \
1860 DEFN_ASN_OP_T(op,const sc_fxnum&) \
1861 DEFN_ASN_OP_T(op,const sc_fxnum_fast&) \
1862 DEFN_ASN_OP_OTHER(op)
1863
1864 DEFN_ASN_OP(=)
1865
1866 DEFN_ASN_OP(*=)
1867 DEFN_ASN_OP(/=)
1868 DEFN_ASN_OP(+=)
1869 DEFN_ASN_OP(-=)
1870
1871 DEFN_ASN_OP_T(<<=,int)
1872 DEFN_ASN_OP_T(>>=,int)
1873
1874 #undef DEFN_ASN_OP_T
1875 #undef DEFN_ASN_OP_OTHER
1876 #undef DEFN_ASN_OP
1877
1878
1879 #define DEFN_ASN_OP_T(op,op2,tp) \
1880 inline \
1881 sc_ufix_fast& \
1882 sc_ufix_fast::operator op ( const tp& b ) \
1883 { \
1884 SC_FXNUM_FAST_OBSERVER_READ_( *this ) \
1885 b.observer_read(); \
1886 int iwl_c = iwl(); \
1887 for( int i = iwl_c - wl(); i < iwl_c; ++ i ) \
1888 set_bit( i, get_bit( i ) op2 b.get_bit( i ) ); \
1889 cast(); \
1890 SC_FXNUM_FAST_OBSERVER_WRITE_( *this ) \
1891 return *this; \
1892 }
1893
1894 DEFN_ASN_OP_T(&=,&&,sc_ufix)
1895 DEFN_ASN_OP_T(&=,&&,sc_ufix_fast)
1896 DEFN_ASN_OP_T(|=,||,sc_ufix)
1897 DEFN_ASN_OP_T(|=,||,sc_ufix_fast)
1898 DEFN_ASN_OP_T(^=,!=,sc_ufix)
1899 DEFN_ASN_OP_T(^=,!=,sc_ufix_fast)
1900
1901 #undef DEFN_ASN_OP_T
1902
1903
1904 // auto-increment and auto-decrement
1905
1906 inline
1907 const sc_fxval_fast
1908 sc_ufix_fast::operator ++ ( int )
1909 {
1910 return sc_fxval_fast( sc_fxnum_fast::operator ++ ( 0 ) );
1911 }
1912
1913 inline
1914 const sc_fxval_fast
1915 sc_ufix_fast::operator -- ( int )
1916 {
1917 return sc_fxval_fast( sc_fxnum_fast::operator -- ( 0 ) );
1918 }
1919
1920 inline
1921 sc_ufix_fast&
1922 sc_ufix_fast::operator ++ ()
1923 {
1924 sc_fxnum_fast::operator ++ ();
1925 return *this;
1926 }
1927
1928 inline
1929 sc_ufix_fast&
1930 sc_ufix_fast::operator -- ()
1931 {
1932 sc_fxnum_fast::operator -- ();
1933 return *this;
1934 }
1935
1936 } // namespace sc_dt
1937
1938
1939 #endif
1940
1941 // Taf!
1942