42 #include "pybind11/pybind11.h" 43 #include "pybind11/stl.h" 61 namespace py = pybind11;
75 py::module
m = py::module::import(
"m5.SimObject");
76 auto f = m.attr(
"resolveSimObject");
99 py::module
m = m_native.def_submodule(
"drain");
101 py::enum_<DrainState>(
m,
"DrainState")
107 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
115 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
124 py::return_value_policy::reference)
131 py::module
m = m_native.def_submodule(
"serialize");
133 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
137 py::class_<CheckpointIn>(
m,
"CheckpointIn")
144 py::module
m = m_native.def_submodule(
"range");
146 py::class_<AddrRange>(
m,
"AddrRange")
148 .def(py::init<Addr &, Addr &>())
151 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
169 py::bind_vector<std::vector<AddrRange>>(
m,
"AddrRangeVector");
179 py::module
m = m_native.def_submodule(
"net");
181 py::class_<Net::EthAddr>(
m,
"EthAddr")
183 .def(py::init<const std::string &>())
186 py::class_<Net::IpAddress>(
m,
"IpAddress")
188 .def(py::init<uint32_t>())
191 py::class_<Net::IpNetmask, Net::IpAddress>(
m,
"IpNetmask")
193 .def(py::init<uint32_t, uint8_t>())
196 py::class_<Net::IpWithPort, Net::IpAddress>(
m,
"IpWithPort")
198 .def(py::init<uint32_t, uint16_t>())
205 py::module
m = m_native.def_submodule(
"loader");
213 py::module m_core = m_native.def_submodule(
"core");
215 py::class_<Cycles>(m_core,
"Cycles")
217 .def(py::init<uint64_t>())
218 .def(
"__int__", &Cycles::operator uint64_t)
219 .def(
"__add__", &Cycles::operator+)
220 .def(
"__sub__", &Cycles::operator-)
223 py::class_<tm>(m_core,
"tm")
224 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&t); })
225 .def_readwrite(
"tm_sec", &tm::tm_sec)
226 .def_readwrite(
"tm_min", &tm::tm_min)
227 .def_readwrite(
"tm_hour", &tm::tm_hour)
228 .def_readwrite(
"tm_mday", &tm::tm_mday)
229 .def_readwrite(
"tm_mon", &tm::tm_mon)
230 .def_readwrite(
"tm_wday", &tm::tm_wday)
231 .def_readwrite(
"tm_yday", &tm::tm_yday)
232 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
235 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
251 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
263 m_core.attr(
"compileDate") = py::cast(
compileDate);
264 m_core.attr(
"gem5Version") = py::cast(
gem5Version);
266 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
267 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
268 m_core.attr(
"flag_NDEBUG") = py::cast(
flag_NDEBUG);
271 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
279 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
280 return new CheckpointIn(cpt_dir, pybindSimObjectResolver);
AddrRange RangeSize(Addr start, Addr size)
void pybind_init_core(py::module &m_native)
const std::string & name()
static void init_serialize(py::module &m_native)
uint64_t granularity() const
Determing the interleaving granularity of the range.
void doExitCleanup()
Do C++ simulator exit processing.
bool tryDrain()
Try to drain the system.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
virtual void notifyFork()
Notify a child process of a fork.
void setClockFrequency(Tick tps)
Resolve a SimObject name using the Pybind configuration.
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
PybindSimObjectResolver pybindSimObjectResolver
void setInterpDir(const std::string &dirname)
This is the interface for setting up a base path for the elf interpreter.
static void init_loader(py::module &m_native)
Base class to wrap object resolving functionality.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
static void init_range(py::module &m_native)
bool valid() const
Determine if the range is valid.
static void setLevel(LogLevel ll)
DrainState drainState() const
Return the current drain state of an object.
void setOutputDir(const string &dir)
const bool flag_TRACING_ON
DrainState state() const
Get the simulators global drain state.
Draining buffers pending serialization/handover.
Tick curTick()
The current simulated tick.
static void unserializeGlobals(CheckpointIn &cp)
static bool allDisabled()
Addr end() const
Get the end address of the range.
bool clockFrequencyFixed()
static void loopbackOnly()
AddrRange RangeIn(Addr start, Addr end)
bool isDrained() const
Check if the system is drained.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void resume()
Resume normal simulation in a Drained system.
static void init_drain(py::module &m_native)
AddrRange RangeEx(Addr start, Addr end)
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
bool interleaved() const
Determine if the range is interleaved or not.
static DrainManager & instance()
Get the singleton DrainManager instance.
SimObject * resolveSimObject(const std::string &name)
Find a SimObject given a full path name.
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
static void serializeAll(const std::string &cpt_dir)
std::string to_string() const
Get a string representation of the range.
static void init_net(py::module &m_native)
Abstract superclass for simulation objects.
const FlagsType init
This Stat is Initialized.