112853Sgabeblack@google.com/*****************************************************************************
212853Sgabeblack@google.com
312853Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412853Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
512853Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
612853Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
712853Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
812853Sgabeblack@google.com  License.  You may obtain a copy of the License at
912853Sgabeblack@google.com
1012853Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1112853Sgabeblack@google.com
1212853Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1312853Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1412853Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512853Sgabeblack@google.com  implied.  See the License for the specific language governing
1612853Sgabeblack@google.com  permissions and limitations under the License.
1712853Sgabeblack@google.com
1812853Sgabeblack@google.com *****************************************************************************/
1912853Sgabeblack@google.com
2012853Sgabeblack@google.com/*****************************************************************************
2112853Sgabeblack@google.com
2212853Sgabeblack@google.com  sc_fix.h -
2312853Sgabeblack@google.com
2412853Sgabeblack@google.com  Original Author: Martin Janssen, Synopsys, Inc.
2512853Sgabeblack@google.com
2612853Sgabeblack@google.com *****************************************************************************/
2712853Sgabeblack@google.com
2812853Sgabeblack@google.com/*****************************************************************************
2912853Sgabeblack@google.com
3012853Sgabeblack@google.com  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
3112853Sgabeblack@google.com  changes you are making here.
3212853Sgabeblack@google.com
3312853Sgabeblack@google.com      Name, Affiliation, Date:
3412853Sgabeblack@google.com  Description of Modification:
3512853Sgabeblack@google.com
3612853Sgabeblack@google.com *****************************************************************************/
3712853Sgabeblack@google.com
3812853Sgabeblack@google.com// $Log: sc_fix.h,v $
3912853Sgabeblack@google.com// Revision 1.2  2011/01/19 18:57:40  acg
4012853Sgabeblack@google.com//  Andy Goodrich: changes for IEEE_1666_2011.
4112853Sgabeblack@google.com//
4212853Sgabeblack@google.com// Revision 1.1.1.1  2006/12/15 20:20:04  acg
4312853Sgabeblack@google.com// SystemC 2.3
4412853Sgabeblack@google.com//
4512853Sgabeblack@google.com// Revision 1.3  2006/01/13 18:53:57  acg
4612853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in
4712853Sgabeblack@google.com// the source.
4812853Sgabeblack@google.com//
4912853Sgabeblack@google.com
5012853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
5112853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
5212853Sgabeblack@google.com
5312853Sgabeblack@google.com#include "sc_fxnum.hh"
5412853Sgabeblack@google.com
5512853Sgabeblack@google.comnamespace sc_dt
5612853Sgabeblack@google.com{
5712853Sgabeblack@google.com
5812853Sgabeblack@google.com// classes defined in this module
5912853Sgabeblack@google.comclass sc_fix;
6012853Sgabeblack@google.comclass sc_fix_fast;
6112853Sgabeblack@google.com
6212853Sgabeblack@google.com
6312853Sgabeblack@google.com// ----------------------------------------------------------------------------
6412853Sgabeblack@google.com//  CLASS : sc_fix
6512853Sgabeblack@google.com//
6612853Sgabeblack@google.com//  "Unconstrained" signed fixed-point class; arbitrary precision.
6712853Sgabeblack@google.com// ----------------------------------------------------------------------------
6812853Sgabeblack@google.com
6912853Sgabeblack@google.comclass sc_fix : public sc_fxnum
7012853Sgabeblack@google.com{
7112853Sgabeblack@google.com  public:
7212853Sgabeblack@google.com    // constructors
7312853Sgabeblack@google.com    explicit sc_fix(sc_fxnum_observer * =0);
7412853Sgabeblack@google.com    sc_fix(int, int, sc_fxnum_observer * =0);
7512853Sgabeblack@google.com    sc_fix(sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
7612853Sgabeblack@google.com    sc_fix(sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
7712853Sgabeblack@google.com    sc_fix(int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
7812853Sgabeblack@google.com    sc_fix(int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
7912853Sgabeblack@google.com    explicit sc_fix(const sc_fxcast_switch &, sc_fxnum_observer * =0);
8012853Sgabeblack@google.com    sc_fix(int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0);
8112853Sgabeblack@google.com    sc_fix(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
8212853Sgabeblack@google.com           sc_fxnum_observer * =0);
8312853Sgabeblack@google.com    sc_fix(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
8412853Sgabeblack@google.com           sc_fxnum_observer * =0);
8512853Sgabeblack@google.com    sc_fix(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
8612853Sgabeblack@google.com           sc_fxnum_observer * =0);
8712853Sgabeblack@google.com    sc_fix(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
8812853Sgabeblack@google.com           sc_fxnum_observer * =0);
8912853Sgabeblack@google.com    explicit sc_fix(const sc_fxtype_params &, sc_fxnum_observer * =0);
9012853Sgabeblack@google.com    sc_fix(const sc_fxtype_params &, const sc_fxcast_switch &,
9112853Sgabeblack@google.com           sc_fxnum_observer * =0);
9212853Sgabeblack@google.com
9312853Sgabeblack@google.com#define DECL_CTORS_T(tp) \
9412853Sgabeblack@google.com    sc_fix(tp, int, int, sc_fxnum_observer * =0); \
9512853Sgabeblack@google.com    sc_fix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
9612853Sgabeblack@google.com    sc_fix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
9712853Sgabeblack@google.com    sc_fix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
9812853Sgabeblack@google.com    sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
9912853Sgabeblack@google.com    sc_fix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
10012853Sgabeblack@google.com    sc_fix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
10112853Sgabeblack@google.com    sc_fix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
10212853Sgabeblack@google.com           sc_fxnum_observer * =0); \
10312853Sgabeblack@google.com    sc_fix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
10412853Sgabeblack@google.com           sc_fxnum_observer * =0); \
10512853Sgabeblack@google.com    sc_fix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
10612853Sgabeblack@google.com           sc_fxnum_observer * =0); \
10712853Sgabeblack@google.com    sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, \
10812853Sgabeblack@google.com           const sc_fxcast_switch &, sc_fxnum_observer * =0); \
10912853Sgabeblack@google.com    sc_fix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
11012853Sgabeblack@google.com    sc_fix(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
11112853Sgabeblack@google.com           sc_fxnum_observer * =0);
11212853Sgabeblack@google.com
11312853Sgabeblack@google.com#define DECL_CTORS_T_A(tp) \
11412853Sgabeblack@google.com    sc_fix(tp, sc_fxnum_observer * =0); \
11512853Sgabeblack@google.com    DECL_CTORS_T(tp)
11612853Sgabeblack@google.com
11712853Sgabeblack@google.com#define DECL_CTORS_T_B(tp) \
11812853Sgabeblack@google.com    explicit sc_fix(tp, sc_fxnum_observer * =0); \
11912853Sgabeblack@google.com    DECL_CTORS_T(tp)
12012853Sgabeblack@google.com
12112853Sgabeblack@google.com    DECL_CTORS_T_A(int)
12212853Sgabeblack@google.com    DECL_CTORS_T_A(unsigned int)
12312853Sgabeblack@google.com    DECL_CTORS_T_A(long)
12412853Sgabeblack@google.com    DECL_CTORS_T_A(unsigned long)
12512853Sgabeblack@google.com    DECL_CTORS_T_A(float)
12612853Sgabeblack@google.com    DECL_CTORS_T_A(double)
12712853Sgabeblack@google.com    DECL_CTORS_T_A(const char *)
12812853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxval &)
12912853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxval_fast &)
13012853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxnum &)
13112853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxnum_fast &)
13212853Sgabeblack@google.com
13312853Sgabeblack@google.com    DECL_CTORS_T_B(int64)
13412853Sgabeblack@google.com    DECL_CTORS_T_B(uint64)
13512853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_int_base &)
13612853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_uint_base &)
13712853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_signed &)
13812853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_unsigned &)
13912853Sgabeblack@google.com
14012853Sgabeblack@google.com#undef DECL_CTORS_T
14112853Sgabeblack@google.com#undef DECL_CTORS_T_A
14212853Sgabeblack@google.com#undef DECL_CTORS_T_B
14312853Sgabeblack@google.com
14412853Sgabeblack@google.com    // copy constructor
14512853Sgabeblack@google.com    sc_fix(const sc_fix &);
14612853Sgabeblack@google.com
14712853Sgabeblack@google.com    // unary bitwise operators
14812853Sgabeblack@google.com    const sc_fix operator ~ () const;
14912853Sgabeblack@google.com
15012853Sgabeblack@google.com    // unary bitwise functions
15112853Sgabeblack@google.com    friend void b_not(sc_fix &, const sc_fix &);
15212853Sgabeblack@google.com
15312853Sgabeblack@google.com    // binary bitwise operators
15412853Sgabeblack@google.com    friend const sc_fix operator & (const sc_fix &, const sc_fix &);
15512853Sgabeblack@google.com    friend const sc_fix operator & (const sc_fix &, const sc_fix_fast &);
15612853Sgabeblack@google.com    friend const sc_fix operator & (const sc_fix_fast &, const sc_fix &);
15712853Sgabeblack@google.com    friend const sc_fix operator | (const sc_fix &, const sc_fix &);
15812853Sgabeblack@google.com    friend const sc_fix operator | (const sc_fix &, const sc_fix_fast &);
15912853Sgabeblack@google.com    friend const sc_fix operator | (const sc_fix_fast &, const sc_fix &);
16012853Sgabeblack@google.com    friend const sc_fix operator ^ (const sc_fix &, const sc_fix &);
16112853Sgabeblack@google.com    friend const sc_fix operator ^ (const sc_fix &, const sc_fix_fast &);
16212853Sgabeblack@google.com    friend const sc_fix operator ^ (const sc_fix_fast&, const sc_fix &);
16312853Sgabeblack@google.com
16412853Sgabeblack@google.com    // binary bitwise functions
16512853Sgabeblack@google.com    friend void b_and(sc_fix &, const sc_fix &, const sc_fix &);
16612853Sgabeblack@google.com    friend void b_and(sc_fix &, const sc_fix &, const sc_fix_fast &);
16712853Sgabeblack@google.com    friend void b_and(sc_fix &, const sc_fix_fast &, const sc_fix &);
16812853Sgabeblack@google.com    friend void b_or(sc_fix &, const sc_fix &, const sc_fix &);
16912853Sgabeblack@google.com    friend void b_or(sc_fix &, const sc_fix &, const sc_fix_fast &);
17012853Sgabeblack@google.com    friend void b_or(sc_fix &, const sc_fix_fast &, const sc_fix &);
17112853Sgabeblack@google.com    friend void b_xor(sc_fix &, const sc_fix &, const sc_fix &);
17212853Sgabeblack@google.com    friend void b_xor(sc_fix &, const sc_fix &, const sc_fix_fast &);
17312853Sgabeblack@google.com    friend void b_xor(sc_fix &, const sc_fix_fast &, const sc_fix &);
17412853Sgabeblack@google.com
17512853Sgabeblack@google.com    // assignment operators
17612853Sgabeblack@google.com    sc_fix &operator = (const sc_fix &);
17712853Sgabeblack@google.com
17812853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) sc_fix &operator op (tp);
17912853Sgabeblack@google.com
18012853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \
18112853Sgabeblack@google.com    DECL_ASN_OP_T(op, int64) \
18212853Sgabeblack@google.com    DECL_ASN_OP_T(op, uint64) \
18312853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_int_base &) \
18412853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_uint_base &) \
18512853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_signed &) \
18612853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_unsigned &)
18712853Sgabeblack@google.com
18812853Sgabeblack@google.com#define DECL_ASN_OP(op) \
18912853Sgabeblack@google.com    DECL_ASN_OP_T(op, int) \
19012853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned int) \
19112853Sgabeblack@google.com    DECL_ASN_OP_T(op, long) \
19212853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned long) \
19312853Sgabeblack@google.com    DECL_ASN_OP_T(op, float) \
19412853Sgabeblack@google.com    DECL_ASN_OP_T(op, double) \
19512853Sgabeblack@google.com    DECL_ASN_OP_T(op, const char *) \
19612853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval &) \
19712853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval_fast &) \
19812853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum &) \
19912853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
20012853Sgabeblack@google.com    DECL_ASN_OP_OTHER(op)
20112853Sgabeblack@google.com
20212853Sgabeblack@google.com    DECL_ASN_OP(=)
20312853Sgabeblack@google.com
20412853Sgabeblack@google.com    DECL_ASN_OP(*=)
20512853Sgabeblack@google.com    DECL_ASN_OP(/=)
20612853Sgabeblack@google.com    DECL_ASN_OP(+=)
20712853Sgabeblack@google.com    DECL_ASN_OP(-=)
20812853Sgabeblack@google.com
20912853Sgabeblack@google.com    DECL_ASN_OP_T(<<=, int)
21012853Sgabeblack@google.com    DECL_ASN_OP_T(>>=, int)
21112853Sgabeblack@google.com
21212853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_fix &)
21312853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_fix_fast &)
21412853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_fix &)
21512853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_fix_fast &)
21612853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_fix &)
21712853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_fix_fast &)
21812853Sgabeblack@google.com
21912853Sgabeblack@google.com#undef DECL_ASN_OP_T
22012853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER
22112853Sgabeblack@google.com#undef DECL_ASN_OP
22212853Sgabeblack@google.com
22312853Sgabeblack@google.com    // auto-increment and auto-decrement
22412853Sgabeblack@google.com    const sc_fxval operator ++ (int);
22512853Sgabeblack@google.com    const sc_fxval operator -- (int);
22612853Sgabeblack@google.com
22712853Sgabeblack@google.com    sc_fix& operator ++ ();
22812853Sgabeblack@google.com    sc_fix& operator -- ();
22912853Sgabeblack@google.com};
23012853Sgabeblack@google.com
23112853Sgabeblack@google.com
23212853Sgabeblack@google.com// ----------------------------------------------------------------------------
23312853Sgabeblack@google.com//  CLASS : sc_fix_fast
23412853Sgabeblack@google.com//
23512853Sgabeblack@google.com//  "Unconstrained" signed fixed-point class; limited precision.
23612853Sgabeblack@google.com// ----------------------------------------------------------------------------
23712853Sgabeblack@google.com
23812853Sgabeblack@google.comclass sc_fix_fast : public sc_fxnum_fast
23912853Sgabeblack@google.com{
24012853Sgabeblack@google.com  public:
24112853Sgabeblack@google.com    // constructors
24212853Sgabeblack@google.com    explicit sc_fix_fast(sc_fxnum_fast_observer * =0);
24312853Sgabeblack@google.com    sc_fix_fast(int, int, sc_fxnum_fast_observer * =0);
24412853Sgabeblack@google.com    sc_fix_fast(sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
24512853Sgabeblack@google.com    sc_fix_fast(sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0);
24612853Sgabeblack@google.com    sc_fix_fast(int, int, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
24712853Sgabeblack@google.com    sc_fix_fast(int, int, sc_q_mode, sc_o_mode, int,
24812853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
24912853Sgabeblack@google.com    explicit sc_fix_fast(const sc_fxcast_switch &,
25012853Sgabeblack@google.com                         sc_fxnum_fast_observer * =0);
25112853Sgabeblack@google.com    sc_fix_fast(int, int, const sc_fxcast_switch &,
25212853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
25312853Sgabeblack@google.com    sc_fix_fast(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
25412853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
25512853Sgabeblack@google.com    sc_fix_fast(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
25612853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
25712853Sgabeblack@google.com    sc_fix_fast(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
25812853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
25912853Sgabeblack@google.com    sc_fix_fast(int, int, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
26012853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
26112853Sgabeblack@google.com    explicit sc_fix_fast(const sc_fxtype_params &,
26212853Sgabeblack@google.com                         sc_fxnum_fast_observer * =0);
26312853Sgabeblack@google.com    sc_fix_fast(const sc_fxtype_params &, const sc_fxcast_switch &,
26412853Sgabeblack@google.com                sc_fxnum_fast_observer * =0);
26512853Sgabeblack@google.com
26612853Sgabeblack@google.com#define DECL_CTORS_T(tp) \
26712853Sgabeblack@google.com    sc_fix_fast(tp, int, int, sc_fxnum_fast_observer * = 0); \
26812853Sgabeblack@google.com    sc_fix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * = 0); \
26912853Sgabeblack@google.com    sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * = 0); \
27012853Sgabeblack@google.com    sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
27112853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
27212853Sgabeblack@google.com    sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
27312853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
27412853Sgabeblack@google.com    sc_fix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
27512853Sgabeblack@google.com    sc_fix_fast(tp, int, int, const sc_fxcast_switch &, \
27612853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
27712853Sgabeblack@google.com    sc_fix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
27812853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
27912853Sgabeblack@google.com    sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
28012853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
28112853Sgabeblack@google.com    sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
28212853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0); \
28312853Sgabeblack@google.com    sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
28412853Sgabeblack@google.com                const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
28512853Sgabeblack@google.com    sc_fix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * = 0); \
28612853Sgabeblack@google.com    sc_fix_fast(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
28712853Sgabeblack@google.com                sc_fxnum_fast_observer * = 0);
28812853Sgabeblack@google.com
28912853Sgabeblack@google.com#define DECL_CTORS_T_A(tp) \
29012853Sgabeblack@google.com    sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
29112853Sgabeblack@google.com    DECL_CTORS_T(tp)
29212853Sgabeblack@google.com
29312853Sgabeblack@google.com#define DECL_CTORS_T_B(tp) \
29412853Sgabeblack@google.com    explicit sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
29512853Sgabeblack@google.com    DECL_CTORS_T(tp)
29612853Sgabeblack@google.com
29712853Sgabeblack@google.com    DECL_CTORS_T_A(int)
29812853Sgabeblack@google.com    DECL_CTORS_T_A(unsigned int)
29912853Sgabeblack@google.com    DECL_CTORS_T_A(long)
30012853Sgabeblack@google.com    DECL_CTORS_T_A(unsigned long)
30112853Sgabeblack@google.com    DECL_CTORS_T_A(float)
30212853Sgabeblack@google.com    DECL_CTORS_T_A(double)
30312853Sgabeblack@google.com    DECL_CTORS_T_A(const char *)
30412853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxval &)
30512853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxval_fast &)
30612853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxnum &)
30712853Sgabeblack@google.com    DECL_CTORS_T_A(const sc_fxnum_fast &)
30812853Sgabeblack@google.com
30912853Sgabeblack@google.com    DECL_CTORS_T_B(int64)
31012853Sgabeblack@google.com    DECL_CTORS_T_B(uint64)
31112853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_int_base &)
31212853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_uint_base &)
31312853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_signed &)
31412853Sgabeblack@google.com    DECL_CTORS_T_B(const sc_unsigned &)
31512853Sgabeblack@google.com
31612853Sgabeblack@google.com#undef DECL_CTORS_T
31712853Sgabeblack@google.com#undef DECL_CTORS_T_A
31812853Sgabeblack@google.com#undef DECL_CTORS_T_B
31912853Sgabeblack@google.com
32012853Sgabeblack@google.com    // copy constructor
32112853Sgabeblack@google.com    sc_fix_fast(const sc_fix_fast &);
32212853Sgabeblack@google.com
32312853Sgabeblack@google.com    // unary bitwise operators
32412853Sgabeblack@google.com    const sc_fix_fast operator ~ () const;
32512853Sgabeblack@google.com
32612853Sgabeblack@google.com    // unary bitwise functions
32712853Sgabeblack@google.com    friend void b_not(sc_fix_fast &, const sc_fix_fast &);
32812853Sgabeblack@google.com
32912853Sgabeblack@google.com    // binary bitwise operators
33012853Sgabeblack@google.com    friend const sc_fix_fast operator & (
33112853Sgabeblack@google.com            const sc_fix_fast &, const sc_fix_fast &);
33212853Sgabeblack@google.com    friend const sc_fix_fast operator ^ (
33312853Sgabeblack@google.com            const sc_fix_fast &, const sc_fix_fast &);
33412853Sgabeblack@google.com    friend const sc_fix_fast operator | (
33512853Sgabeblack@google.com            const sc_fix_fast &, const sc_fix_fast &);
33612853Sgabeblack@google.com
33712853Sgabeblack@google.com    // binary bitwise functions
33812853Sgabeblack@google.com    friend void b_and(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
33912853Sgabeblack@google.com    friend void b_or(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
34012853Sgabeblack@google.com    friend void b_xor(sc_fix_fast &, const sc_fix_fast &, const sc_fix_fast &);
34112853Sgabeblack@google.com
34212853Sgabeblack@google.com    // assignment operators
34312853Sgabeblack@google.com    sc_fix_fast &operator = (const sc_fix_fast &);
34412853Sgabeblack@google.com
34512853Sgabeblack@google.com#define DECL_ASN_OP_T(op,tp) sc_fix_fast &operator op (tp);
34612853Sgabeblack@google.com
34712853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \
34812853Sgabeblack@google.com    DECL_ASN_OP_T(op, int64) \
34912853Sgabeblack@google.com    DECL_ASN_OP_T(op, uint64) \
35012853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_int_base &) \
35112853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_uint_base &) \
35212853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_signed &) \
35312853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_unsigned &)
35412853Sgabeblack@google.com
35512853Sgabeblack@google.com#define DECL_ASN_OP(op) \
35612853Sgabeblack@google.com    DECL_ASN_OP_T(op, int) \
35712853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned int) \
35812853Sgabeblack@google.com    DECL_ASN_OP_T(op, long) \
35912853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned long) \
36012853Sgabeblack@google.com    DECL_ASN_OP_T(op, float) \
36112853Sgabeblack@google.com    DECL_ASN_OP_T(op, double) \
36212853Sgabeblack@google.com    DECL_ASN_OP_T(op, const char *) \
36312853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval &) \
36412853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval_fast &) \
36512853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum &) \
36612853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
36712853Sgabeblack@google.com    DECL_ASN_OP_OTHER(op)
36812853Sgabeblack@google.com
36912853Sgabeblack@google.com    DECL_ASN_OP(=)
37012853Sgabeblack@google.com
37112853Sgabeblack@google.com    DECL_ASN_OP(*=)
37212853Sgabeblack@google.com    DECL_ASN_OP(/=)
37312853Sgabeblack@google.com    DECL_ASN_OP(+=)
37412853Sgabeblack@google.com    DECL_ASN_OP(-=)
37512853Sgabeblack@google.com
37612853Sgabeblack@google.com    DECL_ASN_OP_T(<<=, int)
37712853Sgabeblack@google.com    DECL_ASN_OP_T(>>=, int)
37812853Sgabeblack@google.com
37912853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_fix &)
38012853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_fix_fast &)
38112853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_fix &)
38212853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_fix_fast &)
38312853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_fix &)
38412853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_fix_fast &)
38512853Sgabeblack@google.com
38612853Sgabeblack@google.com#undef DECL_ASN_OP_T
38712853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER
38812853Sgabeblack@google.com#undef DECL_ASN_OP
38912853Sgabeblack@google.com
39012853Sgabeblack@google.com    // auto-increment and auto-decrement
39112853Sgabeblack@google.com    const sc_fxval_fast operator ++ (int);
39212853Sgabeblack@google.com    const sc_fxval_fast operator -- (int);
39312853Sgabeblack@google.com
39412853Sgabeblack@google.com    sc_fix_fast& operator ++ ();
39512853Sgabeblack@google.com    sc_fix_fast& operator -- ();
39612853Sgabeblack@google.com};
39712853Sgabeblack@google.com
39812853Sgabeblack@google.com
39912853Sgabeblack@google.com// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
40012853Sgabeblack@google.com
40112853Sgabeblack@google.com// ----------------------------------------------------------------------------
40212853Sgabeblack@google.com//  CLASS : sc_fix
40312853Sgabeblack@google.com//
40412853Sgabeblack@google.com//  "Unconstrained" signed fixed-point class; arbitrary precision.
40512853Sgabeblack@google.com// ----------------------------------------------------------------------------
40612853Sgabeblack@google.com
40712853Sgabeblack@google.com// constructors
40812853Sgabeblack@google.cominline sc_fix::sc_fix(sc_fxnum_observer *observer_) :
40912853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), observer_)
41012853Sgabeblack@google.com{}
41112853Sgabeblack@google.com
41212853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, sc_fxnum_observer *observer_) :
41312853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(),
41412853Sgabeblack@google.com                 observer_)
41512853Sgabeblack@google.com{}
41612853Sgabeblack@google.com
41712853Sgabeblack@google.cominline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om,
41812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
41912853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(),
42012853Sgabeblack@google.com                 observer_ )
42112853Sgabeblack@google.com{}
42212853Sgabeblack@google.com
42312853Sgabeblack@google.cominline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om, int nb,
42412853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
42512853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om, nb), SC_TC_, sc_fxcast_switch(),
42612853Sgabeblack@google.com                 observer_)
42712853Sgabeblack@google.com{}
42812853Sgabeblack@google.com
42912853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
43012853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
43112853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_,
43212853Sgabeblack@google.com                 sc_fxcast_switch(), observer_)
43312853Sgabeblack@google.com{}
43412853Sgabeblack@google.com
43512853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
43612853Sgabeblack@google.com                      sc_fxnum_observer* observer_) :
43712853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_,
43812853Sgabeblack@google.com                 sc_fxcast_switch(), observer_)
43912853Sgabeblack@google.com{}
44012853Sgabeblack@google.com
44112853Sgabeblack@google.cominline sc_fix::sc_fix(const sc_fxcast_switch &cast_sw,
44212853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
44312853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(), SC_TC_, cast_sw, observer_)
44412853Sgabeblack@google.com{}
44512853Sgabeblack@google.com
44612853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
44712853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
44812853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_)
44912853Sgabeblack@google.com{}
45012853Sgabeblack@google.com
45112853Sgabeblack@google.cominline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om,
45212853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw,
45312853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
45412853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_)
45512853Sgabeblack@google.com{}
45612853Sgabeblack@google.com
45712853Sgabeblack@google.cominline sc_fix::sc_fix(sc_q_mode qm, sc_o_mode om, int nb,
45812853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw,
45912853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
46012853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_)
46112853Sgabeblack@google.com{}
46212853Sgabeblack@google.com
46312853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
46412853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw,
46512853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
46612853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw,
46712853Sgabeblack@google.com                                  observer_)
46812853Sgabeblack@google.com{}
46912853Sgabeblack@google.com
47012853Sgabeblack@google.cominline sc_fix::sc_fix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
47112853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw,
47212853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
47312853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw,
47412853Sgabeblack@google.com                 observer_)
47512853Sgabeblack@google.com{}
47612853Sgabeblack@google.com
47712853Sgabeblack@google.cominline sc_fix::sc_fix(const sc_fxtype_params &type_params_,
47812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
47912853Sgabeblack@google.com        sc_fxnum( type_params_, SC_TC_, sc_fxcast_switch(), observer_)
48012853Sgabeblack@google.com{}
48112853Sgabeblack@google.com
48212853Sgabeblack@google.cominline sc_fix::sc_fix(const sc_fxtype_params &type_params_,
48312853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw,
48412853Sgabeblack@google.com                      sc_fxnum_observer *observer_) :
48512853Sgabeblack@google.com        sc_fxnum(type_params_, SC_TC_, cast_sw, observer_)
48612853Sgabeblack@google.com{}
48712853Sgabeblack@google.com
48812853Sgabeblack@google.com#define DEFN_CTORS_T_A(tp) \
48912853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
49012853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
49112853Sgabeblack@google.com                 observer_) \
49212853Sgabeblack@google.com{} \
49312853Sgabeblack@google.com \
49412853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
49512853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
49612853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(), \
49712853Sgabeblack@google.com                 observer_) \
49812853Sgabeblack@google.com{} \
49912853Sgabeblack@google.com \
50012853Sgabeblack@google.cominline sc_fix::sc_fix(tp a,  sc_q_mode qm, sc_o_mode om, \
50112853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
50212853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(), \
50312853Sgabeblack@google.com                 observer_) \
50412853Sgabeblack@google.com{} \
50512853Sgabeblack@google.com \
50612853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
50712853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
50812853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
50912853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
51012853Sgabeblack@google.com{} \
51112853Sgabeblack@google.com \
51212853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
51312853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
51412853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
51512853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
51612853Sgabeblack@google.com{} \
51712853Sgabeblack@google.com \
51812853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
51912853Sgabeblack@google.com                      int nb, sc_fxnum_observer *observer_) : \
52012853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
52112853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
52212853Sgabeblack@google.com{} \
52312853Sgabeblack@google.com \
52412853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
52512853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
52612853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
52712853Sgabeblack@google.com{} \
52812853Sgabeblack@google.com \
52912853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
53012853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
53112853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
53212853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_) \
53312853Sgabeblack@google.com{} \
53412853Sgabeblack@google.com \
53512853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
53612853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
53712853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
53812853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_) \
53912853Sgabeblack@google.com{} \
54012853Sgabeblack@google.com \
54112853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
54212853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
54312853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
54412853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_) \
54512853Sgabeblack@google.com{} \
54612853Sgabeblack@google.com \
54712853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
54812853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
54912853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
55012853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
55112853Sgabeblack@google.com                 observer_) \
55212853Sgabeblack@google.com{} \
55312853Sgabeblack@google.com \
55412853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
55512853Sgabeblack@google.com                      int nb, const sc_fxcast_switch &cast_sw, \
55612853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
55712853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
55812853Sgabeblack@google.com                 observer_) \
55912853Sgabeblack@google.com{} \
56012853Sgabeblack@google.com \
56112853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
56212853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
56312853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
56412853Sgabeblack@google.com{} \
56512853Sgabeblack@google.com \
56612853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
56712853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
56812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
56912853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
57012853Sgabeblack@google.com{}
57112853Sgabeblack@google.com
57212853Sgabeblack@google.com#define DEFN_CTORS_T_B(tp) \
57312853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
57412853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_TC_, sc_fxcast_switch(), observer_) \
57512853Sgabeblack@google.com{} \
57612853Sgabeblack@google.com \
57712853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
57812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
57912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
58012853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
58112853Sgabeblack@google.com{} \
58212853Sgabeblack@google.com \
58312853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
58412853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
58512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
58612853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
58712853Sgabeblack@google.com{} \
58812853Sgabeblack@google.com \
58912853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
59012853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
59112853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
59212853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
59312853Sgabeblack@google.com{} \
59412853Sgabeblack@google.com \
59512853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
59612853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
59712853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
59812853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
59912853Sgabeblack@google.com{} \
60012853Sgabeblack@google.com \
60112853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
60212853Sgabeblack@google.com                      int nb, sc_fxnum_observer *observer_) : \
60312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
60412853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
60512853Sgabeblack@google.com{} \
60612853Sgabeblack@google.com \
60712853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
60812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
60912853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_TC_, cast_sw, observer_) \
61012853Sgabeblack@google.com{} \
61112853Sgabeblack@google.com \
61212853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
61312853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
61412853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
61512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
61612853Sgabeblack@google.com                 cast_sw, observer_) \
61712853Sgabeblack@google.com{} \
61812853Sgabeblack@google.com \
61912853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
62012853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
62112853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
62212853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
62312853Sgabeblack@google.com                 cast_sw, observer_) \
62412853Sgabeblack@google.com{} \
62512853Sgabeblack@google.com \
62612853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
62712853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
62812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
62912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
63012853Sgabeblack@google.com                 cast_sw, observer_) \
63112853Sgabeblack@google.com{} \
63212853Sgabeblack@google.com \
63312853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
63412853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
63512853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
63612853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
63712853Sgabeblack@google.com                 observer_) \
63812853Sgabeblack@google.com{} \
63912853Sgabeblack@google.com \
64012853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
64112853Sgabeblack@google.com                      int nb, const sc_fxcast_switch &cast_sw, \
64212853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
64312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
64412853Sgabeblack@google.com                 observer_) \
64512853Sgabeblack@google.com{} \
64612853Sgabeblack@google.com \
64712853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
64812853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
64912853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
65012853Sgabeblack@google.com{} \
65112853Sgabeblack@google.com \
65212853Sgabeblack@google.cominline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
65312853Sgabeblack@google.com                      const sc_fxcast_switch &cast_sw, \
65412853Sgabeblack@google.com                      sc_fxnum_observer *observer_) : \
65512853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
65612853Sgabeblack@google.com{}
65712853Sgabeblack@google.com
65812853Sgabeblack@google.comDEFN_CTORS_T_A(int)
65912853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned int)
66012853Sgabeblack@google.comDEFN_CTORS_T_A(long)
66112853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned long)
66212853Sgabeblack@google.comDEFN_CTORS_T_A(float)
66312853Sgabeblack@google.comDEFN_CTORS_T_A(double)
66412853Sgabeblack@google.comDEFN_CTORS_T_A(const char *)
66512853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval &)
66612853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval_fast &)
66712853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum &)
66812853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum_fast &)
66912853Sgabeblack@google.com
67012853Sgabeblack@google.comDEFN_CTORS_T_A(int64)
67112853Sgabeblack@google.comDEFN_CTORS_T_A(uint64)
67212853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_int_base &)
67312853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_uint_base &)
67412853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_signed &)
67512853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_unsigned &)
67612853Sgabeblack@google.com
67712853Sgabeblack@google.com#undef DEFN_CTORS_T_A
67812853Sgabeblack@google.com#undef DEFN_CTORS_T_B
67912853Sgabeblack@google.com
68012853Sgabeblack@google.com// copy constructor
68112853Sgabeblack@google.cominline sc_fix::sc_fix(const sc_fix &a) :
68212853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_TC_, sc_fxcast_switch(), 0)
68312853Sgabeblack@google.com{}
68412853Sgabeblack@google.com
68512853Sgabeblack@google.com// unary bitwise operators
68612853Sgabeblack@google.cominline const sc_fix sc_fix::operator ~ () const
68712853Sgabeblack@google.com{
68812853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(*this)
68912853Sgabeblack@google.com    int iwl_c = iwl();
69012853Sgabeblack@google.com    int wl_c = wl();
69112853Sgabeblack@google.com    sc_fix c(wl_c, iwl_c);
69212853Sgabeblack@google.com    for (int i = iwl_c - wl_c; i < iwl_c; ++i)
69312853Sgabeblack@google.com        c.set_bit(i, !get_bit(i));
69412853Sgabeblack@google.com    return sc_fix(c, wl_c, iwl_c);
69512853Sgabeblack@google.com}
69612853Sgabeblack@google.com
69712853Sgabeblack@google.com// unary bitwise functions
69812853Sgabeblack@google.cominline void
69912853Sgabeblack@google.comb_not(sc_fix &c, const sc_fix &a)
70012853Sgabeblack@google.com{
70112853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(a)
70212853Sgabeblack@google.com    int iwl_c = c.iwl();
70312853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
70412853Sgabeblack@google.com        c.set_bit(i, !a.get_bit(i));
70512853Sgabeblack@google.com    c.cast();
70612853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(c)
70712853Sgabeblack@google.com}
70812853Sgabeblack@google.com
70912853Sgabeblack@google.com// binary bitwise operators
71012853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
71112853Sgabeblack@google.cominline const sc_fix \
71212853Sgabeblack@google.comoperator op (const tp1 &a, const tp2 &b) \
71312853Sgabeblack@google.com{ \
71412853Sgabeblack@google.com    a.observer_read(); \
71512853Sgabeblack@google.com    b.observer_read(); \
71612853Sgabeblack@google.com    int iwl_a = a.iwl(); \
71712853Sgabeblack@google.com    int iwl_b = b.iwl(); \
71812853Sgabeblack@google.com    int iwl_c = sc_max(iwl_a, iwl_b); \
71912853Sgabeblack@google.com    int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
72012853Sgabeblack@google.com    sc_fix c(iwl_c + fwl_c, iwl_c); \
72112853Sgabeblack@google.com    for (int i = -fwl_c; i < iwl_c; ++ i) \
72212853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
72312853Sgabeblack@google.com    return sc_fix(c, iwl_c + fwl_c, iwl_c); \
72412853Sgabeblack@google.com}
72512853Sgabeblack@google.com
72612853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_fix, sc_fix)
72712853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_fix, sc_fix_fast)
72812853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_fix_fast, sc_fix)
72912853Sgabeblack@google.com
73012853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_fix, sc_fix)
73112853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_fix, sc_fix_fast)
73212853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_fix_fast, sc_fix)
73312853Sgabeblack@google.com
73412853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_fix, sc_fix)
73512853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_fix, sc_fix_fast)
73612853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_fix_fast, sc_fix)
73712853Sgabeblack@google.com
73812853Sgabeblack@google.com#undef DEFN_BIN_OP_T
73912853Sgabeblack@google.com
74012853Sgabeblack@google.com// binary bitwise functions
74112853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
74212853Sgabeblack@google.cominline void \
74312853Sgabeblack@google.comfnc (sc_fix &c, const tp1 &a, const tp2 &b) \
74412853Sgabeblack@google.com{ \
74512853Sgabeblack@google.com    a.observer_read(); \
74612853Sgabeblack@google.com    b.observer_read(); \
74712853Sgabeblack@google.com    int iwl_c = c.iwl(); \
74812853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
74912853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
75012853Sgabeblack@google.com    c.cast(); \
75112853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(c) \
75212853Sgabeblack@google.com}
75312853Sgabeblack@google.com
75412853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_fix, sc_fix)
75512853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_fix, sc_fix_fast)
75612853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_fix_fast, sc_fix)
75712853Sgabeblack@google.com
75812853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_fix, sc_fix)
75912853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_fix, sc_fix_fast)
76012853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_fix_fast, sc_fix)
76112853Sgabeblack@google.com
76212853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_fix, sc_fix)
76312853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_fix, sc_fix_fast)
76412853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_fix_fast, sc_fix)
76512853Sgabeblack@google.com
76612853Sgabeblack@google.com#undef DEFN_BIN_FNC_T
76712853Sgabeblack@google.com
76812853Sgabeblack@google.com// assignment operators
76912853Sgabeblack@google.cominline
77012853Sgabeblack@google.comsc_fix &
77112853Sgabeblack@google.comsc_fix::operator = (const sc_fix &a)
77212853Sgabeblack@google.com{
77312853Sgabeblack@google.com    sc_fxnum::operator = (a);
77412853Sgabeblack@google.com    return *this;
77512853Sgabeblack@google.com}
77612853Sgabeblack@google.com
77712853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \
77812853Sgabeblack@google.cominline sc_fix & \
77912853Sgabeblack@google.comsc_fix::operator op (tp a) \
78012853Sgabeblack@google.com{ \
78112853Sgabeblack@google.com    sc_fxnum::operator op(a); \
78212853Sgabeblack@google.com    return *this; \
78312853Sgabeblack@google.com}
78412853Sgabeblack@google.com
78512853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \
78612853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \
78712853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \
78812853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \
78912853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \
79012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \
79112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &)
79212853Sgabeblack@google.com
79312853Sgabeblack@google.com#define DEFN_ASN_OP(op) \
79412853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \
79512853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \
79612853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \
79712853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \
79812853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \
79912853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \
80012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \
80112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \
80212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \
80312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \
80412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
80512853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op)
80612853Sgabeblack@google.com
80712853Sgabeblack@google.comDEFN_ASN_OP(=)
80812853Sgabeblack@google.com
80912853Sgabeblack@google.comDEFN_ASN_OP(*=)
81012853Sgabeblack@google.comDEFN_ASN_OP(/=)
81112853Sgabeblack@google.comDEFN_ASN_OP(+=)
81212853Sgabeblack@google.comDEFN_ASN_OP(-=)
81312853Sgabeblack@google.com
81412853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int)
81512853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int)
81612853Sgabeblack@google.com
81712853Sgabeblack@google.com#undef DEFN_ASN_OP_T
81812853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER
81912853Sgabeblack@google.com#undef DEFN_ASN_OP
82012853Sgabeblack@google.com
82112853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, op2, tp) \
82212853Sgabeblack@google.cominline sc_fix & \
82312853Sgabeblack@google.comsc_fix::operator op (const tp &b) \
82412853Sgabeblack@google.com{ \
82512853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(*this) \
82612853Sgabeblack@google.com    b.observer_read(); \
82712853Sgabeblack@google.com    int iwl_c = iwl(); \
82812853Sgabeblack@google.com    for (int i = iwl_c - wl(); i < iwl_c; ++i) \
82912853Sgabeblack@google.com        set_bit(i, get_bit(i) op2 b.get_bit(i)); \
83012853Sgabeblack@google.com    cast(); \
83112853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(*this) \
83212853Sgabeblack@google.com    return *this; \
83312853Sgabeblack@google.com}
83412853Sgabeblack@google.com
83512853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_fix)
83612853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_fix_fast)
83712853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_fix)
83812853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_fix_fast)
83912853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_fix)
84012853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_fix_fast)
84112853Sgabeblack@google.com
84212853Sgabeblack@google.com#undef DEFN_ASN_OP_T
84312853Sgabeblack@google.com
84412853Sgabeblack@google.com// auto-increment and auto-decrement
84512853Sgabeblack@google.cominline const sc_fxval
84612853Sgabeblack@google.comsc_fix::operator ++ (int)
84712853Sgabeblack@google.com{
84812853Sgabeblack@google.com    return sc_fxval(sc_fxnum::operator ++ (0));
84912853Sgabeblack@google.com}
85012853Sgabeblack@google.com
85112853Sgabeblack@google.cominline const sc_fxval
85212853Sgabeblack@google.comsc_fix::operator -- (int)
85312853Sgabeblack@google.com{
85412853Sgabeblack@google.com    return sc_fxval(sc_fxnum::operator -- (0));
85512853Sgabeblack@google.com}
85612853Sgabeblack@google.com
85712853Sgabeblack@google.cominline sc_fix &
85812853Sgabeblack@google.comsc_fix::operator ++ ()
85912853Sgabeblack@google.com{
86012853Sgabeblack@google.com    sc_fxnum::operator ++ ();
86112853Sgabeblack@google.com    return *this;
86212853Sgabeblack@google.com}
86312853Sgabeblack@google.com
86412853Sgabeblack@google.cominline sc_fix &
86512853Sgabeblack@google.comsc_fix::operator -- ()
86612853Sgabeblack@google.com{
86712853Sgabeblack@google.com    sc_fxnum::operator -- ();
86812853Sgabeblack@google.com    return *this;
86912853Sgabeblack@google.com}
87012853Sgabeblack@google.com
87112853Sgabeblack@google.com
87212853Sgabeblack@google.com// ----------------------------------------------------------------------------
87312853Sgabeblack@google.com// CLASS : sc_fix_fast
87412853Sgabeblack@google.com//
87512853Sgabeblack@google.com// "Unconstrained" signed fixed-point class; limited precision.
87612853Sgabeblack@google.com// ----------------------------------------------------------------------------
87712853Sgabeblack@google.com
87812853Sgabeblack@google.com// constructors
87912853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(sc_fxnum_fast_observer *observer_) :
88012853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(), SC_TC_, sc_fxcast_switch(),
88112853Sgabeblack@google.com                      observer_)
88212853Sgabeblack@google.com{}
88312853Sgabeblack@google.com
88412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_,
88512853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
88612853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(),
88712853Sgabeblack@google.com                      observer_ )
88812853Sgabeblack@google.com{}
88912853Sgabeblack@google.com
89012853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om,
89112853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
89212853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(),
89312853Sgabeblack@google.com                      observer_ )
89412853Sgabeblack@google.com{}
89512853Sgabeblack@google.com
89612853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om, int nb,
89712853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
89812853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_TC_, sc_fxcast_switch(),
89912853Sgabeblack@google.com                      observer_ )
90012853Sgabeblack@google.com{}
90112853Sgabeblack@google.com
90212853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
90312853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
90412853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_,
90512853Sgabeblack@google.com                      sc_fxcast_switch(), observer_)
90612853Sgabeblack@google.com{}
90712853Sgabeblack@google.com
90812853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
90912853Sgabeblack@google.com                                int nb, sc_fxnum_fast_observer *observer_) :
91012853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_,
91112853Sgabeblack@google.com                      sc_fxcast_switch(), observer_)
91212853Sgabeblack@google.com{}
91312853Sgabeblack@google.com
91412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(const sc_fxcast_switch &cast_sw,
91512853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
91612853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(), SC_TC_, cast_sw, observer_)
91712853Sgabeblack@google.com{}
91812853Sgabeblack@google.com
91912853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_,
92012853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw,
92112853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
92212853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_)
92312853Sgabeblack@google.com{}
92412853Sgabeblack@google.com
92512853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om,
92612853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw,
92712853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
92812853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_)
92912853Sgabeblack@google.com{}
93012853Sgabeblack@google.com
93112853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(sc_q_mode qm, sc_o_mode om, int nb,
93212853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw,
93312853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
93412853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_)
93512853Sgabeblack@google.com{}
93612853Sgabeblack@google.com
93712853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
93812853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw,
93912853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
94012853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw,
94112853Sgabeblack@google.com                      observer_)
94212853Sgabeblack@google.com{}
94312853Sgabeblack@google.com
94412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
94512853Sgabeblack@google.com                                int nb, const sc_fxcast_switch &cast_sw,
94612853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
94712853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw,
94812853Sgabeblack@google.com                      observer_)
94912853Sgabeblack@google.com{}
95012853Sgabeblack@google.com
95112853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(const sc_fxtype_params &type_params_,
95212853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
95312853Sgabeblack@google.com        sc_fxnum_fast(type_params_, SC_TC_, sc_fxcast_switch(), observer_)
95412853Sgabeblack@google.com{}
95512853Sgabeblack@google.com
95612853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(const sc_fxtype_params &type_params_,
95712853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw,
95812853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) :
95912853Sgabeblack@google.com        sc_fxnum_fast(type_params_, SC_TC_, cast_sw, observer_)
96012853Sgabeblack@google.com{}
96112853Sgabeblack@google.com
96212853Sgabeblack@google.com#define DEFN_CTORS_T_A(tp) \
96312853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_ ) : \
96412853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
96512853Sgabeblack@google.com                      observer_ ) \
96612853Sgabeblack@google.com{} \
96712853Sgabeblack@google.com \
96812853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
96912853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
97012853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, \
97112853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
97212853Sgabeblack@google.com{} \
97312853Sgabeblack@google.com \
97412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
97512853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
97612853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, \
97712853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
97812853Sgabeblack@google.com{} \
97912853Sgabeblack@google.com \
98012853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
98112853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_ ) : \
98212853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
98312853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
98412853Sgabeblack@google.com{} \
98512853Sgabeblack@google.com \
98612853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
98712853Sgabeblack@google.com                                sc_o_mode om, \
98812853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
98912853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
99012853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
99112853Sgabeblack@google.com{} \
99212853Sgabeblack@google.com \
99312853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
99412853Sgabeblack@google.com                                sc_o_mode om, int nb, \
99512853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
99612853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
99712853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
99812853Sgabeblack@google.com{} \
99912853Sgabeblack@google.com \
100012853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
100112853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
100212853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
100312853Sgabeblack@google.com{} \
100412853Sgabeblack@google.com \
100512853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
100612853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
100712853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
100812853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, \
100912853Sgabeblack@google.com                      observer_ ) \
101012853Sgabeblack@google.com{} \
101112853Sgabeblack@google.com \
101212853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
101312853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
101412853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
101512853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, \
101612853Sgabeblack@google.com                      observer_) \
101712853Sgabeblack@google.com{} \
101812853Sgabeblack@google.com \
101912853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
102012853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
102112853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
102212853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, \
102312853Sgabeblack@google.com                      observer_ ) \
102412853Sgabeblack@google.com{} \
102512853Sgabeblack@google.com \
102612853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
102712853Sgabeblack@google.com                                sc_o_mode om, \
102812853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
102912853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
103012853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
103112853Sgabeblack@google.com                      cast_sw, observer_) \
103212853Sgabeblack@google.com{} \
103312853Sgabeblack@google.com \
103412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
103512853Sgabeblack@google.com                                sc_o_mode om, int nb, \
103612853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
103712853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
103812853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
103912853Sgabeblack@google.com                      cast_sw, observer_) \
104012853Sgabeblack@google.com{} \
104112853Sgabeblack@google.com \
104212853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
104312853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
104412853Sgabeblack@google.com        sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
104512853Sgabeblack@google.com{} \
104612853Sgabeblack@google.com \
104712853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
104812853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
104912853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
105012853Sgabeblack@google.com        sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_) \
105112853Sgabeblack@google.com{}
105212853Sgabeblack@google.com
105312853Sgabeblack@google.com#define DEFN_CTORS_T_B(tp) \
105412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
105512853Sgabeblack@google.com        sc_fxnum_fast(a, a.type_params(), SC_TC_, sc_fxcast_switch(), \
105612853Sgabeblack@google.com                      observer_ ) \
105712853Sgabeblack@google.com{} \
105812853Sgabeblack@google.com \
105912853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
106012853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
106112853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
106212853Sgabeblack@google.com                      SC_TC_, sc_fxcast_switch(), observer_) \
106312853Sgabeblack@google.com{} \
106412853Sgabeblack@google.com \
106512853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
106612853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
106712853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
106812853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
106912853Sgabeblack@google.com{} \
107012853Sgabeblack@google.com \
107112853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
107212853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
107312853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
107412853Sgabeblack@google.com                      SC_TC_, sc_fxcast_switch(), observer_) \
107512853Sgabeblack@google.com{} \
107612853Sgabeblack@google.com \
107712853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
107812853Sgabeblack@google.com                                sc_o_mode om, \
107912853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
108012853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
108112853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
108212853Sgabeblack@google.com{} \
108312853Sgabeblack@google.com \
108412853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
108512853Sgabeblack@google.com                                sc_o_mode om, int nb, \
108612853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
108712853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
108812853Sgabeblack@google.com                      sc_fxcast_switch(), observer_) \
108912853Sgabeblack@google.com{} \
109012853Sgabeblack@google.com \
109112853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
109212853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
109312853Sgabeblack@google.com        sc_fxnum_fast(a, a.type_params(), SC_TC_, cast_sw, observer_) \
109412853Sgabeblack@google.com{} \
109512853Sgabeblack@google.com \
109612853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
109712853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
109812853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
109912853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
110012853Sgabeblack@google.com                      SC_TC_, cast_sw, observer_) \
110112853Sgabeblack@google.com{} \
110212853Sgabeblack@google.com \
110312853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
110412853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
110512853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
110612853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
110712853Sgabeblack@google.com                      cast_sw, observer_) \
110812853Sgabeblack@google.com{} \
110912853Sgabeblack@google.com \
111012853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
111112853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
111212853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
111312853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
111412853Sgabeblack@google.com                      SC_TC_, cast_sw, observer_) \
111512853Sgabeblack@google.com{} \
111612853Sgabeblack@google.com \
111712853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
111812853Sgabeblack@google.com                                sc_o_mode om, \
111912853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
112012853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
112112853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
112212853Sgabeblack@google.com                      cast_sw, observer_) \
112312853Sgabeblack@google.com{} \
112412853Sgabeblack@google.com \
112512853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
112612853Sgabeblack@google.com                                sc_o_mode om, int nb, \
112712853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
112812853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
112912853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
113012853Sgabeblack@google.com                      cast_sw, observer_) \
113112853Sgabeblack@google.com{} \
113212853Sgabeblack@google.com \
113312853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
113412853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
113512853Sgabeblack@google.com        sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
113612853Sgabeblack@google.com{} \
113712853Sgabeblack@google.com \
113812853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
113912853Sgabeblack@google.com                                const sc_fxcast_switch &cast_sw, \
114012853Sgabeblack@google.com                                sc_fxnum_fast_observer *observer_) : \
114112853Sgabeblack@google.com        sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_ ) \
114212853Sgabeblack@google.com{}
114312853Sgabeblack@google.com
114412853Sgabeblack@google.comDEFN_CTORS_T_A(int)
114512853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned int)
114612853Sgabeblack@google.comDEFN_CTORS_T_A(long)
114712853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned long)
114812853Sgabeblack@google.comDEFN_CTORS_T_A(float)
114912853Sgabeblack@google.comDEFN_CTORS_T_A(double)
115012853Sgabeblack@google.comDEFN_CTORS_T_A(const char *)
115112853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval &)
115212853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval_fast &)
115312853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum &)
115412853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum_fast &)
115512853Sgabeblack@google.com
115612853Sgabeblack@google.comDEFN_CTORS_T_A(int64)
115712853Sgabeblack@google.comDEFN_CTORS_T_A(uint64)
115812853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_int_base &)
115912853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_uint_base &)
116012853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_signed &)
116112853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_unsigned &)
116212853Sgabeblack@google.com
116312853Sgabeblack@google.com#undef DEFN_CTORS_T_A
116412853Sgabeblack@google.com#undef DEFN_CTORS_T_B
116512853Sgabeblack@google.com
116612853Sgabeblack@google.com// copy constructor
116712853Sgabeblack@google.cominline sc_fix_fast::sc_fix_fast(const sc_fix_fast &a) :
116812853Sgabeblack@google.com        sc_fxnum_fast(a, a.type_params(), SC_TC_, sc_fxcast_switch(), 0)
116912853Sgabeblack@google.com{}
117012853Sgabeblack@google.com
117112853Sgabeblack@google.com// unary bitwise operators
117212853Sgabeblack@google.cominline const sc_fix_fast
117312853Sgabeblack@google.comsc_fix_fast::operator ~ () const
117412853Sgabeblack@google.com{
117512853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(*this)
117612853Sgabeblack@google.com    int iwl_c = iwl();
117712853Sgabeblack@google.com    int wl_c = wl();
117812853Sgabeblack@google.com    sc_fix_fast c(wl_c, iwl_c);
117912853Sgabeblack@google.com    for (int i = iwl_c - wl_c; i < iwl_c; ++i)
118012853Sgabeblack@google.com        c.set_bit(i, !get_bit(i));
118112853Sgabeblack@google.com    return sc_fix_fast(c, wl_c, iwl_c);
118212853Sgabeblack@google.com}
118312853Sgabeblack@google.com
118412853Sgabeblack@google.com// unary bitwise functions
118512853Sgabeblack@google.cominline void
118612853Sgabeblack@google.comb_not(sc_fix_fast &c, const sc_fix_fast &a)
118712853Sgabeblack@google.com{
118812853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(a)
118912853Sgabeblack@google.com    int iwl_c = c.iwl();
119012853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
119112853Sgabeblack@google.com        c.set_bit(i, !a.get_bit(i));
119212853Sgabeblack@google.com    c.cast();
119312853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(c)
119412853Sgabeblack@google.com}
119512853Sgabeblack@google.com
119612853Sgabeblack@google.com// binary bitwise operators
119712853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
119812853Sgabeblack@google.cominline const sc_fix_fast \
119912853Sgabeblack@google.comoperator op (const tp1 &a, const tp2 &b) \
120012853Sgabeblack@google.com{ \
120112853Sgabeblack@google.com    a.observer_read(); \
120212853Sgabeblack@google.com    b.observer_read(); \
120312853Sgabeblack@google.com    int iwl_a = a.iwl(); \
120412853Sgabeblack@google.com    int iwl_b = b.iwl(); \
120512853Sgabeblack@google.com    int iwl_c = sc_max(iwl_a, iwl_b); \
120612853Sgabeblack@google.com    int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
120712853Sgabeblack@google.com    sc_fix_fast c(iwl_c + fwl_c, iwl_c); \
120812853Sgabeblack@google.com    for (int i = -fwl_c; i < iwl_c; ++i) \
120912853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
121012853Sgabeblack@google.com    return sc_fix_fast(c, iwl_c + fwl_c, iwl_c); \
121112853Sgabeblack@google.com}
121212853Sgabeblack@google.com
121312853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_fix_fast, sc_fix_fast)
121412853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_fix_fast, sc_fix_fast)
121512853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_fix_fast, sc_fix_fast)
121612853Sgabeblack@google.com
121712853Sgabeblack@google.com#undef DEFN_BIN_OP_T
121812853Sgabeblack@google.com
121912853Sgabeblack@google.com// binary bitwise functions
122012853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
122112853Sgabeblack@google.cominline void \
122212853Sgabeblack@google.comfnc(sc_fix_fast &c, const tp1 &a, const tp2 &b) \
122312853Sgabeblack@google.com{ \
122412853Sgabeblack@google.com    a.observer_read(); \
122512853Sgabeblack@google.com    b.observer_read(); \
122612853Sgabeblack@google.com    int iwl_c = c.iwl(); \
122712853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
122812853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
122912853Sgabeblack@google.com    c.cast(); \
123012853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
123112853Sgabeblack@google.com}
123212853Sgabeblack@google.com
123312853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_fix_fast, sc_fix_fast)
123412853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_fix_fast, sc_fix_fast)
123512853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_fix_fast, sc_fix_fast)
123612853Sgabeblack@google.com
123712853Sgabeblack@google.com#undef DEFN_BIN_FNC_T
123812853Sgabeblack@google.com
123912853Sgabeblack@google.com// assignment operators
124012853Sgabeblack@google.cominline sc_fix_fast &
124112853Sgabeblack@google.comsc_fix_fast::operator = (const sc_fix_fast &a)
124212853Sgabeblack@google.com{
124312853Sgabeblack@google.com    sc_fxnum_fast::operator = (a);
124412853Sgabeblack@google.com    return *this;
124512853Sgabeblack@google.com}
124612853Sgabeblack@google.com
124712853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \
124812853Sgabeblack@google.cominline sc_fix_fast & \
124912853Sgabeblack@google.comsc_fix_fast::operator op (tp a) \
125012853Sgabeblack@google.com{ \
125112853Sgabeblack@google.com    sc_fxnum_fast::operator op(a); \
125212853Sgabeblack@google.com    return *this; \
125312853Sgabeblack@google.com}
125412853Sgabeblack@google.com
125512853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \
125612853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \
125712853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \
125812853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \
125912853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \
126012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \
126112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &)
126212853Sgabeblack@google.com
126312853Sgabeblack@google.com#define DEFN_ASN_OP(op) \
126412853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \
126512853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \
126612853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \
126712853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \
126812853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \
126912853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \
127012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \
127112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \
127212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \
127312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \
127412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
127512853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op)
127612853Sgabeblack@google.com
127712853Sgabeblack@google.comDEFN_ASN_OP(=)
127812853Sgabeblack@google.com
127912853Sgabeblack@google.comDEFN_ASN_OP(*=)
128012853Sgabeblack@google.comDEFN_ASN_OP(/=)
128112853Sgabeblack@google.comDEFN_ASN_OP(+=)
128212853Sgabeblack@google.comDEFN_ASN_OP(-=)
128312853Sgabeblack@google.com
128412853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int)
128512853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int)
128612853Sgabeblack@google.com
128712853Sgabeblack@google.com#undef DEFN_ASN_OP_T
128812853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER
128912853Sgabeblack@google.com#undef DEFN_ASN_OP
129012853Sgabeblack@google.com
129112853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, op2, tp) \
129212853Sgabeblack@google.cominline sc_fix_fast & \
129312853Sgabeblack@google.comsc_fix_fast::operator op (const tp &b) \
129412853Sgabeblack@google.com{ \
129512853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(*this) \
129612853Sgabeblack@google.com    b.observer_read(); \
129712853Sgabeblack@google.com    int iwl_c = iwl(); \
129812853Sgabeblack@google.com    for (int i = iwl_c - wl(); i < iwl_c; ++i) \
129912853Sgabeblack@google.com        set_bit(i, get_bit(i) op2 b.get_bit(i)); \
130012853Sgabeblack@google.com    cast(); \
130112853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
130212853Sgabeblack@google.com    return *this; \
130312853Sgabeblack@google.com}
130412853Sgabeblack@google.com
130512853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_fix)
130612853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_fix_fast)
130712853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_fix)
130812853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_fix_fast)
130912853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_fix)
131012853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_fix_fast)
131112853Sgabeblack@google.com
131212853Sgabeblack@google.com#undef DEFN_ASN_OP_T
131312853Sgabeblack@google.com
131412853Sgabeblack@google.com// auto-increment and auto-decrement
131512853Sgabeblack@google.cominline const sc_fxval_fast
131612853Sgabeblack@google.comsc_fix_fast::operator ++ (int)
131712853Sgabeblack@google.com{
131812853Sgabeblack@google.com    return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
131912853Sgabeblack@google.com}
132012853Sgabeblack@google.com
132112853Sgabeblack@google.cominline const sc_fxval_fast
132212853Sgabeblack@google.comsc_fix_fast::operator -- (int)
132312853Sgabeblack@google.com{
132412853Sgabeblack@google.com    return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
132512853Sgabeblack@google.com}
132612853Sgabeblack@google.com
132712853Sgabeblack@google.cominline sc_fix_fast &
132812853Sgabeblack@google.comsc_fix_fast::operator ++ ()
132912853Sgabeblack@google.com{
133012853Sgabeblack@google.com    sc_fxnum_fast::operator ++ ();
133112853Sgabeblack@google.com    return *this;
133212853Sgabeblack@google.com}
133312853Sgabeblack@google.com
133412853Sgabeblack@google.cominline sc_fix_fast &
133512853Sgabeblack@google.comsc_fix_fast::operator -- ()
133612853Sgabeblack@google.com{
133712853Sgabeblack@google.com    sc_fxnum_fast::operator -- ();
133812853Sgabeblack@google.com    return *this;
133912853Sgabeblack@google.com}
134012853Sgabeblack@google.com
134112853Sgabeblack@google.com} // namespace sc_dt
134212853Sgabeblack@google.com
134312853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
1344