gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
31namespace gem5
32{
33
34namespace memory
35{
36
39 ::DRAMSys::Config::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 iSocket.register_nb_transport_bw(this, &DRAMSysWrapper::nb_transport_bw);
48
49 tSocket.register_b_transport(this, &DRAMSysWrapper::b_transport);
50
51 tSocket.register_transport_dbg(this, &DRAMSysWrapper::transport_dbg);
52 iSocket.bind(dramsys->tSocket);
53
54 // Register a callback to compensate for the destructor not
55 // being called.
57 []()
58 {
59 // Workaround for BUG GEM5-1233
61 });
62}
63
64std::shared_ptr<::DRAMSys::DRAMSys>
66 bool recordable,
67 ::DRAMSys::Config::Configuration const &config)
68{
69 return recordable
70 ? std::make_shared<::DRAMSys::DRAMSysRecordable>("DRAMSys", config)
71 : std::make_shared<::DRAMSys::DRAMSys>("DRAMSys", config);
72}
73
76 sc_core::sc_time &delay)
77{
78 // Subtract base address offset
79 payload.set_address(payload.get_address() - range.start());
80
81 iSocket->b_transport(payload, delay);
82}
83
86 tlm::tlm_phase &phase,
87 sc_core::sc_time &fwDelay)
88{
89 // Subtract base address offset
90 payload.set_address(payload.get_address() - range.start());
91
92 return iSocket->nb_transport_fw(payload, phase, fwDelay);
93}
94
97 tlm::tlm_phase &phase,
98 sc_core::sc_time &bwDelay)
99{
100 return tSocket->nb_transport_bw(payload, phase, bwDelay);
101}
102
104{
105 // Subtract base address offset
106 trans.set_address(trans.get_address() - range.start());
107
108 return iSocket->transport_dbg(trans);
109}
110
111} // namespace memory
112} // namespace gem5
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, sc_core::sc_time &bwDelay)
DRAMSysWrapper(sc_core::sc_module_name name, ::DRAMSys::Config::Configuration const &config, bool recordable, AddrRange range)
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, sc_core::sc_time &fwDelay)
std::shared_ptr<::DRAMSys::DRAMSys > dramsys
tlm_utils::simple_initiator_socket< DRAMSysWrapper > iSocket
unsigned int transport_dbg(tlm::tlm_generic_payload &trans)
void b_transport(tlm::tlm_generic_payload &payload, sc_core::sc_time &delay)
tlm_utils::simple_target_socket< DRAMSysWrapper > tSocket
static std::shared_ptr<::DRAMSys::DRAMSys > instantiateDRAMSys(bool recordable, ::DRAMSys::Config::Configuration const &config)
static void stop()
Definition kernel.cc:143
void set_address(const sc_dt::uint64 address)
Definition gp.hh:185
sc_dt::uint64 get_address() const
Definition gp.hh:184
Addr start() const
Get the start address of the range.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
void registerExitCallback(const std::function< void()> &callback)
Register an exit callback.
Definition core.cc:143
tlm_sync_enum
Definition fw_bw_ifs.hh:31
Definition mem.h:38
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0