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    __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__
2213521Sgabeblack@google.com#define \
2313521Sgabeblack@google.com    __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__
2413521Sgabeblack@google.com
2513686Sgabeblack@google.com#include "../../interfaces/master_slave_ifs.hh"
2613521Sgabeblack@google.com
2713521Sgabeblack@google.comnamespace tlm
2813521Sgabeblack@google.com{
2913521Sgabeblack@google.com
3013521Sgabeblack@google.comtemplate <typename PUT_DATA, typename GET_DATA>
3113521Sgabeblack@google.comclass tlm_put_get_imp : private virtual tlm_put_if<PUT_DATA>,
3213521Sgabeblack@google.com  private virtual tlm_get_peek_if<GET_DATA>
3313521Sgabeblack@google.com{
3413521Sgabeblack@google.com  public:
3513521Sgabeblack@google.com    tlm_put_get_imp(tlm_put_if<PUT_DATA> &p, tlm_get_peek_if<GET_DATA> &g) :
3613521Sgabeblack@google.com        put_fifo(p), get_fifo(g)
3713521Sgabeblack@google.com    {}
3813521Sgabeblack@google.com
3913521Sgabeblack@google.com    // Put interface.
4013521Sgabeblack@google.com    void put(const PUT_DATA &t) { put_fifo.put(t); }
4113521Sgabeblack@google.com    bool nb_put(const PUT_DATA &t) { return put_fifo.nb_put(t); }
4213521Sgabeblack@google.com    bool
4313521Sgabeblack@google.com    nb_can_put(tlm_tag<PUT_DATA> *t=nullptr) const
4413521Sgabeblack@google.com    {
4513521Sgabeblack@google.com        return put_fifo.nb_can_put(t);
4613521Sgabeblack@google.com    }
4713521Sgabeblack@google.com    const sc_core::sc_event &
4813521Sgabeblack@google.com    ok_to_put(tlm_tag<PUT_DATA> *t=nullptr) const
4913521Sgabeblack@google.com    {
5013521Sgabeblack@google.com        return put_fifo.ok_to_put(t);
5113521Sgabeblack@google.com    }
5213521Sgabeblack@google.com
5313521Sgabeblack@google.com    // Get interface.
5413521Sgabeblack@google.com    GET_DATA get(tlm_tag<GET_DATA> * =nullptr) { return get_fifo.get(); }
5513521Sgabeblack@google.com    bool nb_get(GET_DATA &t) { return get_fifo.nb_get(t); }
5613521Sgabeblack@google.com    bool
5713521Sgabeblack@google.com    nb_can_get(tlm_tag<GET_DATA> *t=nullptr) const
5813521Sgabeblack@google.com    {
5913521Sgabeblack@google.com        return get_fifo.nb_can_get(t);
6013521Sgabeblack@google.com    }
6113521Sgabeblack@google.com
6213521Sgabeblack@google.com    virtual const sc_core::sc_event &
6313521Sgabeblack@google.com    ok_to_get(tlm_tag<GET_DATA> *t=nullptr) const
6413521Sgabeblack@google.com    {
6513521Sgabeblack@google.com        return get_fifo.ok_to_get(t);
6613521Sgabeblack@google.com    }
6713521Sgabeblack@google.com
6813521Sgabeblack@google.com    // Peek interface.
6913521Sgabeblack@google.com    GET_DATA
7013521Sgabeblack@google.com    peek(tlm_tag<GET_DATA> * =nullptr) const
7113521Sgabeblack@google.com    {
7213521Sgabeblack@google.com        return get_fifo.peek();
7313521Sgabeblack@google.com    }
7413521Sgabeblack@google.com    bool nb_peek(GET_DATA &t) const { return get_fifo.nb_peek(t); }
7513521Sgabeblack@google.com    bool
7613521Sgabeblack@google.com    nb_can_peek(tlm_tag<GET_DATA> *t=nullptr) const
7713521Sgabeblack@google.com    {
7813521Sgabeblack@google.com        return get_fifo.nb_can_peek(t);
7913521Sgabeblack@google.com    }
8013521Sgabeblack@google.com
8113521Sgabeblack@google.com    virtual const sc_core::sc_event &
8213521Sgabeblack@google.com    ok_to_peek(tlm_tag<GET_DATA> *t=nullptr) const
8313521Sgabeblack@google.com    {
8413521Sgabeblack@google.com        return get_fifo.ok_to_peek(t);
8513521Sgabeblack@google.com    }
8613521Sgabeblack@google.com
8713521Sgabeblack@google.com  private:
8813521Sgabeblack@google.com    tlm_put_if<PUT_DATA> &put_fifo;
8913521Sgabeblack@google.com    tlm_get_peek_if<GET_DATA> &get_fifo;
9013521Sgabeblack@google.com};
9113521Sgabeblack@google.com
9213521Sgabeblack@google.comtemplate <typename REQ, typename RSP>
9313521Sgabeblack@google.comclass tlm_master_imp : private tlm_put_get_imp<REQ, RSP>,
9413521Sgabeblack@google.com    public virtual tlm_master_if<REQ, RSP>
9513521Sgabeblack@google.com{
9613521Sgabeblack@google.com  public:
9713521Sgabeblack@google.com    tlm_master_imp(tlm_put_if<REQ> &req, tlm_get_peek_if<RSP> &rsp) :
9813521Sgabeblack@google.com        tlm_put_get_imp<REQ, RSP>(req, rsp)
9913521Sgabeblack@google.com    {}
10013521Sgabeblack@google.com};
10113521Sgabeblack@google.com
10213521Sgabeblack@google.comtemplate <typename REQ, typename RSP>
10313521Sgabeblack@google.comclass tlm_slave_imp : private tlm_put_get_imp<RSP, REQ>,
10413521Sgabeblack@google.com    public virtual tlm_slave_if<REQ, RSP>
10513521Sgabeblack@google.com{
10613521Sgabeblack@google.com  public:
10713521Sgabeblack@google.com    tlm_slave_imp(tlm_get_peek_if<REQ> &req, tlm_put_if<RSP> &rsp) :
10813521Sgabeblack@google.com        tlm_put_get_imp<RSP, REQ>(rsp, req)
10913521Sgabeblack@google.com    {}
11013521Sgabeblack@google.com};
11113521Sgabeblack@google.com
11213521Sgabeblack@google.com} // namespace tlm
11313521Sgabeblack@google.com
11413521Sgabeblack@google.com#endif
11513521Sgabeblack@google.com/*__SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__*/
116