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