sc_fixed.h revision 12027
12155SN/A/*****************************************************************************
22155SN/A
32155SN/A  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
42155SN/A  more contributor license agreements.  See the NOTICE file distributed
52155SN/A  with this work for additional information regarding copyright ownership.
62155SN/A  Accellera licenses this file to you under the Apache License, Version 2.0
72155SN/A  (the "License"); you may not use this file except in compliance with the
82155SN/A  License.  You may obtain a copy of the License at
92155SN/A
102155SN/A    http://www.apache.org/licenses/LICENSE-2.0
112155SN/A
122155SN/A  Unless required by applicable law or agreed to in writing, software
132155SN/A  distributed under the License is distributed on an "AS IS" BASIS,
142155SN/A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152155SN/A  implied.  See the License for the specific language governing
162155SN/A  permissions and limitations under the License.
172155SN/A
182155SN/A *****************************************************************************/
192155SN/A
202155SN/A/*****************************************************************************
212155SN/A
222155SN/A  sc_fixed.h -
232155SN/A
242155SN/A  Original Author: Martin Janssen, Synopsys, Inc.
252155SN/A
262155SN/A *****************************************************************************/
272155SN/A
282665Ssaidi@eecs.umich.edu/*****************************************************************************
292665Ssaidi@eecs.umich.edu
302155SN/A  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
314202Sbinkertn@umich.edu  changes you are making here.
322155SN/A
339850Sandreas.hansson@arm.com      Name, Affiliation, Date:
349850Sandreas.hansson@arm.com  Description of Modification:
359850Sandreas.hansson@arm.com
367768SAli.Saidi@ARM.com *****************************************************************************/
377768SAli.Saidi@ARM.com
382178SN/A// $Log: sc_fixed.h,v $
392178SN/A// Revision 1.2  2011/01/19 18:57:40  acg
402178SN/A//  Andy Goodrich: changes for IEEE_1666_2011.
412178SN/A//
422178SN/A// Revision 1.1.1.1  2006/12/15 20:20:04  acg
432178SN/A// SystemC 2.3
442178SN/A//
452178SN/A// Revision 1.3  2006/01/13 18:53:57  acg
462178SN/A// Andy Goodrich: added $Log command so that CVS comments are reproduced in
472178SN/A// the source.
482178SN/A//
492155SN/A
505865Sksewell@umich.edu#ifndef SC_FIXED_H
516181Sksewell@umich.edu#define SC_FIXED_H
526181Sksewell@umich.edu
535865Sksewell@umich.edu
543918Ssaidi@eecs.umich.edu#include "sysc/datatypes/fx/sc_fix.h"
555865Sksewell@umich.edu
562623SN/A
573918Ssaidi@eecs.umich.edunamespace sc_dt
582155SN/A{
592155SN/A
602292SN/A// classes defined in this module
616181Sksewell@umich.edutemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> class sc_fixed;
626181Sksewell@umich.edutemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> class sc_fixed_fast;
633918Ssaidi@eecs.umich.edu
642292SN/A
652292SN/A// ----------------------------------------------------------------------------
662292SN/A//  TEMPLATE CLASS : sc_fixed
673918Ssaidi@eecs.umich.edu//
682292SN/A//  "Constrained" signed fixed-point class; arbitrary precision.
692292SN/A// ----------------------------------------------------------------------------
702766Sktlim@umich.edu
712766Sktlim@umich.edutemplate <int W, int I,
722766Sktlim@umich.edu	  sc_q_mode Q = SC_DEFAULT_Q_MODE_,
732921Sktlim@umich.edu	  sc_o_mode O = SC_DEFAULT_O_MODE_, int N = SC_DEFAULT_N_BITS_>
748887Sgeoffrey.blake@arm.comclass sc_fixed : public sc_fix
758887Sgeoffrey.blake@arm.com{
762766Sktlim@umich.edu
774762Snate@binkert.orgpublic:
782155SN/A
792155SN/A    // constructors
802155SN/A
812155SN/A    explicit sc_fixed( sc_fxnum_observer* = 0 );
822155SN/A    explicit sc_fixed( const sc_fxcast_switch&, sc_fxnum_observer* = 0 );
832155SN/A
842766Sktlim@umich.edu#define DECL_CTORS_T_A(tp)                                                    \
852155SN/A             sc_fixed( tp, sc_fxnum_observer* = 0 );                          \
865865Sksewell@umich.edu             sc_fixed( tp, const sc_fxcast_switch&, sc_fxnum_observer* = 0 );
872155SN/A
882155SN/A#define DECL_CTORS_T_B(tp)                                                    \
892155SN/A    explicit sc_fixed( tp, sc_fxnum_observer* = 0 );                          \
902155SN/A             sc_fixed( tp, const sc_fxcast_switch&, sc_fxnum_observer* = 0 );
912178SN/A
922178SN/A    DECL_CTORS_T_A(int)
937756SAli.Saidi@ARM.com    DECL_CTORS_T_A(unsigned int)
942766Sktlim@umich.edu    DECL_CTORS_T_A(long)
952178SN/A    DECL_CTORS_T_A(unsigned long)
962178SN/A    DECL_CTORS_T_A(float)
976994Snate@binkert.org    DECL_CTORS_T_A(double)
982178SN/A    DECL_CTORS_T_A(const char*)
992766Sktlim@umich.edu    DECL_CTORS_T_A(const sc_fxval&)
1002766Sktlim@umich.edu    DECL_CTORS_T_A(const sc_fxval_fast&)
1012788Sktlim@umich.edu    DECL_CTORS_T_A(const sc_fxnum&)
1022178SN/A    DECL_CTORS_T_A(const sc_fxnum_fast&)
1034486Sbinkertn@umich.edu#ifndef SC_FX_EXCLUDE_OTHER
1044486Sbinkertn@umich.edu    DECL_CTORS_T_B(int64)
1054776Sgblack@eecs.umich.edu    DECL_CTORS_T_B(uint64)
1064776Sgblack@eecs.umich.edu    DECL_CTORS_T_B(const sc_int_base&)
1078739Sgblack@eecs.umich.edu    DECL_CTORS_T_B(const sc_uint_base&)
1086365Sgblack@eecs.umich.edu    DECL_CTORS_T_B(const sc_signed&)
1094486Sbinkertn@umich.edu    DECL_CTORS_T_B(const sc_unsigned&)
1104202Sbinkertn@umich.edu#endif
1114202Sbinkertn@umich.edu
1124202Sbinkertn@umich.edu#undef DECL_CTORS_T_A
1134202Sbinkertn@umich.edu#undef DECL_CTORS_T_B
1144202Sbinkertn@umich.edu
1154776Sgblack@eecs.umich.edu    // copy constructor
1168739Sgblack@eecs.umich.edu
1176365Sgblack@eecs.umich.edu    sc_fixed( const sc_fixed<W,I,Q,O,N>& );
1184202Sbinkertn@umich.edu
1198777Sgblack@eecs.umich.edu
1204202Sbinkertn@umich.edu    // assignment operators
1214202Sbinkertn@umich.edu
1224202Sbinkertn@umich.edu    sc_fixed& operator = ( const sc_fixed<W,I,Q,O,N>& );
1235217Ssaidi@eecs.umich.edu
1244202Sbinkertn@umich.edu#define DECL_ASN_OP_T(op,tp)                                                  \
1252155SN/A    sc_fixed& operator op ( tp );
1268793Sgblack@eecs.umich.edu
1278793Sgblack@eecs.umich.edu#ifndef SC_FX_EXCLUDE_OTHER
1288793Sgblack@eecs.umich.edu#define DECL_ASN_OP_OTHER(op)                                                 \
1294776Sgblack@eecs.umich.edu    DECL_ASN_OP_T(op,int64)                                                   \
1308887Sgeoffrey.blake@arm.com    DECL_ASN_OP_T(op,uint64)                                                  \
1318887Sgeoffrey.blake@arm.com    DECL_ASN_OP_T(op,const sc_int_base&)                                      \
1329340SAndreas.Sandberg@arm.com    DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
1338887Sgeoffrey.blake@arm.com    DECL_ASN_OP_T(op,const sc_signed&)                                        \
1345192Ssaidi@eecs.umich.edu    DECL_ASN_OP_T(op,const sc_unsigned&)
1358335Snate@binkert.org#else
1368335Snate@binkert.org#define DECL_ASN_OP_OTHER(op)
1378335Snate@binkert.org#endif
1388335Snate@binkert.org
1398335Snate@binkert.org#define DECL_ASN_OP(op)                                                       \
1409534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,int)                                                     \
1419534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,unsigned int)                                            \
1429534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,long)                                                    \
1438335Snate@binkert.org    DECL_ASN_OP_T(op,unsigned long)                                           \
1449534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,float)                                                  \
1459534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,double)                                                  \
1468335Snate@binkert.org    DECL_ASN_OP_T(op,const char*)                                             \
1479534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,const sc_fxval&)                                         \
1489534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
1499534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
1509534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
1519534SAndreas.Sandberg@ARM.com    DECL_ASN_OP_OTHER(op)
1529534SAndreas.Sandberg@ARM.com
1539534SAndreas.Sandberg@ARM.com    DECL_ASN_OP(=)
1549534SAndreas.Sandberg@ARM.com
1559534SAndreas.Sandberg@ARM.com    DECL_ASN_OP(*=)
1569534SAndreas.Sandberg@ARM.com    DECL_ASN_OP(/=)
1578335Snate@binkert.org    DECL_ASN_OP(+=)
1588335Snate@binkert.org    DECL_ASN_OP(-=)
1598471SGiacomo.Gabrielli@arm.com
1608335Snate@binkert.org    DECL_ASN_OP_T(<<=,int)
1618335Snate@binkert.org    DECL_ASN_OP_T(>>=,int)
1625192Ssaidi@eecs.umich.edu
1638232Snate@binkert.org    DECL_ASN_OP_T(&=,const sc_fix&)
1648232Snate@binkert.org    DECL_ASN_OP_T(&=,const sc_fix_fast&)
1658232Snate@binkert.org    DECL_ASN_OP_T(|=,const sc_fix&)
1668300Schander.sudanthi@arm.com    DECL_ASN_OP_T(|=,const sc_fix_fast&)
1678300Schander.sudanthi@arm.com    DECL_ASN_OP_T(^=,const sc_fix&)
1685192Ssaidi@eecs.umich.edu    DECL_ASN_OP_T(^=,const sc_fix_fast&)
1698300Schander.sudanthi@arm.com
1708300Schander.sudanthi@arm.com#undef DECL_ASN_OP_T
1716036Sksewell@umich.edu#undef DECL_ASN_OP_OTHER
1728300Schander.sudanthi@arm.com#undef DECL_ASN_OP
1738300Schander.sudanthi@arm.com
174
175    // auto-increment and auto-decrement
176
177    const sc_fxval operator ++ ( int );
178    const sc_fxval operator -- ( int );
179
180    sc_fixed& operator ++ ();
181    sc_fixed& operator -- ();
182
183};
184
185
186// ----------------------------------------------------------------------------
187//  TEMPLATE CLASS : sc_fixed_fast
188//
189//  "Constrained" signed fixed-point class; limited precision.
190// ----------------------------------------------------------------------------
191
192template <int W, int I,
193	  sc_q_mode Q = SC_DEFAULT_Q_MODE_,
194	  sc_o_mode O = SC_DEFAULT_O_MODE_, int N = SC_DEFAULT_N_BITS_>
195class sc_fixed_fast : public sc_fix_fast
196{
197
198public:
199
200    // constructors
201
202    explicit sc_fixed_fast( sc_fxnum_fast_observer* = 0 );
203    explicit sc_fixed_fast( const sc_fxcast_switch&,
204			    sc_fxnum_fast_observer* = 0 );
205
206#define DECL_CTORS_T_A(tp)                                                    \
207             sc_fixed_fast( tp, sc_fxnum_fast_observer* = 0 );                \
208             sc_fixed_fast( tp, const sc_fxcast_switch&,                      \
209                            sc_fxnum_fast_observer* = 0 );
210
211#define DECL_CTORS_T_B(tp)                                                    \
212    explicit sc_fixed_fast( tp, sc_fxnum_fast_observer* = 0 );                \
213             sc_fixed_fast( tp, const sc_fxcast_switch&,                      \
214                            sc_fxnum_fast_observer* = 0 );
215
216    DECL_CTORS_T_A(int)
217    DECL_CTORS_T_A(unsigned int)
218    DECL_CTORS_T_A(long)
219    DECL_CTORS_T_A(unsigned long)
220    DECL_CTORS_T_A(float)
221    DECL_CTORS_T_A(double)
222    DECL_CTORS_T_A(const char*)
223    DECL_CTORS_T_A(const sc_fxval&)
224    DECL_CTORS_T_A(const sc_fxval_fast&)
225    DECL_CTORS_T_A(const sc_fxnum&)
226    DECL_CTORS_T_A(const sc_fxnum_fast&)
227#ifndef SC_FX_EXCLUDE_OTHER
228    DECL_CTORS_T_B(int64)
229    DECL_CTORS_T_B(uint64)
230    DECL_CTORS_T_B(const sc_int_base&)
231    DECL_CTORS_T_B(const sc_uint_base&)
232    DECL_CTORS_T_B(const sc_signed&)
233    DECL_CTORS_T_B(const sc_unsigned&)
234#endif
235
236#undef DECL_CTORS_T_A
237#undef DECL_CTORS_T_B
238
239    // copy constructor
240
241    sc_fixed_fast( const sc_fixed_fast<W,I,Q,O,N>& );
242
243
244    // assignment operators
245
246    sc_fixed_fast& operator = ( const sc_fixed_fast<W,I,Q,O,N>& );
247
248#define DECL_ASN_OP_T(op,tp)                                                  \
249    sc_fixed_fast& operator op ( tp );
250
251#ifndef SC_FX_EXCLUDE_OTHER
252#define DECL_ASN_OP_OTHER(op)                                                 \
253    DECL_ASN_OP_T(op,int64)                                                   \
254    DECL_ASN_OP_T(op,uint64)                                                  \
255    DECL_ASN_OP_T(op,const sc_int_base&)                                      \
256    DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
257    DECL_ASN_OP_T(op,const sc_signed&)                                        \
258    DECL_ASN_OP_T(op,const sc_unsigned&)
259#else
260#define DECL_ASN_OP_OTHER(op)
261#endif
262
263#define DECL_ASN_OP(op)                                                       \
264    DECL_ASN_OP_T(op,int)                                                     \
265    DECL_ASN_OP_T(op,unsigned int)                                            \
266    DECL_ASN_OP_T(op,long)                                                    \
267    DECL_ASN_OP_T(op,unsigned long)                                           \
268    DECL_ASN_OP_T(op,float)                                                  \
269    DECL_ASN_OP_T(op,double)                                                  \
270    DECL_ASN_OP_T(op,const char*)                                             \
271    DECL_ASN_OP_T(op,const sc_fxval&)                                         \
272    DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
273    DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
274    DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
275    DECL_ASN_OP_OTHER(op)
276
277    DECL_ASN_OP(=)
278
279    DECL_ASN_OP(*=)
280    DECL_ASN_OP(/=)
281    DECL_ASN_OP(+=)
282    DECL_ASN_OP(-=)
283
284    DECL_ASN_OP_T(<<=,int)
285    DECL_ASN_OP_T(>>=,int)
286
287    DECL_ASN_OP_T(&=,const sc_fix&)
288    DECL_ASN_OP_T(&=,const sc_fix_fast&)
289    DECL_ASN_OP_T(|=,const sc_fix&)
290    DECL_ASN_OP_T(|=,const sc_fix_fast&)
291    DECL_ASN_OP_T(^=,const sc_fix&)
292    DECL_ASN_OP_T(^=,const sc_fix_fast&)
293
294#undef DECL_ASN_OP_T
295#undef DECL_ASN_OP_OTHER
296#undef DECL_ASN_OP
297
298
299    // auto-increment and auto-decrement
300
301    const sc_fxval_fast operator ++ ( int );
302    const sc_fxval_fast operator -- ( int );
303
304    sc_fixed_fast& operator ++ ();
305    sc_fixed_fast& operator -- ();
306
307};
308
309
310// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
311
312// ----------------------------------------------------------------------------
313//  TEMPLATE CLASS : sc_fixed
314//
315//  "Constrained" signed fixed-point class; arbitrary precision.
316// ----------------------------------------------------------------------------
317
318template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
319inline
320sc_fixed<W,I,Q,O,N>::sc_fixed( sc_fxnum_observer* observer_ )
321: sc_fix( W, I, Q, O, N, observer_ )
322{}
323
324template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
325inline
326sc_fixed<W,I,Q,O,N>::sc_fixed( const sc_fxcast_switch& cast_sw,
327			       sc_fxnum_observer* observer_ )
328: sc_fix( W, I, Q, O, N, cast_sw, observer_ )
329{}
330
331#define DEFN_CTORS_T(tp)                                                      \
332template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
333inline                                                                        \
334sc_fixed<W,I,Q,O,N>::sc_fixed( tp a,                                          \
335			       sc_fxnum_observer* observer_ )                 \
336: sc_fix( a, W, I, Q, O, N, observer_ )                                       \
337{}                                                                            \
338                                                                              \
339template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
340inline                                                                        \
341sc_fixed<W,I,Q,O,N>::sc_fixed( tp a,                                          \
342			       const sc_fxcast_switch& cast_sw,               \
343			       sc_fxnum_observer* observer_ )                 \
344: sc_fix( a, W, I, Q, O, N, cast_sw, observer_ )                              \
345{}
346
347DEFN_CTORS_T(int)
348DEFN_CTORS_T(unsigned int)
349DEFN_CTORS_T(long)
350DEFN_CTORS_T(unsigned long)
351DEFN_CTORS_T(float)
352DEFN_CTORS_T(double)
353DEFN_CTORS_T(const char*)
354DEFN_CTORS_T(const sc_fxval&)
355DEFN_CTORS_T(const sc_fxval_fast&)
356DEFN_CTORS_T(const sc_fxnum&)
357DEFN_CTORS_T(const sc_fxnum_fast&)
358#ifndef SC_FX_EXCLUDE_OTHER
359DEFN_CTORS_T(int64)
360DEFN_CTORS_T(uint64)
361DEFN_CTORS_T(const sc_int_base&)
362DEFN_CTORS_T(const sc_uint_base&)
363DEFN_CTORS_T(const sc_signed&)
364DEFN_CTORS_T(const sc_unsigned&)
365#endif
366
367#undef DEFN_CTORS_T
368
369// copy constructor
370
371template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
372inline
373sc_fixed<W,I,Q,O,N>::sc_fixed( const sc_fixed<W,I,Q,O,N>& a )
374: sc_fix( a, W, I, Q, O, N )
375{}
376
377
378// assignment operators
379
380template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
381inline
382sc_fixed<W,I,Q,O,N>&
383sc_fixed<W,I,Q,O,N>::operator = ( const sc_fixed<W,I,Q,O,N>& a )
384{
385    sc_fix::operator = ( a );
386    return *this;
387}
388
389#define DEFN_ASN_OP_T(op,tp)                                                  \
390template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
391inline                                                                        \
392sc_fixed<W,I,Q,O,N>&                                                          \
393sc_fixed<W,I,Q,O,N>::operator op ( tp a )                                     \
394{                                                                             \
395    sc_fix::operator op ( a );                                                \
396    return *this;                                                             \
397}
398
399#ifndef SC_FX_EXCLUDE_OTHER
400#define DEFN_ASN_OP_OTHER(op)                                                 \
401DEFN_ASN_OP_T(op,int64)                                                       \
402DEFN_ASN_OP_T(op,uint64)                                                      \
403DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
404DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
405DEFN_ASN_OP_T(op,const sc_signed&)                                            \
406DEFN_ASN_OP_T(op,const sc_unsigned&)
407#else
408#define DEFN_ASN_OP_OTHER(op)
409#endif
410
411#define DEFN_ASN_OP(op)                                                       \
412DEFN_ASN_OP_T(op,int)                                                         \
413DEFN_ASN_OP_T(op,unsigned int)                                                \
414DEFN_ASN_OP_T(op,long)                                                        \
415DEFN_ASN_OP_T(op,unsigned long)                                               \
416DEFN_ASN_OP_T(op,float)                                                      \
417DEFN_ASN_OP_T(op,double)                                                      \
418DEFN_ASN_OP_T(op,const char*)                                                 \
419DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
420DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
421DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
422DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
423DEFN_ASN_OP_OTHER(op)
424
425DEFN_ASN_OP(=)
426
427DEFN_ASN_OP(*=)
428DEFN_ASN_OP(/=)
429DEFN_ASN_OP(+=)
430DEFN_ASN_OP(-=)
431
432DEFN_ASN_OP_T(<<=,int)
433DEFN_ASN_OP_T(>>=,int)
434
435DEFN_ASN_OP_T(&=,const sc_fix&)
436DEFN_ASN_OP_T(&=,const sc_fix_fast&)
437DEFN_ASN_OP_T(|=,const sc_fix&)
438DEFN_ASN_OP_T(|=,const sc_fix_fast&)
439DEFN_ASN_OP_T(^=,const sc_fix&)
440DEFN_ASN_OP_T(^=,const sc_fix_fast&)
441
442#undef DEFN_ASN_OP_T
443#undef DEFN_ASN_OP_OTHER
444#undef DEFN_ASN_OP
445
446
447// auto-increment and auto-decrement
448
449template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
450inline
451const sc_fxval
452sc_fixed<W,I,Q,O,N>::operator ++ ( int )
453{
454    return sc_fxval( sc_fix::operator ++ ( 0 ) );
455}
456
457template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
458inline
459const sc_fxval
460sc_fixed<W,I,Q,O,N>::operator -- ( int )
461{
462    return sc_fxval( sc_fix::operator -- ( 0 ) );
463}
464
465template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
466inline
467sc_fixed<W,I,Q,O,N>&
468sc_fixed<W,I,Q,O,N>::operator ++ ()
469{
470    sc_fix::operator ++ ();
471    return *this;
472}
473
474template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
475inline
476sc_fixed<W,I,Q,O,N>&
477sc_fixed<W,I,Q,O,N>::operator -- ()
478{
479    sc_fix::operator -- ();
480    return *this;
481}
482
483
484// ----------------------------------------------------------------------------
485//  TEMPLATE CLASS : sc_fixed_fast
486//
487//  "Constrained" signed fixed-point class; limited precision.
488// ----------------------------------------------------------------------------
489
490template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
491inline
492sc_fixed_fast<W,I,Q,O,N>::sc_fixed_fast( sc_fxnum_fast_observer* observer_ )
493: sc_fix_fast( W, I, Q, O, N, observer_ )
494{}
495
496template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
497inline
498sc_fixed_fast<W,I,Q,O,N>::sc_fixed_fast( const sc_fxcast_switch& cast_sw,
499					 sc_fxnum_fast_observer* observer_ )
500: sc_fix_fast( W, I, Q, O, N, cast_sw, observer_ )
501{}
502
503#define DEFN_CTORS_T(tp)                                                      \
504template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
505inline                                                                        \
506sc_fixed_fast<W,I,Q,O,N>::sc_fixed_fast( tp a,                                \
507					 sc_fxnum_fast_observer* observer_ )  \
508: sc_fix_fast( a, W, I, Q, O, N, observer_ )                                  \
509{}                                                                            \
510                                                                              \
511template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
512inline                                                                        \
513sc_fixed_fast<W,I,Q,O,N>::sc_fixed_fast( tp a,                                \
514					 const sc_fxcast_switch& cast_sw,     \
515					 sc_fxnum_fast_observer* observer_ )  \
516: sc_fix_fast( a, W, I, Q, O, N, cast_sw, observer_ )                         \
517{}
518
519DEFN_CTORS_T(int)
520DEFN_CTORS_T(unsigned int)
521DEFN_CTORS_T(long)
522DEFN_CTORS_T(unsigned long)
523DEFN_CTORS_T(float)
524DEFN_CTORS_T(double)
525DEFN_CTORS_T(const char*)
526DEFN_CTORS_T(const sc_fxval&)
527DEFN_CTORS_T(const sc_fxval_fast&)
528DEFN_CTORS_T(const sc_fxnum&)
529DEFN_CTORS_T(const sc_fxnum_fast&)
530#ifndef SC_FX_EXCLUDE_OTHER
531DEFN_CTORS_T(int64)
532DEFN_CTORS_T(uint64)
533DEFN_CTORS_T(const sc_int_base&)
534DEFN_CTORS_T(const sc_uint_base&)
535DEFN_CTORS_T(const sc_signed&)
536DEFN_CTORS_T(const sc_unsigned&)
537#endif
538
539#undef DEFN_CTORS_T
540
541// copy constructor
542
543template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
544inline
545sc_fixed_fast<W,I,Q,O,N>::sc_fixed_fast( const sc_fixed_fast<W,I,Q,O,N>& a )
546: sc_fix_fast( a, W, I, Q, O, N )
547{}
548
549
550// assignment operators
551
552template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
553inline
554sc_fixed_fast<W,I,Q,O,N>&
555sc_fixed_fast<W,I,Q,O,N>::operator = ( const sc_fixed_fast<W,I,Q,O,N>& a )
556{
557    sc_fix_fast::operator = ( a );
558    return *this;
559}
560
561#define DEFN_ASN_OP_T(op,tp)                                                  \
562template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>                       \
563inline                                                                        \
564sc_fixed_fast<W,I,Q,O,N>&                                                     \
565sc_fixed_fast<W,I,Q,O,N>::operator op ( tp a )                                \
566{                                                                             \
567    sc_fix_fast::operator op ( a );                                           \
568    return *this;                                                             \
569}
570
571#ifndef SC_FX_EXCLUDE_OTHER
572#define DEFN_ASN_OP_OTHER(op)                                                 \
573DEFN_ASN_OP_T(op,int64)                                                       \
574DEFN_ASN_OP_T(op,uint64)                                                      \
575DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
576DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
577DEFN_ASN_OP_T(op,const sc_signed&)                                            \
578DEFN_ASN_OP_T(op,const sc_unsigned&)
579#else
580#define DEFN_ASN_OP_OTHER(op)
581#endif
582
583#define DEFN_ASN_OP(op)                                                       \
584DEFN_ASN_OP_T(op,int)                                                         \
585DEFN_ASN_OP_T(op,unsigned int)                                                \
586DEFN_ASN_OP_T(op,long)                                                        \
587DEFN_ASN_OP_T(op,unsigned long)                                               \
588DEFN_ASN_OP_T(op,float)                                                      \
589DEFN_ASN_OP_T(op,double)                                                      \
590DEFN_ASN_OP_T(op,const char*)                                                 \
591DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
592DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
593DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
594DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
595DEFN_ASN_OP_OTHER(op)
596
597DEFN_ASN_OP(=)
598
599DEFN_ASN_OP(*=)
600DEFN_ASN_OP(/=)
601DEFN_ASN_OP(+=)
602DEFN_ASN_OP(-=)
603
604DEFN_ASN_OP_T(<<=,int)
605DEFN_ASN_OP_T(>>=,int)
606
607DEFN_ASN_OP_T(&=,const sc_fix&)
608DEFN_ASN_OP_T(&=,const sc_fix_fast&)
609DEFN_ASN_OP_T(|=,const sc_fix&)
610DEFN_ASN_OP_T(|=,const sc_fix_fast&)
611DEFN_ASN_OP_T(^=,const sc_fix&)
612DEFN_ASN_OP_T(^=,const sc_fix_fast&)
613
614#undef DEFN_ASN_OP_T
615#undef DEFN_ASN_OP_OTHER
616#undef DEFN_ASN_OP
617
618
619// auto-increment and auto-decrement
620
621template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
622inline
623const sc_fxval_fast
624sc_fixed_fast<W,I,Q,O,N>::operator ++ ( int )
625{
626    return sc_fxval_fast( sc_fix_fast::operator ++ ( 0 ) );
627}
628
629template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
630inline
631const sc_fxval_fast
632sc_fixed_fast<W,I,Q,O,N>::operator -- ( int )
633{
634    return sc_fxval_fast( sc_fix_fast::operator -- ( 0 ) );
635}
636
637template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
638inline
639sc_fixed_fast<W,I,Q,O,N>&
640sc_fixed_fast<W,I,Q,O,N>::operator ++ ()
641{
642    sc_fix_fast::operator ++ ();
643    return *this;
644}
645
646template<int W, int I, sc_q_mode Q, sc_o_mode O, int N>
647inline
648sc_fixed_fast<W,I,Q,O,N>&
649sc_fixed_fast<W,I,Q,O,N>::operator -- ()
650{
651    sc_fix_fast::operator -- ();
652    return *this;
653}
654
655} // namespace sc_dt
656
657
658#endif
659
660// Taf!
661