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_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_target_socket_b<BUSWIDTH,
00079 fw_interface_type,
00080 bw_interface_type> base_type;
00081
00082 template <unsigned int, typename, typename, int
00083 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00084 ,sc_core::sc_port_policy
00085 #endif
00086
00087 >
00088 friend class tlm_base_initiator_socket;
00089
00090 public:
00091 tlm_base_target_socket()
00092 : export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket"))
00093 , m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port"))
00094 {
00095 }
00096
00097 explicit tlm_base_target_socket(const char* name)
00098 : export_type(name)
00099 , m_port(sc_core::sc_gen_unique_name((std::string(name) + "_port").c_str()))
00100 {
00101 }
00102
00103 virtual const char* kind() const
00104 {
00105 return "tlm_base_target_socket";
00106 }
00107
00108 unsigned int get_bus_width() const
00109 {
00110 return BUSWIDTH;
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120 void bind(base_initiator_socket_type& s)
00121 {
00122
00123 (s.get_base_port())(get_base_interface());
00124
00125 get_base_port()(s.get_base_interface());
00126 }
00127
00128 void operator() (base_initiator_socket_type& s)
00129 {
00130 bind(s);
00131 }
00132
00133
00134
00135
00136
00137 void bind(base_type& s)
00138 {
00139
00140 (get_base_export())(s.get_base_export());
00141
00142 (s.get_base_port())(get_base_port());
00143 }
00144
00145 void operator() (base_type& s)
00146 {
00147 bind(s);
00148 }
00149
00150
00151
00152
00153
00154 void bind(fw_interface_type& ifs)
00155 {
00156 (get_base_export())(ifs);
00157 }
00158
00159 void operator() (fw_interface_type& s)
00160 {
00161 bind(s);
00162 }
00163
00164
00165
00166
00167 int size() const
00168 {
00169 return m_port.size();
00170 }
00171
00172
00173
00174
00175 bw_interface_type* operator->()
00176 {
00177 return m_port.operator->();
00178 }
00179
00180
00181
00182
00183 bw_interface_type* operator[](int i)
00184 {
00185 return m_port.operator[](i);
00186 }
00187
00188
00189 virtual sc_core::sc_port_b<BW_IF> & get_base_port() { return m_port; }
00190 virtual FW_IF & get_base_interface() { return *this; }
00191 virtual sc_core::sc_export<FW_IF> & get_base_export() { return *this; }
00192
00193 protected:
00194 port_type m_port;
00195 };
00196
00197
00198
00199
00200
00201
00202 template <unsigned int BUSWIDTH = 32,
00203 typename TYPES = tlm_base_protocol_types,
00204 int N = 1
00205 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00206 ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
00207 #endif
00208 >
00209 class tlm_target_socket :
00210 public tlm_base_target_socket <BUSWIDTH,
00211 tlm_fw_transport_if<TYPES>,
00212 tlm_bw_transport_if<TYPES>,
00213 N
00214 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00215 ,POL
00216 #endif
00217 >
00218 {
00219 public:
00220 tlm_target_socket() :
00221 tlm_base_target_socket<BUSWIDTH,
00222 tlm_fw_transport_if<TYPES>,
00223 tlm_bw_transport_if<TYPES>,
00224 N
00225 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00226 ,POL
00227 #endif
00228 >()
00229 {
00230 }
00231
00232 explicit tlm_target_socket(const char* name) :
00233 tlm_base_target_socket<BUSWIDTH,
00234 tlm_fw_transport_if<TYPES>,
00235 tlm_bw_transport_if<TYPES>,
00236 N
00237 #if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
00238 ,POL
00239 #endif
00240 >(name)
00241 {
00242 }
00243
00244 virtual const char* kind() const
00245 {
00246 return "tlm_target_socket";
00247 }
00248 };
00249
00250 }
00251
00252 #endif