00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2004 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.3 (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_buffer.h -- The sc_buffer<T> primitive channel class. 00021 Like sc_signal<T>, but *every* write causes an event. 00022 00023 Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21 00024 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 00029 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00030 changes you are making here. 00031 00032 Name, Affiliation, Date: 00033 Description of Modification: 00034 00035 *****************************************************************************/ 00036 00037 #ifndef SC_BUFFER_H 00038 #define SC_BUFFER_H 00039 00040 00041 #include "systemc/communication/sc_signal.h" 00042 00043 00044 // ---------------------------------------------------------------------------- 00045 // CLASS : sc_buffer<T> 00046 // 00047 // The sc_buffer<T> primitive channel class. 00048 // ---------------------------------------------------------------------------- 00049 00050 template <class T> 00051 class sc_buffer 00052 : public sc_signal<T> 00053 { 00054 public: 00055 00056 // typedefs 00057 00058 typedef sc_buffer<T> this_type; 00059 typedef sc_signal<T> base_type; 00060 00061 public: 00062 00063 // constructors 00064 00065 sc_buffer() 00066 : base_type( sc_gen_unique_name( "buffer" ) ) 00067 {} 00068 00069 explicit sc_buffer( const char* name_ ) 00070 : base_type( name_ ) 00071 {} 00072 00073 00074 // interface methods 00075 00076 // write the new value 00077 virtual void write( const T& ); 00078 00079 00080 // other methods 00081 00082 sc_buffer<T>& operator = ( const T& a ) 00083 { write( a ); return *this; } 00084 00085 sc_buffer<T>& operator = ( const base_type& a ) 00086 { write( a.read() ); return *this; } 00087 00088 sc_buffer<T>& operator = ( const this_type& a ) 00089 { write( a.read() ); return *this; } 00090 00091 virtual const char* kind() const 00092 { return "sc_buffer"; } 00093 00094 protected: 00095 00096 virtual void update(); 00097 00098 private: 00099 00100 // disabled 00101 sc_buffer( const sc_buffer<T>& ); 00102 }; 00103 00104 00105 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 00106 00107 // write the new value 00108 00109 template <class T> 00110 inline 00111 void 00112 sc_buffer<T>::write( const T& value_ ) 00113 { 00114 #ifdef DEBUG_SYSTEMC 00115 this->check_writer(); 00116 #endif 00117 this->m_new_val = value_; 00118 this->request_update(); 00119 } 00120 00121 00122 template <class T> 00123 inline 00124 void 00125 sc_buffer<T>::update() 00126 { 00127 this->m_cur_val = this->m_new_val; 00128 this->m_value_changed_event.notify_delayed(); 00129 this->m_delta = this->simcontext()->delta_count(); 00130 } 00131 00132 00133 #endif 00134 00135 // Taf!
1.2.18