rc_rv_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_RV_PORTALS_H_
00038 #define RC_RV_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 template<int W>
00049 RC_PORTAL_TEMPLATE(sc_in_rv<W>)
00050 {
00051     RC_PORTAL_TEMPLATE_CTOR(sc_in_rv<W>)
00052     {
00053         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00054     }
00055 
00056     RC_ON_OPEN()
00057     {
00058         this->refresh_notify();
00059     }
00060 
00061     RC_ON_REFRESH_NOTIFY()
00062     {
00063         this->notify_event("value_changed_event");
00064     }
00065 };
00066 
00070 template<int W>
00071 RC_PORTAL_TEMPLATE(sc_inout_rv<W>)
00072 {
00073     RC_PORTAL_TEMPLATE_CTOR(sc_inout_rv<W>)
00074     {
00075         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00076     }
00077 
00078     RC_ON_OPEN()
00079     {
00080         this->refresh_notify();
00081     }
00082 
00083     RC_ON_CLOSE()
00084     {
00085         // write 'Z..Z' to the static channel (for each registered driver)
00086         rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00087         const int drv_count = ifw.get_nb_driver_count();
00088         for (int i=0; i < drv_count; i++) {
00089             ifw.get_nb_driver_access(i)->call(
00090                 &if_type::write, rc_cref(s_ZZZ));
00091         }
00092     }
00093 
00094     RC_ON_UNDEF()
00095     {
00096         // write 'X..X' to the static channel (disable other drivers first)
00097         rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00098         const int drv_count = ifw.get_nb_driver_count();
00099         for (int i=1; i < drv_count; i++) {
00100             ifw.get_nb_driver_access(i)->call(
00101                 &if_type::write, rc_cref(s_ZZZ));
00102         }
00103         ifw.get_nb_driver_access(0)->call(&if_type::write, rc_cref(s_XXX));
00104     }
00105 
00106     RC_ON_REFRESH_NOTIFY()
00107     {
00108         this->notify_event("value_changed_event");
00109     }
00110 
00111 private:
00112     static const sc_dt::sc_lv<W> s_ZZZ;
00113     static const sc_dt::sc_lv<W> s_XXX;
00114 };
00115 
00116 template<int W>
00117 const typename sc_dt::sc_lv<W>
00118 rc_portal<sc_inout_rv<W> >::s_ZZZ = sc_lv<W>('Z');
00119 
00120 template<int W>
00121 const typename sc_dt::sc_lv<W>
00122 rc_portal<sc_inout_rv<W> >::s_XXX = sc_lv<W>('X');
00123 
00127 template<int W>
00128 class rc_portal<sc_out_rv<W> >
00129     : public rc_portal<sc_inout_rv<W> >
00130 {
00131     typedef rc_portal<sc_inout_rv<W> > base_type;
00132 public:
00133     typedef typename base_type::port_type     port_type;
00134     typedef typename base_type::if_type       if_type;
00135     typedef typename base_type::accessor_type accessor_type;
00136 
00137     rc_portal<sc_out_rv<W> >(
00138         const sc_module_name& module_name =
00139             sc_gen_unique_name("rc_portal"))
00140         : base_type(module_name)
00141     { }
00142 };
00143 
00144 /* named portal specializations */
00145 
00149 template<int W>
00150 class rc_in_rv_portal
00151     : public rc_portal<sc_in_rv<W> >
00152 {
00153     typedef rc_portal<sc_in_rv<W> > base_type;
00154 public:
00155     typedef typename base_type::port_type     port_type;
00156     typedef typename base_type::if_type       if_type;
00157     typedef typename base_type::accessor_type accessor_type;
00158 
00159     explicit rc_in_rv_portal(
00160         const sc_module_name& name_ =
00161             sc_gen_unique_name("rc_in_rv_portal"))
00162         : base_type(name_)
00163     { }
00164 };
00165 
00169 template<int W>
00170 class rc_inout_rv_portal
00171     : public rc_portal<sc_inout_rv<W> >
00172 {
00173     typedef rc_portal<sc_inout_rv<W> > base_type;
00174 public:
00175     typedef typename base_type::port_type     port_type;
00176     typedef typename base_type::if_type       if_type;
00177     typedef typename base_type::accessor_type accessor_type;
00178 
00179     explicit rc_inout_rv_portal(
00180         const sc_module_name& name_ =
00181             sc_gen_unique_name("rc_inout_rv_portal"))
00182         : base_type(name_)
00183     { }
00184 };
00185 
00189 template<int W>
00190 class rc_out_rv_portal
00191     : public rc_portal<sc_out_rv<W> >
00192 {
00193     typedef rc_portal<sc_out_rv<W> > base_type;
00194 public:
00195     typedef typename base_type::port_type     port_type;
00196     typedef typename base_type::if_type       if_type;
00197     typedef typename base_type::accessor_type accessor_type;
00198 
00199     explicit rc_out_rv_portal(
00200         const sc_module_name& name_ =
00201             sc_gen_unique_name("rc_out_rv_portal"))
00202         : base_type(name_)
00203     { }
00204 };
00205 
00206 } // namespace ReChannel
00207 
00208 #endif // RC_RV_PORTALS_H_
00209 //
00210 // $Id: rc_rv_portals.h,v 1.10 2007/11/23 13:25:45 felke Exp $
00211 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/portals/rc_rv_portals.h,v $
00212 //

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