1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20#ifndef __TLM_REQ_RSP_CHANNELS_H__ 21#define __TLM_REQ_RSP_CHANNELS_H__ 22 23#include "tlm_core/tlm_1/tlm_req_rsp/tlm_adapters/tlm_adapters.h" 24#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo.h" 25#include "tlm_core/tlm_1/tlm_req_rsp/tlm_channels/tlm_req_rsp_channels/tlm_put_get_imp.h" 26 27namespace tlm { 28 29template < typename REQ , typename RSP , 30 typename REQ_CHANNEL = tlm_fifo<REQ> , 31 typename RSP_CHANNEL = tlm_fifo<RSP> > 32 33class tlm_req_rsp_channel : public sc_core::sc_module 34{ 35public: 36 // uni-directional slave interface 37 38 sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export; 39 sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export; 40 41 // uni-directional master interface 42 43 sc_core::sc_export< tlm_fifo_put_if< REQ > > put_request_export; 44 sc_core::sc_export< tlm_fifo_get_if< RSP > > get_response_export; 45 46 // master / slave interfaces 47 48 sc_core::sc_export< tlm_master_if< REQ , RSP > > master_export; 49 sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export; 50 51 52 tlm_req_rsp_channel( int req_size = 1 , int rsp_size = 1 ) : 53 sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("tlm_req_rsp_channel") ) ) , 54 request_fifo( req_size ) , 55 response_fifo( rsp_size ) , 56 master( request_fifo , response_fifo ) , 57 slave( request_fifo , response_fifo ) 58 { 59 60 bind_exports(); 61 62 } 63 64 tlm_req_rsp_channel( sc_core::sc_module_name module_name , 65 int req_size = 1 , int rsp_size = 1 ) : 66 sc_core::sc_module( module_name ) , 67 request_fifo( req_size ) , 68 response_fifo( rsp_size ) , 69 master( request_fifo , response_fifo ) , 70 slave( request_fifo , response_fifo ) 71 { 72 73 bind_exports(); 74 75 } 76 77private: 78 void bind_exports() { 79 80 put_request_export( request_fifo ); 81 get_request_export( request_fifo ); 82 83 put_response_export( response_fifo ); 84 get_response_export( response_fifo ); 85 86 master_export( master ); 87 slave_export( slave ); 88 89 } 90 91protected: 92 REQ_CHANNEL request_fifo; 93 RSP_CHANNEL response_fifo; 94 95 tlm_master_imp< REQ , RSP > master; 96 tlm_slave_imp< REQ , RSP > slave; 97}; 98 99template < typename REQ , typename RSP , 100 typename REQ_CHANNEL = tlm_fifo<REQ> , 101 typename RSP_CHANNEL = tlm_fifo<RSP> > 102class tlm_transport_channel : public sc_core::sc_module 103{ 104public: 105 106 // master transport interface 107 108 sc_core::sc_export< tlm_transport_if< REQ , RSP > > target_export; 109 110 // slave interfaces 111 112 sc_core::sc_export< tlm_fifo_get_if< REQ > > get_request_export; 113 sc_core::sc_export< tlm_fifo_put_if< RSP > > put_response_export; 114 115 sc_core::sc_export< tlm_slave_if< REQ , RSP > > slave_export; 116 117 tlm_transport_channel() : 118 sc_core::sc_module( sc_core::sc_module_name( sc_core::sc_gen_unique_name("transport_channel" ) ) ) , 119 target_export("target_export") , 120 req_rsp( "req_rsp" , 1 , 1 ) , 121 t2m("ts2m") 122 { 123 do_binding(); 124 } 125 126 tlm_transport_channel( sc_core::sc_module_name nm ) : 127 sc_core::sc_module( nm ) , 128 target_export("target_export") , 129 req_rsp( "req_rsp" , 1 , 1 ) , 130 t2m("tsm" ) 131 { 132 do_binding(); 133 } 134 135private: 136 void do_binding() { 137 138 target_export( t2m.target_export ); 139 140 t2m.master_port( req_rsp.master_export ); 141 142 get_request_export( req_rsp.get_request_export ); 143 put_response_export( req_rsp.put_response_export ); 144 slave_export( req_rsp.slave_export ); 145 146 } 147 148 tlm_req_rsp_channel< REQ , RSP , REQ_CHANNEL , RSP_CHANNEL > req_rsp; 149 tlm_transport_to_master< REQ , RSP > t2m; 150 151}; 152 153} // namespace tlm 154 155#endif 156