rc_signal_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_SIGNAL_PORTALS_H_
00038 #define RC_SIGNAL_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<class T>
00049 RC_PORTAL_TEMPLATE(sc_in<T>)
00050 {
00051     RC_PORTAL_TEMPLATE_CTOR(sc_in<T>)
00052     {
00053         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00054     }
00055 
00056     RC_ON_OPEN()
00057     {
00058         this->notify_event("value_changed_event");
00059     }
00060 };
00061 
00065 RC_PORTAL(sc_in<bool>)
00066 {
00067     RC_PORTAL_CTOR(sc_in<bool>)
00068     {
00069         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00070         RC_PORTAL_FORWARD_EVENT(posedge_event);
00071         RC_PORTAL_FORWARD_EVENT(negedge_event);
00072     }
00073 
00074     RC_ON_OPEN()
00075     {
00076         this->refresh_notify();
00077     }
00078 
00079     RC_ON_REFRESH_NOTIFY()
00080     {
00081         this->notify_event("value_changed_event");
00082         if (this->get_static_port().read() == true) {
00083             this->notify_event("posedge_event");
00084         } else {
00085             this->notify_event("negedge_event");
00086         }
00087     }
00088 };
00089 
00093 RC_PORTAL(sc_in<sc_logic>)
00094 {
00095     RC_PORTAL_CTOR(sc_in<sc_logic>)
00096     {
00097         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00098         RC_PORTAL_FORWARD_EVENT(posedge_event);
00099         RC_PORTAL_FORWARD_EVENT(negedge_event);
00100     }
00101 
00102     RC_ON_OPEN()
00103     {
00104         this->refresh_notify();
00105     }
00106 
00107     RC_ON_REFRESH_NOTIFY()
00108     {
00109         const sc_logic value = this->get_static_port().read();
00110         this->notify_event("value_changed_event");
00111         if (value == SC_LOGIC_1) {
00112             this->notify_event("posedge_event");
00113         } else if (value == SC_LOGIC_0) {
00114             this->notify_event("negedge_event");
00115         }
00116     }
00117 };
00118 
00122 template<class T>
00123 RC_PORTAL_TEMPLATE(sc_inout<T>)
00124 {
00125     typedef rc_portal<sc_inout<T> > this_type;
00126 
00127     RC_PORTAL_TEMPLATE_CTOR(sc_inout<T>),
00128         p_is_register(false)
00129     {
00130         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00131     }
00132 
00133     RC_ON_OPEN()
00134     {
00135         this->refresh_notify();
00136     }
00137 
00138     RC_ON_CLOSE()
00139     {
00140         if (!p_is_register) {
00141             // write undefined value to the static channel
00142             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00143             ifw.get_nb_driver_access(0)->call(
00144                 &if_type::write, rc_undefined_value<T>());
00145         }
00146     }
00147 
00148     RC_ON_UNDEF()
00149     {
00150         this_type::rc_on_close();
00151     }
00152 
00153     RC_ON_REFRESH_NOTIFY()
00154     {
00155         this->notify_event("value_changed_event");
00156     }
00157 
00158     inline void set_register()
00159         { if (!sc_is_running()) p_is_register = true; }
00160     inline bool is_register() const
00161         { return p_is_register; }
00162 
00163 private:
00164     bool p_is_register;
00165 };
00166 
00170 RC_PORTAL(sc_inout<bool>)
00171 {
00172     typedef rc_portal<sc_inout<bool> > this_type;
00173 
00174     RC_PORTAL_CTOR(sc_inout<bool>),
00175         p_is_register(false)
00176     {
00177         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00178         RC_PORTAL_FORWARD_EVENT(posedge_event);
00179         RC_PORTAL_FORWARD_EVENT(negedge_event);
00180     }
00181 
00182     RC_ON_OPEN()
00183     {
00184         this->refresh_notify();
00185     }
00186 
00187     RC_ON_CLOSE()
00188     {
00189         if (!p_is_register) {
00190             // write undefined value to the static channel
00191             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00192             ifw.get_nb_driver_access(0)->call(
00193                 &if_type::write, rc_undefined_value<bool>());
00194         }
00195     }
00196 
00197     RC_ON_UNDEF()
00198     {
00199         this_type::rc_on_close();
00200     }
00201 
00202     RC_ON_REFRESH_NOTIFY()
00203     {
00204         this->notify_event("value_changed_event");
00205         if (this->get_static_port().read() == true) {
00206             this->notify_event("posedge_event");
00207         } else {
00208             this->notify_event("negedge_event");
00209         }
00210     }
00211 
00212     inline void set_register()
00213         { if (!sc_is_running()) p_is_register = true; }
00214 
00215     inline bool is_register() const
00216         { return p_is_register; }
00217 
00218 private:
00219     bool p_is_register;
00220 };
00221 
00225 RC_PORTAL(sc_inout<sc_logic>)
00226 {
00227     RC_PORTAL_CTOR(sc_inout<sc_logic>),
00228         p_is_register(false)
00229     {
00230         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00231         RC_PORTAL_FORWARD_EVENT(posedge_event);
00232         RC_PORTAL_FORWARD_EVENT(negedge_event);
00233     }
00234 
00235     RC_ON_OPEN()
00236     {
00237         this->refresh_notify();
00238     }
00239 
00240     RC_ON_CLOSE()
00241     {
00242         if (!p_is_register) {
00243             // write 'Z' to the static channel
00244             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00245             ifw.get_nb_driver_access(0)->call(&if_type::write, SC_LOGIC_Z);
00246         }
00247     }
00248 
00249     RC_ON_UNDEF()
00250     {
00251         if (!p_is_register) {
00252             // write 'X' to the static channel
00253             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00254             ifw.get_nb_driver_access(0)->call(&if_type::write, SC_LOGIC_X);
00255         }
00256     }
00257 
00258     RC_ON_REFRESH_NOTIFY()
00259     {
00260         const sc_logic value = this->get_static_port().read();
00261         this->notify_event("value_changed_event");
00262         if (value == SC_LOGIC_1) {
00263             this->notify_event("posedge_event");
00264         } else if (value == SC_LOGIC_0) {
00265             this->notify_event("negedge_event");
00266         }
00267     }
00268 
00269     inline void set_register()
00270         { if (!sc_is_running()) p_is_register = true; }
00271 
00272     inline bool is_register() const
00273         { return p_is_register; }
00274 
00275 private:
00276     bool p_is_register;
00277 };
00278 
00282 template<int W>
00283 RC_PORTAL_TEMPLATE(sc_inout<sc_lv<W> >)
00284 {
00285     RC_PORTAL_TEMPLATE_CTOR(sc_inout<sc_lv<W> >),
00286         p_is_register(false)
00287     {
00288         RC_PORTAL_FORWARD_EVENT(value_changed_event);
00289     }
00290 
00291     RC_ON_OPEN()
00292     {
00293         this->refresh_notify();
00294     }
00295 
00296     RC_ON_CLOSE()
00297     {
00298         if (!p_is_register) {
00299             // write 'Z..Z' to the static channel
00300             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00301             ifw.get_nb_driver_access(0)->call(&if_type::write, s_ZZZ);
00302         }
00303     }
00304 
00305     RC_ON_UNDEF()
00306     {
00307         if (!p_is_register) {
00308             // write 'X..X' to the static channel
00309             rc_interface_wrapper<if_type>& ifw = this->get_interface_wrapper();
00310             ifw.get_nb_driver_access(0)->call(&if_type::write, s_XXX);
00311         }
00312     }
00313 
00314     RC_ON_REFRESH_NOTIFY()
00315     {
00316         this->notify_event("value_changed_event");
00317     }
00318 
00319     inline void set_register()
00320         { if (!sc_is_running()) { p_is_register = true; } }
00321 
00322     inline bool is_register() const
00323         { return p_is_register; }
00324 
00325 private:
00326     bool p_is_register;
00327 
00328 private:
00329     static const sc_dt::sc_lv<W> s_ZZZ;
00330     static const sc_dt::sc_lv<W> s_XXX;
00331 };
00332 
00333 template<int W>
00334 const typename sc_dt::sc_lv<W>
00335 rc_portal<sc_inout<sc_lv<W> > >::s_ZZZ = sc_lv<W>('Z');
00336 
00337 template<int W>
00338 const typename sc_dt::sc_lv<W>
00339 rc_portal<sc_inout<sc_lv<W> > >::s_XXX = sc_lv<W>('X');
00340 
00344 template<class T>
00345 class rc_portal<sc_out<T> >
00346     : public rc_portal<sc_inout<T> >
00347 {
00348     typedef rc_portal<sc_inout<T> > base_type;
00349 public:
00350     typedef typename base_type::port_type     port_type;
00351     typedef typename base_type::if_type       if_type;
00352     typedef typename base_type::accessor_type accessor_type;
00353 
00354     rc_portal<sc_out<T> >(
00355         const sc_module_name& module_name =
00356             sc_gen_unique_name("rc_portal"))
00357         : base_type(module_name)
00358     { }
00359 };
00360 
00361 /* named portal specializations */
00362 
00366 template<class T>
00367 class rc_in_portal
00368     : public rc_portal<sc_in<T> >
00369 {
00370     typedef rc_portal<sc_in<T> > base_type;
00371 public:
00372     typedef typename base_type::port_type     port_type;
00373     typedef typename base_type::if_type       if_type;
00374     typedef typename base_type::accessor_type accessor_type;
00375 
00376     explicit rc_in_portal(
00377         const sc_module_name& name_ =
00378             sc_gen_unique_name("rc_in_portal"))
00379         : base_type(name_)
00380     { }
00381 };
00382 
00386 template<class T>
00387 class rc_inout_portal
00388     : public rc_portal<sc_inout<T> >
00389 {
00390     typedef rc_portal<sc_inout<T> > base_type;
00391 public:
00392     typedef typename base_type::port_type     port_type;
00393     typedef typename base_type::if_type       if_type;
00394     typedef typename base_type::accessor_type accessor_type;
00395 
00396     explicit rc_inout_portal(
00397         const sc_module_name& name_ =
00398             sc_gen_unique_name("rc_inout_portal"))
00399         : base_type(name_)
00400     { }
00401 };
00402 
00406 template<class T>
00407 class rc_out_portal
00408     : public rc_portal<sc_out<T> >
00409 {
00410     typedef rc_portal<sc_out<T> > base_type;
00411 public:
00412     typedef typename base_type::port_type     port_type;
00413     typedef typename base_type::if_type       if_type;
00414     typedef typename base_type::accessor_type accessor_type;
00415 
00416     explicit rc_out_portal(
00417         const sc_module_name& name_ =
00418             sc_gen_unique_name("rc_out_portal"))
00419         : base_type(name_)
00420     { }
00421 };
00422 
00423 } // namespace ReChannel
00424 
00425 #endif // RC_SIGNAL_PORTALS_H_
00426 //
00427 // $Id: rc_signal_portals.h,v 1.13 2007/11/23 13:25:45 felke Exp $
00428 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/portals/rc_signal_portals.h,v $
00429 //

Generated on Tue Jan 1 23:14:06 2008 for ReChannel by  doxygen 1.5.3