17 #ifndef _TLM_SCC_INITIATOR_MIXIN_H__
18 #define _TLM_SCC_INITIATOR_MIXIN_H__
20 #include "scc/utilities.h"
38 template <
typename BASE_TYPE,
typename TYPES = tlm::tlm_base_protocol_types>
class initiator_mixin :
public BASE_TYPE {
40 using transaction_type =
typename TYPES::tlm_payload_type;
41 using phase_type =
typename TYPES::tlm_phase_type;
42 using sync_enum_type = tlm::tlm_sync_enum;
43 using fw_interface_type = tlm::tlm_fw_transport_if<TYPES>;
44 using bw_interface_type = tlm::tlm_bw_transport_if<TYPES>;
51 :
initiator_mixin(sc_core::sc_gen_unique_name(
"initiator_mixin_socket")) {}
59 , bw_if(this->name()) {
60 this->m_export.bind(bw_if);
68 bw_if.set_transport_function(cb);
76 bw_if.set_invalidate_direct_mem_function(cb);
80 class bw_transport_if :
public tlm::tlm_bw_transport_if<TYPES> {
82 using transport_fct = std::function<sync_enum_type(transaction_type&, phase_type&, sc_core::sc_time&)>;
83 using invalidate_dmi_fct = std::function<void(sc_dt::uint64, sc_dt::uint64)>;
85 bw_transport_if(
const std::string& name)
88 , m_invalidate_direct_mem_ptr(0) {}
90 void set_transport_function(transport_fct p) {
93 s << m_name <<
": non-blocking callback allready registered";
94 SC_REPORT_WARNING(
"/OSCI_TLM-2/simple_socket", s.str().c_str());
100 void set_invalidate_direct_mem_function(invalidate_dmi_fct p) {
101 if(m_invalidate_direct_mem_ptr) {
103 s << m_name <<
": invalidate DMI callback allready registered";
104 SC_REPORT_WARNING(
"/OSCI_TLM-2/simple_socket", s.str().c_str());
106 m_invalidate_direct_mem_ptr = p;
110 sync_enum_type nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) {
112 return m_transport_ptr(trans, phase, t);
114 s << m_name <<
": no transport callback registered";
115 SC_REPORT_ERROR(
"/OSCI_TLM-2/initiator_mixin", s.str().c_str());
116 return tlm::TLM_ACCEPTED;
119 void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) {
120 if(m_invalidate_direct_mem_ptr)
121 m_invalidate_direct_mem_ptr(start_range, end_range);
125 const std::string m_name;
126 transport_fct m_transport_ptr;
127 invalidate_dmi_fct m_invalidate_direct_mem_ptr;
131 bw_transport_if bw_if;
void register_invalidate_direct_mem_ptr(std::function< void(sc_dt::uint64, sc_dt::uint64)> cb)
initiator_mixin(const sc_core::sc_module_name &name)
void register_nb_transport_bw(std::function< sync_enum_type(transaction_type &, phase_type &, sc_core::sc_time &)> cb)