multi_socket_bases.h revision 13513
113511Sgabeblack@google.com/***************************************************************************** 213511Sgabeblack@google.com 313511Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 413511Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 513511Sgabeblack@google.com with this work for additional information regarding copyright ownership. 613511Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 713511Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 813511Sgabeblack@google.com License. You may obtain a copy of the License at 913511Sgabeblack@google.com 1013511Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1113511Sgabeblack@google.com 1213511Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1313511Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1413511Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1513511Sgabeblack@google.com implied. See the License for the specific language governing 1613511Sgabeblack@google.com permissions and limitations under the License. 1713511Sgabeblack@google.com 1813511Sgabeblack@google.com *****************************************************************************/ 1913511Sgabeblack@google.com 2013513Sgabeblack@google.com#ifndef __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ 2113513Sgabeblack@google.com#define __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ 2213511Sgabeblack@google.com 2313513Sgabeblack@google.com#include <map> 2413511Sgabeblack@google.com#include <tlm> 2513511Sgabeblack@google.com#include "tlm_utils/convenience_socket_bases.h" 2613511Sgabeblack@google.com 2713513Sgabeblack@google.comnamespace tlm_utils 2813513Sgabeblack@google.com{ 2913511Sgabeblack@google.com 3013511Sgabeblack@google.comtemplate <typename signature> 3113513Sgabeblack@google.comstruct fn_container 3213513Sgabeblack@google.com{ 3313513Sgabeblack@google.com signature function; 3413511Sgabeblack@google.com}; 3513511Sgabeblack@google.com 3613511Sgabeblack@google.com#define TLM_DEFINE_FUNCTOR(name) \ 3713511Sgabeblack@google.comtemplate <typename MODULE, typename TRAITS> \ 3813513Sgabeblack@google.cominline TLM_RET_VAL \ 3913513Sgabeblack@google.comstatic_##name(void *mod, void *fn, int index, TLM_FULL_ARG_LIST) \ 4013511Sgabeblack@google.com{ \ 4113513Sgabeblack@google.com typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \ 4213513Sgabeblack@google.com fn_container_type; \ 4313513Sgabeblack@google.com MODULE *tmp_mod = static_cast<MODULE *>(mod); \ 4413513Sgabeblack@google.com fn_container_type *tmp_cb = static_cast<fn_container_type *> (fn); \ 4513513Sgabeblack@google.com return (tmp_mod->*(tmp_cb->function))( \ 4613513Sgabeblack@google.com index, TLM_ARG_LIST_WITHOUT_TYPES); \ 4713513Sgabeblack@google.com} \ 4813513Sgabeblack@google.com \ 4913511Sgabeblack@google.comtemplate <typename MODULE, typename TRAITS> \ 5013513Sgabeblack@google.cominline void \ 5113513Sgabeblack@google.comdelete_fn_container_of_##name(void *fn) \ 5213511Sgabeblack@google.com{ \ 5313513Sgabeblack@google.com typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> \ 5413513Sgabeblack@google.com fn_container_type; \ 5513513Sgabeblack@google.com fn_container_type *tmp_cb = static_cast<fn_container_type *>(fn); \ 5613513Sgabeblack@google.com if (tmp_cb) \ 5713513Sgabeblack@google.com delete tmp_cb; \ 5813511Sgabeblack@google.com} \ 5913513Sgabeblack@google.com \ 6013511Sgabeblack@google.comtemplate <typename TRAITS> \ 6113511Sgabeblack@google.comclass name##_functor{ \ 6213511Sgabeblack@google.compublic: \ 6313513Sgabeblack@google.com typedef typename TRAITS::tlm_payload_type payload_type; \ 6413513Sgabeblack@google.com typedef typename TRAITS::tlm_phase_type phase_type; \ 6513513Sgabeblack@google.com typedef TLM_RET_VAL (*call_fn)(void *,void *, int, TLM_FULL_ARG_LIST); \ 6613513Sgabeblack@google.com typedef void (*del_fn)(void *); \ 6713513Sgabeblack@google.com \ 6813513Sgabeblack@google.com name##_functor() : m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0) {} \ 6913513Sgabeblack@google.com ~name##_functor() \ 7013513Sgabeblack@google.com { \ 7113513Sgabeblack@google.com if (m_del_fn) \ 7213513Sgabeblack@google.com (*m_del_fn)(m_mem_fn); \ 7313513Sgabeblack@google.com } \ 7413513Sgabeblack@google.com \ 7513513Sgabeblack@google.com template <typename MODULE> \ 7613513Sgabeblack@google.com void \ 7713513Sgabeblack@google.com set_function(MODULE *mod, TLM_RET_VAL (MODULE::*cb)( \ 7813513Sgabeblack@google.com int, TLM_FULL_ARG_LIST)) \ 7913513Sgabeblack@google.com { \ 8013513Sgabeblack@google.com typedef fn_container<TLM_RET_VAL (MODULE::*)( \ 8113513Sgabeblack@google.com int, TLM_FULL_ARG_LIST)> fn_container_type; \ 8213513Sgabeblack@google.com m_fn = &static_##name<MODULE,TRAITS>; \ 8313513Sgabeblack@google.com m_del_fn = &delete_fn_container_of_##name<MODULE, TRAITS>; \ 8413513Sgabeblack@google.com m_del_fn(m_mem_fn); \ 8513513Sgabeblack@google.com fn_container_type *tmp =new fn_container_type(); \ 8613513Sgabeblack@google.com tmp->function = cb; \ 8713513Sgabeblack@google.com m_mod = static_cast<void *>(mod); \ 8813513Sgabeblack@google.com m_mem_fn = static_cast<void *>(tmp); \ 8913513Sgabeblack@google.com } \ 9013511Sgabeblack@google.com \ 9113513Sgabeblack@google.com TLM_RET_VAL \ 9213513Sgabeblack@google.com operator ()(int index, TLM_FULL_ARG_LIST) \ 9313513Sgabeblack@google.com { \ 9413513Sgabeblack@google.com return m_fn(m_mod, m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \ 9513513Sgabeblack@google.com } \ 9613513Sgabeblack@google.com \ 9713513Sgabeblack@google.com bool is_valid() { return (m_mod != 0 && m_mem_fn != 0 && m_fn != 0); } \ 9813513Sgabeblack@google.com \ 9913513Sgabeblack@google.com protected: \ 10013513Sgabeblack@google.com call_fn m_fn;\ 10113513Sgabeblack@google.com del_fn m_del_fn; \ 10213513Sgabeblack@google.com void *m_mod; \ 10313513Sgabeblack@google.com void *m_mem_fn; \ 10413513Sgabeblack@google.com private: \ 10513513Sgabeblack@google.com name##_functor &operator = (const name##_functor &); \ 10613511Sgabeblack@google.com} 10713511Sgabeblack@google.com 10813511Sgabeblack@google.com 10913511Sgabeblack@google.com#define TLM_RET_VAL tlm::tlm_sync_enum 11013513Sgabeblack@google.com#define TLM_FULL_ARG_LIST \ 11113513Sgabeblack@google.com typename TRAITS::tlm_payload_type &txn, \ 11213513Sgabeblack@google.com typename TRAITS::tlm_phase_type &ph, sc_core::sc_time &t 11313513Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn, ph, t 11413511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(nb_transport); 11513511Sgabeblack@google.com#undef TLM_RET_VAL 11613511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST 11713511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES 11813511Sgabeblack@google.com 11913511Sgabeblack@google.com#define TLM_RET_VAL void 12013513Sgabeblack@google.com#define TLM_FULL_ARG_LIST \ 12113513Sgabeblack@google.com typename TRAITS::tlm_payload_type &txn, sc_core::sc_time &t 12213513Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn, t 12313511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(b_transport); 12413511Sgabeblack@google.com#undef TLM_RET_VAL 12513511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST 12613511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES 12713511Sgabeblack@google.com 12813511Sgabeblack@google.com#define TLM_RET_VAL unsigned int 12913513Sgabeblack@google.com#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type &txn 13013511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn 13113511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(debug_transport); 13213511Sgabeblack@google.com#undef TLM_RET_VAL 13313511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST 13413511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES 13513511Sgabeblack@google.com 13613511Sgabeblack@google.com#define TLM_RET_VAL bool 13713513Sgabeblack@google.com#define TLM_FULL_ARG_LIST \ 13813513Sgabeblack@google.com typename TRAITS::tlm_payload_type &txn, tlm::tlm_dmi &dmi 13913513Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn, dmi 14013511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(get_dmi_ptr); 14113511Sgabeblack@google.com#undef TLM_RET_VAL 14213511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST 14313511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES 14413511Sgabeblack@google.com 14513511Sgabeblack@google.com#define TLM_RET_VAL void 14613511Sgabeblack@google.com#define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u 14713513Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES l, u 14813511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(invalidate_dmi); 14913511Sgabeblack@google.com#undef TLM_RET_VAL 15013511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST 15113511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES 15213511Sgabeblack@google.com 15313511Sgabeblack@google.com#undef TLM_DEFINE_FUNCTOR 15413511Sgabeblack@google.com 15513511Sgabeblack@google.com/* 15613511Sgabeblack@google.comThis class implements the fw interface. 15713511Sgabeblack@google.comIt allows to register a callback for each of the fw interface methods. 15813511Sgabeblack@google.comThe callbacks simply forward the fw interface call, but add the id (an int) 15913511Sgabeblack@google.comof the callback binder to the signature of the call. 16013511Sgabeblack@google.com*/ 16113511Sgabeblack@google.comtemplate <typename TYPES> 16213513Sgabeblack@google.comclass callback_binder_fw : public tlm::tlm_fw_transport_if<TYPES>, 16313513Sgabeblack@google.com protected convenience_socket_cb_holder 16413511Sgabeblack@google.com{ 16513511Sgabeblack@google.com public: 16613513Sgabeblack@google.com // typedefs according to the used TYPES class. 16713513Sgabeblack@google.com typedef typename TYPES::tlm_payload_type transaction_type; 16813513Sgabeblack@google.com typedef typename TYPES::tlm_phase_type phase_type; 16913513Sgabeblack@google.com typedef tlm::tlm_sync_enum sync_enum_type; 17013513Sgabeblack@google.com 17113513Sgabeblack@google.com // typedefs for the callbacks. 17213513Sgabeblack@google.com typedef nb_transport_functor<TYPES> nb_func_type; 17313513Sgabeblack@google.com typedef b_transport_functor<TYPES> b_func_type; 17413511Sgabeblack@google.com typedef debug_transport_functor<TYPES> debug_func_type; 17513513Sgabeblack@google.com typedef get_dmi_ptr_functor<TYPES> dmi_func_type; 17613511Sgabeblack@google.com 17713513Sgabeblack@google.com callback_binder_fw(multi_socket_base *owner, int id) : 17813513Sgabeblack@google.com convenience_socket_cb_holder(owner), m_id(id), 17913513Sgabeblack@google.com m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0) , m_caller_port(0) 18013511Sgabeblack@google.com {} 18113511Sgabeblack@google.com 18213513Sgabeblack@google.com // The nb_transport method of the fw interface 18313513Sgabeblack@google.com sync_enum_type nb_transport_fw( 18413513Sgabeblack@google.com transaction_type &txn, phase_type &p, sc_core::sc_time &t) 18513513Sgabeblack@google.com { 18613513Sgabeblack@google.com // Check if a callback is registered. 18713513Sgabeblack@google.com if (m_nb_f && m_nb_f->is_valid()) { 18813513Sgabeblack@google.com return (*m_nb_f)(m_id, txn, p, t); // Do the callback. 18913513Sgabeblack@google.com } 19013511Sgabeblack@google.com 19113513Sgabeblack@google.com display_error("Call to nb_transport_fw without a " 19213513Sgabeblack@google.com "registered callback for nb_transport_fw."); 19313513Sgabeblack@google.com return tlm::TLM_COMPLETED; 19413511Sgabeblack@google.com } 19513511Sgabeblack@google.com 19613513Sgabeblack@google.com // The b_transport method of the fw interface. 19713513Sgabeblack@google.com void 19813513Sgabeblack@google.com b_transport(transaction_type &trans, sc_core::sc_time &t) 19913513Sgabeblack@google.com { 20013513Sgabeblack@google.com // Check if a callback is registered. 20113513Sgabeblack@google.com if (m_b_f && m_b_f->is_valid()) { 20213513Sgabeblack@google.com (*m_b_f)(m_id, trans, t); // Do the callback 20313513Sgabeblack@google.com return; 20413513Sgabeblack@google.com } 20513511Sgabeblack@google.com 20613513Sgabeblack@google.com display_error("Call to b_transport without a " 20713513Sgabeblack@google.com "registered callback for b_transport."); 20813511Sgabeblack@google.com } 20913511Sgabeblack@google.com 21013513Sgabeblack@google.com // The DMI method of the fw interface. 21113513Sgabeblack@google.com bool 21213513Sgabeblack@google.com get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data) 21313513Sgabeblack@google.com { 21413513Sgabeblack@google.com // Check if a callback is registered. 21513513Sgabeblack@google.com if (m_dmi_f && m_dmi_f->is_valid()) { 21613513Sgabeblack@google.com // Do the callback. 21713513Sgabeblack@google.com return (*m_dmi_f)(m_id, trans, dmi_data); 21813513Sgabeblack@google.com } 21913513Sgabeblack@google.com 22013513Sgabeblack@google.com dmi_data.allow_none(); 22113513Sgabeblack@google.com dmi_data.set_start_address(0x0); 22213513Sgabeblack@google.com dmi_data.set_end_address((sc_dt::uint64)-1); 22313513Sgabeblack@google.com return false; 22413511Sgabeblack@google.com } 22513511Sgabeblack@google.com 22613513Sgabeblack@google.com // The debug method of the fw interface. 22713513Sgabeblack@google.com unsigned int 22813513Sgabeblack@google.com transport_dbg(transaction_type &trans) 22913513Sgabeblack@google.com { 23013513Sgabeblack@google.com // check if a callback is registered 23113513Sgabeblack@google.com if (m_dbg_f && m_dbg_f->is_valid()) { 23213513Sgabeblack@google.com return (*m_dbg_f)(m_id, trans); // Do the callback. 23313513Sgabeblack@google.com } 23413513Sgabeblack@google.com 23513513Sgabeblack@google.com return 0; 23613511Sgabeblack@google.com } 23713513Sgabeblack@google.com 23813513Sgabeblack@google.com // The SystemC standard callback register_port: 23913513Sgabeblack@google.com // - Called when a port if bound to the interface. 24013513Sgabeblack@google.com // - Allowd to find out who is bound to that callback binder. 24113513Sgabeblack@google.com void 24213513Sgabeblack@google.com register_port(sc_core::sc_port_base &b, const char * /* name */) 24313513Sgabeblack@google.com { 24413513Sgabeblack@google.com m_caller_port = &b; 24513511Sgabeblack@google.com } 24613513Sgabeblack@google.com 24713513Sgabeblack@google.com // Register callbacks for all fw interface methods at once. 24813513Sgabeblack@google.com void 24913513Sgabeblack@google.com set_callbacks(nb_func_type &cb1, b_func_type &cb2, 25013513Sgabeblack@google.com dmi_func_type &cb3, debug_func_type &cb4) 25113513Sgabeblack@google.com { 25213513Sgabeblack@google.com m_nb_f = &cb1; 25313513Sgabeblack@google.com m_b_f = &cb2; 25413513Sgabeblack@google.com m_dmi_f = &cb3; 25513513Sgabeblack@google.com m_dbg_f = &cb4; 25613511Sgabeblack@google.com } 25713513Sgabeblack@google.com 25813513Sgabeblack@google.com // Getter method to get the port that is bound to that callback binder. 25913513Sgabeblack@google.com // NOTE: This will only return a valid value at end of elaboration 26013511Sgabeblack@google.com // (but not before end of elaboration!) 26113513Sgabeblack@google.com sc_core::sc_port_base *get_other_side() { return m_caller_port; } 26213513Sgabeblack@google.com 26313511Sgabeblack@google.com private: 26413513Sgabeblack@google.com // The ID of the callback binder. 26513513Sgabeblack@google.com int m_id; 26613513Sgabeblack@google.com 26713513Sgabeblack@google.com // The callbacks. 26813513Sgabeblack@google.com nb_func_type *m_nb_f; 26913513Sgabeblack@google.com b_func_type *m_b_f; 27013513Sgabeblack@google.com debug_func_type *m_dbg_f; 27113513Sgabeblack@google.com dmi_func_type *m_dmi_f; 27213513Sgabeblack@google.com 27313513Sgabeblack@google.com // The port bound to that callback binder. 27413513Sgabeblack@google.com sc_core::sc_port_base *m_caller_port; 27513511Sgabeblack@google.com}; 27613511Sgabeblack@google.com 27713511Sgabeblack@google.com/* 27813511Sgabeblack@google.comThis class implements the bw interface. 27913511Sgabeblack@google.comIt allows to register a callback for each of the bw interface methods. 28013511Sgabeblack@google.comThe callbacks simply forward the bw interface call, but add the id (an int) 28113511Sgabeblack@google.comof the callback binder to the signature of the call. 28213511Sgabeblack@google.com*/ 28313511Sgabeblack@google.comtemplate <typename TYPES> 28413513Sgabeblack@google.comclass callback_binder_bw : public tlm::tlm_bw_transport_if<TYPES>, 28513513Sgabeblack@google.com protected convenience_socket_cb_holder 28613511Sgabeblack@google.com{ 28713511Sgabeblack@google.com public: 28813513Sgabeblack@google.com // typedefs according to the used TYPES class 28913513Sgabeblack@google.com typedef typename TYPES::tlm_payload_type transaction_type; 29013513Sgabeblack@google.com typedef typename TYPES::tlm_phase_type phase_type; 29113513Sgabeblack@google.com typedef tlm::tlm_sync_enum sync_enum_type; 29213513Sgabeblack@google.com 29313513Sgabeblack@google.com // typedefs for the callbacks 29413513Sgabeblack@google.com typedef nb_transport_functor<TYPES> nb_func_type; 29513511Sgabeblack@google.com typedef invalidate_dmi_functor<TYPES> dmi_func_type; 29613511Sgabeblack@google.com 29713513Sgabeblack@google.com callback_binder_bw(multi_socket_base *owner, int id) : 29813513Sgabeblack@google.com convenience_socket_cb_holder(owner), m_id(id), 29913513Sgabeblack@google.com m_nb_f(0), m_dmi_f(0) 30013513Sgabeblack@google.com {} 30113511Sgabeblack@google.com 30213513Sgabeblack@google.com // The nb_transport method of the bw interface. 30313513Sgabeblack@google.com sync_enum_type 30413513Sgabeblack@google.com nb_transport_bw(transaction_type &txn, phase_type& p, 30513513Sgabeblack@google.com sc_core::sc_time &t) 30613513Sgabeblack@google.com { 30713513Sgabeblack@google.com // Check if a callback is registered. 30813513Sgabeblack@google.com if (m_nb_f && m_nb_f->is_valid()) { 30913513Sgabeblack@google.com return (*m_nb_f)(m_id, txn, p, t); // Do the callback. 31013513Sgabeblack@google.com } 31113511Sgabeblack@google.com 31213513Sgabeblack@google.com display_error("Call to nb_transport_bw without a " 31313513Sgabeblack@google.com "registered callback for nb_transport_bw"); 31413513Sgabeblack@google.com return tlm::TLM_COMPLETED; 31513511Sgabeblack@google.com } 31613511Sgabeblack@google.com 31713513Sgabeblack@google.com // The DMI method of the bw interface. 31813513Sgabeblack@google.com void 31913513Sgabeblack@google.com invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u) 32013513Sgabeblack@google.com { 32113513Sgabeblack@google.com // Check if a callback is registered. 32213513Sgabeblack@google.com if (m_dmi_f && m_dmi_f->is_valid()) { 32313513Sgabeblack@google.com (*m_dmi_f)(m_id,l,u); // Do the callback. 32413513Sgabeblack@google.com } 32513511Sgabeblack@google.com } 32613513Sgabeblack@google.com 32713513Sgabeblack@google.com // Register callbacks for all bw interface methods at once. 32813513Sgabeblack@google.com void 32913513Sgabeblack@google.com set_callbacks(nb_func_type &cb1, dmi_func_type &cb2) 33013513Sgabeblack@google.com { 33113513Sgabeblack@google.com m_nb_f = &cb1; 33213513Sgabeblack@google.com m_dmi_f = &cb2; 33313513Sgabeblack@google.com } 33413513Sgabeblack@google.com 33513511Sgabeblack@google.com private: 33613513Sgabeblack@google.com // The ID of the callback binder. 33713511Sgabeblack@google.com int m_id; 33813513Sgabeblack@google.com // The callbacks. 33913513Sgabeblack@google.com nb_func_type *m_nb_f; 34013513Sgabeblack@google.com dmi_func_type *m_dmi_f; 34113511Sgabeblack@google.com}; 34213511Sgabeblack@google.com 34313511Sgabeblack@google.com/* 34413511Sgabeblack@google.comThis class forms the base for multi initiator sockets, 34513511Sgabeblack@google.comwith fewer template parameters than the multi_init_base. 34613511Sgabeblack@google.comThis class is implementation-defined. 34713511Sgabeblack@google.com*/ 34813513Sgabeblack@google.comtemplate <typename TYPES=tlm::tlm_base_protocol_types> 34913513Sgabeblack@google.comclass multi_init_base_if 35013513Sgabeblack@google.com{ 35113513Sgabeblack@google.com public: 35213513Sgabeblack@google.com // This method shall return a vector of the callback binders of multi 35313513Sgabeblack@google.com // initiator socket. 35413513Sgabeblack@google.com virtual std::vector<callback_binder_bw<TYPES> *> &get_binders()=0; 35513513Sgabeblack@google.com // This method shall return a vector of all target interfaces bound to 35613513Sgabeblack@google.com // this multi init socket. 35713513Sgabeblack@google.com virtual std::vector<tlm::tlm_fw_transport_if<TYPES> *> &get_sockets()=0; 35813513Sgabeblack@google.com protected: 35913513Sgabeblack@google.com virtual ~multi_init_base_if() {} 36013511Sgabeblack@google.com}; 36113511Sgabeblack@google.com 36213511Sgabeblack@google.com/* 36313511Sgabeblack@google.comThis class forms the base for multi initiator sockets. 36413511Sgabeblack@google.comIt enforces a multi initiator socket to implement all functions 36513511Sgabeblack@google.comneeded to do hierarchical bindings. 36613511Sgabeblack@google.com*/ 36713513Sgabeblack@google.comtemplate <unsigned int BUSWIDTH=32, 36813513Sgabeblack@google.com typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0, 36913513Sgabeblack@google.com sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> 37013513Sgabeblack@google.comclass multi_init_base : 37113513Sgabeblack@google.com public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>, 37213513Sgabeblack@google.com public multi_init_base_if<TYPES>, protected multi_socket_base 37313511Sgabeblack@google.com{ 37413513Sgabeblack@google.com public: 37513513Sgabeblack@google.com // typedef for the base type: the standard tlm initiator socket. 37613513Sgabeblack@google.com typedef tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> base_type; 37713511Sgabeblack@google.com 37813513Sgabeblack@google.com // This method shall disable the code that does the callback binding 37913513Sgabeblack@google.com // that registers callbacks to binders. 38013513Sgabeblack@google.com virtual void disable_cb_bind()=0; 38113511Sgabeblack@google.com 38213513Sgabeblack@google.com // This method shall return the multi_init_base to which the 38313513Sgabeblack@google.com // multi_init_base is bound hierarchically. If the base is not bound 38413513Sgabeblack@google.com // hierarchically it shall return a pointer to itself. 38513513Sgabeblack@google.com virtual multi_init_base *get_hierarch_bind() = 0; 38613513Sgabeblack@google.com 38713513Sgabeblack@google.com virtual tlm::tlm_socket_category 38813513Sgabeblack@google.com get_socket_category() const 38913513Sgabeblack@google.com { 39013513Sgabeblack@google.com return tlm::TLM_MULTI_INITIATOR_SOCKET; 39113513Sgabeblack@google.com } 39213513Sgabeblack@google.com 39313513Sgabeblack@google.com virtual ~multi_init_base() {} 39413513Sgabeblack@google.com multi_init_base() : 39513513Sgabeblack@google.com base_type(sc_core::sc_gen_unique_name("multi_init_base")) 39613513Sgabeblack@google.com {} 39713513Sgabeblack@google.com multi_init_base(const char *name) : base_type(name) {} 39813513Sgabeblack@google.com 39913513Sgabeblack@google.com private: 40013513Sgabeblack@google.com const sc_core::sc_object *get_socket() const { return this; } 40113511Sgabeblack@google.com}; 40213511Sgabeblack@google.com 40313511Sgabeblack@google.com/* 40413511Sgabeblack@google.comThis class forms the base for multi target sockets, 40513511Sgabeblack@google.comwith fewer template parameters than the multi_target_base. 40613511Sgabeblack@google.comThis class is implementation-defined. 40713511Sgabeblack@google.com*/ 40813513Sgabeblack@google.comtemplate <typename TYPES=tlm::tlm_base_protocol_types> 40913513Sgabeblack@google.comclass multi_target_base_if 41013513Sgabeblack@google.com{ 41113513Sgabeblack@google.com public: 41213513Sgabeblack@google.com // This method shall return a vector of the callback binders of multi 41313513Sgabeblack@google.com // initiator socket. 41413513Sgabeblack@google.com virtual std::vector<callback_binder_fw<TYPES> *> &get_binders() = 0; 41513513Sgabeblack@google.com 41613513Sgabeblack@google.com // This method shall return a map of all multi initiator sockets that are 41713513Sgabeblack@google.com // bound to this multi target the key of the map is the index at which the 41813513Sgabeblack@google.com // multi initiator i bound, while the value is the interface of the multi 41913513Sgabeblack@google.com // initiator socket that is bound at that index. 42013513Sgabeblack@google.com virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*> & 42113513Sgabeblack@google.com get_multi_binds() = 0; 42213513Sgabeblack@google.com 42313513Sgabeblack@google.com protected: 42413513Sgabeblack@google.com virtual ~multi_target_base_if() {} 42513511Sgabeblack@google.com}; 42613511Sgabeblack@google.com 42713511Sgabeblack@google.com/* 42813511Sgabeblack@google.comThis class forms the base for multi target sockets. 42913511Sgabeblack@google.comIt enforces a multi target socket to implement all functions 43013511Sgabeblack@google.comneeded to do hierarchical bindings. 43113511Sgabeblack@google.com*/ 43213513Sgabeblack@google.comtemplate <unsigned int BUSWIDTH=32, 43313513Sgabeblack@google.com typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0, 43413513Sgabeblack@google.com sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> 43513513Sgabeblack@google.comclass multi_target_base : 43613513Sgabeblack@google.com public tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL>, 43713513Sgabeblack@google.com public multi_target_base_if<TYPES>, protected multi_socket_base 43813511Sgabeblack@google.com{ 43913513Sgabeblack@google.com public: 44013513Sgabeblack@google.com // Typedef for the base type: the standard tlm target socket. 44113513Sgabeblack@google.com typedef tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL > base_type; 44213511Sgabeblack@google.com 44313513Sgabeblack@google.com // This method shall return the multi_init_base to which the 44413513Sgabeblack@google.com // multi_init_base is bound hierarchically. If the base is not bound 44513513Sgabeblack@google.com // hierarchically it shall return a pointer to itself. 44613513Sgabeblack@google.com virtual multi_target_base *get_hierarch_bind() = 0; 44713511Sgabeblack@google.com 44813513Sgabeblack@google.com // This method shall inform the multi target socket that it is bound 44913513Sgabeblack@google.com // hierarchically and to which other multi target socket it is bound 45013513Sgabeblack@google.com // hierarchically. 45113513Sgabeblack@google.com virtual void set_hierarch_bind(multi_target_base*) = 0; 45213511Sgabeblack@google.com 45313513Sgabeblack@google.com virtual tlm::tlm_socket_category 45413513Sgabeblack@google.com get_socket_category() const 45513513Sgabeblack@google.com { 45613513Sgabeblack@google.com return tlm::TLM_MULTI_TARGET_SOCKET; 45713513Sgabeblack@google.com } 45813513Sgabeblack@google.com 45913513Sgabeblack@google.com virtual ~multi_target_base() {} 46013513Sgabeblack@google.com multi_target_base() : 46113513Sgabeblack@google.com base_type(sc_core::sc_gen_unique_name("multi_target_base")) 46213513Sgabeblack@google.com {} 46313513Sgabeblack@google.com multi_target_base(const char *name) : base_type(name) {} 46413513Sgabeblack@google.com 46513513Sgabeblack@google.com private: 46613513Sgabeblack@google.com const sc_core::sc_object *get_socket() const { return this; } 46713511Sgabeblack@google.com}; 46813511Sgabeblack@google.com 46913511Sgabeblack@google.com/* 47013511Sgabeblack@google.comAll multi sockets must additionally derive from this class. 47113513Sgabeblack@google.comIt enforces a multi socket to implement a function 47213511Sgabeblack@google.comneeded to do multi init to multi target bindings. 47313511Sgabeblack@google.com*/ 47413511Sgabeblack@google.comtemplate <typename TYPES> 47513513Sgabeblack@google.comclass multi_to_multi_bind_base 47613513Sgabeblack@google.com{ 47713513Sgabeblack@google.com public: 47813513Sgabeblack@google.com virtual ~multi_to_multi_bind_base() {} 47913513Sgabeblack@google.com virtual tlm::tlm_fw_transport_if<TYPES> * 48013513Sgabeblack@google.com get_last_binder(tlm::tlm_bw_transport_if<TYPES> *) = 0; 48113511Sgabeblack@google.com}; 48213511Sgabeblack@google.com 48313511Sgabeblack@google.com} // namespace tlm_utils 48413513Sgabeblack@google.com 48513513Sgabeblack@google.com#endif /* __SYSTEMC_EXT_TLM_UTILS_MULTI_SOCKET_BASES_H__ */ 486