00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __TLM_INITIATOR_SOCKET_H__
00019 #define __TLM_INITIATOR_SOCKET_H__
00020
00021
00022 #include "tlm_h/tlm_trans/tlm_2_interfaces/tlm_fw_bw_ifs.h"
00023
00024 namespace tlm {
00025
00026
00027 template <unsigned int BUSWIDTH = 32,
00028 typename FW_IF = tlm_fw_transport_if<>,
00029 typename BW_IF = tlm_bw_transport_if<> >
00030 class tlm_base_initiator_socket_b
00031 {
00032 public:
00033 virtual ‾tlm_base_initiator_socket_b() {}
00034
00035 virtual sc_core::sc_port_b<FW_IF> & get_base_port() = 0;
00036 virtual BW_IF & get_base_interface() = 0;
00037 virtual sc_core::sc_export<BW_IF> & get_base_export() = 0;
00038 };
00039
00040
00041 template <unsigned int BUSWIDTH,
00042 typename FW_IF,
00043 typename BW_IF> class tlm_base_target_socket_b;
00044
00045 template <unsigned int BUSWIDTH,
00046 typename FW_IF,
00047 typename BW_IF,
00048 int N
00049 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00050 ,sc_core::sc_port_policy POL
00051 #endif
00052 > class tlm_base_target_socket;
00053
00054 template <unsigned int BUSWIDTH = 32,
00055 typename FW_IF = tlm_fw_transport_if<>,
00056 typename BW_IF = tlm_bw_transport_if<>,
00057 int N = 1
00058 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00059 ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
00060 #endif
00061 >
00062 class tlm_base_initiator_socket : public tlm_base_initiator_socket_b<BUSWIDTH, FW_IF, BW_IF>,
00063 public sc_core::sc_port<FW_IF, N
00064 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00065 , POL
00066 #endif
00067 >
00068
00069 {
00070 public:
00071 typedef FW_IF fw_interface_type;
00072 typedef BW_IF bw_interface_type;
00073 typedef sc_core::sc_port<fw_interface_type, N
00074 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00075 , POL
00076 #endif
00077 > port_type;
00078
00079 typedef sc_core::sc_export<bw_interface_type> export_type;
00080 typedef tlm_base_target_socket<BUSWIDTH,
00081 fw_interface_type,
00082 bw_interface_type,
00083 N
00084 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00085 ,POL
00086 #endif
00087 > target_socket_type;
00088
00089 typedef tlm_base_target_socket_b<BUSWIDTH,
00090 fw_interface_type,
00091 bw_interface_type> base_target_socket_type;
00092 typedef tlm_base_initiator_socket_b<BUSWIDTH,
00093 fw_interface_type,
00094 bw_interface_type> base_type;
00095
00096 template <unsigned int, typename, typename, int
00097 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00098 ,sc_core::sc_port_policy
00099 #endif
00100 >
00101 friend class tlm_base_target_socket;
00102
00103 public:
00104 tlm_base_initiator_socket()
00105 : port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket"))
00106 , m_export(sc_core::sc_gen_unique_name("tlm_initiator_socket_export"))
00107 {
00108 }
00109
00110 explicit tlm_base_initiator_socket(const char* name)
00111 : port_type(name)
00112 , m_export(sc_core::sc_gen_unique_name((std::string(name) + "_export").c_str()))
00113 {
00114 }
00115
00116 unsigned int get_bus_width() const
00117 {
00118 return BUSWIDTH;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128 void bind(base_target_socket_type& s)
00129 {
00130
00131 (get_base_port())(s.get_base_interface());
00132
00133 (s.get_base_port())(get_base_interface());
00134 }
00135
00136 void operator() (base_target_socket_type& s)
00137 {
00138 bind(s);
00139 }
00140
00141
00142
00143
00144
00145 void bind(base_type& s)
00146 {
00147
00148 (get_base_port())(s.get_base_port());
00149
00150 (s.get_base_export())(get_base_export());
00151 }
00152
00153 void operator() (base_type& s)
00154 {
00155 bind(s);
00156 }
00157
00158
00159
00160
00161
00162 void bind(bw_interface_type& ifs)
00163 {
00164 (get_base_export())(ifs);
00165 }
00166
00167 void operator() (bw_interface_type& s)
00168 {
00169 bind(s);
00170 }
00171
00172
00173 virtual sc_core::sc_port_b<FW_IF> & get_base_port() { return *this; }
00174 virtual BW_IF & get_base_interface() { return m_export; }
00175 virtual sc_core::sc_export<BW_IF> & get_base_export() { return m_export; }
00176
00177 protected:
00178 export_type m_export;
00179 };
00180
00181
00182
00183
00184
00185 template <unsigned int BUSWIDTH = 32,
00186 typename TYPES = tlm_base_protocol_types,
00187 int N = 1
00188 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00189 ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
00190 #endif
00191 >
00192 class tlm_initiator_socket :
00193 public tlm_base_initiator_socket <BUSWIDTH,
00194 tlm_fw_transport_if<TYPES>,
00195 tlm_bw_transport_if<TYPES>,
00196 N
00197 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00198 ,POL
00199 #endif
00200 >
00201 {
00202 public:
00203 tlm_initiator_socket() :
00204 tlm_base_initiator_socket<BUSWIDTH,
00205 tlm_fw_transport_if<TYPES>,
00206 tlm_bw_transport_if<TYPES>,
00207 N
00208 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00209 ,POL
00210 #endif
00211 >()
00212 {
00213 }
00214
00215 explicit tlm_initiator_socket(const char* name) :
00216 tlm_base_initiator_socket<BUSWIDTH,
00217 tlm_fw_transport_if<TYPES>,
00218 tlm_bw_transport_if<TYPES>,
00219 N
00220 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00221 ,POL
00222 #endif
00223 >(name)
00224 {
00225 }
00226 };
00227
00228 }
00229
00230 #endif