Go to the documentation of this file.
42 #include "pybind11/operators.h"
43 #include "pybind11/pybind11.h"
44 #include "pybind11/stl.h"
63 namespace py = pybind11;
80 py::module_
m = py::module_::import(
"m5.SimObject");
81 auto f =
m.attr(
"resolveSimObject");
92 py::module_
m = m_native.def_submodule(
"drain");
94 py::enum_<DrainState>(
m,
"DrainState")
100 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
108 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
117 py::return_value_policy::reference)
124 py::module_
m = m_native.def_submodule(
"serialize");
126 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
130 py::class_<CheckpointIn>(
m,
"CheckpointIn")
137 py::module_
m = m_native.def_submodule(
"range");
139 py::class_<AddrRange>(
m,
"AddrRange")
141 .def(py::init<Addr &, Addr &>())
144 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
170 py::module_
m = m_native.def_submodule(
"pc");
171 py::class_<PcCountPair>(
m,
"PcCountPair")
173 .def(py::init<Addr, int>())
174 .def(
"__eq__", [](
const PcCountPair&
self, py::object other) {
175 py::int_ pyPC = other.attr(
"get_pc")();
176 py::int_ pyCount = other.attr(
"get_count")();
177 uint64_t cPC = pyPC.cast<uint64_t>();
178 int cCount = pyCount.cast<
int>();
179 return (
self.getPC() == cPC &&
self.getCount() == cCount);
182 py::int_ pyPC = py::cast(
self.getPC());
183 py::int_ pyCount = py::cast(
self.getCount());
184 return py::hash(py::make_tuple(pyPC, pyCount));
195 py::module_
m = m_native.def_submodule(
"net");
197 py::class_<networking::EthAddr>(
m,
"EthAddr")
199 .def(py::init<const std::string &>())
202 py::class_<networking::IpAddress>(
m,
"IpAddress")
204 .def(py::init<uint32_t>())
207 py::class_<networking::IpNetmask, networking::IpAddress>(
m,
"IpNetmask")
209 .def(py::init<uint32_t, uint8_t>())
212 py::class_<networking::IpWithPort, networking::IpAddress>(
m,
"IpWithPort")
214 .def(py::init<uint32_t, uint16_t>())
221 py::module_
m = m_native.def_submodule(
"loader");
229 py::module_ m_socket = m_native.def_submodule(
"socket");
234 .def(
"listenSocketUnixAbstractConfig",
237 py::class_<ListenSocketConfig>(m_socket,
"ListenSocketConfig");
243 py::module_ m_core = m_native.def_submodule(
"core");
245 py::class_<Cycles>(m_core,
"Cycles")
247 .def(py::init<uint64_t>())
248 .def(
"__int__", &Cycles::operator uint64_t)
249 .def(
"__add__", &Cycles::operator+)
250 .def(
"__sub__", &Cycles::operator-)
253 py::class_<Temperature>(m_core,
"Temperature")
255 .def(py::init<double>())
262 .def(py::self == py::self)
263 .def(py::self != py::self)
264 .def(py::self < py::self)
265 .def(py::self <= py::self)
266 .def(py::self > py::self)
267 .def(py::self >= py::self)
268 .def(py::self + py::self)
269 .def(py::self - py::self)
270 .def(py::self *
float())
271 .def(
float() * py::self)
272 .def(py::self /
float())
280 s <<
"Temperature(" <<
t.toKelvin() <<
")";
285 py::class_<tm>(m_core,
"tm")
286 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&
t); })
287 .def_readwrite(
"tm_sec", &tm::tm_sec)
288 .def_readwrite(
"tm_min", &tm::tm_min)
289 .def_readwrite(
"tm_hour", &tm::tm_hour)
290 .def_readwrite(
"tm_mday", &tm::tm_mday)
291 .def_readwrite(
"tm_mon", &tm::tm_mon)
292 .def_readwrite(
"tm_wday", &tm::tm_wday)
293 .def_readwrite(
"tm_yday", &tm::tm_yday)
294 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
297 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
313 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
325 m_core.attr(
"compileDate") = py::cast(
compileDate);
326 m_core.attr(
"gem5Version") = py::cast(
gem5Version);
328 m_core.attr(
"TRACING_ON") = py::cast(TRACING_ON);
330 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
337 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
constexpr double toCelsius() const
static DrainManager & instance()
Get the singleton DrainManager instance.
Tick curTick()
The universal simulation clock.
static void init_pc(py::module_ &m_native)
std::string to_string() const
Get a string representation of the range.
std::string to_string() const
String format.
uint64_t granularity() const
Determing the interleaving granularity of the range.
Addr start() const
Get the start address of the range.
static void init_loader(py::module_ &m_native)
DrainState drainState() const
Return the current drain state of an object.
AddrRange RangeSize(Addr start, Addr size)
static void serializeAll(const std::string &cpt_dir)
Create a checkpoint by serializing all SimObjects in the system.
static void init_net(py::module_ &m_native)
static void init_serialize(py::module_ &m_native)
void setInterpDir(const std::string &dirname)
This is the interface for setting up a base path for the elf interpreter.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
ListenSocketConfig listenSocketUnixFileConfig(std::string dir, std::string fname)
virtual void notifyFork()
Notify a child process of a fork.
The class stores temperatures in Kelvin and provides helper methods to convert to/from Celsius.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
void pybind_init_core(py::module_ &m_native)
static void init_range(py::module_ &m_native)
AddrRange RangeIn(Addr start, Addr end)
void doExitCleanup()
Do C++ simulator exit processing.
AddrRange RangeEx(Addr start, Addr end)
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
ListenSocketConfig listenSocketInetConfig(int port)
static Temperature fromKelvin(double _value)
static Temperature fromFahrenheit(double _value)
bool interleaved() const
Determine if the range is interleaved or not.
Addr size() const
Get the size of the address range.
Addr end() const
Get the end address of the range.
bool valid() const
Determine if the range is valid.
bool clockFrequencyFixed()
static void init_socket(py::module_ &m_native)
SimObject * resolveSimObject(const std::string &name)
Find a SimObject given a full path name.
Abstract superclass for simulation objects.
@ Drained
Buffers drained, ready for serialization/handover.
constexpr double toKelvin() const
static bool allDisabled()
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
ListenSocketConfig listenSocketUnixAbstractConfig(std::string path)
const std::string & name()
static void init_drain(py::module_ &m_native)
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
bool tryDrain()
Try to drain the system.
PybindSimObjectResolver pybindSimObjectResolver
void resume()
Resume normal simulation in a Drained system.
void setOutputDir(const std::string &dir)
Resolve a SimObject name using the Pybind configuration.
bool isDrained() const
Check if the system is drained.
Base class to wrap object resolving functionality.
constexpr Addr getPC() const
Returns the Program Counter address.
void setClockFrequency(Tick tps)
static void setLevel(LogLevel ll)
AddrRangeList exclude(const AddrRangeList &exclude_ranges) const
Subtract a list of intervals from the range and return the resulting collection of ranges,...
static void loopbackOnly()
constexpr int getCount() const
Returns the count of the Program.
DrainState state() const
Get the simulators global drain state.
const FlagsType init
This Stat is Initialized.
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
@ Running
Running normally.
static Temperature fromCelsius(double _value)
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
static ListenSocketConfig listenSocketEmptyConfig()
double toFahrenheit() const
static void setSimObjectResolver(SimObjectResolver *resolver)
There is a single object name resolver, and it is only set when simulation is restoring from checkpoi...
@ Draining
Draining buffers pending serialization/handover.
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
Generated on Sun Jul 30 2023 01:56:59 for gem5 by doxygen 1.8.17