gem5  v20.1.0.0
adapters.hh
Go to the documentation of this file.
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 __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_HH__
21 #define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_HH__
22 
23 #include "../interfaces/master_slave_ifs.hh"
24 
25 namespace tlm
26 {
27 
28 template <typename REQ, typename RSP>
29 class tlm_transport_to_master : public sc_core::sc_module,
30  public virtual tlm_transport_if<REQ, RSP>
31 {
32  public:
35 
37  sc_core::sc_module(nm)
38  {
39  target_export( *this );
40  }
41 
43  sc_core::sc_module(sc_core::sc_module_name(
44  sc_core::sc_gen_unique_name("transport_to_master")))
45  {
46  target_export( *this );
47  }
48 
49  RSP
50  transport(const REQ &req)
51  {
52  mutex.lock();
53  master_port->put(req);
54  rsp = master_port->get();
55 
56  mutex.unlock();
57  return rsp;
58  }
59 
60  private:
62  RSP rsp;
63 };
64 
65 template <typename REQ, typename RSP>
66 class tlm_slave_to_transport : public sc_core::sc_module
67 {
68  public:
70 
73 
75  sc_core::sc_module(nm)
76  {}
77 
79  sc_core::sc_module(sc_core::sc_module_name(
80  sc_core::sc_gen_unique_name("slave_to_transport")))
81  {}
82 
83  private:
84  void
85  run()
86  {
87  REQ req;
88  RSP rsp;
89 
90  while (true) {
91  slave_port->get(req);
92  rsp = initiator_port->transport(req);
93  slave_port->put(rsp);
94  }
95  }
96 };
97 
98 } // namespace tlm
99 
100 #endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_ADAPTERS_HH__ */
tlm::tlm_slave_to_transport::run
void run()
Definition: adapters.hh:102
tlm::tlm_slave_to_transport::SC_HAS_PROCESS
SC_HAS_PROCESS(tlm_slave_to_transport)
sc_core::sc_module
Definition: sc_module.hh:97
sc_core::sc_port
Definition: sc_port.hh:249
sc_core
Definition: messages.cc:31
tlm::tlm_transport_to_master::transport
RSP transport(const REQ &req)
Definition: adapters.hh:84
sc_core::sc_module::sc_module
sc_module()
Definition: sc_module.cc:256
tlm::tlm_slave_to_transport
Definition: adapters.hh:83
tlm::tlm_transport_to_master::tlm_transport_to_master
tlm_transport_to_master()
Definition: adapters.hh:76
tlm::tlm_transport_to_master::rsp
RSP rsp
Definition: adapters.hh:96
tlm::tlm_transport_to_master::master_port
sc_core::sc_port< tlm_master_if< REQ, RSP > > master_port
Definition: adapters.hh:68
tlm::tlm_transport_to_master::target_export
sc_core::sc_export< tlm_transport_if< REQ, RSP > > target_export
Definition: adapters.hh:67
tlm::tlm_transport_to_master::mutex
sc_core::sc_mutex mutex
Definition: adapters.hh:95
sc_core::sc_module_name
Definition: sc_module_name.hh:41
sc_core::sc_gen_unique_name
const char * sc_gen_unique_name(const char *seed)
Definition: sc_module.cc:820
tlm
Definition: analysis_fifo.hh:27
tlm::tlm_slave_to_transport::initiator_port
sc_core::sc_port< tlm_transport_if< REQ, RSP > > initiator_port
Definition: adapters.hh:89
tlm::tlm_slave_to_transport::tlm_slave_to_transport
tlm_slave_to_transport()
Definition: adapters.hh:95
sc_core::sc_mutex
Definition: sc_mutex.hh:39
tlm::tlm_slave_to_transport::slave_port
sc_core::sc_port< tlm_slave_if< REQ, RSP > > slave_port
Definition: adapters.hh:88
sc_core::sc_mutex::unlock
virtual int unlock()
Definition: sc_mutex.cc:61
sc_core::sc_mutex::lock
virtual int lock()
Definition: sc_mutex.cc:44
sc_core::sc_export
Definition: sc_export.hh:60

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17