/* * tlm_rec_target_socket.h * * Created on: 08.11.2015 * Author: eyck */ #ifndef TLM_REC_TARGET_SOCKET_H_ #define TLM_REC_TARGET_SOCKET_H_ #include #include "tlm2_recorder.h" namespace scv4tlm { template class tlm_rec_target_socket: public tlm::tlm_target_socket { static std::string gen_name(const char* first, const char* second){ std::stringstream ss; ss< fw_interface_type; typedef tlm::tlm_bw_transport_if bw_interface_type; typedef sc_core::sc_port port_type; typedef sc_core::sc_export export_type; typedef tlm::tlm_base_initiator_socket_b base_initiator_socket_type; typedef tlm::tlm_base_target_socket_b base_type; tlm_rec_target_socket() : tlm::tlm_target_socket() ,recorder() { } explicit tlm_rec_target_socket(const char* name) : tlm::tlm_target_socket(name) ,recorder(gen_name(name, "rec").c_str()) { } virtual ~tlm_rec_target_socket(){} virtual const char* kind() const { return "tlm_rec_target_socket"; } // // Bind target socket to target socket (hierarchical bind) // - Binds both the export and the port // virtual void bind(base_type& s) { // export (this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs) // port (s.get_base_port())(recorder); // bind the recording interface to the port, recording will use the m_port } // // Bind interface to socket // - Binds the interface to the export // virtual void bind(fw_interface_type& ifs){ export_type* exp = &this->get_base_export(); if( this == exp ) { export_type::bind(recorder); // non-virtual function call recorder.fw_port(ifs); recorder.bw_port(this->get_base_port()); } else { exp->bind( ifs ); } } // // Forward to 'operator->()' of port class // bw_interface_type* operator->() { return &recorder; } scv4tlm::tlm2_recorder& get_recorder(){ return recorder; } protected: scv4tlm::tlm2_recorder recorder; }; } // namespace scv4tlm #endif /* TLM_REC_TARGET_SOCKET_H_ */