20#ifndef __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__
21#define __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__
32template <
typename signature>
38#define TLM_DEFINE_FUNCTOR(name) \
39template <typename MODULE, typename TRAITS> \
41static_##name(void *mod, void *fn, int index, TLM_FULL_ARG_LIST) \
43 typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \
45 MODULE *tmp_mod = static_cast<MODULE *>(mod); \
46 fn_container_type *tmp_cb = static_cast<fn_container_type *> (fn); \
47 return (tmp_mod->*(tmp_cb->function))( \
48 index, TLM_ARG_LIST_WITHOUT_TYPES); \
51template <typename MODULE, typename TRAITS> \
53delete_fn_container_of_##name(void *fn) \
55 typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \
57 fn_container_type *tmp_cb = static_cast<fn_container_type *>(fn); \
62template <typename TRAITS> \
63class name##_functor{ \
65 typedef typename TRAITS::tlm_payload_type payload_type; \
66 typedef typename TRAITS::tlm_phase_type phase_type; \
67 typedef TLM_RET_VAL (*call_fn)(void *,void *, int, TLM_FULL_ARG_LIST); \
68 typedef void (*del_fn)(void *); \
70 name##_functor() : m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0) {} \
74 (*m_del_fn)(m_mem_fn); \
77 template <typename MODULE> \
79 set_function(MODULE *mod, TLM_RET_VAL (MODULE::*cb)( \
80 int, TLM_FULL_ARG_LIST)) \
82 typedef fn_container<TLM_RET_VAL (MODULE::*)( \
83 int, TLM_FULL_ARG_LIST)> fn_container_type; \
84 m_fn = &static_##name<MODULE,TRAITS>; \
85 m_del_fn = &delete_fn_container_of_##name<MODULE, TRAITS>; \
87 fn_container_type *tmp =new fn_container_type(); \
89 m_mod = static_cast<void *>(mod); \
90 m_mem_fn = static_cast<void *>(tmp); \
94 operator ()(int index, TLM_FULL_ARG_LIST) \
96 return m_fn(m_mod, m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \
99 bool is_valid() { return (m_mod != 0 && m_mem_fn != 0 && m_fn != 0); } \
107 name##_functor &operator = (const name##_functor &); \
111#define TLM_RET_VAL tlm::tlm_sync_enum
112#define TLM_FULL_ARG_LIST \
113 typename TRAITS::tlm_payload_type &txn, \
114 typename TRAITS::tlm_phase_type &ph, sc_core::sc_time &t
115#define TLM_ARG_LIST_WITHOUT_TYPES txn, ph, t
118#undef TLM_FULL_ARG_LIST
119#undef TLM_ARG_LIST_WITHOUT_TYPES
121#define TLM_RET_VAL void
122#define TLM_FULL_ARG_LIST \
123 typename TRAITS::tlm_payload_type &txn, sc_core::sc_time &t
124#define TLM_ARG_LIST_WITHOUT_TYPES txn, t
127#undef TLM_FULL_ARG_LIST
128#undef TLM_ARG_LIST_WITHOUT_TYPES
130#define TLM_RET_VAL unsigned int
131#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type &txn
132#define TLM_ARG_LIST_WITHOUT_TYPES txn
135#undef TLM_FULL_ARG_LIST
136#undef TLM_ARG_LIST_WITHOUT_TYPES
138#define TLM_RET_VAL bool
139#define TLM_FULL_ARG_LIST \
140 typename TRAITS::tlm_payload_type &txn, tlm::tlm_dmi &dmi
141#define TLM_ARG_LIST_WITHOUT_TYPES txn, dmi
144#undef TLM_FULL_ARG_LIST
145#undef TLM_ARG_LIST_WITHOUT_TYPES
147#define TLM_RET_VAL void
148#define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u
149#define TLM_ARG_LIST_WITHOUT_TYPES l, u
152#undef TLM_FULL_ARG_LIST
153#undef TLM_ARG_LIST_WITHOUT_TYPES
155#undef TLM_DEFINE_FUNCTOR
163template <
typename TYPES>
194 "registered callback for nb_transport_fw.");
204 (*m_b_f)(
m_id, trans, t);
209 "registered callback for b_transport.");
285template <
typename TYPES>
315 "registered callback for nb_transport_bw");
325 (*m_dmi_f)(
m_id,l,u);
350template <
typename TYPES=tlm::tlm_base_protocol_types>
369template <
unsigned int BUSWIDTH=32,
410template <
typename TYPES=tlm::tlm_base_protocol_types>
422 virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*> &
434template <
unsigned int BUSWIDTH=32,
476template <
typename TYPES>
void set_start_address(sc_dt::uint64 addr)
void set_end_address(sc_dt::uint64 addr)
TYPES::tlm_phase_type phase_type
sync_enum_type nb_transport_bw(transaction_type &txn, phase_type &p, sc_core::sc_time &t)
tlm::tlm_sync_enum sync_enum_type
void set_callbacks(nb_func_type &cb1, dmi_func_type &cb2)
callback_binder_bw(multi_socket_base *owner, int id)
invalidate_dmi_functor< TYPES > dmi_func_type
void invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u)
nb_transport_functor< TYPES > nb_func_type
TYPES::tlm_payload_type transaction_type
get_dmi_ptr_functor< TYPES > dmi_func_type
void register_port(sc_core::sc_port_base &b, const char *)
debug_transport_functor< TYPES > debug_func_type
TYPES::tlm_payload_type transaction_type
callback_binder_fw(multi_socket_base *owner, int id)
nb_transport_functor< TYPES > nb_func_type
sc_core::sc_port_base * get_other_side()
debug_func_type * m_dbg_f
void b_transport(transaction_type &trans, sc_core::sc_time &t)
sc_core::sc_port_base * m_caller_port
bool get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data)
b_transport_functor< TYPES > b_func_type
TYPES::tlm_phase_type phase_type
sync_enum_type nb_transport_fw(transaction_type &txn, phase_type &p, sc_core::sc_time &t)
unsigned int transport_dbg(transaction_type &trans)
tlm::tlm_sync_enum sync_enum_type
void set_callbacks(nb_func_type &cb1, b_func_type &cb2, dmi_func_type &cb3, debug_func_type &cb4)
void display_error(const char *msg) const
virtual std::vector< callback_binder_bw< TYPES > * > & get_binders()=0
virtual ~multi_init_base_if()
virtual std::vector< tlm::tlm_fw_transport_if< TYPES > * > & get_sockets()=0
virtual ~multi_init_base()
virtual multi_init_base * get_hierarch_bind()=0
tlm::tlm_initiator_socket< BUSWIDTH, TYPES, N, POL > base_type
const sc_core::sc_object * get_socket() const
virtual void disable_cb_bind()=0
multi_init_base(const char *name)
virtual tlm::tlm_socket_category get_socket_category() const
virtual std::map< unsigned int, tlm::tlm_bw_transport_if< TYPES > * > & get_multi_binds()=0
virtual std::vector< callback_binder_fw< TYPES > * > & get_binders()=0
virtual ~multi_target_base_if()
const sc_core::sc_object * get_socket() const
multi_target_base(const char *name)
virtual multi_target_base * get_hierarch_bind()=0
tlm::tlm_target_socket< BUSWIDTH, TYPES, N, POL > base_type
virtual tlm::tlm_socket_category get_socket_category() const
virtual void set_hierarch_bind(multi_target_base *)=0
virtual ~multi_target_base()
virtual tlm::tlm_fw_transport_if< TYPES > * get_last_binder(tlm::tlm_bw_transport_if< TYPES > *)=0
virtual ~multi_to_multi_bind_base()
@ TLM_MULTI_TARGET_SOCKET
@ TLM_MULTI_INITIATOR_SOCKET
#define TLM_DEFINE_FUNCTOR(name)
const std::string & name()