Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / vendor / TLM-2006-11-29 / tlm / tlm_core / tlm_req_rsp / tlm_req_rsp_channels.h
CommitLineData
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#ifndef TLM_REQ_RSP_CHANNELS
20#define TLM_REQ_RSP_CHANNELS
21
22#include "tlm_core/tlm_adapters/tlm_adapters.h"
23#include "tlm_core/tlm_fifo/tlm_fifo.h"
24#include "tlm_core/tlm_req_rsp/tlm_put_get_imp.h"
25
26template < typename REQ , typename RSP ,
27 typename REQ_CHANNEL = tlm_fifo<REQ> ,
28 typename RSP_CHANNEL = tlm_fifo<RSP> >
29
30class tlm_req_rsp_channel : public sc_module
31{
32public:
33 // uni-directional slave interface
34
35 sc_export< tlm_fifo_get_if< REQ > > get_request_export;
36 sc_export< tlm_fifo_put_if< RSP > > put_response_export;
37
38 // uni-directional master interface
39
40 sc_export< tlm_fifo_put_if< REQ > > put_request_export;
41 sc_export< tlm_fifo_get_if< RSP > > get_response_export;
42
43 // master / slave interfaces
44
45 sc_export< tlm_master_if< REQ , RSP > > master_export;
46 sc_export< tlm_slave_if< REQ , RSP > > slave_export;
47
48
49 tlm_req_rsp_channel( int req_size = 1 , int rsp_size = 1 ) :
50 sc_module( sc_module_name( sc_gen_unique_name("tlm_req_rsp_channel") ) ) ,
51 request_fifo( req_size ) ,
52 response_fifo( rsp_size ) ,
53 master( request_fifo , response_fifo ) ,
54 slave( request_fifo , response_fifo )
55 {
56
57 bind_exports();
58
59 }
60
61 tlm_req_rsp_channel( sc_module_name module_name ,
62 int req_size = 1 , int rsp_size = 1 ) :
63 sc_module( module_name ) ,
64 request_fifo( req_size ) ,
65 response_fifo( rsp_size ) ,
66 master( request_fifo , response_fifo ) ,
67 slave( request_fifo , response_fifo )
68 {
69
70 bind_exports();
71
72 }
73
74private:
75 void bind_exports() {
76
77 put_request_export( request_fifo );
78 get_request_export( request_fifo );
79
80 put_response_export( response_fifo );
81 get_response_export( response_fifo );
82
83 master_export( master );
84 slave_export( slave );
85
86 }
87
88protected:
89 REQ_CHANNEL request_fifo;
90 RSP_CHANNEL response_fifo;
91
92 tlm_master_imp< REQ , RSP > master;
93 tlm_slave_imp< REQ , RSP > slave;
94};
95
96template < typename REQ , typename RSP ,
97 typename REQ_CHANNEL = tlm_fifo<REQ> ,
98 typename RSP_CHANNEL = tlm_fifo<RSP> >
99class tlm_transport_channel : public sc_module
100{
101public:
102
103 // master transport interface
104
105 sc_export< tlm_transport_if< REQ , RSP > > target_export;
106
107 // slave interfaces
108
109 sc_export< tlm_fifo_get_if< REQ > > get_request_export;
110 sc_export< tlm_fifo_put_if< RSP > > put_response_export;
111
112 sc_export< tlm_slave_if< REQ , RSP > > slave_export;
113
114 tlm_transport_channel() :
115 sc_module( sc_module_name( sc_gen_unique_name("transport_channel" ) ) ) ,
116 target_export("target_export") ,
117 req_rsp( "req_rsp" , 1 , 1 ) ,
118 t2m("ts2m")
119 {
120 do_binding();
121 }
122
123 tlm_transport_channel( sc_module_name nm ) :
124 sc_module( nm ) ,
125 target_export("target_export") ,
126 req_rsp( "req_rsp" , 1 , 1 ) ,
127 t2m("tsm" )
128 {
129 do_binding();
130 }
131
132private:
133 void do_binding() {
134
135 target_export( t2m.target_export );
136
137 t2m.master_port( req_rsp.master_export );
138
139 get_request_export( req_rsp.get_request_export );
140 put_response_export( req_rsp.put_response_export );
141 slave_export( req_rsp.slave_export );
142
143 }
144
145 tlm_req_rsp_channel< REQ , RSP , REQ_CHANNEL , RSP_CHANNEL > req_rsp;
146 tlm_transport_to_master< REQ , RSP > t2m;
147
148};
149#endif