Go to the documentation of this file.
42 #include "pybind11/pybind11.h"
43 #include "pybind11/stl.h"
62 namespace py = pybind11;
76 py::module_
m = py::module_::import(
"m5.SimObject");
77 auto f =
m.attr(
"resolveSimObject");
100 py::module_
m = m_native.def_submodule(
"drain");
102 py::enum_<DrainState>(
m,
"DrainState")
108 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
116 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
125 py::return_value_policy::reference)
132 py::module_
m = m_native.def_submodule(
"serialize");
134 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
138 py::class_<CheckpointIn>(
m,
"CheckpointIn")
145 py::module_
m = m_native.def_submodule(
"range");
147 py::class_<AddrRange>(
m,
"AddrRange")
149 .def(py::init<Addr &, Addr &>())
152 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
170 py::bind_vector<std::vector<AddrRange>>(
m,
"AddrRangeVector");
180 py::module_
m = m_native.def_submodule(
"net");
182 py::class_<Net::EthAddr>(
m,
"EthAddr")
184 .def(py::init<const std::string &>())
187 py::class_<Net::IpAddress>(
m,
"IpAddress")
189 .def(py::init<uint32_t>())
192 py::class_<Net::IpNetmask, Net::IpAddress>(
m,
"IpNetmask")
194 .def(py::init<uint32_t, uint8_t>())
197 py::class_<Net::IpWithPort, Net::IpAddress>(
m,
"IpWithPort")
199 .def(py::init<uint32_t, uint16_t>())
206 py::module_
m = m_native.def_submodule(
"loader");
214 py::module_ m_core = m_native.def_submodule(
"core");
216 py::class_<Cycles>(m_core,
"Cycles")
218 .def(py::init<uint64_t>())
219 .def(
"__int__", &Cycles::operator uint64_t)
220 .def(
"__add__", &Cycles::operator+)
221 .def(
"__sub__", &Cycles::operator-)
224 py::class_<Temperature>(m_core,
"Temperature")
226 .def(py::init<double>())
233 .def(py::self == py::self)
234 .def(py::self != py::self)
235 .def(py::self < py::self)
236 .def(py::self <= py::self)
237 .def(py::self > py::self)
238 .def(py::self >= py::self)
239 .def(py::self + py::self)
240 .def(py::self - py::self)
241 .def(py::self *
float())
242 .def(
float() * py::self)
243 .def(py::self /
float())
251 s <<
"Temperature(" <<
t.toKelvin() <<
")";
256 py::class_<tm>(m_core,
"tm")
257 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&
t); })
258 .def_readwrite(
"tm_sec", &tm::tm_sec)
259 .def_readwrite(
"tm_min", &tm::tm_min)
260 .def_readwrite(
"tm_hour", &tm::tm_hour)
261 .def_readwrite(
"tm_mday", &tm::tm_mday)
262 .def_readwrite(
"tm_mon", &tm::tm_mon)
263 .def_readwrite(
"tm_wday", &tm::tm_wday)
264 .def_readwrite(
"tm_yday", &tm::tm_yday)
265 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
268 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
284 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
296 m_core.attr(
"compileDate") = py::cast(
compileDate);
297 m_core.attr(
"gem5Version") = py::cast(
gem5Version);
299 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
300 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
301 m_core.attr(
"flag_NDEBUG") = py::cast(
flag_NDEBUG);
304 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
312 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
Base class to wrap object resolving functionality.
const FlagsType init
This Stat is Initialized.
void doExitCleanup()
Do C++ simulator exit processing.
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
@ Running
Running normally.
static Temperature fromCelsius(double _value)
bool tryDrain()
Try to drain the system.
bool interleaved() const
Determine if the range is interleaved or not.
void setClockFrequency(Tick tps)
constexpr double toCelsius() const
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
Addr end() const
Get the end address of the range.
bool isDrained() const
Check if the system is drained.
static Temperature fromFahrenheit(double _value)
void resume()
Resume normal simulation in a Drained system.
virtual void notifyFork()
Notify a child process of a fork.
static void setLevel(LogLevel ll)
The class stores temperatures in Kelvin and provides helper methods to convert to/from Celsius.
void setInterpDir(const std::string &dirname)
This is the interface for setting up a base path for the elf interpreter.
@ Drained
Buffers drained, ready for serialization/handover.
const bool flag_TRACING_ON
constexpr double toKelvin() const
PybindSimObjectResolver pybindSimObjectResolver
static void init_serialize(py::module_ &m_native)
static void unserializeGlobals(CheckpointIn &cp)
bool valid() const
Determine if the range is valid.
AddrRange RangeSize(Addr start, Addr size)
bool clockFrequencyFixed()
static void init_drain(py::module_ &m_native)
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
static void init_loader(py::module_ &m_native)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
SimObject * resolveSimObject(const std::string &name)
Find a SimObject given a full path name.
const std::string & name()
DrainState drainState() const
Return the current drain state of an object.
static DrainManager & instance()
Get the singleton DrainManager instance.
static bool allDisabled()
DrainState state() const
Get the simulators global drain state.
Resolve a SimObject name using the Pybind configuration.
uint64_t granularity() const
Determing the interleaving granularity of the range.
Addr start() const
Get the start address of the range.
std::string to_string() const
Get a string representation of the range.
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
double toFahrenheit() const
static void loopbackOnly()
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
static void serializeAll(const std::string &cpt_dir)
Serializes all the SimObjects.
AddrRange RangeEx(Addr start, Addr end)
static void init_range(py::module_ &m_native)
void setOutputDir(const std::string &dir)
Tick curTick()
The universal simulation clock.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
AddrRange RangeIn(Addr start, Addr end)
Addr size() const
Get the size of the address range.
void pybind_init_core(py::module_ &m_native)
static void init_net(py::module_ &m_native)
@ Draining
Draining buffers pending serialization/handover.
static Temperature fromKelvin(double _value)
Abstract superclass for simulation objects.
Generated on Tue Jun 22 2021 15:28:30 for gem5 by doxygen 1.8.17