diff options
Diffstat (limited to 'src/systemc/ext/tlm_utils/multi_socket_bases.h')
-rw-r--r-- | src/systemc/ext/tlm_utils/multi_socket_bases.h | 615 |
1 files changed, 330 insertions, 285 deletions
diff --git a/src/systemc/ext/tlm_utils/multi_socket_bases.h b/src/systemc/ext/tlm_utils/multi_socket_bases.h index d937511dc..95ca56adb 100644 --- a/src/systemc/ext/tlm_utils/multi_socket_bases.h +++ b/src/systemc/ext/tlm_utils/multi_socket_bases.h @@ -17,99 +17,116 @@ *****************************************************************************/ -#ifndef TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_ -#define TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_ +#ifndef __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ +#define __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ +#include <map> #include <tlm> #include "tlm_utils/convenience_socket_bases.h" -#include <map> - -namespace tlm_utils { +namespace tlm_utils +{ template <typename signature> -struct fn_container{ - signature function; +struct fn_container +{ + signature function; }; #define TLM_DEFINE_FUNCTOR(name) \ template <typename MODULE, typename TRAITS> \ -inline TLM_RET_VAL static_##name( void* mod \ - , void* fn \ - , int index \ - , TLM_FULL_ARG_LIST) \ +inline TLM_RET_VAL \ +static_##name(void *mod, void *fn, int index, TLM_FULL_ARG_LIST) \ { \ - typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ - MODULE* tmp_mod=static_cast<MODULE*>(mod); \ - fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \ - return (tmp_mod->*(tmp_cb->function))(index, TLM_ARG_LIST_WITHOUT_TYPES); \ -}\ -\ + typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \ + fn_container_type; \ + MODULE *tmp_mod = static_cast<MODULE *>(mod); \ + fn_container_type *tmp_cb = static_cast<fn_container_type *> (fn); \ + return (tmp_mod->*(tmp_cb->function))( \ + index, TLM_ARG_LIST_WITHOUT_TYPES); \ +} \ + \ template <typename MODULE, typename TRAITS> \ -inline void delete_fn_container_of_##name(void* fn) \ +inline void \ +delete_fn_container_of_##name(void *fn) \ { \ - typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ - fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \ - if (tmp_cb) delete tmp_cb;\ + typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \ + fn_container_type; \ + fn_container_type *tmp_cb = static_cast<fn_container_type *>(fn); \ + if (tmp_cb) \ + delete tmp_cb; \ } \ -\ + \ template <typename TRAITS> \ class name##_functor{ \ public: \ - typedef typename TRAITS::tlm_payload_type payload_type; \ - typedef typename TRAITS::tlm_phase_type phase_type; \ - typedef TLM_RET_VAL (*call_fn)(void*,void*, int, TLM_FULL_ARG_LIST); \ - typedef void (*del_fn)(void*); \ -\ - name##_functor(): m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0){} \ - ~name##_functor(){if (m_del_fn) (*m_del_fn)(m_mem_fn);} \ -\ - template <typename MODULE> \ - void set_function(MODULE* mod, TLM_RET_VAL (MODULE::*cb)(int, TLM_FULL_ARG_LIST)){ \ - typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ - m_fn=&static_##name<MODULE,TRAITS>;\ - m_del_fn=&delete_fn_container_of_##name<MODULE,TRAITS>;\ - m_del_fn(m_mem_fn); \ - fn_container_type* tmp= new fn_container_type(); \ - tmp->function=cb; \ - m_mod=static_cast<void*>(mod); \ - m_mem_fn=static_cast<void*>(tmp); \ - } \ + typedef typename TRAITS::tlm_payload_type payload_type; \ + typedef typename TRAITS::tlm_phase_type phase_type; \ + typedef TLM_RET_VAL (*call_fn)(void *,void *, int, TLM_FULL_ARG_LIST); \ + typedef void (*del_fn)(void *); \ + \ + name##_functor() : m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0) {} \ + ~name##_functor() \ + { \ + if (m_del_fn) \ + (*m_del_fn)(m_mem_fn); \ + } \ + \ + template <typename MODULE> \ + void \ + set_function(MODULE *mod, TLM_RET_VAL (MODULE::*cb)( \ + int, TLM_FULL_ARG_LIST)) \ + { \ + typedef fn_container<TLM_RET_VAL (MODULE::*)( \ + int, TLM_FULL_ARG_LIST)> fn_container_type; \ + m_fn = &static_##name<MODULE,TRAITS>; \ + m_del_fn = &delete_fn_container_of_##name<MODULE, TRAITS>; \ + m_del_fn(m_mem_fn); \ + fn_container_type *tmp =new fn_container_type(); \ + tmp->function = cb; \ + m_mod = static_cast<void *>(mod); \ + m_mem_fn = static_cast<void *>(tmp); \ + } \ \ - TLM_RET_VAL operator()(int index, TLM_FULL_ARG_LIST){ \ - return m_fn(m_mod,m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \ - } \ -\ - bool is_valid(){return (m_mod!=0 && m_mem_fn!=0 && m_fn!=0);}\ -\ -protected: \ - call_fn m_fn;\ - del_fn m_del_fn; \ - void* m_mod; \ - void* m_mem_fn; \ -private: \ - name##_functor& operator=(const name##_functor&); \ + TLM_RET_VAL \ + operator ()(int index, TLM_FULL_ARG_LIST) \ + { \ + return m_fn(m_mod, m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \ + } \ + \ + bool is_valid() { return (m_mod != 0 && m_mem_fn != 0 && m_fn != 0); } \ + \ + protected: \ + call_fn m_fn;\ + del_fn m_del_fn; \ + void *m_mod; \ + void *m_mem_fn; \ + private: \ + name##_functor &operator = (const name##_functor &); \ } #define TLM_RET_VAL tlm::tlm_sync_enum -#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, typename TRAITS::tlm_phase_type& ph, sc_core::sc_time& t -#define TLM_ARG_LIST_WITHOUT_TYPES txn,ph,t +#define TLM_FULL_ARG_LIST \ + typename TRAITS::tlm_payload_type &txn, \ + typename TRAITS::tlm_phase_type &ph, sc_core::sc_time &t +#define TLM_ARG_LIST_WITHOUT_TYPES txn, ph, t TLM_DEFINE_FUNCTOR(nb_transport); #undef TLM_RET_VAL #undef TLM_FULL_ARG_LIST #undef TLM_ARG_LIST_WITHOUT_TYPES #define TLM_RET_VAL void -#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, sc_core::sc_time& t -#define TLM_ARG_LIST_WITHOUT_TYPES txn,t +#define TLM_FULL_ARG_LIST \ + typename TRAITS::tlm_payload_type &txn, sc_core::sc_time &t +#define TLM_ARG_LIST_WITHOUT_TYPES txn, t TLM_DEFINE_FUNCTOR(b_transport); #undef TLM_RET_VAL #undef TLM_FULL_ARG_LIST #undef TLM_ARG_LIST_WITHOUT_TYPES #define TLM_RET_VAL unsigned int -#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn +#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type &txn #define TLM_ARG_LIST_WITHOUT_TYPES txn TLM_DEFINE_FUNCTOR(debug_transport); #undef TLM_RET_VAL @@ -117,8 +134,9 @@ TLM_DEFINE_FUNCTOR(debug_transport); #undef TLM_ARG_LIST_WITHOUT_TYPES #define TLM_RET_VAL bool -#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, tlm::tlm_dmi& dmi -#define TLM_ARG_LIST_WITHOUT_TYPES txn,dmi +#define TLM_FULL_ARG_LIST \ + typename TRAITS::tlm_payload_type &txn, tlm::tlm_dmi &dmi +#define TLM_ARG_LIST_WITHOUT_TYPES txn, dmi TLM_DEFINE_FUNCTOR(get_dmi_ptr); #undef TLM_RET_VAL #undef TLM_FULL_ARG_LIST @@ -126,7 +144,7 @@ TLM_DEFINE_FUNCTOR(get_dmi_ptr); #define TLM_RET_VAL void #define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u -#define TLM_ARG_LIST_WITHOUT_TYPES l,u +#define TLM_ARG_LIST_WITHOUT_TYPES l, u TLM_DEFINE_FUNCTOR(invalidate_dmi); #undef TLM_RET_VAL #undef TLM_FULL_ARG_LIST @@ -141,108 +159,119 @@ The callbacks simply forward the fw interface call, but add the id (an int) of the callback binder to the signature of the call. */ template <typename TYPES> -class callback_binder_fw - : public tlm::tlm_fw_transport_if<TYPES> - , protected convenience_socket_cb_holder +class callback_binder_fw : public tlm::tlm_fw_transport_if<TYPES>, + protected convenience_socket_cb_holder { public: - //typedefs according to the used TYPES class - typedef typename TYPES::tlm_payload_type transaction_type; - typedef typename TYPES::tlm_phase_type phase_type; - typedef tlm::tlm_sync_enum sync_enum_type; - - //typedefs for the callbacks - typedef nb_transport_functor<TYPES> nb_func_type; - typedef b_transport_functor<TYPES> b_func_type; + // typedefs according to the used TYPES class. + typedef typename TYPES::tlm_payload_type transaction_type; + typedef typename TYPES::tlm_phase_type phase_type; + typedef tlm::tlm_sync_enum sync_enum_type; + + // typedefs for the callbacks. + typedef nb_transport_functor<TYPES> nb_func_type; + typedef b_transport_functor<TYPES> b_func_type; typedef debug_transport_functor<TYPES> debug_func_type; - typedef get_dmi_ptr_functor<TYPES> dmi_func_type; + typedef get_dmi_ptr_functor<TYPES> dmi_func_type; - //ctor: an ID is needed to create a callback binder - callback_binder_fw(multi_socket_base* owner, int id) - : convenience_socket_cb_holder(owner), m_id(id) - , m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0) - , m_caller_port(0) + callback_binder_fw(multi_socket_base *owner, int id) : + convenience_socket_cb_holder(owner), m_id(id), + m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0) , m_caller_port(0) {} - //the nb_transport method of the fw interface - sync_enum_type nb_transport_fw(transaction_type& txn, - phase_type& p, - sc_core::sc_time& t){ - //check if a callback is registered - if (m_nb_f && m_nb_f->is_valid()) { - return (*m_nb_f)(m_id, txn, p, t); //do the callback - } - - display_error("Call to nb_transport_fw without a registered callback for nb_transport_fw."); - return tlm::TLM_COMPLETED; + // The nb_transport method of the fw interface + sync_enum_type nb_transport_fw( + transaction_type &txn, phase_type &p, sc_core::sc_time &t) + { + // Check if a callback is registered. + if (m_nb_f && m_nb_f->is_valid()) { + return (*m_nb_f)(m_id, txn, p, t); // Do the callback. + } + + display_error("Call to nb_transport_fw without a " + "registered callback for nb_transport_fw."); + return tlm::TLM_COMPLETED; } - //the b_transport method of the fw interface - void b_transport(transaction_type& trans,sc_core::sc_time& t){ - //check if a callback is registered - if (m_b_f && m_b_f->is_valid()) { - (*m_b_f)(m_id, trans,t); //do the callback - return; - } - - display_error("Call to b_transport without a registered callback for b_transport."); + // The b_transport method of the fw interface. + void + b_transport(transaction_type &trans, sc_core::sc_time &t) + { + // Check if a callback is registered. + if (m_b_f && m_b_f->is_valid()) { + (*m_b_f)(m_id, trans, t); // Do the callback + return; + } + + display_error("Call to b_transport without a " + "registered callback for b_transport."); } - - //the DMI method of the fw interface - bool get_direct_mem_ptr(transaction_type& trans, tlm::tlm_dmi& dmi_data){ - //check if a callback is registered - if (m_dmi_f && m_dmi_f->is_valid()) { - return (*m_dmi_f)(m_id, trans,dmi_data); //do the callback - } - - dmi_data.allow_none(); - dmi_data.set_start_address(0x0); - dmi_data.set_end_address((sc_dt::uint64)-1); - return false; + + // The DMI method of the fw interface. + bool + get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data) + { + // Check if a callback is registered. + if (m_dmi_f && m_dmi_f->is_valid()) { + // Do the callback. + return (*m_dmi_f)(m_id, trans, dmi_data); + } + + dmi_data.allow_none(); + dmi_data.set_start_address(0x0); + dmi_data.set_end_address((sc_dt::uint64)-1); + return false; } - - //the debug method of the fw interface - unsigned int transport_dbg(transaction_type& trans){ - //check if a callback is registered - if (m_dbg_f && m_dbg_f->is_valid()) { - return (*m_dbg_f)(m_id, trans); //do the callback - } - - return 0; + + // The debug method of the fw interface. + unsigned int + transport_dbg(transaction_type &trans) + { + // check if a callback is registered + if (m_dbg_f && m_dbg_f->is_valid()) { + return (*m_dbg_f)(m_id, trans); // Do the callback. + } + + return 0; } - - //the SystemC standard callback register_port: - // - called when a port if bound to the interface - // - allowd to find out who is bound to that callback binder - void register_port(sc_core::sc_port_base& b, const char* /*name*/){ - m_caller_port=&b; + + // The SystemC standard callback register_port: + // - Called when a port if bound to the interface. + // - Allowd to find out who is bound to that callback binder. + void + register_port(sc_core::sc_port_base &b, const char * /* name */) + { + m_caller_port = &b; } - - //register callbacks for all fw interface methods at once - void set_callbacks(nb_func_type& cb1, b_func_type& cb2, dmi_func_type& cb3, debug_func_type& cb4){ - m_nb_f=&cb1; - m_b_f=&cb2; - m_dmi_f=&cb3; - m_dbg_f=&cb4; + + // Register callbacks for all fw interface methods at once. + void + set_callbacks(nb_func_type &cb1, b_func_type &cb2, + dmi_func_type &cb3, debug_func_type &cb4) + { + m_nb_f = &cb1; + m_b_f = &cb2; + m_dmi_f = &cb3; + m_dbg_f = &cb4; } - - //getter method to get the port that is bound to that callback binder - // NOTE: this will only return a valid value at end of elaboration + + // Getter method to get the port that is bound to that callback binder. + // NOTE: This will only return a valid value at end of elaboration // (but not before end of elaboration!) - sc_core::sc_port_base* get_other_side(){return m_caller_port;} - + sc_core::sc_port_base *get_other_side() { return m_caller_port; } + private: - //the ID of the callback binder - int m_id; - - //the callbacks - nb_func_type* m_nb_f; - b_func_type* m_b_f; - debug_func_type* m_dbg_f; - dmi_func_type* m_dmi_f; - - //the port bound to that callback binder - sc_core::sc_port_base* m_caller_port; + // The ID of the callback binder. + int m_id; + + // The callbacks. + nb_func_type *m_nb_f; + b_func_type *m_b_f; + debug_func_type *m_dbg_f; + dmi_func_type *m_dmi_f; + + // The port bound to that callback binder. + sc_core::sc_port_base *m_caller_port; }; /* @@ -252,58 +281,63 @@ The callbacks simply forward the bw interface call, but add the id (an int) of the callback binder to the signature of the call. */ template <typename TYPES> -class callback_binder_bw - : public tlm::tlm_bw_transport_if<TYPES> - , protected convenience_socket_cb_holder +class callback_binder_bw : public tlm::tlm_bw_transport_if<TYPES>, + protected convenience_socket_cb_holder { public: - //typedefs according to the used TYPES class - typedef typename TYPES::tlm_payload_type transaction_type; - typedef typename TYPES::tlm_phase_type phase_type; - typedef tlm::tlm_sync_enum sync_enum_type; - - //typedefs for the callbacks - typedef nb_transport_functor<TYPES> nb_func_type; + // typedefs according to the used TYPES class + typedef typename TYPES::tlm_payload_type transaction_type; + typedef typename TYPES::tlm_phase_type phase_type; + typedef tlm::tlm_sync_enum sync_enum_type; + + // typedefs for the callbacks + typedef nb_transport_functor<TYPES> nb_func_type; typedef invalidate_dmi_functor<TYPES> dmi_func_type; - //ctor: an ID is needed to create a callback binder - callback_binder_bw(multi_socket_base* owner, int id) - : convenience_socket_cb_holder(owner), m_id(id) - , m_nb_f(0), m_dmi_f(0) {} - - //the nb_transport method of the bw interface - sync_enum_type nb_transport_bw(transaction_type& txn, - phase_type& p, - sc_core::sc_time& t){ - //check if a callback is registered - if (m_nb_f && m_nb_f->is_valid()) { - return (*m_nb_f)(m_id, txn, p, t); //do the callback - } - - display_error("Call to nb_transport_bw without a registered callback for nb_transport_bw"); - return tlm::TLM_COMPLETED; + callback_binder_bw(multi_socket_base *owner, int id) : + convenience_socket_cb_holder(owner), m_id(id), + m_nb_f(0), m_dmi_f(0) + {} + + // The nb_transport method of the bw interface. + sync_enum_type + nb_transport_bw(transaction_type &txn, phase_type& p, + sc_core::sc_time &t) + { + // Check if a callback is registered. + if (m_nb_f && m_nb_f->is_valid()) { + return (*m_nb_f)(m_id, txn, p, t); // Do the callback. + } + + display_error("Call to nb_transport_bw without a " + "registered callback for nb_transport_bw"); + return tlm::TLM_COMPLETED; } - - //the DMI method of the bw interface - void invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u){ - //check if a callback is registered - if (m_dmi_f && m_dmi_f->is_valid()) { - (*m_dmi_f)(m_id,l,u); //do the callback - } + + // The DMI method of the bw interface. + void + invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u) + { + // Check if a callback is registered. + if (m_dmi_f && m_dmi_f->is_valid()) { + (*m_dmi_f)(m_id,l,u); // Do the callback. + } } - //register callbacks for all bw interface methods at once - void set_callbacks(nb_func_type& cb1, dmi_func_type& cb2){ - m_nb_f=&cb1; - m_dmi_f=&cb2; + // Register callbacks for all bw interface methods at once. + void + set_callbacks(nb_func_type &cb1, dmi_func_type &cb2) + { + m_nb_f = &cb1; + m_dmi_f = &cb2; } - + private: - //the ID of the callback binder + // The ID of the callback binder. int m_id; - //the callbacks - nb_func_type* m_nb_f; - dmi_func_type* m_dmi_f; + // The callbacks. + nb_func_type *m_nb_f; + dmi_func_type *m_dmi_f; }; /* @@ -311,15 +345,18 @@ This class forms the base for multi initiator sockets, with fewer template parameters than the multi_init_base. This class is implementation-defined. */ -template <typename TYPES = tlm::tlm_base_protocol_types> -class multi_init_base_if { -public: - //this method shall return a vector of the callback binders of multi initiator socket - virtual std::vector<callback_binder_bw<TYPES>* >& get_binders()=0; - //this method shall return a vector of all target interfaces bound to this multi init socket - virtual std::vector<tlm::tlm_fw_transport_if<TYPES>*>& get_sockets()=0; -protected: - virtual ~multi_init_base_if() {} +template <typename TYPES=tlm::tlm_base_protocol_types> +class multi_init_base_if +{ + public: + // This method shall return a vector of the callback binders of multi + // initiator socket. + virtual std::vector<callback_binder_bw<TYPES> *> &get_binders()=0; + // This method shall return a vector of all target interfaces bound to + // this multi init socket. + virtual std::vector<tlm::tlm_fw_transport_if<TYPES> *> &get_sockets()=0; + protected: + virtual ~multi_init_base_if() {} }; /* @@ -327,40 +364,40 @@ This class forms the base for multi initiator sockets. It enforces a multi initiator socket to implement all functions needed to do hierarchical bindings. */ -template <unsigned int BUSWIDTH = 32, - typename TYPES = tlm::tlm_base_protocol_types, - unsigned int N=0, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> -class multi_init_base - : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> - , public multi_init_base_if<TYPES> - , protected multi_socket_base +template <unsigned int BUSWIDTH=32, + typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class multi_init_base : + public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>, + public multi_init_base_if<TYPES>, protected multi_socket_base { -public: - //typedef for the base type: the standard tlm initiator socket - typedef tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> base_type; - - //this method shall disable the code that does the callback binding - // that registers callbacks to binders - virtual void disable_cb_bind()=0; - - //this method shall return the multi_init_base to which the - // multi_init_base is bound hierarchically - // If the base is not bound hierarchically it shall return a pointer to itself - virtual multi_init_base* get_hierarch_bind()=0; - - virtual tlm::tlm_socket_category get_socket_category() const - { - return tlm::TLM_MULTI_INITIATOR_SOCKET; - } - - //ctor and dtor - virtual ~multi_init_base(){} - multi_init_base():base_type(sc_core::sc_gen_unique_name("multi_init_base")){} - multi_init_base(const char* name):base_type(name){} - -private: - const sc_core::sc_object* get_socket() const { return this; } + public: + // typedef for the base type: the standard tlm initiator socket. + typedef tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> base_type; + + // This method shall disable the code that does the callback binding + // that registers callbacks to binders. + virtual void disable_cb_bind()=0; + + // This method shall return the multi_init_base to which the + // multi_init_base is bound hierarchically. If the base is not bound + // hierarchically it shall return a pointer to itself. + virtual multi_init_base *get_hierarch_bind() = 0; + + virtual tlm::tlm_socket_category + get_socket_category() const + { + return tlm::TLM_MULTI_INITIATOR_SOCKET; + } + + virtual ~multi_init_base() {} + multi_init_base() : + base_type(sc_core::sc_gen_unique_name("multi_init_base")) + {} + multi_init_base(const char *name) : base_type(name) {} + + private: + const sc_core::sc_object *get_socket() const { return this; } }; /* @@ -368,19 +405,23 @@ This class forms the base for multi target sockets, with fewer template parameters than the multi_target_base. This class is implementation-defined. */ -template <typename TYPES = tlm::tlm_base_protocol_types> -class multi_target_base_if { -public: - //this method shall return a vector of the callback binders of multi initiator socket - virtual std::vector<callback_binder_fw<TYPES>* >& get_binders()=0; - - //this method shall return a map of all multi initiator sockets that are - // bound to this multi target the key of the map is the index at which the - // multi initiator i bound, while the value is the interface of the multi - // initiator socket that is bound at that index - virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& get_multi_binds()=0; -protected: - virtual ~multi_target_base_if() {} +template <typename TYPES=tlm::tlm_base_protocol_types> +class multi_target_base_if +{ + public: + // This method shall return a vector of the callback binders of multi + // initiator socket. + virtual std::vector<callback_binder_fw<TYPES> *> &get_binders() = 0; + + // This method shall return a map of all multi initiator sockets that are + // bound to this multi target the key of the map is the index at which the + // multi initiator i bound, while the value is the interface of the multi + // initiator socket that is bound at that index. + virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*> & + get_multi_binds() = 0; + + protected: + virtual ~multi_target_base_if() {} }; /* @@ -388,53 +429,57 @@ This class forms the base for multi target sockets. It enforces a multi target socket to implement all functions needed to do hierarchical bindings. */ -template <unsigned int BUSWIDTH = 32, - typename TYPES = tlm::tlm_base_protocol_types, - unsigned int N=0, - sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND> -class multi_target_base - : public tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL> - , public multi_target_base_if<TYPES> - , protected multi_socket_base +template <unsigned int BUSWIDTH=32, + typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class multi_target_base : + public tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL>, + public multi_target_base_if<TYPES>, protected multi_socket_base { -public: - //typedef for the base type: the standard tlm target socket - typedef tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL > base_type; - - //this method shall return the multi_init_base to which the - // multi_init_base is bound hierarchically - // If the base is not bound hierarchically it shall return a pointer to itself - virtual multi_target_base* get_hierarch_bind()=0; - - //this method shall inform the multi target socket that it is bound - // hierarchically and to which other multi target socket it is bound hierarchically - virtual void set_hierarch_bind(multi_target_base*)=0; - - virtual tlm::tlm_socket_category get_socket_category() const - { - return tlm::TLM_MULTI_TARGET_SOCKET; - } - - //ctor and dtor - virtual ~multi_target_base(){} - multi_target_base():base_type(sc_core::sc_gen_unique_name("multi_target_base")){} - multi_target_base(const char* name):base_type(name){} - -private: - const sc_core::sc_object* get_socket() const { return this; } + public: + // Typedef for the base type: the standard tlm target socket. + typedef tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL > base_type; + + // This method shall return the multi_init_base to which the + // multi_init_base is bound hierarchically. If the base is not bound + // hierarchically it shall return a pointer to itself. + virtual multi_target_base *get_hierarch_bind() = 0; + + // This method shall inform the multi target socket that it is bound + // hierarchically and to which other multi target socket it is bound + // hierarchically. + virtual void set_hierarch_bind(multi_target_base*) = 0; + + virtual tlm::tlm_socket_category + get_socket_category() const + { + return tlm::TLM_MULTI_TARGET_SOCKET; + } + + virtual ~multi_target_base() {} + multi_target_base() : + base_type(sc_core::sc_gen_unique_name("multi_target_base")) + {} + multi_target_base(const char *name) : base_type(name) {} + + private: + const sc_core::sc_object *get_socket() const { return this; } }; /* All multi sockets must additionally derive from this class. -It enforces a multi socket to implement a function +It enforces a multi socket to implement a function needed to do multi init to multi target bindings. */ template <typename TYPES> -class multi_to_multi_bind_base{ -public: - virtual ~multi_to_multi_bind_base(){} - virtual tlm::tlm_fw_transport_if<TYPES>* get_last_binder(tlm::tlm_bw_transport_if<TYPES>*)=0; +class multi_to_multi_bind_base +{ + public: + virtual ~multi_to_multi_bind_base() {} + virtual tlm::tlm_fw_transport_if<TYPES> * + get_last_binder(tlm::tlm_bw_transport_if<TYPES> *) = 0; }; } // namespace tlm_utils -#endif // TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_ + +#endif /* __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ */ |