rc_sc_buffer.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_SC_BUFFER_H_
00038 #define RC_SC_BUFFER_H_
00039 
00040 #include "ReChannel/components/rc_sc_signal.h"
00041 
00042 namespace ReChannel {
00043 
00047 template<class T>
00048 class rc_sc_buffer
00049     : public rc_sc_signal_b<T, sc_buffer<T> >
00050 {
00051 private:
00052     typedef rc_sc_signal_b<T, sc_buffer<T> > base_type;
00053 
00054 public:
00055     explicit rc_sc_buffer(
00056         const sc_module_name& name_=sc_gen_unique_name("buffer"))
00057         : base_type(name_)
00058     { }
00059 
00060     operator const T&() const
00061         { return this->read(); }
00062 
00063     rc_sc_buffer<T>& operator= (const T& value)
00064         { this->write(value); return *this; }
00065 
00066     rc_sc_buffer<T>& operator= (const rc_sc_buffer<T>& buffer_)
00067         { this->write(buffer_); return *this; }
00068 };
00069 
00073 template<>
00074 class rc_sc_buffer<bool>
00075     : public rc_sc_signal_b<bool, internals::reset_buffer>,
00076       virtual public rc_reset_channel_if
00077 {
00078 private:
00079     typedef rc_sc_signal_b<bool, internals::reset_buffer>
00080         base_type;
00081 
00082 public:
00083     explicit rc_sc_buffer(
00084         const sc_module_name& name_=sc_gen_unique_name("buffer"))
00085         : base_type(name_)
00086     { }
00087 
00088 /* interface methods */
00089 
00090     virtual bool posedge() const
00091         { return get_if().posedge(); }
00092 
00093     virtual bool negedge() const
00094         { return get_if().negedge(); }
00095 
00096     virtual const sc_event& posedge_event() const
00097         { return get_exportal_if().posedge_event(); }
00098 
00099     virtual const sc_event& negedge_event() const
00100         { return get_exportal_if().negedge_event(); }
00101 
00102 #if !defined(RC_USE_NON_OSCI_KERNEL)
00103     virtual sc_reset* is_reset() const
00104         { return m_signal.is_reset(); }
00105 #endif // !defined(RC_USE_NON_OSCI_KERNEL)
00106 
00107 protected:
00108     virtual void register_process_control(
00109         rc_process_control& pctrl, bool reset_level) const
00110     {
00111         m_signal.register_process_control(pctrl, reset_level);
00112     }
00113 
00114     virtual void unregister_process_control(
00115         rc_process_control& pctrl) const
00116     {
00117         m_signal.unregister_process_control(pctrl);
00118     }
00119 
00120     virtual bool get_current_level() const
00121         { return m_signal.read(); }
00122 
00123     virtual const sc_signal<bool>* get_underlying_reset_signal() const
00124         { return &m_signal; }
00125 
00126 /* other channel methods */
00127 
00128 public:
00129     operator const bool&() const
00130         { return this->read(); }
00131 
00132     rc_sc_buffer<bool>& operator= (const bool& value)
00133         { this->write(value); return *this; }
00134 
00135     rc_sc_buffer<bool>& operator= (const rc_sc_buffer<bool>& buffer_)
00136         { this->write(buffer_); return *this; }
00137 };
00138 
00142 template<>
00143 class rc_sc_buffer<sc_logic>
00144     : public rc_sc_signal_b<sc_logic, sc_buffer<sc_logic> >
00145 {
00146 private:
00147     typedef rc_sc_signal_b<sc_logic, sc_buffer<sc_logic> > base_type;
00148 
00149 public:
00150     explicit rc_sc_buffer(
00151         const sc_module_name& name_=sc_gen_unique_name("buffer"))
00152         : base_type(name_)
00153     { }
00154 
00155 /* interface methods */
00156 
00157     virtual bool posedge() const
00158         { return get_if().posedge(); }
00159 
00160     virtual bool negedge() const
00161         { return get_if().negedge(); }
00162 
00163     virtual const sc_event& posedge_event() const
00164         { return get_exportal_if().posedge_event(); }
00165 
00166     virtual const sc_event& negedge_event() const
00167         { return get_exportal_if().negedge_event(); }
00168 
00169 /* other channel methods */
00170 
00171     operator const sc_logic&() const
00172         { return this->read(); }
00173 
00174     rc_sc_buffer<sc_logic>& operator= (const sc_logic& value)
00175         { this->write(value); return *this; }
00176 
00177     rc_sc_buffer<sc_logic>& operator= (const rc_sc_buffer<sc_logic>& buffer_)
00178         { this->write(buffer_); return *this; }
00179 };
00180 
00181 } // namespace ReChannel
00182 
00183 #endif // RC_SC_BUFFER_H_
00184 
00185 //
00186 // $Id: rc_sc_buffer.h,v 1.6 2007/11/23 13:25:45 felke Exp $
00187 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/components/rc_sc_buffer.h,v $
00188 //

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