00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0: 00002 /* 00003 * Copyright (C) 2007, Technical Computer Science Group, 00004 * University of Bonn 00005 * 00006 * This file is part of the ReChannel library. 00007 * 00008 * The ReChannel library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as 00010 * published by the Free Software Foundation; either version 2 of the 00011 * License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be 00014 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this library; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke. 00024 * {raabe, felke}@cs.uni-bonn.de 00025 */ 00037 #ifndef RC_SIGNAL_RESOLVED_H_ 00038 #define RC_SIGNAL_RESOLVED_H_ 00039 00040 #include "ReChannel/components/rc_signal.h" 00041 00042 namespace ReChannel { 00043 00047 class rc_signal_resolved 00048 : public rc_signal<sc_logic> 00049 { 00050 private: 00051 typedef sc_dt::sc_logic_value_t data_type; 00052 enum logic_values { 00053 Log_0 = 0, 00054 Log_1, 00055 Log_Z, 00056 Log_X 00057 }; 00058 struct written 00059 { 00060 written(const sc_process_handle& hproc_, data_type value_) 00061 : hproc(hproc_), value(value_) 00062 { } 00063 sc_process_handle hproc; 00064 data_type value; 00065 }; 00066 00067 private: 00068 typedef rc_signal_resolved this_type; 00069 typedef rc_signal<sc_logic> base_type; 00070 00071 typedef std::vector<written> written_vector; 00072 00073 using base_type::m_new_value; 00074 00075 public: 00076 explicit rc_signal_resolved( 00077 const sc_module_name& name_=sc_gen_unique_name("signal_resolved")); 00078 00079 virtual const char* kind() const 00080 { return "rc_signal_resolved"; } 00081 00082 virtual void register_port(sc_port_base& port_, const char* if_name_) 00083 { } 00084 00085 virtual void write(const sc_logic& value); 00086 00087 operator const sc_logic&() const 00088 { return this->read(); } 00089 00090 this_type& operator=(const sc_logic& value) 00091 { this->write(value); return *this; } 00092 00093 this_type& operator=(const this_type& signal_) 00094 { this->write(signal_); return *this; } 00095 00096 protected: 00097 00098 RC_ON_INIT_RESETTABLE() 00099 { 00100 base_type::rc_on_init_resettable(); 00101 if (!m_written_vector.empty()) { 00102 m_reset_written_vector = m_written_vector; 00103 } 00104 } 00105 00106 RC_ON_RESET() 00107 { 00108 base_type::rc_on_reset(); 00109 for (int i=0; i < 4; ++i) { 00110 m_value_count[i] = 0; 00111 } 00112 if (m_reset_written_vector.empty()) { 00113 m_written_vector.clear(); 00114 } else { 00115 m_written_vector = m_reset_written_vector; 00116 for (written_vector::iterator it = m_written_vector.begin(); 00117 it != m_written_vector.end(); 00118 ++it) 00119 { 00120 int value = (*it).value; 00121 if (value != Log_Z) { 00122 m_value_count[value] += 1; 00123 } 00124 } 00125 } 00126 } 00127 00128 protected: 00129 00130 written_vector m_reset_written_vector; 00131 written_vector m_written_vector; 00132 int m_value_count[4]; 00133 00134 private: 00135 // diabled 00136 rc_signal_resolved(const this_type& signal_); 00137 }; 00138 00139 } // namespace ReChannel 00140 00141 #endif // RC_SIGNAL_RESOLVED_H_ 00142 00143 // 00144 // $Id: rc_signal_resolved.h,v 1.7 2007/11/23 13:25:45 felke Exp $ 00145 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/components/rc_signal_resolved.h,v $ 00146 //