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