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