Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /***************************************************************************** |
2 | ||
3 | The following code is derived, directly or indirectly, from the SystemC | |
4 | source code Copyright (c) 1996-2004 by all Contributors. | |
5 | All Rights reserved. | |
6 | ||
7 | The contents of this file are subject to the restrictions and limitations | |
8 | set forth in the SystemC Open Source License Version 2.4 (the "License"); | |
9 | You may not use this file except in compliance with such restrictions and | |
10 | limitations. You may obtain instructions on how to receive a copy of the | |
11 | License at http://www.systemc.org/. Software distributed by Contributors | |
12 | under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF | |
13 | ANY KIND, either express or implied. See the License for the specific | |
14 | language governing rights and limitations under the License. | |
15 | ||
16 | *****************************************************************************/ | |
17 | ||
18 | ||
19 | // | |
20 | // To the LRM writer : these classes are purely artifacts of the implementation. | |
21 | // | |
22 | ||
23 | #ifndef TLM_PUT_GET_IMP_HEADER | |
24 | #define TLM_PUT_GET_IMP_HEADER | |
25 | ||
26 | #include "tlm_core/tlm_interfaces/tlm_master_slave_ifs.h" | |
27 | ||
28 | template < typename PUT_DATA , typename GET_DATA> | |
29 | class tlm_put_get_imp : | |
30 | private virtual tlm_put_if< PUT_DATA > , | |
31 | private virtual tlm_get_peek_if< GET_DATA > | |
32 | { | |
33 | public: | |
34 | tlm_put_get_imp( tlm_put_if<PUT_DATA> &p , | |
35 | tlm_get_peek_if<GET_DATA> &g ) : | |
36 | put_fifo( p ) , get_fifo( g ) {} | |
37 | ||
38 | // put interface | |
39 | ||
40 | void put( const PUT_DATA &t ) { put_fifo.put( t ); } | |
41 | ||
42 | bool nb_put( const PUT_DATA &t ) { return put_fifo.nb_put( t ); } | |
43 | bool nb_can_put( tlm_tag<PUT_DATA> *t = 0 ) const { | |
44 | return put_fifo.nb_can_put( t ); | |
45 | } | |
46 | const sc_event &ok_to_put( tlm_tag<PUT_DATA> *t = 0 ) const { | |
47 | return put_fifo.ok_to_put( t ); | |
48 | } | |
49 | ||
50 | // get interface | |
51 | ||
52 | GET_DATA get( tlm_tag<GET_DATA> *t = 0 ) { return get_fifo.get(); } | |
53 | ||
54 | bool nb_get( GET_DATA &t ) { return get_fifo.nb_get( t ); } | |
55 | ||
56 | bool nb_can_get( tlm_tag<GET_DATA> *t = 0 ) const { | |
57 | return get_fifo.nb_can_get( t ); | |
58 | } | |
59 | ||
60 | virtual const sc_event &ok_to_get( tlm_tag<GET_DATA> *t = 0 ) const { | |
61 | return get_fifo.ok_to_get( t ); | |
62 | } | |
63 | ||
64 | // peek interface | |
65 | ||
66 | GET_DATA peek( tlm_tag<GET_DATA> *t = 0 ) const { return get_fifo.peek(); } | |
67 | ||
68 | bool nb_peek( GET_DATA &t ) const { return get_fifo.nb_peek( t ); } | |
69 | ||
70 | bool nb_can_peek( tlm_tag<GET_DATA> *t = 0 ) const { | |
71 | return get_fifo.nb_can_peek( t ); | |
72 | } | |
73 | ||
74 | virtual const sc_event &ok_to_peek( tlm_tag<GET_DATA> *t = 0 ) const { | |
75 | return get_fifo.ok_to_peek( t ); | |
76 | } | |
77 | ||
78 | private: | |
79 | tlm_put_if<PUT_DATA> &put_fifo; | |
80 | tlm_get_peek_if<GET_DATA> &get_fifo; | |
81 | }; | |
82 | ||
83 | template < typename REQ , typename RSP > | |
84 | class tlm_master_imp : | |
85 | private tlm_put_get_imp< REQ , RSP > , | |
86 | public virtual tlm_master_if< REQ , RSP > | |
87 | { | |
88 | public: | |
89 | ||
90 | tlm_master_imp( tlm_put_if<REQ> &req , | |
91 | tlm_get_peek_if<RSP> &rsp ) : | |
92 | tlm_put_get_imp<REQ,RSP>( req , rsp ) {} | |
93 | ||
94 | }; | |
95 | ||
96 | template < typename REQ , typename RSP > | |
97 | class tlm_slave_imp : | |
98 | private tlm_put_get_imp< RSP , REQ > , | |
99 | public virtual tlm_slave_if< REQ , RSP > | |
100 | { | |
101 | public: | |
102 | ||
103 | tlm_slave_imp( tlm_get_peek_if<REQ> &req , | |
104 | tlm_put_if<RSP> &rsp ) : | |
105 | tlm_put_get_imp<RSP,REQ>( rsp , req ) {} | |
106 | ||
107 | }; | |
108 | ||
109 | #endif |