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 \ 21 __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__ 22#define \ 23 __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__ 24 25#include "../../adapters/adapters.hh" 26#include "../fifo/fifo.hh" 27#include "put_get_imp.hh" 28 29namespace tlm 30{ 31 32template <typename REQ, typename RSP, typename REQ_CHANNEL=tlm_fifo<REQ>, 33 typename RSP_CHANNEL=tlm_fifo<RSP>> 34class tlm_req_rsp_channel : public sc_core::sc_module 35{ 36 public: 37 // Uni-directional slave interface. 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 sc_core::sc_export<tlm_fifo_put_if<REQ>> put_request_export; 43 sc_core::sc_export<tlm_fifo_get_if<RSP>> get_response_export; 44 45 // Master/slave interfaces. 46 sc_core::sc_export<tlm_master_if<REQ, RSP>> master_export; 47 sc_core::sc_export<tlm_slave_if<REQ, RSP>> slave_export; 48 49 tlm_req_rsp_channel(int req_size=1, int rsp_size=1) : 50 sc_core::sc_module(sc_core::sc_module_name( 51 sc_core::sc_gen_unique_name("tlm_req_rsp_channel"))), 52 request_fifo(req_size), response_fifo(rsp_size), 53 master(request_fifo, response_fifo), 54 slave(request_fifo, response_fifo) 55 { 56 bind_exports(); 57 } 58 59 tlm_req_rsp_channel(sc_core::sc_module_name module_name, 60 int req_size=1, int rsp_size=1) : 61 sc_core::sc_module(module_name), 62 request_fifo(req_size), response_fifo(rsp_size), 63 master(request_fifo, response_fifo), 64 slave(request_fifo, response_fifo) 65 { 66 bind_exports(); 67 } 68 69 private: 70 void 71 bind_exports() 72 { 73 put_request_export(request_fifo); 74 get_request_export(request_fifo); 75 76 put_response_export(response_fifo); 77 get_response_export(response_fifo); 78 79 master_export(master); 80 slave_export(slave); 81 } 82 83 protected: 84 REQ_CHANNEL request_fifo; 85 RSP_CHANNEL response_fifo; 86 87 tlm_master_imp<REQ, RSP> master; 88 tlm_slave_imp<REQ, RSP> slave; 89}; 90 91template <typename REQ, typename RSP, 92 typename REQ_CHANNEL=tlm_fifo<REQ>, 93 typename RSP_CHANNEL=tlm_fifo<RSP>> 94class tlm_transport_channel : public sc_core::sc_module 95{ 96 public: 97 // Master transport interface. 98 sc_core::sc_export<tlm_transport_if<REQ, RSP>> target_export; 99 100 // Slave interfaces. 101 sc_core::sc_export<tlm_fifo_get_if<REQ>> get_request_export; 102 sc_core::sc_export<tlm_fifo_put_if<RSP>> put_response_export; 103 104 sc_core::sc_export<tlm_slave_if<REQ, RSP>> slave_export; 105 106 tlm_transport_channel() : 107 sc_core::sc_module(sc_core::sc_module_name( 108 sc_core::sc_gen_unique_name("transport_channel"))), 109 target_export("target_export"), req_rsp("req_rsp", 1, 1), t2m("ts2m") 110 { 111 do_binding(); 112 } 113 114 tlm_transport_channel(sc_core::sc_module_name nm) : 115 sc_core::sc_module(nm), target_export("target_export"), 116 req_rsp("req_rsp", 1, 1), t2m("tsm") 117 { 118 do_binding(); 119 } 120 121 private: 122 void 123 do_binding() 124 { 125 target_export(t2m.target_export); 126 t2m.master_port(req_rsp.master_export); 127 128 get_request_export(req_rsp.get_request_export); 129 put_response_export(req_rsp.put_response_export); 130 slave_export(req_rsp.slave_export); 131 } 132 133 tlm_req_rsp_channel<REQ, RSP, REQ_CHANNEL, RSP_CHANNEL> req_rsp; 134 tlm_transport_to_master<REQ, RSP> t2m; 135}; 136 137} // namespace tlm 138 139#endif 140/* __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__ */ 141