rc_resolved_portals.h

Go to the documentation of this file.
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_RESOLVED_PORTALS_H_
00038 #define RC_RESOLVED_PORTALS_H_
00039 
00040 #include "ReChannel/communication/portals/rc_portal.h"
00041 #include "ReChannel/communication/accessors/rc_signal_accessors.h"
00042 
00043 namespace ReChannel {
00044 
00048 RC_PORTAL(sc_in_resolved)
00049 {
00050     RC_PORTAL_CTOR(sc_in_resolved)
00051     {
00052         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00053         RC_PORTAL_FORWARD_EVENT(posedge_event);
00054         RC_PORTAL_FORWARD_EVENT(negedge_event);
00055     }
00056 
00057     RC_ON_OPEN()
00058     {
00059         this->refresh_notify();
00060     }
00061 
00062     RC_ON_REFRESH_NOTIFY()
00063     {
00064         const sc_logic value = this->get_static_port().read();
00065         this->notify_event("value_changed_event");
00066         if (value == SC_LOGIC_1) {
00067             this->notify_event("posedge_event");
00068         }
00069     }
00070 };
00071 
00075 RC_PORTAL(sc_inout_resolved)
00076 {
00077     RC_PORTAL_CTOR(sc_inout_resolved)
00078     {
00079         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00080         RC_PORTAL_FORWARD_EVENT(posedge_event);
00081         RC_PORTAL_FORWARD_EVENT(negedge_event);
00082     }
00083 
00084     RC_ON_OPEN()
00085     {
00086         this->refresh_notify();
00087     }
00088 
00089     RC_ON_CLOSE()
00090     {
00091         // write 'Z' to the static channel (for each registered driver)
00092         rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00093         const int drv_count = ifw.get_nb_driver_count();
00094         for (int i=0; i < drv_count; i++) {
00095             ifw.get_nb_driver_access(i)->call(&if_type::write, SC_LOGIC_Z);
00096         }
00097     }
00098 
00099     RC_ON_UNDEF()
00100     {
00101         // write 'X' to the static channel (disable other drivers first)
00102         rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00103         const int drv_count = ifw.get_nb_driver_count();
00104         for (int i=1; i < drv_count; i++) {
00105             ifw.get_nb_driver_access(i)->call(&if_type::write, SC_LOGIC_Z);
00106         }
00107         ifw.get_nb_driver_access(0)->call(&if_type::write, SC_LOGIC_X);
00108     }
00109 
00110     RC_ON_REFRESH_NOTIFY()
00111     {
00112         const sc_logic value = this->get_static_port().read();
00113         this->notify_event("value_changed_event");
00114         if (value == SC_LOGIC_1) {
00115             this->notify_event("posedge_event");
00116         }
00117     }
00118 };
00119 
00123 template<>
00124 class rc_portal<sc_out_resolved>
00125     : public rc_portal<sc_inout_resolved>
00126 {
00127     typedef rc_portal<sc_inout_resolved> base_type;
00128 public:
00129     typedef base_type::port_type     port_type;
00130     typedef base_type::if_type       if_type;
00131     typedef base_type::accessor_type accessor_type;
00132 
00133     rc_portal<sc_out_resolved>(
00134         const sc_module_name& module_name =
00135             sc_gen_unique_name("rc_portal"))
00136         : base_type(module_name)
00137     { }
00138 };
00139 
00140 /* named portal specializations */
00141 
00145 class rc_in_resolved_portal
00146     : public rc_portal<sc_in_resolved>
00147 {
00148     typedef rc_portal<sc_in_resolved> base_type;
00149 public:
00150     typedef base_type::port_type     port_type;
00151     typedef base_type::if_type       if_type;
00152     typedef base_type::accessor_type accessor_type;
00153 
00154     explicit rc_in_resolved_portal(
00155         const sc_module_name& name_ =
00156             sc_gen_unique_name("rc_in_resolved_portal"))
00157         : base_type(name_)
00158     { }
00159 };
00160 
00164 class rc_inout_resolved_portal
00165     : public rc_portal<sc_inout_resolved>
00166 {
00167     typedef rc_portal<sc_inout_resolved> base_type;
00168 public:
00169     typedef base_type::port_type     port_type;
00170     typedef base_type::if_type       if_type;
00171     typedef base_type::accessor_type accessor_type;
00172 
00173     explicit rc_inout_resolved_portal(
00174         const sc_module_name& name_ =
00175             sc_gen_unique_name("rc_inout_resolved_portal"))
00176         : base_type(name_)
00177     { }
00178 };
00179 
00183 class rc_out_resolved_portal
00184     : public rc_portal<sc_out_resolved>
00185 {
00186     typedef rc_portal<sc_out_resolved> base_type;
00187 public:
00188     typedef base_type::port_type     port_type;
00189     typedef base_type::if_type       if_type;
00190     typedef base_type::accessor_type accessor_type;
00191 
00192     explicit rc_out_resolved_portal(
00193         const sc_module_name& name_ =
00194             sc_gen_unique_name("rc_out_resolved_portal"))
00195         : base_type(name_)
00196     { }
00197 };
00198 
00199 } // namespace ReChannel
00200 
00201 #endif // RC_RESOLVED_PORTALS_H_
00202 //
00203 // $Id: rc_resolved_portals.h,v 1.11 2007/11/23 13:25:45 felke Exp $
00204 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/portals/rc_resolved_portals.h,v $
00205 //
00206 

Generated on Tue Jan 1 23:13:48 2008 for ReChannel by  doxygen 1.5.3