gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dramsys_wrapper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Fraunhofer IESE
3  * All rights reserved
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "dramsys_wrapper.hh"
30 
31 namespace gem5
32 {
33 
34 namespace memory
35 {
36 
39  DRAMSysConfiguration::Configuration const &config,
40  bool recordable,
41  AddrRange range) :
42  sc_core::sc_module(name),
43  dramsys(instantiateDRAMSys(recordable, config)),
44  range(range)
45 {
46  tSocket.register_nb_transport_fw(this, &DRAMSysWrapper::nb_transport_fw);
47  tSocket.register_transport_dbg(this, &DRAMSysWrapper::transport_dbg);
48  iSocket.register_nb_transport_bw(this, &DRAMSysWrapper::nb_transport_bw);
49  iSocket.bind(dramsys->tSocket);
50 
51  // Register a callback to compensate for the destructor not
52  // being called.
54  [this]()
55  {
56  // Workaround for BUG GEM5-1233
58  });
59 }
60 
61 std::shared_ptr<::DRAMSys>
63  bool recordable,
64  DRAMSysConfiguration::Configuration const &config)
65 {
66  return recordable
67  ? std::make_shared<::DRAMSysRecordable>("DRAMSys", config)
68  : std::make_shared<::DRAMSys>("DRAMSys", config);
69 }
70 
72  tlm::tlm_generic_payload &payload,
73  tlm::tlm_phase &phase,
74  sc_core::sc_time &fwDelay)
75 {
76  // Subtract base address offset
77  payload.set_address(payload.get_address() - range.start());
78 
79  return iSocket->nb_transport_fw(payload, phase, fwDelay);
80 }
81 
83  tlm::tlm_generic_payload &payload,
84  tlm::tlm_phase &phase,
85  sc_core::sc_time &bwDelay)
86 {
87  return tSocket->nb_transport_bw(payload, phase, bwDelay);
88 }
89 
91 {
92  // Subtract base address offset
93  trans.set_address(trans.get_address() - range.start());
94 
95  return iSocket->transport_dbg(trans);
96 }
97 
98 } // namespace memory
99 } // namespace gem5
gem5::memory::DRAMSysWrapper::range
AddrRange range
Definition: dramsys_wrapper.hh:84
gem5::AddrRange::start
Addr start() const
Get the start address of the range.
Definition: addr_range.hh:343
tlm::tlm_phase
Definition: phase.hh:47
memory
Definition: mem.h:38
sc_gem5::Kernel::stop
static void stop()
Definition: kernel.cc:143
sc_core
Definition: messages.cc:31
gem5::memory::DRAMSysWrapper::tSocket
tlm_utils::simple_target_socket< DRAMSysWrapper > tSocket
Definition: dramsys_wrapper.hh:80
dramsys_wrapper.hh
gem5::memory::DRAMSysWrapper::dramsys
std::shared_ptr<::DRAMSys > dramsys
Definition: dramsys_wrapper.hh:82
gem5::memory::DRAMSysWrapper::DRAMSysWrapper
DRAMSysWrapper(sc_core::sc_module_name name, DRAMSysConfiguration::Configuration const &config, bool recordable, AddrRange range)
Definition: dramsys_wrapper.cc:37
sc_core::sc_time
Definition: sc_time.hh:49
sc_core::sc_module_name
Definition: sc_module_name.hh:41
gem5::memory::DRAMSysWrapper::transport_dbg
unsigned int transport_dbg(tlm::tlm_generic_payload &trans)
Definition: dramsys_wrapper.cc:90
gem5::memory::DRAMSysWrapper::nb_transport_bw
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, sc_core::sc_time &bwDelay)
Definition: dramsys_wrapper.cc:82
name
const std::string & name()
Definition: trace.cc:48
tlm::tlm_generic_payload
Definition: gp.hh:133
tlm::tlm_generic_payload::set_address
void set_address(const sc_dt::uint64 address)
Definition: gp.hh:202
gem5::memory::DRAMSysWrapper::nb_transport_fw
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, sc_core::sc_time &fwDelay)
Definition: dramsys_wrapper.cc:71
tlm::tlm_sync_enum
tlm_sync_enum
Definition: fw_bw_ifs.hh:48
gem5::memory::DRAMSysWrapper::iSocket
tlm_utils::simple_initiator_socket< DRAMSysWrapper > iSocket
Definition: dramsys_wrapper.hh:79
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:81
gem5::registerExitCallback
void registerExitCallback(const std::function< void()> &callback)
Register an exit callback.
Definition: core.cc:143
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
tlm::tlm_generic_payload::get_address
sc_dt::uint64 get_address() const
Definition: gp.hh:201
gem5::memory::DRAMSysWrapper::instantiateDRAMSys
static std::shared_ptr<::DRAMSys > instantiateDRAMSys(bool recordable, DRAMSysConfiguration::Configuration const &config)
Definition: dramsys_wrapper.cc:62

Generated on Sun Jul 30 2023 01:56:58 for gem5 by doxygen 1.8.17