TLM-2.0: include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_req_rsp_channels.h

Go to the documentation of this file.

    00001 /*****************************************************************************
    00002
    00003   The following code is derived, directly or indirectly, from the SystemC
    00004   source code Copyright (c) 1996-2008 by all Contributors.
    00005   All Rights reserved.
    00006
    00007   The contents of this file are subject to the restrictions and limitations
    00008   set forth in the SystemC Open Source License Version 3.0 (the "License");
    00009   You may not use this file except in compliance with such restrictions and
    00010   limitations. You may obtain instructions on how to receive a copy of the
    00011   License at http://www.systemc.org/. Software distributed by Contributors
    00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
    00013   ANY KIND, either express or implied. See the License for the specific
    00014   language governing rights and limitations under the License.
    00015
    00016  *****************************************************************************/
    00017
    00018 #ifndef __TLM_REQ_RSP_CHANNELS_H__
    00019 #define __TLM_REQ_RSP_CHANNELS_H__
    00020
    00021 #include "tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h"
    00022 #include "tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h"
    00023 #include "tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h"
    00024
    00025 namespace tlm {
    00026
    00027 template < typename REQ , typename RSP ,
    00028      typename REQ_CHANNEL = tlm_fifo<REQ> ,
    00029      typename RSP_CHANNEL = tlm_fifo<RSP> >
    00030
    00031 class tlm_req_rsp_channel : public sc_core::sc_module
    00032 {
    00033 public:
    00034   // uni-directional slave interface
    00035
    00036   sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export;
    00037   sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export;
    00038
    00039   // uni-directional master interface
    00040
    00041   sc_core::sc_export< tlm_fifo_put_if< REQ > > put_request_export;
    00042   sc_core::sc_export< tlm_fifo_get_if< RSP > > get_response_export;
    00043
    00044   // master / slave interfaces
    00045
    00046   sc_core::sc_export< tlm_master_if< REQ , RSP > > master_export;
    00047   sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export;
    00048
    00049
    00050   tlm_req_rsp_channel( int req_size = 1 , int rsp_size = 1 ) :
    00051     sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("tlm_req_rsp_channel") ) ) ,
    00052     request_fifo( req_size ) ,
    00053     response_fifo( rsp_size ) ,
    00054     master( request_fifo , response_fifo ) ,
    00055     slave( request_fifo , response_fifo )
    00056   {
    00057
    00058     bind_exports();
    00059
    00060   }
    00061
    00062   tlm_req_rsp_channel( sc_core::sc_module_name module_name ,
    00063            int req_size = 1 , int rsp_size = 1 ) :
    00064     sc_core::sc_module( module_name  ) ,
    00065     request_fifo( req_size ) ,
    00066     response_fifo( rsp_size ) ,
    00067     master( request_fifo , response_fifo ) ,
    00068     slave( request_fifo , response_fifo )
    00069   {
    00070
    00071     bind_exports();
    00072
    00073   }
    00074
    00075 private:
    00076   void bind_exports() {
    00077
    00078     put_request_export( request_fifo );
    00079     get_request_export( request_fifo );
    00080
    00081     put_response_export( response_fifo );
    00082     get_response_export( response_fifo );
    00083
    00084     master_export( master );
    00085     slave_export( slave );
    00086
    00087   }
    00088
    00089 protected:
    00090   REQ_CHANNEL request_fifo;
    00091   RSP_CHANNEL response_fifo;
    00092
    00093   tlm_master_imp< REQ , RSP > master;
    00094   tlm_slave_imp< REQ , RSP > slave;
    00095 };
    00096
    00097 template < typename REQ , typename RSP ,
    00098      typename REQ_CHANNEL = tlm_fifo<REQ> ,
    00099      typename RSP_CHANNEL = tlm_fifo<RSP> >
    00100 class tlm_transport_channel : public sc_core::sc_module
    00101 {
    00102 public:
    00103
    00104   // master transport interface
    00105
    00106   sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export;
    00107
    00108   // slave interfaces
    00109
    00110   sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export;
    00111   sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export;
    00112
    00113   sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export;
    00114
    00115   tlm_transport_channel() :
    00116     sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("transport_channel" ) ) ) ,
    00117     target_export("target_export") ,
    00118     req_rsp( "req_rsp" , 1 , 1 ) ,
    00119     t2m("ts2m")
    00120   {
    00121     do_binding();
    00122   }
    00123
    00124   tlm_transport_channel( sc_core::sc_module_name nm ) :
    00125     sc_core::sc_module( nm ) ,
    00126     target_export("target_export") ,
    00127     req_rsp( "req_rsp" , 1 , 1 ) ,
    00128     t2m("tsm" )
    00129   {
    00130     do_binding();
    00131   }
    00132
    00133 private:
    00134   void do_binding() {
    00135
    00136     target_export( t2m.target_export );
    00137
    00138     t2m.master_port( req_rsp.master_export );
    00139
    00140     get_request_export( req_rsp.get_request_export );
    00141     put_response_export( req_rsp.put_response_export );
    00142     slave_export( req_rsp.slave_export );
    00143
    00144   }
    00145
    00146   tlm_req_rsp_channel< REQ , RSP , REQ_CHANNEL , RSP_CHANNEL > req_rsp;
    00147   tlm_transport_to_master< REQ , RSP > t2m;
    00148
    00149 };
    00150
    00151 } // namespace tlm
    00152
    00153 #endif