sc_fxtype_params.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_fxtype_params.h - 
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 // $Log: sc_fxtype_params.h,v $
00037 // Revision 1.1.1.1  2006/12/15 20:31:36  acg
00038 // SystemC 2.2
00039 //
00040 // Revision 1.3  2006/01/13 18:53:58  acg
00041 // Andy Goodrich: added $Log command so that CVS comments are reproduced in
00042 // the source.
00043 //
00044 
00045 #ifndef SC_FXTYPE_PARAMS_H
00046 #define SC_FXTYPE_PARAMS_H
00047 
00048 
00049 #include "sysc/datatypes/fx/sc_context.h"
00050 
00051 
00052 namespace sc_dt
00053 {
00054 
00055 // classes defined in this module
00056 class sc_fxtype_params;
00057 
00058 
00059 // ----------------------------------------------------------------------------
00060 //  CLASS : sc_fxtype_params
00061 //
00062 //  Fixed-point type parameters class.
00063 // ----------------------------------------------------------------------------
00064 
00065 class sc_fxtype_params
00066 {
00067 public:
00068 
00069              sc_fxtype_params();
00070              sc_fxtype_params( int, int );
00071              sc_fxtype_params(           sc_q_mode, sc_o_mode, int = 0 );
00072              sc_fxtype_params( int, int, sc_q_mode, sc_o_mode, int = 0 );
00073              sc_fxtype_params( const sc_fxtype_params& );
00074          sc_fxtype_params( const sc_fxtype_params&,
00075                    int, int );
00076          sc_fxtype_params( const sc_fxtype_params&,
00077                              sc_q_mode, sc_o_mode, int = 0 );
00078     explicit sc_fxtype_params( sc_without_context );
00079 
00080     sc_fxtype_params& operator = ( const sc_fxtype_params& );
00081 
00082     friend bool operator == ( const sc_fxtype_params&,
00083                               const sc_fxtype_params& );
00084     friend bool operator != ( const sc_fxtype_params&,
00085                   const sc_fxtype_params& );
00086 
00087     int wl() const;
00088     void wl( int );
00089 
00090     int iwl() const;
00091     void iwl( int );
00092 
00093     sc_q_mode q_mode() const;
00094     void q_mode( sc_q_mode );
00095 
00096     sc_o_mode o_mode() const;
00097     void o_mode( sc_o_mode );
00098 
00099     int n_bits() const;
00100     void n_bits( int );
00101 
00102     const std::string to_string() const;
00103 
00104     void print( ::std::ostream& = ::std::cout ) const;
00105     void dump( ::std::ostream& = ::std::cout ) const;
00106 
00107 private:
00108 
00109     int       m_wl;
00110     int       m_iwl;
00111     sc_q_mode m_q_mode;
00112     sc_o_mode m_o_mode;
00113     int       m_n_bits;
00114 };
00115 
00116 
00117 // ----------------------------------------------------------------------------
00118 //  TYPEDEF : sc_fxtype_context
00119 //
00120 //  Context type for the fixed-point type parameters.
00121 // ----------------------------------------------------------------------------
00122 
00123 typedef sc_context<sc_fxtype_params> sc_fxtype_context;
00124 
00125 
00126 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00127 
00128 inline
00129 sc_fxtype_params::sc_fxtype_params()
00130 {
00131     *this = sc_fxtype_context::default_value();
00132 }
00133 
00134 inline
00135 sc_fxtype_params::sc_fxtype_params( int wl_, int iwl_ )
00136 {
00137     *this = sc_fxtype_context::default_value();
00138 
00139     SC_CHECK_WL_( wl_ );
00140     m_wl  = wl_;
00141     m_iwl = iwl_;
00142 }
00143 
00144 inline
00145 sc_fxtype_params::sc_fxtype_params( sc_q_mode q_mode_,
00146                                     sc_o_mode o_mode_, int n_bits_ )
00147 {
00148     *this = sc_fxtype_context::default_value();
00149 
00150     SC_CHECK_N_BITS_( n_bits_ );
00151     m_q_mode = q_mode_;
00152     m_o_mode = o_mode_;
00153     m_n_bits = n_bits_;
00154 }
00155 
00156 inline
00157 sc_fxtype_params::sc_fxtype_params( int wl_, int iwl_,
00158                                     sc_q_mode q_mode_,
00159                                     sc_o_mode o_mode_, int n_bits_ )
00160 {
00161     SC_CHECK_WL_( wl_ );
00162     SC_CHECK_N_BITS_( n_bits_ );
00163     m_wl     = wl_;
00164     m_iwl    = iwl_;
00165     m_q_mode = q_mode_;
00166     m_o_mode = o_mode_;
00167     m_n_bits = n_bits_;
00168 }
00169 
00170 inline
00171 sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a )
00172 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
00173   m_q_mode( a.m_q_mode ),
00174   m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
00175 {}
00176 
00177 inline
00178 sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a,
00179                     int wl_, int iwl_ )
00180 : m_wl( wl_ ), m_iwl( iwl_ ),
00181   m_q_mode( a.m_q_mode ),
00182   m_o_mode( a.m_o_mode ), m_n_bits( a.m_n_bits )
00183 {}
00184 
00185 inline
00186 sc_fxtype_params::sc_fxtype_params( const sc_fxtype_params& a,
00187                     sc_q_mode q_mode_,
00188                     sc_o_mode o_mode_, int n_bits_ )
00189 : m_wl( a.m_wl ), m_iwl( a.m_iwl ),
00190   m_q_mode( q_mode_ ),
00191   m_o_mode( o_mode_ ), m_n_bits( n_bits_ )
00192 {}
00193 
00194 inline
00195 sc_fxtype_params::sc_fxtype_params( sc_without_context )
00196 : m_wl    ( SC_DEFAULT_WL_ ),
00197   m_iwl   ( SC_DEFAULT_IWL_ ),
00198   m_q_mode( SC_DEFAULT_Q_MODE_ ),
00199   m_o_mode( SC_DEFAULT_O_MODE_ ),
00200   m_n_bits( SC_DEFAULT_N_BITS_ )
00201 {}
00202 
00203 
00204 inline
00205 sc_fxtype_params&
00206 sc_fxtype_params::operator = ( const sc_fxtype_params& a )
00207 {
00208     if( &a != this )
00209     {
00210         m_wl     = a.m_wl;
00211     m_iwl    = a.m_iwl;
00212     m_q_mode = a.m_q_mode;
00213     m_o_mode = a.m_o_mode;
00214     m_n_bits = a.m_n_bits;
00215     }
00216     return *this;
00217 }
00218 
00219 
00220 inline
00221 bool
00222 operator == ( const sc_fxtype_params& a, const sc_fxtype_params& b )
00223 {
00224     return ( a.m_wl     == b.m_wl     &&
00225          a.m_iwl    == b.m_iwl    &&
00226          a.m_q_mode == b.m_q_mode &&
00227          a.m_o_mode == b.m_o_mode &&
00228          a.m_n_bits == b.m_n_bits );
00229 }
00230 
00231 inline
00232 bool
00233 operator != ( const sc_fxtype_params& a, const sc_fxtype_params& b )
00234 {
00235     return ( a.m_wl     != b.m_wl     ||
00236          a.m_iwl    != b.m_iwl    ||
00237          a.m_q_mode != b.m_q_mode ||
00238          a.m_o_mode != b.m_o_mode ||
00239          a.m_n_bits != b.m_n_bits );
00240 }
00241 
00242 
00243 inline
00244 int
00245 sc_fxtype_params::wl() const
00246 {
00247     return m_wl;
00248 }
00249 
00250 inline
00251 void
00252 sc_fxtype_params::wl( int wl_ )
00253 {
00254     SC_CHECK_WL_( wl_ );
00255     m_wl = wl_;
00256 }
00257 
00258 
00259 inline
00260 int
00261 sc_fxtype_params::iwl() const
00262 {
00263     return m_iwl;
00264 }
00265 
00266 inline
00267 void
00268 sc_fxtype_params::iwl( int iwl_ )
00269 {
00270     m_iwl = iwl_;
00271 }
00272 
00273 
00274 inline
00275 sc_q_mode
00276 sc_fxtype_params::q_mode() const
00277 {
00278     return m_q_mode;
00279 }
00280 
00281 inline
00282 void
00283 sc_fxtype_params::q_mode( sc_q_mode q_mode_ )
00284 {
00285     m_q_mode = q_mode_;
00286 }
00287 
00288 
00289 inline
00290 sc_o_mode
00291 sc_fxtype_params::o_mode() const
00292 {
00293     return m_o_mode;
00294 }
00295 
00296 inline
00297 void
00298 sc_fxtype_params::o_mode( sc_o_mode o_mode_ )
00299 {
00300     m_o_mode = o_mode_;
00301 }
00302 
00303 
00304 inline
00305 int
00306 sc_fxtype_params::n_bits() const
00307 {
00308     return m_n_bits;
00309 }
00310 
00311 inline
00312 void
00313 sc_fxtype_params::n_bits( int n_bits_ )
00314 {
00315     SC_CHECK_N_BITS_( n_bits_ );
00316     m_n_bits = n_bits_;
00317 }
00318 
00319 
00320 inline
00321 ::std::ostream&
00322 operator << ( ::std::ostream& os, const sc_fxtype_params& a )
00323 {
00324     a.print( os );
00325     return os;
00326 }
00327 
00328 } // namespace sc_dt
00329 
00330 
00331 #endif
00332 
00333 // Taf!

Generated on Wed Jan 21 15:32:07 2009 for SystemC by  doxygen 1.5.5