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 #include "rc_signal_resolved.h" 00038 00039 namespace ReChannel { 00040 00041 rc_signal_resolved::rc_signal_resolved(const sc_module_name& name_) 00042 : base_type(name_) 00043 { 00044 for (int i=0; i < 4; ++i) { 00045 m_value_count[i] = 0; 00046 } 00047 } 00048 00049 void rc_signal_resolved::write(const sc_logic& value) 00050 { 00051 if (this->rc_is_active() || !sc_is_running()) { 00052 sc_process_handle hproc = sc_get_current_process_handle(); 00053 00054 data_type value_ = value.value(); 00055 00056 bool found = false; 00057 00058 for(written_vector::iterator it = m_written_vector.begin(); 00059 it != m_written_vector.end(); 00060 ++it) 00061 { 00062 written& w = *it; 00063 if (hproc.get_process_object() 00064 == w.hproc.get_process_object()) 00065 { 00066 data_type& w_value_ = w.value; 00067 if (value_ != w_value_) { 00068 --m_value_count[w_value_]; 00069 if (value_ != (data_type)Log_Z) { 00070 ++m_value_count[value_]; 00071 w_value_ = value_; 00072 } else { 00073 if (&w != &m_written_vector.back()) { 00074 w = m_written_vector.back(); 00075 } 00076 m_written_vector.pop_back(); 00077 } 00078 found = true; 00079 break; 00080 } 00081 return; 00082 } 00083 } 00084 00085 if (!found && value_ != (data_type)Log_Z) { 00086 m_written_vector.push_back(written(hproc, value_)); 00087 ++m_value_count[value_]; 00088 } 00089 00090 if (m_value_count[Log_X] > 0) { 00091 m_new_value = Log_X; 00092 } else if (m_value_count[Log_0] > 0) { 00093 m_new_value = 00094 (m_value_count[Log_1] == 0 00095 ? Log_0 : Log_X); 00096 } else if (m_value_count[Log_1] > 0) { 00097 m_new_value = 00098 (m_value_count[Log_0] == 0 00099 ? Log_1 : Log_X); 00100 } else { 00101 m_new_value = Log_Z; 00102 } 00103 request_update(); 00104 } 00105 } 00106 00107 } // namespace ReChannel 00108 00109 // 00110 // $Id: rc_signal_resolved.cpp,v 1.6 2007/12/20 20:33:51 felke Exp $ 00111 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/components/rc_signal_resolved.cpp,v $ 00112 //