112027Sjungma@eit.uni-kl.de/***************************************************************************** 212027Sjungma@eit.uni-kl.de 312027Sjungma@eit.uni-kl.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412027Sjungma@eit.uni-kl.de more contributor license agreements. See the NOTICE file distributed 512027Sjungma@eit.uni-kl.de with this work for additional information regarding copyright ownership. 612027Sjungma@eit.uni-kl.de Accellera licenses this file to you under the Apache License, Version 2.0 712027Sjungma@eit.uni-kl.de (the "License"); you may not use this file except in compliance with the 812027Sjungma@eit.uni-kl.de License. You may obtain a copy of the License at 912027Sjungma@eit.uni-kl.de 1012027Sjungma@eit.uni-kl.de http://www.apache.org/licenses/LICENSE-2.0 1112027Sjungma@eit.uni-kl.de 1212027Sjungma@eit.uni-kl.de Unless required by applicable law or agreed to in writing, software 1312027Sjungma@eit.uni-kl.de distributed under the License is distributed on an "AS IS" BASIS, 1412027Sjungma@eit.uni-kl.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512027Sjungma@eit.uni-kl.de implied. See the License for the specific language governing 1612027Sjungma@eit.uni-kl.de permissions and limitations under the License. 1712027Sjungma@eit.uni-kl.de 1812027Sjungma@eit.uni-kl.de *****************************************************************************/ 1912027Sjungma@eit.uni-kl.de 2012027Sjungma@eit.uni-kl.de#ifndef __MULTI_SOCKET_BASES_H__ 2112027Sjungma@eit.uni-kl.de#define __MULTI_SOCKET_BASES_H__ 2212027Sjungma@eit.uni-kl.de 2312027Sjungma@eit.uni-kl.de#include <systemc> 2412027Sjungma@eit.uni-kl.de#include <tlm> 2512027Sjungma@eit.uni-kl.de 2612027Sjungma@eit.uni-kl.de#include <map> 2712027Sjungma@eit.uni-kl.de#include <sstream> 2812027Sjungma@eit.uni-kl.de 2912027Sjungma@eit.uni-kl.denamespace tlm_utils { 3012027Sjungma@eit.uni-kl.de 3112027Sjungma@eit.uni-kl.detemplate <typename signature> 3212027Sjungma@eit.uni-kl.destruct fn_container{ 3312027Sjungma@eit.uni-kl.de signature function; 3412027Sjungma@eit.uni-kl.de}; 3512027Sjungma@eit.uni-kl.de 3612027Sjungma@eit.uni-kl.de#define TLM_DEFINE_FUNCTOR(name) \ 3712027Sjungma@eit.uni-kl.detemplate <typename MODULE, typename TRAITS> \ 3812027Sjungma@eit.uni-kl.deinline TLM_RET_VAL static_##name( void* mod \ 3912027Sjungma@eit.uni-kl.de , void* fn \ 4012027Sjungma@eit.uni-kl.de , int index \ 4112027Sjungma@eit.uni-kl.de , TLM_FULL_ARG_LIST) \ 4212027Sjungma@eit.uni-kl.de{ \ 4312027Sjungma@eit.uni-kl.de typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ 4412027Sjungma@eit.uni-kl.de MODULE* tmp_mod=static_cast<MODULE*>(mod); \ 4512027Sjungma@eit.uni-kl.de fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \ 4612027Sjungma@eit.uni-kl.de return (tmp_mod->*(tmp_cb->function))(index, TLM_ARG_LIST_WITHOUT_TYPES); \ 4712027Sjungma@eit.uni-kl.de}\ 4812027Sjungma@eit.uni-kl.de\ 4912027Sjungma@eit.uni-kl.detemplate <typename MODULE, typename TRAITS> \ 5012027Sjungma@eit.uni-kl.deinline void delete_fn_container_of_##name(void* fn) \ 5112027Sjungma@eit.uni-kl.de{ \ 5212027Sjungma@eit.uni-kl.de typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ 5312027Sjungma@eit.uni-kl.de fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \ 5412027Sjungma@eit.uni-kl.de if (tmp_cb) delete tmp_cb;\ 5512027Sjungma@eit.uni-kl.de} \ 5612027Sjungma@eit.uni-kl.de\ 5712027Sjungma@eit.uni-kl.detemplate <typename TRAITS> \ 5812027Sjungma@eit.uni-kl.declass name##_functor{ \ 5912027Sjungma@eit.uni-kl.depublic: \ 6012027Sjungma@eit.uni-kl.de typedef typename TRAITS::tlm_payload_type payload_type; \ 6112027Sjungma@eit.uni-kl.de typedef typename TRAITS::tlm_phase_type phase_type; \ 6212027Sjungma@eit.uni-kl.de typedef TLM_RET_VAL (*call_fn)(void*,void*, int, TLM_FULL_ARG_LIST); \ 6312027Sjungma@eit.uni-kl.de typedef void (*del_fn)(void*); \ 6412027Sjungma@eit.uni-kl.de\ 6512027Sjungma@eit.uni-kl.de name##_functor(): m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0){} \ 6612027Sjungma@eit.uni-kl.de ~name##_functor(){if (m_del_fn) (*m_del_fn)(m_mem_fn);} \ 6712027Sjungma@eit.uni-kl.de\ 6812027Sjungma@eit.uni-kl.de template <typename MODULE> \ 6912027Sjungma@eit.uni-kl.de void set_function(MODULE* mod, TLM_RET_VAL (MODULE::*cb)(int, TLM_FULL_ARG_LIST)){ \ 7012027Sjungma@eit.uni-kl.de typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \ 7112027Sjungma@eit.uni-kl.de m_fn=&static_##name<MODULE,TRAITS>;\ 7212027Sjungma@eit.uni-kl.de m_del_fn=&delete_fn_container_of_##name<MODULE,TRAITS>;\ 7312027Sjungma@eit.uni-kl.de m_del_fn(m_mem_fn); \ 7412027Sjungma@eit.uni-kl.de fn_container_type* tmp= new fn_container_type(); \ 7512027Sjungma@eit.uni-kl.de tmp->function=cb; \ 7612027Sjungma@eit.uni-kl.de m_mod=static_cast<void*>(mod); \ 7712027Sjungma@eit.uni-kl.de m_mem_fn=static_cast<void*>(tmp); \ 7812027Sjungma@eit.uni-kl.de } \ 7912027Sjungma@eit.uni-kl.de \ 8012027Sjungma@eit.uni-kl.de TLM_RET_VAL operator()(int index, TLM_FULL_ARG_LIST){ \ 8112027Sjungma@eit.uni-kl.de return m_fn(m_mod,m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \ 8212027Sjungma@eit.uni-kl.de } \ 8312027Sjungma@eit.uni-kl.de\ 8412027Sjungma@eit.uni-kl.de bool empty(){return (m_mod==0 || m_mem_fn==0 || m_fn==0);}\ 8512027Sjungma@eit.uni-kl.de\ 8612027Sjungma@eit.uni-kl.deprotected: \ 8712027Sjungma@eit.uni-kl.de call_fn m_fn;\ 8812027Sjungma@eit.uni-kl.de del_fn m_del_fn; \ 8912027Sjungma@eit.uni-kl.de void* m_mod; \ 9012027Sjungma@eit.uni-kl.de void* m_mem_fn; \ 9112027Sjungma@eit.uni-kl.deprivate: \ 9212027Sjungma@eit.uni-kl.de name##_functor& operator=(const name##_functor&); \ 9312027Sjungma@eit.uni-kl.de} 9412027Sjungma@eit.uni-kl.de 9512027Sjungma@eit.uni-kl.de 9612027Sjungma@eit.uni-kl.de#define TLM_RET_VAL tlm::tlm_sync_enum 9712027Sjungma@eit.uni-kl.de#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, typename TRAITS::tlm_phase_type& ph, sc_core::sc_time& t 9812027Sjungma@eit.uni-kl.de#define TLM_ARG_LIST_WITHOUT_TYPES txn,ph,t 9912027Sjungma@eit.uni-kl.deTLM_DEFINE_FUNCTOR(nb_transport); 10012027Sjungma@eit.uni-kl.de#undef TLM_RET_VAL 10112027Sjungma@eit.uni-kl.de#undef TLM_FULL_ARG_LIST 10212027Sjungma@eit.uni-kl.de#undef TLM_ARG_LIST_WITHOUT_TYPES 10312027Sjungma@eit.uni-kl.de 10412027Sjungma@eit.uni-kl.de#define TLM_RET_VAL void 10512027Sjungma@eit.uni-kl.de#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, sc_core::sc_time& t 10612027Sjungma@eit.uni-kl.de#define TLM_ARG_LIST_WITHOUT_TYPES txn,t 10712027Sjungma@eit.uni-kl.deTLM_DEFINE_FUNCTOR(b_transport); 10812027Sjungma@eit.uni-kl.de#undef TLM_RET_VAL 10912027Sjungma@eit.uni-kl.de#undef TLM_FULL_ARG_LIST 11012027Sjungma@eit.uni-kl.de#undef TLM_ARG_LIST_WITHOUT_TYPES 11112027Sjungma@eit.uni-kl.de 11212027Sjungma@eit.uni-kl.de#define TLM_RET_VAL unsigned int 11312027Sjungma@eit.uni-kl.de#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn 11412027Sjungma@eit.uni-kl.de#define TLM_ARG_LIST_WITHOUT_TYPES txn 11512027Sjungma@eit.uni-kl.deTLM_DEFINE_FUNCTOR(debug_transport); 11612027Sjungma@eit.uni-kl.de#undef TLM_RET_VAL 11712027Sjungma@eit.uni-kl.de#undef TLM_FULL_ARG_LIST 11812027Sjungma@eit.uni-kl.de#undef TLM_ARG_LIST_WITHOUT_TYPES 11912027Sjungma@eit.uni-kl.de 12012027Sjungma@eit.uni-kl.de#define TLM_RET_VAL bool 12112027Sjungma@eit.uni-kl.de#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, tlm::tlm_dmi& dmi 12212027Sjungma@eit.uni-kl.de#define TLM_ARG_LIST_WITHOUT_TYPES txn,dmi 12312027Sjungma@eit.uni-kl.deTLM_DEFINE_FUNCTOR(get_dmi_ptr); 12412027Sjungma@eit.uni-kl.de#undef TLM_RET_VAL 12512027Sjungma@eit.uni-kl.de#undef TLM_FULL_ARG_LIST 12612027Sjungma@eit.uni-kl.de#undef TLM_ARG_LIST_WITHOUT_TYPES 12712027Sjungma@eit.uni-kl.de 12812027Sjungma@eit.uni-kl.de#define TLM_RET_VAL void 12912027Sjungma@eit.uni-kl.de#define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u 13012027Sjungma@eit.uni-kl.de#define TLM_ARG_LIST_WITHOUT_TYPES l,u 13112027Sjungma@eit.uni-kl.deTLM_DEFINE_FUNCTOR(invalidate_dmi); 13212027Sjungma@eit.uni-kl.de#undef TLM_RET_VAL 13312027Sjungma@eit.uni-kl.de#undef TLM_FULL_ARG_LIST 13412027Sjungma@eit.uni-kl.de#undef TLM_ARG_LIST_WITHOUT_TYPES 13512027Sjungma@eit.uni-kl.de 13612027Sjungma@eit.uni-kl.de#undef TLM_DEFINE_FUNCTOR 13712027Sjungma@eit.uni-kl.de 13812027Sjungma@eit.uni-kl.de/* 13912027Sjungma@eit.uni-kl.deThis class implements the fw interface. 14012027Sjungma@eit.uni-kl.deIt allows to register a callback for each of the fw interface methods. 14112027Sjungma@eit.uni-kl.deThe callbacks simply forward the fw interface call, but add the id (an int) 14212027Sjungma@eit.uni-kl.deof the callback binder to the signature of the call. 14312027Sjungma@eit.uni-kl.de*/ 14412027Sjungma@eit.uni-kl.detemplate <typename TYPES> 14512027Sjungma@eit.uni-kl.declass callback_binder_fw: public tlm::tlm_fw_transport_if<TYPES>{ 14612027Sjungma@eit.uni-kl.de public: 14712027Sjungma@eit.uni-kl.de //typedefs according to the used TYPES class 14812027Sjungma@eit.uni-kl.de typedef typename TYPES::tlm_payload_type transaction_type; 14912027Sjungma@eit.uni-kl.de typedef typename TYPES::tlm_phase_type phase_type; 15012027Sjungma@eit.uni-kl.de typedef tlm::tlm_sync_enum sync_enum_type; 15112027Sjungma@eit.uni-kl.de 15212027Sjungma@eit.uni-kl.de //typedefs for the callbacks 15312027Sjungma@eit.uni-kl.de typedef nb_transport_functor<TYPES> nb_func_type; 15412027Sjungma@eit.uni-kl.de typedef b_transport_functor<TYPES> b_func_type; 15512027Sjungma@eit.uni-kl.de typedef debug_transport_functor<TYPES> debug_func_type; 15612027Sjungma@eit.uni-kl.de typedef get_dmi_ptr_functor<TYPES> dmi_func_type; 15712027Sjungma@eit.uni-kl.de 15812027Sjungma@eit.uni-kl.de //ctor: an ID is needed to create a callback binder 15912027Sjungma@eit.uni-kl.de callback_binder_fw(int id): m_id(id), m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0), m_caller_port(0) { 16012027Sjungma@eit.uni-kl.de } 16112027Sjungma@eit.uni-kl.de 16212027Sjungma@eit.uni-kl.de //the nb_transport method of the fw interface 16312027Sjungma@eit.uni-kl.de sync_enum_type nb_transport_fw(transaction_type& txn, 16412027Sjungma@eit.uni-kl.de phase_type& p, 16512027Sjungma@eit.uni-kl.de sc_core::sc_time& t){ 16612027Sjungma@eit.uni-kl.de //check if a callback is registered 16712027Sjungma@eit.uni-kl.de if ((m_nb_f == 0) || (m_nb_f && m_nb_f->empty())) { 16812027Sjungma@eit.uni-kl.de //std::cerr<<"No function registered"<<std::endl; 16912027Sjungma@eit.uni-kl.de SC_REPORT_ERROR("/OSCI_TLM-2/multi_socket","Call to nb_transport_fw without a registered callback for nb_transport_fw."); 17012027Sjungma@eit.uni-kl.de } 17112027Sjungma@eit.uni-kl.de else 17212027Sjungma@eit.uni-kl.de return (*m_nb_f)(m_id, txn, p, t); //do the callback 17312027Sjungma@eit.uni-kl.de return tlm::TLM_ACCEPTED; //unreachable 17412027Sjungma@eit.uni-kl.de } 17512027Sjungma@eit.uni-kl.de 17612027Sjungma@eit.uni-kl.de //the b_transport method of the fw interface 17712027Sjungma@eit.uni-kl.de void b_transport(transaction_type& trans,sc_core::sc_time& t){ 17812027Sjungma@eit.uni-kl.de //check if a callback is registered 17912027Sjungma@eit.uni-kl.de if ((m_b_f == 0) || (m_b_f && m_b_f->empty())) { 18012027Sjungma@eit.uni-kl.de SC_REPORT_ERROR("/OSCI_TLM-2/multi_socket","Call to b_transport without a registered callback for b_transport."); 18112027Sjungma@eit.uni-kl.de } 18212027Sjungma@eit.uni-kl.de else 18312027Sjungma@eit.uni-kl.de (*m_b_f)(m_id, trans,t); //do the callback 18412027Sjungma@eit.uni-kl.de } 18512027Sjungma@eit.uni-kl.de 18612027Sjungma@eit.uni-kl.de //the DMI method of the fw interface 18712027Sjungma@eit.uni-kl.de bool get_direct_mem_ptr(transaction_type& trans, tlm::tlm_dmi& dmi_data){ 18812027Sjungma@eit.uni-kl.de //check if a callback is registered 18912027Sjungma@eit.uni-kl.de if ((m_dmi_f == 0) && (m_dmi_f && m_dmi_f->empty())) { 19012027Sjungma@eit.uni-kl.de dmi_data.allow_none(); 19112027Sjungma@eit.uni-kl.de dmi_data.set_start_address(0x0); 19212027Sjungma@eit.uni-kl.de dmi_data.set_end_address((sc_dt::uint64)-1); 19312027Sjungma@eit.uni-kl.de return false; 19412027Sjungma@eit.uni-kl.de } 19512027Sjungma@eit.uni-kl.de else 19612027Sjungma@eit.uni-kl.de return (*m_dmi_f)(m_id, trans,dmi_data); //do the callback 19712027Sjungma@eit.uni-kl.de } 19812027Sjungma@eit.uni-kl.de 19912027Sjungma@eit.uni-kl.de //the debug method of the fw interface 20012027Sjungma@eit.uni-kl.de unsigned int transport_dbg(transaction_type& trans){ 20112027Sjungma@eit.uni-kl.de //check if a callback is registered 20212027Sjungma@eit.uni-kl.de if ((m_dbg_f == 0) || (m_dbg_f && m_dbg_f->empty())) { 20312027Sjungma@eit.uni-kl.de return 0; 20412027Sjungma@eit.uni-kl.de } 20512027Sjungma@eit.uni-kl.de else 20612027Sjungma@eit.uni-kl.de return (*m_dbg_f)(m_id, trans); //do the callback 20712027Sjungma@eit.uni-kl.de } 20812027Sjungma@eit.uni-kl.de 20912027Sjungma@eit.uni-kl.de //the SystemC standard callback register_port: 21012027Sjungma@eit.uni-kl.de // - called when a port if bound to the interface 21112027Sjungma@eit.uni-kl.de // - allowd to find out who is bound to that callback binder 21212027Sjungma@eit.uni-kl.de void register_port(sc_core::sc_port_base& b, const char* name){ 21312027Sjungma@eit.uni-kl.de m_caller_port=&b; 21412027Sjungma@eit.uni-kl.de } 21512027Sjungma@eit.uni-kl.de 21612027Sjungma@eit.uni-kl.de //register callbacks for all fw interface methods at once 21712027Sjungma@eit.uni-kl.de void set_callbacks(nb_func_type& cb1, b_func_type& cb2, dmi_func_type& cb3, debug_func_type& cb4){ 21812027Sjungma@eit.uni-kl.de m_nb_f=&cb1; 21912027Sjungma@eit.uni-kl.de m_b_f=&cb2; 22012027Sjungma@eit.uni-kl.de m_dmi_f=&cb3; 22112027Sjungma@eit.uni-kl.de m_dbg_f=&cb4; 22212027Sjungma@eit.uni-kl.de } 22312027Sjungma@eit.uni-kl.de 22412027Sjungma@eit.uni-kl.de //getter method to get the port that is bound to that callback binder 22512027Sjungma@eit.uni-kl.de // NOTE: this will only return a valid value at end of elaboration 22612027Sjungma@eit.uni-kl.de // (but not before end of elaboration!) 22712027Sjungma@eit.uni-kl.de sc_core::sc_port_base* get_other_side(){return m_caller_port;} 22812027Sjungma@eit.uni-kl.de 22912027Sjungma@eit.uni-kl.de private: 23012027Sjungma@eit.uni-kl.de //the ID of the callback binder 23112027Sjungma@eit.uni-kl.de int m_id; 23212027Sjungma@eit.uni-kl.de 23312027Sjungma@eit.uni-kl.de //the callbacks 23412027Sjungma@eit.uni-kl.de nb_func_type* m_nb_f; 23512027Sjungma@eit.uni-kl.de b_func_type* m_b_f; 23612027Sjungma@eit.uni-kl.de debug_func_type* m_dbg_f; 23712027Sjungma@eit.uni-kl.de dmi_func_type* m_dmi_f; 23812027Sjungma@eit.uni-kl.de 23912027Sjungma@eit.uni-kl.de //the port bound to that callback binder 24012027Sjungma@eit.uni-kl.de sc_core::sc_port_base* m_caller_port; 24112027Sjungma@eit.uni-kl.de}; 24212027Sjungma@eit.uni-kl.de 24312027Sjungma@eit.uni-kl.de/* 24412027Sjungma@eit.uni-kl.deThis class implements the bw interface. 24512027Sjungma@eit.uni-kl.deIt allows to register a callback for each of the bw interface methods. 24612027Sjungma@eit.uni-kl.deThe callbacks simply forward the bw interface call, but add the id (an int) 24712027Sjungma@eit.uni-kl.deof the callback binder to the signature of the call. 24812027Sjungma@eit.uni-kl.de*/ 24912027Sjungma@eit.uni-kl.detemplate <typename TYPES> 25012027Sjungma@eit.uni-kl.declass callback_binder_bw: public tlm::tlm_bw_transport_if<TYPES>{ 25112027Sjungma@eit.uni-kl.de public: 25212027Sjungma@eit.uni-kl.de //typedefs according to the used TYPES class 25312027Sjungma@eit.uni-kl.de typedef typename TYPES::tlm_payload_type transaction_type; 25412027Sjungma@eit.uni-kl.de typedef typename TYPES::tlm_phase_type phase_type; 25512027Sjungma@eit.uni-kl.de typedef tlm::tlm_sync_enum sync_enum_type; 25612027Sjungma@eit.uni-kl.de 25712027Sjungma@eit.uni-kl.de //typedefs for the callbacks 25812027Sjungma@eit.uni-kl.de typedef nb_transport_functor<TYPES> nb_func_type; 25912027Sjungma@eit.uni-kl.de typedef invalidate_dmi_functor<TYPES> dmi_func_type; 26012027Sjungma@eit.uni-kl.de 26112027Sjungma@eit.uni-kl.de //ctor: an ID is needed to create a callback binder 26212027Sjungma@eit.uni-kl.de callback_binder_bw(int id): m_id(id), m_nb_f(0), m_dmi_f(0) { 26312027Sjungma@eit.uni-kl.de } 26412027Sjungma@eit.uni-kl.de 26512027Sjungma@eit.uni-kl.de //the nb_transport method of the bw interface 26612027Sjungma@eit.uni-kl.de sync_enum_type nb_transport_bw(transaction_type& txn, 26712027Sjungma@eit.uni-kl.de phase_type& p, 26812027Sjungma@eit.uni-kl.de sc_core::sc_time& t){ 26912027Sjungma@eit.uni-kl.de //check if a callback is registered 27012027Sjungma@eit.uni-kl.de if ((m_nb_f == 0) || (m_nb_f && m_nb_f->empty())) { 27112027Sjungma@eit.uni-kl.de SC_REPORT_ERROR("/OSCI_TLM-2/multi_socket","Call to nb_transport_bw without a registered callback for nb_transport_bw"); 27212027Sjungma@eit.uni-kl.de } 27312027Sjungma@eit.uni-kl.de else 27412027Sjungma@eit.uni-kl.de return (*m_nb_f)(m_id, txn, p, t); //do the callback 27512027Sjungma@eit.uni-kl.de return tlm::TLM_ACCEPTED; //unreachable 27612027Sjungma@eit.uni-kl.de } 27712027Sjungma@eit.uni-kl.de 27812027Sjungma@eit.uni-kl.de //the DMI method of the bw interface 27912027Sjungma@eit.uni-kl.de void invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u){ 28012027Sjungma@eit.uni-kl.de //check if a callback is registered 28112027Sjungma@eit.uni-kl.de if ((m_dmi_f == 0) || (m_dmi_f && m_dmi_f->empty())) { 28212027Sjungma@eit.uni-kl.de return; 28312027Sjungma@eit.uni-kl.de } 28412027Sjungma@eit.uni-kl.de else 28512027Sjungma@eit.uni-kl.de (*m_dmi_f)(m_id,l,u); //do the callback 28612027Sjungma@eit.uni-kl.de } 28712027Sjungma@eit.uni-kl.de 28812027Sjungma@eit.uni-kl.de //register callbacks for all bw interface methods at once 28912027Sjungma@eit.uni-kl.de void set_callbacks(nb_func_type& cb1, dmi_func_type& cb2){ 29012027Sjungma@eit.uni-kl.de m_nb_f=&cb1; 29112027Sjungma@eit.uni-kl.de m_dmi_f=&cb2; 29212027Sjungma@eit.uni-kl.de } 29312027Sjungma@eit.uni-kl.de 29412027Sjungma@eit.uni-kl.de private: 29512027Sjungma@eit.uni-kl.de //the ID of the callback binder 29612027Sjungma@eit.uni-kl.de int m_id; 29712027Sjungma@eit.uni-kl.de //the callbacks 29812027Sjungma@eit.uni-kl.de nb_func_type* m_nb_f; 29912027Sjungma@eit.uni-kl.de dmi_func_type* m_dmi_f; 30012027Sjungma@eit.uni-kl.de}; 30112027Sjungma@eit.uni-kl.de 30212027Sjungma@eit.uni-kl.de 30312027Sjungma@eit.uni-kl.de/* 30412027Sjungma@eit.uni-kl.deThis class forms the base for multi initiator sockets. 30512027Sjungma@eit.uni-kl.deIt enforces a multi initiator socket to implement all functions 30612027Sjungma@eit.uni-kl.deneeded to do hierarchical bindings. 30712027Sjungma@eit.uni-kl.de*/ 30812027Sjungma@eit.uni-kl.detemplate <unsigned int BUSWIDTH = 32, 30912027Sjungma@eit.uni-kl.de typename TYPES = tlm::tlm_base_protocol_types, 31012027Sjungma@eit.uni-kl.de unsigned int N=0 31112027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 31212027Sjungma@eit.uni-kl.de ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND 31312027Sjungma@eit.uni-kl.de#endif 31412027Sjungma@eit.uni-kl.de > 31512027Sjungma@eit.uni-kl.declass multi_init_base: public tlm::tlm_initiator_socket<BUSWIDTH, 31612027Sjungma@eit.uni-kl.de TYPES, 31712027Sjungma@eit.uni-kl.de N 31812027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 31912027Sjungma@eit.uni-kl.de ,POL 32012027Sjungma@eit.uni-kl.de#endif 32112027Sjungma@eit.uni-kl.de >{ 32212027Sjungma@eit.uni-kl.depublic: 32312027Sjungma@eit.uni-kl.de //typedef for the base type: the standard tlm initiator socket 32412027Sjungma@eit.uni-kl.de typedef tlm::tlm_initiator_socket<BUSWIDTH, 32512027Sjungma@eit.uni-kl.de TYPES, 32612027Sjungma@eit.uni-kl.de N 32712027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 32812027Sjungma@eit.uni-kl.de ,POL 32912027Sjungma@eit.uni-kl.de#endif 33012027Sjungma@eit.uni-kl.de > base_type; 33112027Sjungma@eit.uni-kl.de 33212027Sjungma@eit.uni-kl.de //this method shall disable the code that does the callback binding 33312027Sjungma@eit.uni-kl.de // that registers callbacks to binders 33412027Sjungma@eit.uni-kl.de virtual void disable_cb_bind()=0; 33512027Sjungma@eit.uni-kl.de 33612027Sjungma@eit.uni-kl.de //this method shall return the multi_init_base to which the 33712027Sjungma@eit.uni-kl.de // multi_init_base is bound hierarchically 33812027Sjungma@eit.uni-kl.de // If the base is not bound hierarchically it shall return a pointer to itself 33912027Sjungma@eit.uni-kl.de virtual multi_init_base* get_hierarch_bind()=0; 34012027Sjungma@eit.uni-kl.de 34112027Sjungma@eit.uni-kl.de //this method shall return a vector of the callback binders of multi initiator socket 34212027Sjungma@eit.uni-kl.de virtual std::vector<callback_binder_bw<TYPES>* >& get_binders()=0; 34312027Sjungma@eit.uni-kl.de 34412027Sjungma@eit.uni-kl.de //this method shall return a vector of all target interfaces bound to this multi init socket 34512027Sjungma@eit.uni-kl.de virtual std::vector<tlm::tlm_fw_transport_if<TYPES>*>& get_sockets()=0; 34612027Sjungma@eit.uni-kl.de 34712027Sjungma@eit.uni-kl.de //ctor and dtor 34812027Sjungma@eit.uni-kl.de virtual ~multi_init_base(){} 34912027Sjungma@eit.uni-kl.de multi_init_base():base_type(sc_core::sc_gen_unique_name("multi_init_base")){} 35012027Sjungma@eit.uni-kl.de multi_init_base(const char* name):base_type(name){} 35112027Sjungma@eit.uni-kl.de}; 35212027Sjungma@eit.uni-kl.de 35312027Sjungma@eit.uni-kl.de/* 35412027Sjungma@eit.uni-kl.deThis class forms the base for multi target sockets. 35512027Sjungma@eit.uni-kl.deIt enforces a multi target socket to implement all functions 35612027Sjungma@eit.uni-kl.deneeded to do hierarchical bindings. 35712027Sjungma@eit.uni-kl.de*/ 35812027Sjungma@eit.uni-kl.detemplate <unsigned int BUSWIDTH = 32, 35912027Sjungma@eit.uni-kl.de typename TYPES = tlm::tlm_base_protocol_types, 36012027Sjungma@eit.uni-kl.de unsigned int N=0 36112027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 36212027Sjungma@eit.uni-kl.de ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND 36312027Sjungma@eit.uni-kl.de#endif 36412027Sjungma@eit.uni-kl.de > 36512027Sjungma@eit.uni-kl.declass multi_target_base: public tlm::tlm_target_socket<BUSWIDTH, 36612027Sjungma@eit.uni-kl.de TYPES, 36712027Sjungma@eit.uni-kl.de N 36812027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 36912027Sjungma@eit.uni-kl.de ,POL 37012027Sjungma@eit.uni-kl.de#endif 37112027Sjungma@eit.uni-kl.de >{ 37212027Sjungma@eit.uni-kl.depublic: 37312027Sjungma@eit.uni-kl.de //typedef for the base type: the standard tlm target socket 37412027Sjungma@eit.uni-kl.de typedef tlm::tlm_target_socket<BUSWIDTH, 37512027Sjungma@eit.uni-kl.de TYPES, 37612027Sjungma@eit.uni-kl.de N 37712027Sjungma@eit.uni-kl.de#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714) 37812027Sjungma@eit.uni-kl.de ,POL 37912027Sjungma@eit.uni-kl.de#endif 38012027Sjungma@eit.uni-kl.de > base_type; 38112027Sjungma@eit.uni-kl.de 38212027Sjungma@eit.uni-kl.de //this method shall return the multi_init_base to which the 38312027Sjungma@eit.uni-kl.de // multi_init_base is bound hierarchically 38412027Sjungma@eit.uni-kl.de // If the base is not bound hierarchically it shall return a pointer to itself 38512027Sjungma@eit.uni-kl.de virtual multi_target_base* get_hierarch_bind()=0; 38612027Sjungma@eit.uni-kl.de 38712027Sjungma@eit.uni-kl.de //this method shall inform the multi target socket that it is bound 38812027Sjungma@eit.uni-kl.de // hierarchically and to which other multi target socket it is bound hierarchically 38912027Sjungma@eit.uni-kl.de virtual void set_hierarch_bind(multi_target_base*)=0; 39012027Sjungma@eit.uni-kl.de 39112027Sjungma@eit.uni-kl.de //this method shall return a vector of the callback binders of multi initiator socket 39212027Sjungma@eit.uni-kl.de virtual std::vector<callback_binder_fw<TYPES>* >& get_binders()=0; 39312027Sjungma@eit.uni-kl.de 39412027Sjungma@eit.uni-kl.de //this method shall return a map of all multi initiator sockets that are bound to this multi target 39512027Sjungma@eit.uni-kl.de // the key of the map is the index at which the multi initiator i bound, while the value 39612027Sjungma@eit.uni-kl.de // is the interface of the multi initiator socket that is bound at that index 39712027Sjungma@eit.uni-kl.de virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& get_multi_binds()=0; 39812027Sjungma@eit.uni-kl.de 39912027Sjungma@eit.uni-kl.de //ctor and dtor 40012027Sjungma@eit.uni-kl.de virtual ~multi_target_base(){} 40112027Sjungma@eit.uni-kl.de multi_target_base():base_type(sc_core::sc_gen_unique_name("multi_target_base")){} 40212027Sjungma@eit.uni-kl.de multi_target_base(const char* name):base_type(name){} 40312027Sjungma@eit.uni-kl.de}; 40412027Sjungma@eit.uni-kl.de 40512027Sjungma@eit.uni-kl.de/* 40612027Sjungma@eit.uni-kl.deAll multi sockets must additionally derive from this class. 40712027Sjungma@eit.uni-kl.deIt enforces a multi socket to implement a function 40812027Sjungma@eit.uni-kl.deneeded to do multi init to multi target bindings. 40912027Sjungma@eit.uni-kl.de*/ 41012027Sjungma@eit.uni-kl.detemplate <typename TYPES> 41112027Sjungma@eit.uni-kl.declass multi_to_multi_bind_base{ 41212027Sjungma@eit.uni-kl.depublic: 41312027Sjungma@eit.uni-kl.de virtual ~multi_to_multi_bind_base(){} 41412027Sjungma@eit.uni-kl.de virtual tlm::tlm_fw_transport_if<TYPES>* get_last_binder(tlm::tlm_bw_transport_if<TYPES>*)=0; 41512027Sjungma@eit.uni-kl.de}; 41612027Sjungma@eit.uni-kl.de 41712027Sjungma@eit.uni-kl.de} 41812027Sjungma@eit.uni-kl.de#endif 419