47 #include "pybind11/pybind11.h"
64 namespace py = pybind11;
78 py::module
m = py::module::import(
"m5.SimObject");
79 auto f = m.attr(
"resolveSimObject");
101 py::module
m = m_native.def_submodule(
"drain");
103 py::enum_<DrainState>(
m,
"DrainState")
109 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
117 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
126 py::return_value_policy::reference)
133 py::module
m = m_native.def_submodule(
"serialize");
135 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
139 py::class_<CheckpointIn>(
m,
"CheckpointIn")
146 py::module
m = m_native.def_submodule(
"range");
148 py::class_<AddrRange>(
m,
"AddrRange")
150 .def(py::init<Addr &, Addr &>())
152 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
171 py::bind_vector<std::vector<AddrRange>>(
m,
"AddrRangeVector");
181 py::module
m = m_native.def_submodule(
"net");
183 py::class_<Net::EthAddr>(
m,
"EthAddr")
185 .def(py::init<const std::string &>())
188 py::class_<Net::IpAddress>(
m,
"IpAddress")
190 .def(py::init<uint32_t>())
193 py::class_<Net::IpNetmask, Net::IpAddress>(
m,
"IpNetmask")
195 .def(py::init<uint32_t, uint8_t>())
198 py::class_<Net::IpWithPort, Net::IpAddress>(
m,
"IpWithPort")
200 .def(py::init<uint32_t, uint16_t>())
207 py::module m_core = m_native.def_submodule(
"core");
209 py::class_<Cycles>(m_core,
"Cycles")
211 .def(py::init<uint64_t>())
212 .def(
"__int__", &Cycles::operator uint64_t)
213 .def(
"__add__", &Cycles::operator+)
214 .def(
"__sub__", &Cycles::operator-)
217 py::class_<tm>(m_core,
"tm")
218 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&t); })
219 .def_readwrite(
"tm_sec", &tm::tm_sec)
220 .def_readwrite(
"tm_min", &tm::tm_min)
221 .def_readwrite(
"tm_hour", &tm::tm_hour)
222 .def_readwrite(
"tm_mday", &tm::tm_mday)
223 .def_readwrite(
"tm_mon", &tm::tm_mon)
224 .def_readwrite(
"tm_wday", &tm::tm_wday)
225 .def_readwrite(
"tm_yday", &tm::tm_yday)
226 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
229 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
245 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
253 m_core.attr(
"compileDate") = py::cast(
compileDate);
255 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
256 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
257 m_core.attr(
"flag_NDEBUG") = py::cast(
flag_NDEBUG);
260 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
268 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
269 return new CheckpointIn(cpt_dir, pybindSimObjectResolver);
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
static void unserializeGlobals(CheckpointIn &cp)
AddrRange RangeSize(Addr start, Addr size)
void pybind_init_core(py::module &m_native)
uint64_t granularity() const
Determing the interleaving granularity of the range.
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
bool hashed() const
Determine if the range interleaving is hashed or not.
Addr start() const
Get the start address of the range.
const std::string & name()
bool interleaved() const
Determine if the range is interleaved or not.
static void init_serialize(py::module &m_native)
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
void doExitCleanup()
Do C++ simulator exit processing.
Resolve a SimObject name using the Pybind configuration.
PybindSimObjectResolver pybindSimObjectResolver
Base class to wrap object resolving functionality.
static void init_range(py::module &m_native)
void setOutputDir(const string &dir)
const bool flag_TRACING_ON
Tick curTick()
The current simulated tick.
bool valid() const
Determine if the range is valid.
static bool allDisabled()
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
DrainState state() const
Get the simulators global drain state.
std::string to_string() const
Get a string representation of the range.
static void loopbackOnly()
AddrRange RangeIn(Addr start, Addr end)
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
Draining buffers pending serialization/handover.
static void init_drain(py::module &m_native)
bool tryDrain()
Try to drain the system.
AddrRange RangeEx(Addr start, Addr end)
Addr end() const
Get the end address of the range.
bool isDrained() const
Check if the system is drained.
virtual void notifyFork()
Notify a child process of a fork.
static DrainManager & instance()
Get the singleton DrainManager instance.
void setClockFrequency(Tick ticksPerSecond)
void resume()
Resume normal simulation in a Drained system.
SimObject * resolveSimObject(const std::string &name)
DrainState drainState() const
Return the current drain state of an object.
static void init_net(py::module &m_native)
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
static void setLevel(LogLevel ll)
Set the active log level.
Addr size() const
Get the size of the address range.
Abstract superclass for simulation objects.
const FlagsType init
This Stat is Initialized.
static void serializeAll(const std::string &cpt_dir)