42 #include "pybind11/operators.h"
43 #include "pybind11/pybind11.h"
44 #include "pybind11/stl.h"
62 namespace py = pybind11;
79 py::module_
m = py::module_::import(
"m5.SimObject");
80 auto f =
m.attr(
"resolveSimObject");
91 py::module_
m = m_native.def_submodule(
"drain");
93 py::enum_<DrainState>(
m,
"DrainState")
99 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
107 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
116 py::return_value_policy::reference)
123 py::module_
m = m_native.def_submodule(
"serialize");
125 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
129 py::class_<CheckpointIn>(
m,
"CheckpointIn")
136 py::module_
m = m_native.def_submodule(
"range");
138 py::class_<AddrRange>(
m,
"AddrRange")
140 .def(py::init<Addr &, Addr &>())
143 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
169 py::module_
m = m_native.def_submodule(
"net");
171 py::class_<networking::EthAddr>(
m,
"EthAddr")
173 .def(py::init<const std::string &>())
176 py::class_<networking::IpAddress>(
m,
"IpAddress")
178 .def(py::init<uint32_t>())
181 py::class_<networking::IpNetmask, networking::IpAddress>(
m,
"IpNetmask")
183 .def(py::init<uint32_t, uint8_t>())
186 py::class_<networking::IpWithPort, networking::IpAddress>(
m,
"IpWithPort")
188 .def(py::init<uint32_t, uint16_t>())
195 py::module_
m = m_native.def_submodule(
"loader");
203 py::module_ m_core = m_native.def_submodule(
"core");
205 py::class_<Cycles>(m_core,
"Cycles")
207 .def(py::init<uint64_t>())
208 .def(
"__int__", &Cycles::operator uint64_t)
209 .def(
"__add__", &Cycles::operator+)
210 .def(
"__sub__", &Cycles::operator-)
213 py::class_<Temperature>(m_core,
"Temperature")
215 .def(py::init<double>())
222 .def(py::self == py::self)
223 .def(py::self != py::self)
224 .def(py::self < py::self)
225 .def(py::self <= py::self)
226 .def(py::self > py::self)
227 .def(py::self >= py::self)
228 .def(py::self + py::self)
229 .def(py::self - py::self)
230 .def(py::self *
float())
231 .def(
float() * py::self)
232 .def(py::self /
float())
240 s <<
"Temperature(" <<
t.toKelvin() <<
")";
245 py::class_<tm>(m_core,
"tm")
246 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&
t); })
247 .def_readwrite(
"tm_sec", &tm::tm_sec)
248 .def_readwrite(
"tm_min", &tm::tm_min)
249 .def_readwrite(
"tm_hour", &tm::tm_hour)
250 .def_readwrite(
"tm_mday", &tm::tm_mday)
251 .def_readwrite(
"tm_mon", &tm::tm_mon)
252 .def_readwrite(
"tm_wday", &tm::tm_wday)
253 .def_readwrite(
"tm_yday", &tm::tm_yday)
254 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
257 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
273 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
285 m_core.attr(
"compileDate") = py::cast(
compileDate);
286 m_core.attr(
"gem5Version") = py::cast(
gem5Version);
288 m_core.attr(
"TRACING_ON") = py::cast(TRACING_ON);
290 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
297 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
static DrainManager & instance()
Get the singleton DrainManager instance.
static void loopbackOnly()
static bool allDisabled()
static void setLevel(LogLevel ll)
Resolve a SimObject name using the Pybind configuration.
SimObject * resolveSimObject(const std::string &name)
Find a SimObject given a full path name.
Base class to wrap object resolving functionality.
Abstract superclass for simulation objects.
static void serializeAll(const std::string &cpt_dir)
Create a checkpoint by serializing all SimObjects in the system.
static void setSimObjectResolver(SimObjectResolver *resolver)
There is a single object name resolver, and it is only set when simulation is restoring from checkpoi...
The class stores temperatures in Kelvin and provides helper methods to convert to/from Celsius.
double toFahrenheit() const
static Temperature fromCelsius(double _value)
constexpr double toKelvin() const
constexpr double toCelsius() const
static Temperature fromFahrenheit(double _value)
static Temperature fromKelvin(double _value)
bool interleaved() const
Determine if the range is interleaved or not.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
AddrRange RangeEx(Addr start, Addr end)
AddrRange RangeSize(Addr start, Addr size)
uint64_t granularity() const
Determing the interleaving granularity of the range.
AddrRange RangeIn(Addr start, Addr end)
AddrRangeList exclude(const AddrRangeList &exclude_ranges) const
Subtract a list of intervals from the range and return the resulting collection of ranges,...
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
bool valid() const
Determine if the range is valid.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
Addr end() const
Get the end address of the range.
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
std::string to_string() const
Get a string representation of the range.
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
DrainState state() const
Get the simulators global drain state.
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
virtual void notifyFork()
Notify a child process of a fork.
void resume()
Resume normal simulation in a Drained system.
DrainState drainState() const
Return the current drain state of an object.
bool isDrained() const
Check if the system is drained.
bool tryDrain()
Try to drain the system.
@ Draining
Draining buffers pending serialization/handover.
@ Running
Running normally.
@ Drained
Buffers drained, ready for serialization/handover.
void setInterpDir(const std::string &dirname)
This is the interface for setting up a base path for the elf interpreter.
const FlagsType init
This Stat is Initialized.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
static void init_drain(py::module_ &m_native)
Tick curTick()
The universal simulation clock.
void pybind_init_core(py::module_ &m_native)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool clockFrequencyFixed()
static void init_loader(py::module_ &m_native)
void setOutputDir(const std::string &dir)
PybindSimObjectResolver pybindSimObjectResolver
void setClockFrequency(Tick tps)
void doExitCleanup()
Do C++ simulator exit processing.
static void init_net(py::module_ &m_native)
static void init_serialize(py::module_ &m_native)
static void init_range(py::module_ &m_native)
const std::string & name()