00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 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 (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.accellera.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 // $Log: sc_value_base.h,v $ 00037 // Revision 1.4 2011/08/29 18:04:32 acg 00038 // Philipp A. Hartmann: miscellaneous clean ups. 00039 // 00040 // Revision 1.3 2011/08/24 22:05:48 acg 00041 // Torsten Maehne: initialization changes to remove warnings. 00042 // 00043 // Revision 1.2 2011/06/28 21:23:04 acg 00044 // Andy Goodrich: merging of SCV tree. 00045 // 00046 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00047 // SystemC 2.3 00048 // 00049 // Revision 1.3 2006/01/13 18:54:01 acg 00050 // Andy Goodrich: added $Log command so that CVS comments are reproduced in 00051 // the source. 00052 // 00053 00054 #ifndef SC_VALUE_BASE_H 00055 #define SC_VALUE_BASE_H 00056 00057 00058 #include "sysc/datatypes/int/sc_nbdefs.h" 00059 00060 namespace sc_dt 00061 { 00062 00063 class sc_signed; 00064 class sc_unsigned; 00065 00066 // ---------------------------------------------------------------------------- 00067 // CLASS : sc_value_base 00068 // 00069 // Abstract base class of all SystemC native variables. It provides 00070 // support for concatenation operations via a set of virtual methods. 00071 // A general description of the methods appear with their default 00072 // definitions in sc_object.cpp. 00073 // ---------------------------------------------------------------------------- 00074 00075 class sc_value_base 00076 { 00077 friend class sc_concatref; 00078 private: 00079 virtual void concat_clear_data( bool to_ones=false ); 00080 virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const; 00081 virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const; 00082 virtual uint64 concat_get_uint64() const; 00083 virtual int concat_length(bool* xz_present_p=0) const; 00084 virtual void concat_set( int64 src, int low_i ); 00085 virtual void concat_set( const sc_signed& src, int low_i ); 00086 virtual void concat_set( const sc_unsigned& src, int low_i ); 00087 virtual void concat_set( uint64 src, int low_i ); 00088 public: 00089 virtual ~sc_value_base() {} 00090 }; 00091 00092 00093 // ---------------------------------------------------------------------------- 00094 // CLASS : sc_generic_base 00095 // 00096 // Proxy class for user-defined value classes and other classes that 00097 // are defined outside of SystemC. 00098 // The class is utilized as a base class for the arbitrary class: 00099 // 00100 // class my_class : public sc_generic_base<my_class> 00101 // 00102 // The purpose of the class is to allow to_XXXX methods defined within that 00103 // class so that assignments and casts from the arbitrary class to native 00104 // SystemC types are possible. To interact correctly with the SystemC library 00105 // the class derived from sc_generic_base must implement the following 00106 // methods: 00107 // (1) uint64 to_uint64() const 00108 // (2) int64 to_int64() const 00109 // (3) void to_sc_unsigned( sc_unsigned& ) const 00110 // (4) void to_sc_signed( sc_signed& ) const 00111 // ---------------------------------------------------------------------------- 00112 template< class T > 00113 class sc_generic_base { 00114 public: 00115 inline const T* operator-> () const 00116 { 00117 return (const T*)this; 00118 } 00119 inline T* operator-> () 00120 { 00121 return (T*)this; 00122 } 00123 }; 00124 00125 } // namespace sc_dt 00126 00127 #endif