00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00039 #ifndef RC_FIFO_ACCESSORS_H_
00040 #define RC_FIFO_ACCESSORS_H_
00041
00042 #include "ReChannel/communication/accessors/rc_accessor.h"
00043
00044 namespace ReChannel {
00045
00049 template<class T>
00050 class rc_fallback_interface<sc_fifo_in_if<T> >
00051 : virtual public sc_fifo_in_if<T>
00052 {
00053 public:
00054 rc_fallback_interface()
00055 : p_value(rc_undefined_value<T>())
00056 { }
00057 virtual bool nb_read(T& value)
00058 { value = p_value; return false; }
00059 virtual const sc_event& data_written_event() const
00060 {
00061 SC_REPORT_WARNING(RC_ID_UNDEFINED_EVENT_WARNING_, 0);
00062 return p_undef;
00063 }
00064 virtual void read(T& value)
00065 { ::sc_core::wait(p_undef); }
00066 virtual T read()
00067 {
00068 SC_REPORT_WARNING(RC_ID_UNDEFINED_BLOCKING_ACCESS_WARNING_, 0);
00069 ::sc_core::wait(p_undef); return p_value;
00070 }
00071 virtual int num_available() const
00072 { return 0; }
00073 private:
00074 const T p_value;
00075 sc_event p_undef;
00076 };
00077
00081 template<class T>
00082 class rc_fallback_interface<sc_fifo_out_if<T> >
00083 : virtual public sc_fifo_out_if<T>
00084 {
00085 public:
00086 rc_fallback_interface() { }
00087 virtual bool nb_write(const T& value)
00088 { return false; }
00089 virtual const sc_event& data_read_event() const
00090 {
00091 SC_REPORT_WARNING(RC_ID_UNDEFINED_EVENT_WARNING_, 0);
00092 return p_undef;
00093 }
00094 virtual void write(const T& value)
00095 {
00096 SC_REPORT_WARNING(RC_ID_UNDEFINED_BLOCKING_ACCESS_WARNING_, 0);
00097 ::sc_core::wait(p_undef);
00098 }
00099 virtual int num_free() const
00100 { return 0; }
00101 private:
00102 sc_event p_undef;
00103 };
00104
00108 template<class T>
00109 RC_ACCESSOR_TEMPLATE(sc_fifo_in_if<T>)
00110 {
00111 RC_ACCESSOR_TEMPLATE_CTOR(sc_fifo_in_if<T>) { }
00112
00113 RC_EVENT(data_written_event);
00114
00115 virtual bool nb_read(T& value)
00116 {
00117 return this->rc_nb_forward(&if_type::nb_read, rc_ref(value));
00118 }
00119 virtual void read(T& value)
00120 {
00121
00122 while (this->num_available() <= 0) {
00123 this->wait(this->data_written_event());
00124 }
00125 this->rc_forward(&if_type::read, rc_ref(value));
00126 }
00127 virtual T read()
00128 {
00129
00130 while (this->num_available() <= 0) {
00131 this->wait(this->data_written_event());
00132 }
00133 return this->rc_forward(&if_type::read);
00134 }
00135 virtual int num_available() const
00136 {
00137 return this->rc_nb_forward(&if_type::num_available);
00138 }
00139 };
00140
00144 template<class T>
00145 RC_ACCESSOR_TEMPLATE(sc_fifo_out_if<T>)
00146 {
00147 RC_ACCESSOR_TEMPLATE_CTOR(sc_fifo_out_if<T>) { }
00148
00149 RC_EVENT(data_read_event);
00150
00151 virtual bool nb_write(const T& value)
00152 {
00153 return this->rc_nb_forward(&if_type::nb_write, rc_cref(value));
00154 }
00155 virtual void write(const T& value)
00156 {
00157
00158 while (this->num_free() <= 0) {
00159 this->wait(this->data_read_event());
00160 }
00161 this->rc_forward(&if_type::write, rc_cref(value));
00162 }
00163 virtual int num_free() const
00164 {
00165 return this->rc_nb_forward(&if_type::num_free);
00166 }
00167 };
00168
00169 }
00170
00171 #endif // RC_FIFO_ACCESSORS_H_
00172
00173
00174
00175
00176