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