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_ufix.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_ufix.h,v $
3912853Sgabeblack@google.com// Revision 1.2  2011/01/20 22:52:30  acg
4012853Sgabeblack@google.com//  Andy Goodrich: Add float constructors.
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:58  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_UFIX_HH__
5112853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_FX_SC_UFIX_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_ufix;
6012853Sgabeblack@google.comclass sc_ufix_fast;
6112853Sgabeblack@google.com
6212853Sgabeblack@google.com
6312853Sgabeblack@google.com// ----------------------------------------------------------------------------
6412853Sgabeblack@google.com//  CLASS : sc_ufix
6512853Sgabeblack@google.com//
6612853Sgabeblack@google.com//  "Unconstrained" unsigned fixed-point class; arbitrary precision.
6712853Sgabeblack@google.com// ----------------------------------------------------------------------------
6812853Sgabeblack@google.com
6912853Sgabeblack@google.comclass sc_ufix : public sc_fxnum
7012853Sgabeblack@google.com{
7112853Sgabeblack@google.com  public:
7212853Sgabeblack@google.com    // constructors
7312853Sgabeblack@google.com    explicit sc_ufix(sc_fxnum_observer * =0);
7412853Sgabeblack@google.com    sc_ufix(int, int, sc_fxnum_observer * =0);
7512853Sgabeblack@google.com    sc_ufix(sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
7612853Sgabeblack@google.com    sc_ufix(sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
7712853Sgabeblack@google.com    sc_ufix(int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0);
7812853Sgabeblack@google.com    sc_ufix(int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0);
7912853Sgabeblack@google.com    explicit sc_ufix(const sc_fxcast_switch &, sc_fxnum_observer * =0);
8012853Sgabeblack@google.com    sc_ufix(int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0);
8112853Sgabeblack@google.com    sc_ufix(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
8212853Sgabeblack@google.com            sc_fxnum_observer * =0);
8312853Sgabeblack@google.com    sc_ufix(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &,
8412853Sgabeblack@google.com            sc_fxnum_observer * =0);
8512853Sgabeblack@google.com    sc_ufix(int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
8612853Sgabeblack@google.com            sc_fxnum_observer * =0);
8712853Sgabeblack@google.com    sc_ufix(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_ufix(const sc_fxtype_params &, sc_fxnum_observer * =0);
9012853Sgabeblack@google.com    sc_ufix(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_ufix(tp, int, int, sc_fxnum_observer * =0); \
9512853Sgabeblack@google.com    sc_ufix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
9612853Sgabeblack@google.com    sc_ufix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
9712853Sgabeblack@google.com    sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
9812853Sgabeblack@google.com    sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
9912853Sgabeblack@google.com    sc_ufix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
10012853Sgabeblack@google.com    sc_ufix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
10112853Sgabeblack@google.com    sc_ufix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
10212853Sgabeblack@google.com            sc_fxnum_observer * =0); \
10312853Sgabeblack@google.com    sc_ufix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
10412853Sgabeblack@google.com            sc_fxnum_observer * =0); \
10512853Sgabeblack@google.com    sc_ufix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
10612853Sgabeblack@google.com            sc_fxnum_observer * =0); \
10712853Sgabeblack@google.com    sc_ufix(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_ufix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
11012853Sgabeblack@google.com    sc_ufix(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_ufix(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_ufix(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_ufix(const sc_ufix &);
14612853Sgabeblack@google.com
14712853Sgabeblack@google.com    // unary bitwise operators
14812853Sgabeblack@google.com    const sc_ufix operator ~ () const;
14912853Sgabeblack@google.com
15012853Sgabeblack@google.com    // unary bitwise functions
15112853Sgabeblack@google.com    friend void b_not(sc_ufix &, const sc_ufix &);
15212853Sgabeblack@google.com
15312853Sgabeblack@google.com    // binary bitwise operators
15412853Sgabeblack@google.com    friend const sc_ufix operator & (const sc_ufix &, const sc_ufix &);
15512853Sgabeblack@google.com    friend const sc_ufix operator & (const sc_ufix &, const sc_ufix_fast &);
15612853Sgabeblack@google.com    friend const sc_ufix operator & (const sc_ufix_fast &, const sc_ufix &);
15712853Sgabeblack@google.com    friend const sc_ufix operator | (const sc_ufix &, const sc_ufix &);
15812853Sgabeblack@google.com    friend const sc_ufix operator | (const sc_ufix &, const sc_ufix_fast &);
15912853Sgabeblack@google.com    friend const sc_ufix operator | (const sc_ufix_fast &, const sc_ufix &);
16012853Sgabeblack@google.com    friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix &);
16112853Sgabeblack@google.com    friend const sc_ufix operator ^ (const sc_ufix &, const sc_ufix_fast &);
16212853Sgabeblack@google.com    friend const sc_ufix operator ^ (const sc_ufix_fast &, const sc_ufix &);
16312853Sgabeblack@google.com
16412853Sgabeblack@google.com    // binary bitwise functions
16512853Sgabeblack@google.com    friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix &);
16612853Sgabeblack@google.com    friend void b_and(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
16712853Sgabeblack@google.com    friend void b_and(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
16812853Sgabeblack@google.com    friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix &);
16912853Sgabeblack@google.com    friend void b_or(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
17012853Sgabeblack@google.com    friend void b_or(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
17112853Sgabeblack@google.com    friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix &);
17212853Sgabeblack@google.com    friend void b_xor(sc_ufix &, const sc_ufix &, const sc_ufix_fast &);
17312853Sgabeblack@google.com    friend void b_xor(sc_ufix &, const sc_ufix_fast &, const sc_ufix &);
17412853Sgabeblack@google.com
17512853Sgabeblack@google.com    // assignment operators
17612853Sgabeblack@google.com    sc_ufix &operator = (const sc_ufix &);
17712853Sgabeblack@google.com
17812853Sgabeblack@google.com#define DECL_ASN_OP_T(op,tp) sc_ufix &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_ufix &)
21312853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_ufix_fast &)
21412853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_ufix &)
21512853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_ufix_fast &)
21612853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_ufix &)
21712853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_ufix_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_ufix& operator ++ ();
22812853Sgabeblack@google.com    sc_ufix& operator -- ();
22912853Sgabeblack@google.com};
23012853Sgabeblack@google.com
23112853Sgabeblack@google.com
23212853Sgabeblack@google.com// ----------------------------------------------------------------------------
23312853Sgabeblack@google.com//  CLASS : sc_ufix_fast
23412853Sgabeblack@google.com//
23512853Sgabeblack@google.com//  "Unconstrained" unsigned fixed-point class; limited precision.
23612853Sgabeblack@google.com// ----------------------------------------------------------------------------
23712853Sgabeblack@google.com
23812853Sgabeblack@google.comclass sc_ufix_fast : public sc_fxnum_fast
23912853Sgabeblack@google.com{
24012853Sgabeblack@google.com  public:
24112853Sgabeblack@google.com    // constructors
24212853Sgabeblack@google.com    explicit sc_ufix_fast(sc_fxnum_fast_observer * =0);
24312853Sgabeblack@google.com    sc_ufix_fast(int, int, sc_fxnum_fast_observer * =0);
24412853Sgabeblack@google.com    sc_ufix_fast(sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
24512853Sgabeblack@google.com    sc_ufix_fast(sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0);
24612853Sgabeblack@google.com    sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0);
24712853Sgabeblack@google.com    sc_ufix_fast(int, int, sc_q_mode, sc_o_mode, int,
24812853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0);
24912853Sgabeblack@google.com    explicit sc_ufix_fast(const sc_fxcast_switch &,
25012853Sgabeblack@google.com                          sc_fxnum_fast_observer * =0);
25112853Sgabeblack@google.com    sc_ufix_fast(int, int, const sc_fxcast_switch &,
25212853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0);
25312853Sgabeblack@google.com    sc_ufix_fast(sc_q_mode, sc_o_mode, const sc_fxcast_switch &,
25412853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0);
25512853Sgabeblack@google.com    sc_ufix_fast(sc_q_mode, sc_o_mode, int, const sc_fxcast_switch&,
25612853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0);
25712853Sgabeblack@google.com    sc_ufix_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_ufix_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_ufix_fast(const sc_fxtype_params &,
26212853Sgabeblack@google.com                          sc_fxnum_fast_observer * =0);
26312853Sgabeblack@google.com    sc_ufix_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_ufix_fast(tp, int, int, sc_fxnum_fast_observer * =0); \
26812853Sgabeblack@google.com    sc_ufix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * =0); \
26912853Sgabeblack@google.com    sc_ufix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * =0); \
27012853Sgabeblack@google.com    sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
27112853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0); \
27212853Sgabeblack@google.com    sc_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
27312853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0); \
27412853Sgabeblack@google.com    sc_ufix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
27512853Sgabeblack@google.com    sc_ufix_fast(tp, int, int, const sc_fxcast_switch &, \
27612853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0); \
27712853Sgabeblack@google.com    sc_ufix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
27812853Sgabeblack@google.com                 sc_fxnum_fast_observer * =0); \
27912853Sgabeblack@google.com    sc_ufix_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_ufix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
28212853Sgabeblack@google.com                 const sc_fxcast_switch &, sc_fxnum_fast_observer * =0); \
28312853Sgabeblack@google.com    sc_ufix_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_ufix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * =0); \
28612853Sgabeblack@google.com    sc_ufix_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_ufix_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_ufix_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_ufix_fast(const sc_ufix_fast &);
32212853Sgabeblack@google.com
32312853Sgabeblack@google.com    // unary bitwise operators
32412853Sgabeblack@google.com    const sc_ufix_fast operator ~ () const;
32512853Sgabeblack@google.com
32612853Sgabeblack@google.com    // unary bitwise functions
32712853Sgabeblack@google.com    friend void b_not(sc_ufix_fast &, const sc_ufix_fast &);
32812853Sgabeblack@google.com
32912853Sgabeblack@google.com
33012853Sgabeblack@google.com    // binary bitwise operators
33112853Sgabeblack@google.com
33212853Sgabeblack@google.com    friend const sc_ufix_fast operator & (const sc_ufix_fast &,
33312853Sgabeblack@google.com                                          const sc_ufix_fast &);
33412853Sgabeblack@google.com    friend const sc_ufix_fast operator ^ (const sc_ufix_fast &,
33512853Sgabeblack@google.com                                          const sc_ufix_fast &);
33612853Sgabeblack@google.com    friend const sc_ufix_fast operator | (const sc_ufix_fast &,
33712853Sgabeblack@google.com                                          const sc_ufix_fast &);
33812853Sgabeblack@google.com
33912853Sgabeblack@google.com
34012853Sgabeblack@google.com    // binary bitwise functions
34112853Sgabeblack@google.com
34212853Sgabeblack@google.com    friend void b_and(sc_ufix_fast &, const sc_ufix_fast &,
34312853Sgabeblack@google.com                                      const sc_ufix_fast &);
34412853Sgabeblack@google.com    friend void b_or(sc_ufix_fast &, const sc_ufix_fast &,
34512853Sgabeblack@google.com                                     const sc_ufix_fast &);
34612853Sgabeblack@google.com    friend void b_xor(sc_ufix_fast &, const sc_ufix_fast &,
34712853Sgabeblack@google.com                                      const sc_ufix_fast &);
34812853Sgabeblack@google.com
34912853Sgabeblack@google.com    // assignment operators
35012853Sgabeblack@google.com    sc_ufix_fast &operator = (const sc_ufix_fast &);
35112853Sgabeblack@google.com
35212853Sgabeblack@google.com#define DECL_ASN_OP_T(op,tp) sc_ufix_fast &operator op (tp);
35312853Sgabeblack@google.com
35412853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \
35512853Sgabeblack@google.com    DECL_ASN_OP_T(op, int64) \
35612853Sgabeblack@google.com    DECL_ASN_OP_T(op, uint64) \
35712853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_int_base &) \
35812853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_uint_base &) \
35912853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_signed &) \
36012853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_unsigned &)
36112853Sgabeblack@google.com
36212853Sgabeblack@google.com#define DECL_ASN_OP(op) \
36312853Sgabeblack@google.com    DECL_ASN_OP_T(op, int) \
36412853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned int) \
36512853Sgabeblack@google.com    DECL_ASN_OP_T(op, long) \
36612853Sgabeblack@google.com    DECL_ASN_OP_T(op, unsigned long) \
36712853Sgabeblack@google.com    DECL_ASN_OP_T(op, float) \
36812853Sgabeblack@google.com    DECL_ASN_OP_T(op, double) \
36912853Sgabeblack@google.com    DECL_ASN_OP_T(op, const char *) \
37012853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval &) \
37112853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxval_fast &) \
37212853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum &) \
37312853Sgabeblack@google.com    DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
37412853Sgabeblack@google.com    DECL_ASN_OP_OTHER(op)
37512853Sgabeblack@google.com
37612853Sgabeblack@google.com    DECL_ASN_OP(=)
37712853Sgabeblack@google.com
37812853Sgabeblack@google.com    DECL_ASN_OP(*=)
37912853Sgabeblack@google.com    DECL_ASN_OP(/=)
38012853Sgabeblack@google.com    DECL_ASN_OP(+=)
38112853Sgabeblack@google.com    DECL_ASN_OP(-=)
38212853Sgabeblack@google.com
38312853Sgabeblack@google.com    DECL_ASN_OP_T(<<=, int)
38412853Sgabeblack@google.com    DECL_ASN_OP_T(>>=, int)
38512853Sgabeblack@google.com
38612853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_ufix &)
38712853Sgabeblack@google.com    DECL_ASN_OP_T(&=, const sc_ufix_fast &)
38812853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_ufix &)
38912853Sgabeblack@google.com    DECL_ASN_OP_T(|=, const sc_ufix_fast &)
39012853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_ufix &)
39112853Sgabeblack@google.com    DECL_ASN_OP_T(^=, const sc_ufix_fast &)
39212853Sgabeblack@google.com
39312853Sgabeblack@google.com#undef DECL_ASN_OP_T
39412853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER
39512853Sgabeblack@google.com#undef DECL_ASN_OP
39612853Sgabeblack@google.com
39712853Sgabeblack@google.com    // auto-increment and auto-decrement
39812853Sgabeblack@google.com    const sc_fxval_fast operator ++ (int);
39912853Sgabeblack@google.com    const sc_fxval_fast operator -- (int);
40012853Sgabeblack@google.com
40112853Sgabeblack@google.com    sc_ufix_fast &operator ++ ();
40212853Sgabeblack@google.com    sc_ufix_fast &operator -- ();
40312853Sgabeblack@google.com};
40412853Sgabeblack@google.com
40512853Sgabeblack@google.com
40612853Sgabeblack@google.com// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
40712853Sgabeblack@google.com
40812853Sgabeblack@google.com// ----------------------------------------------------------------------------
40912853Sgabeblack@google.com//  CLASS : sc_ufix
41012853Sgabeblack@google.com//
41112853Sgabeblack@google.com//  "Unconstrained" unsigned fixed-point class; arbitrary precision.
41212853Sgabeblack@google.com// ----------------------------------------------------------------------------
41312853Sgabeblack@google.com
41412853Sgabeblack@google.com// constructors
41512853Sgabeblack@google.com
41612853Sgabeblack@google.cominline sc_ufix::sc_ufix(sc_fxnum_observer *observer_) :
41712853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(), SC_US_, sc_fxcast_switch(), observer_)
41812853Sgabeblack@google.com{}
41912853Sgabeblack@google.com
42012853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, sc_fxnum_observer *observer_ ) :
42112853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(),
42212853Sgabeblack@google.com                 observer_)
42312853Sgabeblack@google.com{}
42412853Sgabeblack@google.com
42512853Sgabeblack@google.cominline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
42612853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
42712853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(),
42812853Sgabeblack@google.com                 observer_)
42912853Sgabeblack@google.com{}
43012853Sgabeblack@google.com
43112853Sgabeblack@google.cominline
43212853Sgabeblack@google.comsc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
43312853Sgabeblack@google.com                 sc_fxnum_observer *observer_) :
43412853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(),
43512853Sgabeblack@google.com                 observer_)
43612853Sgabeblack@google.com{}
43712853Sgabeblack@google.com
43812853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
43912853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
44012853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
44112853Sgabeblack@google.com                 sc_fxcast_switch(), observer_)
44212853Sgabeblack@google.com{}
44312853Sgabeblack@google.com
44412853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
44512853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
44612853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
44712853Sgabeblack@google.com                 sc_fxcast_switch(), observer_)
44812853Sgabeblack@google.com{}
44912853Sgabeblack@google.com
45012853Sgabeblack@google.cominline sc_ufix::sc_ufix(const sc_fxcast_switch &cast_sw,
45112853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
45212853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(), SC_US_, cast_sw, observer_)
45312853Sgabeblack@google.com{}
45412853Sgabeblack@google.com
45512853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
45612853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
45712853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
45812853Sgabeblack@google.com{}
45912853Sgabeblack@google.com
46012853Sgabeblack@google.cominline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om,
46112853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw,
46212853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
46312853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
46412853Sgabeblack@google.com{}
46512853Sgabeblack@google.com
46612853Sgabeblack@google.cominline sc_ufix::sc_ufix(sc_q_mode qm, sc_o_mode om, int nb,
46712853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw,
46812853Sgabeblack@google.com                        sc_fxnum_observer *observer_ ) :
46912853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
47012853Sgabeblack@google.com{}
47112853Sgabeblack@google.com
47212853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
47312853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw,
47412853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
47512853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
47612853Sgabeblack@google.com                 observer_)
47712853Sgabeblack@google.com{}
47812853Sgabeblack@google.com
47912853Sgabeblack@google.cominline sc_ufix::sc_ufix(int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
48012853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw,
48112853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
48212853Sgabeblack@google.com        sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
48312853Sgabeblack@google.com                 observer_)
48412853Sgabeblack@google.com{}
48512853Sgabeblack@google.com
48612853Sgabeblack@google.cominline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
48712853Sgabeblack@google.com                        sc_fxnum_observer *observer_) :
48812853Sgabeblack@google.com        sc_fxnum(type_params_, SC_US_, sc_fxcast_switch(), observer_)
48912853Sgabeblack@google.com{}
49012853Sgabeblack@google.com
49112853Sgabeblack@google.cominline sc_ufix::sc_ufix(const sc_fxtype_params &type_params_,
49212853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw,
49312853Sgabeblack@google.com                        sc_fxnum_observer *observer_ ) :
49412853Sgabeblack@google.com        sc_fxnum(type_params_, SC_US_, cast_sw, observer_)
49512853Sgabeblack@google.com{}
49612853Sgabeblack@google.com
49712853Sgabeblack@google.com#define DEFN_CTORS_T_A(tp) \
49812853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_ ) : \
49912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
50012853Sgabeblack@google.com                 observer_) \
50112853Sgabeblack@google.com{} \
50212853Sgabeblack@google.com \
50312853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
50412853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
50512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
50612853Sgabeblack@google.com                 observer_ ) \
50712853Sgabeblack@google.com{} \
50812853Sgabeblack@google.com \
50912853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
51012853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
51112853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
51212853Sgabeblack@google.com                 observer_ ) \
51312853Sgabeblack@google.com{} \
51412853Sgabeblack@google.com \
51512853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
51612853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
51712853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(), \
51812853Sgabeblack@google.com                 observer_ ) \
51912853Sgabeblack@google.com{} \
52012853Sgabeblack@google.com \
52112853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
52212853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
52312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
52412853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
52512853Sgabeblack@google.com{} \
52612853Sgabeblack@google.com \
52712853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
52812853Sgabeblack@google.com                        int nb, sc_fxnum_observer *observer_) : \
52912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
53012853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
53112853Sgabeblack@google.com{} \
53212853Sgabeblack@google.com \
53312853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch &cast_sw, \
53412853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
53512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
53612853Sgabeblack@google.com{} \
53712853Sgabeblack@google.com \
53812853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
53912853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
54012853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
54112853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
54212853Sgabeblack@google.com{} \
54312853Sgabeblack@google.com \
54412853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
54512853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
54612853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
54712853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
54812853Sgabeblack@google.com{} \
54912853Sgabeblack@google.com \
55012853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
55112853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
55212853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
55312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_) \
55412853Sgabeblack@google.com{} \
55512853Sgabeblack@google.com \
55612853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
55712853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
55812853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
55912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
56012853Sgabeblack@google.com                 observer_) \
56112853Sgabeblack@google.com{} \
56212853Sgabeblack@google.com \
56312853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
56412853Sgabeblack@google.com                        int nb, const sc_fxcast_switch &cast_sw, \
56512853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
56612853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
56712853Sgabeblack@google.com                 observer_) \
56812853Sgabeblack@google.com{} \
56912853Sgabeblack@google.com \
57012853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
57112853Sgabeblack@google.com                        sc_fxnum_observer * observer_) : \
57212853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
57312853Sgabeblack@google.com{} \
57412853Sgabeblack@google.com \
57512853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
57612853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
57712853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
57812853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
57912853Sgabeblack@google.com{}
58012853Sgabeblack@google.com
58112853Sgabeblack@google.com#define DEFN_CTORS_T_B(tp) \
58212853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_fxnum_observer *observer_) : \
58312853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
58412853Sgabeblack@google.com{} \
58512853Sgabeblack@google.com \
58612853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
58712853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
58812853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
58912853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
59012853Sgabeblack@google.com{} \
59112853Sgabeblack@google.com \
59212853Sgabeblack@google.cominline \
59312853Sgabeblack@google.comsc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
59412853Sgabeblack@google.com                 sc_fxnum_observer *observer_) : \
59512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
59612853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
59712853Sgabeblack@google.com{} \
59812853Sgabeblack@google.com \
59912853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
60012853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
60112853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
60212853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
60312853Sgabeblack@google.com{} \
60412853Sgabeblack@google.com \
60512853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
60612853Sgabeblack@google.com                        sc_fxnum_observer* observer_) : \
60712853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
60812853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
60912853Sgabeblack@google.com{} \
61012853Sgabeblack@google.com \
61112853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
61212853Sgabeblack@google.com                        int nb, sc_fxnum_observer *observer_) : \
61312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
61412853Sgabeblack@google.com                 sc_fxcast_switch(), observer_) \
61512853Sgabeblack@google.com{} \
61612853Sgabeblack@google.com \
61712853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxcast_switch& cast_sw, \
61812853Sgabeblack@google.com                        sc_fxnum_observer* observer_) : \
61912853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_US_, cast_sw, observer_) \
62012853Sgabeblack@google.com{} \
62112853Sgabeblack@google.com \
62212853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, \
62312853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
62412853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
62512853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
62612853Sgabeblack@google.com                 cast_sw, observer_) \
62712853Sgabeblack@google.com{} \
62812853Sgabeblack@google.com \
62912853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, \
63012853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
63112853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
63212853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
63312853Sgabeblack@google.com                 cast_sw, observer_) \
63412853Sgabeblack@google.com{} \
63512853Sgabeblack@google.com \
63612853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
63712853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
63812853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
63912853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
64012853Sgabeblack@google.com                 cast_sw, observer_) \
64112853Sgabeblack@google.com{} \
64212853Sgabeblack@google.com \
64312853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
64412853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
64512853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
64612853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
64712853Sgabeblack@google.com                 observer_) \
64812853Sgabeblack@google.com{} \
64912853Sgabeblack@google.com \
65012853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
65112853Sgabeblack@google.com                        int nb, const sc_fxcast_switch &cast_sw, \
65212853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
65312853Sgabeblack@google.com        sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw, \
65412853Sgabeblack@google.com                 observer_) \
65512853Sgabeblack@google.com{} \
65612853Sgabeblack@google.com \
65712853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxtype_params &type_params_, \
65812853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
65912853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
66012853Sgabeblack@google.com{} \
66112853Sgabeblack@google.com \
66212853Sgabeblack@google.cominline sc_ufix::sc_ufix(tp a, const sc_fxtype_params& type_params_, \
66312853Sgabeblack@google.com                        const sc_fxcast_switch &cast_sw, \
66412853Sgabeblack@google.com                        sc_fxnum_observer *observer_) : \
66512853Sgabeblack@google.com        sc_fxnum(a, type_params_, SC_US_, cast_sw, observer_) \
66612853Sgabeblack@google.com{}
66712853Sgabeblack@google.com
66812853Sgabeblack@google.comDEFN_CTORS_T_A(int)
66912853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned int)
67012853Sgabeblack@google.comDEFN_CTORS_T_A(long)
67112853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned long)
67212853Sgabeblack@google.comDEFN_CTORS_T_A(float)
67312853Sgabeblack@google.comDEFN_CTORS_T_A(double)
67412853Sgabeblack@google.comDEFN_CTORS_T_A(const char *)
67512853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval &)
67612853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval_fast &)
67712853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum &)
67812853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum_fast &)
67912853Sgabeblack@google.com
68012853Sgabeblack@google.comDEFN_CTORS_T_A(int64)
68112853Sgabeblack@google.comDEFN_CTORS_T_A(uint64)
68212853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_int_base &)
68312853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_uint_base &)
68412853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_signed &)
68512853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_unsigned &)
68612853Sgabeblack@google.com
68712853Sgabeblack@google.com#undef DEFN_CTORS_T_A
68812853Sgabeblack@google.com#undef DEFN_CTORS_T_B
68912853Sgabeblack@google.com
69012853Sgabeblack@google.com// copy constructor
69112853Sgabeblack@google.com
69212853Sgabeblack@google.cominline sc_ufix::sc_ufix(const sc_ufix &a) :
69312853Sgabeblack@google.com        sc_fxnum(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
69412853Sgabeblack@google.com{}
69512853Sgabeblack@google.com
69612853Sgabeblack@google.com// unary bitwise operators
69712853Sgabeblack@google.cominline const sc_ufix
69812853Sgabeblack@google.comsc_ufix::operator ~ () const
69912853Sgabeblack@google.com{
70012853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(*this)
70112853Sgabeblack@google.com    int iwl_c = iwl();
70212853Sgabeblack@google.com    int wl_c = wl();
70312853Sgabeblack@google.com    sc_ufix c(wl_c, iwl_c);
70412853Sgabeblack@google.com    for (int i = iwl_c - wl_c; i < iwl_c; ++i)
70512853Sgabeblack@google.com        c.set_bit(i, !get_bit(i));
70612853Sgabeblack@google.com    return sc_ufix(c, wl_c, iwl_c);
70712853Sgabeblack@google.com}
70812853Sgabeblack@google.com
70912853Sgabeblack@google.com// unary bitwise functions
71012853Sgabeblack@google.cominline void
71112853Sgabeblack@google.comb_not(sc_ufix &c, const sc_ufix &a)
71212853Sgabeblack@google.com{
71312853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(a)
71412853Sgabeblack@google.com    int iwl_c = c.iwl();
71512853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
71612853Sgabeblack@google.com        c.set_bit(i, !a.get_bit(i));
71712853Sgabeblack@google.com    c.cast();
71812853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(c)
71912853Sgabeblack@google.com}
72012853Sgabeblack@google.com
72112853Sgabeblack@google.com// binary bitwise operators
72212853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
72312853Sgabeblack@google.cominline const sc_ufix \
72412853Sgabeblack@google.comoperator op (const tp1 &a, const tp2 &b) \
72512853Sgabeblack@google.com{ \
72612853Sgabeblack@google.com    a.observer_read(); \
72712853Sgabeblack@google.com    b.observer_read(); \
72812853Sgabeblack@google.com    int iwl_a = a.iwl(); \
72912853Sgabeblack@google.com    int iwl_b = b.iwl(); \
73012853Sgabeblack@google.com    int iwl_c = sc_max(iwl_a, iwl_b); \
73112853Sgabeblack@google.com    int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
73212853Sgabeblack@google.com    sc_ufix c(iwl_c + fwl_c, iwl_c); \
73312853Sgabeblack@google.com    for (int i = -fwl_c; i < iwl_c; ++i) \
73412853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
73512853Sgabeblack@google.com    return sc_ufix(c, iwl_c + fwl_c, iwl_c); \
73612853Sgabeblack@google.com}
73712853Sgabeblack@google.com
73812853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_ufix, sc_ufix)
73912853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_ufix, sc_ufix_fast)
74012853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_ufix_fast, sc_ufix)
74112853Sgabeblack@google.com
74212853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_ufix, sc_ufix)
74312853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_ufix, sc_ufix_fast)
74412853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_ufix_fast, sc_ufix)
74512853Sgabeblack@google.com
74612853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_ufix, sc_ufix)
74712853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_ufix, sc_ufix_fast)
74812853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_ufix_fast, sc_ufix)
74912853Sgabeblack@google.com
75012853Sgabeblack@google.com#undef DEFN_BIN_OP_T
75112853Sgabeblack@google.com
75212853Sgabeblack@google.com// binary bitwise functions
75312853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
75412853Sgabeblack@google.cominline void \
75512853Sgabeblack@google.comfnc (sc_ufix &c, const tp1 &a, const tp2 &b) \
75612853Sgabeblack@google.com{ \
75712853Sgabeblack@google.com    a.observer_read(); \
75812853Sgabeblack@google.com    b.observer_read(); \
75912853Sgabeblack@google.com    int iwl_c = c.iwl(); \
76012853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
76112853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
76212853Sgabeblack@google.com    c.cast(); \
76312853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(c) \
76412853Sgabeblack@google.com}
76512853Sgabeblack@google.com
76612853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_ufix, sc_ufix)
76712853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_ufix, sc_ufix_fast)
76812853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_ufix_fast, sc_ufix)
76912853Sgabeblack@google.com
77012853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_ufix, sc_ufix)
77112853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_ufix, sc_ufix_fast)
77212853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_ufix_fast, sc_ufix)
77312853Sgabeblack@google.com
77412853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_ufix, sc_ufix)
77512853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_ufix, sc_ufix_fast)
77612853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_ufix_fast, sc_ufix)
77712853Sgabeblack@google.com
77812853Sgabeblack@google.com#undef DEFN_BIN_FNC_T
77912853Sgabeblack@google.com
78012853Sgabeblack@google.com// assignment operators
78112853Sgabeblack@google.cominline sc_ufix &
78212853Sgabeblack@google.comsc_ufix::operator = (const sc_ufix &a)
78312853Sgabeblack@google.com{
78412853Sgabeblack@google.com    sc_fxnum::operator = (a);
78512853Sgabeblack@google.com    return *this;
78612853Sgabeblack@google.com}
78712853Sgabeblack@google.com
78812853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \
78912853Sgabeblack@google.cominline sc_ufix & \
79012853Sgabeblack@google.comsc_ufix::operator op (tp a) \
79112853Sgabeblack@google.com{ \
79212853Sgabeblack@google.com    sc_fxnum::operator op(a); \
79312853Sgabeblack@google.com    return *this; \
79412853Sgabeblack@google.com}
79512853Sgabeblack@google.com
79612853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \
79712853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \
79812853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \
79912853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \
80012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \
80112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \
80212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &)
80312853Sgabeblack@google.com
80412853Sgabeblack@google.com#define DEFN_ASN_OP(op) \
80512853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \
80612853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \
80712853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \
80812853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \
80912853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \
81012853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \
81112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \
81212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \
81312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \
81412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \
81512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
81612853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op)
81712853Sgabeblack@google.com
81812853Sgabeblack@google.comDEFN_ASN_OP(=)
81912853Sgabeblack@google.com
82012853Sgabeblack@google.comDEFN_ASN_OP(*=)
82112853Sgabeblack@google.comDEFN_ASN_OP(/=)
82212853Sgabeblack@google.comDEFN_ASN_OP(+=)
82312853Sgabeblack@google.comDEFN_ASN_OP(-=)
82412853Sgabeblack@google.com
82512853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int)
82612853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int)
82712853Sgabeblack@google.com
82812853Sgabeblack@google.com#undef DEFN_ASN_OP_T
82912853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER
83012853Sgabeblack@google.com#undef DEFN_ASN_OP
83112853Sgabeblack@google.com
83212853Sgabeblack@google.com
83312853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, op2, tp) \
83412853Sgabeblack@google.cominline sc_ufix & \
83512853Sgabeblack@google.comsc_ufix::operator op (const tp &b) \
83612853Sgabeblack@google.com{ \
83712853Sgabeblack@google.com    SC_FXNUM_OBSERVER_READ_(*this) \
83812853Sgabeblack@google.com    b.observer_read(); \
83912853Sgabeblack@google.com    int iwl_c = iwl(); \
84012853Sgabeblack@google.com    for (int i = iwl_c - wl(); i < iwl_c; ++i) \
84112853Sgabeblack@google.com        set_bit(i, get_bit(i) op2 b.get_bit(i)); \
84212853Sgabeblack@google.com    cast(); \
84312853Sgabeblack@google.com    SC_FXNUM_OBSERVER_WRITE_(*this) \
84412853Sgabeblack@google.com    return *this; \
84512853Sgabeblack@google.com}
84612853Sgabeblack@google.com
84712853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_ufix)
84812853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_ufix_fast)
84912853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_ufix)
85012853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_ufix_fast)
85112853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_ufix)
85212853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_ufix_fast)
85312853Sgabeblack@google.com
85412853Sgabeblack@google.com#undef DEFN_ASN_OP_T
85512853Sgabeblack@google.com
85612853Sgabeblack@google.com// auto-increment and auto-decrement
85712853Sgabeblack@google.cominline const sc_fxval
85812853Sgabeblack@google.comsc_ufix::operator ++ (int)
85912853Sgabeblack@google.com{
86012853Sgabeblack@google.com    return sc_fxval(sc_fxnum::operator ++ (0));
86112853Sgabeblack@google.com}
86212853Sgabeblack@google.com
86312853Sgabeblack@google.cominline const sc_fxval
86412853Sgabeblack@google.comsc_ufix::operator -- (int)
86512853Sgabeblack@google.com{
86612853Sgabeblack@google.com    return sc_fxval(sc_fxnum::operator -- (0));
86712853Sgabeblack@google.com}
86812853Sgabeblack@google.com
86912853Sgabeblack@google.cominline sc_ufix &
87012853Sgabeblack@google.comsc_ufix::operator ++ ()
87112853Sgabeblack@google.com{
87212853Sgabeblack@google.com    sc_fxnum::operator ++ ();
87312853Sgabeblack@google.com    return *this;
87412853Sgabeblack@google.com}
87512853Sgabeblack@google.com
87612853Sgabeblack@google.cominline sc_ufix &
87712853Sgabeblack@google.comsc_ufix::operator -- ()
87812853Sgabeblack@google.com{
87912853Sgabeblack@google.com    sc_fxnum::operator -- ();
88012853Sgabeblack@google.com    return *this;
88112853Sgabeblack@google.com}
88212853Sgabeblack@google.com
88312853Sgabeblack@google.com
88412853Sgabeblack@google.com// ----------------------------------------------------------------------------
88512853Sgabeblack@google.com//  CLASS : sc_ufix_fast
88612853Sgabeblack@google.com//
88712853Sgabeblack@google.com//  "Unconstrained" unsigned fixed-point class; limited precision.
88812853Sgabeblack@google.com// ----------------------------------------------------------------------------
88912853Sgabeblack@google.com
89012853Sgabeblack@google.com// constructors
89112853Sgabeblack@google.com
89212853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(sc_fxnum_fast_observer *observer_) :
89312853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(), SC_US_, sc_fxcast_switch(),
89412853Sgabeblack@google.com                      observer_)
89512853Sgabeblack@google.com{}
89612853Sgabeblack@google.com
89712853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(int wl_, int iwl_,
89812853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
89912853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(),
90012853Sgabeblack@google.com                      observer_ )
90112853Sgabeblack@google.com{}
90212853Sgabeblack@google.com
90312853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(sc_q_mode qm, sc_o_mode om,
90412853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
90512853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(),
90612853Sgabeblack@google.com                      observer_ )
90712853Sgabeblack@google.com{}
90812853Sgabeblack@google.com
90912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(sc_q_mode qm, sc_o_mode om, int nb,
91012853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
91112853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_US_, sc_fxcast_switch(),
91212853Sgabeblack@google.com                      observer_ )
91312853Sgabeblack@google.com{}
91412853Sgabeblack@google.com
91512853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
91612853Sgabeblack@google.com        int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
91712853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) :
91812853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_,
91912853Sgabeblack@google.com                  sc_fxcast_switch(), observer_)
92012853Sgabeblack@google.com{}
92112853Sgabeblack@google.com
92212853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
92312853Sgabeblack@google.com        int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
92412853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) :
92512853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_,
92612853Sgabeblack@google.com                  sc_fxcast_switch(), observer_)
92712853Sgabeblack@google.com{}
92812853Sgabeblack@google.com
92912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(const sc_fxcast_switch &cast_sw,
93012853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
93112853Sgabeblack@google.com        sc_fxnum_fast(sc_fxtype_params(), SC_US_, cast_sw, observer_)
93212853Sgabeblack@google.com{}
93312853Sgabeblack@google.com
93412853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
93512853Sgabeblack@google.com        int wl_, int iwl_, const sc_fxcast_switch &cast_sw,
93612853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) :
93712853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_)
93812853Sgabeblack@google.com{}
93912853Sgabeblack@google.com
94012853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
94112853Sgabeblack@google.com        sc_q_mode qm, sc_o_mode om, const sc_fxcast_switch &cast_sw,
94212853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) :
94312853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_)
94412853Sgabeblack@google.com{}
94512853Sgabeblack@google.com
94612853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
94712853Sgabeblack@google.com        sc_q_mode qm, sc_o_mode om, int nb, const sc_fxcast_switch &cast_sw,
94812853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) :
94912853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, observer_)
95012853Sgabeblack@google.com{}
95112853Sgabeblack@google.com
95212853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
95312853Sgabeblack@google.com        int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
95412853Sgabeblack@google.com        const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
95512853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw,
95612853Sgabeblack@google.com                  observer_ )
95712853Sgabeblack@google.com{}
95812853Sgabeblack@google.com
95912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(
96012853Sgabeblack@google.com        int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
96112853Sgabeblack@google.com        const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) :
96212853Sgabeblack@google.com    sc_fxnum_fast(sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, cast_sw,
96312853Sgabeblack@google.com                  observer_)
96412853Sgabeblack@google.com{}
96512853Sgabeblack@google.com
96612853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
96712853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
96812853Sgabeblack@google.com    sc_fxnum_fast(type_params_, SC_US_, sc_fxcast_switch(), observer_)
96912853Sgabeblack@google.com{}
97012853Sgabeblack@google.com
97112853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(const sc_fxtype_params &type_params_,
97212853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw,
97312853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) :
97412853Sgabeblack@google.com    sc_fxnum_fast(type_params_, SC_US_, cast_sw, observer_)
97512853Sgabeblack@google.com{}
97612853Sgabeblack@google.com
97712853Sgabeblack@google.com#define DEFN_CTORS_T_A(tp) \
97812853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
97912853Sgabeblack@google.com        sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, sc_fxcast_switch(), \
98012853Sgabeblack@google.com                      observer_) \
98112853Sgabeblack@google.com{} \
98212853Sgabeblack@google.com \
98312853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
98412853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
98512853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, sc_fxcast_switch(), \
98612853Sgabeblack@google.com                  observer_) \
98712853Sgabeblack@google.com{} \
98812853Sgabeblack@google.com \
98912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
99012853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
99112853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, sc_fxcast_switch(), \
99212853Sgabeblack@google.com                  observer_) \
99312853Sgabeblack@google.com{} \
99412853Sgabeblack@google.com \
99512853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
99612853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
99712853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, \
99812853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
99912853Sgabeblack@google.com{} \
100012853Sgabeblack@google.com \
100112853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
100212853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
100312853Sgabeblack@google.com        sc_fxnum_fast_observer* observer_) : \
100412853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
100512853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
100612853Sgabeblack@google.com{} \
100712853Sgabeblack@google.com \
100812853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
100912853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
101012853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) : \
101112853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
101212853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
101312853Sgabeblack@google.com{} \
101412853Sgabeblack@google.com \
101512853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
101612853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
101712853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(), SC_US_, cast_sw, observer_) \
101812853Sgabeblack@google.com{} \
101912853Sgabeblack@google.com \
102012853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
102112853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
102212853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
102312853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_US_, cast_sw, observer_) \
102412853Sgabeblack@google.com{} \
102512853Sgabeblack@google.com \
102612853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
102712853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
102812853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
102912853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_US_, cast_sw, observer_) \
103012853Sgabeblack@google.com{} \
103112853Sgabeblack@google.com \
103212853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
103312853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
103412853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
103512853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_US_, cast_sw, \
103612853Sgabeblack@google.com                  observer_) \
103712853Sgabeblack@google.com{} \
103812853Sgabeblack@google.com \
103912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
104012853Sgabeblack@google.com                                  sc_q_mode qm, sc_o_mode om, \
104112853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
104212853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
104312853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
104412853Sgabeblack@google.com                  observer_) \
104512853Sgabeblack@google.com{} \
104612853Sgabeblack@google.com \
104712853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
104812853Sgabeblack@google.com                                  sc_q_mode qm, sc_o_mode om, int nb, \
104912853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
105012853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
105112853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
105212853Sgabeblack@google.com                  cast_sw, observer_) \
105312853Sgabeblack@google.com{} \
105412853Sgabeblack@google.com \
105512853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
105612853Sgabeblack@google.com        tp a, const sc_fxtype_params &type_params_, \
105712853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) : \
105812853Sgabeblack@google.com    sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
105912853Sgabeblack@google.com{} \
106012853Sgabeblack@google.com \
106112853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
106212853Sgabeblack@google.com        tp a, const sc_fxtype_params &type_params_, \
106312853Sgabeblack@google.com        const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
106412853Sgabeblack@google.com    sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
106512853Sgabeblack@google.com{}
106612853Sgabeblack@google.com
106712853Sgabeblack@google.com#define DEFN_CTORS_T_B(tp) \
106812853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
106912853Sgabeblack@google.com    sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), observer_) \
107012853Sgabeblack@google.com{} \
107112853Sgabeblack@google.com \
107212853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, int wl_, int iwl_, \
107312853Sgabeblack@google.com                                  sc_fxnum_fast_observer* observer_) : \
107412853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
107512853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
107612853Sgabeblack@google.com{} \
107712853Sgabeblack@google.com \
107812853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
107912853Sgabeblack@google.com                                  sc_fxnum_fast_observer* observer_) : \
108012853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
108112853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
108212853Sgabeblack@google.com{} \
108312853Sgabeblack@google.com \
108412853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
108512853Sgabeblack@google.com                                  sc_fxnum_fast_observer* observer_) : \
108612853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
108712853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
108812853Sgabeblack@google.com{} \
108912853Sgabeblack@google.com \
109012853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
109112853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
109212853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) : \
109312853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, \
109412853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
109512853Sgabeblack@google.com{} \
109612853Sgabeblack@google.com \
109712853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
109812853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
109912853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) : \
110012853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
110112853Sgabeblack@google.com                  sc_fxcast_switch(), observer_) \
110212853Sgabeblack@google.com{} \
110312853Sgabeblack@google.com \
110412853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxcast_switch &cast_sw, \
110512853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
110612853Sgabeblack@google.com    sc_fxnum_fast(a, a.type_params(), SC_US_, cast_sw, observer_) \
110712853Sgabeblack@google.com{} \
110812853Sgabeblack@google.com \
110912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
111012853Sgabeblack@google.com        tp a, int wl_, int iwl_, const sc_fxcast_switch &cast_sw, \
111112853Sgabeblack@google.com        sc_fxnum_fast_observer *observer_) : \
111212853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_US_, \
111312853Sgabeblack@google.com                  cast_sw, observer_) \
111412853Sgabeblack@google.com{} \
111512853Sgabeblack@google.com \
111612853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
111712853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
111812853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
111912853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_US_, \
112012853Sgabeblack@google.com                  cast_sw, observer_) \
112112853Sgabeblack@google.com{} \
112212853Sgabeblack@google.com \
112312853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
112412853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
112512853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
112612853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_US_, \
112712853Sgabeblack@google.com                  cast_sw, observer_) \
112812853Sgabeblack@google.com{} \
112912853Sgabeblack@google.com \
113012853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
113112853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
113212853Sgabeblack@google.com        const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
113312853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_US_, cast_sw, \
113412853Sgabeblack@google.com                  observer_) \
113512853Sgabeblack@google.com{} \
113612853Sgabeblack@google.com \
113712853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast( \
113812853Sgabeblack@google.com        tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb, \
113912853Sgabeblack@google.com        const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : \
114012853Sgabeblack@google.com    sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_US_, \
114112853Sgabeblack@google.com                  cast_sw, observer_) \
114212853Sgabeblack@google.com{} \
114312853Sgabeblack@google.com \
114412853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
114512853Sgabeblack@google.com                                  sc_fxnum_fast_observer *observer_) : \
114612853Sgabeblack@google.com    sc_fxnum_fast(a, type_params_, SC_US_, sc_fxcast_switch(), observer_) \
114712853Sgabeblack@google.com{} \
114812853Sgabeblack@google.com \
114912853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(tp a, const sc_fxtype_params &type_params_, \
115012853Sgabeblack@google.com                                  const sc_fxcast_switch &cast_sw, \
115112853Sgabeblack@google.com                                  sc_fxnum_fast_observer* observer_) : \
115212853Sgabeblack@google.com    sc_fxnum_fast(a, type_params_, SC_US_, cast_sw, observer_) \
115312853Sgabeblack@google.com{}
115412853Sgabeblack@google.com
115512853Sgabeblack@google.comDEFN_CTORS_T_A(int)
115612853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned int)
115712853Sgabeblack@google.comDEFN_CTORS_T_A(long)
115812853Sgabeblack@google.comDEFN_CTORS_T_A(unsigned long)
115912853Sgabeblack@google.comDEFN_CTORS_T_A(float)
116012853Sgabeblack@google.comDEFN_CTORS_T_A(double)
116112853Sgabeblack@google.comDEFN_CTORS_T_A(const char *)
116212853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval &)
116312853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_fxval_fast &)
116412853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum &)
116512853Sgabeblack@google.comDEFN_CTORS_T_B(const sc_fxnum_fast &)
116612853Sgabeblack@google.com
116712853Sgabeblack@google.comDEFN_CTORS_T_A(int64)
116812853Sgabeblack@google.comDEFN_CTORS_T_A(uint64)
116912853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_int_base &)
117012853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_uint_base &)
117112853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_signed &)
117212853Sgabeblack@google.comDEFN_CTORS_T_A(const sc_unsigned &)
117312853Sgabeblack@google.com
117412853Sgabeblack@google.com#undef DEFN_CTORS_T_A
117512853Sgabeblack@google.com#undef DEFN_CTORS_T_B
117612853Sgabeblack@google.com
117712853Sgabeblack@google.com// copy constructor
117812853Sgabeblack@google.cominline sc_ufix_fast::sc_ufix_fast(const sc_ufix_fast &a) :
117912853Sgabeblack@google.com    sc_fxnum_fast(a, a.type_params(), SC_US_, sc_fxcast_switch(), 0)
118012853Sgabeblack@google.com{}
118112853Sgabeblack@google.com
118212853Sgabeblack@google.com// unary bitwise operators
118312853Sgabeblack@google.cominline const sc_ufix_fast
118412853Sgabeblack@google.comsc_ufix_fast::operator ~ () const
118512853Sgabeblack@google.com{
118612853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(*this)
118712853Sgabeblack@google.com    int iwl_c = iwl();
118812853Sgabeblack@google.com    int wl_c = wl();
118912853Sgabeblack@google.com    sc_ufix_fast c(wl_c, iwl_c);
119012853Sgabeblack@google.com    for (int i = iwl_c - wl_c; i < iwl_c; ++i)
119112853Sgabeblack@google.com        c.set_bit(i, !get_bit(i));
119212853Sgabeblack@google.com    return sc_ufix_fast(c, wl_c, iwl_c);
119312853Sgabeblack@google.com}
119412853Sgabeblack@google.com
119512853Sgabeblack@google.com// unary bitwise functions
119612853Sgabeblack@google.cominline void
119712853Sgabeblack@google.comb_not(sc_ufix_fast &c, const sc_ufix_fast &a)
119812853Sgabeblack@google.com{
119912853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(a)
120012853Sgabeblack@google.com    int iwl_c = c.iwl();
120112853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i)
120212853Sgabeblack@google.com        c.set_bit(i, !a.get_bit(i));
120312853Sgabeblack@google.com    c.cast();
120412853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(c)
120512853Sgabeblack@google.com}
120612853Sgabeblack@google.com
120712853Sgabeblack@google.com// binary bitwise operators
120812853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
120912853Sgabeblack@google.cominline const sc_ufix_fast \
121012853Sgabeblack@google.comoperator op (const tp1 &a, const tp2 &b) \
121112853Sgabeblack@google.com{ \
121212853Sgabeblack@google.com    a.observer_read(); \
121312853Sgabeblack@google.com    b.observer_read(); \
121412853Sgabeblack@google.com    int iwl_a = a.iwl(); \
121512853Sgabeblack@google.com    int iwl_b = b.iwl(); \
121612853Sgabeblack@google.com    int iwl_c = sc_max(iwl_a, iwl_b); \
121712853Sgabeblack@google.com    int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
121812853Sgabeblack@google.com    sc_ufix_fast c(iwl_c + fwl_c, iwl_c); \
121912853Sgabeblack@google.com    for (int i = -fwl_c; i < iwl_c; ++i) \
122012853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
122112853Sgabeblack@google.com    return sc_ufix_fast(c, iwl_c + fwl_c, iwl_c); \
122212853Sgabeblack@google.com}
122312853Sgabeblack@google.com
122412853Sgabeblack@google.comDEFN_BIN_OP_T(&, &&, sc_ufix_fast, sc_ufix_fast)
122512853Sgabeblack@google.comDEFN_BIN_OP_T(|, ||, sc_ufix_fast, sc_ufix_fast)
122612853Sgabeblack@google.comDEFN_BIN_OP_T(^, !=, sc_ufix_fast, sc_ufix_fast)
122712853Sgabeblack@google.com
122812853Sgabeblack@google.com#undef DEFN_BIN_OP_T
122912853Sgabeblack@google.com
123012853Sgabeblack@google.com// binary bitwise functions
123112853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
123212853Sgabeblack@google.cominline void \
123312853Sgabeblack@google.comfnc (sc_ufix_fast &c, const tp1 &a, const tp2 &b) \
123412853Sgabeblack@google.com{ \
123512853Sgabeblack@google.com    a.observer_read(); \
123612853Sgabeblack@google.com    b.observer_read(); \
123712853Sgabeblack@google.com    int iwl_c = c.iwl(); \
123812853Sgabeblack@google.com    for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
123912853Sgabeblack@google.com        c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
124012853Sgabeblack@google.com    c.cast(); \
124112853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
124212853Sgabeblack@google.com}
124312853Sgabeblack@google.com
124412853Sgabeblack@google.comDEFN_BIN_FNC_T(b_and, &&, sc_ufix_fast, sc_ufix_fast)
124512853Sgabeblack@google.comDEFN_BIN_FNC_T(b_or, ||, sc_ufix_fast, sc_ufix_fast)
124612853Sgabeblack@google.comDEFN_BIN_FNC_T(b_xor, !=, sc_ufix_fast, sc_ufix_fast)
124712853Sgabeblack@google.com
124812853Sgabeblack@google.com#undef DEFN_BIN_FNC_T
124912853Sgabeblack@google.com
125012853Sgabeblack@google.com// assignment operators
125112853Sgabeblack@google.cominline sc_ufix_fast &
125212853Sgabeblack@google.comsc_ufix_fast::operator = (const sc_ufix_fast &a)
125312853Sgabeblack@google.com{
125412853Sgabeblack@google.com    sc_fxnum_fast::operator = (a);
125512853Sgabeblack@google.com    return *this;
125612853Sgabeblack@google.com}
125712853Sgabeblack@google.com
125812853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \
125912853Sgabeblack@google.cominline sc_ufix_fast & \
126012853Sgabeblack@google.comsc_ufix_fast::operator op (tp a) \
126112853Sgabeblack@google.com{ \
126212853Sgabeblack@google.com    sc_fxnum_fast::operator op(a); \
126312853Sgabeblack@google.com    return *this; \
126412853Sgabeblack@google.com}
126512853Sgabeblack@google.com
126612853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \
126712853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \
126812853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \
126912853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \
127012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \
127112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \
127212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &)
127312853Sgabeblack@google.com
127412853Sgabeblack@google.com#define DEFN_ASN_OP(op) \
127512853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \
127612853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \
127712853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \
127812853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \
127912853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \
128012853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \
128112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \
128212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \
128312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \
128412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \
128512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
128612853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op)
128712853Sgabeblack@google.com
128812853Sgabeblack@google.comDEFN_ASN_OP(=)
128912853Sgabeblack@google.com
129012853Sgabeblack@google.comDEFN_ASN_OP(*=)
129112853Sgabeblack@google.comDEFN_ASN_OP(/=)
129212853Sgabeblack@google.comDEFN_ASN_OP(+=)
129312853Sgabeblack@google.comDEFN_ASN_OP(-=)
129412853Sgabeblack@google.com
129512853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int)
129612853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int)
129712853Sgabeblack@google.com
129812853Sgabeblack@google.com#undef DEFN_ASN_OP_T
129912853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER
130012853Sgabeblack@google.com#undef DEFN_ASN_OP
130112853Sgabeblack@google.com
130212853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, op2, tp) \
130312853Sgabeblack@google.cominline sc_ufix_fast & \
130412853Sgabeblack@google.comsc_ufix_fast::operator op (const tp &b) \
130512853Sgabeblack@google.com{ \
130612853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_READ_(*this) \
130712853Sgabeblack@google.com    b.observer_read(); \
130812853Sgabeblack@google.com    int iwl_c = iwl(); \
130912853Sgabeblack@google.com    for (int i = iwl_c - wl(); i < iwl_c; ++i) \
131012853Sgabeblack@google.com        set_bit(i, get_bit(i) op2 b.get_bit(i)); \
131112853Sgabeblack@google.com    cast(); \
131212853Sgabeblack@google.com    SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
131312853Sgabeblack@google.com    return *this; \
131412853Sgabeblack@google.com}
131512853Sgabeblack@google.com
131612853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_ufix)
131712853Sgabeblack@google.comDEFN_ASN_OP_T(&=, &&, sc_ufix_fast)
131812853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_ufix)
131912853Sgabeblack@google.comDEFN_ASN_OP_T(|=, ||, sc_ufix_fast)
132012853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_ufix)
132112853Sgabeblack@google.comDEFN_ASN_OP_T(^=, !=, sc_ufix_fast)
132212853Sgabeblack@google.com
132312853Sgabeblack@google.com#undef DEFN_ASN_OP_T
132412853Sgabeblack@google.com
132512853Sgabeblack@google.com// auto-increment and auto-decrement
132612853Sgabeblack@google.cominline const sc_fxval_fast
132712853Sgabeblack@google.comsc_ufix_fast::operator ++ (int)
132812853Sgabeblack@google.com{
132912853Sgabeblack@google.com    return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
133012853Sgabeblack@google.com}
133112853Sgabeblack@google.com
133212853Sgabeblack@google.cominline const sc_fxval_fast
133312853Sgabeblack@google.comsc_ufix_fast::operator -- (int)
133412853Sgabeblack@google.com{
133512853Sgabeblack@google.com    return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
133612853Sgabeblack@google.com}
133712853Sgabeblack@google.com
133812853Sgabeblack@google.cominline sc_ufix_fast &
133912853Sgabeblack@google.comsc_ufix_fast::operator ++ ()
134012853Sgabeblack@google.com{
134112853Sgabeblack@google.com    sc_fxnum_fast::operator ++ ();
134212853Sgabeblack@google.com    return *this;
134312853Sgabeblack@google.com}
134412853Sgabeblack@google.com
134512853Sgabeblack@google.cominline sc_ufix_fast &
134612853Sgabeblack@google.comsc_ufix_fast::operator -- ()
134712853Sgabeblack@google.com{
134812853Sgabeblack@google.com    sc_fxnum_fast::operator -- ();
134912853Sgabeblack@google.com    return *this;
135012853Sgabeblack@google.com}
135112853Sgabeblack@google.com
135212853Sgabeblack@google.com} // namespace sc_dt
135312853Sgabeblack@google.com
135412853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SC_UFIX_HH__
1355