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 */ 00039 #ifndef RC_SIGNAL_EXPORTALS_H_ 00040 #define RC_SIGNAL_EXPORTALS_H_ 00041 00042 #include "ReChannel/communication/exportals/rc_exportal.h" 00043 #include "ReChannel/communication/accessors/rc_signal_accessors.h" 00044 00045 namespace ReChannel { 00046 00050 template<class T> 00051 RC_EXPORTAL_TEMPLATE(sc_signal_in_if<T>) 00052 { 00053 RC_EXPORTAL_TEMPLATE_CTOR(sc_signal_in_if<T>) 00054 { 00055 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00056 } 00057 00058 RC_ON_OPEN() 00059 { 00060 this->refresh_notify(); 00061 } 00062 00063 RC_ON_CLOSE() 00064 { 00065 this->notify_event("value_changed_event"); 00066 } 00067 00068 RC_ON_REFRESH_NOTIFY() 00069 { 00070 this->notify_event("value_changed_event"); 00071 00072 } 00073 }; 00074 00078 RC_EXPORTAL(sc_signal_in_if<bool>) 00079 { 00080 RC_EXPORTAL_CTOR(sc_signal_in_if<bool>) 00081 { 00082 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00083 RC_EXPORTAL_FORWARD_EVENT(posedge_event); 00084 RC_EXPORTAL_FORWARD_EVENT(negedge_event); 00085 } 00086 00087 RC_ON_OPEN() 00088 { 00089 this->refresh_notify(); 00090 } 00091 00092 RC_ON_CLOSE() 00093 { 00094 this->notify_event("value_changed_event"); 00095 } 00096 00097 RC_ON_REFRESH_NOTIFY() 00098 { 00099 this->notify_event("value_changed_event"); 00100 if_type* const interface_ = this->get_interface(); 00101 if (interface_ != NULL) { 00102 if (interface_->read() == true) { 00103 this->notify_event("posedge_event"); 00104 } else { 00105 this->notify_event("negedge_event"); 00106 } 00107 } 00108 } 00109 }; 00110 00114 RC_EXPORTAL(sc_signal_in_if<sc_logic>) 00115 { 00116 RC_EXPORTAL_CTOR(sc_signal_in_if<sc_logic>) 00117 { 00118 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00119 RC_EXPORTAL_FORWARD_EVENT(posedge_event); 00120 RC_EXPORTAL_FORWARD_EVENT(negedge_event); 00121 } 00122 00123 RC_ON_OPEN() 00124 { 00125 this->refresh_notify(); 00126 } 00127 00128 RC_ON_CLOSE() 00129 { 00130 this->notify_event("value_changed_event"); 00131 } 00132 00133 RC_ON_REFRESH_NOTIFY() 00134 { 00135 this->notify_event("value_changed_event"); 00136 if_type* const interface_ = this->get_interface(); 00137 assert(interface_ != NULL); 00138 if (interface_ != NULL) { 00139 const sc_logic value = interface_->read(); 00140 if (value == SC_LOGIC_1) { 00141 this->notify_event("posedge_event"); 00142 } else if (value == SC_LOGIC_0) { 00143 this->notify_event("negedge_event"); 00144 } 00145 } 00146 } 00147 }; 00148 00152 template<int W> 00153 RC_EXPORTAL_TEMPLATE(sc_signal_in_if<sc_lv<W> >) 00154 { 00155 RC_EXPORTAL_TEMPLATE_CTOR(sc_signal_in_if<sc_lv<W> >) 00156 { 00157 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00158 } 00159 00160 RC_ON_OPEN() 00161 { 00162 this->refresh_notify(); 00163 } 00164 00165 RC_ON_CLOSE() 00166 { 00167 this->notify_event("value_changed_event"); 00168 } 00169 00170 RC_ON_REFRESH_NOTIFY() 00171 { 00172 this->notify_event("value_changed_event"); 00173 } 00174 }; 00175 00179 template<class T> 00180 RC_EXPORTAL_TEMPLATE(sc_signal_inout_if<T>) 00181 { 00182 RC_EXPORTAL_TEMPLATE_CTOR(sc_signal_inout_if<T>) 00183 { 00184 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00185 } 00186 00187 RC_ON_OPEN() 00188 { 00189 this->refresh_notify(); 00190 } 00191 00192 RC_ON_CLOSE() 00193 { 00194 this->notify_event("value_changed_event"); 00195 } 00196 00197 RC_ON_REFRESH_NOTIFY() 00198 { 00199 this->notify_event("value_changed_event"); 00200 } 00201 }; 00202 00206 RC_EXPORTAL(sc_signal_inout_if<bool>) 00207 { 00208 RC_EXPORTAL_CTOR(sc_signal_inout_if<bool>) 00209 { 00210 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00211 RC_EXPORTAL_FORWARD_EVENT(posedge_event); 00212 RC_EXPORTAL_FORWARD_EVENT(negedge_event); 00213 } 00214 00215 RC_ON_OPEN() 00216 { 00217 this->refresh_notify(); 00218 } 00219 00220 RC_ON_CLOSE() 00221 { 00222 this->notify_event("value_changed_event"); 00223 } 00224 00225 RC_ON_REFRESH_NOTIFY() 00226 { 00227 this->notify_event("value_changed_event"); 00228 if_type* const interface_ = this->get_interface(); 00229 assert(interface_ != NULL); 00230 if (interface_ != NULL) { 00231 if (interface_->read() == true) { 00232 this->notify_event("posedge_event"); 00233 } else { 00234 this->notify_event("negedge_event"); 00235 } 00236 } 00237 } 00238 }; 00239 00243 RC_EXPORTAL(sc_signal_inout_if<sc_logic>) 00244 { 00245 RC_EXPORTAL_CTOR(sc_signal_inout_if<sc_logic>) 00246 { 00247 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00248 RC_EXPORTAL_FORWARD_EVENT(posedge_event); 00249 RC_EXPORTAL_FORWARD_EVENT(negedge_event); 00250 } 00251 00252 RC_ON_OPEN() 00253 { 00254 this->refresh_notify(); 00255 } 00256 00257 RC_ON_CLOSE() 00258 { 00259 // write 'Z' to the channel (for each registered driver) 00260 rc_interface_wrapper<if_type>* const ifw = 00261 this->get_interface_wrapper(); 00262 assert(ifw != NULL); 00263 if (ifw != NULL) { 00264 const int drv_count = ifw->get_nb_driver_count(); 00265 for (int i=0; i < drv_count; i++) { 00266 ifw->get_nb_driver_access(i)->call( 00267 &if_type::write, SC_LOGIC_Z); 00268 } 00269 } 00270 this->notify_event("value_changed_event"); 00271 } 00272 00273 RC_ON_REFRESH_NOTIFY() 00274 { 00275 this->notify_event("value_changed_event"); 00276 if_type* const interface_ = this->get_interface(); 00277 assert(interface_ != NULL); 00278 if (interface_ != NULL) { 00279 const sc_logic value = interface_->read(); 00280 if (value == SC_LOGIC_1) { 00281 this->notify_event("posedge_event"); 00282 } else if (value == SC_LOGIC_0) { 00283 this->notify_event("negedge_event"); 00284 } 00285 } 00286 } 00287 }; 00288 00292 template<int W> 00293 RC_EXPORTAL_TEMPLATE(sc_signal_inout_if<sc_lv<W> >) 00294 { 00295 RC_EXPORTAL_TEMPLATE_CTOR(sc_signal_inout_if<sc_lv<W> >) 00296 { 00297 RC_EXPORTAL_FORWARD_EVENT(value_changed_event); 00298 } 00299 00300 RC_ON_OPEN() 00301 { 00302 this->refresh_notify(); 00303 } 00304 00305 RC_ON_CLOSE() 00306 { 00307 // write 'Z..Z' to the static channel (for each registered driver) 00308 rc_interface_wrapper<if_type>* const ifw = 00309 this->get_interface_wrapper(); 00310 assert(ifw != NULL); 00311 if (ifw != NULL) { 00312 const int drv_count = ifw->get_nb_driver_count(); 00313 for (int i=0; i < drv_count; i++) { 00314 ifw->get_nb_driver_access(i)->call( 00315 &if_type::write, s_ZZZ); 00316 } 00317 } 00318 this->notify_event("value_changed_event"); 00319 } 00320 00321 RC_ON_REFRESH_NOTIFY() 00322 { 00323 this->notify_event("value_changed_event"); 00324 } 00325 00326 private: 00327 static const sc_dt::sc_lv<W> s_ZZZ; 00328 }; 00329 00330 template<int W> 00331 const typename sc_dt::sc_lv<W> 00332 rc_exportal<sc_signal_inout_if<sc_lv<W> > >::s_ZZZ = sc_lv<W>('Z'); 00333 00334 } // namespace ReChannel 00335 00336 #endif // RC_SIGNAL_EXPORTALS_H_ 00337 // 00338 // $Id: rc_signal_exportals.h,v 1.8 2007/11/23 13:25:45 felke Exp $ 00339 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/exportals/rc_signal_exportals.h,v $ 00340 //