multi_socket_bases.h revision 13511
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
2013511Sgabeblack@google.com#ifndef TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
2113511Sgabeblack@google.com#define TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
2213511Sgabeblack@google.com
2313511Sgabeblack@google.com#include <tlm>
2413511Sgabeblack@google.com#include "tlm_utils/convenience_socket_bases.h"
2513511Sgabeblack@google.com
2613511Sgabeblack@google.com#include <map>
2713511Sgabeblack@google.com
2813511Sgabeblack@google.comnamespace tlm_utils {
2913511Sgabeblack@google.com
3013511Sgabeblack@google.comtemplate <typename signature>
3113511Sgabeblack@google.comstruct fn_container{
3213511Sgabeblack@google.com  signature function;
3313511Sgabeblack@google.com};
3413511Sgabeblack@google.com
3513511Sgabeblack@google.com#define TLM_DEFINE_FUNCTOR(name) \
3613511Sgabeblack@google.comtemplate <typename MODULE, typename TRAITS> \
3713511Sgabeblack@google.cominline TLM_RET_VAL static_##name( void* mod \
3813511Sgabeblack@google.com                                       , void* fn \
3913511Sgabeblack@google.com                                       , int index \
4013511Sgabeblack@google.com                                       , TLM_FULL_ARG_LIST) \
4113511Sgabeblack@google.com{ \
4213511Sgabeblack@google.com  typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
4313511Sgabeblack@google.com  MODULE* tmp_mod=static_cast<MODULE*>(mod); \
4413511Sgabeblack@google.com  fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \
4513511Sgabeblack@google.com  return (tmp_mod->*(tmp_cb->function))(index, TLM_ARG_LIST_WITHOUT_TYPES); \
4613511Sgabeblack@google.com}\
4713511Sgabeblack@google.com\
4813511Sgabeblack@google.comtemplate <typename MODULE, typename TRAITS> \
4913511Sgabeblack@google.cominline void delete_fn_container_of_##name(void* fn) \
5013511Sgabeblack@google.com{ \
5113511Sgabeblack@google.com  typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
5213511Sgabeblack@google.com  fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \
5313511Sgabeblack@google.com  if (tmp_cb) delete tmp_cb;\
5413511Sgabeblack@google.com} \
5513511Sgabeblack@google.com\
5613511Sgabeblack@google.comtemplate <typename TRAITS> \
5713511Sgabeblack@google.comclass name##_functor{ \
5813511Sgabeblack@google.compublic: \
5913511Sgabeblack@google.com  typedef typename TRAITS::tlm_payload_type payload_type; \
6013511Sgabeblack@google.com  typedef typename TRAITS::tlm_phase_type   phase_type; \
6113511Sgabeblack@google.com  typedef TLM_RET_VAL (*call_fn)(void*,void*, int, TLM_FULL_ARG_LIST); \
6213511Sgabeblack@google.com  typedef void (*del_fn)(void*); \
6313511Sgabeblack@google.com\
6413511Sgabeblack@google.com  name##_functor(): m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0){} \
6513511Sgabeblack@google.com  ~name##_functor(){if (m_del_fn) (*m_del_fn)(m_mem_fn);}  \
6613511Sgabeblack@google.com\
6713511Sgabeblack@google.com  template <typename MODULE> \
6813511Sgabeblack@google.com  void set_function(MODULE* mod, TLM_RET_VAL (MODULE::*cb)(int, TLM_FULL_ARG_LIST)){ \
6913511Sgabeblack@google.com    typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
7013511Sgabeblack@google.com    m_fn=&static_##name<MODULE,TRAITS>;\
7113511Sgabeblack@google.com    m_del_fn=&delete_fn_container_of_##name<MODULE,TRAITS>;\
7213511Sgabeblack@google.com    m_del_fn(m_mem_fn); \
7313511Sgabeblack@google.com    fn_container_type* tmp= new fn_container_type(); \
7413511Sgabeblack@google.com    tmp->function=cb; \
7513511Sgabeblack@google.com    m_mod=static_cast<void*>(mod); \
7613511Sgabeblack@google.com    m_mem_fn=static_cast<void*>(tmp); \
7713511Sgabeblack@google.com  } \
7813511Sgabeblack@google.com  \
7913511Sgabeblack@google.com  TLM_RET_VAL operator()(int index, TLM_FULL_ARG_LIST){ \
8013511Sgabeblack@google.com    return m_fn(m_mod,m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \
8113511Sgabeblack@google.com  } \
8213511Sgabeblack@google.com\
8313511Sgabeblack@google.com  bool is_valid(){return (m_mod!=0 && m_mem_fn!=0 && m_fn!=0);}\
8413511Sgabeblack@google.com\
8513511Sgabeblack@google.comprotected: \
8613511Sgabeblack@google.com  call_fn m_fn;\
8713511Sgabeblack@google.com  del_fn m_del_fn; \
8813511Sgabeblack@google.com  void* m_mod; \
8913511Sgabeblack@google.com  void* m_mem_fn; \
9013511Sgabeblack@google.comprivate: \
9113511Sgabeblack@google.com  name##_functor& operator=(const name##_functor&); \
9213511Sgabeblack@google.com}
9313511Sgabeblack@google.com
9413511Sgabeblack@google.com
9513511Sgabeblack@google.com#define TLM_RET_VAL tlm::tlm_sync_enum
9613511Sgabeblack@google.com#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, typename TRAITS::tlm_phase_type& ph, sc_core::sc_time& t
9713511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn,ph,t
9813511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(nb_transport);
9913511Sgabeblack@google.com#undef TLM_RET_VAL
10013511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST
10113511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES
10213511Sgabeblack@google.com
10313511Sgabeblack@google.com#define TLM_RET_VAL void
10413511Sgabeblack@google.com#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, sc_core::sc_time& t
10513511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn,t
10613511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(b_transport);
10713511Sgabeblack@google.com#undef TLM_RET_VAL
10813511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST
10913511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES
11013511Sgabeblack@google.com
11113511Sgabeblack@google.com#define TLM_RET_VAL unsigned int
11213511Sgabeblack@google.com#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn
11313511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn
11413511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(debug_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 bool
12013511Sgabeblack@google.com#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, tlm::tlm_dmi& dmi
12113511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES txn,dmi
12213511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(get_dmi_ptr);
12313511Sgabeblack@google.com#undef TLM_RET_VAL
12413511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST
12513511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES
12613511Sgabeblack@google.com
12713511Sgabeblack@google.com#define TLM_RET_VAL void
12813511Sgabeblack@google.com#define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u
12913511Sgabeblack@google.com#define TLM_ARG_LIST_WITHOUT_TYPES l,u
13013511Sgabeblack@google.comTLM_DEFINE_FUNCTOR(invalidate_dmi);
13113511Sgabeblack@google.com#undef TLM_RET_VAL
13213511Sgabeblack@google.com#undef TLM_FULL_ARG_LIST
13313511Sgabeblack@google.com#undef TLM_ARG_LIST_WITHOUT_TYPES
13413511Sgabeblack@google.com
13513511Sgabeblack@google.com#undef TLM_DEFINE_FUNCTOR
13613511Sgabeblack@google.com
13713511Sgabeblack@google.com/*
13813511Sgabeblack@google.comThis class implements the fw interface.
13913511Sgabeblack@google.comIt allows to register a callback for each of the fw interface methods.
14013511Sgabeblack@google.comThe callbacks simply forward the fw interface call, but add the id (an int)
14113511Sgabeblack@google.comof the callback binder to the signature of the call.
14213511Sgabeblack@google.com*/
14313511Sgabeblack@google.comtemplate <typename TYPES>
14413511Sgabeblack@google.comclass callback_binder_fw
14513511Sgabeblack@google.com  : public tlm::tlm_fw_transport_if<TYPES>
14613511Sgabeblack@google.com  , protected convenience_socket_cb_holder
14713511Sgabeblack@google.com{
14813511Sgabeblack@google.com  public:
14913511Sgabeblack@google.com    //typedefs according to the used TYPES class
15013511Sgabeblack@google.com    typedef typename TYPES::tlm_payload_type              transaction_type;
15113511Sgabeblack@google.com    typedef typename TYPES::tlm_phase_type                phase_type;
15213511Sgabeblack@google.com    typedef tlm::tlm_sync_enum                            sync_enum_type;
15313511Sgabeblack@google.com
15413511Sgabeblack@google.com    //typedefs for the callbacks
15513511Sgabeblack@google.com    typedef nb_transport_functor<TYPES>    nb_func_type;
15613511Sgabeblack@google.com    typedef b_transport_functor<TYPES>     b_func_type;
15713511Sgabeblack@google.com    typedef debug_transport_functor<TYPES> debug_func_type;
15813511Sgabeblack@google.com    typedef get_dmi_ptr_functor<TYPES>     dmi_func_type;
15913511Sgabeblack@google.com
16013511Sgabeblack@google.com    //ctor: an ID is needed to create a callback binder
16113511Sgabeblack@google.com    callback_binder_fw(multi_socket_base* owner, int id)
16213511Sgabeblack@google.com      : convenience_socket_cb_holder(owner), m_id(id)
16313511Sgabeblack@google.com      , m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0)
16413511Sgabeblack@google.com      , m_caller_port(0)
16513511Sgabeblack@google.com    {}
16613511Sgabeblack@google.com
16713511Sgabeblack@google.com    //the nb_transport method of the fw interface
16813511Sgabeblack@google.com    sync_enum_type nb_transport_fw(transaction_type& txn,
16913511Sgabeblack@google.com                                phase_type& p,
17013511Sgabeblack@google.com                                sc_core::sc_time& t){
17113511Sgabeblack@google.com      //check if a callback is registered
17213511Sgabeblack@google.com      if (m_nb_f && m_nb_f->is_valid()) {
17313511Sgabeblack@google.com        return (*m_nb_f)(m_id, txn, p, t); //do the callback
17413511Sgabeblack@google.com      }
17513511Sgabeblack@google.com
17613511Sgabeblack@google.com      display_error("Call to nb_transport_fw without a registered callback for nb_transport_fw.");
17713511Sgabeblack@google.com      return tlm::TLM_COMPLETED;
17813511Sgabeblack@google.com    }
17913511Sgabeblack@google.com
18013511Sgabeblack@google.com    //the b_transport method of the fw interface
18113511Sgabeblack@google.com    void b_transport(transaction_type& trans,sc_core::sc_time& t){
18213511Sgabeblack@google.com      //check if a callback is registered
18313511Sgabeblack@google.com      if (m_b_f && m_b_f->is_valid()) {
18413511Sgabeblack@google.com        (*m_b_f)(m_id, trans,t); //do the callback
18513511Sgabeblack@google.com        return;
18613511Sgabeblack@google.com      }
18713511Sgabeblack@google.com
18813511Sgabeblack@google.com      display_error("Call to b_transport without a registered callback for b_transport.");
18913511Sgabeblack@google.com    }
19013511Sgabeblack@google.com
19113511Sgabeblack@google.com    //the DMI method of the fw interface
19213511Sgabeblack@google.com    bool get_direct_mem_ptr(transaction_type& trans, tlm::tlm_dmi&  dmi_data){
19313511Sgabeblack@google.com      //check if a callback is registered
19413511Sgabeblack@google.com      if (m_dmi_f && m_dmi_f->is_valid()) {
19513511Sgabeblack@google.com        return (*m_dmi_f)(m_id, trans,dmi_data); //do the callback
19613511Sgabeblack@google.com      }
19713511Sgabeblack@google.com
19813511Sgabeblack@google.com      dmi_data.allow_none();
19913511Sgabeblack@google.com      dmi_data.set_start_address(0x0);
20013511Sgabeblack@google.com      dmi_data.set_end_address((sc_dt::uint64)-1);
20113511Sgabeblack@google.com      return false;
20213511Sgabeblack@google.com    }
20313511Sgabeblack@google.com
20413511Sgabeblack@google.com    //the debug method of the fw interface
20513511Sgabeblack@google.com    unsigned int transport_dbg(transaction_type& trans){
20613511Sgabeblack@google.com      //check if a callback is registered
20713511Sgabeblack@google.com      if (m_dbg_f && m_dbg_f->is_valid()) {
20813511Sgabeblack@google.com        return (*m_dbg_f)(m_id, trans); //do the callback
20913511Sgabeblack@google.com      }
21013511Sgabeblack@google.com
21113511Sgabeblack@google.com      return 0;
21213511Sgabeblack@google.com    }
21313511Sgabeblack@google.com
21413511Sgabeblack@google.com    //the SystemC standard callback register_port:
21513511Sgabeblack@google.com    // - called when a port if bound to the interface
21613511Sgabeblack@google.com    // - allowd to find out who is bound to that callback binder
21713511Sgabeblack@google.com    void register_port(sc_core::sc_port_base& b, const char* /*name*/){
21813511Sgabeblack@google.com      m_caller_port=&b;
21913511Sgabeblack@google.com    }
22013511Sgabeblack@google.com
22113511Sgabeblack@google.com    //register callbacks for all fw interface methods at once
22213511Sgabeblack@google.com    void set_callbacks(nb_func_type& cb1, b_func_type& cb2, dmi_func_type& cb3, debug_func_type& cb4){
22313511Sgabeblack@google.com      m_nb_f=&cb1;
22413511Sgabeblack@google.com      m_b_f=&cb2;
22513511Sgabeblack@google.com      m_dmi_f=&cb3;
22613511Sgabeblack@google.com      m_dbg_f=&cb4;
22713511Sgabeblack@google.com    }
22813511Sgabeblack@google.com
22913511Sgabeblack@google.com    //getter method to get the port that is bound to that callback binder
23013511Sgabeblack@google.com    // NOTE: this will only return a valid value at end of elaboration
23113511Sgabeblack@google.com    //  (but not before end of elaboration!)
23213511Sgabeblack@google.com    sc_core::sc_port_base* get_other_side(){return m_caller_port;}
23313511Sgabeblack@google.com
23413511Sgabeblack@google.com  private:
23513511Sgabeblack@google.com    //the ID of the callback binder
23613511Sgabeblack@google.com    int m_id;
23713511Sgabeblack@google.com
23813511Sgabeblack@google.com    //the callbacks
23913511Sgabeblack@google.com    nb_func_type* m_nb_f;
24013511Sgabeblack@google.com    b_func_type*  m_b_f;
24113511Sgabeblack@google.com    debug_func_type* m_dbg_f;
24213511Sgabeblack@google.com    dmi_func_type* m_dmi_f;
24313511Sgabeblack@google.com
24413511Sgabeblack@google.com    //the port bound to that callback binder
24513511Sgabeblack@google.com    sc_core::sc_port_base* m_caller_port;
24613511Sgabeblack@google.com};
24713511Sgabeblack@google.com
24813511Sgabeblack@google.com/*
24913511Sgabeblack@google.comThis class implements the bw interface.
25013511Sgabeblack@google.comIt allows to register a callback for each of the bw interface methods.
25113511Sgabeblack@google.comThe callbacks simply forward the bw interface call, but add the id (an int)
25213511Sgabeblack@google.comof the callback binder to the signature of the call.
25313511Sgabeblack@google.com*/
25413511Sgabeblack@google.comtemplate <typename TYPES>
25513511Sgabeblack@google.comclass callback_binder_bw
25613511Sgabeblack@google.com  : public tlm::tlm_bw_transport_if<TYPES>
25713511Sgabeblack@google.com  , protected convenience_socket_cb_holder
25813511Sgabeblack@google.com{
25913511Sgabeblack@google.com  public:
26013511Sgabeblack@google.com    //typedefs according to the used TYPES class
26113511Sgabeblack@google.com    typedef typename TYPES::tlm_payload_type              transaction_type;
26213511Sgabeblack@google.com    typedef typename TYPES::tlm_phase_type                phase_type;
26313511Sgabeblack@google.com    typedef tlm::tlm_sync_enum                            sync_enum_type;
26413511Sgabeblack@google.com
26513511Sgabeblack@google.com    //typedefs for the callbacks
26613511Sgabeblack@google.com    typedef nb_transport_functor<TYPES>   nb_func_type;
26713511Sgabeblack@google.com    typedef invalidate_dmi_functor<TYPES> dmi_func_type;
26813511Sgabeblack@google.com
26913511Sgabeblack@google.com    //ctor: an ID is needed to create a callback binder
27013511Sgabeblack@google.com    callback_binder_bw(multi_socket_base* owner, int id)
27113511Sgabeblack@google.com      : convenience_socket_cb_holder(owner), m_id(id)
27213511Sgabeblack@google.com      , m_nb_f(0), m_dmi_f(0) {}
27313511Sgabeblack@google.com
27413511Sgabeblack@google.com    //the nb_transport method of the bw interface
27513511Sgabeblack@google.com    sync_enum_type nb_transport_bw(transaction_type& txn,
27613511Sgabeblack@google.com                                phase_type& p,
27713511Sgabeblack@google.com                                sc_core::sc_time& t){
27813511Sgabeblack@google.com      //check if a callback is registered
27913511Sgabeblack@google.com      if (m_nb_f && m_nb_f->is_valid()) {
28013511Sgabeblack@google.com        return (*m_nb_f)(m_id, txn, p, t); //do the callback
28113511Sgabeblack@google.com      }
28213511Sgabeblack@google.com
28313511Sgabeblack@google.com      display_error("Call to nb_transport_bw without a registered callback for nb_transport_bw");
28413511Sgabeblack@google.com      return tlm::TLM_COMPLETED;
28513511Sgabeblack@google.com    }
28613511Sgabeblack@google.com
28713511Sgabeblack@google.com    //the DMI method of the bw interface
28813511Sgabeblack@google.com    void invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u){
28913511Sgabeblack@google.com      //check if a callback is registered
29013511Sgabeblack@google.com      if (m_dmi_f && m_dmi_f->is_valid()) {
29113511Sgabeblack@google.com        (*m_dmi_f)(m_id,l,u); //do the callback
29213511Sgabeblack@google.com      }
29313511Sgabeblack@google.com    }
29413511Sgabeblack@google.com
29513511Sgabeblack@google.com    //register callbacks for all bw interface methods at once
29613511Sgabeblack@google.com    void set_callbacks(nb_func_type& cb1, dmi_func_type& cb2){
29713511Sgabeblack@google.com      m_nb_f=&cb1;
29813511Sgabeblack@google.com      m_dmi_f=&cb2;
29913511Sgabeblack@google.com    }
30013511Sgabeblack@google.com
30113511Sgabeblack@google.com  private:
30213511Sgabeblack@google.com    //the ID of the callback binder
30313511Sgabeblack@google.com    int m_id;
30413511Sgabeblack@google.com    //the callbacks
30513511Sgabeblack@google.com    nb_func_type* m_nb_f;
30613511Sgabeblack@google.com    dmi_func_type* m_dmi_f;
30713511Sgabeblack@google.com};
30813511Sgabeblack@google.com
30913511Sgabeblack@google.com/*
31013511Sgabeblack@google.comThis class forms the base for multi initiator sockets,
31113511Sgabeblack@google.comwith fewer template parameters than the multi_init_base.
31213511Sgabeblack@google.comThis class is implementation-defined.
31313511Sgabeblack@google.com*/
31413511Sgabeblack@google.comtemplate <typename TYPES = tlm::tlm_base_protocol_types>
31513511Sgabeblack@google.comclass multi_init_base_if {
31613511Sgabeblack@google.compublic:
31713511Sgabeblack@google.com  //this method shall return a vector of the callback binders of multi initiator socket
31813511Sgabeblack@google.com  virtual std::vector<callback_binder_bw<TYPES>* >& get_binders()=0;
31913511Sgabeblack@google.com  //this method shall return a vector of all target interfaces bound to this multi init socket
32013511Sgabeblack@google.com  virtual std::vector<tlm::tlm_fw_transport_if<TYPES>*>& get_sockets()=0;
32113511Sgabeblack@google.comprotected:
32213511Sgabeblack@google.com  virtual ~multi_init_base_if() {}
32313511Sgabeblack@google.com};
32413511Sgabeblack@google.com
32513511Sgabeblack@google.com/*
32613511Sgabeblack@google.comThis class forms the base for multi initiator sockets.
32713511Sgabeblack@google.comIt enforces a multi initiator socket to implement all functions
32813511Sgabeblack@google.comneeded to do hierarchical bindings.
32913511Sgabeblack@google.com*/
33013511Sgabeblack@google.comtemplate <unsigned int BUSWIDTH = 32,
33113511Sgabeblack@google.com          typename TYPES = tlm::tlm_base_protocol_types,
33213511Sgabeblack@google.com          unsigned int N=0,
33313511Sgabeblack@google.com          sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
33413511Sgabeblack@google.comclass multi_init_base
33513511Sgabeblack@google.com  : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>
33613511Sgabeblack@google.com  , public multi_init_base_if<TYPES>
33713511Sgabeblack@google.com  , protected multi_socket_base
33813511Sgabeblack@google.com{
33913511Sgabeblack@google.compublic:
34013511Sgabeblack@google.com  //typedef for the base type: the standard tlm initiator socket
34113511Sgabeblack@google.com  typedef tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> base_type;
34213511Sgabeblack@google.com
34313511Sgabeblack@google.com  //this method shall disable the code that does the callback binding
34413511Sgabeblack@google.com  // that registers callbacks to binders
34513511Sgabeblack@google.com  virtual void disable_cb_bind()=0;
34613511Sgabeblack@google.com
34713511Sgabeblack@google.com  //this method shall return the multi_init_base to which the
34813511Sgabeblack@google.com  // multi_init_base is bound hierarchically
34913511Sgabeblack@google.com  //  If the base is not bound hierarchically it shall return a pointer to itself
35013511Sgabeblack@google.com  virtual multi_init_base* get_hierarch_bind()=0;
35113511Sgabeblack@google.com
35213511Sgabeblack@google.com  virtual tlm::tlm_socket_category get_socket_category() const
35313511Sgabeblack@google.com  {
35413511Sgabeblack@google.com    return tlm::TLM_MULTI_INITIATOR_SOCKET;
35513511Sgabeblack@google.com  }
35613511Sgabeblack@google.com
35713511Sgabeblack@google.com  //ctor and dtor
35813511Sgabeblack@google.com  virtual ~multi_init_base(){}
35913511Sgabeblack@google.com  multi_init_base():base_type(sc_core::sc_gen_unique_name("multi_init_base")){}
36013511Sgabeblack@google.com  multi_init_base(const char* name):base_type(name){}
36113511Sgabeblack@google.com
36213511Sgabeblack@google.comprivate:
36313511Sgabeblack@google.com  const sc_core::sc_object* get_socket() const { return this; }
36413511Sgabeblack@google.com};
36513511Sgabeblack@google.com
36613511Sgabeblack@google.com/*
36713511Sgabeblack@google.comThis class forms the base for multi target sockets,
36813511Sgabeblack@google.comwith fewer template parameters than the multi_target_base.
36913511Sgabeblack@google.comThis class is implementation-defined.
37013511Sgabeblack@google.com*/
37113511Sgabeblack@google.comtemplate <typename TYPES = tlm::tlm_base_protocol_types>
37213511Sgabeblack@google.comclass multi_target_base_if {
37313511Sgabeblack@google.compublic:
37413511Sgabeblack@google.com  //this method shall return a vector of the callback binders of multi initiator socket
37513511Sgabeblack@google.com  virtual std::vector<callback_binder_fw<TYPES>* >& get_binders()=0;
37613511Sgabeblack@google.com
37713511Sgabeblack@google.com  //this method shall return a map of all multi initiator sockets that are
37813511Sgabeblack@google.com  // bound to this multi target the key of the map is the index at which the
37913511Sgabeblack@google.com  // multi initiator i bound, while the value is the interface of the multi
38013511Sgabeblack@google.com  // initiator socket that is bound at that index
38113511Sgabeblack@google.com  virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& get_multi_binds()=0;
38213511Sgabeblack@google.comprotected:
38313511Sgabeblack@google.com  virtual ~multi_target_base_if() {}
38413511Sgabeblack@google.com};
38513511Sgabeblack@google.com
38613511Sgabeblack@google.com/*
38713511Sgabeblack@google.comThis class forms the base for multi target sockets.
38813511Sgabeblack@google.comIt enforces a multi target socket to implement all functions
38913511Sgabeblack@google.comneeded to do hierarchical bindings.
39013511Sgabeblack@google.com*/
39113511Sgabeblack@google.comtemplate <unsigned int BUSWIDTH = 32,
39213511Sgabeblack@google.com          typename TYPES = tlm::tlm_base_protocol_types,
39313511Sgabeblack@google.com          unsigned int N=0,
39413511Sgabeblack@google.com          sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
39513511Sgabeblack@google.comclass multi_target_base
39613511Sgabeblack@google.com  : public tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL>
39713511Sgabeblack@google.com  , public multi_target_base_if<TYPES>
39813511Sgabeblack@google.com  , protected multi_socket_base
39913511Sgabeblack@google.com{
40013511Sgabeblack@google.compublic:
40113511Sgabeblack@google.com  //typedef for the base type: the standard tlm target socket
40213511Sgabeblack@google.com  typedef tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL > base_type;
40313511Sgabeblack@google.com
40413511Sgabeblack@google.com  //this method shall return the multi_init_base to which the
40513511Sgabeblack@google.com  // multi_init_base is bound hierarchically
40613511Sgabeblack@google.com  //  If the base is not bound hierarchically it shall return a pointer to itself
40713511Sgabeblack@google.com  virtual multi_target_base* get_hierarch_bind()=0;
40813511Sgabeblack@google.com
40913511Sgabeblack@google.com  //this method shall inform the multi target socket that it is bound
41013511Sgabeblack@google.com  // hierarchically and to which other multi target socket it is bound hierarchically
41113511Sgabeblack@google.com  virtual void set_hierarch_bind(multi_target_base*)=0;
41213511Sgabeblack@google.com
41313511Sgabeblack@google.com  virtual tlm::tlm_socket_category get_socket_category() const
41413511Sgabeblack@google.com  {
41513511Sgabeblack@google.com    return tlm::TLM_MULTI_TARGET_SOCKET;
41613511Sgabeblack@google.com  }
41713511Sgabeblack@google.com
41813511Sgabeblack@google.com  //ctor and dtor
41913511Sgabeblack@google.com  virtual ~multi_target_base(){}
42013511Sgabeblack@google.com  multi_target_base():base_type(sc_core::sc_gen_unique_name("multi_target_base")){}
42113511Sgabeblack@google.com  multi_target_base(const char* name):base_type(name){}
42213511Sgabeblack@google.com
42313511Sgabeblack@google.comprivate:
42413511Sgabeblack@google.com  const sc_core::sc_object* get_socket() const { return this; }
42513511Sgabeblack@google.com};
42613511Sgabeblack@google.com
42713511Sgabeblack@google.com/*
42813511Sgabeblack@google.comAll multi sockets must additionally derive from this class.
42913511Sgabeblack@google.comIt enforces a multi socket to implement a function
43013511Sgabeblack@google.comneeded to do multi init to multi target bindings.
43113511Sgabeblack@google.com*/
43213511Sgabeblack@google.comtemplate <typename TYPES>
43313511Sgabeblack@google.comclass multi_to_multi_bind_base{
43413511Sgabeblack@google.compublic:
43513511Sgabeblack@google.com  virtual ~multi_to_multi_bind_base(){}
43613511Sgabeblack@google.com  virtual tlm::tlm_fw_transport_if<TYPES>* get_last_binder(tlm::tlm_bw_transport_if<TYPES>*)=0;
43713511Sgabeblack@google.com};
43813511Sgabeblack@google.com
43913511Sgabeblack@google.com} // namespace tlm_utils
44013511Sgabeblack@google.com#endif // TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
441