misc: Merge branch 'release-staging-v21-2' into develop
Change-Id: Icc03e585d87cf89ed844a0249c365cc296fa2d14
This commit is contained in:
@@ -149,13 +149,21 @@ class SimObject(PySource):
|
||||
enums = dict()
|
||||
tags = dict()
|
||||
|
||||
def __init__(self, source, *, sim_objects=[], enums=[],
|
||||
def __init__(self, source, *, sim_objects=None, enums=None,
|
||||
tags=None, add_tags=None):
|
||||
'''Specify the source file and any tags (automatically in
|
||||
the m5.objects package)'''
|
||||
if sim_objects is None:
|
||||
if enums is None:
|
||||
error(f"SimObject({source}...) must list c++ sim_objects or "
|
||||
"enums (set either to [] if there are none).")
|
||||
sim_objects = []
|
||||
if enums is None:
|
||||
enums = []
|
||||
|
||||
super().__init__('m5.objects', source, tags, add_tags)
|
||||
if self.fixed:
|
||||
raise AttributeError("Too late to call SimObject now.")
|
||||
error("Too late to call SimObject now.")
|
||||
|
||||
SimObject.sim_objects[self.modpath] = sim_objects
|
||||
SimObject.enums[self.modpath] = enums
|
||||
|
||||
@@ -32,7 +32,7 @@ Import('*')
|
||||
|
||||
if 'O3CPU' in env['CPU_MODELS']:
|
||||
SimObject('FUPool.py', sim_objects=['FUPool'])
|
||||
SimObject('FuncUnitConfig.py')
|
||||
SimObject('FuncUnitConfig.py', sim_objects=[])
|
||||
SimObject('O3CPU.py', sim_objects=['O3CPU'], enums=[
|
||||
'SMTFetchPolicy', 'SMTQueuePolicy', 'CommitPolicy'])
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Source('isa_fake.cc')
|
||||
Source('dma_device.cc')
|
||||
Source('dma_virt_device.cc')
|
||||
|
||||
SimObject('IntPin.py')
|
||||
SimObject('IntPin.py', sim_objects=[])
|
||||
Source('intpin.cc')
|
||||
|
||||
DebugFlag('IsaFake')
|
||||
|
||||
@@ -60,28 +60,11 @@ main(int argc, char **argv)
|
||||
// It's probably not necessary, but is mostly harmless and might be useful.
|
||||
Py_SetProgramName(program.get());
|
||||
|
||||
py::scoped_interpreter guard;
|
||||
py::scoped_interpreter guard(true, argc, argv);
|
||||
|
||||
auto importer = py::module_::import("importer");
|
||||
importer.attr("install")();
|
||||
|
||||
// Embedded python doesn't set up sys.argv, so we'll do that ourselves.
|
||||
py::list py_argv;
|
||||
auto sys = py::module::import("sys");
|
||||
if (py::hasattr(sys, "argv")) {
|
||||
// sys.argv already exists, so grab that.
|
||||
py_argv = sys.attr("argv");
|
||||
} else {
|
||||
// sys.argv doesn't exist, so create it.
|
||||
sys.add_object("argv", py_argv);
|
||||
}
|
||||
// Clear out argv just in case it has something in it.
|
||||
py_argv.attr("clear")();
|
||||
|
||||
// Fill it with our argvs.
|
||||
for (int i = 0; i < argc; i++)
|
||||
py_argv.append(argv[i]);
|
||||
|
||||
try {
|
||||
py::module_::import("m5").attr("main")();
|
||||
} catch (py::error_already_set &e) {
|
||||
|
||||
@@ -32,4 +32,4 @@ env.UseSystemcCheck(warn=True)
|
||||
|
||||
env.Append(CPPPATH=Dir('ext'))
|
||||
|
||||
SimObject('Tlm.py')
|
||||
SimObject('Tlm.py', sim_objects=[])
|
||||
|
||||
@@ -63,11 +63,3 @@ class SystemC_ScModule(SystemC_ScObject):
|
||||
@cxxMethod(return_value_policy="reference", cxx_name="gem5_getPort")
|
||||
def getPort(self, if_name, iex):
|
||||
return None
|
||||
|
||||
try:
|
||||
import _m5
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
import _m5.systemc
|
||||
_m5.systemc.python_ready()
|
||||
|
||||
@@ -38,13 +38,6 @@ namespace sc_gem5
|
||||
namespace
|
||||
{
|
||||
|
||||
PythonReadyFunc *&
|
||||
firstReadyFunc()
|
||||
{
|
||||
static PythonReadyFunc *first = nullptr;
|
||||
return first;
|
||||
}
|
||||
|
||||
PythonInitFunc *&
|
||||
firstInitFunc()
|
||||
{
|
||||
@@ -52,33 +45,31 @@ firstInitFunc()
|
||||
return first;
|
||||
}
|
||||
|
||||
void
|
||||
python_ready(pybind11::args args)
|
||||
{
|
||||
for (auto ptr = firstReadyFunc(); ptr; ptr = ptr->next)
|
||||
ptr->run();
|
||||
}
|
||||
bool python_initialized = false;
|
||||
|
||||
void
|
||||
systemc_pybind(pybind11::module_ &m_internal)
|
||||
{
|
||||
pybind11::module_ m = m_internal.def_submodule("systemc");
|
||||
m.def("python_ready", &python_ready);
|
||||
for (auto ptr = firstInitFunc(); ptr; ptr = ptr->next)
|
||||
ptr->run(m);
|
||||
ptr->callback(m);
|
||||
|
||||
python_initialized = true;
|
||||
}
|
||||
gem5::EmbeddedPyBind embed_("systemc", &systemc_pybind);
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
PythonReadyFunc::PythonReadyFunc() : next(firstReadyFunc())
|
||||
{
|
||||
firstReadyFunc() = this;
|
||||
}
|
||||
|
||||
PythonInitFunc::PythonInitFunc() : next(firstInitFunc())
|
||||
PythonInitFunc::PythonInitFunc(Callback run) :
|
||||
callback(run), next(firstInitFunc())
|
||||
{
|
||||
firstInitFunc() = this;
|
||||
|
||||
// If the python was already initialized, run the callback immediately.
|
||||
if (python_initialized) {
|
||||
auto systemc_module = pybind11::module_::import("_m5.systemc");
|
||||
callback(systemc_module);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sc_gem5
|
||||
|
||||
@@ -33,22 +33,14 @@
|
||||
namespace sc_gem5
|
||||
{
|
||||
|
||||
struct PythonReadyFunc
|
||||
{
|
||||
PythonReadyFunc *next;
|
||||
|
||||
PythonReadyFunc();
|
||||
~PythonReadyFunc() {}
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
struct PythonInitFunc
|
||||
{
|
||||
using Callback = void(*)(pybind11::module_ &systemc);
|
||||
Callback callback;
|
||||
|
||||
PythonInitFunc *next;
|
||||
|
||||
PythonInitFunc();
|
||||
~PythonInitFunc() {}
|
||||
virtual void run(pybind11::module_ &systemc) = 0;
|
||||
PythonInitFunc(Callback run);
|
||||
};
|
||||
|
||||
} // namespace sc_gem5
|
||||
|
||||
@@ -92,15 +92,10 @@ sc_main_result_str()
|
||||
// Make our sc_main wrapper available in the internal _m5 python module under
|
||||
// the systemc submodule.
|
||||
|
||||
struct InstallScMain : public ::sc_gem5::PythonInitFunc
|
||||
{
|
||||
void
|
||||
run(pybind11::module_ &systemc) override
|
||||
{
|
||||
systemc.def("sc_main", &sc_main);
|
||||
systemc.def("sc_main_result_code", &sc_main_result_code);
|
||||
systemc.def("sc_main_result_str", &sc_main_result_str);
|
||||
}
|
||||
} installScMain;
|
||||
::sc_gem5::PythonInitFunc installScMain([](pybind11::module_ &systemc) {
|
||||
systemc.def("sc_main", &sc_main);
|
||||
systemc.def("sc_main_result_code", &sc_main_result_code);
|
||||
systemc.def("sc_main_result_str", &sc_main_result_str);
|
||||
});
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@@ -33,48 +33,43 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
struct InstallScTime : public ::sc_gem5::PythonInitFunc
|
||||
{
|
||||
void
|
||||
run(pybind11::module_ &systemc) override
|
||||
{
|
||||
pybind11::class_<sc_core::sc_time> sc_time(systemc, "sc_time");
|
||||
sc_time
|
||||
// Constructors (omitting nonstandard and deprecated)
|
||||
.def(pybind11::init<>())
|
||||
.def(pybind11::init<double, sc_core::sc_time_unit>())
|
||||
.def(pybind11::init<const sc_core::sc_time &>())
|
||||
::sc_gem5::PythonInitFunc installScTime([](pybind11::module_ &systemc) {
|
||||
pybind11::class_<sc_core::sc_time> sc_time(systemc, "sc_time");
|
||||
sc_time
|
||||
// Constructors (omitting nonstandard and deprecated)
|
||||
.def(pybind11::init<>())
|
||||
.def(pybind11::init<double, sc_core::sc_time_unit>())
|
||||
.def(pybind11::init<const sc_core::sc_time &>())
|
||||
|
||||
// Converters.
|
||||
.def("value", &sc_core::sc_time::value)
|
||||
.def("to_double", &sc_core::sc_time::to_double)
|
||||
.def("to_seconds", &sc_core::sc_time::to_seconds)
|
||||
.def("to_string", &sc_core::sc_time::to_string)
|
||||
.def("__str__", &sc_core::sc_time::to_string)
|
||||
// Converters.
|
||||
.def("value", &sc_core::sc_time::value)
|
||||
.def("to_double", &sc_core::sc_time::to_double)
|
||||
.def("to_seconds", &sc_core::sc_time::to_seconds)
|
||||
.def("to_string", &sc_core::sc_time::to_string)
|
||||
.def("__str__", &sc_core::sc_time::to_string)
|
||||
|
||||
// Operators.
|
||||
.def(pybind11::self == pybind11::self)
|
||||
.def(pybind11::self != pybind11::self)
|
||||
.def(pybind11::self < pybind11::self)
|
||||
.def(pybind11::self <= pybind11::self)
|
||||
.def(pybind11::self > pybind11::self)
|
||||
.def(pybind11::self >= pybind11::self)
|
||||
.def(pybind11::self += pybind11::self)
|
||||
.def(pybind11::self -= pybind11::self)
|
||||
.def(pybind11::self *= double())
|
||||
.def(pybind11::self /= double())
|
||||
;
|
||||
// Operators.
|
||||
.def(pybind11::self == pybind11::self)
|
||||
.def(pybind11::self != pybind11::self)
|
||||
.def(pybind11::self < pybind11::self)
|
||||
.def(pybind11::self <= pybind11::self)
|
||||
.def(pybind11::self > pybind11::self)
|
||||
.def(pybind11::self >= pybind11::self)
|
||||
.def(pybind11::self += pybind11::self)
|
||||
.def(pybind11::self -= pybind11::self)
|
||||
.def(pybind11::self *= double())
|
||||
.def(pybind11::self /= double())
|
||||
;
|
||||
|
||||
pybind11::enum_<sc_core::sc_time_unit>(sc_time, "sc_time_unit")
|
||||
.value("SC_FS", sc_core::SC_FS)
|
||||
.value("SC_PS", sc_core::SC_PS)
|
||||
.value("SC_NS", sc_core::SC_NS)
|
||||
.value("SC_US", sc_core::SC_US)
|
||||
.value("SC_MS", sc_core::SC_MS)
|
||||
.value("SC_SEC", sc_core::SC_SEC)
|
||||
.export_values()
|
||||
;
|
||||
}
|
||||
} installScTime;
|
||||
pybind11::enum_<sc_core::sc_time_unit>(sc_time, "sc_time_unit")
|
||||
.value("SC_FS", sc_core::SC_FS)
|
||||
.value("SC_PS", sc_core::SC_PS)
|
||||
.value("SC_NS", sc_core::SC_NS)
|
||||
.value("SC_US", sc_core::SC_US)
|
||||
.value("SC_MS", sc_core::SC_MS)
|
||||
.value("SC_SEC", sc_core::SC_SEC)
|
||||
.export_values()
|
||||
;
|
||||
});
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@@ -63,7 +63,8 @@ if env['USE_SYSTEMC'] and GetOption('with_systemc_tests'):
|
||||
test_dir = Dir('.')
|
||||
class SystemCTestBin(Executable):
|
||||
def __init__(self, test):
|
||||
super().__init__(test.target, *test.sources)
|
||||
all_sources = test.sources + [with_tag('main')]
|
||||
super().__init__(test.target, *all_sources)
|
||||
self.reldir = test.reldir
|
||||
self.test_deps = test.deps
|
||||
|
||||
@@ -78,26 +79,16 @@ if env['USE_SYSTEMC'] and GetOption('with_systemc_tests'):
|
||||
|
||||
env.Append(CPPPATH=test_dir.Dir('include'))
|
||||
|
||||
shared_lib_path = env['SHARED_LIB'][0].abspath
|
||||
sl_dir, sl_base = os.path.split(shared_lib_path)
|
||||
env.Append(LIBPATH=[sl_dir], LIBS=[sl_base])
|
||||
env.Append(LIBPATH=['${BUILDDIR}'], LIBS=['gem5_${ENV_LABEL}'])
|
||||
env.AddLocalRPATH('${BUILDDIR}')
|
||||
|
||||
env['OBJSUFFIX'] = '.sc' + env['OBJSUFFIX'][1:]
|
||||
env['SHOBJSUFFIX'] = '.sc' + env['OBJSUFFIX'][1:]
|
||||
|
||||
super().declare_all(env)
|
||||
|
||||
def declare(self, env):
|
||||
env = env.Clone()
|
||||
sources = list(self.sources)
|
||||
for f in self.filters:
|
||||
sources += Source.all.apply_filter(f)
|
||||
objs = self.srcs_to_objs(env, sources)
|
||||
objs = objs + env['MAIN_OBJS']
|
||||
relpath = os.path.relpath(
|
||||
env['SHARED_LIB'][0].dir.abspath,
|
||||
self.path(env).dir.abspath)
|
||||
env.Append(LINKFLAGS=Split('-z origin'))
|
||||
env.Append(RPATH=[
|
||||
env.Literal(os.path.join('\\$$ORIGIN', relpath))])
|
||||
test_bin = super().declare(env, objs)
|
||||
test_bin, _u = super().declare(env)
|
||||
test_dir = self.dir.Dir(self.reldir)
|
||||
for dep in self.test_deps:
|
||||
env.Depends(test_bin, test_dir.File(dep))
|
||||
|
||||
@@ -277,9 +277,9 @@ class LogChecker(DiffingChecker):
|
||||
test_filt = merge_filts(
|
||||
r'^/.*:\d+: ',
|
||||
r'^Global frequency set at \d* ticks per second\n',
|
||||
r'info: Entering event queue @ \d*\. Starting simulation\.\.\.\n',
|
||||
r'warn: Ignoring request to set stack size\.\n',
|
||||
r'^warn: No dot file generated. Please install pydot ' +
|
||||
r'.*info: Entering event queue @ \d*\. Starting simulation\.\.\.\n',
|
||||
r'.*warn: Ignoring request to set stack size\.\n',
|
||||
r'^.*warn: No dot file generated. Please install pydot ' +
|
||||
r'to generate the dot file and pdf.\n',
|
||||
info_filt(804),
|
||||
in_file_filt,
|
||||
|
||||
@@ -31,21 +31,17 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
struct InstallTlmGlobalQuantum : public ::sc_gem5::PythonInitFunc
|
||||
{
|
||||
void
|
||||
run(pybind11::module_ &systemc) override
|
||||
{
|
||||
pybind11::class_<tlm::tlm_global_quantum>(
|
||||
systemc, "tlm_global_quantum")
|
||||
.def_static("instance", &tlm::tlm_global_quantum::instance,
|
||||
pybind11::return_value_policy::reference)
|
||||
.def("set", &tlm::tlm_global_quantum::set)
|
||||
.def("get", &tlm::tlm_global_quantum::get)
|
||||
.def("compute_local_quantum",
|
||||
&tlm::tlm_global_quantum::compute_local_quantum)
|
||||
;
|
||||
}
|
||||
} installTlmGlobalQuantum;
|
||||
::sc_gem5::PythonInitFunc installTlmGlobalQuantum(
|
||||
[](pybind11::module_ &systemc) {
|
||||
pybind11::class_<tlm::tlm_global_quantum>(
|
||||
systemc, "tlm_global_quantum")
|
||||
.def_static("instance", &tlm::tlm_global_quantum::instance,
|
||||
pybind11::return_value_policy::reference)
|
||||
.def("set", &tlm::tlm_global_quantum::set)
|
||||
.def("get", &tlm::tlm_global_quantum::get)
|
||||
.def("compute_local_quantum",
|
||||
&tlm::tlm_global_quantum::compute_local_quantum)
|
||||
;
|
||||
});
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Reference in New Issue
Block a user