gem5  v20.1.0.0
sc_ufix.hh
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 __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
51 #define __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
52 
53 #include "sc_fxnum.hh"
54 
55 namespace sc_dt
56 {
57 
58 // classes defined in this module
59 class sc_ufix;
60 class sc_ufix_fast;
61 
62 
63 // ----------------------------------------------------------------------------
64 // CLASS : sc_ufix
65 //
66 // "Unconstrained" unsigned fixed-point class; arbitrary precision.
67 // ----------------------------------------------------------------------------
68 
69 class sc_ufix : public sc_fxnum
70 {
71  public:
72  // constructors
73  explicit sc_ufix(sc_fxnum_observer * =0);
74  sc_ufix(int, int, sc_fxnum_observer * =0);
75  sc_ufix(sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
76  sc_ufix(sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
77  sc_ufix(int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
78  sc_ufix(int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
79  explicit sc_ufix(const sc_fxcast_switch &, sc_fxnum_observer * =0);
80  sc_ufix(int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0);
81  sc_ufix(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
82  sc_fxnum_observer * =0);
83  sc_ufix(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
84  sc_fxnum_observer * =0);
85  sc_ufix(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
86  sc_fxnum_observer * =0);
87  sc_ufix(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
88  sc_fxnum_observer * =0);
89  explicit sc_ufix(const sc_fxtype_params &, sc_fxnum_observer * =0);
90  sc_ufix(const sc_fxtype_params &, const sc_fxcast_switch &,
91  sc_fxnum_observer * =0);
92 
93 #define DECL_CTORS_T(tp) \
94  sc_ufix(tp, int, int, sc_fxnum_observer * =0); \
95  sc_ufix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
96  sc_ufix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
97  sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
98  sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
99  sc_ufix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
100  sc_ufix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
101  sc_ufix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
102  sc_fxnum_observer * =0); \
103  sc_ufix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
104  sc_fxnum_observer * =0); \
105  sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
106  sc_fxnum_observer * =0); \
107  sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, int, \
108  const sc_fxcast_switch &, sc_fxnum_observer * =0); \
109  sc_ufix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
110  sc_ufix(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
111  sc_fxnum_observer * =0);
112 
113 #define DECL_CTORS_T_A(tp) \
114  sc_ufix(tp, sc_fxnum_observer * =0); \
115  DECL_CTORS_T(tp)
116 
117 #define DECL_CTORS_T_B(tp) \
118  explicit sc_ufix(tp, sc_fxnum_observer * =0); \
119  DECL_CTORS_T(tp)
120 
121  DECL_CTORS_T_A(int)
122  DECL_CTORS_T_A(unsigned int)
123  DECL_CTORS_T_A(long)
124  DECL_CTORS_T_A(unsigned long)
125  DECL_CTORS_T_A(float)
126  DECL_CTORS_T_A(double)
127  DECL_CTORS_T_A(const char *)
128  DECL_CTORS_T_A(const sc_fxval &)
130  DECL_CTORS_T_A(const sc_fxnum &)
132 
135  DECL_CTORS_T_B(const sc_int_base &)
137  DECL_CTORS_T_B(const sc_signed &)
138  DECL_CTORS_T_B(const sc_unsigned &)
139 
140 #undef DECL_CTORS_T
141 #undef DECL_CTORS_T_A
142 #undef DECL_CTORS_T_B
143 
144  // copy constructor
145  sc_ufix(const sc_ufix &);
146 
147  // unary bitwise operators
148  const sc_ufix operator ~ () const;
149 
150  // unary bitwise functions
151  friend void b_not(sc_ufix &, const sc_ufix &);
152 
153  // binary bitwise operators
154  friend const sc_ufix operator & (const sc_ufix &, const sc_ufix &);
155  friend const sc_ufix operator & (const sc_ufix &, const sc_ufix_fast &);
156  friend const sc_ufix operator & (const sc_ufix_fast &, const sc_ufix &);
157  friend const sc_ufix operator | (const sc_ufix &, const sc_ufix &);
158  friend const sc_ufix operator | (const sc_ufix &, const sc_ufix_fast &);
159  friend const sc_ufix operator | (const sc_ufix_fast &, const sc_ufix &);
160  friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix &);
161  friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix_fast &);
162  friend const sc_ufix operator ^ (const sc_ufix_fast &, const sc_ufix &);
163 
164  // binary bitwise functions
165  friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix &);
166  friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
167  friend void b_and(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
168  friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix &);
169  friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
170  friend void b_or(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
171  friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix &);
172  friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
173  friend void b_xor(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
174 
175  // assignment operators
176  sc_ufix &operator = (const sc_ufix &);
177 
178 #define DECL_ASN_OP_T(op,tp) sc_ufix &operator op (tp);
179 
180 #define DECL_ASN_OP_OTHER(op) \
181  DECL_ASN_OP_T(op, int64) \
182  DECL_ASN_OP_T(op, uint64) \
183  DECL_ASN_OP_T(op, const sc_int_base &) \
184  DECL_ASN_OP_T(op, const sc_uint_base &) \
185  DECL_ASN_OP_T(op, const sc_signed &) \
186  DECL_ASN_OP_T(op, const sc_unsigned &)
187 
188 #define DECL_ASN_OP(op) \
189  DECL_ASN_OP_T(op, int) \
190  DECL_ASN_OP_T(op, unsigned int) \
191  DECL_ASN_OP_T(op, long) \
192  DECL_ASN_OP_T(op, unsigned long) \
193  DECL_ASN_OP_T(op, float) \
194  DECL_ASN_OP_T(op, double) \
195  DECL_ASN_OP_T(op, const char *) \
196  DECL_ASN_OP_T(op, const sc_fxval &) \
197  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
198  DECL_ASN_OP_T(op, const sc_fxnum &) \
199  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
200  DECL_ASN_OP_OTHER(op)
201 
202  DECL_ASN_OP(=)
203 
204  DECL_ASN_OP(*=)
205  DECL_ASN_OP(/=)
206  DECL_ASN_OP(+=)
207  DECL_ASN_OP(-=)
208 
209  DECL_ASN_OP_T(<<=, int)
210  DECL_ASN_OP_T(>>=, int)
211 
212  DECL_ASN_OP_T(&=, const sc_ufix &)
213  DECL_ASN_OP_T(&=, const sc_ufix_fast &)
214  DECL_ASN_OP_T(|=, const sc_ufix &)
215  DECL_ASN_OP_T(|=, const sc_ufix_fast &)
216  DECL_ASN_OP_T(^=, const sc_ufix &)
217  DECL_ASN_OP_T(^=, const sc_ufix_fast &)
218 
219 #undef DECL_ASN_OP_T
220 #undef DECL_ASN_OP_OTHER
221 #undef DECL_ASN_OP
222 
223  // auto-increment and auto-decrement
224  const sc_fxval operator ++ (int);
225  const sc_fxval operator -- (int);
226 
229 };
230 
231 
232 // ----------------------------------------------------------------------------
233 // CLASS : sc_ufix_fast
234 //
235 // "Unconstrained" unsigned fixed-point class; limited precision.
236 // ----------------------------------------------------------------------------
237 
238 class sc_ufix_fast : public sc_fxnum_fast
239 {
240  public:
241  // constructors
242  explicit sc_ufix_fast(sc_fxnum_fast_observer * =0);
243  sc_ufix_fast(int, int, sc_fxnum_fast_observer * =0);
247  sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, int,
249  explicit sc_ufix_fast(const sc_fxcast_switch &,
251  sc_ufix_fast(int, int, const sc_fxcast_switch &,
257  sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
259  sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
261  explicit sc_ufix_fast(const sc_fxtype_params &,
265 
266 #define DECL_CTORS_T(tp) \
267  sc_ufix_fast(tp, int, int, sc_fxnum_fast_observer * =0); \
268  sc_ufix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0); \
269  sc_ufix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0); \
270  sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
271  sc_fxnum_fast_observer * =0); \
272  sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
273  sc_fxnum_fast_observer * =0); \
274  sc_ufix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
275  sc_ufix_fast(tp, int, int, const sc_fxcast_switch &, \
276  sc_fxnum_fast_observer * =0); \
277  sc_ufix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
278  sc_fxnum_fast_observer * =0); \
279  sc_ufix_fast(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
280  sc_fxnum_fast_observer * =0); \
281  sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
282  const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
283  sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
284  const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
285  sc_ufix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * =0); \
286  sc_ufix_fast(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
287  sc_fxnum_fast_observer * =0);
288 
289 #define DECL_CTORS_T_A(tp) \
290  sc_ufix_fast(tp, sc_fxnum_fast_observer * =0); \
291  DECL_CTORS_T(tp)
292 
293 #define DECL_CTORS_T_B(tp) \
294  explicit sc_ufix_fast(tp, sc_fxnum_fast_observer * =0); \
295  DECL_CTORS_T(tp)
296 
298  DECL_CTORS_T_A(unsigned int)
299  DECL_CTORS_T_A(long)
300  DECL_CTORS_T_A(unsigned long)
301  DECL_CTORS_T_A(float)
302  DECL_CTORS_T_A(double)
303  DECL_CTORS_T_A(const char *)
304  DECL_CTORS_T_A(const sc_fxval &)
306  DECL_CTORS_T_A(const sc_fxnum &)
308 
311  DECL_CTORS_T_B(const sc_int_base &)
312  DECL_CTORS_T_B(const sc_uint_base &)
313  DECL_CTORS_T_B(const sc_signed &)
314  DECL_CTORS_T_B(const sc_unsigned &)
315 
316 #undef DECL_CTORS_T
317 #undef DECL_CTORS_T_A
318 #undef DECL_CTORS_T_B
319 
320  // copy constructor
321  sc_ufix_fast(const sc_ufix_fast &);
322 
323  // unary bitwise operators
324  const sc_ufix_fast operator ~ () const;
325 
326  // unary bitwise functions
327  friend void b_not(sc_ufix_fast &, const sc_ufix_fast &);
328 
329 
330  // binary bitwise operators
331 
332  friend const sc_ufix_fast operator & (const sc_ufix_fast &,
333  const sc_ufix_fast &);
334  friend const sc_ufix_fast operator ^ (const sc_ufix_fast &,
335  const sc_ufix_fast &);
336  friend const sc_ufix_fast operator | (const sc_ufix_fast &,
337  const sc_ufix_fast &);
338 
339 
340  // binary bitwise functions
341 
342  friend void b_and(sc_ufix_fast &, const sc_ufix_fast &,
343  const sc_ufix_fast &);
344  friend void b_or(sc_ufix_fast &, const sc_ufix_fast &,
345  const sc_ufix_fast &);
346  friend void b_xor(sc_ufix_fast &, const sc_ufix_fast &,
347  const sc_ufix_fast &);
348 
349  // assignment operators
351 
352 #define DECL_ASN_OP_T(op,tp) sc_ufix_fast &operator op (tp);
353 
354 #define DECL_ASN_OP_OTHER(op) \
355  DECL_ASN_OP_T(op, int64) \
356  DECL_ASN_OP_T(op, uint64) \
357  DECL_ASN_OP_T(op, const sc_int_base &) \
358  DECL_ASN_OP_T(op, const sc_uint_base &) \
359  DECL_ASN_OP_T(op, const sc_signed &) \
360  DECL_ASN_OP_T(op, const sc_unsigned &)
361 
362 #define DECL_ASN_OP(op) \
363  DECL_ASN_OP_T(op, int) \
364  DECL_ASN_OP_T(op, unsigned int) \
365  DECL_ASN_OP_T(op, long) \
366  DECL_ASN_OP_T(op, unsigned long) \
367  DECL_ASN_OP_T(op, float) \
368  DECL_ASN_OP_T(op, double) \
369  DECL_ASN_OP_T(op, const char *) \
370  DECL_ASN_OP_T(op, const sc_fxval &) \
371  DECL_ASN_OP_T(op, const sc_fxval_fast &) \
372  DECL_ASN_OP_T(op, const sc_fxnum &) \
373  DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
374  DECL_ASN_OP_OTHER(op)
375 
376  DECL_ASN_OP(=)
377 
378  DECL_ASN_OP(*=)
379  DECL_ASN_OP(/=)
380  DECL_ASN_OP(+=)
381  DECL_ASN_OP(-=)
382 
383  DECL_ASN_OP_T(<<=, int)
384  DECL_ASN_OP_T(>>=, int)
385 
386  DECL_ASN_OP_T(&=, const sc_ufix &)
387  DECL_ASN_OP_T(&=, const sc_ufix_fast &)
388  DECL_ASN_OP_T(|=, const sc_ufix &)
389  DECL_ASN_OP_T(|=, const sc_ufix_fast &)
390  DECL_ASN_OP_T(^=, const sc_ufix &)
391  DECL_ASN_OP_T(^=, const sc_ufix_fast &)
392 
393 #undef DECL_ASN_OP_T
394 #undef DECL_ASN_OP_OTHER
395 #undef DECL_ASN_OP
396 
397  // auto-increment and auto-decrement
398  const sc_fxval_fast operator ++ (int);
399  const sc_fxval_fast operator -- (int);
400 
403 };
404 
405 
406 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
407 
408 // ----------------------------------------------------------------------------
409 // CLASS : sc_ufix
410 //
411 // "Unconstrained" unsigned fixed-point class; arbitrary precision.
412 // ----------------------------------------------------------------------------
413 
414 // constructors
415 
416 inline sc_ufix::sc_ufix(sc_fxnum_observer *observer_) :
417  sc_fxnum(sc_fxtype_params(), SC_US_, sc_fxcast_switch(), observer_)
418 {}
419 
420 inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_fxnum_observer *observer_ ) :
421  sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(),
422  observer_)
423 {}
424 
425 inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
426  sc_fxnum_observer *observer_) :
427  sc_fxnum(sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(),
428  observer_)
429 {}
430 
431 inline
432 sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
433  sc_fxnum_observer *observer_) :
434  sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(),
435  observer_)
436 {}
437 
438 inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
439  sc_fxnum_observer *observer_) :
440  sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
441  sc_fxcast_switch(), observer_)
442 {}
443 
444 inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
445  sc_fxnum_observer *observer_) :
446  sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
447  sc_fxcast_switch(), observer_)
448 {}
449 
450 inline sc_ufix::sc_ufix(const sc_fxcast_switch &cast_sw,
451  sc_fxnum_observer *observer_) :
452  sc_fxnum(sc_fxtype_params(), SC_US_, cast_sw, observer_)
453 {}
454 
455 inline sc_ufix::sc_ufix(int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
456  sc_fxnum_observer *observer_) :
457  sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
458 {}
459 
460 inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
461  const sc_fxcast_switch &cast_sw,
462  sc_fxnum_observer *observer_) :
463  sc_fxnum(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
464 {}
465 
466 inline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
467  const sc_fxcast_switch &cast_sw,
468  sc_fxnum_observer *observer_ ) :
469  sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
470 {}
471 
472 inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
473  const sc_fxcast_switch &cast_sw,
474  sc_fxnum_observer *observer_) :
475  sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
476  observer_)
477 {}
478 
479 inline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
480  const sc_fxcast_switch &cast_sw,
481  sc_fxnum_observer *observer_) :
482  sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
483  observer_)
484 {}
485 
486 inline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
487  sc_fxnum_observer *observer_) :
488  sc_fxnum(type_params_, SC_US_, sc_fxcast_switch(), observer_)
489 {}
490 
491 inline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
492  const sc_fxcast_switch &cast_sw,
493  sc_fxnum_observer *observer_ ) :
494  sc_fxnum(type_params_, SC_US_, cast_sw, observer_)
495 {}
496 
497 #define DEFN_CTORS_T_A(tp) \
498 inline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_ ) : \
499  sc_fxnum(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
500  observer_) \
501 {} \
502  \
503 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
504  sc_fxnum_observer *observer_) : \
505  sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
506  observer_ ) \
507 {} \
508  \
509 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
510  sc_fxnum_observer *observer_) : \
511  sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
512  observer_ ) \
513 {} \
514  \
515 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
516  sc_fxnum_observer *observer_) : \
517  sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(), \
518  observer_ ) \
519 {} \
520  \
521 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
522  sc_fxnum_observer *observer_) : \
523  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
524  sc_fxcast_switch(), observer_) \
525 {} \
526  \
527 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
528  int nb, sc_fxnum_observer *observer_) : \
529  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
530  sc_fxcast_switch(), observer_) \
531 {} \
532  \
533 inline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch &cast_sw, \
534  sc_fxnum_observer *observer_) : \
535  sc_fxnum(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
536 {} \
537  \
538 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
539  const sc_fxcast_switch &cast_sw, \
540  sc_fxnum_observer *observer_) : \
541  sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
542 {} \
543  \
544 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
545  const sc_fxcast_switch &cast_sw, \
546  sc_fxnum_observer *observer_) : \
547  sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
548 {} \
549  \
550 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
551  const sc_fxcast_switch &cast_sw, \
552  sc_fxnum_observer *observer_) : \
553  sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_) \
554 {} \
555  \
556 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
557  const sc_fxcast_switch &cast_sw, \
558  sc_fxnum_observer *observer_) : \
559  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
560  observer_) \
561 {} \
562  \
563 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
564  int nb, const sc_fxcast_switch &cast_sw, \
565  sc_fxnum_observer *observer_) : \
566  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
567  observer_) \
568 {} \
569  \
570 inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
571  sc_fxnum_observer * observer_) : \
572  sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
573 {} \
574  \
575 inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
576  const sc_fxcast_switch &cast_sw, \
577  sc_fxnum_observer *observer_) : \
578  sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
579 {}
580 
581 #define DEFN_CTORS_T_B(tp) \
582 inline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_) : \
583  sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
584 {} \
585  \
586 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
587  sc_fxnum_observer *observer_) : \
588  sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
589  sc_fxcast_switch(), observer_) \
590 {} \
591  \
592 inline \
593 sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
594  sc_fxnum_observer *observer_) : \
595  sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
596  sc_fxcast_switch(), observer_) \
597 {} \
598  \
599 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
600  sc_fxnum_observer *observer_) : \
601  sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
602  sc_fxcast_switch(), observer_) \
603 {} \
604  \
605 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
606  sc_fxnum_observer* observer_) : \
607  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
608  sc_fxcast_switch(), observer_) \
609 {} \
610  \
611 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
612  int nb, sc_fxnum_observer *observer_) : \
613  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
614  sc_fxcast_switch(), observer_) \
615 {} \
616  \
617 inline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch& cast_sw, \
618  sc_fxnum_observer* observer_) : \
619  sc_fxnum(a, a.type_params(), SC_US_, cast_sw, observer_) \
620 {} \
621  \
622 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
623  const sc_fxcast_switch &cast_sw, \
624  sc_fxnum_observer *observer_) : \
625  sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
626  cast_sw, observer_) \
627 {} \
628  \
629 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
630  const sc_fxcast_switch &cast_sw, \
631  sc_fxnum_observer *observer_) : \
632  sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
633  cast_sw, observer_) \
634 {} \
635  \
636 inline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
637  const sc_fxcast_switch &cast_sw, \
638  sc_fxnum_observer *observer_) : \
639  sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
640  cast_sw, observer_) \
641 {} \
642  \
643 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
644  const sc_fxcast_switch &cast_sw, \
645  sc_fxnum_observer *observer_) : \
646  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
647  observer_) \
648 {} \
649  \
650 inline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
651  int nb, const sc_fxcast_switch &cast_sw, \
652  sc_fxnum_observer *observer_) : \
653  sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
654  observer_) \
655 {} \
656  \
657 inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
658  sc_fxnum_observer *observer_) : \
659  sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
660 {} \
661  \
662 inline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
663  const sc_fxcast_switch &cast_sw, \
664  sc_fxnum_observer *observer_) : \
665  sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
666 {}
667 
668 DEFN_CTORS_T_A(int)
669 DEFN_CTORS_T_A(unsigned int)
670 DEFN_CTORS_T_A(long)
671 DEFN_CTORS_T_A(unsigned long)
672 DEFN_CTORS_T_A(float)
673 DEFN_CTORS_T_A(double)
674 DEFN_CTORS_T_A(const char *)
675 DEFN_CTORS_T_A(const sc_fxval &)
677 DEFN_CTORS_T_B(const sc_fxnum &)
679 
684 DEFN_CTORS_T_A(const sc_signed &)
686 
687 #undef DEFN_CTORS_T_A
688 #undef DEFN_CTORS_T_B
689 
690 // copy constructor
691 
692 inline sc_ufix::sc_ufix(const sc_ufix &a) :
693  sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
694 {}
695 
696 // unary bitwise operators
697 inline const sc_ufix
698 sc_ufix::operator ~ () const
699 {
701  int iwl_c = iwl();
702  int wl_c = wl();
703  sc_ufix c(wl_c, iwl_c);
704  for (int i = iwl_c - wl_c; i < iwl_c; ++i)
705  c.set_bit(i, !get_bit(i));
706  return sc_ufix(c, wl_c, iwl_c);
707 }
708 
709 // unary bitwise functions
710 inline void
711 b_not(sc_ufix &c, const sc_ufix &a)
712 {
714  int iwl_c = c.iwl();
715  for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
716  c.set_bit(i, !a.get_bit(i));
717  c.cast();
719 }
720 
721 // binary bitwise operators
722 #define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
723 inline const sc_ufix \
724 operator op (const tp1 &a, const tp2 &b) \
725 { \
726  a.observer_read(); \
727  b.observer_read(); \
728  int iwl_a = a.iwl(); \
729  int iwl_b = b.iwl(); \
730  int iwl_c = sc_max(iwl_a, iwl_b); \
731  int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
732  sc_ufix c(iwl_c + fwl_c, iwl_c); \
733  for (int i = -fwl_c; i < iwl_c; ++i) \
734  c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
735  return sc_ufix(c, iwl_c + fwl_c, iwl_c); \
736 }
737 
741 
745 
749 
750 #undef DEFN_BIN_OP_T
751 
752 // binary bitwise functions
753 #define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
754 inline void \
755 fnc (sc_ufix &c, const tp1 &a, const tp2 &b) \
756 { \
757  a.observer_read(); \
758  b.observer_read(); \
759  int iwl_c = c.iwl(); \
760  for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
761  c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
762  c.cast(); \
763  SC_FXNUM_OBSERVER_WRITE_(c) \
764 }
765 
769 
773 
777 
778 #undef DEFN_BIN_FNC_T
779 
780 // assignment operators
781 inline sc_ufix &
783 {
784  sc_fxnum::operator = (a);
785  return *this;
786 }
787 
788 #define DEFN_ASN_OP_T(op, tp) \
789 inline sc_ufix & \
790 sc_ufix::operator op (tp a) \
791 { \
792  sc_fxnum::operator op(a); \
793  return *this; \
794 }
795 
796 #define DEFN_ASN_OP_OTHER(op) \
797 DEFN_ASN_OP_T(op, int64) \
798 DEFN_ASN_OP_T(op, uint64) \
799 DEFN_ASN_OP_T(op, const sc_int_base &) \
800 DEFN_ASN_OP_T(op, const sc_uint_base &) \
801 DEFN_ASN_OP_T(op, const sc_signed &) \
802 DEFN_ASN_OP_T(op, const sc_unsigned &)
803 
804 #define DEFN_ASN_OP(op) \
805 DEFN_ASN_OP_T(op, int) \
806 DEFN_ASN_OP_T(op, unsigned int) \
807 DEFN_ASN_OP_T(op, long) \
808 DEFN_ASN_OP_T(op, unsigned long) \
809 DEFN_ASN_OP_T(op, float) \
810 DEFN_ASN_OP_T(op, double) \
811 DEFN_ASN_OP_T(op, const char *) \
812 DEFN_ASN_OP_T(op, const sc_fxval &) \
813 DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
814 DEFN_ASN_OP_T(op, const sc_fxnum &) \
815 DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
816 DEFN_ASN_OP_OTHER(op)
817 
818 DEFN_ASN_OP(=)
819 
820 DEFN_ASN_OP(*=)
821 DEFN_ASN_OP(/=)
822 DEFN_ASN_OP(+=)
823 DEFN_ASN_OP(-=)
824 
825 DEFN_ASN_OP_T(<<=, int)
826 DEFN_ASN_OP_T(>>=, int)
827 
828 #undef DEFN_ASN_OP_T
829 #undef DEFN_ASN_OP_OTHER
830 #undef DEFN_ASN_OP
831 
832 
833 #define DEFN_ASN_OP_T(op, op2, tp) \
834 inline sc_ufix & \
835 sc_ufix::operator op (const tp &b) \
836 { \
837  SC_FXNUM_OBSERVER_READ_(*this) \
838  b.observer_read(); \
839  int iwl_c = iwl(); \
840  for (int i = iwl_c - wl(); i < iwl_c; ++i) \
841  set_bit(i, get_bit(i) op2 b.get_bit(i)); \
842  cast(); \
843  SC_FXNUM_OBSERVER_WRITE_(*this) \
844  return *this; \
845 }
846 
847 DEFN_ASN_OP_T(&=, &&, sc_ufix)
849 DEFN_ASN_OP_T(|=, ||, sc_ufix)
851 DEFN_ASN_OP_T(^=, !=, sc_ufix)
853 
854 #undef DEFN_ASN_OP_T
855 
856 // auto-increment and auto-decrement
857 inline const sc_fxval
859 {
860  return sc_fxval(sc_fxnum::operator ++ (0));
861 }
862 
863 inline const sc_fxval
865 {
866  return sc_fxval(sc_fxnum::operator -- (0));
867 }
868 
869 inline sc_ufix &
871 {
873  return *this;
874 }
875 
876 inline sc_ufix &
878 {
880  return *this;
881 }
882 
883 
884 // ----------------------------------------------------------------------------
885 // CLASS : sc_ufix_fast
886 //
887 // "Unconstrained" unsigned fixed-point class; limited precision.
888 // ----------------------------------------------------------------------------
889 
890 // constructors
891 
894  observer_)
895 {}
896 
897 inline sc_ufix_fast::sc_ufix_fast(int wl_, int iwl_,
898  sc_fxnum_fast_observer *observer_) :
900  observer_ )
901 {}
902 
904  sc_fxnum_fast_observer *observer_) :
906  observer_ )
907 {}
908 
909 inline sc_ufix_fast::sc_ufix_fast(sc_q_mode qm, sc_o_mode om, int nb,
910  sc_fxnum_fast_observer *observer_) :
912  observer_ )
913 {}
914 
916  int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
917  sc_fxnum_fast_observer *observer_) :
918  sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
919  sc_fxcast_switch(), observer_)
920 {}
921 
923  int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
924  sc_fxnum_fast_observer *observer_) :
925  sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
926  sc_fxcast_switch(), observer_)
927 {}
928 
929 inline sc_ufix_fast::sc_ufix_fast(const sc_fxcast_switch &cast_sw,
930  sc_fxnum_fast_observer *observer_) :
931  sc_fxnum_fast(sc_fxtype_params(), SC_US_, cast_sw, observer_)
932 {}
933 
935  int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
936  sc_fxnum_fast_observer *observer_) :
937  sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
938 {}
939 
941  sc_q_mode qm, sc_o_mode om, const sc_fxcast_switch &cast_sw,
942  sc_fxnum_fast_observer *observer_) :
943  sc_fxnum_fast(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
944 {}
945 
947  sc_q_mode qm, sc_o_mode om, int nb, const sc_fxcast_switch &cast_sw,
948  sc_fxnum_fast_observer *observer_) :
949  sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
950 {}
951 
953  int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
954  const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
955  sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
956  observer_ )
957 {}
958 
960  int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
961  const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
962  sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
963  observer_)
964 {}
965 
966 inline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
967  sc_fxnum_fast_observer *observer_) :
968  sc_fxnum_fast(type_params_, SC_US_, sc_fxcast_switch(), observer_)
969 {}
970 
971 inline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
972  const sc_fxcast_switch &cast_sw,
973  sc_fxnum_fast_observer *observer_) :
974  sc_fxnum_fast(type_params_, SC_US_, cast_sw, observer_)
975 {}
976 
977 #define DEFN_CTORS_T_A(tp) \
978 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
979  sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
980  observer_) \
981 {} \
982  \
983 inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
984  sc_fxnum_fast_observer *observer_) : \
985  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
986  observer_) \
987 {} \
988  \
989 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
990  sc_fxnum_fast_observer *observer_) : \
991  sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
992  observer_) \
993 {} \
994  \
995 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
996  sc_fxnum_fast_observer *observer_) : \
997  sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, \
998  sc_fxcast_switch(), observer_) \
999 {} \
1000  \
1001 inline sc_ufix_fast::sc_ufix_fast( \
1002  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1003  sc_fxnum_fast_observer* observer_) : \
1004  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
1005  sc_fxcast_switch(), observer_) \
1006 {} \
1007  \
1008 inline sc_ufix_fast::sc_ufix_fast( \
1009  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
1010  sc_fxnum_fast_observer *observer_) : \
1011  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
1012  sc_fxcast_switch(), observer_) \
1013 {} \
1014  \
1015 inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
1016  sc_fxnum_fast_observer *observer_) : \
1017  sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
1018 {} \
1019  \
1020 inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
1021  const sc_fxcast_switch &cast_sw, \
1022  sc_fxnum_fast_observer *observer_) : \
1023  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
1024 {} \
1025  \
1026 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1027  const sc_fxcast_switch &cast_sw, \
1028  sc_fxnum_fast_observer *observer_) : \
1029  sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
1030 {} \
1031  \
1032 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1033  const sc_fxcast_switch &cast_sw, \
1034  sc_fxnum_fast_observer *observer_) : \
1035  sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, \
1036  observer_) \
1037 {} \
1038  \
1039 inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
1040  sc_q_mode qm, sc_o_mode om, \
1041  const sc_fxcast_switch &cast_sw, \
1042  sc_fxnum_fast_observer *observer_) : \
1043  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
1044  observer_) \
1045 {} \
1046  \
1047 inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
1048  sc_q_mode qm, sc_o_mode om, int nb, \
1049  const sc_fxcast_switch &cast_sw, \
1050  sc_fxnum_fast_observer *observer_) : \
1051  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
1052  cast_sw, observer_) \
1053 {} \
1054  \
1055 inline sc_ufix_fast::sc_ufix_fast( \
1056  tp a, const sc_fxtype_params &type_params_, \
1057  sc_fxnum_fast_observer *observer_) : \
1058  sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
1059 {} \
1060  \
1061 inline sc_ufix_fast::sc_ufix_fast( \
1062  tp a, const sc_fxtype_params &type_params_, \
1063  const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
1064  sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
1065 {}
1066 
1067 #define DEFN_CTORS_T_B(tp) \
1068 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
1069  sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
1070 {} \
1071  \
1072 inline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
1073  sc_fxnum_fast_observer* observer_) : \
1074  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
1075  sc_fxcast_switch(), observer_) \
1076 {} \
1077  \
1078 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1079  sc_fxnum_fast_observer* observer_) : \
1080  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
1081  sc_fxcast_switch(), observer_) \
1082 {} \
1083  \
1084 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1085  sc_fxnum_fast_observer* observer_) : \
1086  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
1087  sc_fxcast_switch(), observer_) \
1088 {} \
1089  \
1090 inline sc_ufix_fast::sc_ufix_fast( \
1091  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1092  sc_fxnum_fast_observer *observer_) : \
1093  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
1094  sc_fxcast_switch(), observer_) \
1095 {} \
1096  \
1097 inline sc_ufix_fast::sc_ufix_fast( \
1098  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
1099  sc_fxnum_fast_observer *observer_) : \
1100  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
1101  sc_fxcast_switch(), observer_) \
1102 {} \
1103  \
1104 inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
1105  sc_fxnum_fast_observer *observer_) : \
1106  sc_fxnum_fast(a, a.type_params(), SC_US_, cast_sw, observer_) \
1107 {} \
1108  \
1109 inline sc_ufix_fast::sc_ufix_fast( \
1110  tp a, int wl_, int iwl_, const sc_fxcast_switch &cast_sw, \
1111  sc_fxnum_fast_observer *observer_) : \
1112  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
1113  cast_sw, observer_) \
1114 {} \
1115  \
1116 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1117  const sc_fxcast_switch &cast_sw, \
1118  sc_fxnum_fast_observer *observer_) : \
1119  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
1120  cast_sw, observer_) \
1121 {} \
1122  \
1123 inline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1124  const sc_fxcast_switch &cast_sw, \
1125  sc_fxnum_fast_observer *observer_) : \
1126  sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
1127  cast_sw, observer_) \
1128 {} \
1129  \
1130 inline sc_ufix_fast::sc_ufix_fast( \
1131  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
1132  const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
1133  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
1134  observer_) \
1135 {} \
1136  \
1137 inline sc_ufix_fast::sc_ufix_fast( \
1138  tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
1139  const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
1140  sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
1141  cast_sw, observer_) \
1142 {} \
1143  \
1144 inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
1145  sc_fxnum_fast_observer *observer_) : \
1146  sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
1147 {} \
1148  \
1149 inline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
1150  const sc_fxcast_switch &cast_sw, \
1151  sc_fxnum_fast_observer* observer_) : \
1152  sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
1153 {}
1154 
1155 DEFN_CTORS_T_A(int)
1156 DEFN_CTORS_T_A(unsigned int)
1157 DEFN_CTORS_T_A(long)
1158 DEFN_CTORS_T_A(unsigned long)
1159 DEFN_CTORS_T_A(float)
1160 DEFN_CTORS_T_A(double)
1161 DEFN_CTORS_T_A(const char *)
1162 DEFN_CTORS_T_A(const sc_fxval &)
1163 DEFN_CTORS_T_A(const sc_fxval_fast &)
1164 DEFN_CTORS_T_B(const sc_fxnum &)
1165 DEFN_CTORS_T_B(const sc_fxnum_fast &)
1166 
1169 DEFN_CTORS_T_A(const sc_int_base &)
1170 DEFN_CTORS_T_A(const sc_uint_base &)
1171 DEFN_CTORS_T_A(const sc_signed &)
1172 DEFN_CTORS_T_A(const sc_unsigned &)
1173 
1174 #undef DEFN_CTORS_T_A
1175 #undef DEFN_CTORS_T_B
1176 
1177 // copy constructor
1178 inline sc_ufix_fast::sc_ufix_fast(const sc_ufix_fast &a) :
1179  sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
1180 {}
1181 
1182 // unary bitwise operators
1183 inline const sc_ufix_fast
1185 {
1187  int iwl_c = iwl();
1188  int wl_c = wl();
1189  sc_ufix_fast c(wl_c, iwl_c);
1190  for (int i = iwl_c - wl_c; i < iwl_c; ++i)
1191  c.set_bit(i, !get_bit(i));
1192  return sc_ufix_fast(c, wl_c, iwl_c);
1193 }
1194 
1195 // unary bitwise functions
1196 inline void
1197 b_not(sc_ufix_fast &c, const sc_ufix_fast &a)
1198 {
1200  int iwl_c = c.iwl();
1201  for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
1202  c.set_bit(i, !a.get_bit(i));
1203  c.cast();
1205 }
1206 
1207 // binary bitwise operators
1208 #define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
1209 inline const sc_ufix_fast \
1210 operator op (const tp1 &a, const tp2 &b) \
1211 { \
1212  a.observer_read(); \
1213  b.observer_read(); \
1214  int iwl_a = a.iwl(); \
1215  int iwl_b = b.iwl(); \
1216  int iwl_c = sc_max(iwl_a, iwl_b); \
1217  int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
1218  sc_ufix_fast c(iwl_c + fwl_c, iwl_c); \
1219  for (int i = -fwl_c; i < iwl_c; ++i) \
1220  c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
1221  return sc_ufix_fast(c, iwl_c + fwl_c, iwl_c); \
1222 }
1223 
1227 
1228 #undef DEFN_BIN_OP_T
1229 
1230 // binary bitwise functions
1231 #define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
1232 inline void \
1233 fnc (sc_ufix_fast &c, const tp1 &a, const tp2 &b) \
1234 { \
1235  a.observer_read(); \
1236  b.observer_read(); \
1237  int iwl_c = c.iwl(); \
1238  for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
1239  c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
1240  c.cast(); \
1241  SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
1242 }
1243 
1244 DEFN_BIN_FNC_T(b_and, &&, sc_ufix_fast, sc_ufix_fast)
1245 DEFN_BIN_FNC_T(b_or, ||, sc_ufix_fast, sc_ufix_fast)
1246 DEFN_BIN_FNC_T(b_xor, !=, sc_ufix_fast, sc_ufix_fast)
1247 
1248 #undef DEFN_BIN_FNC_T
1249 
1250 // assignment operators
1251 inline sc_ufix_fast &
1252 sc_ufix_fast::operator = (const sc_ufix_fast &a)
1253 {
1254  sc_fxnum_fast::operator = (a);
1255  return *this;
1256 }
1257 
1258 #define DEFN_ASN_OP_T(op, tp) \
1259 inline sc_ufix_fast & \
1260 sc_ufix_fast::operator op (tp a) \
1261 { \
1262  sc_fxnum_fast::operator op(a); \
1263  return *this; \
1264 }
1265 
1266 #define DEFN_ASN_OP_OTHER(op) \
1267 DEFN_ASN_OP_T(op, int64) \
1268 DEFN_ASN_OP_T(op, uint64) \
1269 DEFN_ASN_OP_T(op, const sc_int_base &) \
1270 DEFN_ASN_OP_T(op, const sc_uint_base &) \
1271 DEFN_ASN_OP_T(op, const sc_signed &) \
1272 DEFN_ASN_OP_T(op, const sc_unsigned &)
1273 
1274 #define DEFN_ASN_OP(op) \
1275 DEFN_ASN_OP_T(op, int) \
1276 DEFN_ASN_OP_T(op, unsigned int) \
1277 DEFN_ASN_OP_T(op, long) \
1278 DEFN_ASN_OP_T(op, unsigned long) \
1279 DEFN_ASN_OP_T(op, float) \
1280 DEFN_ASN_OP_T(op, double) \
1281 DEFN_ASN_OP_T(op, const char *) \
1282 DEFN_ASN_OP_T(op, const sc_fxval &) \
1283 DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
1284 DEFN_ASN_OP_T(op, const sc_fxnum &) \
1285 DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
1286 DEFN_ASN_OP_OTHER(op)
1287 
1288 DEFN_ASN_OP(=)
1289 
1290 DEFN_ASN_OP(*=)
1291 DEFN_ASN_OP(/=)
1292 DEFN_ASN_OP(+=)
1293 DEFN_ASN_OP(-=)
1294 
1295 DEFN_ASN_OP_T(<<=, int)
1296 DEFN_ASN_OP_T(>>=, int)
1298 #undef DEFN_ASN_OP_T
1299 #undef DEFN_ASN_OP_OTHER
1300 #undef DEFN_ASN_OP
1301 
1302 #define DEFN_ASN_OP_T(op, op2, tp) \
1303 inline sc_ufix_fast & \
1304 sc_ufix_fast::operator op (const tp &b) \
1305 { \
1306  SC_FXNUM_FAST_OBSERVER_READ_(*this) \
1307  b.observer_read(); \
1308  int iwl_c = iwl(); \
1309  for (int i = iwl_c - wl(); i < iwl_c; ++i) \
1310  set_bit(i, get_bit(i) op2 b.get_bit(i)); \
1311  cast(); \
1312  SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
1313  return *this; \
1314 }
1315 
1316 DEFN_ASN_OP_T(&=, &&, sc_ufix)
1317 DEFN_ASN_OP_T(&=, &&, sc_ufix_fast)
1318 DEFN_ASN_OP_T(|=, ||, sc_ufix)
1319 DEFN_ASN_OP_T(|=, ||, sc_ufix_fast)
1320 DEFN_ASN_OP_T(^=, !=, sc_ufix)
1321 DEFN_ASN_OP_T(^=, !=, sc_ufix_fast)
1322 
1323 #undef DEFN_ASN_OP_T
1324 
1325 // auto-increment and auto-decrement
1326 inline const sc_fxval_fast
1327 sc_ufix_fast::operator ++ (int)
1328 {
1329  return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
1330 }
1331 
1332 inline const sc_fxval_fast
1333 sc_ufix_fast::operator -- (int)
1334 {
1335  return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
1336 }
1337 
1338 inline sc_ufix_fast &
1339 sc_ufix_fast::operator ++ ()
1340 {
1341  sc_fxnum_fast::operator ++ ();
1342  return *this;
1343 }
1344 
1345 inline sc_ufix_fast &
1346 sc_ufix_fast::operator -- ()
1347 {
1348  sc_fxnum_fast::operator -- ();
1349  return *this;
1350 }
1351 
1352 } // namespace sc_dt
1353 
1354 #endif // __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
sc_fxnum.hh
DECL_ASN_OP
#define DECL_ASN_OP(op)
Definition: sc_ufix.hh:393
sc_dt::sc_ufix::sc_ufix
sc_ufix(sc_fxnum_observer *=0)
Definition: sc_ufix.hh:447
sc_dt::sc_ufix::b_xor
friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix &)
sc_dt::sc_ufix_fast
Definition: sc_ufix.hh:269
DECL_ASN_OP_T
#define DECL_ASN_OP_T(op, tp)
Definition: sc_ufix.hh:383
sc_dt::sc_fxnum::sc_fxval
friend class sc_fxval
Definition: sc_fxnum.hh:485
sc_dt::sc_ufix_fast::operator--
sc_ufix_fast & operator--()
Definition: sc_ufix.hh:1377
sc_dt
Definition: sc_bit.cc:67
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_dt::sc_fxnum::set_bit
bool set_bit(int, bool)
Definition: sc_fxnum.hh:3094
sc_dt::sc_fxnum_fast::sc_fxnum_fast
sc_fxnum_fast()
sc_dt::sc_ufix_fast::operator~
const sc_ufix_fast operator~() const
Definition: sc_ufix.hh:1215
sc_dt::sc_ufix::operator=
sc_ufix & operator=(const sc_ufix &)
Definition: sc_ufix.hh:813
sc_dt::sc_fxnum_fast
Definition: sc_fxnum.hh:844
sc_dt::sc_o_mode
sc_o_mode
Definition: sc_fxdefs.hh:117
sc_dt::sc_fxval
Definition: sc_fxval.hh:86
sc_dt::sc_ufix::b_not
friend void b_not(sc_ufix &, const sc_ufix &)
Definition: sc_ufix.hh:742
DECL_CTORS_T_A
#define DECL_CTORS_T_A(tp)
Definition: sc_ufix.hh:320
sc_dt::sc_int_base
Definition: sc_int_base.hh:494
sc_dt::sc_ufix::operator++
sc_ufix & operator++()
Definition: sc_ufix.hh:901
sc_dt::sc_fxnum::iwl
int iwl() const
Definition: sc_fxnum.hh:3043
sc_dt::sc_fxnum_observer
Definition: sc_fxnum_observer.hh:141
sc_dt::sc_signed
Definition: sc_signed.hh:984
sc_dt::sc_ufix::operator~
const sc_ufix operator~() const
Definition: sc_ufix.hh:729
sc_dt::sc_ufix_fast::b_not
friend void b_not(sc_ufix_fast &, const sc_ufix_fast &)
Definition: sc_ufix.hh:1228
DEFN_ASN_OP
#define DEFN_ASN_OP(op)
Definition: sc_ufix.hh:1305
sc_dt::sc_fxtype_params
Definition: sc_fxtype_params.hh:101
DEFN_BIN_OP_T
#define DEFN_BIN_OP_T(op, op2, tp1, tp2)
Definition: sc_ufix.hh:1239
sc_dt::sc_ufix_fast::operator&
const friend sc_ufix_fast operator&(const sc_ufix_fast &, const sc_ufix_fast &)
sc_dt::b_and
const sc_bit b_and(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.hh:359
sc_dt::sc_ufix::b_and
friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix &)
sc_dt::sc_ufix_fast::operator^
const friend sc_ufix_fast operator^(const sc_ufix_fast &, const sc_ufix_fast &)
sc_dt::sc_fxnum::operator--
sc_fxnum & operator--()
Definition: sc_fxnum.hh:2812
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
SC_FXNUM_OBSERVER_WRITE_
#define SC_FXNUM_OBSERVER_WRITE_(object)
Definition: sc_fxnum_observer.hh:123
sc_dt::sc_fxnum_fast_observer
Definition: sc_fxnum_observer.hh:163
sc_dt::sc_ufix_fast::b_or
friend void b_or(sc_ufix_fast &, const sc_ufix_fast &, const sc_ufix_fast &)
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_dt::sc_q_mode
sc_q_mode
Definition: sc_fxdefs.hh:91
sc_dt::sc_ufix_fast::sc_ufix_fast
sc_ufix_fast(sc_fxnum_fast_observer *=0)
Definition: sc_ufix.hh:923
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_dt::sc_ufix::operator|
const friend sc_ufix operator|(const sc_ufix &, const sc_ufix &)
SC_FXNUM_OBSERVER_READ_
#define SC_FXNUM_OBSERVER_READ_(object)
Definition: sc_fxnum_observer.hh:122
sc_ufix
#define sc_ufix
Definition: fx_precision_double.h:66
sc_dt::sc_ufix::b_or
friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix &)
sc_dt::sc_fxnum::get_bit
bool get_bit(int) const
Definition: sc_fxnum.hh:3087
sc_dt::sc_fxcast_switch
Definition: sc_fxcast_switch.hh:102
sc_dt::sc_ufix_fast::b_and
friend void b_and(sc_ufix_fast &, const sc_ufix_fast &, const sc_ufix_fast &)
sc_dt::sc_ufix::operator--
sc_ufix & operator--()
Definition: sc_ufix.hh:908
sc_dt::int64
int64_t int64
Definition: sc_nbdefs.hh:205
SC_FXNUM_FAST_OBSERVER_READ_
#define SC_FXNUM_FAST_OBSERVER_READ_(object)
Definition: sc_fxnum_observer.hh:128
DEFN_CTORS_T_B
#define DEFN_CTORS_T_B(tp)
Definition: sc_ufix.hh:1098
sc_dt::sc_fxnum::operator++
sc_fxnum & operator++()
Definition: sc_fxnum.hh:2805
sc_dt::sc_ufix
Definition: sc_ufix.hh:100
sc_dt::b_not
void b_not(sc_ufix_fast &c, const sc_ufix_fast &a)
Definition: sc_ufix.hh:1228
sc_dt::sc_ufix::operator&
const friend sc_ufix operator&(const sc_ufix &, const sc_ufix &)
sc_dt::sc_uint_base
Definition: sc_uint_base.hh:465
sc_dt::sc_fxnum::wl
int wl() const
Definition: sc_fxnum.hh:3037
SC_FXNUM_FAST_OBSERVER_WRITE_
#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
Definition: sc_fxnum_observer.hh:129
sc_dt::b_or
const sc_bit b_or(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.hh:360
sc_fxval
#define sc_fxval
Definition: fx_precision_double.h:65
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_dt::sc_ufix_fast::operator++
sc_ufix_fast & operator++()
Definition: sc_ufix.hh:1370
sc_dt::operator~
const sc_bit operator~(const sc_bit &a)
Definition: sc_bit.hh:326
ArmISA::c
Bitfield< 29 > c
Definition: miscregs_types.hh:50
sc_dt::sc_ufix_fast::operator=
sc_ufix_fast & operator=(const sc_ufix_fast &)
Definition: sc_ufix.hh:1283
sc_dt::sc_ufix_fast::operator|
const friend sc_ufix_fast operator|(const sc_ufix_fast &, const sc_ufix_fast &)
sc_dt::b_xor
const sc_bit b_xor(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.hh:361
sc_dt::sc_ufix_fast::b_xor
friend void b_xor(sc_ufix_fast &, const sc_ufix_fast &, const sc_ufix_fast &)
DEFN_ASN_OP_T
#define DEFN_ASN_OP_T(op, tp)
Definition: sc_ufix.hh:1333
sc_dt::sc_ufix::operator^
const friend sc_ufix operator^(const sc_ufix &, const sc_ufix &)
sc_dt::sc_fxnum_fast::sc_fxval_fast
friend class sc_fxval_fast
Definition: sc_fxnum.hh:846
DEFN_CTORS_T_A
#define DEFN_CTORS_T_A(tp)
Definition: sc_ufix.hh:1008
DECL_CTORS_T_B
#define DECL_CTORS_T_B(tp)
Definition: sc_ufix.hh:324
DEFN_BIN_FNC_T
#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2)
Definition: sc_ufix.hh:1262
sc_dt::SC_US_
@ SC_US_
Definition: sc_fxdefs.hh:73

Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17