113521Sgabeblack@google.com/*****************************************************************************
213521Sgabeblack@google.com
313521Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
413521Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
513521Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
613521Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
713521Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
813521Sgabeblack@google.com  License.  You may obtain a copy of the License at
913521Sgabeblack@google.com
1013521Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1113521Sgabeblack@google.com
1213521Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1313521Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1413521Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1513521Sgabeblack@google.com  implied.  See the License for the specific language governing
1613521Sgabeblack@google.com  permissions and limitations under the License.
1713521Sgabeblack@google.com
1813521Sgabeblack@google.com *****************************************************************************/
1913521Sgabeblack@google.com
2013521Sgabeblack@google.com#ifndef \
2113521Sgabeblack@google.com    __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__
2213521Sgabeblack@google.com#define \
2313521Sgabeblack@google.com    __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__
2413521Sgabeblack@google.com
2513586Sgabeblack@google.com#include "../../adapters/adapters.hh"
2613586Sgabeblack@google.com#include "../fifo/fifo.hh"
2713586Sgabeblack@google.com#include "put_get_imp.hh"
2813521Sgabeblack@google.com
2913521Sgabeblack@google.comnamespace tlm
3013521Sgabeblack@google.com{
3113521Sgabeblack@google.com
3213521Sgabeblack@google.comtemplate <typename REQ, typename RSP, typename REQ_CHANNEL=tlm_fifo<REQ>,
3313521Sgabeblack@google.com          typename RSP_CHANNEL=tlm_fifo<RSP>>
3413521Sgabeblack@google.comclass tlm_req_rsp_channel : public sc_core::sc_module
3513521Sgabeblack@google.com{
3613521Sgabeblack@google.com  public:
3713521Sgabeblack@google.com    // Uni-directional slave interface.
3813521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_get_if<REQ>> get_request_export;
3913521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_put_if<RSP>> put_response_export;
4013521Sgabeblack@google.com
4113521Sgabeblack@google.com    // Uni-directional master interface.
4213521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_put_if<REQ>> put_request_export;
4313521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_get_if<RSP>> get_response_export;
4413521Sgabeblack@google.com
4513521Sgabeblack@google.com    // Master/slave interfaces.
4613521Sgabeblack@google.com    sc_core::sc_export<tlm_master_if<REQ, RSP>> master_export;
4713521Sgabeblack@google.com    sc_core::sc_export<tlm_slave_if<REQ, RSP>> slave_export;
4813521Sgabeblack@google.com
4913521Sgabeblack@google.com    tlm_req_rsp_channel(int req_size=1, int rsp_size=1) :
5013521Sgabeblack@google.com        sc_core::sc_module(sc_core::sc_module_name(
5113521Sgabeblack@google.com                    sc_core::sc_gen_unique_name("tlm_req_rsp_channel"))),
5213521Sgabeblack@google.com        request_fifo(req_size), response_fifo(rsp_size),
5313521Sgabeblack@google.com        master(request_fifo, response_fifo),
5413521Sgabeblack@google.com        slave(request_fifo, response_fifo)
5513521Sgabeblack@google.com    {
5613521Sgabeblack@google.com        bind_exports();
5713521Sgabeblack@google.com    }
5813521Sgabeblack@google.com
5913521Sgabeblack@google.com    tlm_req_rsp_channel(sc_core::sc_module_name module_name,
6013521Sgabeblack@google.com            int req_size=1, int rsp_size=1) :
6113521Sgabeblack@google.com        sc_core::sc_module(module_name),
6213521Sgabeblack@google.com        request_fifo(req_size), response_fifo(rsp_size),
6313521Sgabeblack@google.com        master(request_fifo, response_fifo),
6413521Sgabeblack@google.com        slave(request_fifo, response_fifo)
6513521Sgabeblack@google.com    {
6613521Sgabeblack@google.com        bind_exports();
6713521Sgabeblack@google.com    }
6813521Sgabeblack@google.com
6913521Sgabeblack@google.com  private:
7013521Sgabeblack@google.com    void
7113521Sgabeblack@google.com    bind_exports()
7213521Sgabeblack@google.com    {
7313521Sgabeblack@google.com        put_request_export(request_fifo);
7413521Sgabeblack@google.com        get_request_export(request_fifo);
7513521Sgabeblack@google.com
7613521Sgabeblack@google.com        put_response_export(response_fifo);
7713521Sgabeblack@google.com        get_response_export(response_fifo);
7813521Sgabeblack@google.com
7913521Sgabeblack@google.com        master_export(master);
8013521Sgabeblack@google.com        slave_export(slave);
8113521Sgabeblack@google.com    }
8213521Sgabeblack@google.com
8313521Sgabeblack@google.com  protected:
8413521Sgabeblack@google.com    REQ_CHANNEL request_fifo;
8513521Sgabeblack@google.com    RSP_CHANNEL response_fifo;
8613521Sgabeblack@google.com
8713521Sgabeblack@google.com    tlm_master_imp<REQ, RSP> master;
8813521Sgabeblack@google.com    tlm_slave_imp<REQ, RSP> slave;
8913521Sgabeblack@google.com};
9013521Sgabeblack@google.com
9113521Sgabeblack@google.comtemplate <typename REQ, typename RSP,
9213521Sgabeblack@google.com     typename REQ_CHANNEL=tlm_fifo<REQ>,
9313521Sgabeblack@google.com     typename RSP_CHANNEL=tlm_fifo<RSP>>
9413521Sgabeblack@google.comclass tlm_transport_channel : public sc_core::sc_module
9513521Sgabeblack@google.com{
9613521Sgabeblack@google.com  public:
9713521Sgabeblack@google.com    // Master transport interface.
9813521Sgabeblack@google.com    sc_core::sc_export<tlm_transport_if<REQ, RSP>> target_export;
9913521Sgabeblack@google.com
10013521Sgabeblack@google.com    // Slave interfaces.
10113521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_get_if<REQ>> get_request_export;
10213521Sgabeblack@google.com    sc_core::sc_export<tlm_fifo_put_if<RSP>> put_response_export;
10313521Sgabeblack@google.com
10413521Sgabeblack@google.com    sc_core::sc_export<tlm_slave_if<REQ, RSP>> slave_export;
10513521Sgabeblack@google.com
10613521Sgabeblack@google.com    tlm_transport_channel() :
10713521Sgabeblack@google.com        sc_core::sc_module(sc_core::sc_module_name(
10813521Sgabeblack@google.com                    sc_core::sc_gen_unique_name("transport_channel"))),
10913521Sgabeblack@google.com        target_export("target_export"), req_rsp("req_rsp", 1, 1), t2m("ts2m")
11013521Sgabeblack@google.com    {
11113521Sgabeblack@google.com        do_binding();
11213521Sgabeblack@google.com    }
11313521Sgabeblack@google.com
11413521Sgabeblack@google.com    tlm_transport_channel(sc_core::sc_module_name nm) :
11513521Sgabeblack@google.com        sc_core::sc_module(nm), target_export("target_export"),
11613521Sgabeblack@google.com        req_rsp("req_rsp", 1, 1), t2m("tsm")
11713521Sgabeblack@google.com    {
11813521Sgabeblack@google.com        do_binding();
11913521Sgabeblack@google.com    }
12013521Sgabeblack@google.com
12113521Sgabeblack@google.com  private:
12213521Sgabeblack@google.com    void
12313521Sgabeblack@google.com    do_binding()
12413521Sgabeblack@google.com    {
12513521Sgabeblack@google.com        target_export(t2m.target_export);
12613521Sgabeblack@google.com        t2m.master_port(req_rsp.master_export);
12713521Sgabeblack@google.com
12813521Sgabeblack@google.com        get_request_export(req_rsp.get_request_export);
12913521Sgabeblack@google.com        put_response_export(req_rsp.put_response_export);
13013521Sgabeblack@google.com        slave_export(req_rsp.slave_export);
13113521Sgabeblack@google.com    }
13213521Sgabeblack@google.com
13313521Sgabeblack@google.com    tlm_req_rsp_channel<REQ, RSP, REQ_CHANNEL, RSP_CHANNEL> req_rsp;
13413521Sgabeblack@google.com    tlm_transport_to_master<REQ, RSP> t2m;
13513521Sgabeblack@google.com};
13613521Sgabeblack@google.com
13713521Sgabeblack@google.com} // namespace tlm
13813521Sgabeblack@google.com
13913521Sgabeblack@google.com#endif
14013521Sgabeblack@google.com/* __EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_HH__ */
141