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    __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__
22#define \
23    __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__
24
25#include "../../interfaces/master_slave_ifs.hh"
26
27namespace tlm
28{
29
30template <typename PUT_DATA, typename GET_DATA>
31class tlm_put_get_imp : private virtual tlm_put_if<PUT_DATA>,
32  private virtual tlm_get_peek_if<GET_DATA>
33{
34  public:
35    tlm_put_get_imp(tlm_put_if<PUT_DATA> &p, tlm_get_peek_if<GET_DATA> &g) :
36        put_fifo(p), get_fifo(g)
37    {}
38
39    // Put interface.
40    void put(const PUT_DATA &t) { put_fifo.put(t); }
41    bool nb_put(const PUT_DATA &t) { return put_fifo.nb_put(t); }
42    bool
43    nb_can_put(tlm_tag<PUT_DATA> *t=nullptr) const
44    {
45        return put_fifo.nb_can_put(t);
46    }
47    const sc_core::sc_event &
48    ok_to_put(tlm_tag<PUT_DATA> *t=nullptr) const
49    {
50        return put_fifo.ok_to_put(t);
51    }
52
53    // Get interface.
54    GET_DATA get(tlm_tag<GET_DATA> * =nullptr) { return get_fifo.get(); }
55    bool nb_get(GET_DATA &t) { return get_fifo.nb_get(t); }
56    bool
57    nb_can_get(tlm_tag<GET_DATA> *t=nullptr) const
58    {
59        return get_fifo.nb_can_get(t);
60    }
61
62    virtual const sc_core::sc_event &
63    ok_to_get(tlm_tag<GET_DATA> *t=nullptr) const
64    {
65        return get_fifo.ok_to_get(t);
66    }
67
68    // Peek interface.
69    GET_DATA
70    peek(tlm_tag<GET_DATA> * =nullptr) const
71    {
72        return get_fifo.peek();
73    }
74    bool nb_peek(GET_DATA &t) const { return get_fifo.nb_peek(t); }
75    bool
76    nb_can_peek(tlm_tag<GET_DATA> *t=nullptr) const
77    {
78        return get_fifo.nb_can_peek(t);
79    }
80
81    virtual const sc_core::sc_event &
82    ok_to_peek(tlm_tag<GET_DATA> *t=nullptr) const
83    {
84        return get_fifo.ok_to_peek(t);
85    }
86
87  private:
88    tlm_put_if<PUT_DATA> &put_fifo;
89    tlm_get_peek_if<GET_DATA> &get_fifo;
90};
91
92template <typename REQ, typename RSP>
93class tlm_master_imp : private tlm_put_get_imp<REQ, RSP>,
94    public virtual tlm_master_if<REQ, RSP>
95{
96  public:
97    tlm_master_imp(tlm_put_if<REQ> &req, tlm_get_peek_if<RSP> &rsp) :
98        tlm_put_get_imp<REQ, RSP>(req, rsp)
99    {}
100};
101
102template <typename REQ, typename RSP>
103class tlm_slave_imp : private tlm_put_get_imp<RSP, REQ>,
104    public virtual tlm_slave_if<REQ, RSP>
105{
106  public:
107    tlm_slave_imp(tlm_get_peek_if<REQ> &req, tlm_put_if<RSP> &rsp) :
108        tlm_put_get_imp<RSP, REQ>(rsp, req)
109    {}
110};
111
112} // namespace tlm
113
114#endif
115/*__SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_CHANNELS_REQ_RSP_CHANNELS_PUT_GET_IMP_HH__*/
116