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