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_bit_proxies.h -- Proxy classes for vector data types.
2312853Sgabeblack@google.com
2412853Sgabeblack@google.com  Original Author: Gene Bushuyev, Synopsys, Inc.
2512853Sgabeblack@google.com
2612853Sgabeblack@google.com CHANGE LOG AT THE END OF THE FILE
2712853Sgabeblack@google.com *****************************************************************************/
2812853Sgabeblack@google.com
2912853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
3012853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
3112853Sgabeblack@google.com
3212853Sgabeblack@google.com#include <iostream>
3312853Sgabeblack@google.com
3413322Sgabeblack@google.com#include "../../utils/messages.hh"
3512853Sgabeblack@google.com#include "sc_proxy.hh"
3612853Sgabeblack@google.com
3712853Sgabeblack@google.comnamespace sc_dt
3812853Sgabeblack@google.com{
3912853Sgabeblack@google.com
4012853Sgabeblack@google.com// classes defined in this module
4112853Sgabeblack@google.comtemplate <class X, class Traits>
4212853Sgabeblack@google.comclass sc_bitref_conv_r;
4312853Sgabeblack@google.comtemplate <class X>
4412853Sgabeblack@google.comclass sc_bitref_r;
4512853Sgabeblack@google.comtemplate <class X>
4612853Sgabeblack@google.comclass sc_bitref;
4712853Sgabeblack@google.comtemplate <class X>
4812853Sgabeblack@google.comclass sc_subref_r;
4912853Sgabeblack@google.comtemplate <class X>
5012853Sgabeblack@google.comclass sc_subref;
5112853Sgabeblack@google.comtemplate <class X, class Y>
5212853Sgabeblack@google.comclass sc_concref_r;
5312853Sgabeblack@google.comtemplate <class X, class Y>
5412853Sgabeblack@google.comclass sc_concref;
5512853Sgabeblack@google.com
5612853Sgabeblack@google.com// ----------------------------------------------------------------------------
5712853Sgabeblack@google.com//  CLASS TEMPLATE : sc_bitref_conv_r<T>
5812853Sgabeblack@google.com//
5912853Sgabeblack@google.com//  Proxy class for sc_proxy bit selection (r-value only, boolean conversion).
6012853Sgabeblack@google.com// ----------------------------------------------------------------------------
6112853Sgabeblack@google.comtemplate <class T, class Traits=typename T::traits_type>
6212853Sgabeblack@google.comclass sc_bitref_conv_r { /* empty by default */ };
6312853Sgabeblack@google.com
6412853Sgabeblack@google.com// specialization for bit-vector based sc_proxy classes
6512853Sgabeblack@google.comtemplate<typename T>
6612853Sgabeblack@google.comclass sc_bitref_conv_r<T, sc_proxy_traits<sc_bv_base> >
6712853Sgabeblack@google.com{
6812853Sgabeblack@google.com  public:
6912853Sgabeblack@google.com#if __cplusplus >= 201103L // explicit operator needs C++11
7012853Sgabeblack@google.com    // explicit conversion to bool
7112853Sgabeblack@google.com    explicit operator bool() const
7212853Sgabeblack@google.com    {
7312853Sgabeblack@google.com        return static_cast<const sc_bitref_r<T> &>(*this).to_bool();
7412853Sgabeblack@google.com    }
7512853Sgabeblack@google.com#endif
7612853Sgabeblack@google.com
7712853Sgabeblack@google.com    // explicit (negating) conversion to bool
7812853Sgabeblack@google.com    bool
7912853Sgabeblack@google.com    operator ! () const
8012853Sgabeblack@google.com    {
8112853Sgabeblack@google.com        return !static_cast<const sc_bitref_r<T> &>(*this).to_bool();
8212853Sgabeblack@google.com    }
8312853Sgabeblack@google.com};
8412853Sgabeblack@google.com
8512853Sgabeblack@google.com// ----------------------------------------------------------------------------
8612853Sgabeblack@google.com//  CLASS TEMPLATE : sc_bitref_r<T>
8712853Sgabeblack@google.com//
8812853Sgabeblack@google.com//  Proxy class for sc_proxy bit selection (r-value only).
8912853Sgabeblack@google.com// ----------------------------------------------------------------------------
9012853Sgabeblack@google.com
9112853Sgabeblack@google.comtemplate <class T>
9212853Sgabeblack@google.comclass sc_bitref_r : public sc_bitref_conv_r<T>
9312853Sgabeblack@google.com{
9412853Sgabeblack@google.com    friend class sc_bv_base;
9512853Sgabeblack@google.com    friend class sc_lv_base;
9612853Sgabeblack@google.com
9712853Sgabeblack@google.com  public:
9812853Sgabeblack@google.com    // typedefs
9912853Sgabeblack@google.com    typedef typename T::traits_type traits_type;
10012853Sgabeblack@google.com    typedef typename traits_type::bit_type bit_type;
10112853Sgabeblack@google.com    typedef typename traits_type::value_type value_type;
10212853Sgabeblack@google.com
10312853Sgabeblack@google.com    // constructor
10412853Sgabeblack@google.com    sc_bitref_r(const T &obj_, int index_) :
10512853Sgabeblack@google.com            m_obj(const_cast<T &>(obj_)), m_index(index_)
10612853Sgabeblack@google.com    {}
10712853Sgabeblack@google.com
10812853Sgabeblack@google.com    // copy constructor
10912853Sgabeblack@google.com    sc_bitref_r(const sc_bitref_r<T> &a) : m_obj(a.m_obj), m_index(a.m_index)
11012853Sgabeblack@google.com    {}
11112853Sgabeblack@google.com
11212853Sgabeblack@google.com    // cloning
11312853Sgabeblack@google.com    sc_bitref_r<T> *clone() const { return new sc_bitref_r<T>(*this); }
11412853Sgabeblack@google.com
11512853Sgabeblack@google.com    // bitwise operators and functions
11612853Sgabeblack@google.com
11712853Sgabeblack@google.com    // bitwise complement
11812853Sgabeblack@google.com    bit_type
11912853Sgabeblack@google.com    operator ~ () const
12012853Sgabeblack@google.com    {
12112853Sgabeblack@google.com        return bit_type(sc_logic::not_table[value()]);
12212853Sgabeblack@google.com    }
12312853Sgabeblack@google.com
12412853Sgabeblack@google.com    // implicit conversion to bit_type
12512853Sgabeblack@google.com    operator bit_type() const { return bit_type(m_obj.get_bit(m_index)); }
12612853Sgabeblack@google.com
12712853Sgabeblack@google.com    // explicit conversions
12812853Sgabeblack@google.com    value_type value() const { return m_obj.get_bit(m_index); }
12912853Sgabeblack@google.com    bool is_01() const { return sc_logic(value()).is_01(); }
13012853Sgabeblack@google.com    bool to_bool() const { return sc_logic(value()).to_bool(); }
13112853Sgabeblack@google.com    char to_char() const { return sc_logic(value()).to_char(); }
13212853Sgabeblack@google.com
13312853Sgabeblack@google.com    // common methods
13412853Sgabeblack@google.com    int length() const { return 1; }
13512853Sgabeblack@google.com    int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
13612853Sgabeblack@google.com
13712853Sgabeblack@google.com    value_type get_bit(int n) const;
13812853Sgabeblack@google.com
13912853Sgabeblack@google.com    sc_digit get_word(int i) const;
14012853Sgabeblack@google.com    sc_digit get_cword(int i) const;
14112853Sgabeblack@google.com
14212853Sgabeblack@google.com    // other methods
14312853Sgabeblack@google.com    void print(::std::ostream &os=::std::cout) const { os << to_char(); }
14412853Sgabeblack@google.com
14512853Sgabeblack@google.com  protected:
14612853Sgabeblack@google.com    T &m_obj;
14712853Sgabeblack@google.com    int m_index;
14812853Sgabeblack@google.com
14912853Sgabeblack@google.com  private:
15012853Sgabeblack@google.com    // Disabled
15112853Sgabeblack@google.com    sc_bitref_r();
15212853Sgabeblack@google.com    sc_bitref_r<T> &operator = (const sc_bitref_r<T> &);
15312853Sgabeblack@google.com};
15412853Sgabeblack@google.com
15512853Sgabeblack@google.com// bitwise operators and functions
15612853Sgabeblack@google.com
15712853Sgabeblack@google.com// bitwise and
15812853Sgabeblack@google.comtemplate <class T1, class T2>
15912853Sgabeblack@google.cominline sc_logic operator & (
16012853Sgabeblack@google.com        const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
16112853Sgabeblack@google.com
16212853Sgabeblack@google.com
16312853Sgabeblack@google.com// bitwise or
16412853Sgabeblack@google.comtemplate <class T1, class T2>
16512853Sgabeblack@google.cominline sc_logic operator | (
16612853Sgabeblack@google.com        const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
16712853Sgabeblack@google.com
16812853Sgabeblack@google.com// bitwise xor
16912853Sgabeblack@google.comtemplate <class T1, class T2>
17012853Sgabeblack@google.cominline sc_logic operator ^ (
17112853Sgabeblack@google.com        const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
17212853Sgabeblack@google.com
17312853Sgabeblack@google.com// relational operators and functions
17412853Sgabeblack@google.comtemplate <class T1, class T2>
17512853Sgabeblack@google.cominline bool operator == (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
17612853Sgabeblack@google.com
17712853Sgabeblack@google.comtemplate <class T1, class T2>
17812853Sgabeblack@google.cominline bool operator != (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b);
17912853Sgabeblack@google.com
18012853Sgabeblack@google.com// r-value concatenation operators and functions
18112853Sgabeblack@google.comtemplate <class T1, class T2>
18212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
18312853Sgabeblack@google.com        sc_bitref_r<T1>, sc_bitref_r<T2>);
18412853Sgabeblack@google.com
18512853Sgabeblack@google.comtemplate <class T1, class T2>
18612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
18712853Sgabeblack@google.com        sc_bitref_r<T1>, sc_subref_r<T2>);
18812853Sgabeblack@google.com
18912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
19012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > operator , (
19112853Sgabeblack@google.com        sc_bitref_r<T1>, sc_concref_r<T2,T3>);
19212853Sgabeblack@google.com
19312853Sgabeblack@google.comtemplate <class T1, class T2>
19412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
19512853Sgabeblack@google.com        sc_bitref_r<T1>, const sc_proxy<T2> &);
19612853Sgabeblack@google.com
19712853Sgabeblack@google.comtemplate <class T>
19812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
19912853Sgabeblack@google.com        sc_bitref_r<T>, const char *);
20012853Sgabeblack@google.com
20112853Sgabeblack@google.comtemplate <class T>
20212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
20312853Sgabeblack@google.com        const char *, sc_bitref_r<T>);
20412853Sgabeblack@google.com
20512853Sgabeblack@google.comtemplate <class T>
20612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
20712853Sgabeblack@google.com        sc_bitref_r<T>, const sc_logic &);
20812853Sgabeblack@google.com
20912853Sgabeblack@google.comtemplate <class T>
21012853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
21112853Sgabeblack@google.com        const sc_logic &, sc_bitref_r<T>);
21212853Sgabeblack@google.com
21312853Sgabeblack@google.comtemplate <class T>
21412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
21512853Sgabeblack@google.com        sc_bitref_r<T>, bool);
21612853Sgabeblack@google.com
21712853Sgabeblack@google.comtemplate <class T>
21812853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
21912853Sgabeblack@google.com        bool, sc_bitref_r<T>);
22012853Sgabeblack@google.com
22112853Sgabeblack@google.com
22212853Sgabeblack@google.comtemplate <class T1, class T2>
22312853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
22412853Sgabeblack@google.com        sc_bitref_r<T1>, sc_bitref_r<T2>);
22512853Sgabeblack@google.com
22612853Sgabeblack@google.comtemplate <class T1, class T2>
22712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
22812853Sgabeblack@google.com        sc_bitref_r<T1>, sc_subref_r<T2>);
22912853Sgabeblack@google.com
23012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
23112853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > concat(
23212853Sgabeblack@google.com        sc_bitref_r<T1>, sc_concref_r<T2, T3>);
23312853Sgabeblack@google.com
23412853Sgabeblack@google.comtemplate <class T1, class T2>
23512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> concat(
23612853Sgabeblack@google.com        sc_bitref_r<T1>, const sc_proxy<T2> &);
23712853Sgabeblack@google.com
23812853Sgabeblack@google.comtemplate <class T>
23912853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
24012853Sgabeblack@google.com        sc_bitref_r<T>, const char *);
24112853Sgabeblack@google.com
24212853Sgabeblack@google.comtemplate <class T>
24312853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
24412853Sgabeblack@google.com        const char *, sc_bitref_r<T>);
24512853Sgabeblack@google.com
24612853Sgabeblack@google.comtemplate <class T>
24712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
24812853Sgabeblack@google.com        sc_bitref_r<T>, const sc_logic &);
24912853Sgabeblack@google.com
25012853Sgabeblack@google.comtemplate <class T>
25112853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
25212853Sgabeblack@google.com        const sc_logic &, sc_bitref_r<T>);
25312853Sgabeblack@google.com
25412853Sgabeblack@google.comtemplate <class T>
25512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
25612853Sgabeblack@google.com        sc_bitref_r<T>, bool);
25712853Sgabeblack@google.com
25812853Sgabeblack@google.comtemplate <class T>
25912853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
26012853Sgabeblack@google.com        bool, sc_bitref_r<T>);
26112853Sgabeblack@google.com
26212853Sgabeblack@google.com
26312853Sgabeblack@google.comtemplate <class T1, class T2>
26412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
26512853Sgabeblack@google.com        sc_bitref_r<T1>, sc_bitref<T2>);
26612853Sgabeblack@google.com
26712853Sgabeblack@google.comtemplate <class T1, class T2>
26812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > operator , (
26912853Sgabeblack@google.com        sc_bitref<T1>, sc_bitref_r<T2>);
27012853Sgabeblack@google.com
27112853Sgabeblack@google.comtemplate <class T1, class T2>
27212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
27312853Sgabeblack@google.com        sc_bitref_r<T1>, sc_subref<T2>);
27412853Sgabeblack@google.com
27512853Sgabeblack@google.comtemplate <class T1, class T2>
27612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > operator , (
27712853Sgabeblack@google.com        sc_bitref<T1>, sc_subref_r<T2>);
27812853Sgabeblack@google.com
27912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
28012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > operator , (
28112853Sgabeblack@google.com        sc_bitref_r<T1>, sc_concref<T2, T3>);
28212853Sgabeblack@google.com
28312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
28412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> > operator , (
28512853Sgabeblack@google.com        sc_bitref<T1>, sc_concref_r<T2, T3>);
28612853Sgabeblack@google.com
28712853Sgabeblack@google.comtemplate <class T1, class T2>
28812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
28912853Sgabeblack@google.com        sc_bitref<T1>, const sc_proxy<T2> &);
29012853Sgabeblack@google.com
29112853Sgabeblack@google.comtemplate <class T1, class T2>
29212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> operator , (
29312853Sgabeblack@google.com        sc_bitref_r<T1>, sc_proxy<T2> &);
29412853Sgabeblack@google.com
29512853Sgabeblack@google.comtemplate <class T>
29612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
29712853Sgabeblack@google.com        sc_bitref<T>, const char *);
29812853Sgabeblack@google.com
29912853Sgabeblack@google.comtemplate <class T>
30012853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
30112853Sgabeblack@google.com        const char *, sc_bitref<T>);
30212853Sgabeblack@google.com
30312853Sgabeblack@google.comtemplate <class T>
30412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
30512853Sgabeblack@google.com        sc_bitref<T>, const sc_logic &);
30612853Sgabeblack@google.com
30712853Sgabeblack@google.comtemplate <class T>
30812853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
30912853Sgabeblack@google.com        const sc_logic &, sc_bitref<T>);
31012853Sgabeblack@google.com
31112853Sgabeblack@google.comtemplate <class T>
31212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> operator , (
31312853Sgabeblack@google.com        sc_bitref<T>, bool);
31412853Sgabeblack@google.com
31512853Sgabeblack@google.comtemplate <class T>
31612853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > operator , (
31712853Sgabeblack@google.com        bool, sc_bitref<T>);
31812853Sgabeblack@google.com
31912853Sgabeblack@google.com
32012853Sgabeblack@google.comtemplate <class T1, class T2>
32112853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
32212853Sgabeblack@google.com        sc_bitref_r<T1>, sc_bitref<T2>);
32312853Sgabeblack@google.com
32412853Sgabeblack@google.comtemplate <class T1, class T2>
32512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > concat(
32612853Sgabeblack@google.com        sc_bitref<T1>, sc_bitref_r<T2>);
32712853Sgabeblack@google.com
32812853Sgabeblack@google.comtemplate <class T1, class T2>
32912853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
33012853Sgabeblack@google.com        sc_bitref_r<T1>, sc_subref<T2>);
33112853Sgabeblack@google.com
33212853Sgabeblack@google.comtemplate <class T1, class T2>
33312853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> > concat(
33412853Sgabeblack@google.com        sc_bitref<T1>, sc_subref_r<T2>);
33512853Sgabeblack@google.com
33612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
33712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > concat(
33812853Sgabeblack@google.com        sc_bitref_r<T1>, sc_concref<T2, T3>);
33912853Sgabeblack@google.com
34012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
34112853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> > concat(
34212853Sgabeblack@google.com        sc_bitref<T1>, sc_concref_r<T2, T3>);
34312853Sgabeblack@google.com
34412853Sgabeblack@google.comtemplate <class T1, class T2>
34512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> concat(
34612853Sgabeblack@google.com        sc_bitref<T1>, const sc_proxy<T2> &);
34712853Sgabeblack@google.com
34812853Sgabeblack@google.comtemplate <class T1, class T2>
34912853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2> concat(
35012853Sgabeblack@google.com        sc_bitref_r<T1>, sc_proxy<T2> &);
35112853Sgabeblack@google.com
35212853Sgabeblack@google.comtemplate <class T>
35312853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
35412853Sgabeblack@google.com        sc_bitref<T>, const char *);
35512853Sgabeblack@google.com
35612853Sgabeblack@google.comtemplate <class T>
35712853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
35812853Sgabeblack@google.com        const char *, sc_bitref<T>);
35912853Sgabeblack@google.com
36012853Sgabeblack@google.comtemplate <class T>
36112853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(
36212853Sgabeblack@google.com        sc_bitref<T>, const sc_logic &);
36312853Sgabeblack@google.com
36412853Sgabeblack@google.comtemplate <class T>
36512853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(
36612853Sgabeblack@google.com        const sc_logic &, sc_bitref<T>);
36712853Sgabeblack@google.com
36812853Sgabeblack@google.comtemplate <class T>
36912853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T>, sc_lv_base> concat(sc_bitref<T>, bool);
37012853Sgabeblack@google.com
37112853Sgabeblack@google.comtemplate <class T>
37212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_bitref_r<T> > concat(bool, sc_bitref<T>);
37312853Sgabeblack@google.com
37412853Sgabeblack@google.com
37512853Sgabeblack@google.com// ----------------------------------------------------------------------------
37612853Sgabeblack@google.com//  CLASS TEMPLATE : sc_bitref<X>
37712853Sgabeblack@google.com//
37812853Sgabeblack@google.com//  Proxy class for sc_proxy bit selection (r-value and l-value).
37912853Sgabeblack@google.com// ----------------------------------------------------------------------------
38012853Sgabeblack@google.com
38112853Sgabeblack@google.comtemplate <class X>
38212853Sgabeblack@google.comclass sc_bitref : public sc_bitref_r<X>
38312853Sgabeblack@google.com{
38412853Sgabeblack@google.com    friend class sc_bv_base;
38512853Sgabeblack@google.com    friend class sc_lv_base;
38612853Sgabeblack@google.com
38712853Sgabeblack@google.com  public:
38812853Sgabeblack@google.com    typedef typename sc_bitref_r<X>::value_type value_type;
38912853Sgabeblack@google.com
39012853Sgabeblack@google.com    // constructor
39112853Sgabeblack@google.com    sc_bitref(X &obj_, int index_) : sc_bitref_r<X>(obj_, index_) {}
39212853Sgabeblack@google.com
39312853Sgabeblack@google.com    // copy constructor
39412853Sgabeblack@google.com    sc_bitref(const sc_bitref<X> &a) : sc_bitref_r<X>(a) {}
39512853Sgabeblack@google.com
39612853Sgabeblack@google.com    // cloning
39712853Sgabeblack@google.com    sc_bitref<X> *clone() const { return new sc_bitref<X>(*this); }
39812853Sgabeblack@google.com
39912853Sgabeblack@google.com    // assignment operators
40012853Sgabeblack@google.com    sc_bitref<X> &operator = (const sc_bitref_r<X> &a);
40112853Sgabeblack@google.com    sc_bitref<X> &operator = (const sc_bitref<X> &a);
40212853Sgabeblack@google.com
40312853Sgabeblack@google.com    sc_bitref<X> &
40412853Sgabeblack@google.com    operator = (const sc_logic &a)
40512853Sgabeblack@google.com    {
40612853Sgabeblack@google.com        this->m_obj.set_bit(this->m_index, a.value());
40712853Sgabeblack@google.com        return *this;
40812853Sgabeblack@google.com    }
40912853Sgabeblack@google.com
41012853Sgabeblack@google.com    sc_bitref<X> &
41112853Sgabeblack@google.com    operator = (sc_logic_value_t v)
41212853Sgabeblack@google.com    {
41312853Sgabeblack@google.com        *this = sc_logic(v);
41412853Sgabeblack@google.com        return *this;
41512853Sgabeblack@google.com    }
41612853Sgabeblack@google.com
41712853Sgabeblack@google.com    sc_bitref<X> &
41812853Sgabeblack@google.com    operator = (bool a)
41912853Sgabeblack@google.com    {
42012853Sgabeblack@google.com        *this = sc_logic(a);
42112853Sgabeblack@google.com        return *this;
42212853Sgabeblack@google.com    }
42312853Sgabeblack@google.com
42412853Sgabeblack@google.com    sc_bitref<X> &
42512853Sgabeblack@google.com    operator = (char a)
42612853Sgabeblack@google.com    {
42712853Sgabeblack@google.com        *this = sc_logic(a);
42812853Sgabeblack@google.com        return *this;
42912853Sgabeblack@google.com    }
43012853Sgabeblack@google.com
43112853Sgabeblack@google.com    sc_bitref<X> &
43212853Sgabeblack@google.com    operator = (int a)
43312853Sgabeblack@google.com    {
43412853Sgabeblack@google.com        *this = sc_logic(a);
43512853Sgabeblack@google.com        return *this;
43612853Sgabeblack@google.com    }
43712853Sgabeblack@google.com
43812853Sgabeblack@google.com    sc_bitref<X> &
43912853Sgabeblack@google.com    operator = (const sc_bit &a)
44012853Sgabeblack@google.com    {
44112853Sgabeblack@google.com        *this = sc_logic(a);
44212853Sgabeblack@google.com        return *this;
44312853Sgabeblack@google.com    }
44412853Sgabeblack@google.com
44512853Sgabeblack@google.com    // bitwise assignment operators
44612853Sgabeblack@google.com    sc_bitref<X> &operator &= (const sc_bitref_r<X> &a);
44712853Sgabeblack@google.com    sc_bitref<X> &operator &= (const sc_logic &a);
44812853Sgabeblack@google.com
44912853Sgabeblack@google.com    sc_bitref<X> &
45012853Sgabeblack@google.com    operator &= (sc_logic_value_t v)
45112853Sgabeblack@google.com    {
45212853Sgabeblack@google.com        *this &= sc_logic(v);
45312853Sgabeblack@google.com        return *this;
45412853Sgabeblack@google.com    }
45512853Sgabeblack@google.com
45612853Sgabeblack@google.com    sc_bitref<X> &
45712853Sgabeblack@google.com    operator &= (bool a)
45812853Sgabeblack@google.com    {
45912853Sgabeblack@google.com        *this &= sc_logic(a);
46012853Sgabeblack@google.com        return *this;
46112853Sgabeblack@google.com    }
46212853Sgabeblack@google.com
46312853Sgabeblack@google.com    sc_bitref<X> &
46412853Sgabeblack@google.com    operator &= (char a)
46512853Sgabeblack@google.com    {
46612853Sgabeblack@google.com        *this &= sc_logic(a);
46712853Sgabeblack@google.com        return *this;
46812853Sgabeblack@google.com    }
46912853Sgabeblack@google.com
47012853Sgabeblack@google.com    sc_bitref<X> &
47112853Sgabeblack@google.com    operator &= (int a)
47212853Sgabeblack@google.com    {
47312853Sgabeblack@google.com        *this &= sc_logic(a);
47412853Sgabeblack@google.com        return *this;
47512853Sgabeblack@google.com    }
47612853Sgabeblack@google.com
47712853Sgabeblack@google.com    sc_bitref<X> &operator |= (const sc_bitref_r<X> &a);
47812853Sgabeblack@google.com    sc_bitref<X> &operator |= (const sc_logic &a);
47912853Sgabeblack@google.com
48012853Sgabeblack@google.com    sc_bitref<X> &
48112853Sgabeblack@google.com    operator |= (sc_logic_value_t v)
48212853Sgabeblack@google.com    {
48312853Sgabeblack@google.com        *this |= sc_logic(v);
48412853Sgabeblack@google.com        return *this;
48512853Sgabeblack@google.com    }
48612853Sgabeblack@google.com
48712853Sgabeblack@google.com    sc_bitref<X> &
48812853Sgabeblack@google.com    operator |= (bool a)
48912853Sgabeblack@google.com    {
49012853Sgabeblack@google.com        *this |= sc_logic(a);
49112853Sgabeblack@google.com        return *this;
49212853Sgabeblack@google.com    }
49312853Sgabeblack@google.com
49412853Sgabeblack@google.com    sc_bitref<X> &
49512853Sgabeblack@google.com    operator |= (char a)
49612853Sgabeblack@google.com    {
49712853Sgabeblack@google.com        *this |= sc_logic(a);
49812853Sgabeblack@google.com        return *this;
49912853Sgabeblack@google.com    }
50012853Sgabeblack@google.com
50112853Sgabeblack@google.com    sc_bitref<X> &
50212853Sgabeblack@google.com    operator |= (int a)
50312853Sgabeblack@google.com    {
50412853Sgabeblack@google.com        *this |= sc_logic(a);
50512853Sgabeblack@google.com        return *this;
50612853Sgabeblack@google.com    }
50712853Sgabeblack@google.com
50812853Sgabeblack@google.com    sc_bitref<X> &operator ^= (const sc_bitref_r<X> &a);
50912853Sgabeblack@google.com    sc_bitref<X> &operator ^= (const sc_logic &a);
51012853Sgabeblack@google.com
51112853Sgabeblack@google.com    sc_bitref<X> &
51212853Sgabeblack@google.com    operator ^= (sc_logic_value_t v)
51312853Sgabeblack@google.com    {
51412853Sgabeblack@google.com        *this ^= sc_logic(v);
51512853Sgabeblack@google.com        return *this;
51612853Sgabeblack@google.com    }
51712853Sgabeblack@google.com
51812853Sgabeblack@google.com    sc_bitref<X> &
51912853Sgabeblack@google.com    operator ^= (bool a)
52012853Sgabeblack@google.com    {
52112853Sgabeblack@google.com        *this ^= sc_logic(a);
52212853Sgabeblack@google.com        return *this;
52312853Sgabeblack@google.com    }
52412853Sgabeblack@google.com
52512853Sgabeblack@google.com    sc_bitref<X> &
52612853Sgabeblack@google.com    operator ^= (char a)
52712853Sgabeblack@google.com    {
52812853Sgabeblack@google.com        *this ^= sc_logic(a);
52912853Sgabeblack@google.com        return *this;
53012853Sgabeblack@google.com    }
53112853Sgabeblack@google.com
53212853Sgabeblack@google.com    sc_bitref<X> &
53312853Sgabeblack@google.com    operator ^= (int a)
53412853Sgabeblack@google.com    {
53512853Sgabeblack@google.com        *this ^= sc_logic(a);
53612853Sgabeblack@google.com        return *this;
53712853Sgabeblack@google.com    }
53812853Sgabeblack@google.com
53912853Sgabeblack@google.com    // bitwise operators and functions
54012853Sgabeblack@google.com
54112853Sgabeblack@google.com    // bitwise complement
54212853Sgabeblack@google.com    sc_bitref<X> &b_not();
54312853Sgabeblack@google.com
54412853Sgabeblack@google.com    // common methods
54512853Sgabeblack@google.com    void set_bit(int n, value_type value);
54612853Sgabeblack@google.com
54712853Sgabeblack@google.com    void set_word(int i, sc_digit w);
54812853Sgabeblack@google.com    void set_cword(int i, sc_digit w);
54912853Sgabeblack@google.com
55012853Sgabeblack@google.com    void clean_tail() { this->m_obj.clean_tail(); }
55112853Sgabeblack@google.com
55212853Sgabeblack@google.com    // other methods
55312853Sgabeblack@google.com    void scan(::std::istream &is=::std::cin);
55412853Sgabeblack@google.com
55512853Sgabeblack@google.com  private:
55612853Sgabeblack@google.com    // Disabled
55712853Sgabeblack@google.com    sc_bitref();
55812853Sgabeblack@google.com};
55912853Sgabeblack@google.com
56012853Sgabeblack@google.com
56112853Sgabeblack@google.com// l-value concatenation operators and functions
56212853Sgabeblack@google.com
56312853Sgabeblack@google.comtemplate <class T1, class T2>
56412853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_bitref<T2> > operator , (
56512853Sgabeblack@google.com        sc_bitref<T1>, sc_bitref<T2>);
56612853Sgabeblack@google.com
56712853Sgabeblack@google.comtemplate <class T1, class T2>
56812853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_subref<T2> > operator , (
56912853Sgabeblack@google.com        sc_bitref<T1>, sc_subref<T2>);
57012853Sgabeblack@google.com
57112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
57212853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> > operator , (
57312853Sgabeblack@google.com        sc_bitref<T1>, sc_concref<T2, T3>);
57412853Sgabeblack@google.com
57512853Sgabeblack@google.comtemplate <class T1, class T2>
57612853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, T2> operator , (
57712853Sgabeblack@google.com        sc_bitref<T1>, sc_proxy<T2> &);
57812853Sgabeblack@google.com
57912853Sgabeblack@google.com
58012853Sgabeblack@google.comtemplate <class T1, class T2>
58112853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_bitref<T2> > concat(
58212853Sgabeblack@google.com        sc_bitref<T1>, sc_bitref<T2>);
58312853Sgabeblack@google.com
58412853Sgabeblack@google.comtemplate <class T1, class T2>
58512853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_subref<T2> > concat(
58612853Sgabeblack@google.com        sc_bitref<T1>, sc_subref<T2>);
58712853Sgabeblack@google.com
58812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
58912853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_concref<T2,T3> > concat(
59012853Sgabeblack@google.com        sc_bitref<T1>, sc_concref<T2, T3>);
59112853Sgabeblack@google.com
59212853Sgabeblack@google.comtemplate <class T1, class T2>
59312853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, T2> concat(sc_bitref<T1>, sc_proxy<T2> &);
59412853Sgabeblack@google.com
59512853Sgabeblack@google.com
59612853Sgabeblack@google.comtemplate <class T>
59712853Sgabeblack@google.com::std::istream &operator >> (::std::istream &, sc_bitref<T>);
59812853Sgabeblack@google.com
59912853Sgabeblack@google.com
60012853Sgabeblack@google.com// ----------------------------------------------------------------------------
60112853Sgabeblack@google.com//  CLASS TEMPLATE : sc_subref_r<X>
60212853Sgabeblack@google.com//
60312853Sgabeblack@google.com//  Proxy class for sc_proxy part selection (r-value only).
60412853Sgabeblack@google.com// ----------------------------------------------------------------------------
60512853Sgabeblack@google.com
60612853Sgabeblack@google.comtemplate <class X>
60712853Sgabeblack@google.comclass sc_subref_r : public sc_proxy<sc_subref_r<X> >
60812853Sgabeblack@google.com{
60912853Sgabeblack@google.com    void check_bounds();
61012853Sgabeblack@google.com
61112853Sgabeblack@google.com  public:
61212853Sgabeblack@google.com    typedef typename sc_proxy<sc_subref_r<X> >::value_type value_type;
61312853Sgabeblack@google.com
61412853Sgabeblack@google.com    // constructor
61512853Sgabeblack@google.com    sc_subref_r(const X &obj_, int hi_, int lo_) :
61612853Sgabeblack@google.com            m_obj(const_cast<X &>(obj_)), m_hi(hi_), m_lo(lo_), m_len(0)
61712853Sgabeblack@google.com    { check_bounds(); }
61812853Sgabeblack@google.com
61912853Sgabeblack@google.com    // copy constructor
62012853Sgabeblack@google.com    sc_subref_r(const sc_subref_r<X> &a) :
62112853Sgabeblack@google.com        m_obj(a.m_obj), m_hi(a.m_hi), m_lo(a.m_lo), m_len(a.m_len)
62212853Sgabeblack@google.com    {}
62312853Sgabeblack@google.com
62412853Sgabeblack@google.com    // cloning
62512853Sgabeblack@google.com    sc_subref_r<X> *clone() const { return new sc_subref_r<X>(*this); }
62612853Sgabeblack@google.com
62712853Sgabeblack@google.com    // common methods
62812853Sgabeblack@google.com    int length() const { return m_len; }
62912853Sgabeblack@google.com
63012853Sgabeblack@google.com    int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
63112853Sgabeblack@google.com
63212853Sgabeblack@google.com    value_type get_bit(int n) const;
63312853Sgabeblack@google.com    void set_bit(int n, value_type value);
63412853Sgabeblack@google.com
63512853Sgabeblack@google.com    sc_digit get_word(int i) const;
63612853Sgabeblack@google.com    void set_word(int i, sc_digit w);
63712853Sgabeblack@google.com
63812853Sgabeblack@google.com    sc_digit get_cword(int i) const;
63912853Sgabeblack@google.com    void set_cword(int i, sc_digit w);
64012853Sgabeblack@google.com
64112853Sgabeblack@google.com    void clean_tail() { m_obj.clean_tail(); }
64212853Sgabeblack@google.com
64312853Sgabeblack@google.com    // other methods
64412853Sgabeblack@google.com    bool is_01() const;
64512853Sgabeblack@google.com    bool reversed() const { return m_lo > m_hi; }
64612853Sgabeblack@google.com
64712853Sgabeblack@google.com  protected:
64812853Sgabeblack@google.com    X &m_obj;
64912853Sgabeblack@google.com    int m_hi;
65012853Sgabeblack@google.com    int m_lo;
65112853Sgabeblack@google.com    int m_len;
65212853Sgabeblack@google.com
65312853Sgabeblack@google.com  private:
65412853Sgabeblack@google.com    // Disabled
65512853Sgabeblack@google.com    sc_subref_r();
65612853Sgabeblack@google.com    sc_subref_r<X> &operator = (const sc_subref_r<X> &);
65712853Sgabeblack@google.com};
65812853Sgabeblack@google.com
65912853Sgabeblack@google.com
66012853Sgabeblack@google.com// r-value concatenation operators and functions
66112853Sgabeblack@google.com
66212853Sgabeblack@google.comtemplate <class T1, class T2>
66312853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
66412853Sgabeblack@google.com        sc_subref_r<T1>, sc_bitref_r<T2>);
66512853Sgabeblack@google.com
66612853Sgabeblack@google.comtemplate <class T1, class T2>
66712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
66812853Sgabeblack@google.com        sc_subref_r<T1>, sc_subref_r<T2>);
66912853Sgabeblack@google.com
67012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
67112853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2,T3> > operator , (
67212853Sgabeblack@google.com        sc_subref_r<T1>, sc_concref_r<T2, T3>);
67312853Sgabeblack@google.com
67412853Sgabeblack@google.comtemplate <class T1, class T2>
67512853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> operator , (
67612853Sgabeblack@google.com        sc_subref_r<T1>, const sc_proxy<T2> &);
67712853Sgabeblack@google.com
67812853Sgabeblack@google.comtemplate <class T>
67912853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>,sc_lv_base> operator , (
68012853Sgabeblack@google.com        sc_subref_r<T>, const char *);
68112853Sgabeblack@google.com
68212853Sgabeblack@google.comtemplate <class T>
68312853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
68412853Sgabeblack@google.com        const char *, sc_subref_r<T>);
68512853Sgabeblack@google.com
68612853Sgabeblack@google.comtemplate <class T>
68712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
68812853Sgabeblack@google.com        sc_subref_r<T>, const sc_logic &);
68912853Sgabeblack@google.com
69012853Sgabeblack@google.comtemplate <class T>
69112853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
69212853Sgabeblack@google.com        const sc_logic &, sc_subref_r<T>);
69312853Sgabeblack@google.com
69412853Sgabeblack@google.comtemplate <class T>
69512853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_bv_base> operator , (
69612853Sgabeblack@google.com        sc_subref_r<T>, bool);
69712853Sgabeblack@google.com
69812853Sgabeblack@google.comtemplate <class T>
69912853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_subref_r<T> > operator , (
70012853Sgabeblack@google.com        bool, sc_subref_r<T>);
70112853Sgabeblack@google.com
70212853Sgabeblack@google.com
70312853Sgabeblack@google.comtemplate <class T1, class T2>
70412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
70512853Sgabeblack@google.com        sc_subref_r<T1>, sc_bitref_r<T2>);
70612853Sgabeblack@google.com
70712853Sgabeblack@google.comtemplate <class T1, class T2>
70812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
70912853Sgabeblack@google.com        sc_subref_r<T1>, sc_subref_r<T2>);
71012853Sgabeblack@google.com
71112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
71212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
71312853Sgabeblack@google.com        sc_subref_r<T1>, sc_concref_r<T2, T3>);
71412853Sgabeblack@google.com
71512853Sgabeblack@google.comtemplate <class T1, class T2>
71612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> concat(
71712853Sgabeblack@google.com        sc_subref_r<T1>, const sc_proxy<T2> &);
71812853Sgabeblack@google.com
71912853Sgabeblack@google.comtemplate <class T>
72012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
72112853Sgabeblack@google.com        sc_subref_r<T>, const char *);
72212853Sgabeblack@google.com
72312853Sgabeblack@google.comtemplate <class T>
72412853Sgabeblack@google.cominline sc_concref_r<sc_lv_base,sc_subref_r<T> > concat(
72512853Sgabeblack@google.com        const char *, sc_subref_r<T>);
72612853Sgabeblack@google.com
72712853Sgabeblack@google.comtemplate <class T>
72812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
72912853Sgabeblack@google.com        sc_subref_r<T>, const sc_logic &);
73012853Sgabeblack@google.com
73112853Sgabeblack@google.comtemplate <class T>
73212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
73312853Sgabeblack@google.com        const sc_logic &, sc_subref_r<T>);
73412853Sgabeblack@google.com
73512853Sgabeblack@google.comtemplate <class T>
73612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_bv_base> concat(sc_subref_r<T>, bool);
73712853Sgabeblack@google.com
73812853Sgabeblack@google.comtemplate <class T>
73912853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_subref_r<T> > concat(bool, sc_subref_r<T>);
74012853Sgabeblack@google.com
74112853Sgabeblack@google.com
74212853Sgabeblack@google.comtemplate <class T1, class T2>
74312853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
74412853Sgabeblack@google.com        sc_subref_r<T1>, sc_bitref<T2>);
74512853Sgabeblack@google.com
74612853Sgabeblack@google.comtemplate <class T1, class T2>
74712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > operator , (
74812853Sgabeblack@google.com        sc_subref<T1>, sc_bitref_r<T2>);
74912853Sgabeblack@google.com
75012853Sgabeblack@google.comtemplate <class T1, class T2>
75112853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
75212853Sgabeblack@google.com        sc_subref_r<T1>, sc_subref<T2>);
75312853Sgabeblack@google.com
75412853Sgabeblack@google.comtemplate <class T1, class T2>
75512853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > operator , (
75612853Sgabeblack@google.com        sc_subref<T1>, sc_subref_r<T2>);
75712853Sgabeblack@google.com
75812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
75912853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > operator , (
76012853Sgabeblack@google.com        sc_subref_r<T1>, sc_concref<T2, T3>);
76112853Sgabeblack@google.com
76212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
76312853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > operator , (
76412853Sgabeblack@google.com        sc_subref<T1>, sc_concref_r<T2, T3>);
76512853Sgabeblack@google.com
76612853Sgabeblack@google.comtemplate <class T1, class T2>
76712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> operator , (
76812853Sgabeblack@google.com        sc_subref<T1>, const sc_proxy<T2> &);
76912853Sgabeblack@google.com
77012853Sgabeblack@google.comtemplate <class T1, class T2>
77112853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> operator , (
77212853Sgabeblack@google.com        sc_subref_r<T1>, sc_proxy<T2> &);
77312853Sgabeblack@google.com
77412853Sgabeblack@google.comtemplate <class T>
77512853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
77612853Sgabeblack@google.com        sc_subref<T>, const char *);
77712853Sgabeblack@google.com
77812853Sgabeblack@google.comtemplate <class T>
77912853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
78012853Sgabeblack@google.com        const char *, sc_subref<T>);
78112853Sgabeblack@google.com
78212853Sgabeblack@google.comtemplate <class T>
78312853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> operator , (
78412853Sgabeblack@google.com        sc_subref<T>, const sc_logic &);
78512853Sgabeblack@google.com
78612853Sgabeblack@google.comtemplate <class T>
78712853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > operator , (
78812853Sgabeblack@google.com        const sc_logic &, sc_subref<T>);
78912853Sgabeblack@google.com
79012853Sgabeblack@google.comtemplate <class T>
79112853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_bv_base> operator , (
79212853Sgabeblack@google.com        sc_subref<T>, bool);
79312853Sgabeblack@google.com
79412853Sgabeblack@google.comtemplate <class T>
79512853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_subref_r<T> > operator , (
79612853Sgabeblack@google.com        bool, sc_subref<T>);
79712853Sgabeblack@google.com
79812853Sgabeblack@google.com
79912853Sgabeblack@google.comtemplate <class T1, class T2>
80012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
80112853Sgabeblack@google.com        sc_subref_r<T1>, sc_bitref<T2>);
80212853Sgabeblack@google.com
80312853Sgabeblack@google.comtemplate <class T1, class T2>
80412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> > concat(
80512853Sgabeblack@google.com        sc_subref<T1>, sc_bitref_r<T2>);
80612853Sgabeblack@google.com
80712853Sgabeblack@google.comtemplate <class T1, class T2>
80812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
80912853Sgabeblack@google.com        sc_subref_r<T1>, sc_subref<T2>);
81012853Sgabeblack@google.com
81112853Sgabeblack@google.comtemplate <class T1, class T2>
81212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> > concat(
81312853Sgabeblack@google.com        sc_subref<T1>, sc_subref_r<T2>);
81412853Sgabeblack@google.com
81512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
81612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
81712853Sgabeblack@google.com        sc_subref_r<T1>, sc_concref<T2, T3>);
81812853Sgabeblack@google.com
81912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
82012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> > concat(
82112853Sgabeblack@google.com        sc_subref<T1>, sc_concref_r<T2, T3>);
82212853Sgabeblack@google.com
82312853Sgabeblack@google.comtemplate <class T1, class T2>
82412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> concat(
82512853Sgabeblack@google.com        sc_subref<T1>, const sc_proxy<T2> &);
82612853Sgabeblack@google.com
82712853Sgabeblack@google.comtemplate <class T1, class T2>
82812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2> concat(
82912853Sgabeblack@google.com        sc_subref_r<T1>, sc_proxy<T2> &);
83012853Sgabeblack@google.com
83112853Sgabeblack@google.comtemplate <class T>
83212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
83312853Sgabeblack@google.com        sc_subref<T>, const char *);
83412853Sgabeblack@google.com
83512853Sgabeblack@google.comtemplate <class T>
83612853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
83712853Sgabeblack@google.com        const char *, sc_subref<T>);
83812853Sgabeblack@google.com
83912853Sgabeblack@google.comtemplate <class T>
84012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_lv_base> concat(
84112853Sgabeblack@google.com        sc_subref<T>, const sc_logic &);
84212853Sgabeblack@google.com
84312853Sgabeblack@google.comtemplate <class T>
84412853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_subref_r<T> > concat(
84512853Sgabeblack@google.com        const sc_logic &, sc_subref<T>);
84612853Sgabeblack@google.com
84712853Sgabeblack@google.comtemplate <class T>
84812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T>, sc_bv_base> concat(sc_subref<T>, bool);
84912853Sgabeblack@google.com
85012853Sgabeblack@google.comtemplate <class T>
85112853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_subref_r<T> > concat(bool, sc_subref<T>);
85212853Sgabeblack@google.com
85312853Sgabeblack@google.com
85412853Sgabeblack@google.com// ----------------------------------------------------------------------------
85512853Sgabeblack@google.com//  CLASS TEMPLATE : sc_subref<X>
85612853Sgabeblack@google.com//
85712853Sgabeblack@google.com//  Proxy class for sc_proxy part selection (r-value and l-value).
85812853Sgabeblack@google.com// ----------------------------------------------------------------------------
85912853Sgabeblack@google.com
86012853Sgabeblack@google.comtemplate <class X>
86112853Sgabeblack@google.comclass sc_subref : public sc_subref_r<X>
86212853Sgabeblack@google.com{
86312853Sgabeblack@google.com  public:
86412853Sgabeblack@google.com    // typedefs
86512853Sgabeblack@google.com    typedef sc_subref_r<X> base_type;
86612853Sgabeblack@google.com
86712853Sgabeblack@google.com    // constructor
86812853Sgabeblack@google.com    sc_subref(X &obj_, int hi_, int lo_) : sc_subref_r<X>(obj_, hi_, lo_) {}
86912853Sgabeblack@google.com
87012853Sgabeblack@google.com    // copy constructor
87112853Sgabeblack@google.com    sc_subref(const sc_subref<X> &a) : sc_subref_r<X>(a) {}
87212853Sgabeblack@google.com
87312853Sgabeblack@google.com    // cloning
87412853Sgabeblack@google.com    sc_subref<X> *clone() const { return new sc_subref<X>(*this); }
87512853Sgabeblack@google.com
87612853Sgabeblack@google.com    // assignment operators
87712853Sgabeblack@google.com    template <class Y>
87812853Sgabeblack@google.com    sc_subref<X> &
87912853Sgabeblack@google.com    operator = (const sc_proxy<Y> &a)
88012853Sgabeblack@google.com    {
88112853Sgabeblack@google.com        base_type::assign_(a);
88212853Sgabeblack@google.com        return *this;
88312853Sgabeblack@google.com    }
88412853Sgabeblack@google.com
88512853Sgabeblack@google.com    sc_subref<X> &operator = (const sc_subref_r<X> &a);
88612853Sgabeblack@google.com    sc_subref<X> &operator = (const sc_subref<X> &a);
88712853Sgabeblack@google.com
88812853Sgabeblack@google.com    sc_subref<X> &
88912853Sgabeblack@google.com    operator = (const char *a)
89012853Sgabeblack@google.com    {
89112853Sgabeblack@google.com        base_type::assign_(a);
89212853Sgabeblack@google.com        return *this;
89312853Sgabeblack@google.com    }
89412853Sgabeblack@google.com
89512853Sgabeblack@google.com    sc_subref<X> &
89612853Sgabeblack@google.com    operator = (const bool *a)
89712853Sgabeblack@google.com    {
89812853Sgabeblack@google.com        base_type::assign_(a);
89912853Sgabeblack@google.com        return *this;
90012853Sgabeblack@google.com    }
90112853Sgabeblack@google.com
90212853Sgabeblack@google.com    sc_subref<X> &
90312853Sgabeblack@google.com    operator = (const sc_logic *a)
90412853Sgabeblack@google.com    {
90512853Sgabeblack@google.com        base_type::assign_(a);
90612853Sgabeblack@google.com        return *this;
90712853Sgabeblack@google.com    }
90812853Sgabeblack@google.com
90912853Sgabeblack@google.com    sc_subref<X> &
91012853Sgabeblack@google.com    operator = (const sc_unsigned &a)
91112853Sgabeblack@google.com    {
91212853Sgabeblack@google.com        base_type::assign_(a);
91312853Sgabeblack@google.com        return *this;
91412853Sgabeblack@google.com    }
91512853Sgabeblack@google.com
91612853Sgabeblack@google.com    sc_subref<X> &
91712853Sgabeblack@google.com    operator = (const sc_signed &a)
91812853Sgabeblack@google.com    {
91912853Sgabeblack@google.com        base_type::assign_(a);
92012853Sgabeblack@google.com        return *this;
92112853Sgabeblack@google.com    }
92212853Sgabeblack@google.com
92312853Sgabeblack@google.com    sc_subref<X> &
92412853Sgabeblack@google.com    operator = (const sc_uint_base &a)
92512853Sgabeblack@google.com    {
92612853Sgabeblack@google.com        base_type::assign_(a);
92712853Sgabeblack@google.com        return *this;
92812853Sgabeblack@google.com    }
92912853Sgabeblack@google.com
93012853Sgabeblack@google.com    sc_subref<X> &
93112853Sgabeblack@google.com    operator = (const sc_int_base &a)
93212853Sgabeblack@google.com    {
93312853Sgabeblack@google.com        base_type::assign_(a);
93412853Sgabeblack@google.com        return *this;
93512853Sgabeblack@google.com    }
93612853Sgabeblack@google.com
93712853Sgabeblack@google.com    sc_subref<X> &
93812853Sgabeblack@google.com    operator = (unsigned long a)
93912853Sgabeblack@google.com    {
94012853Sgabeblack@google.com        base_type::assign_(a);
94112853Sgabeblack@google.com        return *this;
94212853Sgabeblack@google.com    }
94312853Sgabeblack@google.com
94412853Sgabeblack@google.com    sc_subref<X> &
94512853Sgabeblack@google.com    operator = (long a)
94612853Sgabeblack@google.com    {
94712853Sgabeblack@google.com        base_type::assign_(a);
94812853Sgabeblack@google.com        return *this;
94912853Sgabeblack@google.com    }
95012853Sgabeblack@google.com
95112853Sgabeblack@google.com    sc_subref<X> &
95212853Sgabeblack@google.com    operator = (unsigned int a)
95312853Sgabeblack@google.com    {
95412853Sgabeblack@google.com        base_type::assign_(a);
95512853Sgabeblack@google.com        return *this;
95612853Sgabeblack@google.com    }
95712853Sgabeblack@google.com
95812853Sgabeblack@google.com    sc_subref<X> &
95912853Sgabeblack@google.com    operator = (int a)
96012853Sgabeblack@google.com    {
96112853Sgabeblack@google.com        base_type::assign_(a);
96212853Sgabeblack@google.com        return *this;
96312853Sgabeblack@google.com    }
96412853Sgabeblack@google.com
96512853Sgabeblack@google.com    sc_subref<X> &
96612853Sgabeblack@google.com    operator = (uint64 a)
96712853Sgabeblack@google.com    {
96812853Sgabeblack@google.com        base_type::assign_(a);
96912853Sgabeblack@google.com        return *this;
97012853Sgabeblack@google.com    }
97112853Sgabeblack@google.com
97212853Sgabeblack@google.com    sc_subref<X> &
97312853Sgabeblack@google.com    operator = (int64 a)
97412853Sgabeblack@google.com    {
97512853Sgabeblack@google.com        base_type::assign_(a);
97612853Sgabeblack@google.com        return *this;
97712853Sgabeblack@google.com    }
97812853Sgabeblack@google.com
97912853Sgabeblack@google.com    // other methods
98012853Sgabeblack@google.com    void scan(::std::istream & =::std::cin);
98112853Sgabeblack@google.com
98212853Sgabeblack@google.com  private:
98312853Sgabeblack@google.com    // Disabled
98412853Sgabeblack@google.com    sc_subref();
98512853Sgabeblack@google.com};
98612853Sgabeblack@google.com
98712853Sgabeblack@google.com
98812853Sgabeblack@google.com// l-value concatenation operators and functions
98912853Sgabeblack@google.com
99012853Sgabeblack@google.comtemplate <class T1, class T2>
99112853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_bitref<T2> > operator , (
99212853Sgabeblack@google.com        sc_subref<T1>, sc_bitref<T2>);
99312853Sgabeblack@google.com
99412853Sgabeblack@google.comtemplate <class T1, class T2>
99512853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_subref<T2> > operator , (
99612853Sgabeblack@google.com        sc_subref<T1>, sc_subref<T2>);
99712853Sgabeblack@google.com
99812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
99912853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_concref<T2, T3> > operator , (
100012853Sgabeblack@google.com        sc_subref<T1>, sc_concref<T2, T3>);
100112853Sgabeblack@google.com
100212853Sgabeblack@google.comtemplate <class T1, class T2>
100312853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, T2> operator , (
100412853Sgabeblack@google.com        sc_subref<T1>, sc_proxy<T2> &);
100512853Sgabeblack@google.com
100612853Sgabeblack@google.com
100712853Sgabeblack@google.comtemplate <class T1, class T2>
100812853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_bitref<T2> > concat(
100912853Sgabeblack@google.com        sc_subref<T1>, sc_bitref<T2>);
101012853Sgabeblack@google.com
101112853Sgabeblack@google.comtemplate <class T1, class T2>
101212853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_subref<T2> > concat(
101312853Sgabeblack@google.com        sc_subref<T1>, sc_subref<T2>);
101412853Sgabeblack@google.com
101512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
101612853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_concref<T2, T3> > concat(
101712853Sgabeblack@google.com        sc_subref<T1>, sc_concref<T2, T3>);
101812853Sgabeblack@google.com
101912853Sgabeblack@google.comtemplate <class T1, class T2>
102012853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, T2> concat(sc_subref<T1>, sc_proxy<T2> &);
102112853Sgabeblack@google.com
102212853Sgabeblack@google.com
102312853Sgabeblack@google.comtemplate <class T>
102412853Sgabeblack@google.cominline ::std::istream &operator >> (::std::istream &, sc_subref<T>);
102512853Sgabeblack@google.com
102612853Sgabeblack@google.com
102712853Sgabeblack@google.com// ----------------------------------------------------------------------------
102812853Sgabeblack@google.com//  CLASS TEMPLATE : sc_concref_r<X,Y>
102912853Sgabeblack@google.com//
103012853Sgabeblack@google.com//  Proxy class for sc_proxy concatenation (r-value only).
103112853Sgabeblack@google.com// ----------------------------------------------------------------------------
103212853Sgabeblack@google.com
103312853Sgabeblack@google.comtemplate <class X, class Y>
103412853Sgabeblack@google.comclass sc_concref_r : public sc_proxy<sc_concref_r<X, Y> >
103512853Sgabeblack@google.com{
103612853Sgabeblack@google.com  public:
103712853Sgabeblack@google.com    typedef typename sc_proxy<sc_concref_r<X, Y> >::value_type value_type;
103812853Sgabeblack@google.com
103912853Sgabeblack@google.com    // constructor
104012853Sgabeblack@google.com    sc_concref_r(const X &left_, const Y &right_, int delete_=0) :
104112853Sgabeblack@google.com        m_left(const_cast<X &>(left_)), m_right(const_cast<Y &>(right_)),
104212853Sgabeblack@google.com          m_delete(delete_), m_refs(*new int(1))
104312853Sgabeblack@google.com    {}
104412853Sgabeblack@google.com
104512853Sgabeblack@google.com    // copy constructor
104612853Sgabeblack@google.com    sc_concref_r(const sc_concref_r<X, Y> &a) :
104712853Sgabeblack@google.com            m_left(a.m_left), m_right(a.m_right),
104812853Sgabeblack@google.com            m_delete(a.m_delete), m_refs(a.m_refs)
104912853Sgabeblack@google.com    { ++ m_refs; }
105012853Sgabeblack@google.com
105112853Sgabeblack@google.com    // destructor
105212853Sgabeblack@google.com    virtual ~sc_concref_r();
105312853Sgabeblack@google.com
105412853Sgabeblack@google.com    // cloning
105512853Sgabeblack@google.com    sc_concref_r<X, Y> *clone() const { return new sc_concref_r<X, Y>(*this); }
105612853Sgabeblack@google.com
105712853Sgabeblack@google.com    // common methods
105812853Sgabeblack@google.com    int length() const { return (m_left.length() + m_right.length()); }
105912853Sgabeblack@google.com
106012853Sgabeblack@google.com    int size() const { return ((length() - 1) / SC_DIGIT_SIZE + 1); }
106112853Sgabeblack@google.com
106212853Sgabeblack@google.com    value_type get_bit(int n) const;
106312853Sgabeblack@google.com    void set_bit(int n, value_type value);
106412853Sgabeblack@google.com
106512853Sgabeblack@google.com    sc_digit get_word(int i) const;
106612853Sgabeblack@google.com    void set_word(int i, sc_digit w);
106712853Sgabeblack@google.com
106812853Sgabeblack@google.com    sc_digit get_cword(int i) const;
106912853Sgabeblack@google.com    void set_cword(int i, sc_digit w);
107012853Sgabeblack@google.com
107112853Sgabeblack@google.com    void clean_tail() { m_left.clean_tail(); m_right.clean_tail(); }
107212853Sgabeblack@google.com
107312853Sgabeblack@google.com    // other methods
107412853Sgabeblack@google.com    bool is_01() const { return (m_left.is_01() && m_right.is_01()); }
107512853Sgabeblack@google.com
107612853Sgabeblack@google.com  protected:
107712853Sgabeblack@google.com    X &m_left;
107812853Sgabeblack@google.com    Y &m_right;
107912853Sgabeblack@google.com    mutable int m_delete;
108012853Sgabeblack@google.com    int &m_refs;
108112853Sgabeblack@google.com
108212853Sgabeblack@google.com  private:
108312853Sgabeblack@google.com    // Disabled
108412853Sgabeblack@google.com    sc_concref_r();
108512853Sgabeblack@google.com    sc_concref_r<X, Y> &operator = (const sc_concref_r<X, Y> &);
108612853Sgabeblack@google.com};
108712853Sgabeblack@google.com
108812853Sgabeblack@google.com
108912853Sgabeblack@google.com// r-value concatenation operators and functions
109012853Sgabeblack@google.com
109112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
109212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> > operator , (
109312853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_bitref_r<T3>);
109412853Sgabeblack@google.com
109512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
109612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
109712853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_subref_r<T3>);
109812853Sgabeblack@google.com
109912853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
110012853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
110112853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_concref_r<T3, T4>);
110212853Sgabeblack@google.com
110312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
110412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
110512853Sgabeblack@google.com        sc_concref_r<T1, T2>, const sc_proxy<T3> &);
110612853Sgabeblack@google.com
110712853Sgabeblack@google.comtemplate <class T1, class T2>
110812853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
110912853Sgabeblack@google.com        sc_concref_r<T1, T2>, const char *);
111012853Sgabeblack@google.com
111112853Sgabeblack@google.comtemplate <class T1, class T2>
111212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
111312853Sgabeblack@google.com        const char *, sc_concref_r<T1, T2>);
111412853Sgabeblack@google.com
111512853Sgabeblack@google.comtemplate <class T1, class T2>
111612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
111712853Sgabeblack@google.com        sc_concref_r<T1, T2>, const sc_logic &);
111812853Sgabeblack@google.com
111912853Sgabeblack@google.comtemplate <class T1, class T2>
112012853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
112112853Sgabeblack@google.com        const sc_logic &, sc_concref_r<T1, T2>);
112212853Sgabeblack@google.com
112312853Sgabeblack@google.comtemplate <class T1, class T2>
112412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> operator , (
112512853Sgabeblack@google.com        sc_concref_r<T1, T2>, bool);
112612853Sgabeblack@google.com
112712853Sgabeblack@google.comtemplate <class T1, class T2>
112812853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > operator , (
112912853Sgabeblack@google.com        bool, sc_concref_r<T1, T2>);
113012853Sgabeblack@google.com
113112853Sgabeblack@google.com
113212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
113312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
113412853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_bitref_r<T3>);
113512853Sgabeblack@google.com
113612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
113712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
113812853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_subref_r<T3>);
113912853Sgabeblack@google.com
114012853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
114112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
114212853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_concref_r<T3, T4>);
114312853Sgabeblack@google.com
114412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
114512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
114612853Sgabeblack@google.com        sc_concref_r<T1, T2>, const sc_proxy<T3> &);
114712853Sgabeblack@google.com
114812853Sgabeblack@google.comtemplate <class T1, class T2>
114912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
115012853Sgabeblack@google.com        sc_concref_r<T1, T2>, const char *);
115112853Sgabeblack@google.com
115212853Sgabeblack@google.comtemplate <class T1, class T2>
115312853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
115412853Sgabeblack@google.com        const char *, sc_concref_r<T1, T2>);
115512853Sgabeblack@google.com
115612853Sgabeblack@google.comtemplate <class T1, class T2>
115712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
115812853Sgabeblack@google.com        sc_concref_r<T1, T2>, const sc_logic &);
115912853Sgabeblack@google.com
116012853Sgabeblack@google.comtemplate <class T1, class T2>
116112853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
116212853Sgabeblack@google.com        const sc_logic &, sc_concref_r<T1, T2>);
116312853Sgabeblack@google.com
116412853Sgabeblack@google.comtemplate <class T1, class T2>
116512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> concat(
116612853Sgabeblack@google.com        sc_concref_r<T1, T2>, bool);
116712853Sgabeblack@google.com
116812853Sgabeblack@google.comtemplate <class T1, class T2>
116912853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > concat(
117012853Sgabeblack@google.com        bool, sc_concref_r<T1, T2>);
117112853Sgabeblack@google.com
117212853Sgabeblack@google.com
117312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
117412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > operator , (
117512853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_bitref<T3>);
117612853Sgabeblack@google.com
117712853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
117812853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > operator , (
117912853Sgabeblack@google.com        sc_concref<T1, T2>, sc_bitref_r<T3>);
118012853Sgabeblack@google.com
118112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
118212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
118312853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_subref<T3>);
118412853Sgabeblack@google.com
118512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
118612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > operator , (
118712853Sgabeblack@google.com        sc_concref<T1, T2>, sc_subref_r<T3>);
118812853Sgabeblack@google.com
118912853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
119012853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
119112853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_concref<T3, T4>);
119212853Sgabeblack@google.com
119312853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
119412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > operator , (
119512853Sgabeblack@google.com        sc_concref<T1, T2>, sc_concref_r<T3, T4>);
119612853Sgabeblack@google.com
119712853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
119812853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
119912853Sgabeblack@google.com        sc_concref<T1, T2>, const sc_proxy<T3> &);
120012853Sgabeblack@google.com
120112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
120212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> operator , (
120312853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_proxy<T3> &);
120412853Sgabeblack@google.com
120512853Sgabeblack@google.comtemplate <class T1, class T2>
120612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
120712853Sgabeblack@google.com        sc_concref<T1, T2>, const char *);
120812853Sgabeblack@google.com
120912853Sgabeblack@google.comtemplate <class T1, class T2>
121012853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
121112853Sgabeblack@google.com        const char *, sc_concref<T1, T2>);
121212853Sgabeblack@google.com
121312853Sgabeblack@google.comtemplate <class T1, class T2>
121412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> operator , (
121512853Sgabeblack@google.com        sc_concref<T1, T2>, const sc_logic &);
121612853Sgabeblack@google.com
121712853Sgabeblack@google.comtemplate <class T1, class T2>
121812853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > operator , (
121912853Sgabeblack@google.com        const sc_logic &, sc_concref<T1, T2>);
122012853Sgabeblack@google.com
122112853Sgabeblack@google.comtemplate <class T1, class T2>
122212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> operator , (
122312853Sgabeblack@google.com        sc_concref<T1, T2>, bool);
122412853Sgabeblack@google.com
122512853Sgabeblack@google.comtemplate <class T1, class T2>
122612853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > operator , (
122712853Sgabeblack@google.com        bool, sc_concref<T1, T2>);
122812853Sgabeblack@google.com
122912853Sgabeblack@google.com
123012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
123112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
123212853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_bitref<T3>);
123312853Sgabeblack@google.com
123412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
123512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> > concat(
123612853Sgabeblack@google.com        sc_concref<T1, T2>, sc_bitref_r<T3>);
123712853Sgabeblack@google.com
123812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
123912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
124012853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_subref<T3>);
124112853Sgabeblack@google.com
124212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
124312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> > concat(
124412853Sgabeblack@google.com        sc_concref<T1, T2>, sc_subref_r<T3>);
124512853Sgabeblack@google.com
124612853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
124712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
124812853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_concref<T3, T4>);
124912853Sgabeblack@google.com
125012853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
125112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> > concat(
125212853Sgabeblack@google.com        sc_concref<T1, T2>, sc_concref_r<T3, T4> );
125312853Sgabeblack@google.com
125412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
125512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
125612853Sgabeblack@google.com        sc_concref<T1, T2>, const sc_proxy<T3> &);
125712853Sgabeblack@google.com
125812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
125912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3> concat(
126012853Sgabeblack@google.com        sc_concref_r<T1, T2>, sc_proxy<T3> &);
126112853Sgabeblack@google.com
126212853Sgabeblack@google.comtemplate <class T1, class T2>
126312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
126412853Sgabeblack@google.com        sc_concref<T1, T2>, const char *);
126512853Sgabeblack@google.com
126612853Sgabeblack@google.comtemplate <class T1, class T2>
126712853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
126812853Sgabeblack@google.com        const char *, sc_concref<T1, T2>);
126912853Sgabeblack@google.com
127012853Sgabeblack@google.comtemplate <class T1, class T2>
127112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_lv_base> concat(
127212853Sgabeblack@google.com        sc_concref<T1, T2>, const sc_logic &);
127312853Sgabeblack@google.com
127412853Sgabeblack@google.comtemplate <class T1, class T2>
127512853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, sc_concref_r<T1, T2> > concat(
127612853Sgabeblack@google.com        const sc_logic &, sc_concref<T1, T2>);
127712853Sgabeblack@google.com
127812853Sgabeblack@google.comtemplate <class T1, class T2>
127912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bv_base> concat(
128012853Sgabeblack@google.com        sc_concref<T1, T2>, bool);
128112853Sgabeblack@google.com
128212853Sgabeblack@google.comtemplate <class T1, class T2>
128312853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, sc_concref_r<T1, T2> > concat(
128412853Sgabeblack@google.com        bool, sc_concref<T1, T2>);
128512853Sgabeblack@google.com
128612853Sgabeblack@google.com
128712853Sgabeblack@google.com// ----------------------------------------------------------------------------
128812853Sgabeblack@google.com//  CLASS TEMPLATE : sc_concref<X,Y>
128912853Sgabeblack@google.com//
129012853Sgabeblack@google.com//  Proxy class for sc_proxy concatenation (r-value and l-value).
129112853Sgabeblack@google.com// ----------------------------------------------------------------------------
129212853Sgabeblack@google.com
129312853Sgabeblack@google.comtemplate <class X, class Y>
129412853Sgabeblack@google.comclass sc_concref : public sc_concref_r<X, Y>
129512853Sgabeblack@google.com{
129612853Sgabeblack@google.com  public:
129712853Sgabeblack@google.com    // typedefs
129812853Sgabeblack@google.com    typedef sc_concref_r<X, Y> base_type;
129912853Sgabeblack@google.com
130012853Sgabeblack@google.com    // constructor
130112853Sgabeblack@google.com    sc_concref(X &left_, Y &right_, int delete_=0) :
130212853Sgabeblack@google.com            sc_concref_r<X, Y>(left_, right_, delete_)
130312853Sgabeblack@google.com    {}
130412853Sgabeblack@google.com
130512853Sgabeblack@google.com    // copy constructor
130612853Sgabeblack@google.com    sc_concref(const sc_concref<X, Y> &a) : sc_concref_r<X, Y>(a) {}
130712853Sgabeblack@google.com
130812853Sgabeblack@google.com    // cloning
130912853Sgabeblack@google.com    sc_concref<X, Y> *clone() const { return new sc_concref<X, Y>(*this); }
131012853Sgabeblack@google.com
131112853Sgabeblack@google.com    // assignment operators
131212853Sgabeblack@google.com    template <class Z>
131312853Sgabeblack@google.com    sc_concref<X, Y> &
131412853Sgabeblack@google.com    operator = (const sc_proxy<Z> &a)
131512853Sgabeblack@google.com    {
131612853Sgabeblack@google.com        base_type::assign_(a);
131712853Sgabeblack@google.com        return *this;
131812853Sgabeblack@google.com    }
131912853Sgabeblack@google.com
132012853Sgabeblack@google.com    sc_concref<X, Y> &
132112853Sgabeblack@google.com    operator = (const sc_concref<X, Y> &a)
132212853Sgabeblack@google.com    {
132312853Sgabeblack@google.com        base_type::assign_(a);
132412853Sgabeblack@google.com        return *this;
132512853Sgabeblack@google.com    }
132612853Sgabeblack@google.com
132712853Sgabeblack@google.com    sc_concref<X, Y> &
132812853Sgabeblack@google.com    operator = (const char *a)
132912853Sgabeblack@google.com    {
133012853Sgabeblack@google.com        base_type::assign_(a);
133112853Sgabeblack@google.com        return *this;
133212853Sgabeblack@google.com    }
133312853Sgabeblack@google.com
133412853Sgabeblack@google.com    sc_concref<X, Y> &
133512853Sgabeblack@google.com    operator = (const bool *a)
133612853Sgabeblack@google.com    {
133712853Sgabeblack@google.com        base_type::assign_(a);
133812853Sgabeblack@google.com        return *this;
133912853Sgabeblack@google.com    }
134012853Sgabeblack@google.com
134112853Sgabeblack@google.com    sc_concref<X, Y> &
134212853Sgabeblack@google.com    operator = (const sc_logic *a)
134312853Sgabeblack@google.com    {
134412853Sgabeblack@google.com        base_type::assign_(a);
134512853Sgabeblack@google.com        return *this;
134612853Sgabeblack@google.com    }
134712853Sgabeblack@google.com
134812853Sgabeblack@google.com    sc_concref<X, Y> &
134912853Sgabeblack@google.com    operator = (const sc_unsigned &a)
135012853Sgabeblack@google.com    {
135112853Sgabeblack@google.com        base_type::assign_(a);
135212853Sgabeblack@google.com        return *this;
135312853Sgabeblack@google.com    }
135412853Sgabeblack@google.com
135512853Sgabeblack@google.com    sc_concref<X, Y> &
135612853Sgabeblack@google.com    operator = (const sc_signed &a)
135712853Sgabeblack@google.com    {
135812853Sgabeblack@google.com        base_type::assign_(a);
135912853Sgabeblack@google.com        return *this;
136012853Sgabeblack@google.com    }
136112853Sgabeblack@google.com
136212853Sgabeblack@google.com    sc_concref<X, Y> &
136312853Sgabeblack@google.com    operator = (const sc_uint_base &a)
136412853Sgabeblack@google.com    {
136512853Sgabeblack@google.com        base_type::assign_(a);
136612853Sgabeblack@google.com        return *this;
136712853Sgabeblack@google.com    }
136812853Sgabeblack@google.com
136912853Sgabeblack@google.com    sc_concref<X, Y> &
137012853Sgabeblack@google.com    operator = (const sc_int_base &a)
137112853Sgabeblack@google.com    {
137212853Sgabeblack@google.com        base_type::assign_(a);
137312853Sgabeblack@google.com        return *this;
137412853Sgabeblack@google.com    }
137512853Sgabeblack@google.com
137612853Sgabeblack@google.com    sc_concref<X, Y> &
137712853Sgabeblack@google.com    operator = (unsigned long a)
137812853Sgabeblack@google.com    {
137912853Sgabeblack@google.com        base_type::assign_(a);
138012853Sgabeblack@google.com        return *this;
138112853Sgabeblack@google.com    }
138212853Sgabeblack@google.com
138312853Sgabeblack@google.com    sc_concref<X, Y> &
138412853Sgabeblack@google.com    operator = (long a)
138512853Sgabeblack@google.com    {
138612853Sgabeblack@google.com        base_type::assign_(a);
138712853Sgabeblack@google.com        return *this;
138812853Sgabeblack@google.com    }
138912853Sgabeblack@google.com
139012853Sgabeblack@google.com    sc_concref<X, Y> &
139112853Sgabeblack@google.com    operator = (unsigned int a)
139212853Sgabeblack@google.com    {
139312853Sgabeblack@google.com        base_type::assign_(a);
139412853Sgabeblack@google.com        return *this;
139512853Sgabeblack@google.com    }
139612853Sgabeblack@google.com
139712853Sgabeblack@google.com    sc_concref<X, Y> &
139812853Sgabeblack@google.com    operator = (int a)
139912853Sgabeblack@google.com    {
140012853Sgabeblack@google.com        base_type::assign_(a);
140112853Sgabeblack@google.com        return *this;
140212853Sgabeblack@google.com    }
140312853Sgabeblack@google.com
140412853Sgabeblack@google.com    sc_concref<X, Y> &
140512853Sgabeblack@google.com    operator = (uint64 a)
140612853Sgabeblack@google.com    {
140712853Sgabeblack@google.com        base_type::assign_(a);
140812853Sgabeblack@google.com        return *this;
140912853Sgabeblack@google.com    }
141012853Sgabeblack@google.com
141112853Sgabeblack@google.com    sc_concref<X, Y> &
141212853Sgabeblack@google.com    operator = (int64 a)
141312853Sgabeblack@google.com    {
141412853Sgabeblack@google.com        base_type::assign_(a);
141512853Sgabeblack@google.com        return *this;
141612853Sgabeblack@google.com    }
141712853Sgabeblack@google.com
141812853Sgabeblack@google.com    // other methods
141912853Sgabeblack@google.com    void scan(::std::istream & =::std::cin);
142012853Sgabeblack@google.com
142112853Sgabeblack@google.com  private:
142212853Sgabeblack@google.com    // Disabled
142312853Sgabeblack@google.com    sc_concref();
142412853Sgabeblack@google.com};
142512853Sgabeblack@google.com
142612853Sgabeblack@google.com
142712853Sgabeblack@google.com// l-value concatenation operators and functions
142812853Sgabeblack@google.com
142912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
143012853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> > operator , (
143112853Sgabeblack@google.com        sc_concref<T1, T2>, sc_bitref<T3>);
143212853Sgabeblack@google.com
143312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
143412853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_subref<T3> > operator , (
143512853Sgabeblack@google.com        sc_concref<T1, T2>, sc_subref<T3>);
143612853Sgabeblack@google.com
143712853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
143812853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> > operator , (
143912853Sgabeblack@google.com        sc_concref<T1, T2>, sc_concref<T3, T4>);
144012853Sgabeblack@google.com
144112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
144212853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, T3> operator , (
144312853Sgabeblack@google.com        sc_concref<T1, T2>, sc_proxy<T3> &);
144412853Sgabeblack@google.com
144512853Sgabeblack@google.com
144612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
144712853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> > concat(
144812853Sgabeblack@google.com        sc_concref<T1, T2>, sc_bitref<T3>);
144912853Sgabeblack@google.com
145012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
145112853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_subref<T3> > concat(
145212853Sgabeblack@google.com        sc_concref<T1, T2>, sc_subref<T3>);
145312853Sgabeblack@google.com
145412853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
145512853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> > concat(
145612853Sgabeblack@google.com        sc_concref<T1, T2>, sc_concref<T3, T4>);
145712853Sgabeblack@google.com
145812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
145912853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, T3> concat(
146012853Sgabeblack@google.com        sc_concref<T1, T2>, sc_proxy<T3> &);
146112853Sgabeblack@google.com
146212853Sgabeblack@google.com
146312853Sgabeblack@google.comtemplate <class T1, class T2>
146412853Sgabeblack@google.cominline ::std::istream &operator >> (::std::istream &, sc_concref<T1, T2>);
146512853Sgabeblack@google.com
146612853Sgabeblack@google.com
146712853Sgabeblack@google.com// ----------------------------------------------------------------------------
146812853Sgabeblack@google.com//  CLASS TEMPLATE : sc_proxy<T>
146912853Sgabeblack@google.com//
147012853Sgabeblack@google.com//  Base class template for bit/logic vector classes.
147112853Sgabeblack@google.com//  (Barton/Nackmann implementation)
147212853Sgabeblack@google.com// ----------------------------------------------------------------------------
147312853Sgabeblack@google.com
147412853Sgabeblack@google.com// r-value concatenation operators and functions
147512853Sgabeblack@google.com
147612853Sgabeblack@google.comtemplate <class T1, class T2>
147712853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
147812853Sgabeblack@google.com        const sc_proxy<T1> &, sc_bitref_r<T2>);
147912853Sgabeblack@google.com
148012853Sgabeblack@google.comtemplate <class T1, class T2>
148112853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > operator , (
148212853Sgabeblack@google.com        const sc_proxy<T1> &, sc_subref_r<T2>);
148312853Sgabeblack@google.com
148412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
148512853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
148612853Sgabeblack@google.com        const sc_proxy<T1> &, sc_concref_r<T2, T3>);
148712853Sgabeblack@google.com
148812853Sgabeblack@google.comtemplate <class T1, class T2>
148912853Sgabeblack@google.cominline sc_concref_r<T1, T2> operator , (
149012853Sgabeblack@google.com        const sc_proxy<T1> &, const sc_proxy<T2> &);
149112853Sgabeblack@google.com
149212853Sgabeblack@google.comtemplate <class T>
149312853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> operator , (
149412853Sgabeblack@google.com        const sc_proxy<T> &, const char *);
149512853Sgabeblack@google.com
149612853Sgabeblack@google.comtemplate <class T>
149712853Sgabeblack@google.cominline sc_concref_r<sc_lv_base,T> operator , (
149812853Sgabeblack@google.com        const char *, const sc_proxy<T> &);
149912853Sgabeblack@google.com
150012853Sgabeblack@google.comtemplate <class T>
150112853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> operator , (
150212853Sgabeblack@google.com        const sc_proxy<T> &, const sc_logic &);
150312853Sgabeblack@google.com
150412853Sgabeblack@google.comtemplate <class T>
150512853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> operator , (
150612853Sgabeblack@google.com        const sc_logic &, const sc_proxy<T> &);
150712853Sgabeblack@google.com
150812853Sgabeblack@google.comtemplate <class T>
150912853Sgabeblack@google.cominline sc_concref_r<T, sc_bv_base> operator , (const sc_proxy<T> &, bool);
151012853Sgabeblack@google.com
151112853Sgabeblack@google.comtemplate <class T>
151212853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, T> operator , (bool, const sc_proxy<T> &);
151312853Sgabeblack@google.com
151412853Sgabeblack@google.com
151512853Sgabeblack@google.comtemplate <class T1, class T2>
151612853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > concat(
151712853Sgabeblack@google.com        const sc_proxy<T1> &, sc_bitref_r<T2>);
151812853Sgabeblack@google.com
151912853Sgabeblack@google.comtemplate <class T1, class T2>
152012853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > concat(
152112853Sgabeblack@google.com        const sc_proxy<T1> &, sc_subref_r<T2>);
152212853Sgabeblack@google.com
152312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
152412853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
152512853Sgabeblack@google.com        const sc_proxy<T1> &, sc_concref_r<T2, T3>);
152612853Sgabeblack@google.com
152712853Sgabeblack@google.comtemplate <class T1, class T2>
152812853Sgabeblack@google.cominline sc_concref_r<T1, T2> concat(const sc_proxy<T1> &, const sc_proxy<T2> &);
152912853Sgabeblack@google.com
153012853Sgabeblack@google.comtemplate <class T>
153112853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> concat(const sc_proxy<T> &, const char *);
153212853Sgabeblack@google.com
153312853Sgabeblack@google.comtemplate <class T>
153412853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> concat(const char *, const sc_proxy<T> &);
153512853Sgabeblack@google.com
153612853Sgabeblack@google.comtemplate <class T>
153712853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> concat(
153812853Sgabeblack@google.com        const sc_proxy<T> &, const sc_logic &);
153912853Sgabeblack@google.com
154012853Sgabeblack@google.comtemplate <class T>
154112853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> concat(
154212853Sgabeblack@google.com        const sc_logic &, const sc_proxy<T> &);
154312853Sgabeblack@google.com
154412853Sgabeblack@google.comtemplate <class T>
154512853Sgabeblack@google.cominline sc_concref_r<T, sc_bv_base> concat(const sc_proxy<T> &, bool);
154612853Sgabeblack@google.com
154712853Sgabeblack@google.comtemplate <class T>
154812853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, T> concat(bool, const sc_proxy<T> &);
154912853Sgabeblack@google.com
155012853Sgabeblack@google.com
155112853Sgabeblack@google.comtemplate <class T1, class T2>
155212853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
155312853Sgabeblack@google.com        const sc_proxy<T1> &, sc_bitref<T2>);
155412853Sgabeblack@google.com
155512853Sgabeblack@google.comtemplate <class T1, class T2>
155612853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > operator , (
155712853Sgabeblack@google.com        sc_proxy<T1> &, sc_bitref_r<T2>);
155812853Sgabeblack@google.com
155912853Sgabeblack@google.comtemplate <class T1, class T2>
156012853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > operator , (
156112853Sgabeblack@google.com        const sc_proxy<T1> &, sc_subref<T2>);
156212853Sgabeblack@google.com
156312853Sgabeblack@google.comtemplate <class T1, class T2>
156412853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > operator , (
156512853Sgabeblack@google.com        sc_proxy<T1> &, sc_subref_r<T2>);
156612853Sgabeblack@google.com
156712853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
156812853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
156912853Sgabeblack@google.com        const sc_proxy<T1> &, sc_concref<T2, T3>);
157012853Sgabeblack@google.com
157112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
157212853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > operator , (
157312853Sgabeblack@google.com        sc_proxy<T1> &, sc_concref_r<T2, T3>);
157412853Sgabeblack@google.com
157512853Sgabeblack@google.comtemplate <class T1, class T2>
157612853Sgabeblack@google.cominline sc_concref_r<T1, T2> operator , (const sc_proxy<T1> &, sc_proxy<T2> &);
157712853Sgabeblack@google.com
157812853Sgabeblack@google.comtemplate <class T1, class T2>
157912853Sgabeblack@google.cominline sc_concref_r<T1, T2> operator , (sc_proxy<T1> &, const sc_proxy<T2> &);
158012853Sgabeblack@google.com
158112853Sgabeblack@google.comtemplate <class T>
158212853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> operator , (sc_proxy<T> &, const char *);
158312853Sgabeblack@google.com
158412853Sgabeblack@google.comtemplate <class T>
158512853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> operator , (const char *, sc_proxy<T> &);
158612853Sgabeblack@google.com
158712853Sgabeblack@google.comtemplate <class T>
158812853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> operator , (
158912853Sgabeblack@google.com        sc_proxy<T> &, const sc_logic &);
159012853Sgabeblack@google.com
159112853Sgabeblack@google.comtemplate <class T>
159212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> operator , (
159312853Sgabeblack@google.com        const sc_logic &, sc_proxy<T> &);
159412853Sgabeblack@google.com
159512853Sgabeblack@google.comtemplate <class T>
159612853Sgabeblack@google.cominline sc_concref_r<T, sc_bv_base> operator , (sc_proxy<T> &, bool);
159712853Sgabeblack@google.com
159812853Sgabeblack@google.comtemplate <class T>
159912853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, T> operator , (bool, sc_proxy<T> &);
160012853Sgabeblack@google.com
160112853Sgabeblack@google.com
160212853Sgabeblack@google.comtemplate <class T1, class T2>
160312853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > concat(
160412853Sgabeblack@google.com        const sc_proxy<T1> &, sc_bitref<T2>);
160512853Sgabeblack@google.com
160612853Sgabeblack@google.comtemplate <class T1, class T2>
160712853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> > concat(
160812853Sgabeblack@google.com        sc_proxy<T1> &, sc_bitref_r<T2>);
160912853Sgabeblack@google.com
161012853Sgabeblack@google.comtemplate <class T1, class T2>
161112853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > concat(
161212853Sgabeblack@google.com        const sc_proxy<T1> &, sc_subref<T2>);
161312853Sgabeblack@google.com
161412853Sgabeblack@google.comtemplate <class T1, class T2>
161512853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> > concat(
161612853Sgabeblack@google.com        sc_proxy<T1> &, sc_subref_r<T2>);
161712853Sgabeblack@google.com
161812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
161912853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
162012853Sgabeblack@google.com        const sc_proxy<T1> &, sc_concref<T2, T3>);
162112853Sgabeblack@google.com
162212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
162312853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> > concat(
162412853Sgabeblack@google.com        sc_proxy<T1> &, sc_concref_r<T2, T3>);
162512853Sgabeblack@google.com
162612853Sgabeblack@google.comtemplate <class T1, class T2>
162712853Sgabeblack@google.cominline sc_concref_r<T1, T2> concat(const sc_proxy<T1> &, sc_proxy<T2> &);
162812853Sgabeblack@google.com
162912853Sgabeblack@google.comtemplate <class T1, class T2>
163012853Sgabeblack@google.cominline sc_concref_r<T1, T2> concat(sc_proxy<T1> &, const sc_proxy<T2> &);
163112853Sgabeblack@google.com
163212853Sgabeblack@google.comtemplate <class T>
163312853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> concat(sc_proxy<T> &, const char *);
163412853Sgabeblack@google.com
163512853Sgabeblack@google.comtemplate <class T>
163612853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> concat(const char *, sc_proxy<T> &);
163712853Sgabeblack@google.com
163812853Sgabeblack@google.comtemplate <class T>
163912853Sgabeblack@google.cominline sc_concref_r<T, sc_lv_base> concat(sc_proxy<T> &, const sc_logic &);
164012853Sgabeblack@google.com
164112853Sgabeblack@google.comtemplate <class T>
164212853Sgabeblack@google.cominline sc_concref_r<sc_lv_base, T> concat(const sc_logic &, sc_proxy<T> &);
164312853Sgabeblack@google.com
164412853Sgabeblack@google.comtemplate <class T>
164512853Sgabeblack@google.cominline sc_concref_r<T, sc_bv_base> concat(sc_proxy<T> &, bool);
164612853Sgabeblack@google.com
164712853Sgabeblack@google.comtemplate <class T>
164812853Sgabeblack@google.cominline sc_concref_r<sc_bv_base, T> concat(bool, sc_proxy<T> &);
164912853Sgabeblack@google.com
165012853Sgabeblack@google.com
165112853Sgabeblack@google.com// l-value concatenation operators and functions
165212853Sgabeblack@google.comtemplate <class T1, class T2>
165312853Sgabeblack@google.cominline sc_concref<T1,sc_bitref<T2> > operator , (
165412853Sgabeblack@google.com        sc_proxy<T1> &, sc_bitref<T2>);
165512853Sgabeblack@google.com
165612853Sgabeblack@google.comtemplate <class T1, class T2>
165712853Sgabeblack@google.cominline sc_concref<T1, sc_subref<T2> > operator , (
165812853Sgabeblack@google.com        sc_proxy<T1> &, sc_subref<T2>);
165912853Sgabeblack@google.com
166012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
166112853Sgabeblack@google.cominline sc_concref<T1, sc_concref<T2, T3> > operator , (
166212853Sgabeblack@google.com        sc_proxy<T1> &, sc_concref<T2, T3>);
166312853Sgabeblack@google.com
166412853Sgabeblack@google.comtemplate <class T1, class T2>
166512853Sgabeblack@google.cominline sc_concref<T1, T2> operator , (sc_proxy<T1> &, sc_proxy<T2> &);
166612853Sgabeblack@google.com
166712853Sgabeblack@google.com
166812853Sgabeblack@google.comtemplate <class T1, class T2>
166912853Sgabeblack@google.cominline sc_concref<T1, sc_bitref<T2> > concat(sc_proxy<T1> &, sc_bitref<T2>);
167012853Sgabeblack@google.com
167112853Sgabeblack@google.comtemplate <class T1, class T2>
167212853Sgabeblack@google.cominline sc_concref<T1, sc_subref<T2> > concat(sc_proxy<T1> &, sc_subref<T2>);
167312853Sgabeblack@google.com
167412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
167512853Sgabeblack@google.cominline sc_concref<T1, sc_concref<T2, T3> > concat(
167612853Sgabeblack@google.com        sc_proxy<T1> &, sc_concref<T2, T3>);
167712853Sgabeblack@google.com
167812853Sgabeblack@google.comtemplate <class T1, class T2>
167912853Sgabeblack@google.cominline sc_concref<T1, T2> concat(sc_proxy<T1> &, sc_proxy<T2> &);
168012853Sgabeblack@google.com
168112853Sgabeblack@google.com
168212853Sgabeblack@google.com// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
168312853Sgabeblack@google.com
168412853Sgabeblack@google.com// ----------------------------------------------------------------------------
168512853Sgabeblack@google.com//  CLASS TEMPLATE : sc_bitref_r<T>
168612853Sgabeblack@google.com//
168712853Sgabeblack@google.com//  Proxy class for sc_proxy bit selection (r-value only).
168812853Sgabeblack@google.com// ----------------------------------------------------------------------------
168912853Sgabeblack@google.com
169012853Sgabeblack@google.com// bitwise operators and functions
169112853Sgabeblack@google.com
169212853Sgabeblack@google.com// bitwise and
169312853Sgabeblack@google.comtemplate <class T1, class T2>
169412853Sgabeblack@google.cominline sc_logic
169512853Sgabeblack@google.comoperator & (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
169612853Sgabeblack@google.com{
169712853Sgabeblack@google.com    return sc_logic(sc_logic::and_table[a.value()][b.value()]);
169812853Sgabeblack@google.com}
169912853Sgabeblack@google.com
170012853Sgabeblack@google.com// bitwise or
170112853Sgabeblack@google.comtemplate <class T1, class T2>
170212853Sgabeblack@google.cominline sc_logic
170312853Sgabeblack@google.comoperator | (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
170412853Sgabeblack@google.com{
170512853Sgabeblack@google.com    return sc_logic(sc_logic::or_table[a.value()][b.value()]);
170612853Sgabeblack@google.com}
170712853Sgabeblack@google.com
170812853Sgabeblack@google.com// bitwise xor
170912853Sgabeblack@google.comtemplate <class T1, class T2>
171012853Sgabeblack@google.cominline sc_logic
171112853Sgabeblack@google.comoperator ^ (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
171212853Sgabeblack@google.com{
171312853Sgabeblack@google.com    return sc_logic(sc_logic::xor_table[a.value()][b.value()]);
171412853Sgabeblack@google.com}
171512853Sgabeblack@google.com
171612853Sgabeblack@google.com// relational operators and functions
171712853Sgabeblack@google.comtemplate <class T1, class T2>
171812853Sgabeblack@google.cominline bool
171912853Sgabeblack@google.comoperator == (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
172012853Sgabeblack@google.com{
172112853Sgabeblack@google.com    return ((int)a.value() == b.value());
172212853Sgabeblack@google.com}
172312853Sgabeblack@google.com
172412853Sgabeblack@google.comtemplate <class T1, class T2>
172512853Sgabeblack@google.cominline bool
172612853Sgabeblack@google.comoperator != (const sc_bitref_r<T1> &a, const sc_bitref_r<T2> &b)
172712853Sgabeblack@google.com{
172812853Sgabeblack@google.com    return ((int)a.value() != b.value());
172912853Sgabeblack@google.com}
173012853Sgabeblack@google.com
173112853Sgabeblack@google.com// common methods
173212853Sgabeblack@google.comtemplate <class T>
173312853Sgabeblack@google.cominline typename sc_bitref_r<T>::value_type
173412853Sgabeblack@google.comsc_bitref_r<T>::get_bit(int n) const
173512853Sgabeblack@google.com{
173612853Sgabeblack@google.com    if (n == 0) {
173712853Sgabeblack@google.com        return m_obj.get_bit(m_index);
173812853Sgabeblack@google.com    } else {
173913322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
174012853Sgabeblack@google.com        return Log_0;
174112853Sgabeblack@google.com    }
174212853Sgabeblack@google.com}
174312853Sgabeblack@google.com
174412853Sgabeblack@google.comtemplate <class T>
174512853Sgabeblack@google.cominline sc_digit
174612853Sgabeblack@google.comsc_bitref_r<T>::get_word(int n) const
174712853Sgabeblack@google.com{
174812853Sgabeblack@google.com    if (n == 0) {
174912853Sgabeblack@google.com        return (get_bit(n) & SC_DIGIT_ONE);
175012853Sgabeblack@google.com    } else {
175113322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
175212853Sgabeblack@google.com        return 0;
175312853Sgabeblack@google.com    }
175412853Sgabeblack@google.com}
175512853Sgabeblack@google.com
175612853Sgabeblack@google.comtemplate <class T>
175712853Sgabeblack@google.cominline sc_digit
175812853Sgabeblack@google.comsc_bitref_r<T>::get_cword(int n) const
175912853Sgabeblack@google.com{
176012853Sgabeblack@google.com    if (n == 0) {
176112853Sgabeblack@google.com        return ((get_bit(n) & SC_DIGIT_TWO) >> 1);
176212853Sgabeblack@google.com    } else {
176313322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
176412853Sgabeblack@google.com        return 0;
176512853Sgabeblack@google.com    }
176612853Sgabeblack@google.com}
176712853Sgabeblack@google.com
176812853Sgabeblack@google.com// r-value concatenation operators and functions
176912853Sgabeblack@google.comtemplate <class T1, class T2>
177012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
177112853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_bitref_r<T2> b)
177212853Sgabeblack@google.com{
177312853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
177412853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
177512853Sgabeblack@google.com}
177612853Sgabeblack@google.com
177712853Sgabeblack@google.comtemplate <class T1, class T2>
177812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
177912853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_subref_r<T2> b)
178012853Sgabeblack@google.com{
178112853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
178212853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
178312853Sgabeblack@google.com}
178412853Sgabeblack@google.com
178512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
178612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
178712853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_concref_r<T2, T3> b)
178812853Sgabeblack@google.com{
178912853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
179012853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
179112853Sgabeblack@google.com}
179212853Sgabeblack@google.com
179312853Sgabeblack@google.comtemplate <class T1, class T2>
179412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
179512853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, const sc_proxy<T2> &b)
179612853Sgabeblack@google.com{
179712853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(
179812853Sgabeblack@google.com        *a.clone(), b.back_cast(), 1);
179912853Sgabeblack@google.com}
180012853Sgabeblack@google.com
180112853Sgabeblack@google.com
180212853Sgabeblack@google.comtemplate <class T1, class T2>
180312853Sgabeblack@google.cominline
180412853Sgabeblack@google.comsc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
180512853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_bitref_r<T2> b)
180612853Sgabeblack@google.com{
180712853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
180812853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
180912853Sgabeblack@google.com}
181012853Sgabeblack@google.com
181112853Sgabeblack@google.comtemplate <class T1, class T2>
181212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
181312853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_subref_r<T2> b)
181412853Sgabeblack@google.com{
181512853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
181612853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
181712853Sgabeblack@google.com}
181812853Sgabeblack@google.com
181912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
182012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
182112853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_concref_r<T2, T3> b)
182212853Sgabeblack@google.com{
182312853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
182412853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
182512853Sgabeblack@google.com}
182612853Sgabeblack@google.com
182712853Sgabeblack@google.comtemplate <class T1, class T2>
182812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
182912853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, const sc_proxy<T2> &b)
183012853Sgabeblack@google.com{
183112853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(
183212853Sgabeblack@google.com        *a.clone(), b.back_cast(), 1);
183312853Sgabeblack@google.com}
183412853Sgabeblack@google.com
183512853Sgabeblack@google.com
183612853Sgabeblack@google.comtemplate <class T1, class T2>
183712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
183812853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_bitref<T2> b)
183912853Sgabeblack@google.com{
184012853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
184112853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
184212853Sgabeblack@google.com}
184312853Sgabeblack@google.com
184412853Sgabeblack@google.comtemplate <class T1, class T2>
184512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
184612853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_bitref_r<T2> b)
184712853Sgabeblack@google.com{
184812853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
184912853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
185012853Sgabeblack@google.com}
185112853Sgabeblack@google.com
185212853Sgabeblack@google.comtemplate <class T1, class T2>
185312853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
185412853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_subref<T2> b)
185512853Sgabeblack@google.com{
185612853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
185712853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
185812853Sgabeblack@google.com}
185912853Sgabeblack@google.com
186012853Sgabeblack@google.comtemplate <class T1, class T2>
186112853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
186212853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_subref_r<T2> b)
186312853Sgabeblack@google.com{
186412853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
186512853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
186612853Sgabeblack@google.com}
186712853Sgabeblack@google.com
186812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
186912853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
187012853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_concref<T2, T3> b)
187112853Sgabeblack@google.com{
187212853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
187312853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
187412853Sgabeblack@google.com}
187512853Sgabeblack@google.com
187612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
187712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
187812853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_concref_r<T2, T3> b)
187912853Sgabeblack@google.com{
188012853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >(
188112853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
188212853Sgabeblack@google.com}
188312853Sgabeblack@google.com
188412853Sgabeblack@google.comtemplate <class T1, class T2>
188512853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
188612853Sgabeblack@google.comoperator , (sc_bitref<T1> a, const sc_proxy<T2> &b)
188712853Sgabeblack@google.com{
188812853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(
188912853Sgabeblack@google.com        *a.clone(), b.back_cast(), 1);
189012853Sgabeblack@google.com}
189112853Sgabeblack@google.com
189212853Sgabeblack@google.comtemplate <class T1, class T2>
189312853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
189412853Sgabeblack@google.comoperator , (sc_bitref_r<T1> a, sc_proxy<T2> &b)
189512853Sgabeblack@google.com{
189612853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(
189712853Sgabeblack@google.com        *a.clone(), b.back_cast(), 1);
189812853Sgabeblack@google.com}
189912853Sgabeblack@google.com
190012853Sgabeblack@google.com
190112853Sgabeblack@google.comtemplate <class T1, class T2>
190212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
190312853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_bitref<T2> b)
190412853Sgabeblack@google.com{
190512853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
190612853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
190712853Sgabeblack@google.com}
190812853Sgabeblack@google.com
190912853Sgabeblack@google.comtemplate <class T1, class T2>
191012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >
191112853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_bitref_r<T2> b)
191212853Sgabeblack@google.com{
191312853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> >(
191412853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
191512853Sgabeblack@google.com}
191612853Sgabeblack@google.com
191712853Sgabeblack@google.comtemplate <class T1, class T2>
191812853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
191912853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_subref<T2> b)
192012853Sgabeblack@google.com{
192112853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
192212853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
192312853Sgabeblack@google.com}
192412853Sgabeblack@google.com
192512853Sgabeblack@google.comtemplate <class T1, class T2>
192612853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >
192712853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_subref_r<T2> b)
192812853Sgabeblack@google.com{
192912853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_subref_r<T2> >(
193012853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
193112853Sgabeblack@google.com}
193212853Sgabeblack@google.com
193312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
193412853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
193512853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_concref<T2, T3> b)
193612853Sgabeblack@google.com{
193712853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> >(
193812853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
193912853Sgabeblack@google.com}
194012853Sgabeblack@google.com
194112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
194212853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2, T3> >
194312853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_concref_r<T2, T3> b)
194412853Sgabeblack@google.com{
194512853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, sc_concref_r<T2,T3> >(
194612853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
194712853Sgabeblack@google.com}
194812853Sgabeblack@google.com
194912853Sgabeblack@google.comtemplate <class T1, class T2>
195012853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
195112853Sgabeblack@google.comconcat(sc_bitref<T1> a, const sc_proxy<T2> &b)
195212853Sgabeblack@google.com{
195312853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
195412853Sgabeblack@google.com}
195512853Sgabeblack@google.com
195612853Sgabeblack@google.comtemplate <class T1, class T2>
195712853Sgabeblack@google.cominline sc_concref_r<sc_bitref_r<T1>, T2>
195812853Sgabeblack@google.comconcat(sc_bitref_r<T1> a, sc_proxy<T2> &b)
195912853Sgabeblack@google.com{
196012853Sgabeblack@google.com    return sc_concref_r<sc_bitref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
196112853Sgabeblack@google.com}
196212853Sgabeblack@google.com
196312853Sgabeblack@google.com
196412853Sgabeblack@google.com// ----------------------------------------------------------------------------
196512853Sgabeblack@google.com//  CLASS TEMPLATE : sc_bitref<X>
196612853Sgabeblack@google.com//
196712853Sgabeblack@google.com//  Proxy class for sc_proxy bit selection (r-value and l-value).
196812853Sgabeblack@google.com// ----------------------------------------------------------------------------
196912853Sgabeblack@google.com
197012853Sgabeblack@google.com// assignment operators
197112853Sgabeblack@google.comtemplate <class X>
197212853Sgabeblack@google.cominline sc_bitref<X> &
197312853Sgabeblack@google.comsc_bitref<X>::operator = (const sc_bitref_r<X> &a)
197412853Sgabeblack@google.com{
197512853Sgabeblack@google.com    this->m_obj.set_bit(this->m_index, a.value());
197612853Sgabeblack@google.com    return *this;
197712853Sgabeblack@google.com}
197812853Sgabeblack@google.com
197912853Sgabeblack@google.comtemplate <class X>
198012853Sgabeblack@google.cominline sc_bitref<X> &
198112853Sgabeblack@google.comsc_bitref<X>::operator = (const sc_bitref<X> &a)
198212853Sgabeblack@google.com{
198312853Sgabeblack@google.com    if (&a != this) {
198412853Sgabeblack@google.com        this->m_obj.set_bit(this->m_index, a.value());
198512853Sgabeblack@google.com    }
198612853Sgabeblack@google.com    return *this;
198712853Sgabeblack@google.com}
198812853Sgabeblack@google.com
198912853Sgabeblack@google.com
199012853Sgabeblack@google.com// bitwise assignment operators
199112853Sgabeblack@google.comtemplate <class X>
199212853Sgabeblack@google.cominline sc_bitref<X> &
199312853Sgabeblack@google.comsc_bitref<X>::operator &= (const sc_bitref_r<X> &a)
199412853Sgabeblack@google.com{
199512853Sgabeblack@google.com    if (&a != this) {
199612853Sgabeblack@google.com        this->m_obj.set_bit(
199712853Sgabeblack@google.com                this->m_index, sc_logic::and_table[this->value()][a.value()]);
199812853Sgabeblack@google.com    }
199912853Sgabeblack@google.com    return *this;
200012853Sgabeblack@google.com}
200112853Sgabeblack@google.com
200212853Sgabeblack@google.comtemplate <class X>
200312853Sgabeblack@google.cominline sc_bitref<X> &
200412853Sgabeblack@google.comsc_bitref<X>::operator &= (const sc_logic &a)
200512853Sgabeblack@google.com{
200612853Sgabeblack@google.com    this->m_obj.set_bit(
200712853Sgabeblack@google.com            this->m_index, sc_logic::and_table[this->value()][a.value()]);
200812853Sgabeblack@google.com    return *this;
200912853Sgabeblack@google.com}
201012853Sgabeblack@google.com
201112853Sgabeblack@google.com
201212853Sgabeblack@google.comtemplate <class X>
201312853Sgabeblack@google.cominline sc_bitref<X> &
201412853Sgabeblack@google.comsc_bitref<X>::operator |= (const sc_bitref_r<X> &a)
201512853Sgabeblack@google.com{
201612853Sgabeblack@google.com    if (&a != this) {
201712853Sgabeblack@google.com        this->m_obj.set_bit(
201812853Sgabeblack@google.com                this->m_index, sc_logic::or_table[this->value()][a.value()]);
201912853Sgabeblack@google.com    }
202012853Sgabeblack@google.com    return *this;
202112853Sgabeblack@google.com}
202212853Sgabeblack@google.com
202312853Sgabeblack@google.comtemplate <class X>
202412853Sgabeblack@google.cominline sc_bitref<X> &
202512853Sgabeblack@google.comsc_bitref<X>::operator |= (const sc_logic &a)
202612853Sgabeblack@google.com{
202712853Sgabeblack@google.com    this->m_obj.set_bit(
202812853Sgabeblack@google.com            this->m_index, sc_logic::or_table[this->value()][a.value()]);
202912853Sgabeblack@google.com    return *this;
203012853Sgabeblack@google.com}
203112853Sgabeblack@google.com
203212853Sgabeblack@google.com
203312853Sgabeblack@google.comtemplate <class X>
203412853Sgabeblack@google.cominline sc_bitref<X> &
203512853Sgabeblack@google.comsc_bitref<X>::operator ^= (const sc_bitref_r<X> &a)
203612853Sgabeblack@google.com{
203712853Sgabeblack@google.com    if (&a != this) {
203812853Sgabeblack@google.com        this->m_obj.set_bit(
203912853Sgabeblack@google.com                this->m_index, sc_logic::xor_table[this->value()][a.value()]);
204012853Sgabeblack@google.com    }
204112853Sgabeblack@google.com    return *this;
204212853Sgabeblack@google.com}
204312853Sgabeblack@google.com
204412853Sgabeblack@google.comtemplate <class X>
204512853Sgabeblack@google.cominline sc_bitref<X> &
204612853Sgabeblack@google.comsc_bitref<X>::operator ^= (const sc_logic &a)
204712853Sgabeblack@google.com{
204812853Sgabeblack@google.com    this->m_obj.set_bit(
204912853Sgabeblack@google.com            this->m_index, sc_logic::xor_table[this->value()][a.value()]);
205012853Sgabeblack@google.com    return *this;
205112853Sgabeblack@google.com}
205212853Sgabeblack@google.com
205312853Sgabeblack@google.com// bitwise operators and functions
205412853Sgabeblack@google.com
205512853Sgabeblack@google.com// bitwise complement
205612853Sgabeblack@google.comtemplate <class X>
205712853Sgabeblack@google.cominline sc_bitref<X> &
205812853Sgabeblack@google.comsc_bitref<X>::b_not()
205912853Sgabeblack@google.com{
206012853Sgabeblack@google.com    this->m_obj.set_bit(this->m_index, sc_logic::not_table[this->value()]);
206112853Sgabeblack@google.com    return *this;
206212853Sgabeblack@google.com}
206312853Sgabeblack@google.com
206412853Sgabeblack@google.com// common methods
206512853Sgabeblack@google.comtemplate <class X>
206612853Sgabeblack@google.cominline void
206712853Sgabeblack@google.comsc_bitref<X>::set_bit(int n, value_type value)
206812853Sgabeblack@google.com{
206912853Sgabeblack@google.com    if (n == 0) {
207012853Sgabeblack@google.com        this->m_obj.set_bit(this->m_index, value);
207112853Sgabeblack@google.com    } else {
207213322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
207312853Sgabeblack@google.com    }
207412853Sgabeblack@google.com}
207512853Sgabeblack@google.com
207612853Sgabeblack@google.comtemplate <class X>
207712853Sgabeblack@google.cominline void
207812853Sgabeblack@google.comsc_bitref<X>::set_word(int n, sc_digit w)
207912853Sgabeblack@google.com{
208012853Sgabeblack@google.com    unsigned int bi = this->m_index % (8 * sizeof(sc_digit));
208112853Sgabeblack@google.com    sc_digit temp;
208212853Sgabeblack@google.com    unsigned int wi = this->m_index / (8 * sizeof(sc_digit));
208312853Sgabeblack@google.com    if (n == 0) {
208412853Sgabeblack@google.com        temp = this->m_obj.get_word(wi);
208512853Sgabeblack@google.com        temp = (temp & ~(1 << bi)) | ((w & 1) << bi);
208612853Sgabeblack@google.com        this->m_obj.set_word(wi, temp);
208712853Sgabeblack@google.com    } else {
208813322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
208912853Sgabeblack@google.com    }
209012853Sgabeblack@google.com}
209112853Sgabeblack@google.com
209212853Sgabeblack@google.comtemplate <class X>
209312853Sgabeblack@google.cominline void
209412853Sgabeblack@google.comsc_bitref<X>::set_cword(int n, sc_digit w)
209512853Sgabeblack@google.com{
209612853Sgabeblack@google.com    unsigned int bi = this->m_index % (8 * sizeof(sc_digit));
209712853Sgabeblack@google.com    sc_digit temp;
209812853Sgabeblack@google.com    unsigned int wi = this->m_index / (8 * sizeof(sc_digit));
209912853Sgabeblack@google.com    if (n == 0) {
210012853Sgabeblack@google.com        temp = this->m_obj.get_cword(wi);
210112853Sgabeblack@google.com        temp = (temp & ~(1 << bi)) | ((w & 1) << bi);
210212853Sgabeblack@google.com        this->m_obj.set_cword(wi, temp);
210312853Sgabeblack@google.com    } else {
210413322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
210512853Sgabeblack@google.com    }
210612853Sgabeblack@google.com}
210712853Sgabeblack@google.com
210812853Sgabeblack@google.com// other methods
210912853Sgabeblack@google.comtemplate <class X>
211012853Sgabeblack@google.cominline void
211112853Sgabeblack@google.comsc_bitref<X>::scan(::std::istream &is)
211212853Sgabeblack@google.com{
211312853Sgabeblack@google.com    char c;
211412853Sgabeblack@google.com    is >> c;
211512853Sgabeblack@google.com    *this = c;
211612853Sgabeblack@google.com}
211712853Sgabeblack@google.com
211812853Sgabeblack@google.com// l-value concatenation operators and functions
211912853Sgabeblack@google.comtemplate <class T1, class T2>
212012853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_bitref<T2> >
212112853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_bitref<T2> b)
212212853Sgabeblack@google.com{
212312853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_bitref<T2> >(
212412853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
212512853Sgabeblack@google.com}
212612853Sgabeblack@google.com
212712853Sgabeblack@google.comtemplate <class T1, class T2>
212812853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_subref<T2> >
212912853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_subref<T2> b)
213012853Sgabeblack@google.com{
213112853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_subref<T2> >(
213212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
213312853Sgabeblack@google.com}
213412853Sgabeblack@google.com
213512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
213612853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >
213712853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_concref<T2, T3> b)
213812853Sgabeblack@google.com{
213912853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >(
214012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
214112853Sgabeblack@google.com}
214212853Sgabeblack@google.com
214312853Sgabeblack@google.comtemplate <class T1, class T2>
214412853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, T2>
214512853Sgabeblack@google.comoperator , (sc_bitref<T1> a, sc_proxy<T2> &b)
214612853Sgabeblack@google.com{
214712853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, T2>(*a.clone(), b.back_cast(), 1);
214812853Sgabeblack@google.com}
214912853Sgabeblack@google.com
215012853Sgabeblack@google.com
215112853Sgabeblack@google.comtemplate <class T1, class T2>
215212853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_bitref<T2> >
215312853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_bitref<T2> b)
215412853Sgabeblack@google.com{
215512853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_bitref<T2> >(
215612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
215712853Sgabeblack@google.com}
215812853Sgabeblack@google.com
215912853Sgabeblack@google.comtemplate <class T1, class T2>
216012853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_subref<T2> >
216112853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_subref<T2> b)
216212853Sgabeblack@google.com{
216312853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_subref<T2> >(
216412853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
216512853Sgabeblack@google.com}
216612853Sgabeblack@google.com
216712853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
216812853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, sc_concref<T2, T3> >
216912853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_concref<T2, T3> b)
217012853Sgabeblack@google.com{
217112853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, sc_concref<T2,T3> >(
217212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
217312853Sgabeblack@google.com}
217412853Sgabeblack@google.com
217512853Sgabeblack@google.comtemplate <class T1, class T2>
217612853Sgabeblack@google.cominline sc_concref<sc_bitref<T1>, T2>
217712853Sgabeblack@google.comconcat(sc_bitref<T1> a, sc_proxy<T2> &b)
217812853Sgabeblack@google.com{
217912853Sgabeblack@google.com    return sc_concref<sc_bitref<T1>, T2>(*a.clone(), b.back_cast(), 1);
218012853Sgabeblack@google.com}
218112853Sgabeblack@google.com
218212853Sgabeblack@google.comtemplate <class X>
218312853Sgabeblack@google.cominline ::std::istream &
218412853Sgabeblack@google.comoperator >> (::std::istream &is, sc_bitref<X> a)
218512853Sgabeblack@google.com{
218612853Sgabeblack@google.com    a.scan(is);
218712853Sgabeblack@google.com    return is;
218812853Sgabeblack@google.com}
218912853Sgabeblack@google.com
219012853Sgabeblack@google.com
219112853Sgabeblack@google.com// ----------------------------------------------------------------------------
219212853Sgabeblack@google.com//  CLASS TEMPLATE : sc_subref_r<X>
219312853Sgabeblack@google.com//
219412853Sgabeblack@google.com//  Proxy class for sc_proxy part selection (r-value only).
219512853Sgabeblack@google.com// ----------------------------------------------------------------------------
219612853Sgabeblack@google.com
219712853Sgabeblack@google.comtemplate <class X>
219812853Sgabeblack@google.cominline void
219912853Sgabeblack@google.comsc_subref_r<X>::check_bounds()
220012853Sgabeblack@google.com{
220112853Sgabeblack@google.com    int len = m_obj.length();
220212853Sgabeblack@google.com    if (m_hi < 0 || m_hi >= len || m_lo < 0 || m_lo >= len) {
220313322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
220412853Sgabeblack@google.com        sc_core::sc_abort(); // can't recover from here
220512853Sgabeblack@google.com    }
220612853Sgabeblack@google.com    if (reversed()) {
220712853Sgabeblack@google.com        m_len = m_lo - m_hi + 1;
220812853Sgabeblack@google.com    } else {
220912853Sgabeblack@google.com        m_len = m_hi - m_lo + 1;
221012853Sgabeblack@google.com    }
221112853Sgabeblack@google.com}
221212853Sgabeblack@google.com
221312853Sgabeblack@google.com// common methods
221412853Sgabeblack@google.comtemplate <class X>
221512853Sgabeblack@google.cominline typename sc_subref_r<X>::value_type
221612853Sgabeblack@google.comsc_subref_r<X>::get_bit(int n) const
221712853Sgabeblack@google.com{
221812853Sgabeblack@google.com    if (reversed()) {
221912853Sgabeblack@google.com        return m_obj.get_bit(m_lo - n);
222012853Sgabeblack@google.com    } else {
222112853Sgabeblack@google.com        return m_obj.get_bit(m_lo + n);
222212853Sgabeblack@google.com    }
222312853Sgabeblack@google.com}
222412853Sgabeblack@google.com
222512853Sgabeblack@google.comtemplate <class X>
222612853Sgabeblack@google.cominline void
222712853Sgabeblack@google.comsc_subref_r<X>::set_bit(int n, value_type value)
222812853Sgabeblack@google.com{
222912853Sgabeblack@google.com    if (reversed()) {
223012853Sgabeblack@google.com        m_obj.set_bit(m_lo - n, value);
223112853Sgabeblack@google.com    } else {
223212853Sgabeblack@google.com        m_obj.set_bit(m_lo + n, value);
223312853Sgabeblack@google.com    }
223412853Sgabeblack@google.com}
223512853Sgabeblack@google.com
223612853Sgabeblack@google.comtemplate <class X>
223712853Sgabeblack@google.cominline sc_digit
223812853Sgabeblack@google.comsc_subref_r<X>::get_word(int i) const
223912853Sgabeblack@google.com{
224012853Sgabeblack@google.com    int n1 = 0;
224112853Sgabeblack@google.com    int n2 = 0;
224212853Sgabeblack@google.com    sc_digit result = 0;
224312853Sgabeblack@google.com    int k = 0;
224412853Sgabeblack@google.com    if (reversed()) {
224512853Sgabeblack@google.com        n1 = m_lo - i * SC_DIGIT_SIZE;
224612853Sgabeblack@google.com        n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
224712853Sgabeblack@google.com        for (int n = n1; n > n2; n--) {
224812853Sgabeblack@google.com            result |= (m_obj[n].value() & SC_DIGIT_ONE) << k++;
224912853Sgabeblack@google.com        }
225012853Sgabeblack@google.com    } else {
225112853Sgabeblack@google.com        n1 = m_lo + i * SC_DIGIT_SIZE;
225212853Sgabeblack@google.com        n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
225312853Sgabeblack@google.com        for (int n = n1; n < n2; n++) {
225412853Sgabeblack@google.com            result |= (m_obj[n].value() & SC_DIGIT_ONE) << k++;
225512853Sgabeblack@google.com        }
225612853Sgabeblack@google.com    }
225712853Sgabeblack@google.com    return result;
225812853Sgabeblack@google.com}
225912853Sgabeblack@google.com
226012853Sgabeblack@google.comtemplate <class X>
226112853Sgabeblack@google.cominline void
226212853Sgabeblack@google.comsc_subref_r<X>::set_word(int i, sc_digit w)
226312853Sgabeblack@google.com{
226412853Sgabeblack@google.com    int n1 = 0;
226512853Sgabeblack@google.com    int n2 = 0;
226612853Sgabeblack@google.com    int k = 0;
226712853Sgabeblack@google.com    if (reversed()) {
226812853Sgabeblack@google.com        n1 = m_lo - i * SC_DIGIT_SIZE;
226912853Sgabeblack@google.com        n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
227012853Sgabeblack@google.com        for (int n = n1; n > n2; n--) {
227112853Sgabeblack@google.com            m_obj.set_bit(n, value_type(
227212853Sgabeblack@google.com                    ((w >> k++) & SC_DIGIT_ONE) |
227312853Sgabeblack@google.com                    (m_obj[n].value() & SC_DIGIT_TWO)));
227412853Sgabeblack@google.com        }
227512853Sgabeblack@google.com    } else {
227612853Sgabeblack@google.com        n1 = m_lo + i * SC_DIGIT_SIZE;
227712853Sgabeblack@google.com        n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
227812853Sgabeblack@google.com        for (int n = n1; n < n2; n++) {
227912853Sgabeblack@google.com            m_obj.set_bit(n, value_type(
228012853Sgabeblack@google.com                    ((w >> k++) & SC_DIGIT_ONE) |
228112853Sgabeblack@google.com                    (m_obj[n].value() & SC_DIGIT_TWO)));
228212853Sgabeblack@google.com        }
228312853Sgabeblack@google.com    }
228412853Sgabeblack@google.com}
228512853Sgabeblack@google.com
228612853Sgabeblack@google.com
228712853Sgabeblack@google.comtemplate <class X>
228812853Sgabeblack@google.cominline sc_digit
228912853Sgabeblack@google.comsc_subref_r<X>::get_cword(int i) const
229012853Sgabeblack@google.com{
229112853Sgabeblack@google.com    int n1 = 0;
229212853Sgabeblack@google.com    int n2 = 0;
229312853Sgabeblack@google.com    sc_digit result = 0;
229412853Sgabeblack@google.com    int k = 0;
229512853Sgabeblack@google.com    if (reversed()) {
229612853Sgabeblack@google.com        n1 = m_lo - i * SC_DIGIT_SIZE;
229712853Sgabeblack@google.com        n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
229812853Sgabeblack@google.com        for (int n = n1; n > n2; n--) {
229912853Sgabeblack@google.com            result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k++;
230012853Sgabeblack@google.com        }
230112853Sgabeblack@google.com    } else {
230212853Sgabeblack@google.com        n1 = m_lo + i * SC_DIGIT_SIZE;
230312853Sgabeblack@google.com        n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
230412853Sgabeblack@google.com        for (int n = n1; n < n2; n++) {
230512853Sgabeblack@google.com            result |= ((m_obj[n].value() & SC_DIGIT_TWO) >> 1) << k++;
230612853Sgabeblack@google.com        }
230712853Sgabeblack@google.com    }
230812853Sgabeblack@google.com    return result;
230912853Sgabeblack@google.com}
231012853Sgabeblack@google.com
231112853Sgabeblack@google.comtemplate <class X>
231212853Sgabeblack@google.cominline void
231312853Sgabeblack@google.comsc_subref_r<X>::set_cword(int i, sc_digit w)
231412853Sgabeblack@google.com{
231512853Sgabeblack@google.com    int n1 = 0;
231612853Sgabeblack@google.com    int n2 = 0;
231712853Sgabeblack@google.com    int k = 0;
231812853Sgabeblack@google.com    if (reversed()) {
231912853Sgabeblack@google.com        n1 = m_lo - i * SC_DIGIT_SIZE;
232012853Sgabeblack@google.com        n2 = sc_max(n1 - SC_DIGIT_SIZE, m_hi - 1);
232112853Sgabeblack@google.com        for (int n = n1; n > n2; n--) {
232212853Sgabeblack@google.com            m_obj.set_bit(n, value_type(
232312853Sgabeblack@google.com                    (((w >> k++) & SC_DIGIT_ONE) << 1) |
232412853Sgabeblack@google.com                    (m_obj[n].value() & SC_DIGIT_ONE)));
232512853Sgabeblack@google.com        }
232612853Sgabeblack@google.com    } else {
232712853Sgabeblack@google.com        n1 = m_lo + i * SC_DIGIT_SIZE;
232812853Sgabeblack@google.com        n2 = sc_min(n1 + SC_DIGIT_SIZE, m_hi + 1);
232912853Sgabeblack@google.com        for (int n = n1; n < n2; n++) {
233012853Sgabeblack@google.com            m_obj.set_bit(n, value_type(
233112853Sgabeblack@google.com                    (((w >> k++) & SC_DIGIT_ONE) << 1) |
233212853Sgabeblack@google.com                    (m_obj[n].value() & SC_DIGIT_ONE)));
233312853Sgabeblack@google.com        }
233412853Sgabeblack@google.com    }
233512853Sgabeblack@google.com}
233612853Sgabeblack@google.com
233712853Sgabeblack@google.com// other methods
233812853Sgabeblack@google.comtemplate <class X>
233912853Sgabeblack@google.cominline bool
234012853Sgabeblack@google.comsc_subref_r<X>::is_01() const
234112853Sgabeblack@google.com{
234212853Sgabeblack@google.com    int sz = size();
234312853Sgabeblack@google.com    for (int i = 0; i < sz; ++i) {
234412853Sgabeblack@google.com        if (get_cword(i) != SC_DIGIT_ZERO) {
234512853Sgabeblack@google.com            return false;
234612853Sgabeblack@google.com        }
234712853Sgabeblack@google.com    }
234812853Sgabeblack@google.com    return true;
234912853Sgabeblack@google.com}
235012853Sgabeblack@google.com
235112853Sgabeblack@google.com// r-value concatenation operators and functions
235212853Sgabeblack@google.comtemplate <class T1, class T2>
235312853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
235412853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_bitref_r<T2> b)
235512853Sgabeblack@google.com{
235612853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
235712853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
235812853Sgabeblack@google.com}
235912853Sgabeblack@google.com
236012853Sgabeblack@google.comtemplate <class T1, class T2>
236112853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
236212853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_subref_r<T2> b)
236312853Sgabeblack@google.com{
236412853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
236512853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
236612853Sgabeblack@google.com}
236712853Sgabeblack@google.com
236812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
236912853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
237012853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_concref_r<T2, T3> b)
237112853Sgabeblack@google.com{
237212853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
237312853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
237412853Sgabeblack@google.com}
237512853Sgabeblack@google.com
237612853Sgabeblack@google.comtemplate <class T1, class T2>
237712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
237812853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, const sc_proxy<T2> &b)
237912853Sgabeblack@google.com{
238012853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(
238112853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
238212853Sgabeblack@google.com}
238312853Sgabeblack@google.com
238412853Sgabeblack@google.com
238512853Sgabeblack@google.comtemplate <class T1, class T2>
238612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
238712853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_bitref_r<T2> b)
238812853Sgabeblack@google.com{
238912853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
239012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
239112853Sgabeblack@google.com}
239212853Sgabeblack@google.com
239312853Sgabeblack@google.comtemplate <class T1, class T2>
239412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
239512853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_subref_r<T2> b)
239612853Sgabeblack@google.com{
239712853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
239812853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
239912853Sgabeblack@google.com}
240012853Sgabeblack@google.com
240112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
240212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
240312853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_concref_r<T2, T3> b)
240412853Sgabeblack@google.com{
240512853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
240612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
240712853Sgabeblack@google.com}
240812853Sgabeblack@google.com
240912853Sgabeblack@google.comtemplate <class T1, class T2>
241012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
241112853Sgabeblack@google.comconcat(sc_subref_r<T1> a, const sc_proxy<T2> &b)
241212853Sgabeblack@google.com{
241312853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
241412853Sgabeblack@google.com}
241512853Sgabeblack@google.com
241612853Sgabeblack@google.com
241712853Sgabeblack@google.comtemplate <class T1, class T2>
241812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
241912853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_bitref<T2> b)
242012853Sgabeblack@google.com{
242112853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
242212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
242312853Sgabeblack@google.com}
242412853Sgabeblack@google.com
242512853Sgabeblack@google.comtemplate <class T1, class T2>
242612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
242712853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_bitref_r<T2> b)
242812853Sgabeblack@google.com{
242912853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
243012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
243112853Sgabeblack@google.com}
243212853Sgabeblack@google.com
243312853Sgabeblack@google.comtemplate <class T1, class T2>
243412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
243512853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_subref<T2> b)
243612853Sgabeblack@google.com{
243712853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
243812853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
243912853Sgabeblack@google.com}
244012853Sgabeblack@google.com
244112853Sgabeblack@google.comtemplate <class T1, class T2>
244212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
244312853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_subref_r<T2> b)
244412853Sgabeblack@google.com{
244512853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
244612853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
244712853Sgabeblack@google.com}
244812853Sgabeblack@google.com
244912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
245012853Sgabeblack@google.cominline
245112853Sgabeblack@google.comsc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
245212853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_concref<T2, T3> b)
245312853Sgabeblack@google.com{
245412853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
245512853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
245612853Sgabeblack@google.com}
245712853Sgabeblack@google.com
245812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
245912853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
246012853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_concref_r<T2, T3> b)
246112853Sgabeblack@google.com{
246212853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
246312853Sgabeblack@google.com        *a.clone(), *b.clone(), 3);
246412853Sgabeblack@google.com}
246512853Sgabeblack@google.com
246612853Sgabeblack@google.comtemplate <class T1, class T2>
246712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
246812853Sgabeblack@google.comoperator , (sc_subref<T1> a, const sc_proxy<T2> &b)
246912853Sgabeblack@google.com{
247012853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
247112853Sgabeblack@google.com}
247212853Sgabeblack@google.com
247312853Sgabeblack@google.comtemplate <class T1, class T2>
247412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
247512853Sgabeblack@google.comoperator , (sc_subref_r<T1> a, sc_proxy<T2> &b)
247612853Sgabeblack@google.com{
247712853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
247812853Sgabeblack@google.com}
247912853Sgabeblack@google.com
248012853Sgabeblack@google.com
248112853Sgabeblack@google.comtemplate <class T1, class T2>
248212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
248312853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_bitref<T2> b)
248412853Sgabeblack@google.com{
248512853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
248612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
248712853Sgabeblack@google.com}
248812853Sgabeblack@google.com
248912853Sgabeblack@google.comtemplate <class T1, class T2>
249012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >
249112853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_bitref_r<T2> b)
249212853Sgabeblack@google.com{
249312853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_bitref_r<T2> >(
249412853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
249512853Sgabeblack@google.com}
249612853Sgabeblack@google.com
249712853Sgabeblack@google.comtemplate <class T1, class T2>
249812853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
249912853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_subref<T2> b)
250012853Sgabeblack@google.com{
250112853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
250212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
250312853Sgabeblack@google.com}
250412853Sgabeblack@google.com
250512853Sgabeblack@google.comtemplate <class T1, class T2>
250612853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >
250712853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_subref_r<T2> b)
250812853Sgabeblack@google.com{
250912853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_subref_r<T2> >(
251012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
251112853Sgabeblack@google.com}
251212853Sgabeblack@google.com
251312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
251412853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
251512853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_concref<T2, T3> b)
251612853Sgabeblack@google.com{
251712853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
251812853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
251912853Sgabeblack@google.com}
252012853Sgabeblack@google.com
252112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
252212853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >
252312853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_concref_r<T2, T3> b)
252412853Sgabeblack@google.com{
252512853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, sc_concref_r<T2, T3> >(
252612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
252712853Sgabeblack@google.com}
252812853Sgabeblack@google.com
252912853Sgabeblack@google.comtemplate <class T1, class T2>
253012853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
253112853Sgabeblack@google.comconcat(sc_subref<T1> a, const sc_proxy<T2> &b)
253212853Sgabeblack@google.com{
253312853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
253412853Sgabeblack@google.com}
253512853Sgabeblack@google.com
253612853Sgabeblack@google.comtemplate <class T1, class T2>
253712853Sgabeblack@google.cominline sc_concref_r<sc_subref_r<T1>, T2>
253812853Sgabeblack@google.comconcat(sc_subref_r<T1> a, sc_proxy<T2> &b)
253912853Sgabeblack@google.com{
254012853Sgabeblack@google.com    return sc_concref_r<sc_subref_r<T1>, T2>(*a.clone(), b.back_cast(), 1);
254112853Sgabeblack@google.com}
254212853Sgabeblack@google.com
254312853Sgabeblack@google.com
254412853Sgabeblack@google.com// ----------------------------------------------------------------------------
254512853Sgabeblack@google.com//  CLASS TEMPLATE : sc_subref<X>
254612853Sgabeblack@google.com//
254712853Sgabeblack@google.com//  Proxy class for sc_proxy part selection (r-value and l-value).
254812853Sgabeblack@google.com// ----------------------------------------------------------------------------
254912853Sgabeblack@google.com
255012853Sgabeblack@google.com// assignment operators
255112853Sgabeblack@google.com// sc_subref<X>::operator = ( const sc_subref_r<X>& ) in sc_lv_base.h
255212853Sgabeblack@google.com// sc_subref<X>::operator = ( const sc_subref<X>& )   in sc_lv_base.h
255312853Sgabeblack@google.com
255412853Sgabeblack@google.com// other methods
255512853Sgabeblack@google.comtemplate <class T>
255612853Sgabeblack@google.cominline void
255712853Sgabeblack@google.comsc_subref<T>::scan(::std::istream &is)
255812853Sgabeblack@google.com{
255912853Sgabeblack@google.com    std::string s;
256012853Sgabeblack@google.com    is >> s;
256112853Sgabeblack@google.com    *this = s.c_str();
256212853Sgabeblack@google.com}
256312853Sgabeblack@google.com
256412853Sgabeblack@google.com// l-value concatenation operators and functions
256512853Sgabeblack@google.comtemplate <class T1, class T2>
256612853Sgabeblack@google.cominline
256712853Sgabeblack@google.comsc_concref<sc_subref<T1>, sc_bitref<T2> >
256812853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_bitref<T2> b)
256912853Sgabeblack@google.com{
257012853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_bitref<T2> >(
257112853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
257212853Sgabeblack@google.com}
257312853Sgabeblack@google.com
257412853Sgabeblack@google.comtemplate <class T1, class T2>
257512853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_subref<T2> >
257612853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_subref<T2> b)
257712853Sgabeblack@google.com{
257812853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_subref<T2> >(
257912853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
258012853Sgabeblack@google.com}
258112853Sgabeblack@google.com
258212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
258312853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_concref<T2,T3> >
258412853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_concref<T2, T3> b)
258512853Sgabeblack@google.com{
258612853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_concref<T2, T3> >(
258712853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
258812853Sgabeblack@google.com}
258912853Sgabeblack@google.com
259012853Sgabeblack@google.comtemplate <class T1, class T2>
259112853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, T2>
259212853Sgabeblack@google.comoperator , (sc_subref<T1> a, sc_proxy<T2> &b)
259312853Sgabeblack@google.com{
259412853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, T2>(*a.clone(), b.back_cast(), 1);
259512853Sgabeblack@google.com}
259612853Sgabeblack@google.com
259712853Sgabeblack@google.com
259812853Sgabeblack@google.comtemplate <class T1, class T2>
259912853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_bitref<T2> >
260012853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_bitref<T2> b)
260112853Sgabeblack@google.com{
260212853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_bitref<T2> >(
260312853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
260412853Sgabeblack@google.com}
260512853Sgabeblack@google.com
260612853Sgabeblack@google.comtemplate <class T1, class T2>
260712853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_subref<T2> >
260812853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_subref<T2> b)
260912853Sgabeblack@google.com{
261012853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_subref<T2> >(
261112853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
261212853Sgabeblack@google.com}
261312853Sgabeblack@google.com
261412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
261512853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, sc_concref<T2, T3> >
261612853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_concref<T2, T3> b)
261712853Sgabeblack@google.com{
261812853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, sc_concref<T2, T3> >(
261912853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
262012853Sgabeblack@google.com}
262112853Sgabeblack@google.com
262212853Sgabeblack@google.comtemplate <class T1, class T2>
262312853Sgabeblack@google.cominline sc_concref<sc_subref<T1>, T2>
262412853Sgabeblack@google.comconcat(sc_subref<T1> a, sc_proxy<T2> &b)
262512853Sgabeblack@google.com{
262612853Sgabeblack@google.com    return sc_concref<sc_subref<T1>, T2>(*a.clone(), b.back_cast(), 1);
262712853Sgabeblack@google.com}
262812853Sgabeblack@google.com
262912853Sgabeblack@google.comtemplate <class X>
263012853Sgabeblack@google.cominline ::std::istream &
263112853Sgabeblack@google.comoperator >> (::std::istream &is, sc_subref<X> a)
263212853Sgabeblack@google.com{
263312853Sgabeblack@google.com    a.scan(is);
263412853Sgabeblack@google.com    return is;
263512853Sgabeblack@google.com}
263612853Sgabeblack@google.com
263712853Sgabeblack@google.com// ----------------------------------------------------------------------------
263812853Sgabeblack@google.com//  CLASS TEMPLATE : sc_concref_r<X,Y>
263912853Sgabeblack@google.com//
264012853Sgabeblack@google.com//  Proxy class for sc_proxy concatenation (r-value only).
264112853Sgabeblack@google.com// ----------------------------------------------------------------------------
264212853Sgabeblack@google.com
264312853Sgabeblack@google.com// destructor
264412853Sgabeblack@google.comtemplate <class X, class Y>
264512853Sgabeblack@google.cominline sc_concref_r<X, Y>::~sc_concref_r()
264612853Sgabeblack@google.com{
264712853Sgabeblack@google.com    if (--m_refs == 0) {
264812853Sgabeblack@google.com        delete &m_refs;
264912853Sgabeblack@google.com        if (m_delete == 0) {
265012853Sgabeblack@google.com            return;
265112853Sgabeblack@google.com        }
265212853Sgabeblack@google.com        if (m_delete & 1) {
265312853Sgabeblack@google.com            delete &m_left;
265412853Sgabeblack@google.com        }
265512853Sgabeblack@google.com        if (m_delete & 2) {
265612853Sgabeblack@google.com            delete &m_right;
265712853Sgabeblack@google.com        }
265812853Sgabeblack@google.com    }
265912853Sgabeblack@google.com}
266012853Sgabeblack@google.com
266112853Sgabeblack@google.com// common methods
266212853Sgabeblack@google.comtemplate <class X, class Y>
266312853Sgabeblack@google.cominline typename sc_concref_r<X, Y>::value_type
266412853Sgabeblack@google.comsc_concref_r<X, Y>::get_bit(int n) const
266512853Sgabeblack@google.com{
266612853Sgabeblack@google.com    int r_len = m_right.length();
266712853Sgabeblack@google.com    if (n < r_len) {
266812853Sgabeblack@google.com        return value_type(m_right.get_bit(n));
266912853Sgabeblack@google.com    } else if (n < r_len + m_left.length()) {
267012853Sgabeblack@google.com        return value_type(m_left.get_bit(n - r_len));
267112853Sgabeblack@google.com    } else {
267213322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
267312853Sgabeblack@google.com        return Log_0;
267412853Sgabeblack@google.com    }
267512853Sgabeblack@google.com}
267612853Sgabeblack@google.com
267712853Sgabeblack@google.comtemplate <class X, class Y>
267812853Sgabeblack@google.cominline void
267912853Sgabeblack@google.comsc_concref_r<X, Y>::set_bit(int n, value_type v)
268012853Sgabeblack@google.com{
268112853Sgabeblack@google.com    int r_len = m_right.length();
268212853Sgabeblack@google.com    if (n < r_len) {
268312853Sgabeblack@google.com        m_right.set_bit(n, typename Y::value_type(v));
268412853Sgabeblack@google.com    } else if (n < r_len + m_left.length()) {
268512853Sgabeblack@google.com        m_left.set_bit(n - r_len, typename X::value_type(v));
268612853Sgabeblack@google.com    } else {
268713322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
268812853Sgabeblack@google.com    }
268912853Sgabeblack@google.com}
269012853Sgabeblack@google.com
269112853Sgabeblack@google.comtemplate <class X, class Y>
269212853Sgabeblack@google.cominline sc_digit
269312853Sgabeblack@google.comsc_concref_r<X, Y>::get_word(int i) const
269412853Sgabeblack@google.com{
269512853Sgabeblack@google.com    if (i < 0 || i >= size()) {
269613322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
269712853Sgabeblack@google.com    }
269812853Sgabeblack@google.com    // 0 <= i < size()
269912853Sgabeblack@google.com    Y &r = m_right;
270012853Sgabeblack@google.com    int r_len = r.length();
270112853Sgabeblack@google.com    int border = r_len / SC_DIGIT_SIZE;
270212853Sgabeblack@google.com    if (i < border) {
270312853Sgabeblack@google.com        return r.get_word(i);
270412853Sgabeblack@google.com    }
270512853Sgabeblack@google.com    // border <= i < size()
270612853Sgabeblack@google.com    X& l = m_left;
270712853Sgabeblack@google.com    int shift = r_len % SC_DIGIT_SIZE;
270812853Sgabeblack@google.com    int j = i - border;
270912853Sgabeblack@google.com    if (shift == 0) {
271012853Sgabeblack@google.com        return l.get_word(j);
271112853Sgabeblack@google.com    }
271212853Sgabeblack@google.com    // border <= i < size() && shift != 0
271312853Sgabeblack@google.com    int nshift = SC_DIGIT_SIZE - shift;
271412853Sgabeblack@google.com    if (i == border) {
271512853Sgabeblack@google.com        sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
271612853Sgabeblack@google.com        return ((r.get_word(i) & rl_mask) | (l.get_word(0) << shift));
271712853Sgabeblack@google.com    }
271812853Sgabeblack@google.com    // border < i < size() && shift != 0
271912853Sgabeblack@google.com    if (j < l.size())
272012853Sgabeblack@google.com        return ((l.get_word(j - 1) >> nshift) | (l.get_word(j) << shift));
272112853Sgabeblack@google.com    else
272212853Sgabeblack@google.com        return (l.get_word(j - 1) >> nshift);
272312853Sgabeblack@google.com}
272412853Sgabeblack@google.com
272512853Sgabeblack@google.comtemplate <class X, class Y>
272612853Sgabeblack@google.cominline void
272712853Sgabeblack@google.comsc_concref_r<X, Y>::set_word(int i, sc_digit w)
272812853Sgabeblack@google.com{
272912853Sgabeblack@google.com    if (i < 0 || i >= size()) {
273013322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
273112853Sgabeblack@google.com    }
273212853Sgabeblack@google.com    // 0 <= i < size()
273312853Sgabeblack@google.com    Y &r = m_right;
273412853Sgabeblack@google.com    int r_len = r.length();
273512853Sgabeblack@google.com    int border = r_len / SC_DIGIT_SIZE;
273612853Sgabeblack@google.com    if (i < border) {
273712853Sgabeblack@google.com        r.set_word(i, w);
273812853Sgabeblack@google.com        return;
273912853Sgabeblack@google.com    }
274012853Sgabeblack@google.com    // border <= i < size()
274112853Sgabeblack@google.com    X &l = m_left;
274212853Sgabeblack@google.com    int shift = r_len % SC_DIGIT_SIZE;
274312853Sgabeblack@google.com    int j = i - border;
274412853Sgabeblack@google.com    if (shift == 0) {
274512853Sgabeblack@google.com        l.set_word(j, w);
274612853Sgabeblack@google.com        return;
274712853Sgabeblack@google.com    }
274812853Sgabeblack@google.com    // border <= i < size() && shift != 0
274912853Sgabeblack@google.com    int nshift = SC_DIGIT_SIZE - shift;
275012853Sgabeblack@google.com    sc_digit lh_mask = ~SC_DIGIT_ZERO << nshift;
275112853Sgabeblack@google.com    if (i == border) {
275212853Sgabeblack@google.com        sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
275312853Sgabeblack@google.com        r.set_word(i, w & rl_mask);
275412853Sgabeblack@google.com        l.set_word(0, (l.get_word(0) & lh_mask) | (w >> shift));
275512853Sgabeblack@google.com        return;
275612853Sgabeblack@google.com    }
275712853Sgabeblack@google.com    // border < i < size() && shift != 0
275812853Sgabeblack@google.com    sc_digit ll_mask = ~SC_DIGIT_ZERO >> shift;
275912853Sgabeblack@google.com    l.set_word(j - 1, (l.get_word(j - 1) & ll_mask) | (w << nshift));
276012853Sgabeblack@google.com    if (j < l.size())
276112853Sgabeblack@google.com        l.set_word(j, (l.get_word(j) & lh_mask) | (w >> shift));
276212853Sgabeblack@google.com}
276312853Sgabeblack@google.com
276412853Sgabeblack@google.comtemplate <class X, class Y>
276512853Sgabeblack@google.cominline sc_digit
276612853Sgabeblack@google.comsc_concref_r<X, Y>::get_cword(int i) const
276712853Sgabeblack@google.com{
276812853Sgabeblack@google.com    if (i < 0 || i >= size()) {
276913322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
277012853Sgabeblack@google.com    }
277112853Sgabeblack@google.com    // 0 <= i < size()
277212853Sgabeblack@google.com    Y &r = m_right;
277312853Sgabeblack@google.com    int r_len = r.length();
277412853Sgabeblack@google.com    int border = r_len / SC_DIGIT_SIZE;
277512853Sgabeblack@google.com    if (i < border) {
277612853Sgabeblack@google.com        return r.get_cword(i);
277712853Sgabeblack@google.com    }
277812853Sgabeblack@google.com    // border <= i < size()
277912853Sgabeblack@google.com    X &l = m_left;
278012853Sgabeblack@google.com    int shift = r_len % SC_DIGIT_SIZE;
278112853Sgabeblack@google.com    int j = i - border;
278212853Sgabeblack@google.com    if (shift == 0) {
278312853Sgabeblack@google.com        return l.get_cword(j);
278412853Sgabeblack@google.com    }
278512853Sgabeblack@google.com    // border <= i < size() && shift != 0
278612853Sgabeblack@google.com    int nshift = SC_DIGIT_SIZE - shift;
278712853Sgabeblack@google.com    if (i == border) {
278812853Sgabeblack@google.com        sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
278912853Sgabeblack@google.com        return ((r.get_cword(i) & rl_mask) | (l.get_cword(0) << shift));
279012853Sgabeblack@google.com    }
279112853Sgabeblack@google.com    // border < i < size() && shift != 0
279212853Sgabeblack@google.com    if (j < l.size())
279312853Sgabeblack@google.com        return ((l.get_cword(j - 1) >> nshift) | (l.get_cword(j) << shift));
279412853Sgabeblack@google.com    else
279512853Sgabeblack@google.com        return (l.get_cword( j - 1 ) >> nshift);
279612853Sgabeblack@google.com}
279712853Sgabeblack@google.com
279812853Sgabeblack@google.comtemplate <class X, class Y>
279912853Sgabeblack@google.cominline void
280012853Sgabeblack@google.comsc_concref_r<X, Y>::set_cword(int i, sc_digit w)
280112853Sgabeblack@google.com{
280212853Sgabeblack@google.com    if (i < 0 || i >= size()) {
280313322Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0);
280412853Sgabeblack@google.com    }
280512853Sgabeblack@google.com    // 0 <= i < size()
280612853Sgabeblack@google.com    Y &r = m_right;
280712853Sgabeblack@google.com    int r_len = r.length();
280812853Sgabeblack@google.com    int border = r_len / SC_DIGIT_SIZE;
280912853Sgabeblack@google.com    if (i < border) {
281012853Sgabeblack@google.com        r.set_cword(i, w);
281112853Sgabeblack@google.com        return;
281212853Sgabeblack@google.com    }
281312853Sgabeblack@google.com    // border <= i < size()
281412853Sgabeblack@google.com    X &l = m_left;
281512853Sgabeblack@google.com    int shift = r_len % SC_DIGIT_SIZE;
281612853Sgabeblack@google.com    int j = i - border;
281712853Sgabeblack@google.com    if (shift == 0) {
281812853Sgabeblack@google.com        l.set_cword(j, w);
281912853Sgabeblack@google.com        return;
282012853Sgabeblack@google.com    }
282112853Sgabeblack@google.com    // border <= i < size() && shift != 0
282212853Sgabeblack@google.com    int nshift = SC_DIGIT_SIZE - shift;
282312853Sgabeblack@google.com    sc_digit lh_mask = ~SC_DIGIT_ZERO << nshift;
282412853Sgabeblack@google.com    if (i == border) {
282512853Sgabeblack@google.com        sc_digit rl_mask = ~SC_DIGIT_ZERO >> nshift;
282612853Sgabeblack@google.com        r.set_cword(i, w & rl_mask);
282712853Sgabeblack@google.com        l.set_cword(0, (l.get_cword(0) & lh_mask) | (w >> shift));
282812853Sgabeblack@google.com        return;
282912853Sgabeblack@google.com    }
283012853Sgabeblack@google.com    // border < i < size() && shift != 0
283112853Sgabeblack@google.com    sc_digit ll_mask = ~SC_DIGIT_ZERO >> shift;
283212853Sgabeblack@google.com    l.set_cword(j - 1, (l.get_cword(j - 1) & ll_mask) | (w << nshift));
283312853Sgabeblack@google.com    if (j < l.size())
283412853Sgabeblack@google.com        l.set_cword(j, (l.get_cword(j) & lh_mask) | (w >> shift));
283512853Sgabeblack@google.com}
283612853Sgabeblack@google.com
283712853Sgabeblack@google.com// r-value concatenation operators and functions
283812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
283912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> >
284012853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_bitref_r<T3> b)
284112853Sgabeblack@google.com{
284212853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>,sc_bitref_r<T3> >(
284312853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
284412853Sgabeblack@google.com}
284512853Sgabeblack@google.com
284612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
284712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
284812853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_subref_r<T3> b)
284912853Sgabeblack@google.com{
285012853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
285112853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
285212853Sgabeblack@google.com}
285312853Sgabeblack@google.com
285412853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
285512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
285612853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_concref_r<T3, T4> b)
285712853Sgabeblack@google.com{
285812853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>,sc_concref_r<T3, T4> >(
285912853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
286012853Sgabeblack@google.com}
286112853Sgabeblack@google.com
286212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
286312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
286412853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, const sc_proxy<T3> &b)
286512853Sgabeblack@google.com{
286612853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
286712853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
286812853Sgabeblack@google.com}
286912853Sgabeblack@google.com
287012853Sgabeblack@google.com
287112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
287212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
287312853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_bitref_r<T3> b)
287412853Sgabeblack@google.com{
287512853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
287612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
287712853Sgabeblack@google.com}
287812853Sgabeblack@google.com
287912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
288012853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
288112853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_subref_r<T3> b)
288212853Sgabeblack@google.com{
288312853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
288412853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
288512853Sgabeblack@google.com}
288612853Sgabeblack@google.com
288712853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
288812853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
288912853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_concref_r<T3, T4> b)
289012853Sgabeblack@google.com{
289112853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
289212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
289312853Sgabeblack@google.com}
289412853Sgabeblack@google.com
289512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
289612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
289712853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, const sc_proxy<T3> &b)
289812853Sgabeblack@google.com{
289912853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
290012853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
290112853Sgabeblack@google.com}
290212853Sgabeblack@google.com
290312853Sgabeblack@google.com
290412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
290512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
290612853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_bitref<T3> b)
290712853Sgabeblack@google.com{
290812853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
290912853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
291012853Sgabeblack@google.com}
291112853Sgabeblack@google.com
291212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
291312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
291412853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_bitref_r<T3> b)
291512853Sgabeblack@google.com{
291612853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
291712853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
291812853Sgabeblack@google.com}
291912853Sgabeblack@google.com
292012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
292112853Sgabeblack@google.cominline
292212853Sgabeblack@google.comsc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
292312853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_subref<T3> b)
292412853Sgabeblack@google.com{
292512853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
292612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
292712853Sgabeblack@google.com}
292812853Sgabeblack@google.com
292912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
293012853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
293112853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_subref_r<T3> b)
293212853Sgabeblack@google.com{
293312853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
293412853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
293512853Sgabeblack@google.com}
293612853Sgabeblack@google.com
293712853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
293812853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
293912853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_concref<T3, T4> b)
294012853Sgabeblack@google.com{
294112853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
294212853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
294312853Sgabeblack@google.com}
294412853Sgabeblack@google.com
294512853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
294612853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
294712853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_concref_r<T3, T4> b)
294812853Sgabeblack@google.com{
294912853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
295012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
295112853Sgabeblack@google.com}
295212853Sgabeblack@google.com
295312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
295412853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
295512853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, const sc_proxy<T3> &b)
295612853Sgabeblack@google.com{
295712853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
295812853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
295912853Sgabeblack@google.com}
296012853Sgabeblack@google.com
296112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
296212853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
296312853Sgabeblack@google.comoperator , (sc_concref_r<T1, T2> a, sc_proxy<T3> &b)
296412853Sgabeblack@google.com{
296512853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
296612853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
296712853Sgabeblack@google.com}
296812853Sgabeblack@google.com
296912853Sgabeblack@google.com
297012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
297112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
297212853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_bitref<T3> b)
297312853Sgabeblack@google.com{
297412853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
297512853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
297612853Sgabeblack@google.com}
297712853Sgabeblack@google.com
297812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
297912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >
298012853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_bitref_r<T3> b)
298112853Sgabeblack@google.com{
298212853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_bitref_r<T3> >(
298312853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
298412853Sgabeblack@google.com}
298512853Sgabeblack@google.com
298612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
298712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
298812853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_subref<T3> b)
298912853Sgabeblack@google.com{
299012853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
299112853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
299212853Sgabeblack@google.com}
299312853Sgabeblack@google.com
299412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
299512853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >
299612853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_subref_r<T3> b)
299712853Sgabeblack@google.com{
299812853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_subref_r<T3> >(
299912853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
300012853Sgabeblack@google.com}
300112853Sgabeblack@google.com
300212853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
300312853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
300412853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_concref<T3, T4> b)
300512853Sgabeblack@google.com{
300612853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
300712853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
300812853Sgabeblack@google.com}
300912853Sgabeblack@google.com
301012853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
301112853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >
301212853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_concref_r<T3, T4> b)
301312853Sgabeblack@google.com{
301412853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, sc_concref_r<T3, T4> >(
301512853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
301612853Sgabeblack@google.com}
301712853Sgabeblack@google.com
301812853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
301912853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
302012853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, const sc_proxy<T3> &b)
302112853Sgabeblack@google.com{
302212853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
302312853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
302412853Sgabeblack@google.com}
302512853Sgabeblack@google.com
302612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
302712853Sgabeblack@google.cominline sc_concref_r<sc_concref_r<T1, T2>, T3>
302812853Sgabeblack@google.comconcat(sc_concref_r<T1, T2> a, sc_proxy<T3> &b)
302912853Sgabeblack@google.com{
303012853Sgabeblack@google.com    return sc_concref_r<sc_concref_r<T1, T2>, T3>(
303112853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
303212853Sgabeblack@google.com}
303312853Sgabeblack@google.com
303412853Sgabeblack@google.com
303512853Sgabeblack@google.com// ----------------------------------------------------------------------------
303612853Sgabeblack@google.com//  CLASS TEMPLATE : sc_concref<X,Y>
303712853Sgabeblack@google.com//
303812853Sgabeblack@google.com//  Proxy class for sc_proxy concatenation (r-value and l-value).
303912853Sgabeblack@google.com// ----------------------------------------------------------------------------
304012853Sgabeblack@google.com
304112853Sgabeblack@google.com// other methods
304212853Sgabeblack@google.comtemplate <class T1, class T2>
304312853Sgabeblack@google.cominline void
304412853Sgabeblack@google.comsc_concref<T1, T2>::scan(::std::istream &is)
304512853Sgabeblack@google.com{
304612853Sgabeblack@google.com    std::string s;
304712853Sgabeblack@google.com    is >> s;
304812853Sgabeblack@google.com    *this = s.c_str();
304912853Sgabeblack@google.com}
305012853Sgabeblack@google.com
305112853Sgabeblack@google.com// l-value concatenation operators and functions
305212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
305312853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >
305412853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_bitref<T3> b)
305512853Sgabeblack@google.com{
305612853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >(
305712853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
305812853Sgabeblack@google.com}
305912853Sgabeblack@google.com
306012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
306112853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_subref<T3> >
306212853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_subref<T3>b)
306312853Sgabeblack@google.com{
306412853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_subref<T3> >(
306512853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
306612853Sgabeblack@google.com}
306712853Sgabeblack@google.com
306812853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
306912853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >
307012853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_concref<T3, T4> b)
307112853Sgabeblack@google.com{
307212853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >(
307312853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
307412853Sgabeblack@google.com}
307512853Sgabeblack@google.com
307612853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
307712853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, T3>
307812853Sgabeblack@google.comoperator , (sc_concref<T1, T2> a, sc_proxy<T3> &b)
307912853Sgabeblack@google.com{
308012853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, T3>(
308112853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
308212853Sgabeblack@google.com}
308312853Sgabeblack@google.com
308412853Sgabeblack@google.com
308512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
308612853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >
308712853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_bitref<T3> b)
308812853Sgabeblack@google.com{
308912853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_bitref<T3> >(
309012853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
309112853Sgabeblack@google.com}
309212853Sgabeblack@google.com
309312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
309412853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_subref<T3> >
309512853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_subref<T3> b)
309612853Sgabeblack@google.com{
309712853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_subref<T3> >(
309812853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
309912853Sgabeblack@google.com}
310012853Sgabeblack@google.com
310112853Sgabeblack@google.comtemplate <class T1, class T2, class T3, class T4>
310212853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >
310312853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_concref<T3, T4> b)
310412853Sgabeblack@google.com{
310512853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, sc_concref<T3, T4> >(
310612853Sgabeblack@google.com            *a.clone(), *b.clone(), 3);
310712853Sgabeblack@google.com}
310812853Sgabeblack@google.com
310912853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
311012853Sgabeblack@google.cominline sc_concref<sc_concref<T1, T2>, T3>
311112853Sgabeblack@google.comconcat(sc_concref<T1, T2> a, sc_proxy<T3> &b)
311212853Sgabeblack@google.com{
311312853Sgabeblack@google.com    return sc_concref<sc_concref<T1, T2>, T3>(
311412853Sgabeblack@google.com            *a.clone(), b.back_cast(), 1);
311512853Sgabeblack@google.com}
311612853Sgabeblack@google.com
311712853Sgabeblack@google.comtemplate <class X, class Y>
311812853Sgabeblack@google.cominline ::std::istream &
311912853Sgabeblack@google.comoperator >> (::std::istream &is, sc_concref<X, Y> a)
312012853Sgabeblack@google.com{
312112853Sgabeblack@google.com    a.scan(is);
312212853Sgabeblack@google.com    return is;
312312853Sgabeblack@google.com}
312412853Sgabeblack@google.com
312512853Sgabeblack@google.com
312612853Sgabeblack@google.com// ----------------------------------------------------------------------------
312712853Sgabeblack@google.com//  CLASS TEMPLATE : sc_proxy<T>
312812853Sgabeblack@google.com//
312912853Sgabeblack@google.com//  Base class template for bit/logic vector classes.
313012853Sgabeblack@google.com//  (Barton/Nackmann implementation)
313112853Sgabeblack@google.com// ----------------------------------------------------------------------------
313212853Sgabeblack@google.com
313312853Sgabeblack@google.com// r-value concatenation operators and functions
313412853Sgabeblack@google.com
313512853Sgabeblack@google.comtemplate <class T1, class T2>
313612853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
313712853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_bitref_r<T2> b)
313812853Sgabeblack@google.com{
313912853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(
314012853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
314112853Sgabeblack@google.com}
314212853Sgabeblack@google.com
314312853Sgabeblack@google.comtemplate <class T1, class T2>
314412853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
314512853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_subref_r<T2> b)
314612853Sgabeblack@google.com{
314712853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(
314812853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
314912853Sgabeblack@google.com}
315012853Sgabeblack@google.com
315112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
315212853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
315312853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
315412853Sgabeblack@google.com{
315512853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
315612853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
315712853Sgabeblack@google.com}
315812853Sgabeblack@google.com
315912853Sgabeblack@google.comtemplate <class T1, class T2>
316012853Sgabeblack@google.cominline sc_concref_r<T1, T2>
316112853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, const sc_proxy<T2> &b)
316212853Sgabeblack@google.com{
316312853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
316412853Sgabeblack@google.com}
316512853Sgabeblack@google.com
316612853Sgabeblack@google.com
316712853Sgabeblack@google.comtemplate <class T1, class T2>
316812853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
316912853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_bitref_r<T2> b)
317012853Sgabeblack@google.com{
317112853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
317212853Sgabeblack@google.com}
317312853Sgabeblack@google.com
317412853Sgabeblack@google.comtemplate <class T1, class T2>
317512853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
317612853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_subref_r<T2> b)
317712853Sgabeblack@google.com{
317812853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
317912853Sgabeblack@google.com}
318012853Sgabeblack@google.com
318112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
318212853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
318312853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_concref_r<T2, T3> b )
318412853Sgabeblack@google.com{
318512853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
318612853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
318712853Sgabeblack@google.com}
318812853Sgabeblack@google.com
318912853Sgabeblack@google.comtemplate <class T1, class T2>
319012853Sgabeblack@google.cominline sc_concref_r<T1, T2>
319112853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, const sc_proxy<T2> &b)
319212853Sgabeblack@google.com{
319312853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
319412853Sgabeblack@google.com}
319512853Sgabeblack@google.com
319612853Sgabeblack@google.com
319712853Sgabeblack@google.comtemplate <class T1, class T2>
319812853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
319912853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_bitref<T2> b)
320012853Sgabeblack@google.com{
320112853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
320212853Sgabeblack@google.com}
320312853Sgabeblack@google.com
320412853Sgabeblack@google.comtemplate <class T1, class T2>
320512853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
320612853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_bitref_r<T2> b)
320712853Sgabeblack@google.com{
320812853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
320912853Sgabeblack@google.com}
321012853Sgabeblack@google.com
321112853Sgabeblack@google.comtemplate <class T1, class T2>
321212853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
321312853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_subref<T2> b)
321412853Sgabeblack@google.com{
321512853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
321612853Sgabeblack@google.com}
321712853Sgabeblack@google.com
321812853Sgabeblack@google.comtemplate <class T1, class T2>
321912853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
322012853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_subref_r<T2> b)
322112853Sgabeblack@google.com{
322212853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
322312853Sgabeblack@google.com}
322412853Sgabeblack@google.com
322512853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
322612853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
322712853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_concref<T2, T3> b)
322812853Sgabeblack@google.com{
322912853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
323012853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
323112853Sgabeblack@google.com}
323212853Sgabeblack@google.com
323312853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
323412853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
323512853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
323612853Sgabeblack@google.com{
323712853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
323812853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
323912853Sgabeblack@google.com}
324012853Sgabeblack@google.com
324112853Sgabeblack@google.comtemplate <class T1, class T2>
324212853Sgabeblack@google.cominline sc_concref_r<T1, T2>
324312853Sgabeblack@google.comoperator , (const sc_proxy<T1> &a, sc_proxy<T2> &b)
324412853Sgabeblack@google.com{
324512853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
324612853Sgabeblack@google.com}
324712853Sgabeblack@google.com
324812853Sgabeblack@google.comtemplate <class T1, class T2>
324912853Sgabeblack@google.cominline sc_concref_r<T1, T2>
325012853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, const sc_proxy<T2> &b)
325112853Sgabeblack@google.com{
325212853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
325312853Sgabeblack@google.com}
325412853Sgabeblack@google.com
325512853Sgabeblack@google.com
325612853Sgabeblack@google.comtemplate <class T1, class T2>
325712853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
325812853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_bitref<T2> b)
325912853Sgabeblack@google.com{
326012853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
326112853Sgabeblack@google.com}
326212853Sgabeblack@google.com
326312853Sgabeblack@google.comtemplate <class T1, class T2>
326412853Sgabeblack@google.cominline sc_concref_r<T1, sc_bitref_r<T2> >
326512853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_bitref_r<T2> b)
326612853Sgabeblack@google.com{
326712853Sgabeblack@google.com    return sc_concref_r<T1, sc_bitref_r<T2> >(a.back_cast(), *b.clone(), 2);
326812853Sgabeblack@google.com}
326912853Sgabeblack@google.com
327012853Sgabeblack@google.comtemplate <class T1, class T2>
327112853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
327212853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_subref<T2> b)
327312853Sgabeblack@google.com{
327412853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
327512853Sgabeblack@google.com}
327612853Sgabeblack@google.com
327712853Sgabeblack@google.comtemplate <class T1, class T2>
327812853Sgabeblack@google.cominline sc_concref_r<T1, sc_subref_r<T2> >
327912853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_subref_r<T2> b)
328012853Sgabeblack@google.com{
328112853Sgabeblack@google.com    return sc_concref_r<T1, sc_subref_r<T2> >(a.back_cast(), *b.clone(), 2);
328212853Sgabeblack@google.com}
328312853Sgabeblack@google.com
328412853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
328512853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
328612853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_concref<T2, T3> b)
328712853Sgabeblack@google.com{
328812853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
328912853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
329012853Sgabeblack@google.com}
329112853Sgabeblack@google.com
329212853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
329312853Sgabeblack@google.cominline sc_concref_r<T1, sc_concref_r<T2, T3> >
329412853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_concref_r<T2, T3> b)
329512853Sgabeblack@google.com{
329612853Sgabeblack@google.com    return sc_concref_r<T1, sc_concref_r<T2, T3> >(
329712853Sgabeblack@google.com            a.back_cast(), *b.clone(), 2);
329812853Sgabeblack@google.com}
329912853Sgabeblack@google.com
330012853Sgabeblack@google.comtemplate <class T1, class T2>
330112853Sgabeblack@google.cominline sc_concref_r<T1, T2>
330212853Sgabeblack@google.comconcat(const sc_proxy<T1> &a, sc_proxy<T2> &b)
330312853Sgabeblack@google.com{
330412853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
330512853Sgabeblack@google.com}
330612853Sgabeblack@google.com
330712853Sgabeblack@google.comtemplate <class T1, class T2>
330812853Sgabeblack@google.cominline sc_concref_r<T1, T2>
330912853Sgabeblack@google.comconcat(sc_proxy<T1> &a, const sc_proxy<T2> &b)
331012853Sgabeblack@google.com{
331112853Sgabeblack@google.com    return sc_concref_r<T1, T2>(a.back_cast(), b.back_cast());
331212853Sgabeblack@google.com}
331312853Sgabeblack@google.com
331412853Sgabeblack@google.com
331512853Sgabeblack@google.com// l-value concatenation operators and functions
331612853Sgabeblack@google.com
331712853Sgabeblack@google.comtemplate <class T1, class T2>
331812853Sgabeblack@google.cominline sc_concref<T1, sc_bitref<T2> >
331912853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_bitref<T2> b)
332012853Sgabeblack@google.com{
332112853Sgabeblack@google.com    return sc_concref<T1, sc_bitref<T2> >(a.back_cast(), *b.clone(), 2);
332212853Sgabeblack@google.com}
332312853Sgabeblack@google.com
332412853Sgabeblack@google.comtemplate <class T1, class T2>
332512853Sgabeblack@google.cominline sc_concref<T1, sc_subref<T2> >
332612853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_subref<T2> b)
332712853Sgabeblack@google.com{
332812853Sgabeblack@google.com    return sc_concref<T1, sc_subref<T2> >(a.back_cast(), *b.clone(), 2);
332912853Sgabeblack@google.com}
333012853Sgabeblack@google.com
333112853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
333212853Sgabeblack@google.cominline sc_concref<T1, sc_concref<T2, T3> >
333312853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_concref<T2, T3> b)
333412853Sgabeblack@google.com{
333512853Sgabeblack@google.com    return sc_concref<T1, sc_concref<T2, T3> >(a.back_cast(), *b.clone(), 2);
333612853Sgabeblack@google.com}
333712853Sgabeblack@google.com
333812853Sgabeblack@google.comtemplate <class T1, class T2>
333912853Sgabeblack@google.cominline sc_concref<T1, T2>
334012853Sgabeblack@google.comoperator , (sc_proxy<T1> &a, sc_proxy<T2> &b)
334112853Sgabeblack@google.com{
334212853Sgabeblack@google.com    return sc_concref<T1, T2>(a.back_cast(), b.back_cast());
334312853Sgabeblack@google.com}
334412853Sgabeblack@google.com
334512853Sgabeblack@google.com
334612853Sgabeblack@google.comtemplate <class T1, class T2>
334712853Sgabeblack@google.cominline sc_concref<T1, sc_bitref<T2> >
334812853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_bitref<T2> b)
334912853Sgabeblack@google.com{
335012853Sgabeblack@google.com    return sc_concref<T1, sc_bitref<T2> >(a.back_cast(), *b.clone(), 2);
335112853Sgabeblack@google.com}
335212853Sgabeblack@google.com
335312853Sgabeblack@google.comtemplate <class T1, class T2>
335412853Sgabeblack@google.cominline sc_concref<T1, sc_subref<T2> >
335512853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_subref<T2> b)
335612853Sgabeblack@google.com{
335712853Sgabeblack@google.com    return sc_concref<T1, sc_subref<T2> >(a.back_cast(), *b.clone(), 2);
335812853Sgabeblack@google.com}
335912853Sgabeblack@google.com
336012853Sgabeblack@google.comtemplate <class T1, class T2, class T3>
336112853Sgabeblack@google.cominline sc_concref<T1, sc_concref<T2, T3> >
336212853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_concref<T2, T3> b)
336312853Sgabeblack@google.com{
336412853Sgabeblack@google.com    return sc_concref<T1, sc_concref<T2, T3> >(a.back_cast(), *b.clone(), 2);
336512853Sgabeblack@google.com}
336612853Sgabeblack@google.com
336712853Sgabeblack@google.comtemplate <class T1, class T2>
336812853Sgabeblack@google.cominline sc_concref<T1, T2>
336912853Sgabeblack@google.comconcat(sc_proxy<T1> &a, sc_proxy<T2> &b)
337012853Sgabeblack@google.com{
337112853Sgabeblack@google.com    return sc_concref<T1, T2>(a.back_cast(), b.back_cast());
337212853Sgabeblack@google.com}
337312853Sgabeblack@google.com
337412853Sgabeblack@google.com} // namespace sc_dt
337512853Sgabeblack@google.com
337612853Sgabeblack@google.com// $Log: sc_bit_proxies.h,v $
337712853Sgabeblack@google.com// Revision 1.10  2011/09/05 21:19:53  acg
337812853Sgabeblack@google.com//  Philipp A. Hartmann: added parentheses to expressions to eliminate
337912853Sgabeblack@google.com//  compiler warnings.
338012853Sgabeblack@google.com//
338112853Sgabeblack@google.com// Revision 1.9  2011/09/01 15:03:42  acg
338212853Sgabeblack@google.com//  Philipp A. Hartmann: add parentheses to eliminate compiler warnings.
338312853Sgabeblack@google.com//
338412853Sgabeblack@google.com// Revision 1.8  2011/08/29 18:04:32  acg
338512853Sgabeblack@google.com//  Philipp A. Hartmann: miscellaneous clean ups.
338612853Sgabeblack@google.com//
338712853Sgabeblack@google.com// Revision 1.7  2011/08/24 22:05:40  acg
338812853Sgabeblack@google.com//  Torsten Maehne: initialization changes to remove warnings.
338912853Sgabeblack@google.com//
339012853Sgabeblack@google.com// Revision 1.6  2010/02/22 14:25:43  acg
339112853Sgabeblack@google.com//  Andy Goodrich: removed 'mutable' directive from references, since it
339212853Sgabeblack@google.com//  is not a legal C++ construct.
339312853Sgabeblack@google.com//
339412853Sgabeblack@google.com// Revision 1.5  2009/02/28 00:26:14  acg
339512853Sgabeblack@google.com//  Andy Goodrich: bug fixes.
339612853Sgabeblack@google.com//
339712853Sgabeblack@google.com// Revision 1.4  2007/03/14 17:48:37  acg
339812853Sgabeblack@google.com//  Andy Goodrich: fixed bug.
339912853Sgabeblack@google.com//
340012853Sgabeblack@google.com// Revision 1.3  2007/01/18 19:29:18  acg
340112853Sgabeblack@google.com//  Andy Goodrich: fixed bug in concatenations of bit selects on sc_lv and
340212853Sgabeblack@google.com//  sc_bv types. The offending code was in sc_bitref<X>::set_word and
340312853Sgabeblack@google.com//  sc_bitref<X>::get_word. These methods were not writing the bit they
340412853Sgabeblack@google.com//  represented, but rather writing an entire word whose index was the
340512853Sgabeblack@google.com//  index of the bit they represented. This not only did not write the
340612853Sgabeblack@google.com//  correct bit, but clobbered a word that might not even be in the
340712853Sgabeblack@google.com//  variable the reference was for.
340812853Sgabeblack@google.com//
340912853Sgabeblack@google.com// Revision 1.2  2007/01/17 22:45:08  acg
341012853Sgabeblack@google.com//  Andy Goodrich: fixed sc_bitref<X>::set_bit().
341112853Sgabeblack@google.com//
341212853Sgabeblack@google.com// Revision 1.1.1.1  2006/12/15 20:31:36  acg
341312853Sgabeblack@google.com// SystemC 2.2
341412853Sgabeblack@google.com//
341512853Sgabeblack@google.com// Revision 1.3  2006/01/13 18:53:53  acg
341612853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in
341712853Sgabeblack@google.com// the source.
341812853Sgabeblack@google.com//
341912853Sgabeblack@google.com
342012853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__
3421