src/sysc/datatypes/misc/sc_value_base.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-2005 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_value_base.h -- Base class for SystemC bit values.
00021 
00022   Original Author: Andy Goodrich, Forte Design Systems
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 #ifndef SC_VALUE_BASE_H
00037 #define SC_VALUE_BASE_H
00038 
00039 
00040 #include "sysc/datatypes/int/sc_nbdefs.h"
00041 
00042 namespace sc_dt 
00043 {
00044 
00045 class sc_signed;
00046 class sc_unsigned;
00047 
00048 // ----------------------------------------------------------------------------
00049 //  CLASS : sc_value_base
00050 //
00051 //  Abstract base class of all SystemC native variables. It provides
00052 //  support for concatenation operations via a set of virtual methods. 
00053 //  A general description of the methods appear with their default 
00054 //  definitions in sc_object.cpp.
00055 // ----------------------------------------------------------------------------
00056 
00057 class sc_value_base 
00058 {
00059     friend class sc_concatref;
00060   private: 
00061     virtual void concat_clear_data( bool to_ones=false );
00062     virtual bool concat_get_ctrl( unsigned long* dst_p, int low_i ) const;
00063     virtual bool concat_get_data( unsigned long* dst_p, int low_i ) const;
00064     virtual uint64 concat_get_uint64() const;
00065     virtual int concat_length(bool* xz_present_p=0) const;
00066     virtual void concat_set( int64 src, int low_i );
00067     virtual void concat_set( const sc_signed& src, int low_i );
00068     virtual void concat_set( const sc_unsigned& src, int low_i );
00069     virtual void concat_set( uint64 src, int low_i );
00070 };
00071 
00072 
00073 // ----------------------------------------------------------------------------
00074 //  CLASS : sc_generic_base
00075 //
00076 //  Proxy class for user-defined value classes and other classes that 
00077 //  are defined outside of SystemC. 
00078 //  The class is utilized as a base class for the arbitrary class:
00079 //
00080 //       class my_class : public sc_generic_base<my_class>
00081 //
00082 //  The purpose of the class is to allow to_XXXX methods defined within that 
00083 //  class so that assignments and casts from the arbitrary class to native 
00084 //  SystemC types are possible. To interact correctly with the SystemC library 
00085 //  the class derived from sc_generic_base must implement the following 
00086 //  methods: 
00087 //    (1) uint64 to_uint64() const
00088 //    (2) int64  to_int64() const
00089 //    (3) void to_sc_unsigned( sc_unsigned& ) const
00090 //    (4) void to_sc_signed( sc_signed& ) const
00091 // ----------------------------------------------------------------------------
00092 template< class T >
00093 class sc_generic_base {
00094   public: 
00095     inline const T* operator-> () const
00096     {
00097         return (const T*)this;
00098     }
00099     inline T* operator-> () 
00100     {
00101         return (T*)this;
00102     }
00103 };
00104 
00105 } // namespace sc_dt
00106 
00107 #endif

Generated on Wed Apr 25 13:53:27 2007 for SystemC by  doxygen 1.5.1