gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
dramsys.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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.hh"
30
31namespace gem5
32{
33
34namespace memory
35{
36
40 config(::DRAMSys::Config::from_path(params.configuration,
41 params.resource_directory)),
43 params.name.c_str(), config, params.range)
44{
45 dramSysWrapper.dramsys->registerIdleCallback(
46 [this]
47 {
48 if (dramSysWrapper.dramsys->idle())
49 {
51 }
52 });
53}
54
55gem5::Port& DRAMSys::getPort(const std::string& if_name, PortID idx)
56{
57 if (if_name != "tlm")
58 {
59 return AbstractMemory::getPort(if_name, idx);
60 }
61
62 return tlmWrapper;
63}
64
70
72{
73 std::filesystem::path checkpointPath = CheckpointIn::dir();
74
75 auto topLevelObjects = sc_core::sc_get_top_level_objects();
76 for (auto const* object : topLevelObjects)
77 {
78 std::function<void(sc_core::sc_object const*)> serialize;
79 serialize =
80 [&serialize, &checkpointPath](sc_core::sc_object const* object)
81 {
82 auto const* serializableObject =
83 dynamic_cast<::DRAMSys::Serialize const*>(object);
84
85 if (serializableObject != nullptr)
86 {
87 std::string dumpFileName(object->name());
88 std::ofstream stream(checkpointPath / dumpFileName,
89 std::ios::binary);
90 serializableObject->serialize(stream);
91 }
92
93 for (auto const* childObject : object->get_child_objects())
94 {
95 serialize(childObject);
96 }
97 };
98
99 serialize(object);
100 }
101}
102
104{
105 std::filesystem::path checkpointPath = CheckpointIn::dir();
106
107 auto topLevelObjects = sc_core::sc_get_top_level_objects();
108 for (auto* object : topLevelObjects)
109 {
110 std::function<void(sc_core::sc_object*)> deserialize;
111 deserialize =
112 [&deserialize, &checkpointPath](sc_core::sc_object* object)
113 {
114 auto* deserializableObject =
115 dynamic_cast<::DRAMSys::Deserialize*>(object);
116
117 if (deserializableObject != nullptr)
118 {
119 std::string dumpFileName(object->name());
120 std::ifstream stream(checkpointPath / dumpFileName,
121 std::ios::binary);
122 deserializableObject->deserialize(stream);
123 }
124
125 for (auto* childObject : object->get_child_objects())
126 {
127 deserialize(childObject);
128 }
129 };
130
131 deserialize(object);
132 }
133}
134
135} // namespace memory
136} // namespace gem5
ClockedObjectParams Params
Parameters of ClockedObject.
virtual std::string name() const
Definition named.hh:60
Ports are used to interface objects to each other.
Definition port.hh:62
AbstractMemory(const AbstractMemory &)
sc_gem5::TlmTargetWrapper tlmWrapper
Definition dramsys.hh:46
gem5::Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
Definition dramsys.cc:55
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition dramsys.cc:65
DRAMSys(Params const &params)
Definition dramsys.cc:37
DRAMSysWrapper dramSysWrapper
Definition dramsys.hh:60
::DRAMSys::Config::Configuration config
Definition dramsys.hh:59
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition dramsys.cc:71
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition dramsys.cc:103
void signalDrainDone() const
Signal that an object is drained.
Definition drain.hh:305
DrainState
Object drain/handover states.
Definition drain.hh:75
@ Draining
Draining buffers pending serialization/handover.
Definition drain.hh:77
@ Drained
Buffers drained, ready for serialization/handover.
Definition drain.hh:78
static std::string dir()
Get the current checkout directory name.
Definition serialize.cc:157
const Params & params() const
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
std::ostream CheckpointOut
Definition serialize.hh:66
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
const std::vector< sc_object * > & sc_get_top_level_objects()
Definition sc_object.cc:161

Generated on Mon May 26 2025 09:19:11 for gem5 by doxygen 1.13.2