sc_fxnum.hh (13245:c666c5d4996b) sc_fxnum.hh (13325:86323e6cc8ec)
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at

--- 48 unchanged lines hidden (view full) ---

57//
58
59#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
60#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
61
62#include <iostream>
63
64#include "../bit/sc_lv_base.hh"
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at

--- 48 unchanged lines hidden (view full) ---

57//
58
59#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
60#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
61
62#include <iostream>
63
64#include "../bit/sc_lv_base.hh"
65#include "messages.hh"
65#include "sc_fxnum_observer.hh"
66#include "sc_fxval.hh"
67#include "scfx_params.hh"
68
69namespace sc_gem5
70{
71
72template <typename T, typename B>

--- 2096 unchanged lines hidden (view full) ---

2169sc_fxnum::observer() const
2170{
2171 return m_observer;
2172}
2173
2174inline void
2175sc_fxnum::cast()
2176{
66#include "sc_fxnum_observer.hh"
67#include "sc_fxval.hh"
68#include "scfx_params.hh"
69
70namespace sc_gem5
71{
72
73template <typename T, typename B>

--- 2096 unchanged lines hidden (view full) ---

2170sc_fxnum::observer() const
2171{
2172 return m_observer;
2173}
2174
2175inline void
2176sc_fxnum::cast()
2177{
2177 SC_ERROR_IF_(!m_rep->is_normal(), "invalid fixed-point value");
2178 SC_ERROR_IF_(!m_rep->is_normal(), sc_core::SC_ID_INVALID_FX_VALUE_);
2178
2179 if (m_params.cast_switch() == SC_ON)
2180 m_rep->cast(m_params, m_q_flag, m_o_flag);
2181}
2182
2183// constructors
2184inline sc_fxnum::sc_fxnum(const sc_fxtype_params &type_params_,
2185 sc_enc enc_, const sc_fxcast_switch &cast_sw,

--- 627 unchanged lines hidden (view full) ---

2813 (*this) -= 1;
2814 return *this;
2815}
2816
2817// bit selection
2818inline const sc_fxnum_bitref
2819sc_fxnum::operator [] (int i) const
2820{
2179
2180 if (m_params.cast_switch() == SC_ON)
2181 m_rep->cast(m_params, m_q_flag, m_o_flag);
2182}
2183
2184// constructors
2185inline sc_fxnum::sc_fxnum(const sc_fxtype_params &type_params_,
2186 sc_enc enc_, const sc_fxcast_switch &cast_sw,

--- 627 unchanged lines hidden (view full) ---

2814 (*this) -= 1;
2815 return *this;
2816}
2817
2818// bit selection
2819inline const sc_fxnum_bitref
2820sc_fxnum::operator [] (int i) const
2821{
2821 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2822 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2822 return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2823 i - m_params.fwl());
2824}
2825
2826inline sc_fxnum_bitref
2827sc_fxnum::operator [] (int i)
2828{
2823 return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2824 i - m_params.fwl());
2825}
2826
2827inline sc_fxnum_bitref
2828sc_fxnum::operator [] (int i)
2829{
2829 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2830 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2830 return sc_fxnum_bitref(*this, i - m_params.fwl());
2831}
2832
2833inline const sc_fxnum_bitref
2834sc_fxnum::bit(int i) const
2835{
2831 return sc_fxnum_bitref(*this, i - m_params.fwl());
2832}
2833
2834inline const sc_fxnum_bitref
2835sc_fxnum::bit(int i) const
2836{
2836 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2837 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2837 return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2838 i - m_params.fwl());
2839}
2840
2841inline sc_fxnum_bitref
2842sc_fxnum::bit(int i)
2843{
2838 return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this),
2839 i - m_params.fwl());
2840}
2841
2842inline sc_fxnum_bitref
2843sc_fxnum::bit(int i)
2844{
2844 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2845 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2845 return sc_fxnum_bitref(*this, i - m_params.fwl());
2846}
2847
2848// part selection
2849
2850inline const sc_fxnum_subref
2851sc_fxnum::operator () (int i, int j) const
2852{
2846 return sc_fxnum_bitref(*this, i - m_params.fwl());
2847}
2848
2849// part selection
2850
2851inline const sc_fxnum_subref
2852sc_fxnum::operator () (int i, int j) const
2853{
2853 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2854 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
2854 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2855 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2855
2856 return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2857 i - m_params.fwl(), j - m_params.fwl());
2858}
2859
2860inline sc_fxnum_subref
2861sc_fxnum::operator () (int i, int j)
2862{
2856
2857 return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2858 i - m_params.fwl(), j - m_params.fwl());
2859}
2860
2861inline sc_fxnum_subref
2862sc_fxnum::operator () (int i, int j)
2863{
2863 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2864 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
2864 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2865 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2865
2866 return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2867}
2868
2869inline const sc_fxnum_subref
2870sc_fxnum::range(int i, int j) const
2871{
2866
2867 return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2868}
2869
2870inline const sc_fxnum_subref
2871sc_fxnum::range(int i, int j) const
2872{
2872 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2873 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
2873 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2874 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2874
2875 return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2876 i - m_params.fwl(), j - m_params.fwl());
2877}
2878
2879inline sc_fxnum_subref
2880sc_fxnum::range(int i, int j)
2881{
2875
2876 return sc_fxnum_subref(const_cast<sc_fxnum &>(*this),
2877 i - m_params.fwl(), j - m_params.fwl());
2878}
2879
2880inline sc_fxnum_subref
2881sc_fxnum::range(int i, int j)
2882{
2882 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
2883 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
2883 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2884 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
2884
2885 return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2886}
2887
2888
2889inline const sc_fxnum_subref
2890sc_fxnum::operator () () const
2891{

--- 876 unchanged lines hidden (view full) ---

3768 SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
3769 return *this;
3770}
3771
3772// bit selection
3773inline const sc_fxnum_fast_bitref
3774sc_fxnum_fast::operator [] (int i) const
3775{
2885
2886 return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl());
2887}
2888
2889
2890inline const sc_fxnum_subref
2891sc_fxnum::operator () () const
2892{

--- 876 unchanged lines hidden (view full) ---

3769 SC_FXNUM_FAST_OBSERVER_WRITE_(*this)
3770 return *this;
3771}
3772
3773// bit selection
3774inline const sc_fxnum_fast_bitref
3775sc_fxnum_fast::operator [] (int i) const
3776{
3776 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3777 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3777 return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3778 i - m_params.fwl());
3779}
3780
3781inline sc_fxnum_fast_bitref
3782sc_fxnum_fast::operator [] (int i)
3783{
3778 return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3779 i - m_params.fwl());
3780}
3781
3782inline sc_fxnum_fast_bitref
3783sc_fxnum_fast::operator [] (int i)
3784{
3784 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3785 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3785 return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3786}
3787
3788inline const sc_fxnum_fast_bitref
3789sc_fxnum_fast::bit(int i) const
3790{
3786 return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3787}
3788
3789inline const sc_fxnum_fast_bitref
3790sc_fxnum_fast::bit(int i) const
3791{
3791 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3792 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3792 return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3793 i - m_params.fwl());
3794}
3795
3796inline sc_fxnum_fast_bitref
3797sc_fxnum_fast::bit(int i)
3798{
3793 return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this),
3794 i - m_params.fwl());
3795}
3796
3797inline sc_fxnum_fast_bitref
3798sc_fxnum_fast::bit(int i)
3799{
3799 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3800 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3800 return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3801}
3802
3803// part selection
3804inline const sc_fxnum_fast_subref
3805sc_fxnum_fast::operator () (int i, int j) const
3806{
3801 return sc_fxnum_fast_bitref(*this, i - m_params.fwl());
3802}
3803
3804// part selection
3805inline const sc_fxnum_fast_subref
3806sc_fxnum_fast::operator () (int i, int j) const
3807{
3807 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3808 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
3808 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3809 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3809
3810 return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3811 i - m_params.fwl(), j - m_params.fwl());
3812}
3813
3814inline sc_fxnum_fast_subref
3815sc_fxnum_fast::operator () (int i, int j)
3816{
3810
3811 return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3812 i - m_params.fwl(), j - m_params.fwl());
3813}
3814
3815inline sc_fxnum_fast_subref
3816sc_fxnum_fast::operator () (int i, int j)
3817{
3817 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3818 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
3818 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3819 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3819
3820 return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3821}
3822
3823inline const sc_fxnum_fast_subref
3824sc_fxnum_fast::range(int i, int j) const
3825{
3820
3821 return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3822}
3823
3824inline const sc_fxnum_fast_subref
3825sc_fxnum_fast::range(int i, int j) const
3826{
3826 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3827 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
3827 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3828 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3828
3829 return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3830 i - m_params.fwl(), j - m_params.fwl());
3831}
3832
3833inline sc_fxnum_fast_subref
3834sc_fxnum_fast::range(int i, int j)
3835{
3829
3830 return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this),
3831 i - m_params.fwl(), j - m_params.fwl());
3832}
3833
3834inline sc_fxnum_fast_subref
3835sc_fxnum_fast::range(int i, int j)
3836{
3836 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), "index out of range");
3837 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), "index out of range");
3837 SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3838 SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_);
3838
3839 return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3840}
3841
3842inline const sc_fxnum_fast_subref
3843sc_fxnum_fast::operator () () const
3844{
3845 return this->operator () (m_params.wl() - 1, 0);

--- 523 unchanged lines hidden ---
3839
3840 return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl());
3841}
3842
3843inline const sc_fxnum_fast_subref
3844sc_fxnum_fast::operator () () const
3845{
3846 return this->operator () (m_params.wl() - 1, 0);

--- 523 unchanged lines hidden ---