misc: Run pre-commit run on all files in repo
The following command was run: ``` pre-commit run --all-files ``` This ensures all the files in the repository are formatted to pass our checks. Change-Id: Ia2fe3529a50ad925d1076a612d60a4280adc40de Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62572 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
committed by
Bobby Bruce
parent
64add0e04d
commit
2bc5a8b71a
1
.mailmap
1
.mailmap
@@ -331,4 +331,3 @@ Marjan Fariborz <mfariborz@ucdavis.edu> marjanfariborz <mfariborz@ucdavis.edu>
|
||||
Mike Upton <michaelupton@gmail.com>
|
||||
seanzw <seanyukigeek@gmail.com>
|
||||
Trivikram Reddy <tvreddy@ucdavis.edu> tv-reddy <tvreddy@ucdavis.edu>
|
||||
|
||||
|
||||
@@ -252,4 +252,3 @@ suites in parallel, supply the `-t <number-tests>` flag to the run command.
|
||||
For example, to run up to three test suites at the same time::
|
||||
|
||||
./main.py run --skip-build -t 3
|
||||
|
||||
|
||||
@@ -26,16 +26,17 @@
|
||||
import array
|
||||
import functools
|
||||
|
||||
|
||||
def bytesToCppArray(code, symbol, data):
|
||||
'''
|
||||
"""
|
||||
Output an array of bytes to a code formatter as a c++ array declaration.
|
||||
'''
|
||||
code('const std::uint8_t ${symbol}[] = {')
|
||||
"""
|
||||
code("const std::uint8_t ${symbol}[] = {")
|
||||
code.indent()
|
||||
step = 16
|
||||
for i in range(0, len(data), step):
|
||||
x = array.array('B', data[i:i+step])
|
||||
strs = map(lambda i: f'{i},', x)
|
||||
x = array.array("B", data[i : i + step])
|
||||
strs = map(lambda i: f"{i},", x)
|
||||
code(functools.reduce(lambda x, y: x + y, strs))
|
||||
code.dedent()
|
||||
code('};')
|
||||
code("};")
|
||||
|
||||
@@ -45,6 +45,7 @@ import inspect
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
class lookup(object):
|
||||
def __init__(self, formatter, frame, *args, **kwargs):
|
||||
self.frame = frame
|
||||
@@ -64,10 +65,10 @@ class lookup(object):
|
||||
if item in self.kwargs:
|
||||
return self.kwargs[item]
|
||||
|
||||
if item == '__file__':
|
||||
if item == "__file__":
|
||||
return self.frame.f_code.co_filename
|
||||
|
||||
if item == '__line__':
|
||||
if item == "__line__":
|
||||
return self.frame.f_lineno
|
||||
|
||||
if self.formatter.locals and item in self.frame.f_locals:
|
||||
@@ -89,6 +90,7 @@ class lookup(object):
|
||||
pass
|
||||
raise IndexError("Could not find '%s'" % item)
|
||||
|
||||
|
||||
class code_formatter_meta(type):
|
||||
pattern = r"""
|
||||
(?:
|
||||
@@ -102,44 +104,48 @@ class code_formatter_meta(type):
|
||||
%(delim)s(?P<invalid>) # ill-formed delimiter exprs
|
||||
)
|
||||
"""
|
||||
|
||||
def __init__(cls, name, bases, dct):
|
||||
super(code_formatter_meta, cls).__init__(name, bases, dct)
|
||||
if 'pattern' in dct:
|
||||
if "pattern" in dct:
|
||||
pat = cls.pattern
|
||||
else:
|
||||
# tuple expansion to ensure strings are proper length
|
||||
lb,rb = cls.braced
|
||||
lb1,lb2,rb2,rb1 = cls.double_braced
|
||||
lb, rb = cls.braced
|
||||
lb1, lb2, rb2, rb1 = cls.double_braced
|
||||
pat = code_formatter_meta.pattern % {
|
||||
'delim' : re.escape(cls.delim),
|
||||
'ident' : cls.ident,
|
||||
'pos' : cls.pos,
|
||||
'lb' : re.escape(lb),
|
||||
'rb' : re.escape(rb),
|
||||
'ldb' : re.escape(lb1+lb2),
|
||||
'rdb' : re.escape(rb2+rb1),
|
||||
"delim": re.escape(cls.delim),
|
||||
"ident": cls.ident,
|
||||
"pos": cls.pos,
|
||||
"lb": re.escape(lb),
|
||||
"rb": re.escape(rb),
|
||||
"ldb": re.escape(lb1 + lb2),
|
||||
"rdb": re.escape(rb2 + rb1),
|
||||
}
|
||||
cls.pattern = re.compile(pat, re.VERBOSE | re.DOTALL | re.MULTILINE)
|
||||
|
||||
|
||||
class code_formatter(object, metaclass=code_formatter_meta):
|
||||
delim = r'$'
|
||||
ident = r'[_A-z]\w*'
|
||||
pos = r'[0-9]+'
|
||||
braced = r'{}'
|
||||
double_braced = r'{{}}'
|
||||
delim = r"$"
|
||||
ident = r"[_A-z]\w*"
|
||||
pos = r"[0-9]+"
|
||||
braced = r"{}"
|
||||
double_braced = r"{{}}"
|
||||
|
||||
globals = True
|
||||
locals = True
|
||||
fix_newlines = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._data = []
|
||||
self._dict = {}
|
||||
self._indent_level = 0
|
||||
self._indent_spaces = 4
|
||||
self.globals = kwargs.pop('globals', type(self).globals)
|
||||
self.locals = kwargs.pop('locals', type(self).locals)
|
||||
self._fix_newlines = \
|
||||
kwargs.pop('fix_newlines', type(self).fix_newlines)
|
||||
self.globals = kwargs.pop("globals", type(self).globals)
|
||||
self.locals = kwargs.pop("locals", type(self).locals)
|
||||
self._fix_newlines = kwargs.pop(
|
||||
"fix_newlines", type(self).fix_newlines
|
||||
)
|
||||
|
||||
if args:
|
||||
self.__call__(args)
|
||||
@@ -171,38 +177,44 @@ class code_formatter(object, metaclass=code_formatter_meta):
|
||||
# Add a comment to inform which file generated the generated file
|
||||
# to make it easier to backtrack and modify generated code
|
||||
frame = inspect.currentframe().f_back
|
||||
if re.match(r'^\.(cc|hh|c|h)$', extension) is not None:
|
||||
f.write(f'''/**
|
||||
if re.match(r"^\.(cc|hh|c|h)$", extension) is not None:
|
||||
f.write(
|
||||
f"""/**
|
||||
* DO NOT EDIT THIS FILE!
|
||||
* File automatically generated by
|
||||
* {frame.f_code.co_filename}:{frame.f_lineno}
|
||||
*/
|
||||
|
||||
''')
|
||||
elif re.match(r'^\.py$', extension) is not None:
|
||||
f.write(f'''#
|
||||
"""
|
||||
)
|
||||
elif re.match(r"^\.py$", extension) is not None:
|
||||
f.write(
|
||||
f"""#
|
||||
# DO NOT EDIT THIS FILE!
|
||||
# File automatically generated by
|
||||
# {frame.f_code.co_filename}:{frame.f_lineno}
|
||||
#
|
||||
|
||||
''')
|
||||
elif re.match(r'^\.html$', extension) is not None:
|
||||
f.write(f'''<!--
|
||||
"""
|
||||
)
|
||||
elif re.match(r"^\.html$", extension) is not None:
|
||||
f.write(
|
||||
f"""<!--
|
||||
DO NOT EDIT THIS FILE!
|
||||
File automatically generated by
|
||||
{frame.f_code.co_filename}:{frame.f_lineno}
|
||||
-->
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
for data in self._data:
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
def __str__(self):
|
||||
data = ''.join(self._data)
|
||||
self._data = [ data ]
|
||||
data = "".join(self._data)
|
||||
self._data = [data]
|
||||
return data
|
||||
|
||||
def __getitem__(self, item):
|
||||
@@ -231,21 +243,21 @@ class code_formatter(object, metaclass=code_formatter_meta):
|
||||
self._data.append(data)
|
||||
return
|
||||
|
||||
initial_newline = not self._data or self._data[-1] == '\n'
|
||||
initial_newline = not self._data or self._data[-1] == "\n"
|
||||
for line in data.splitlines():
|
||||
if line:
|
||||
if self._indent_level:
|
||||
self._data.append(' ' * self._indent_level)
|
||||
self._data.append(" " * self._indent_level)
|
||||
self._data.append(line)
|
||||
|
||||
if line or not initial_newline:
|
||||
self._data.append('\n')
|
||||
self._data.append("\n")
|
||||
|
||||
initial_newline = False
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
if not args:
|
||||
self._data.append('\n')
|
||||
self._data.append("\n")
|
||||
return
|
||||
|
||||
format = args[0]
|
||||
@@ -254,51 +266,56 @@ class code_formatter(object, metaclass=code_formatter_meta):
|
||||
frame = inspect.currentframe().f_back
|
||||
|
||||
l = lookup(self, frame, *args, **kwargs)
|
||||
|
||||
def convert(match):
|
||||
ident = match.group('lone')
|
||||
ident = match.group("lone")
|
||||
# check for a lone identifier
|
||||
if ident:
|
||||
indent = match.group('indent') # must be spaces
|
||||
lone = '%s' % (l[ident], )
|
||||
indent = match.group("indent") # must be spaces
|
||||
lone = "%s" % (l[ident],)
|
||||
|
||||
def indent_lines(gen):
|
||||
for line in gen:
|
||||
yield indent
|
||||
yield line
|
||||
return ''.join(indent_lines(lone.splitlines(True)))
|
||||
|
||||
return "".join(indent_lines(lone.splitlines(True)))
|
||||
|
||||
# check for an identifier, braced or not
|
||||
ident = match.group('ident') or match.group('b_ident')
|
||||
ident = match.group("ident") or match.group("b_ident")
|
||||
if ident is not None:
|
||||
return '%s' % (l[ident], )
|
||||
return "%s" % (l[ident],)
|
||||
|
||||
# check for a positional parameter, braced or not
|
||||
pos = match.group('pos') or match.group('b_pos')
|
||||
pos = match.group("pos") or match.group("b_pos")
|
||||
if pos is not None:
|
||||
pos = int(pos)
|
||||
if pos > len(args):
|
||||
raise ValueError \
|
||||
('Positional parameter #%d not found in pattern' % pos,
|
||||
code_formatter.pattern)
|
||||
return '%s' % (args[int(pos)], )
|
||||
raise ValueError(
|
||||
"Positional parameter #%d not found in pattern" % pos,
|
||||
code_formatter.pattern,
|
||||
)
|
||||
return "%s" % (args[int(pos)],)
|
||||
|
||||
# check for a double braced expression
|
||||
eval_expr = match.group('eval')
|
||||
eval_expr = match.group("eval")
|
||||
if eval_expr is not None:
|
||||
result = eval(eval_expr, {}, l)
|
||||
return '%s' % (result, )
|
||||
return "%s" % (result,)
|
||||
|
||||
# check for an escaped delimiter
|
||||
if match.group('escaped') is not None:
|
||||
return '$'
|
||||
if match.group("escaped") is not None:
|
||||
return "$"
|
||||
|
||||
# At this point, we have to match invalid
|
||||
if match.group('invalid') is None:
|
||||
if match.group("invalid") is None:
|
||||
# didn't match invalid!
|
||||
raise ValueError('Unrecognized named group in pattern',
|
||||
code_formatter.pattern)
|
||||
raise ValueError(
|
||||
"Unrecognized named group in pattern",
|
||||
code_formatter.pattern,
|
||||
)
|
||||
|
||||
i = match.start('invalid')
|
||||
i = match.start("invalid")
|
||||
if i == 0:
|
||||
colno = 1
|
||||
lineno = 1
|
||||
@@ -307,52 +324,64 @@ class code_formatter(object, metaclass=code_formatter_meta):
|
||||
colno = i - sum(len(z) for z in lines)
|
||||
lineno = len(lines)
|
||||
|
||||
raise ValueError('Invalid format string: line %d, col %d' %
|
||||
(lineno, colno))
|
||||
raise ValueError(
|
||||
"Invalid format string: line %d, col %d" % (lineno, colno)
|
||||
)
|
||||
|
||||
d = code_formatter.pattern.sub(convert, format)
|
||||
self._append(d)
|
||||
|
||||
__all__ = [ "code_formatter" ]
|
||||
|
||||
if __name__ == '__main__':
|
||||
__all__ = ["code_formatter"]
|
||||
|
||||
if __name__ == "__main__":
|
||||
from .code_formatter import code_formatter
|
||||
|
||||
f = code_formatter()
|
||||
|
||||
class Foo(dict):
|
||||
def __init__(self, **kwargs):
|
||||
self.update(kwargs)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
|
||||
x = "this is a test"
|
||||
l = [ [Foo(x=[Foo(y=9)])] ]
|
||||
l = [[Foo(x=[Foo(y=9)])]]
|
||||
|
||||
y = code_formatter()
|
||||
y('''
|
||||
y(
|
||||
"""
|
||||
{
|
||||
this_is_a_test();
|
||||
}
|
||||
''')
|
||||
f(' $y')
|
||||
f('''$__file__:$__line__
|
||||
{''')
|
||||
"""
|
||||
)
|
||||
f(" $y")
|
||||
f(
|
||||
"""$__file__:$__line__
|
||||
{"""
|
||||
)
|
||||
f("${{', '.join(str(x) for x in range(4))}}")
|
||||
f('${x}')
|
||||
f('$x')
|
||||
f("${x}")
|
||||
f("$x")
|
||||
f.indent()
|
||||
for i in range(5):
|
||||
f('$x')
|
||||
f('$i')
|
||||
f('$0', "zero")
|
||||
f('$1 $0', "zero", "one")
|
||||
f('${0}', "he went")
|
||||
f('${0}asdf', "he went")
|
||||
f("$x")
|
||||
f("$i")
|
||||
f("$0", "zero")
|
||||
f("$1 $0", "zero", "one")
|
||||
f("${0}", "he went")
|
||||
f("${0}asdf", "he went")
|
||||
f.dedent()
|
||||
|
||||
f('''
|
||||
f(
|
||||
"""
|
||||
${{l[0][0]["x"][0].y}}
|
||||
}
|
||||
''', 1, 9)
|
||||
""",
|
||||
1,
|
||||
9,
|
||||
)
|
||||
|
||||
print(f, end=' ')
|
||||
print(f, end=" ")
|
||||
|
||||
@@ -46,8 +46,8 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the simobject belongs to')
|
||||
parser.add_argument('cxx_config_cc', help='cxx config cc file to generate')
|
||||
parser.add_argument("modpath", help="module the simobject belongs to")
|
||||
parser.add_argument("cxx_config_cc", help="cxx config cc file to generate")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -63,22 +63,25 @@ import m5.params
|
||||
|
||||
code = code_formatter()
|
||||
|
||||
entry_class = 'CxxConfigDirectoryEntry_%s' % sim_object_name
|
||||
param_class = '%sCxxConfigParams' % sim_object_name
|
||||
entry_class = "CxxConfigDirectoryEntry_%s" % sim_object_name
|
||||
param_class = "%sCxxConfigParams" % sim_object_name
|
||||
|
||||
|
||||
def cxx_bool(b):
|
||||
return 'true' if b else 'false'
|
||||
return "true" if b else "false"
|
||||
|
||||
|
||||
code('#include "params/%s.hh"' % sim_object_name)
|
||||
|
||||
for param in sim_object._params.values():
|
||||
if isSimObjectClass(param.ptype):
|
||||
code('#include "%s"' % param.ptype._value_dict['cxx_header'])
|
||||
code('#include "%s"' % param.ptype._value_dict["cxx_header"])
|
||||
code('#include "params/%s.hh"' % param.ptype.__name__)
|
||||
else:
|
||||
param.ptype.cxx_ini_predecls(code)
|
||||
|
||||
code('''#include "${{sim_object._value_dict['cxx_header']}}"
|
||||
code(
|
||||
"""#include "${{sim_object._value_dict['cxx_header']}}"
|
||||
#include "base/str.hh"
|
||||
#include "cxx_config/${sim_object_name}.hh"
|
||||
|
||||
@@ -87,34 +90,39 @@ namespace gem5
|
||||
|
||||
${param_class}::DirectoryEntry::DirectoryEntry()
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
code.indent()
|
||||
for param in sim_object._params.values():
|
||||
is_vector = isinstance(param, m5.params.VectorParamDesc)
|
||||
is_simobj = issubclass(param.ptype, m5.SimObject.SimObject)
|
||||
|
||||
code('parameters["%s"] = new ParamDesc("%s", %s, %s);' %
|
||||
(param.name, param.name, cxx_bool(is_vector),
|
||||
cxx_bool(is_simobj)));
|
||||
code(
|
||||
'parameters["%s"] = new ParamDesc("%s", %s, %s);'
|
||||
% (param.name, param.name, cxx_bool(is_vector), cxx_bool(is_simobj))
|
||||
)
|
||||
|
||||
for port in sim_object._ports.values():
|
||||
is_vector = isinstance(port, m5.params.VectorPort)
|
||||
is_requestor = port.role == 'GEM5 REQUESTOR'
|
||||
is_requestor = port.role == "GEM5 REQUESTOR"
|
||||
|
||||
code('ports["%s"] = new PortDesc("%s", %s, %s);' %
|
||||
(port.name, port.name, cxx_bool(is_vector),
|
||||
cxx_bool(is_requestor)))
|
||||
code(
|
||||
'ports["%s"] = new PortDesc("%s", %s, %s);'
|
||||
% (port.name, port.name, cxx_bool(is_vector), cxx_bool(is_requestor))
|
||||
)
|
||||
|
||||
code.dedent()
|
||||
|
||||
code('''}
|
||||
code(
|
||||
"""}
|
||||
|
||||
bool
|
||||
${param_class}::setSimObject(const std::string &name, SimObject *simObject)
|
||||
{
|
||||
bool ret = true;
|
||||
if (false) {
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
for param in sim_object._params.values():
|
||||
@@ -124,14 +132,17 @@ for param in sim_object._params.values():
|
||||
if is_simobj and not is_vector:
|
||||
code('} else if (name == "${{param.name}}") {')
|
||||
code.indent()
|
||||
code('this->${{param.name}} = '
|
||||
'dynamic_cast<${{param.ptype.cxx_type}}>(simObject);')
|
||||
code('if (simObject && !this->${{param.name}})')
|
||||
code(' ret = false;')
|
||||
code(
|
||||
"this->${{param.name}} = "
|
||||
"dynamic_cast<${{param.ptype.cxx_type}}>(simObject);"
|
||||
)
|
||||
code("if (simObject && !this->${{param.name}})")
|
||||
code(" ret = false;")
|
||||
code.dedent()
|
||||
code.dedent()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -146,7 +157,8 @@ ${param_class}::setSimObjectVector(const std::string &name,
|
||||
bool ret = true;
|
||||
|
||||
if (false) {
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
for param in sim_object._params.values():
|
||||
@@ -156,23 +168,28 @@ for param in sim_object._params.values():
|
||||
if is_simobj and is_vector:
|
||||
code('} else if (name == "${{param.name}}") {')
|
||||
code.indent()
|
||||
code('this->${{param.name}}.clear();')
|
||||
code('for (auto i = simObjects.begin(); '
|
||||
'ret && i != simObjects.end(); i ++)')
|
||||
code('{')
|
||||
code("this->${{param.name}}.clear();")
|
||||
code(
|
||||
"for (auto i = simObjects.begin(); "
|
||||
"ret && i != simObjects.end(); i ++)"
|
||||
)
|
||||
code("{")
|
||||
code.indent()
|
||||
code('${{param.ptype.cxx_type}} object = '
|
||||
'dynamic_cast<${{param.ptype.cxx_type}}>(*i);')
|
||||
code('if (*i && !object)')
|
||||
code(' ret = false;')
|
||||
code('else')
|
||||
code(' this->${{param.name}}.push_back(object);')
|
||||
code(
|
||||
"${{param.ptype.cxx_type}} object = "
|
||||
"dynamic_cast<${{param.ptype.cxx_type}}>(*i);"
|
||||
)
|
||||
code("if (*i && !object)")
|
||||
code(" ret = false;")
|
||||
code("else")
|
||||
code(" this->${{param.name}}.push_back(object);")
|
||||
code.dedent()
|
||||
code('}')
|
||||
code("}")
|
||||
code.dedent()
|
||||
code.dedent()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -193,7 +210,8 @@ ${param_class}::setParam(const std::string &name,
|
||||
bool ret = true;
|
||||
|
||||
if (false) {
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
for param in sim_object._params.values():
|
||||
@@ -203,12 +221,14 @@ for param in sim_object._params.values():
|
||||
if not is_simobj and not is_vector:
|
||||
code('} else if (name == "${{param.name}}") {')
|
||||
code.indent()
|
||||
param.ptype.cxx_ini_parse(code,
|
||||
'value', 'this->%s' % param.name, 'ret =')
|
||||
param.ptype.cxx_ini_parse(
|
||||
code, "value", "this->%s" % param.name, "ret ="
|
||||
)
|
||||
code.dedent()
|
||||
code.dedent()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -223,7 +243,8 @@ ${param_class}::setParamVector(const std::string &name,
|
||||
bool ret = true;
|
||||
|
||||
if (false) {
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
for param in sim_object._params.values():
|
||||
@@ -233,22 +254,23 @@ for param in sim_object._params.values():
|
||||
if not is_simobj and is_vector:
|
||||
code('} else if (name == "${{param.name}}") {')
|
||||
code.indent()
|
||||
code('${{param.name}}.clear();')
|
||||
code('for (auto i = values.begin(); '
|
||||
'ret && i != values.end(); i ++)')
|
||||
code('{')
|
||||
code("${{param.name}}.clear();")
|
||||
code(
|
||||
"for (auto i = values.begin(); " "ret && i != values.end(); i ++)"
|
||||
)
|
||||
code("{")
|
||||
code.indent()
|
||||
code('${{param.ptype.cxx_type}} elem;')
|
||||
param.ptype.cxx_ini_parse(code,
|
||||
'*i', 'elem', 'ret =')
|
||||
code('if (ret)')
|
||||
code(' this->${{param.name}}.push_back(elem);')
|
||||
code("${{param.ptype.cxx_type}} elem;")
|
||||
param.ptype.cxx_ini_parse(code, "*i", "elem", "ret =")
|
||||
code("if (ret)")
|
||||
code(" this->${{param.name}}.push_back(elem);")
|
||||
code.dedent()
|
||||
code('}')
|
||||
code("}")
|
||||
code.dedent()
|
||||
code.dedent()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -263,15 +285,17 @@ ${param_class}::setPortConnectionCount(const std::string &name,
|
||||
bool ret = true;
|
||||
|
||||
if (false) {
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
for port in sim_object._ports.values():
|
||||
code('} else if (name == "${{port.name}}") {')
|
||||
code(' this->port_${{port.name}}_connection_count = count;')
|
||||
code(" this->port_${{port.name}}_connection_count = count;")
|
||||
code.dedent()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -282,18 +306,21 @@ code('''
|
||||
SimObject *
|
||||
${param_class}::simObjectCreate()
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.indent()
|
||||
if hasattr(sim_object, 'abstract') and sim_object.abstract:
|
||||
code('return nullptr;')
|
||||
if hasattr(sim_object, "abstract") and sim_object.abstract:
|
||||
code("return nullptr;")
|
||||
else:
|
||||
code('return this->create();')
|
||||
code("return this->create();")
|
||||
code.dedent()
|
||||
|
||||
code('''}
|
||||
code(
|
||||
"""}
|
||||
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(args.cxx_config_cc)
|
||||
|
||||
@@ -46,8 +46,8 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the simobject belongs to')
|
||||
parser.add_argument('cxx_config_hh', help='cxx config header file to generate')
|
||||
parser.add_argument("modpath", help="module the simobject belongs to")
|
||||
parser.add_argument("cxx_config_hh", help="cxx config header file to generate")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -60,10 +60,11 @@ sim_object = getattr(module, sim_object_name)
|
||||
|
||||
code = code_formatter()
|
||||
|
||||
entry_class = 'CxxConfigDirectoryEntry_%s' % sim_object_name
|
||||
param_class = '%sCxxConfigParams' % sim_object_name
|
||||
entry_class = "CxxConfigDirectoryEntry_%s" % sim_object_name
|
||||
param_class = "%sCxxConfigParams" % sim_object_name
|
||||
|
||||
code('''#include "params/${sim_object_name}.hh"
|
||||
code(
|
||||
"""#include "params/${sim_object_name}.hh"
|
||||
|
||||
#include "sim/cxx_config.hh"
|
||||
|
||||
@@ -110,6 +111,7 @@ class ${param_class} : public CxxConfigParams, public ${sim_object_name}Params
|
||||
};
|
||||
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(args.cxx_config_hh)
|
||||
|
||||
@@ -44,35 +44,41 @@ parser = argparse.ArgumentParser()
|
||||
parser.add_argument("hh", help="the path of the debug flag header file")
|
||||
parser.add_argument("name", help="the name of the debug flag")
|
||||
parser.add_argument("desc", help="a description of the debug flag")
|
||||
parser.add_argument("fmt",
|
||||
help="whether the flag is a format flag (True or False)")
|
||||
parser.add_argument("components",
|
||||
help="components of a compound flag, if applicable, joined with :")
|
||||
parser.add_argument(
|
||||
"fmt", help="whether the flag is a format flag (True or False)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"components",
|
||||
help="components of a compound flag, if applicable, joined with :",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
fmt = args.fmt.lower()
|
||||
if fmt == 'true':
|
||||
if fmt == "true":
|
||||
fmt = True
|
||||
elif fmt == 'false':
|
||||
elif fmt == "false":
|
||||
fmt = False
|
||||
else:
|
||||
print(f'Unrecognized "FMT" value {fmt}', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
components = args.components.split(':') if args.components else []
|
||||
components = args.components.split(":") if args.components else []
|
||||
|
||||
code = code_formatter()
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
#ifndef __DEBUG_${{args.name}}_HH__
|
||||
#define __DEBUG_${{args.name}}_HH__
|
||||
|
||||
#include "base/compiler.hh" // For namespace deprecation
|
||||
#include "base/debug.hh"
|
||||
''')
|
||||
"""
|
||||
)
|
||||
for flag in components:
|
||||
code('#include "debug/${flag}.hh"')
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
@@ -82,14 +88,16 @@ namespace debug
|
||||
|
||||
namespace unions
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
# Use unions to prevent debug flags from being destructed. It's the
|
||||
# responsibility of the programmer to handle object destruction for members
|
||||
# of the union. We purposefully leave that destructor empty so that we can
|
||||
# use debug flags even in the destructors of other objects.
|
||||
if components:
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
inline union ${{args.name}}
|
||||
{
|
||||
~${{args.name}}() {}
|
||||
@@ -100,9 +108,11 @@ inline union ${{args.name}}
|
||||
}
|
||||
};
|
||||
} ${{args.name}};
|
||||
''')
|
||||
"""
|
||||
)
|
||||
else:
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
inline union ${{args.name}}
|
||||
{
|
||||
~${{args.name}}() {}
|
||||
@@ -110,9 +120,11 @@ inline union ${{args.name}}
|
||||
"${{args.name}}", "${{args.desc}}", ${{"true" if fmt else "false"}}
|
||||
};
|
||||
} ${{args.name}};
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
} // namespace unions
|
||||
|
||||
inline constexpr const auto& ${{args.name}} =
|
||||
@@ -122,6 +134,7 @@ inline constexpr const auto& ${{args.name}} =
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __DEBUG_${{args.name}}_HH__
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(args.hh)
|
||||
|
||||
@@ -46,17 +46,18 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the enum belongs to')
|
||||
parser.add_argument('enum_cc', help='enum cc file to generate')
|
||||
parser.add_argument('use_python',
|
||||
help='whether python is enabled in gem5 (True or False)')
|
||||
parser.add_argument("modpath", help="module the enum belongs to")
|
||||
parser.add_argument("enum_cc", help="enum cc file to generate")
|
||||
parser.add_argument(
|
||||
"use_python", help="whether python is enabled in gem5 (True or False)"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
use_python = args.use_python.lower()
|
||||
if use_python == 'true':
|
||||
if use_python == "true":
|
||||
use_python = True
|
||||
elif use_python == 'false':
|
||||
elif use_python == "false":
|
||||
use_python = False
|
||||
else:
|
||||
print(f'Unrecognized "use_python" value {use_python}', file=sys.stderr)
|
||||
@@ -75,41 +76,46 @@ wrapper_name = enum.wrapper_name
|
||||
file_name = enum.__name__
|
||||
name = enum.__name__ if enum.enum_name is None else enum.enum_name
|
||||
|
||||
code('''#include "base/compiler.hh"
|
||||
code(
|
||||
"""#include "base/compiler.hh"
|
||||
#include "enums/$file_name.hh"
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
if enum.wrapper_is_struct:
|
||||
code('const char *${wrapper_name}::${name}Strings'
|
||||
'[Num_${name}] =')
|
||||
code("const char *${wrapper_name}::${name}Strings" "[Num_${name}] =")
|
||||
else:
|
||||
if enum.is_class:
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
const char *${name}Strings[static_cast<int>(${name}::Num_${name})] =
|
||||
''')
|
||||
"""
|
||||
)
|
||||
else:
|
||||
code('''GEM5_DEPRECATED_NAMESPACE(Enums, enums);
|
||||
code(
|
||||
"""GEM5_DEPRECATED_NAMESPACE(Enums, enums);
|
||||
namespace enums
|
||||
{''')
|
||||
{"""
|
||||
)
|
||||
code.indent(1)
|
||||
code('const char *${name}Strings[Num_${name}] =')
|
||||
code("const char *${name}Strings[Num_${name}] =")
|
||||
|
||||
code('{')
|
||||
code("{")
|
||||
code.indent(1)
|
||||
for val in enum.vals:
|
||||
code('"$val",')
|
||||
code.dedent(1)
|
||||
code('};')
|
||||
code("};")
|
||||
|
||||
if not enum.wrapper_is_struct and not enum.is_class:
|
||||
code.dedent(1)
|
||||
code('} // namespace enums')
|
||||
code("} // namespace enums")
|
||||
|
||||
code('} // namespace gem5')
|
||||
code("} // namespace gem5")
|
||||
|
||||
|
||||
if use_python:
|
||||
@@ -118,7 +124,8 @@ if use_python:
|
||||
enum_name = enum.__name__ if enum.enum_name is None else enum.enum_name
|
||||
wrapper_name = enum_name if enum.is_class else enum.wrapper_name
|
||||
|
||||
code('''#include "pybind11/pybind11.h"
|
||||
code(
|
||||
"""#include "pybind11/pybind11.h"
|
||||
#include "pybind11/stl.h"
|
||||
|
||||
#include <sim/init.hh>
|
||||
@@ -133,7 +140,8 @@ module_init(py::module_ &m_internal)
|
||||
{
|
||||
py::module_ m = m_internal.def_submodule("enum_${name}");
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
if enum.is_class:
|
||||
code('py::enum_<${enum_name}>(m, "enum_${name}")')
|
||||
else:
|
||||
@@ -145,16 +153,18 @@ module_init(py::module_ &m_internal)
|
||||
code('.value("${val}", ${wrapper_name}::${val})')
|
||||
code('.value("Num_${name}", ${wrapper_name}::Num_${enum_name})')
|
||||
if not enum.is_class:
|
||||
code('.export_values()')
|
||||
code(';')
|
||||
code(".export_values()")
|
||||
code(";")
|
||||
code.dedent()
|
||||
|
||||
code('}')
|
||||
code("}")
|
||||
code.dedent()
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
static EmbeddedPyBind embed_enum("enum_${name}", module_init);
|
||||
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(args.enum_cc)
|
||||
|
||||
@@ -46,8 +46,8 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the enum belongs to')
|
||||
parser.add_argument('enum_hh', help='enum header file to generate')
|
||||
parser.add_argument("modpath", help="module the enum belongs to")
|
||||
parser.add_argument("enum_hh", help="enum header file to generate")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -64,53 +64,61 @@ code = code_formatter()
|
||||
# Note that we wrap the enum in a class/struct to act as a namespace,
|
||||
# so that the enum strings can be brief w/o worrying about collisions.
|
||||
wrapper_name = enum.wrapper_name
|
||||
wrapper = 'struct' if enum.wrapper_is_struct else 'namespace'
|
||||
wrapper = "struct" if enum.wrapper_is_struct else "namespace"
|
||||
name = enum.__name__ if enum.enum_name is None else enum.enum_name
|
||||
idem_macro = '__ENUM__%s__%s__' % (wrapper_name, name)
|
||||
idem_macro = "__ENUM__%s__%s__" % (wrapper_name, name)
|
||||
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
#ifndef $idem_macro
|
||||
#define $idem_macro
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
if enum.is_class:
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
enum class $name
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
else:
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
$wrapper $wrapper_name {
|
||||
enum $name
|
||||
{
|
||||
''')
|
||||
"""
|
||||
)
|
||||
code.indent(1)
|
||||
code.indent(1)
|
||||
for val in enum.vals:
|
||||
code('$val = ${{enum.map[val]}},')
|
||||
code('Num_$name = ${{len(enum.vals)}}')
|
||||
code("$val = ${{enum.map[val]}},")
|
||||
code("Num_$name = ${{len(enum.vals)}}")
|
||||
code.dedent(1)
|
||||
code('};')
|
||||
code("};")
|
||||
|
||||
if enum.is_class:
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
extern const char *${name}Strings[static_cast<int>(${name}::Num_${name})];
|
||||
''')
|
||||
"""
|
||||
)
|
||||
elif enum.wrapper_is_struct:
|
||||
code('static const char *${name}Strings[Num_${name}];')
|
||||
code("static const char *${name}Strings[Num_${name}];")
|
||||
else:
|
||||
code('extern const char *${name}Strings[Num_${name}];')
|
||||
code("extern const char *${name}Strings[Num_${name}];")
|
||||
|
||||
if not enum.is_class:
|
||||
code.dedent(1)
|
||||
code('}; // $wrapper_name')
|
||||
code("}; // $wrapper_name")
|
||||
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
code("} // namespace gem5")
|
||||
|
||||
code()
|
||||
code('#endif // $idem_macro')
|
||||
code("#endif // $idem_macro")
|
||||
|
||||
code.write(args.enum_hh)
|
||||
|
||||
@@ -29,73 +29,77 @@ import os
|
||||
import ply.lex
|
||||
import ply.yacc
|
||||
|
||||
|
||||
class ParseError(Exception):
|
||||
def __init__(self, message, token=None):
|
||||
Exception.__init__(self, message)
|
||||
self.token = token
|
||||
|
||||
|
||||
class Grammar(object):
|
||||
def setupLexerFactory(self, **kwargs):
|
||||
if 'module' in kwargs:
|
||||
if "module" in kwargs:
|
||||
raise AttributeError("module is an illegal attribute")
|
||||
self.lex_kwargs = kwargs
|
||||
|
||||
def setupParserFactory(self, **kwargs):
|
||||
if 'module' in kwargs:
|
||||
if "module" in kwargs:
|
||||
raise AttributeError("module is an illegal attribute")
|
||||
|
||||
if 'output' in kwargs:
|
||||
dir,tab = os.path.split(output)
|
||||
if not tab.endswith('.py'):
|
||||
raise AttributeError('The output file must end with .py')
|
||||
kwargs['outputdir'] = dir
|
||||
kwargs['tabmodule'] = tab[:-3]
|
||||
if "output" in kwargs:
|
||||
dir, tab = os.path.split(output)
|
||||
if not tab.endswith(".py"):
|
||||
raise AttributeError("The output file must end with .py")
|
||||
kwargs["outputdir"] = dir
|
||||
kwargs["tabmodule"] = tab[:-3]
|
||||
|
||||
self.yacc_kwargs = kwargs
|
||||
|
||||
def __getattr__(self, attr):
|
||||
if attr == 'lexers':
|
||||
if attr == "lexers":
|
||||
self.lexers = []
|
||||
return self.lexers
|
||||
|
||||
if attr == 'lex_kwargs':
|
||||
if attr == "lex_kwargs":
|
||||
self.setupLexerFactory()
|
||||
return self.lex_kwargs
|
||||
|
||||
if attr == 'yacc_kwargs':
|
||||
if attr == "yacc_kwargs":
|
||||
self.setupParserFactory()
|
||||
return self.yacc_kwargs
|
||||
|
||||
if attr == 'lex':
|
||||
if attr == "lex":
|
||||
self.lex = ply.lex.lex(module=self, **self.lex_kwargs)
|
||||
return self.lex
|
||||
|
||||
if attr == 'yacc':
|
||||
if attr == "yacc":
|
||||
self.yacc = ply.yacc.yacc(module=self, **self.yacc_kwargs)
|
||||
return self.yacc
|
||||
|
||||
if attr == 'current_lexer':
|
||||
if attr == "current_lexer":
|
||||
if not self.lexers:
|
||||
return None
|
||||
return self.lexers[-1][0]
|
||||
|
||||
if attr == 'current_source':
|
||||
if attr == "current_source":
|
||||
if not self.lexers:
|
||||
return '<none>'
|
||||
return "<none>"
|
||||
return self.lexers[-1][1]
|
||||
|
||||
if attr == 'current_line':
|
||||
if attr == "current_line":
|
||||
if not self.lexers:
|
||||
return -1
|
||||
return self.current_lexer.lineno
|
||||
|
||||
raise AttributeError(
|
||||
"'%s' object has no attribute '%s'" % (type(self), attr))
|
||||
"'%s' object has no attribute '%s'" % (type(self), attr)
|
||||
)
|
||||
|
||||
def parse_string(self, data, source='<string>', debug=None, tracking=0):
|
||||
def parse_string(self, data, source="<string>", debug=None, tracking=0):
|
||||
if not isinstance(data, str):
|
||||
raise AttributeError(
|
||||
"argument must be a string, was '%s'" % type(f))
|
||||
"argument must be a string, was '%s'" % type(f)
|
||||
)
|
||||
|
||||
lexer = self.lex.clone()
|
||||
lexer.input(data)
|
||||
@@ -114,24 +118,32 @@ class Grammar(object):
|
||||
def parse_file(self, f, **kwargs):
|
||||
if isinstance(f, str):
|
||||
source = f
|
||||
f = open(f, 'r')
|
||||
f = open(f, "r")
|
||||
elif isinstance(f, file):
|
||||
source = f.name
|
||||
else:
|
||||
raise AttributeError(
|
||||
"argument must be either a string or file, was '%s'" % type(f))
|
||||
"argument must be either a string or file, was '%s'" % type(f)
|
||||
)
|
||||
|
||||
return self.parse_string(f.read(), source, **kwargs)
|
||||
|
||||
def p_error(self, t):
|
||||
if t:
|
||||
msg = "Syntax error at %s:%d:%d\n>>%s<<" % \
|
||||
(self.current_source, t.lineno, t.lexpos + 1, t.value)
|
||||
msg = "Syntax error at %s:%d:%d\n>>%s<<" % (
|
||||
self.current_source,
|
||||
t.lineno,
|
||||
t.lexpos + 1,
|
||||
t.value,
|
||||
)
|
||||
else:
|
||||
msg = "Syntax error at end of %s" % (self.current_source, )
|
||||
msg = "Syntax error at end of %s" % (self.current_source,)
|
||||
raise ParseError(msg, t)
|
||||
|
||||
def t_error(self, t):
|
||||
msg = "Illegal character %s @ %d:%d" % \
|
||||
(repr(t.value[0]), t.lineno, t.lexpos)
|
||||
msg = "Illegal character %s @ %d:%d" % (
|
||||
repr(t.value[0]),
|
||||
t.lineno,
|
||||
t.lexpos,
|
||||
)
|
||||
raise ParseError(msg, t)
|
||||
|
||||
@@ -42,8 +42,8 @@ import sys
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('info_py', help='info.py file path')
|
||||
parser.add_argument('files', help='file to include in info.py', nargs='*')
|
||||
parser.add_argument("info_py", help="info.py file path")
|
||||
parser.add_argument("files", help="file to include in info.py", nargs="*")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -52,8 +52,8 @@ code = code_formatter()
|
||||
|
||||
for source in args.files:
|
||||
src = os.path.basename(source)
|
||||
with open(source, 'r') as f:
|
||||
data = ''.join(f)
|
||||
code('${src} = ${{repr(data)}}')
|
||||
with open(source, "r") as f:
|
||||
data = "".join(f)
|
||||
code("${src} = ${{repr(data)}}")
|
||||
|
||||
code.write(args.info_py)
|
||||
|
||||
@@ -67,16 +67,17 @@ if len(sys.argv) < 4:
|
||||
|
||||
_, cpp, python, modpath, abspath = sys.argv
|
||||
|
||||
with open(python, 'r') as f:
|
||||
with open(python, "r") as f:
|
||||
src = f.read()
|
||||
|
||||
compiled = compile(src, python, 'exec')
|
||||
compiled = compile(src, python, "exec")
|
||||
marshalled = marshal.dumps(compiled)
|
||||
|
||||
compressed = zlib.compress(marshalled)
|
||||
|
||||
code = code_formatter()
|
||||
code('''\
|
||||
code(
|
||||
"""\
|
||||
#include "python/embedded.hh"
|
||||
|
||||
namespace gem5
|
||||
@@ -84,14 +85,16 @@ namespace gem5
|
||||
namespace
|
||||
{
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
bytesToCppArray(code, 'embedded_module_data', compressed)
|
||||
bytesToCppArray(code, "embedded_module_data", compressed)
|
||||
|
||||
# The name of the EmbeddedPython object doesn't matter since it's in an
|
||||
# anonymous namespace, and it's constructor takes care of installing it into a
|
||||
# global list.
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
EmbeddedPython embedded_module_info(
|
||||
"${abspath}",
|
||||
"${modpath}",
|
||||
@@ -101,6 +104,7 @@ EmbeddedPython embedded_module_info(
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(cpp)
|
||||
|
||||
@@ -46,17 +46,18 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the simobject belongs to')
|
||||
parser.add_argument('param_cc', help='parameter cc file to generate')
|
||||
parser.add_argument('use_python',
|
||||
help='whether python is enabled in gem5 (True or False)')
|
||||
parser.add_argument("modpath", help="module the simobject belongs to")
|
||||
parser.add_argument("param_cc", help="parameter cc file to generate")
|
||||
parser.add_argument(
|
||||
"use_python", help="whether python is enabled in gem5 (True or False)"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
use_python = args.use_python.lower()
|
||||
if use_python == 'true':
|
||||
if use_python == "true":
|
||||
use_python = True
|
||||
elif use_python == 'false':
|
||||
elif use_python == "false":
|
||||
use_python = False
|
||||
else:
|
||||
print(f'Unrecognized "use_python" value {use_python}', file=sys.stderr)
|
||||
@@ -64,7 +65,7 @@ else:
|
||||
|
||||
basename = os.path.basename(args.param_cc)
|
||||
no_ext = os.path.splitext(basename)[0]
|
||||
sim_object_name = '_'.join(no_ext.split('_')[1:])
|
||||
sim_object_name = "_".join(no_ext.split("_")[1:])
|
||||
|
||||
importer.install()
|
||||
module = importlib.import_module(args.modpath)
|
||||
@@ -80,14 +81,16 @@ py_class_name = sim_object.pybind_class
|
||||
# the object itself, not including inherited params (which
|
||||
# will also be inherited from the base class's param struct
|
||||
# here). Sort the params based on their key
|
||||
params = list(map(lambda k_v: k_v[1],
|
||||
sorted(sim_object._params.local.items())))
|
||||
params = list(
|
||||
map(lambda k_v: k_v[1], sorted(sim_object._params.local.items()))
|
||||
)
|
||||
ports = sim_object._ports.local
|
||||
|
||||
# only include pybind if python is enabled in the build
|
||||
if use_python:
|
||||
|
||||
code('''#include "pybind11/pybind11.h"
|
||||
code(
|
||||
"""#include "pybind11/pybind11.h"
|
||||
#include "pybind11/stl.h"
|
||||
|
||||
#include <type_traits>
|
||||
@@ -99,9 +102,11 @@ if use_python:
|
||||
|
||||
#include "${{sim_object.cxx_header}}"
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
else:
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
#include <type_traits>
|
||||
|
||||
#include "base/compiler.hh"
|
||||
@@ -109,13 +114,15 @@ else:
|
||||
|
||||
#include "${{sim_object.cxx_header}}"
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
# only include the python params code if python is enabled.
|
||||
if use_python:
|
||||
for param in params:
|
||||
param.pybind_predecls(code)
|
||||
|
||||
code('''namespace py = pybind11;
|
||||
code(
|
||||
"""namespace py = pybind11;
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
@@ -124,39 +131,48 @@ static void
|
||||
module_init(py::module_ &m_internal)
|
||||
{
|
||||
py::module_ m = m_internal.def_submodule("param_${sim_object}");
|
||||
''')
|
||||
"""
|
||||
)
|
||||
code.indent()
|
||||
if sim_object._base:
|
||||
code('py::class_<${sim_object}Params, ' \
|
||||
'${{sim_object._base.type}}Params, ' \
|
||||
'std::unique_ptr<${{sim_object}}Params, py::nodelete>>(' \
|
||||
'm, "${sim_object}Params")')
|
||||
code(
|
||||
"py::class_<${sim_object}Params, "
|
||||
"${{sim_object._base.type}}Params, "
|
||||
"std::unique_ptr<${{sim_object}}Params, py::nodelete>>("
|
||||
'm, "${sim_object}Params")'
|
||||
)
|
||||
else:
|
||||
code('py::class_<${sim_object}Params, ' \
|
||||
'std::unique_ptr<${sim_object}Params, py::nodelete>>(' \
|
||||
'm, "${sim_object}Params")')
|
||||
code(
|
||||
"py::class_<${sim_object}Params, "
|
||||
"std::unique_ptr<${sim_object}Params, py::nodelete>>("
|
||||
'm, "${sim_object}Params")'
|
||||
)
|
||||
|
||||
code.indent()
|
||||
if not hasattr(sim_object, 'abstract') or not sim_object.abstract:
|
||||
code('.def(py::init<>())')
|
||||
if not hasattr(sim_object, "abstract") or not sim_object.abstract:
|
||||
code(".def(py::init<>())")
|
||||
code('.def("create", &${sim_object}Params::create)')
|
||||
|
||||
param_exports = sim_object.cxx_param_exports + [
|
||||
param_exports = (
|
||||
sim_object.cxx_param_exports
|
||||
+ [
|
||||
PyBindProperty(k)
|
||||
for k, v in sorted(sim_object._params.local.items())
|
||||
] + [
|
||||
]
|
||||
+ [
|
||||
PyBindProperty(f"port_{port.name}_connection_count")
|
||||
for port in ports.values()
|
||||
]
|
||||
)
|
||||
for exp in param_exports:
|
||||
exp.export(code, f"{sim_object}Params")
|
||||
|
||||
code(';')
|
||||
code(";")
|
||||
code()
|
||||
code.dedent()
|
||||
|
||||
bases = []
|
||||
if 'cxx_base' in sim_object._value_dict:
|
||||
if "cxx_base" in sim_object._value_dict:
|
||||
# If the c++ base class implied by python inheritance was
|
||||
# overridden, use that value.
|
||||
if sim_object.cxx_base:
|
||||
@@ -170,32 +186,39 @@ py::module_ m = m_internal.def_submodule("param_${sim_object}");
|
||||
|
||||
if bases:
|
||||
base_str = ", ".join(bases)
|
||||
code('py::class_<${{sim_object.cxx_class}}, ${base_str}, ' \
|
||||
'std::unique_ptr<${{sim_object.cxx_class}}, py::nodelete>>(' \
|
||||
'm, "${py_class_name}")')
|
||||
code(
|
||||
"py::class_<${{sim_object.cxx_class}}, ${base_str}, "
|
||||
"std::unique_ptr<${{sim_object.cxx_class}}, py::nodelete>>("
|
||||
'm, "${py_class_name}")'
|
||||
)
|
||||
else:
|
||||
code('py::class_<${{sim_object.cxx_class}}, ' \
|
||||
'std::unique_ptr<${{sim_object.cxx_class}}, py::nodelete>>(' \
|
||||
'm, "${py_class_name}")')
|
||||
code(
|
||||
"py::class_<${{sim_object.cxx_class}}, "
|
||||
"std::unique_ptr<${{sim_object.cxx_class}}, py::nodelete>>("
|
||||
'm, "${py_class_name}")'
|
||||
)
|
||||
code.indent()
|
||||
for exp in sim_object.cxx_exports:
|
||||
exp.export(code, sim_object.cxx_class)
|
||||
code(';')
|
||||
code(";")
|
||||
code.dedent()
|
||||
code()
|
||||
code.dedent()
|
||||
code('}')
|
||||
code("}")
|
||||
code()
|
||||
code('static EmbeddedPyBind '
|
||||
'embed_obj("${0}", module_init, "${1}");',
|
||||
sim_object, sim_object._base.type if sim_object._base else "")
|
||||
code(
|
||||
"static EmbeddedPyBind " 'embed_obj("${0}", module_init, "${1}");',
|
||||
sim_object,
|
||||
sim_object._base.type if sim_object._base else "",
|
||||
)
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
code("} // namespace gem5")
|
||||
|
||||
# include the create() methods whether or not python is enabled.
|
||||
if not hasattr(sim_object, 'abstract') or not sim_object.abstract:
|
||||
if 'type' in sim_object.__dict__:
|
||||
code('''
|
||||
if not hasattr(sim_object, "abstract") or not sim_object.abstract:
|
||||
if "type" in sim_object.__dict__:
|
||||
code(
|
||||
"""
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
@@ -268,6 +291,7 @@ Dummy${sim_object}Shunt<${{sim_object.cxx_class}}>::Params::create() const
|
||||
}
|
||||
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
code.write(args.param_cc)
|
||||
|
||||
@@ -46,8 +46,8 @@ import importer
|
||||
from code_formatter import code_formatter
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('modpath', help='module the simobject belongs to')
|
||||
parser.add_argument('param_hh', help='parameter header file to generate')
|
||||
parser.add_argument("modpath", help="module the simobject belongs to")
|
||||
parser.add_argument("param_hh", help="parameter header file to generate")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -67,8 +67,9 @@ code = code_formatter()
|
||||
# the object itself, not including inherited params (which
|
||||
# will also be inherited from the base class's param struct
|
||||
# here). Sort the params based on their key
|
||||
params = list(map(lambda k_v: k_v[1],
|
||||
sorted(sim_object._params.local.items())))
|
||||
params = list(
|
||||
map(lambda k_v: k_v[1], sorted(sim_object._params.local.items()))
|
||||
)
|
||||
ports = sim_object._ports.local
|
||||
try:
|
||||
ptypes = [p.ptype for p in params]
|
||||
@@ -79,41 +80,44 @@ except:
|
||||
|
||||
warned_about_nested_templates = False
|
||||
|
||||
|
||||
class CxxClass(object):
|
||||
def __init__(self, sig, template_params=[]):
|
||||
# Split the signature into its constituent parts. This could
|
||||
# potentially be done with regular expressions, but
|
||||
# it's simple enough to pick appart a class signature
|
||||
# manually.
|
||||
parts = sig.split('<', 1)
|
||||
parts = sig.split("<", 1)
|
||||
base = parts[0]
|
||||
t_args = []
|
||||
if len(parts) > 1:
|
||||
# The signature had template arguments.
|
||||
text = parts[1].rstrip(' \t\n>')
|
||||
arg = ''
|
||||
text = parts[1].rstrip(" \t\n>")
|
||||
arg = ""
|
||||
# Keep track of nesting to avoid splitting on ","s embedded
|
||||
# in the arguments themselves.
|
||||
depth = 0
|
||||
for c in text:
|
||||
if c == '<':
|
||||
if c == "<":
|
||||
depth = depth + 1
|
||||
if depth > 0 and not warned_about_nested_templates:
|
||||
warned_about_nested_templates = True
|
||||
print('Nested template argument in cxx_class.'
|
||||
' This feature is largely untested and '
|
||||
' may not work.')
|
||||
elif c == '>':
|
||||
print(
|
||||
"Nested template argument in cxx_class."
|
||||
" This feature is largely untested and "
|
||||
" may not work."
|
||||
)
|
||||
elif c == ">":
|
||||
depth = depth - 1
|
||||
elif c == ',' and depth == 0:
|
||||
elif c == "," and depth == 0:
|
||||
t_args.append(arg.strip())
|
||||
arg = ''
|
||||
arg = ""
|
||||
else:
|
||||
arg = arg + c
|
||||
if arg:
|
||||
t_args.append(arg.strip())
|
||||
# Split the non-template part on :: boundaries.
|
||||
class_path = base.split('::')
|
||||
class_path = base.split("::")
|
||||
|
||||
# The namespaces are everything except the last part of the class path.
|
||||
self.namespaces = class_path[:-1]
|
||||
@@ -125,7 +129,7 @@ class CxxClass(object):
|
||||
# Iterate through the template arguments and their values. This
|
||||
# will likely break if parameter packs are used.
|
||||
for arg, param in zip(t_args, template_params):
|
||||
type_keys = ('class', 'typename')
|
||||
type_keys = ("class", "typename")
|
||||
# If a parameter is a type, parse it recursively. Otherwise
|
||||
# assume it's a constant, and store it verbatim.
|
||||
if any(param.strip().startswith(kw) for kw in type_keys):
|
||||
@@ -140,21 +144,24 @@ class CxxClass(object):
|
||||
arg.declare(code)
|
||||
# Re-open the target namespace.
|
||||
for ns in self.namespaces:
|
||||
code('namespace $ns {')
|
||||
code("namespace $ns {")
|
||||
# If this is a class template...
|
||||
if self.template_params:
|
||||
code('template <${{", ".join(self.template_params)}}>')
|
||||
# The actual class declaration.
|
||||
code('class ${{self.name}};')
|
||||
code("class ${{self.name}};")
|
||||
# Close the target namespaces.
|
||||
for ns in reversed(self.namespaces):
|
||||
code('} // namespace $ns')
|
||||
code("} // namespace $ns")
|
||||
|
||||
code('''\
|
||||
|
||||
code(
|
||||
"""\
|
||||
#ifndef __PARAMS__${sim_object}__
|
||||
#define __PARAMS__${sim_object}__
|
||||
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
# The base SimObject has a couple of params that get
|
||||
@@ -162,10 +169,12 @@ code('''\
|
||||
# the normal Param mechanism; we slip them in here (needed
|
||||
# predecls now, actual declarations below)
|
||||
if sim_object == SimObject:
|
||||
code('''#include <string>''')
|
||||
code("""#include <string>""")
|
||||
|
||||
cxx_class = CxxClass(sim_object._value_dict['cxx_class'],
|
||||
sim_object._value_dict['cxx_template_params'])
|
||||
cxx_class = CxxClass(
|
||||
sim_object._value_dict["cxx_class"],
|
||||
sim_object._value_dict["cxx_template_params"],
|
||||
)
|
||||
|
||||
# A forward class declaration is sufficient since we are just
|
||||
# declaring a pointer.
|
||||
@@ -186,27 +195,29 @@ for ptype in ptypes:
|
||||
code('#include "enums/${{ptype.__name__}}.hh"')
|
||||
code()
|
||||
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code('')
|
||||
code("namespace gem5")
|
||||
code("{")
|
||||
code("")
|
||||
|
||||
# now generate the actual param struct
|
||||
code("struct ${sim_object}Params")
|
||||
if sim_object._base:
|
||||
code(" : public ${{sim_object._base.type}}Params")
|
||||
code("{")
|
||||
if not hasattr(sim_object, 'abstract') or not sim_object.abstract:
|
||||
if 'type' in sim_object.__dict__:
|
||||
if not hasattr(sim_object, "abstract") or not sim_object.abstract:
|
||||
if "type" in sim_object.__dict__:
|
||||
code(" ${{sim_object.cxx_type}} create() const;")
|
||||
|
||||
code.indent()
|
||||
if sim_object == SimObject:
|
||||
code('''
|
||||
code(
|
||||
"""
|
||||
SimObjectParams() {}
|
||||
virtual ~SimObjectParams() {}
|
||||
|
||||
std::string name;
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
for param in params:
|
||||
param.cxx_decl(code)
|
||||
@@ -214,11 +225,11 @@ for port in ports.values():
|
||||
port.cxx_decl(code)
|
||||
|
||||
code.dedent()
|
||||
code('};')
|
||||
code("};")
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
code("} // namespace gem5")
|
||||
|
||||
code()
|
||||
code('#endif // __PARAMS__${sim_object}__')
|
||||
code("#endif // __PARAMS__${sim_object}__")
|
||||
|
||||
code.write(args.param_hh)
|
||||
|
||||
@@ -50,7 +50,7 @@ from shutil import rmtree, copyfile
|
||||
|
||||
|
||||
def hex_mask(terms):
|
||||
dec_mask = reduce(operator.or_, [2 ** i for i in terms], 0)
|
||||
dec_mask = reduce(operator.or_, [2**i for i in terms], 0)
|
||||
return "%08x" % dec_mask
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def replace_tree(path):
|
||||
|
||||
|
||||
def config_filesystem(system, options=None):
|
||||
""" This function parses the system object to create the pseudo file system
|
||||
"""This function parses the system object to create the pseudo file system
|
||||
@param system: The system to create the config for
|
||||
@param options: An optional argument which contains an Options.py options
|
||||
object. This is useful if when use se.py and will set the L2 cache
|
||||
|
||||
@@ -177,7 +177,7 @@ def config_mem(options, system):
|
||||
from m5.util import fatal
|
||||
|
||||
intlv_bits = int(math.log(nbr_mem_ctrls, 2))
|
||||
if 2 ** intlv_bits != nbr_mem_ctrls:
|
||||
if 2**intlv_bits != nbr_mem_ctrls:
|
||||
fatal("Number of memory channels must be a power of 2")
|
||||
|
||||
if opt_mem_type:
|
||||
|
||||
@@ -42,7 +42,7 @@ from textwrap import TextWrapper
|
||||
|
||||
|
||||
class ObjectList(object):
|
||||
""" Creates a list of objects that are sub-classes of a given class. """
|
||||
"""Creates a list of objects that are sub-classes of a given class."""
|
||||
|
||||
def _is_obj_class(self, cls):
|
||||
"""Determine if a class is a a sub class of the provided base class
|
||||
@@ -161,10 +161,10 @@ class CPUList(ObjectList):
|
||||
|
||||
|
||||
class EnumList(ObjectList):
|
||||
""" Creates a list of possible values for a given enum class. """
|
||||
"""Creates a list of possible values for a given enum class."""
|
||||
|
||||
def _add_objects(self):
|
||||
""" Add all enum values to the ObjectList """
|
||||
"""Add all enum values to the ObjectList"""
|
||||
self._sub_classes = {}
|
||||
for (key, value) in list(self.base_cls.__members__.items()):
|
||||
# All Enums have a value Num_NAME at the end which we
|
||||
|
||||
@@ -46,8 +46,7 @@ parser = ArgumentParser()
|
||||
|
||||
|
||||
def add_option(*args, **kwargs):
|
||||
"""Call "add_option" to the global options parser
|
||||
"""
|
||||
"""Call "add_option" to the global options parser"""
|
||||
|
||||
if called_parse_args:
|
||||
m5.fatal("Can't add an option after calling SimpleOpts.parse_args")
|
||||
|
||||
33
configs/dist/sw.py
vendored
33
configs/dist/sw.py
vendored
@@ -35,33 +35,39 @@ from m5.defines import buildEnv
|
||||
from m5.objects import *
|
||||
from m5.util import addToPath, fatal
|
||||
|
||||
addToPath('../')
|
||||
addToPath("../")
|
||||
|
||||
from common import Simulation
|
||||
from common import Options
|
||||
|
||||
|
||||
def build_switch(args):
|
||||
# instantiate an EtherSwitch
|
||||
switch = EtherSwitch()
|
||||
# instantiate distEtherLinks to connect switch ports
|
||||
# to other gem5 instances
|
||||
switch.portlink = [DistEtherLink(speed = args.ethernet_linkspeed,
|
||||
delay = args.ethernet_linkdelay,
|
||||
dist_rank = args.dist_rank,
|
||||
dist_size = args.dist_size,
|
||||
server_name = args.dist_server_name,
|
||||
server_port = args.dist_server_port,
|
||||
sync_start = args.dist_sync_start,
|
||||
sync_repeat = args.dist_sync_repeat,
|
||||
is_switch = True,
|
||||
num_nodes = args.dist_size)
|
||||
for i in range(args.dist_size)]
|
||||
switch.portlink = [
|
||||
DistEtherLink(
|
||||
speed=args.ethernet_linkspeed,
|
||||
delay=args.ethernet_linkdelay,
|
||||
dist_rank=args.dist_rank,
|
||||
dist_size=args.dist_size,
|
||||
server_name=args.dist_server_name,
|
||||
server_port=args.dist_server_port,
|
||||
sync_start=args.dist_sync_start,
|
||||
sync_repeat=args.dist_sync_repeat,
|
||||
is_switch=True,
|
||||
num_nodes=args.dist_size,
|
||||
)
|
||||
for i in range(args.dist_size)
|
||||
]
|
||||
|
||||
for (i, link) in enumerate(switch.portlink):
|
||||
link.int0 = switch.interface[i]
|
||||
|
||||
return switch
|
||||
|
||||
|
||||
def main():
|
||||
# Add options
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -70,8 +76,9 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
system = build_switch(args)
|
||||
root = Root(full_system = True, system = system)
|
||||
root = Root(full_system=True, system=system)
|
||||
Simulation.run(args, root, None, None)
|
||||
|
||||
|
||||
if __name__ == "__m5_main__":
|
||||
main()
|
||||
|
||||
@@ -74,7 +74,7 @@ def create_cow_image(name):
|
||||
|
||||
|
||||
def create(args):
|
||||
""" Create and configure the system object. """
|
||||
"""Create and configure the system object."""
|
||||
|
||||
if args.readfile and not os.path.isfile(args.readfile):
|
||||
print("Error: Bootscript %s does not exist" % args.readfile)
|
||||
|
||||
@@ -97,7 +97,7 @@ def config_ruby(system, args):
|
||||
|
||||
|
||||
def create(args):
|
||||
""" Create and configure the system object. """
|
||||
"""Create and configure the system object."""
|
||||
|
||||
if args.script and not os.path.isfile(args.script):
|
||||
print("Error: Bootscript %s does not exist" % args.script)
|
||||
|
||||
@@ -85,7 +85,7 @@ def create_cow_image(name):
|
||||
|
||||
|
||||
def create(args):
|
||||
""" Create and configure the system object. """
|
||||
"""Create and configure the system object."""
|
||||
|
||||
if args.script and not os.path.isfile(args.script):
|
||||
print("Error: Bootscript %s does not exist" % args.script)
|
||||
|
||||
@@ -142,7 +142,7 @@ def get_processes(cmd):
|
||||
|
||||
|
||||
def create(args):
|
||||
""" Create and configure the system object. """
|
||||
"""Create and configure the system object."""
|
||||
|
||||
system = SimpleSeSystem(args)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ from common.SysPaths import binary, disk
|
||||
|
||||
|
||||
class ArmBaremetal(ArmFsWorkload):
|
||||
""" Baremetal workload """
|
||||
"""Baremetal workload"""
|
||||
|
||||
dtb_addr = 0
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ board.set_se_binary_workload(
|
||||
)
|
||||
|
||||
# Lastly we run the simulation.
|
||||
max_ticks = 10 ** 6
|
||||
max_ticks = 10**6
|
||||
simulator = Simulator(board=board, full_system=False)
|
||||
simulator.run(max_ticks=max_ticks)
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class L1Cache(L1Cache_Controller):
|
||||
|
||||
def getBlockSizeBits(self, system):
|
||||
bits = int(math.log(system.cache_line_size, 2))
|
||||
if 2 ** bits != system.cache_line_size.value:
|
||||
if 2**bits != system.cache_line_size.value:
|
||||
panic("Cache line size not a power of 2!")
|
||||
return bits
|
||||
|
||||
@@ -152,8 +152,7 @@ class L1Cache(L1Cache_Controller):
|
||||
return False
|
||||
|
||||
def connectQueues(self, ruby_system):
|
||||
"""Connect all of the queues for this controller.
|
||||
"""
|
||||
"""Connect all of the queues for this controller."""
|
||||
# mandatoryQueue is a special variable. It is used by the sequencer to
|
||||
# send RubyRequests from the CPU (or other processor). It isn't
|
||||
# explicitly connected to anything.
|
||||
@@ -184,8 +183,7 @@ class DirController(Directory_Controller):
|
||||
return cls._version - 1
|
||||
|
||||
def __init__(self, ruby_system, ranges, mem_ctrls):
|
||||
"""ranges are the memory ranges assigned to this controller.
|
||||
"""
|
||||
"""ranges are the memory ranges assigned to this controller."""
|
||||
if len(mem_ctrls) > 1:
|
||||
panic("This cache system can only be connected to one mem ctrl")
|
||||
super(DirController, self).__init__()
|
||||
@@ -217,8 +215,7 @@ class DirController(Directory_Controller):
|
||||
|
||||
|
||||
class MyNetwork(SimpleNetwork):
|
||||
"""A simple point-to-point network. This doesn't not use garnet.
|
||||
"""
|
||||
"""A simple point-to-point network. This doesn't not use garnet."""
|
||||
|
||||
def __init__(self, ruby_system):
|
||||
super(MyNetwork, self).__init__()
|
||||
|
||||
@@ -134,7 +134,7 @@ class L1Cache(L1Cache_Controller):
|
||||
|
||||
def getBlockSizeBits(self, system):
|
||||
bits = int(math.log(system.cache_line_size, 2))
|
||||
if 2 ** bits != system.cache_line_size.value:
|
||||
if 2**bits != system.cache_line_size.value:
|
||||
panic("Cache line size not a power of 2!")
|
||||
return bits
|
||||
|
||||
@@ -150,8 +150,7 @@ class L1Cache(L1Cache_Controller):
|
||||
return False
|
||||
|
||||
def connectQueues(self, ruby_system):
|
||||
"""Connect all of the queues for this controller.
|
||||
"""
|
||||
"""Connect all of the queues for this controller."""
|
||||
self.mandatoryQueue = MessageBuffer()
|
||||
self.requestFromCache = MessageBuffer(ordered=True)
|
||||
self.requestFromCache.out_port = ruby_system.network.in_port
|
||||
@@ -173,8 +172,7 @@ class DirController(Directory_Controller):
|
||||
return cls._version - 1
|
||||
|
||||
def __init__(self, ruby_system, ranges, mem_ctrls):
|
||||
"""ranges are the memory ranges assigned to this controller.
|
||||
"""
|
||||
"""ranges are the memory ranges assigned to this controller."""
|
||||
if len(mem_ctrls) > 1:
|
||||
panic("This cache system can only be connected to one mem ctrl")
|
||||
super(DirController, self).__init__()
|
||||
@@ -203,8 +201,7 @@ class DirController(Directory_Controller):
|
||||
|
||||
|
||||
class MyNetwork(SimpleNetwork):
|
||||
"""A simple point-to-point network. This doesn't not use garnet.
|
||||
"""
|
||||
"""A simple point-to-point network. This doesn't not use garnet."""
|
||||
|
||||
def __init__(self, ruby_system):
|
||||
super(MyNetwork, self).__init__()
|
||||
|
||||
@@ -52,7 +52,7 @@ def define_options(parser):
|
||||
|
||||
|
||||
def read_config_file(file):
|
||||
""" Read file as a module and return it """
|
||||
"""Read file as a module and return it"""
|
||||
import types
|
||||
import importlib.machinery
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ def setup_memory_controllers(system, ruby, dir_cntrls, options):
|
||||
|
||||
|
||||
def create_topology(controllers, options):
|
||||
""" Called from create_system in configs/ruby/<protocol>.py
|
||||
"""Called from create_system in configs/ruby/<protocol>.py
|
||||
Must return an object which is a subclass of BaseTopology
|
||||
found in configs/topologies/BaseTopology.py
|
||||
This is a wrapper for the legacy topologies.
|
||||
|
||||
@@ -31,14 +31,14 @@ class BaseTopology(object):
|
||||
description = "BaseTopology"
|
||||
|
||||
def __init__(self):
|
||||
""" When overriding place any objects created in
|
||||
"""When overriding place any objects created in
|
||||
configs/ruby/<protocol>.py that are needed in
|
||||
makeTopology (below) here. The minimum is usually
|
||||
all of the controllers created in the above file.
|
||||
"""
|
||||
|
||||
def makeTopology(self, options, network, IntLink, ExtLink, Router):
|
||||
""" Called from configs/ruby/Ruby.py
|
||||
"""Called from configs/ruby/Ruby.py
|
||||
The return value is ( list(Router), list(IntLink), list(ExtLink))
|
||||
The API of this function cannot change when subclassing!!
|
||||
Any additional information needed to create this topology should
|
||||
@@ -48,7 +48,7 @@ class BaseTopology(object):
|
||||
m5.util.fatal("BaseTopology should have been overridden!!")
|
||||
|
||||
def registerTopology(self, options):
|
||||
""" Called from configs/ruby/Ruby.py
|
||||
"""Called from configs/ruby/Ruby.py
|
||||
There is no return value. This should only be called in
|
||||
SE mode. It is used by some topology objects to populate
|
||||
the faux filesystem with accurate file contents.
|
||||
@@ -58,7 +58,7 @@ class BaseTopology(object):
|
||||
|
||||
|
||||
class SimpleTopology(BaseTopology):
|
||||
""" Provides methods needed for the topologies included in Ruby before
|
||||
"""Provides methods needed for the topologies included in Ruby before
|
||||
topology changes.
|
||||
These topologies are "simple" in the sense that they only use a flat
|
||||
list of controllers to construct the topology.
|
||||
|
||||
@@ -28,7 +28,7 @@ from topologies.BaseTopology import BaseTopology
|
||||
|
||||
|
||||
class Cluster(BaseTopology):
|
||||
""" A cluster is a group of nodes which are all one hop from eachother
|
||||
"""A cluster is a group of nodes which are all one hop from eachother
|
||||
Clusters can also contain other clusters
|
||||
When creating this kind of topology, return a single cluster (usually
|
||||
the root cluster) from create_system in configs/ruby/<protocol>.py
|
||||
@@ -55,7 +55,7 @@ class Cluster(BaseTopology):
|
||||
return cls._num_routers - 1
|
||||
|
||||
def __init__(self, intBW=0, extBW=0, intLatency=0, extLatency=0):
|
||||
""" internalBandwidth is bandwidth of all links within the cluster
|
||||
"""internalBandwidth is bandwidth of all links within the cluster
|
||||
externalBandwidth is bandwidth from this cluster to any cluster
|
||||
connecting to it.
|
||||
internal/externalLatency are similar
|
||||
@@ -74,8 +74,7 @@ class Cluster(BaseTopology):
|
||||
self.nodes.append(node)
|
||||
|
||||
def makeTopology(self, options, network, IntLink, ExtLink, Router):
|
||||
""" Recursively make all of the links and routers
|
||||
"""
|
||||
"""Recursively make all of the links and routers"""
|
||||
|
||||
# make a router to connect all of the nodes
|
||||
self.router = Router(router_id=self.num_routers())
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
import SCons.Node.FS
|
||||
|
||||
fs = SCons.Node.FS.get_default_fs()
|
||||
root = fs.Dir('#')
|
||||
root = fs.Dir("#")
|
||||
extra_python_nodes = [
|
||||
root.Dir('src').Dir('python').srcnode(), # gem5 includes
|
||||
root.Dir('ext').Dir('ply').srcnode(), # ply is used by several files
|
||||
root.Dir('ext').Dir('Kconfiglib').Dir('import').srcnode(), # kconfiglib
|
||||
root.Dir("src").Dir("python").srcnode(), # gem5 includes
|
||||
root.Dir("ext").Dir("ply").srcnode(), # ply is used by several files
|
||||
root.Dir("ext").Dir("Kconfiglib").Dir("import").srcnode(), # kconfiglib
|
||||
]
|
||||
|
||||
extra_python_paths = [ node.abspath for node in extra_python_nodes ]
|
||||
extra_python_paths = [node.abspath for node in extra_python_nodes]
|
||||
|
||||
__all__ = ['extra_python_paths']
|
||||
__all__ = ["extra_python_paths"]
|
||||
|
||||
@@ -52,34 +52,38 @@ import SCons.Script
|
||||
|
||||
termcap = get_termcap()
|
||||
|
||||
|
||||
def strip_build_path(path, env):
|
||||
path = str(path)
|
||||
build_base = 'build/'
|
||||
variant_base = env['BUILDROOT'] + os.path.sep
|
||||
build_base = "build/"
|
||||
variant_base = env["BUILDROOT"] + os.path.sep
|
||||
if path.startswith(variant_base):
|
||||
path = path[len(variant_base):]
|
||||
path = path[len(variant_base) :]
|
||||
elif path.startswith(build_base):
|
||||
path = path[len(build_base):]
|
||||
path = path[len(build_base) :]
|
||||
return path
|
||||
|
||||
|
||||
def TempFileSpawn(scons_env):
|
||||
old_pspawn = scons_env['PSPAWN']
|
||||
old_spawn = scons_env['SPAWN']
|
||||
old_pspawn = scons_env["PSPAWN"]
|
||||
old_spawn = scons_env["SPAWN"]
|
||||
|
||||
def wrapper(old, sh, esc, cmd, sh_args, *py_args):
|
||||
with tempfile.NamedTemporaryFile() as temp:
|
||||
temp.write(' '.join(sh_args).encode())
|
||||
temp.write(" ".join(sh_args).encode())
|
||||
temp.flush()
|
||||
sh_args = [sh, esc(temp.name)]
|
||||
return old(sh, esc, sh, sh_args, *py_args)
|
||||
|
||||
def new_pspawn(sh, esc, cmd, args, sh_env, stdout, stderr):
|
||||
return wrapper(old_pspawn, sh, esc, cmd, args, sh_env, stdout, stderr)
|
||||
|
||||
def new_spawn(sh, esc, cmd, args, sh_env):
|
||||
return wrapper(old_spawn, sh, esc, cmd, args, sh_env)
|
||||
|
||||
scons_env['PSPAWN'] = new_pspawn
|
||||
scons_env['SPAWN'] = new_spawn
|
||||
scons_env["PSPAWN"] = new_pspawn
|
||||
scons_env["SPAWN"] = new_spawn
|
||||
|
||||
|
||||
# Generate a string of the form:
|
||||
# common/path/prefix/src1, src2 -> tgt1, tgt2
|
||||
@@ -93,23 +97,32 @@ class Transform(object):
|
||||
tgts_color = termcap.Yellow + termcap.Bold
|
||||
|
||||
def __init__(self, tool, max_sources=99):
|
||||
self.format = self.tool_color + (" [%8s] " % tool) \
|
||||
+ self.pfx_color + "%s" \
|
||||
+ self.srcs_color + "%s" \
|
||||
+ self.arrow_color + " -> " \
|
||||
+ self.tgts_color + "%s" \
|
||||
self.format = (
|
||||
self.tool_color
|
||||
+ (" [%8s] " % tool)
|
||||
+ self.pfx_color
|
||||
+ "%s"
|
||||
+ self.srcs_color
|
||||
+ "%s"
|
||||
+ self.arrow_color
|
||||
+ " -> "
|
||||
+ self.tgts_color
|
||||
+ "%s"
|
||||
+ termcap.Normal
|
||||
)
|
||||
self.max_sources = max_sources
|
||||
|
||||
def __call__(self, target, source, env, for_signature=None):
|
||||
# truncate source list according to max_sources param
|
||||
source = source[0:self.max_sources]
|
||||
source = source[0 : self.max_sources]
|
||||
|
||||
def strip(f):
|
||||
return strip_build_path(str(f), env)
|
||||
|
||||
if len(source) > 0:
|
||||
srcs = list(map(strip, source))
|
||||
else:
|
||||
srcs = ['']
|
||||
srcs = [""]
|
||||
tgts = list(map(strip, target))
|
||||
# surprisingly, os.path.commonprefix is a dumb char-by-char string
|
||||
# operation that has nothing to do with paths.
|
||||
@@ -137,20 +150,23 @@ class Transform(object):
|
||||
if sep_idx != -1:
|
||||
com_pfx = com_pfx[0:sep_idx]
|
||||
else:
|
||||
com_pfx = ''
|
||||
com_pfx = ""
|
||||
elif src0_len > com_pfx_len and srcs[0][com_pfx_len] == ".":
|
||||
# still splitting at file extension: ok
|
||||
pass
|
||||
else:
|
||||
# probably a fluke; ignore it
|
||||
com_pfx = ''
|
||||
com_pfx = ""
|
||||
# recalculate length in case com_pfx was modified
|
||||
com_pfx_len = len(com_pfx)
|
||||
|
||||
def fmt(files):
|
||||
f = list(map(lambda s: s[com_pfx_len:], files))
|
||||
return ', '.join(f)
|
||||
return ", ".join(f)
|
||||
|
||||
return self.format % (com_pfx, fmt(srcs), fmt(tgts))
|
||||
|
||||
|
||||
# The width warning and error messages should be wrapped at.
|
||||
text_width = None
|
||||
|
||||
@@ -162,6 +178,7 @@ if not sys.stdout.isatty():
|
||||
if text_width is None:
|
||||
try:
|
||||
import shutil
|
||||
|
||||
text_width = shutil.get_terminal_size().columns
|
||||
except:
|
||||
pass
|
||||
@@ -170,6 +187,7 @@ if text_width is None:
|
||||
if text_width is None:
|
||||
try:
|
||||
import curses
|
||||
|
||||
try:
|
||||
_, text_width = curses.initscr().getmaxyx()
|
||||
finally:
|
||||
@@ -181,21 +199,22 @@ if text_width is None:
|
||||
if text_width is None:
|
||||
text_width = 80
|
||||
|
||||
|
||||
def print_message(prefix, color, message, **kwargs):
|
||||
prefix_len = len(prefix)
|
||||
if text_width > prefix_len:
|
||||
wrap_width = text_width - prefix_len
|
||||
padding = ' ' * prefix_len
|
||||
padding = " " * prefix_len
|
||||
|
||||
# First split on newlines.
|
||||
lines = message.split('\n')
|
||||
lines = message.split("\n")
|
||||
# Then wrap each line to the required width.
|
||||
wrapped_lines = []
|
||||
for line in lines:
|
||||
wrapped_lines.extend(textwrap.wrap(line, wrap_width))
|
||||
# Finally add the prefix and padding on extra lines, and glue it all
|
||||
# back together.
|
||||
message = prefix + ('\n' + padding).join(wrapped_lines)
|
||||
message = prefix + ("\n" + padding).join(wrapped_lines)
|
||||
else:
|
||||
# We have very small terminal, indent formatting doesn't help.
|
||||
message = prefix + message
|
||||
@@ -205,27 +224,36 @@ def print_message(prefix, color, message, **kwargs):
|
||||
print(message, **kwargs)
|
||||
return message
|
||||
|
||||
|
||||
all_warnings = []
|
||||
|
||||
|
||||
def summarize_warnings():
|
||||
if not all_warnings:
|
||||
return
|
||||
print(termcap.Yellow + termcap.Bold +
|
||||
'*** Summary of Warnings ***' +
|
||||
termcap.Normal)
|
||||
print(
|
||||
termcap.Yellow
|
||||
+ termcap.Bold
|
||||
+ "*** Summary of Warnings ***"
|
||||
+ termcap.Normal
|
||||
)
|
||||
list(map(print, all_warnings))
|
||||
|
||||
|
||||
def warning(*args, **kwargs):
|
||||
message = ' '.join(args)
|
||||
printed = print_message('Warning: ', termcap.Yellow, message, **kwargs)
|
||||
message = " ".join(args)
|
||||
printed = print_message("Warning: ", termcap.Yellow, message, **kwargs)
|
||||
all_warnings.append(printed)
|
||||
|
||||
|
||||
def error(*args, **kwargs):
|
||||
message = ' '.join(args)
|
||||
print_message('Error: ', termcap.Red, message, **kwargs)
|
||||
message = " ".join(args)
|
||||
print_message("Error: ", termcap.Red, message, **kwargs)
|
||||
SCons.Script.Exit(1)
|
||||
|
||||
|
||||
def parse_build_path(target):
|
||||
path_dirs = target.split('/')
|
||||
path_dirs = target.split("/")
|
||||
|
||||
# Pop off the target file.
|
||||
path_dirs.pop()
|
||||
@@ -233,40 +261,55 @@ def parse_build_path(target):
|
||||
# Search backwards for the "build" directory. Whatever was just before it
|
||||
# was the name of the variant.
|
||||
variant_dir = path_dirs.pop()
|
||||
while path_dirs and path_dirs[-1] != 'build':
|
||||
while path_dirs and path_dirs[-1] != "build":
|
||||
variant_dir = path_dirs.pop()
|
||||
if not path_dirs:
|
||||
error("No non-leaf 'build' dir found on target path.", t)
|
||||
|
||||
return os.path.join('/', *path_dirs), variant_dir
|
||||
return os.path.join("/", *path_dirs), variant_dir
|
||||
|
||||
|
||||
# The MakeAction wrapper, and a SCons tool to set up the *COMSTR variables.
|
||||
if SCons.Script.GetOption('verbose'):
|
||||
if SCons.Script.GetOption("verbose"):
|
||||
|
||||
def MakeAction(action, string, *args, **kwargs):
|
||||
return SCons.Script.Action(action, *args, **kwargs)
|
||||
|
||||
def MakeActionTool(env):
|
||||
pass
|
||||
|
||||
else:
|
||||
MakeAction = SCons.Script.Action
|
||||
|
||||
def MakeActionTool(env):
|
||||
env['CCCOMSTR'] = Transform("CC")
|
||||
env['CXXCOMSTR'] = Transform("CXX")
|
||||
env['ASCOMSTR'] = Transform("AS")
|
||||
env['ARCOMSTR'] = Transform("AR", 0)
|
||||
env['LINKCOMSTR'] = Transform("LINK", 0)
|
||||
env['SHLINKCOMSTR'] = Transform("SHLINK", 0)
|
||||
env['RANLIBCOMSTR'] = Transform("RANLIB", 0)
|
||||
env['M4COMSTR'] = Transform("M4")
|
||||
env['SHCCCOMSTR'] = Transform("SHCC")
|
||||
env['SHCXXCOMSTR'] = Transform("SHCXX")
|
||||
env["CCCOMSTR"] = Transform("CC")
|
||||
env["CXXCOMSTR"] = Transform("CXX")
|
||||
env["ASCOMSTR"] = Transform("AS")
|
||||
env["ARCOMSTR"] = Transform("AR", 0)
|
||||
env["LINKCOMSTR"] = Transform("LINK", 0)
|
||||
env["SHLINKCOMSTR"] = Transform("SHLINK", 0)
|
||||
env["RANLIBCOMSTR"] = Transform("RANLIB", 0)
|
||||
env["M4COMSTR"] = Transform("M4")
|
||||
env["SHCCCOMSTR"] = Transform("SHCC")
|
||||
env["SHCXXCOMSTR"] = Transform("SHCXX")
|
||||
|
||||
|
||||
def ToValue(obj):
|
||||
return SCons.Node.Python.Value(pickle.dumps(obj))
|
||||
|
||||
|
||||
def FromValue(node):
|
||||
return pickle.loads(node.read())
|
||||
|
||||
__all__ = ['Configure', 'EnvDefaults', 'Transform', 'warning', 'error',
|
||||
'MakeAction', 'MakeActionTool', 'ToValue', 'FromValue']
|
||||
|
||||
__all__ = [
|
||||
"Configure",
|
||||
"EnvDefaults",
|
||||
"Transform",
|
||||
"warning",
|
||||
"error",
|
||||
"MakeAction",
|
||||
"MakeActionTool",
|
||||
"ToValue",
|
||||
"FromValue",
|
||||
]
|
||||
|
||||
@@ -43,26 +43,23 @@ import sys
|
||||
|
||||
import SCons.Node.FS
|
||||
|
||||
|
||||
def AddLocalRPATH(env):
|
||||
def add_local_rpath(env, *targets):
|
||||
'''Set up an RPATH for a library which lives in the build directory.
|
||||
"""Set up an RPATH for a library which lives in the build directory.
|
||||
|
||||
The construction environment variable BIN_RPATH_PREFIX should be set
|
||||
to the relative path of the build directory starting from the location
|
||||
of the binary.'''
|
||||
of the binary."""
|
||||
for target in targets:
|
||||
target = env.Entry(target)
|
||||
if not isinstance(target, SCons.Node.FS.Dir):
|
||||
target = target.dir
|
||||
relpath = os.path.relpath(target.abspath, env['BUILDDIR'])
|
||||
components = [
|
||||
'\\$$ORIGIN',
|
||||
'${BIN_RPATH_PREFIX}',
|
||||
relpath
|
||||
]
|
||||
relpath = os.path.relpath(target.abspath, env["BUILDDIR"])
|
||||
components = ["\\$$ORIGIN", "${BIN_RPATH_PREFIX}", relpath]
|
||||
env.Append(RPATH=[env.Literal(os.path.join(*components))])
|
||||
|
||||
if sys.platform != "darwin":
|
||||
env.Append(LINKFLAGS=env.Split('-z origin'))
|
||||
env.Append(LINKFLAGS=env.Split("-z origin"))
|
||||
|
||||
env.AddMethod(add_local_rpath, 'AddLocalRPATH')
|
||||
env.AddMethod(add_local_rpath, "AddLocalRPATH")
|
||||
|
||||
@@ -46,19 +46,21 @@ from code_formatter import code_formatter
|
||||
|
||||
import SCons.Node.Python
|
||||
|
||||
|
||||
def build_blob(target, source, env):
|
||||
'''
|
||||
"""
|
||||
Embed an arbitrary blob into the gem5 executable,
|
||||
and make it accessible to C++ as a byte array.
|
||||
'''
|
||||
"""
|
||||
|
||||
with open(str(source[0]), 'rb') as f:
|
||||
with open(str(source[0]), "rb") as f:
|
||||
data = f.read()
|
||||
symbol = str(source[1])
|
||||
cc, hh = target
|
||||
|
||||
hh_code = code_formatter()
|
||||
hh_code('''\
|
||||
hh_code(
|
||||
"""\
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -72,13 +74,15 @@ extern const std::uint8_t ${symbol}[];
|
||||
|
||||
} // namespace Blobs
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
hh_code.write(str(hh))
|
||||
|
||||
include_path = os.path.relpath(hh.abspath, env['BUILDDIR'])
|
||||
include_path = os.path.relpath(hh.abspath, env["BUILDDIR"])
|
||||
|
||||
cc_code = code_formatter()
|
||||
cc_code('''\
|
||||
cc_code(
|
||||
"""\
|
||||
#include "${include_path}"
|
||||
|
||||
namespace gem5
|
||||
@@ -87,22 +91,28 @@ namespace Blobs
|
||||
{
|
||||
|
||||
const std::size_t ${symbol}_len = ${{len(data)}};
|
||||
''')
|
||||
"""
|
||||
)
|
||||
bytesToCppArray(cc_code, symbol, data)
|
||||
cc_code('''
|
||||
cc_code(
|
||||
"""
|
||||
} // namespace Blobs
|
||||
} // namespace gem5
|
||||
''')
|
||||
"""
|
||||
)
|
||||
cc_code.write(str(cc))
|
||||
|
||||
|
||||
blob_action = MakeAction(build_blob, Transform("EMBED BLOB"))
|
||||
|
||||
|
||||
def blob_emitter(target, source, env):
|
||||
symbol = str(target[0])
|
||||
cc_file = env.File(symbol + '.cc')
|
||||
hh_file = env.File(symbol + '.hh')
|
||||
cc_file = env.File(symbol + ".cc")
|
||||
hh_file = env.File(symbol + ".hh")
|
||||
return [cc_file, hh_file], [source, SCons.Node.Python.Value(symbol)]
|
||||
|
||||
|
||||
def Blob(env):
|
||||
blob_builder = env.Builder(action=blob_action, emitter=blob_emitter)
|
||||
env.Append(BUILDERS={'Blob': blob_builder})
|
||||
env.Append(BUILDERS={"Blob": blob_builder})
|
||||
|
||||
@@ -46,15 +46,16 @@ from gem5_scons import Transform, MakeAction
|
||||
#
|
||||
###################################################
|
||||
|
||||
|
||||
def ConfigFile(env):
|
||||
# This function generates a config header file that #defines the
|
||||
# variable symbol to the current variable setting (0 or 1). The source
|
||||
# operands are the name of the variable and a Value node containing the
|
||||
# value of the variable.
|
||||
def build_config_file(target, source, env):
|
||||
(variable, value) = [s.get_contents().decode('utf-8') for s in source]
|
||||
with open(str(target[0].abspath), 'w') as f:
|
||||
print('#define', variable, value, file=f)
|
||||
(variable, value) = [s.get_contents().decode("utf-8") for s in source]
|
||||
with open(str(target[0].abspath), "w") as f:
|
||||
print("#define", variable, value, file=f)
|
||||
return None
|
||||
|
||||
# Combine the two functions into a scons Action object.
|
||||
@@ -66,8 +67,8 @@ def ConfigFile(env):
|
||||
# extract variable name from Builder arg
|
||||
variable = str(target[0])
|
||||
# True target is config header file
|
||||
target = env.Dir('config').File(variable.lower() + '.hh')
|
||||
val = env['CONF'][variable]
|
||||
target = env.Dir("config").File(variable.lower() + ".hh")
|
||||
val = env["CONF"][variable]
|
||||
if isinstance(val, bool):
|
||||
# Force value to 0/1
|
||||
val = str(int(val))
|
||||
@@ -79,4 +80,4 @@ def ConfigFile(env):
|
||||
|
||||
config_builder = env.Builder(emitter=config_emitter, action=config_action)
|
||||
|
||||
env.Append(BUILDERS = { 'ConfigFile' : config_builder })
|
||||
env.Append(BUILDERS={"ConfigFile": config_builder})
|
||||
|
||||
@@ -51,27 +51,32 @@ from gem5_scons import Transform, MakeAction
|
||||
#
|
||||
###################################################
|
||||
|
||||
|
||||
def SwitchingHeaders(env):
|
||||
def build_switching_header(target, source, env):
|
||||
path = str(target[0])
|
||||
subdir = str(source[0])
|
||||
dp, fp = os.path.split(path)
|
||||
dp = os.path.relpath(os.path.realpath(dp),
|
||||
os.path.realpath(env['BUILDDIR']))
|
||||
with open(path, 'w') as hdr:
|
||||
dp = os.path.relpath(
|
||||
os.path.realpath(dp), os.path.realpath(env["BUILDDIR"])
|
||||
)
|
||||
with open(path, "w") as hdr:
|
||||
print('#include "%s/%s/%s"' % (dp, subdir, fp), file=hdr)
|
||||
|
||||
switching_header_action = MakeAction(build_switching_header,
|
||||
Transform('GENERATE'))
|
||||
switching_header_action = MakeAction(
|
||||
build_switching_header, Transform("GENERATE")
|
||||
)
|
||||
|
||||
switching_header_builder = env.Builder(action=switching_header_action,
|
||||
switching_header_builder = env.Builder(
|
||||
action=switching_header_action,
|
||||
source_factory=env.Value,
|
||||
single_source=True)
|
||||
single_source=True,
|
||||
)
|
||||
|
||||
env.Append(BUILDERS = { 'SwitchingHeader': switching_header_builder })
|
||||
env.Append(BUILDERS={"SwitchingHeader": switching_header_builder})
|
||||
|
||||
def switching_headers(self, headers, source):
|
||||
for header in headers:
|
||||
self.SwitchingHeader(header, source)
|
||||
|
||||
env.AddMethod(switching_headers, 'SwitchingHeaders')
|
||||
env.AddMethod(switching_headers, "SwitchingHeaders")
|
||||
|
||||
@@ -44,39 +44,41 @@ import os
|
||||
import SCons.Script
|
||||
import SCons.Util
|
||||
|
||||
|
||||
def CheckCxxFlag(context, flag, autoadd=True):
|
||||
context.Message("Checking for compiler %s support... " % flag)
|
||||
last_cxxflags = context.env['CXXFLAGS']
|
||||
last_cxxflags = context.env["CXXFLAGS"]
|
||||
context.env.Append(CXXFLAGS=[flag])
|
||||
pre_werror = context.env['CXXFLAGS']
|
||||
context.env.Append(CXXFLAGS=['-Werror'])
|
||||
ret = context.TryCompile('// CheckCxxFlag DO NOTHING', '.cc')
|
||||
context.env['CXXFLAGS'] = pre_werror
|
||||
pre_werror = context.env["CXXFLAGS"]
|
||||
context.env.Append(CXXFLAGS=["-Werror"])
|
||||
ret = context.TryCompile("// CheckCxxFlag DO NOTHING", ".cc")
|
||||
context.env["CXXFLAGS"] = pre_werror
|
||||
if not (ret and autoadd):
|
||||
context.env['CXXFLAGS'] = last_cxxflags
|
||||
context.env["CXXFLAGS"] = last_cxxflags
|
||||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def CheckLinkFlag(context, flag, autoadd=True, set_for_shared=True):
|
||||
context.Message("Checking for linker %s support... " % flag)
|
||||
last_linkflags = context.env['LINKFLAGS']
|
||||
last_linkflags = context.env["LINKFLAGS"]
|
||||
context.env.Append(LINKFLAGS=[flag])
|
||||
pre_werror = context.env['LINKFLAGS']
|
||||
context.env.Append(LINKFLAGS=['-Werror'])
|
||||
ret = context.TryLink('int main(int, char *[]) { return 0; }', '.cc')
|
||||
context.env['LINKFLAGS'] = pre_werror
|
||||
pre_werror = context.env["LINKFLAGS"]
|
||||
context.env.Append(LINKFLAGS=["-Werror"])
|
||||
ret = context.TryLink("int main(int, char *[]) { return 0; }", ".cc")
|
||||
context.env["LINKFLAGS"] = pre_werror
|
||||
if not (ret and autoadd):
|
||||
context.env['LINKFLAGS'] = last_linkflags
|
||||
if (ret and set_for_shared):
|
||||
assert(autoadd)
|
||||
context.env["LINKFLAGS"] = last_linkflags
|
||||
if ret and set_for_shared:
|
||||
assert autoadd
|
||||
context.env.Append(SHLINKFLAGS=[flag])
|
||||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
|
||||
# Add a custom Check function to test for structure members.
|
||||
def CheckMember(context, include, decl, member, include_quotes="<>"):
|
||||
context.Message("Checking for member %s in %s..." %
|
||||
(member, decl))
|
||||
context.Message("Checking for member %s in %s..." % (member, decl))
|
||||
text = """
|
||||
#include %(header)s
|
||||
int main(){
|
||||
@@ -84,18 +86,21 @@ int main(){
|
||||
(void)test.%(member)s;
|
||||
return 0;
|
||||
};
|
||||
""" % { "header" : include_quotes[0] + include + include_quotes[1],
|
||||
"decl" : decl,
|
||||
"member" : member,
|
||||
""" % {
|
||||
"header": include_quotes[0] + include + include_quotes[1],
|
||||
"decl": decl,
|
||||
"member": member,
|
||||
}
|
||||
|
||||
ret = context.TryCompile(text, extension=".cc")
|
||||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def CheckPythonLib(context):
|
||||
context.Message('Checking Python version... ')
|
||||
ret = context.TryRun(r"""
|
||||
context.Message("Checking Python version... ")
|
||||
ret = context.TryRun(
|
||||
r"""
|
||||
#include <pybind11/embed.h>
|
||||
|
||||
int
|
||||
@@ -107,21 +112,24 @@ main(int argc, char **argv) {
|
||||
"sys.stdout.write('%i.%i.%i' % (vi.major, vi.minor, vi.micro));\n");
|
||||
return 0;
|
||||
}
|
||||
""", extension=".cc")
|
||||
""",
|
||||
extension=".cc",
|
||||
)
|
||||
context.Result(ret[1] if ret[0] == 1 else 0)
|
||||
if ret[0] == 0:
|
||||
return None
|
||||
else:
|
||||
return tuple(map(int, ret[1].split(".")))
|
||||
|
||||
|
||||
def CheckPkgConfig(context, pkgs, *args):
|
||||
if not SCons.Util.is_List(pkgs):
|
||||
pkgs = [pkgs]
|
||||
assert(pkgs)
|
||||
assert pkgs
|
||||
|
||||
for pkg in pkgs:
|
||||
context.Message('Checking for pkg-config package %s... ' % pkg)
|
||||
ret = context.TryAction('pkg-config %s' % pkg)[0]
|
||||
context.Message("Checking for pkg-config package %s... " % pkg)
|
||||
ret = context.TryAction("pkg-config %s" % pkg)[0]
|
||||
if not ret:
|
||||
context.Result(ret)
|
||||
continue
|
||||
@@ -129,7 +137,7 @@ def CheckPkgConfig(context, pkgs, *args):
|
||||
if len(args) == 0:
|
||||
break
|
||||
|
||||
cmd = ' '.join(['pkg-config'] + list(args) + [pkg])
|
||||
cmd = " ".join(["pkg-config"] + list(args) + [pkg])
|
||||
try:
|
||||
context.env.ParseConfig(cmd)
|
||||
ret = 1
|
||||
@@ -141,20 +149,25 @@ def CheckPkgConfig(context, pkgs, *args):
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def Configure(env, *args, **kwargs):
|
||||
kwargs.setdefault('conf_dir',
|
||||
os.path.join(env['GEM5BUILD'], 'scons_config'))
|
||||
kwargs.setdefault('log_file',
|
||||
os.path.join(env['GEM5BUILD'], 'scons_config.log'))
|
||||
kwargs.setdefault('custom_tests', {})
|
||||
kwargs['custom_tests'].update({
|
||||
'CheckCxxFlag' : CheckCxxFlag,
|
||||
'CheckLinkFlag' : CheckLinkFlag,
|
||||
'CheckMember' : CheckMember,
|
||||
'CheckPkgConfig' : CheckPkgConfig,
|
||||
'CheckPythonLib' : CheckPythonLib,
|
||||
})
|
||||
kwargs.setdefault(
|
||||
"conf_dir", os.path.join(env["GEM5BUILD"], "scons_config")
|
||||
)
|
||||
kwargs.setdefault(
|
||||
"log_file", os.path.join(env["GEM5BUILD"], "scons_config.log")
|
||||
)
|
||||
kwargs.setdefault("custom_tests", {})
|
||||
kwargs["custom_tests"].update(
|
||||
{
|
||||
"CheckCxxFlag": CheckCxxFlag,
|
||||
"CheckLinkFlag": CheckLinkFlag,
|
||||
"CheckMember": CheckMember,
|
||||
"CheckPkgConfig": CheckPkgConfig,
|
||||
"CheckPythonLib": CheckPythonLib,
|
||||
}
|
||||
)
|
||||
conf = SCons.Script.Configure(env, *args, **kwargs)
|
||||
|
||||
# Recent versions of scons substitute a "Null" object for Configure()
|
||||
@@ -163,14 +176,17 @@ def Configure(env, *args, **kwargs):
|
||||
# breaking all our configuration checks. We replace it with our own
|
||||
# more optimistic null object that returns True instead.
|
||||
if not conf:
|
||||
|
||||
def NullCheck(*args, **kwargs):
|
||||
return True
|
||||
|
||||
class NullConf:
|
||||
def __init__(self, env):
|
||||
self.env = env
|
||||
|
||||
def Finish(self):
|
||||
return self.env
|
||||
|
||||
def __getattr__(self, mname):
|
||||
return NullCheck
|
||||
|
||||
|
||||
@@ -42,13 +42,32 @@ import os
|
||||
|
||||
from gem5_python_paths import extra_python_paths
|
||||
|
||||
|
||||
def EnvDefaults(env):
|
||||
# export TERM so that clang reports errors in color
|
||||
use_vars = set([ 'AS', 'AR', 'CC', 'CXX', 'HOME', 'LD_LIBRARY_PATH',
|
||||
'LIBRARY_PATH', 'PATH', 'PKG_CONFIG_PATH', 'PROTOC',
|
||||
'PYTHONPATH', 'RANLIB', 'TERM', 'PYTHON_CONFIG',
|
||||
'CCFLAGS_EXTRA', 'GEM5PY_CCFLAGS_EXTRA',
|
||||
'GEM5PY_LINKFLAGS_EXTRA', 'LINKFLAGS_EXTRA', 'LANG'])
|
||||
use_vars = set(
|
||||
[
|
||||
"AS",
|
||||
"AR",
|
||||
"CC",
|
||||
"CXX",
|
||||
"HOME",
|
||||
"LD_LIBRARY_PATH",
|
||||
"LIBRARY_PATH",
|
||||
"PATH",
|
||||
"PKG_CONFIG_PATH",
|
||||
"PROTOC",
|
||||
"PYTHONPATH",
|
||||
"RANLIB",
|
||||
"TERM",
|
||||
"PYTHON_CONFIG",
|
||||
"CCFLAGS_EXTRA",
|
||||
"GEM5PY_CCFLAGS_EXTRA",
|
||||
"GEM5PY_LINKFLAGS_EXTRA",
|
||||
"LINKFLAGS_EXTRA",
|
||||
"LANG",
|
||||
]
|
||||
)
|
||||
|
||||
use_prefixes = [
|
||||
"ASAN_", # address sanitizer symbolizer path and settings
|
||||
@@ -60,38 +79,39 @@ def EnvDefaults(env):
|
||||
"NIX_", # wrapped binaries if using nix package manager
|
||||
]
|
||||
|
||||
for key,val in sorted(os.environ.items()):
|
||||
if key in use_vars or \
|
||||
any([key.startswith(prefix) for prefix in use_prefixes]):
|
||||
env['ENV'][key] = val
|
||||
for key, val in sorted(os.environ.items()):
|
||||
if key in use_vars or any(
|
||||
[key.startswith(prefix) for prefix in use_prefixes]
|
||||
):
|
||||
env["ENV"][key] = val
|
||||
|
||||
# These variables from the environment override/become SCons variables,
|
||||
# with a default if they weren't in the host environment.
|
||||
var_overrides = {
|
||||
'CC': env['CC'],
|
||||
'CXX': env['CXX'],
|
||||
'PROTOC': 'protoc',
|
||||
'PYTHON_CONFIG': [ 'python3-config', 'python-config' ],
|
||||
'CCFLAGS_EXTRA': '',
|
||||
'GEM5PY_CCFLAGS_EXTRA': '',
|
||||
'GEM5PY_LINKFLAGS_EXTRA': '',
|
||||
'LINKFLAGS_EXTRA': '',
|
||||
"CC": env["CC"],
|
||||
"CXX": env["CXX"],
|
||||
"PROTOC": "protoc",
|
||||
"PYTHON_CONFIG": ["python3-config", "python-config"],
|
||||
"CCFLAGS_EXTRA": "",
|
||||
"GEM5PY_CCFLAGS_EXTRA": "",
|
||||
"GEM5PY_LINKFLAGS_EXTRA": "",
|
||||
"LINKFLAGS_EXTRA": "",
|
||||
}
|
||||
for key,default in var_overrides.items():
|
||||
env[key] = env['ENV'].get(key, default)
|
||||
for key, default in var_overrides.items():
|
||||
env[key] = env["ENV"].get(key, default)
|
||||
|
||||
# Tell scons to avoid implicit command dependencies to avoid issues
|
||||
# with the param wrappes being compiled twice (see
|
||||
# https://github.com/SCons/scons/issues/2811
|
||||
env['IMPLICIT_COMMAND_DEPENDENCIES'] = 0
|
||||
env.Decider('MD5-timestamp')
|
||||
env["IMPLICIT_COMMAND_DEPENDENCIES"] = 0
|
||||
env.Decider("MD5-timestamp")
|
||||
|
||||
# add useful python code PYTHONPATH so it can be used by subprocesses
|
||||
# as well
|
||||
env.AppendENVPath('PYTHONPATH', extra_python_paths)
|
||||
env.AppendENVPath("PYTHONPATH", extra_python_paths)
|
||||
|
||||
# Default duplicate option is to use hard links, but this messes up
|
||||
# when you use emacs to edit a file in the target dir, as emacs moves
|
||||
# file to file~ then copies to file, breaking the link. Symbolic
|
||||
# (soft) links work better.
|
||||
env.SetOption('duplicate', 'soft-copy')
|
||||
env.SetOption("duplicate", "soft-copy")
|
||||
|
||||
@@ -47,8 +47,9 @@ import SCons.Script
|
||||
# When specifying a source file of some type, a set of tags can be
|
||||
# specified for that file.
|
||||
|
||||
|
||||
def tag_implies(env, tag, tag_list):
|
||||
'''
|
||||
"""
|
||||
Associates a tag X to a list of tags which are implied by X.
|
||||
|
||||
For example, assume:
|
||||
@@ -72,10 +73,10 @@ def tag_implies(env, tag, tag_list):
|
||||
|
||||
So that any use of a tag will automatically include its transitive tags
|
||||
after being resolved.
|
||||
'''
|
||||
"""
|
||||
|
||||
env.SetDefault(_tag_implies={})
|
||||
implications = env['_tag_implies']
|
||||
implications = env["_tag_implies"]
|
||||
|
||||
if isinstance(tag_list, str):
|
||||
tag_list = frozenset([tag_list])
|
||||
@@ -95,21 +96,23 @@ def tag_implies(env, tag, tag_list):
|
||||
|
||||
# Check if another tag depends on this tag. If so, add this tag's
|
||||
# implications to that tag.
|
||||
for t,implied in implications.items():
|
||||
for t, implied in implications.items():
|
||||
if tag in implied:
|
||||
implications[t] |= implications[tag]
|
||||
|
||||
|
||||
def TagImpliesTool(env):
|
||||
env.AddMethod(tag_implies, 'TagImplies')
|
||||
env.AddMethod(tag_implies, "TagImplies")
|
||||
|
||||
|
||||
def resolve_tags(env, tags):
|
||||
'''
|
||||
"""
|
||||
Returns the complete set of tags implied (dependencies) by the
|
||||
supplied tags.
|
||||
'''
|
||||
"""
|
||||
|
||||
implications = env.SetDefault(_tag_implies={})
|
||||
implications = env['_tag_implies']
|
||||
implications = env["_tag_implies"]
|
||||
|
||||
if isinstance(tags, str):
|
||||
tags = frozenset([tags])
|
||||
@@ -122,53 +125,71 @@ def resolve_tags(env, tags):
|
||||
tags |= implications[tag]
|
||||
return tags
|
||||
|
||||
|
||||
class SourceFilter(object):
|
||||
factories = {}
|
||||
|
||||
def __init__(self, predicate):
|
||||
self.predicate = predicate
|
||||
|
||||
def __or__(self, other):
|
||||
return SourceFilter(lambda env, tags: self.predicate(env, tags) or
|
||||
other.predicate(env, tags))
|
||||
return SourceFilter(
|
||||
lambda env, tags: self.predicate(env, tags)
|
||||
or other.predicate(env, tags)
|
||||
)
|
||||
|
||||
def __and__(self, other):
|
||||
return SourceFilter(lambda env, tags: self.predicate(env, tags) and
|
||||
other.predicate(env, tags))
|
||||
return SourceFilter(
|
||||
lambda env, tags: self.predicate(env, tags)
|
||||
and other.predicate(env, tags)
|
||||
)
|
||||
|
||||
|
||||
def with_any_tags(*tags):
|
||||
'''Return a list of sources with any of the supplied tags.'''
|
||||
return SourceFilter(lambda env, stags: \
|
||||
len(resolve_tags(env, tags) & stags) > 0)
|
||||
"""Return a list of sources with any of the supplied tags."""
|
||||
return SourceFilter(
|
||||
lambda env, stags: len(resolve_tags(env, tags) & stags) > 0
|
||||
)
|
||||
|
||||
|
||||
def with_all_tags(*tags):
|
||||
'''Return a list of sources with all of the supplied tags.'''
|
||||
"""Return a list of sources with all of the supplied tags."""
|
||||
return SourceFilter(lambda env, stags: resolve_tags(env, tags) <= stags)
|
||||
|
||||
|
||||
def with_tag(tag):
|
||||
'''Return a list of sources with the supplied tag.'''
|
||||
"""Return a list of sources with the supplied tag."""
|
||||
return with_any_tags(*[tag])
|
||||
|
||||
|
||||
def without_tags(*tags):
|
||||
'''Return a list of sources without any of the supplied tags.'''
|
||||
return SourceFilter(lambda env, stags: \
|
||||
len(resolve_tags(env, tags) & stags) == 0)
|
||||
"""Return a list of sources without any of the supplied tags."""
|
||||
return SourceFilter(
|
||||
lambda env, stags: len(resolve_tags(env, tags) & stags) == 0
|
||||
)
|
||||
|
||||
|
||||
def without_tag(tag):
|
||||
'''Return a list of sources without the supplied tag.'''
|
||||
"""Return a list of sources without the supplied tag."""
|
||||
return without_tags(*[tag])
|
||||
|
||||
SourceFilter.factories.update({
|
||||
'with_any_tags': with_any_tags,
|
||||
'with_all_tags': with_all_tags,
|
||||
'with_tag': with_tag,
|
||||
'without_tags': without_tags,
|
||||
'without_tag': without_tag,
|
||||
})
|
||||
|
||||
SourceFilter.factories.update(
|
||||
{
|
||||
"with_any_tags": with_any_tags,
|
||||
"with_all_tags": with_all_tags,
|
||||
"with_tag": with_tag,
|
||||
"without_tags": without_tags,
|
||||
"without_tag": without_tag,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class SourceList(list):
|
||||
def apply_filter(self, env, f):
|
||||
def match(source):
|
||||
return f.predicate(env, resolve_tags(env, source.tags))
|
||||
|
||||
return SourceList(filter(match, self))
|
||||
|
||||
def __getattr__(self, name):
|
||||
@@ -179,33 +200,38 @@ class SourceList(list):
|
||||
@functools.wraps(func)
|
||||
def wrapper(env, *args, **kwargs):
|
||||
return self.apply_filter(env, func(*args, **kwargs))
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class SourceMeta(type):
|
||||
'''Meta class for source files that keeps track of all files of a
|
||||
particular type.'''
|
||||
"""Meta class for source files that keeps track of all files of a
|
||||
particular type."""
|
||||
|
||||
def __init__(cls, name, bases, dict):
|
||||
super(SourceMeta, cls).__init__(name, bases, dict)
|
||||
cls.all = SourceList()
|
||||
|
||||
|
||||
class SourceItem(object, metaclass=SourceMeta):
|
||||
'''Base object that encapsulates the notion of a source component for
|
||||
"""Base object that encapsulates the notion of a source component for
|
||||
gem5. This specifies a set of tags which help group components into groups
|
||||
based on arbitrary properties.'''
|
||||
based on arbitrary properties."""
|
||||
|
||||
def __init__(self, source, tags=None, add_tags=None, append=None):
|
||||
self.source = source
|
||||
|
||||
if tags is None:
|
||||
tags='gem5 lib'
|
||||
tags = "gem5 lib"
|
||||
if isinstance(tags, str):
|
||||
tags = { tags }
|
||||
tags = {tags}
|
||||
if not isinstance(tags, set):
|
||||
tags = set(tags)
|
||||
self.tags = tags.copy()
|
||||
|
||||
if add_tags:
|
||||
if isinstance(add_tags, str):
|
||||
add_tags = { add_tags }
|
||||
add_tags = {add_tags}
|
||||
if not isinstance(add_tags, set):
|
||||
add_tags = set(add_tags)
|
||||
self.tags |= add_tags
|
||||
@@ -216,10 +242,11 @@ class SourceItem(object, metaclass=SourceMeta):
|
||||
if issubclass(base, SourceItem):
|
||||
base.all.append(self)
|
||||
|
||||
|
||||
class SourceFile(SourceItem):
|
||||
'''Base object that encapsulates the notion of a source file.
|
||||
"""Base object that encapsulates the notion of a source file.
|
||||
This includes, the source node, target node, various manipulations
|
||||
of those.'''
|
||||
of those."""
|
||||
|
||||
def __init__(self, source, tags=None, add_tags=None, append=None):
|
||||
super().__init__(source, tags=tags, add_tags=add_tags, append=append)
|
||||
@@ -243,6 +270,15 @@ class SourceFile(SourceItem):
|
||||
return env.SharedObject(self.tnode)
|
||||
|
||||
|
||||
__all__ = ['TagImpliesTool', 'SourceFilter', 'SourceList', 'SourceFile',
|
||||
'SourceItem', 'with_any_tags', 'with_all_tags', 'with_tag',
|
||||
'without_tags', 'without_tag']
|
||||
__all__ = [
|
||||
"TagImpliesTool",
|
||||
"SourceFilter",
|
||||
"SourceList",
|
||||
"SourceFile",
|
||||
"SourceItem",
|
||||
"with_any_tags",
|
||||
"with_all_tags",
|
||||
"with_tag",
|
||||
"without_tags",
|
||||
"without_tag",
|
||||
]
|
||||
|
||||
@@ -46,12 +46,15 @@ import SCons.Script
|
||||
|
||||
import m5.util.terminal
|
||||
|
||||
|
||||
def ignore_style():
|
||||
"""Determine whether we should ignore style checks"""
|
||||
return SCons.Script.GetOption('ignore_style') or not sys.stdin.isatty()
|
||||
return SCons.Script.GetOption("ignore_style") or not sys.stdin.isatty()
|
||||
|
||||
|
||||
def get_termcap():
|
||||
return m5.util.terminal.get_termcap(SCons.Script.GetOption('use_colors'))
|
||||
return m5.util.terminal.get_termcap(SCons.Script.GetOption("use_colors"))
|
||||
|
||||
|
||||
def readCommand(cmd, **kwargs):
|
||||
"""
|
||||
@@ -68,13 +71,13 @@ def readCommand(cmd, **kwargs):
|
||||
if isinstance(cmd, str):
|
||||
cmd = cmd.split()
|
||||
|
||||
no_exception = 'exception' in kwargs
|
||||
exception = kwargs.pop('exception', None)
|
||||
no_exception = "exception" in kwargs
|
||||
exception = kwargs.pop("exception", None)
|
||||
|
||||
kwargs.setdefault('shell', False)
|
||||
kwargs.setdefault('stdout', PIPE)
|
||||
kwargs.setdefault('stderr', STDOUT)
|
||||
kwargs.setdefault('close_fds', True)
|
||||
kwargs.setdefault("shell", False)
|
||||
kwargs.setdefault("stdout", PIPE)
|
||||
kwargs.setdefault("stderr", STDOUT)
|
||||
kwargs.setdefault("close_fds", True)
|
||||
try:
|
||||
subp = Popen(cmd, **kwargs)
|
||||
except Exception as e:
|
||||
@@ -82,20 +85,23 @@ def readCommand(cmd, **kwargs):
|
||||
return -1, exception
|
||||
raise
|
||||
|
||||
output = subp.communicate()[0].decode('utf-8')
|
||||
output = subp.communicate()[0].decode("utf-8")
|
||||
return output
|
||||
|
||||
|
||||
def compareVersions(v1, v2):
|
||||
"""helper function: compare arrays or strings of version numbers.
|
||||
E.g., compare_version((1,3,25), (1,4,1)')
|
||||
returns -1, 0, 1 if v1 is <, ==, > v2
|
||||
"""
|
||||
|
||||
def make_version_list(v):
|
||||
if isinstance(v, (list,tuple)):
|
||||
if isinstance(v, (list, tuple)):
|
||||
return v
|
||||
elif isinstance(v, str):
|
||||
return list(map(lambda x: int(re.match('\d+', x).group()),
|
||||
v.split('.')))
|
||||
return list(
|
||||
map(lambda x: int(re.match("\d+", x).group()), v.split("."))
|
||||
)
|
||||
else:
|
||||
raise TypeError()
|
||||
|
||||
@@ -104,8 +110,10 @@ def compareVersions(v1, v2):
|
||||
|
||||
# Compare corresponding elements of lists
|
||||
# The shorter list is filled with 0 till the lists have the same length
|
||||
for n1,n2 in itertools.zip_longest(v1, v2, fillvalue=0):
|
||||
if n1 < n2: return -1
|
||||
if n1 > n2: return 1
|
||||
for n1, n2 in itertools.zip_longest(v1, v2, fillvalue=0):
|
||||
if n1 < n2:
|
||||
return -1
|
||||
if n1 > n2:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
@@ -44,10 +44,12 @@ from __future__ import print_function
|
||||
try:
|
||||
EnsureSConsVersion(3, 0, 0)
|
||||
except SystemExit as e:
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
For more details, see:
|
||||
http://gem5.org/documentation/general_docs/building
|
||||
""")
|
||||
"""
|
||||
)
|
||||
raise
|
||||
|
||||
|
||||
@@ -55,7 +57,8 @@ For more details, see:
|
||||
try:
|
||||
EnsurePythonVersion(3, 6)
|
||||
except SystemExit as e:
|
||||
print("""\033[93m
|
||||
print(
|
||||
"""\033[93m
|
||||
Python 3 is now required.
|
||||
|
||||
The following are steps to compile gem5 in Python 3 environment,
|
||||
@@ -81,7 +84,8 @@ Python 3 environment,
|
||||
|
||||
(Optional) For convenience reasons, you can set up an alias for the Python3 \
|
||||
scons phrase in your environment. \033[0m
|
||||
""")
|
||||
"""
|
||||
)
|
||||
raise
|
||||
|
||||
from gem5_python_paths import extra_python_paths
|
||||
|
||||
@@ -50,15 +50,20 @@ to ensure that your code follows gem5's style rules on git commit.
|
||||
This script will now install the hook in your .git/hooks/ directory.
|
||||
Press enter to continue, or ctrl-c to abort: """
|
||||
|
||||
|
||||
def install_style_hooks(env):
|
||||
try:
|
||||
gitdir = env.Dir(gem5_scons.util.readCommand(
|
||||
["git", "rev-parse", "--git-dir"]).strip("\n"))
|
||||
gitdir = env.Dir(
|
||||
gem5_scons.util.readCommand(
|
||||
["git", "rev-parse", "--git-dir"]
|
||||
).strip("\n")
|
||||
)
|
||||
except Exception as e:
|
||||
print("Warning: Failed to find git repo directory: %s" % e)
|
||||
return
|
||||
|
||||
git_hooks = gitdir.Dir("hooks")
|
||||
|
||||
def hook_exists(hook_name):
|
||||
hook = git_hooks.File(hook_name)
|
||||
return hook.exists()
|
||||
@@ -66,8 +71,9 @@ def install_style_hooks(env):
|
||||
def hook_install(hook_name, script):
|
||||
hook = git_hooks.File(hook_name)
|
||||
if hook.exists():
|
||||
print("Warning: Can't install %s, hook already exists." %
|
||||
hook_name)
|
||||
print(
|
||||
"Warning: Can't install %s, hook already exists." % hook_name
|
||||
)
|
||||
return
|
||||
|
||||
if hook.islink():
|
||||
@@ -78,15 +84,17 @@ def install_style_hooks(env):
|
||||
os.mkdir(git_hooks.get_abspath())
|
||||
git_hooks.clear()
|
||||
|
||||
abs_symlink_hooks = git_hooks.islink() and \
|
||||
os.path.isabs(os.readlink(git_hooks.get_abspath()))
|
||||
abs_symlink_hooks = git_hooks.islink() and os.path.isabs(
|
||||
os.readlink(git_hooks.get_abspath())
|
||||
)
|
||||
|
||||
# Use a relative symlink if the hooks live in the source directory,
|
||||
# and the hooks directory is not a symlink to an absolute path.
|
||||
if hook.is_under(env.Dir("#")) and not abs_symlink_hooks:
|
||||
script_path = os.path.relpath(
|
||||
os.path.realpath(script.get_abspath()),
|
||||
os.path.realpath(hook.Dir(".").get_abspath()))
|
||||
os.path.realpath(hook.Dir(".").get_abspath()),
|
||||
)
|
||||
else:
|
||||
script_path = script.get_abspath()
|
||||
|
||||
@@ -99,8 +107,8 @@ def install_style_hooks(env):
|
||||
if hook_exists("pre-commit") and hook_exists("commit-msg"):
|
||||
return
|
||||
|
||||
print(git_style_message, end=' ')
|
||||
if SCons.Script.GetOption('install_hooks'):
|
||||
print(git_style_message, end=" ")
|
||||
if SCons.Script.GetOption("install_hooks"):
|
||||
print("Installing revision control hooks automatically.")
|
||||
else:
|
||||
try:
|
||||
@@ -115,9 +123,11 @@ def install_style_hooks(env):
|
||||
hook_install("pre-commit", git_style_script)
|
||||
hook_install("commit-msg", git_msg_script)
|
||||
|
||||
|
||||
def generate(env):
|
||||
if exists(env) and not gem5_scons.util.ignore_style():
|
||||
install_style_hooks(env)
|
||||
|
||||
|
||||
def exists(env):
|
||||
return env.Entry('#.git').exists()
|
||||
return env.Entry("#.git").exists()
|
||||
|
||||
@@ -865,7 +865,7 @@ class FastModelGIC(BaseGic):
|
||||
return [int(r.split("=")[1], 16) for r in redists]
|
||||
|
||||
def get_addr_ranges(self):
|
||||
""" Return address ranges that should be served by this GIC """
|
||||
"""Return address ranges that should be served by this GIC"""
|
||||
sc_gic = self.sc_gic
|
||||
gic_frame_size = 0x10000
|
||||
# Add range of distributor
|
||||
|
||||
@@ -35,4 +35,3 @@
|
||||
// ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
|
||||
// IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH
|
||||
// DAMAGES.
|
||||
|
||||
|
||||
@@ -43,4 +43,3 @@
|
||||
|
||||
|
||||
Aarch64::aarch64();
|
||||
|
||||
|
||||
@@ -132,4 +132,3 @@ format DataOp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,4 +56,3 @@ def format ArmBkptHlt() {{
|
||||
}
|
||||
'''
|
||||
}};
|
||||
|
||||
|
||||
@@ -1154,4 +1154,3 @@ def format Thumb16MemLit() {{
|
||||
}
|
||||
''' % loadImmClassName(False, True, False)
|
||||
}};
|
||||
|
||||
|
||||
@@ -202,4 +202,3 @@ def format PredImmOp(code, *opt_flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = PredOpExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -167,4 +167,3 @@ let {{
|
||||
cryptoRegRegRegInst("sha256su1", "SHA256SU164", "SimdShaSigma3Op",
|
||||
sha2_enabled, sha256_su1Code)
|
||||
}};
|
||||
|
||||
|
||||
@@ -229,4 +229,3 @@ let {{
|
||||
raise Exception("Illegal combination of post and writeback")
|
||||
return base
|
||||
}};
|
||||
|
||||
|
||||
@@ -186,5 +186,3 @@ def template BranchTarget {{
|
||||
return std::unique_ptr<PCStateBase>{pc_ptr};
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -1288,4 +1288,3 @@ def template LoadImmConstructor {{
|
||||
#endif
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
@@ -112,13 +112,12 @@ class Template(object):
|
||||
|
||||
operands = SubOperandList(self.parser, compositeCode, d.operands)
|
||||
|
||||
myDict["reg_idx_arr_decl"] = (
|
||||
"RegId srcRegIdxArr[%d]; RegId destRegIdxArr[%d]"
|
||||
% (
|
||||
myDict[
|
||||
"reg_idx_arr_decl"
|
||||
] = "RegId srcRegIdxArr[%d]; RegId destRegIdxArr[%d]" % (
|
||||
d.operands.numSrcRegs + d.srcRegIdxPadding,
|
||||
d.operands.numDestRegs + d.destRegIdxPadding,
|
||||
)
|
||||
)
|
||||
|
||||
# The reinterpret casts are largely because an array with a known
|
||||
# size cannot be passed as an argument which is an array with an
|
||||
@@ -1360,7 +1359,7 @@ StaticInstPtr
|
||||
t[0] = ["default:"]
|
||||
|
||||
def prep_int_lit_case_label(self, lit):
|
||||
if lit >= 2 ** 32:
|
||||
if lit >= 2**32:
|
||||
return "case %#xULL: " % lit
|
||||
else:
|
||||
return "case %#x: " % lit
|
||||
|
||||
@@ -375,7 +375,7 @@ def p_file(t):
|
||||
|
||||
|
||||
def p_opt_rom_or_macros_0(t):
|
||||
"opt_rom_or_macros : "
|
||||
"opt_rom_or_macros :"
|
||||
|
||||
|
||||
def p_opt_rom_or_macros_1(t):
|
||||
@@ -472,7 +472,7 @@ def p_content_of_statement_0(t):
|
||||
|
||||
# Ignore empty statements
|
||||
def p_content_of_statement_1(t):
|
||||
"content_of_statement : "
|
||||
"content_of_statement :"
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -145,4 +145,3 @@ output decoder {{
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
|
||||
@@ -2545,5 +2545,3 @@ decode OPCODE_HI default Unknown::unknown() {
|
||||
0x6: CP2Unimpl::sdc2();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,3 @@ def format Jump(code, *opt_flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -241,5 +241,3 @@ def format CP1Control(code, *flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = CP1Execute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -208,6 +208,3 @@ def format DspHiLoOp(code, *opt_flags) {{
|
||||
exec_output = DspHiLoExecute.subst(iop)
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -363,4 +363,3 @@ def format FloatPSCompareOp(cond_code1, cond_code2, *flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = BasicExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -134,4 +134,3 @@ def format BasicOperateWithNopCheck(code, *opt_args) {{
|
||||
def format Nop() {{
|
||||
decode_block = 'return new Nop(\"\",machInst);\n'
|
||||
}};
|
||||
|
||||
|
||||
@@ -273,4 +273,3 @@ def format WarnUnimpl() {{
|
||||
iop = InstObjParams(name, 'WarnUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -77,4 +77,3 @@ output exec {{
|
||||
def format Unknown() {{
|
||||
decode_block = 'return new Unknown(machInst);\n'
|
||||
}};
|
||||
|
||||
|
||||
@@ -141,4 +141,3 @@ def format WarnUnimpl() {{
|
||||
iop = InstObjParams(name, 'WarnUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -82,4 +82,3 @@ output exec {{
|
||||
def format Unknown() {{
|
||||
decode_block = 'return new Unknown(machInst);\n'
|
||||
}};
|
||||
|
||||
|
||||
@@ -224,5 +224,3 @@ output decoder {{
|
||||
}
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -132,5 +132,3 @@ output exec {{
|
||||
}
|
||||
}
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -187,4 +187,3 @@ def format BranchSplit(code=default_branch_code,
|
||||
decode_block) = doUncondBranch(name, Name,
|
||||
"BranchSplit", code, annul_code, opt_flags)
|
||||
}};
|
||||
|
||||
|
||||
@@ -51,4 +51,3 @@
|
||||
|
||||
// Include the branch format
|
||||
##include "branch.isa"
|
||||
|
||||
|
||||
@@ -162,4 +162,3 @@ def format SetHi(code, *opt_flags) {{
|
||||
exec_output = IntOpExecute.subst(iop)
|
||||
decode_block = SetHiDecode.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -166,4 +166,3 @@ def format TwinLoad(code, *opt_flags) {{
|
||||
AlternateASIPrivFaultCheck + TwinAlignmentFaultCheck,
|
||||
name, Name, "EXT_ASI", opt_flags)
|
||||
}};
|
||||
|
||||
|
||||
@@ -174,5 +174,3 @@ def format CasAlt(code, postacc_code, mem_flags, *opt_flags) {{
|
||||
decode_block) = doCasFormat(code, SwapFuncs, AlternateASIPrivFaultCheck,
|
||||
name, Name, flags, ["IsStoreConditional"], postacc_code)
|
||||
}};
|
||||
|
||||
|
||||
|
||||
@@ -133,4 +133,3 @@ def format HPriv(code, check_tl=false, *opt_flags) {{
|
||||
doPrivFormat(code, check_code, name, Name, opt_flags,
|
||||
check_tl=(check_tl != 'false'))
|
||||
}};
|
||||
|
||||
|
||||
@@ -40,4 +40,3 @@ def format WarnUnimpl() {{
|
||||
iop = InstObjParams(name, 'WarnUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -85,4 +85,3 @@ def format CPUIDInst(code, *opt_flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = CPUIDExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -54,4 +54,3 @@ def format M5InternalError(error_message) {{
|
||||
iop.message = error_message
|
||||
decode_block = ErrorDecode.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -122,4 +122,3 @@ def format MwaitInst(code, *opt_flags) {{
|
||||
exec_output += MwaitInitiateAcc.subst(iop)
|
||||
exec_output += MwaitCompleteAcc.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -84,4 +84,3 @@ def format NopInst(*opt_flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = NopExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -88,4 +88,3 @@ def format SyscallInst(code, *opt_flags) {{
|
||||
decode_block = BasicDecode.subst(iop)
|
||||
exec_output = SyscallExecute.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -149,4 +149,3 @@ def format WarnUnimpl() {{
|
||||
iop = InstObjParams(name, 'WarnUnimplemented')
|
||||
decode_block = BasicDecodeWithMnemonic.subst(iop)
|
||||
}};
|
||||
|
||||
|
||||
@@ -456,4 +456,3 @@ TEST(BitfieldTest, CountLeadingZero64AllZeros)
|
||||
uint64_t value = 0;
|
||||
EXPECT_EQ(64, clz64(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,4 +100,3 @@ MultiBitSel::hash(Addr addr, int hash_number) const
|
||||
|
||||
} // namespace bloom_filter
|
||||
} // namespace gem5
|
||||
|
||||
|
||||
@@ -68,4 +68,3 @@ if env['USE_PYTHON']:
|
||||
SimObject('TrafficGen.py', sim_objects=['TrafficGen'], tags='protobuf')
|
||||
Source('trace_gen.cc', tags='protobuf')
|
||||
Source('traffic_gen.cc', tags='protobuf')
|
||||
|
||||
|
||||
@@ -72,4 +72,3 @@ enum amdgpu_hwreg
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __DEV_GPU_HWREG_DEFINES_H__
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ from m5.util.fdthelper import FdtNode, FdtProperty, FdtPropertyWords, FdtState
|
||||
|
||||
class SystemCounter(SimObject):
|
||||
"""
|
||||
Shared by both PE-implementations and memory-mapped timers. It provides a
|
||||
uniform view of system time through its counter value.
|
||||
Shared by both PE-implementations and memory-mapped timers. It provides a
|
||||
uniform view of system time through its counter value.
|
||||
|
||||
Reference:
|
||||
Reference:
|
||||
Arm ARM (ARM DDI 0487E.a)
|
||||
D11.1.2 - The system counter
|
||||
"""
|
||||
@@ -71,11 +71,11 @@ Reference:
|
||||
|
||||
class GenericTimer(SimObject):
|
||||
"""
|
||||
Architected timers per PE in the system. Each of them provides a physical
|
||||
counter, a virtual counter and several timers accessible from different
|
||||
exception levels and security states.
|
||||
Architected timers per PE in the system. Each of them provides a physical
|
||||
counter, a virtual counter and several timers accessible from different
|
||||
exception levels and security states.
|
||||
|
||||
Reference:
|
||||
Reference:
|
||||
Arm ARM (ARM DDI 0487E.a)
|
||||
D11.2 - The AArch64 view of the Generic Timer
|
||||
G6.2 - The AArch32 view of the Generic Timer
|
||||
@@ -135,10 +135,10 @@ Reference:
|
||||
|
||||
class GenericTimerFrame(PioDevice):
|
||||
"""
|
||||
Memory-mapped timer frame implementation. Controlled from GenericTimerMem,
|
||||
may be used by peripherals without a system register interface.
|
||||
Memory-mapped timer frame implementation. Controlled from GenericTimerMem,
|
||||
may be used by peripherals without a system register interface.
|
||||
|
||||
Reference:
|
||||
Reference:
|
||||
Arm ARM (ARM DDI 0487E.a)
|
||||
I2.3.2 - The CNTBaseN and CNTEL0BaseN frames
|
||||
"""
|
||||
@@ -178,14 +178,14 @@ Reference:
|
||||
|
||||
class GenericTimerMem(PioDevice):
|
||||
"""
|
||||
System level implementation. It provides three main components:
|
||||
- Memory-mapped counter module: controls the system timer through the
|
||||
System level implementation. It provides three main components:
|
||||
- Memory-mapped counter module: controls the system timer through the
|
||||
CNTControlBase frame, and provides its value through the CNTReadBase frame
|
||||
- Memory-mapped timer control module: controls the memory-mapped timers
|
||||
- Memory-mapped timers: implementations of the GenericTimer for system
|
||||
- Memory-mapped timer control module: controls the memory-mapped timers
|
||||
- Memory-mapped timers: implementations of the GenericTimer for system
|
||||
peripherals
|
||||
|
||||
Reference:
|
||||
Reference:
|
||||
Arm ARM (ARM DDI 0487E.a)
|
||||
I2 - System Level Implementation of the Generic Timer
|
||||
"""
|
||||
|
||||
@@ -339,9 +339,9 @@ class RealViewTemperatureSensor(SimObject):
|
||||
class VExpressMCC(SubSystem):
|
||||
"""ARM V2M-P1 Motherboard Configuration Controller
|
||||
|
||||
This subsystem describes a subset of the devices that sit behind the
|
||||
motherboard configuration controller on the the ARM Motherboard
|
||||
Express (V2M-P1) motherboard. See ARM DUI 0447J for details.
|
||||
This subsystem describes a subset of the devices that sit behind the
|
||||
motherboard configuration controller on the the ARM Motherboard
|
||||
Express (V2M-P1) motherboard. See ARM DUI 0447J for details.
|
||||
"""
|
||||
|
||||
class Osc(RealViewOsc):
|
||||
@@ -380,9 +380,9 @@ Express (V2M-P1) motherboard. See ARM DUI 0447J for details.
|
||||
class CoreTile2A15DCC(SubSystem):
|
||||
"""ARM CoreTile Express A15x2 Daughterboard Configuration Controller
|
||||
|
||||
This subsystem describes a subset of the devices that sit behind the
|
||||
daughterboard configuration controller on a CoreTile Express A15x2. See
|
||||
ARM DUI 0604E for details.
|
||||
This subsystem describes a subset of the devices that sit behind the
|
||||
daughterboard configuration controller on a CoreTile Express A15x2. See
|
||||
ARM DUI 0604E for details.
|
||||
"""
|
||||
|
||||
class Osc(RealViewOsc):
|
||||
@@ -491,8 +491,8 @@ class Sp804(AmbaPioDevice):
|
||||
|
||||
class Sp805(AmbaIntDevice):
|
||||
"""
|
||||
Arm Watchdog Module (SP805)
|
||||
Reference:
|
||||
Arm Watchdog Module (SP805)
|
||||
Reference:
|
||||
Arm Watchdog Module (SP805) - Technical Reference Manual - rev. r1p0
|
||||
Doc. ID: ARM DDI 0270B
|
||||
"""
|
||||
@@ -746,8 +746,8 @@ class MmioSRAM(ParentMem):
|
||||
|
||||
class FVPBasePwrCtrl(BasicPioDevice):
|
||||
"""
|
||||
Based on Fast Models Base_PowerController v11.8
|
||||
Reference:
|
||||
Based on Fast Models Base_PowerController v11.8
|
||||
Reference:
|
||||
Fast Models Reference Manual - Section 7.7.2 - Version 11.8
|
||||
Document ID: 100964_1180_00_en
|
||||
"""
|
||||
@@ -1100,27 +1100,27 @@ class VExpress_EMM64(VExpress_EMM):
|
||||
|
||||
class VExpress_GEM5_Base(RealView):
|
||||
"""
|
||||
The VExpress gem5 memory map is loosely based on a modified
|
||||
Versatile Express RS1 memory map.
|
||||
The VExpress gem5 memory map is loosely based on a modified
|
||||
Versatile Express RS1 memory map.
|
||||
|
||||
The gem5 platform has been designed to implement a subset of the
|
||||
original Versatile Express RS1 memory map. Off-chip peripherals should,
|
||||
when possible, adhere to the Versatile Express memory map. Non-PCI
|
||||
off-chip devices that are gem5-specific should live in the CS5 memory
|
||||
space to avoid conflicts with existing devices that we might want to
|
||||
model in the future. Such devices should normally have interrupts in
|
||||
the gem5-specific SPI range.
|
||||
The gem5 platform has been designed to implement a subset of the
|
||||
original Versatile Express RS1 memory map. Off-chip peripherals should,
|
||||
when possible, adhere to the Versatile Express memory map. Non-PCI
|
||||
off-chip devices that are gem5-specific should live in the CS5 memory
|
||||
space to avoid conflicts with existing devices that we might want to
|
||||
model in the future. Such devices should normally have interrupts in
|
||||
the gem5-specific SPI range.
|
||||
|
||||
On-chip peripherals are loosely modeled after the ARM CoreTile Express
|
||||
A15x2 memory and interrupt map. In particular, the GIC and
|
||||
Generic Timer have the same interrupt lines and base addresses. Other
|
||||
on-chip devices are gem5 specific.
|
||||
On-chip peripherals are loosely modeled after the ARM CoreTile Express
|
||||
A15x2 memory and interrupt map. In particular, the GIC and
|
||||
Generic Timer have the same interrupt lines and base addresses. Other
|
||||
on-chip devices are gem5 specific.
|
||||
|
||||
Unlike the original Versatile Express RS2 extended platform, gem5 implements a
|
||||
large contigious DRAM space, without aliases or holes, starting at the
|
||||
2GiB boundary. This means that PCI memory is limited to 1GiB.
|
||||
Unlike the original Versatile Express RS2 extended platform, gem5 implements a
|
||||
large contigious DRAM space, without aliases or holes, starting at the
|
||||
2GiB boundary. This means that PCI memory is limited to 1GiB.
|
||||
|
||||
References:
|
||||
References:
|
||||
|
||||
Technical Reference Manuals:
|
||||
Arm Motherboard Express uATX (V2M-P1) - ARM DUI 0447J
|
||||
@@ -1142,7 +1142,7 @@ References:
|
||||
Armv8-A Foundation Platform - User Guide - Version 11.8
|
||||
Document ID: 100961_1180_00_en
|
||||
|
||||
Memory map:
|
||||
Memory map:
|
||||
0x00000000-0x03ffffff: Boot memory (CS0)
|
||||
0x04000000-0x07ffffff: Trusted Memory/Reserved
|
||||
0x04000000-0x0403FFFF: 256kB Trusted SRAM
|
||||
@@ -1205,7 +1205,7 @@ Memory map:
|
||||
|
||||
0x80000000-X: DRAM
|
||||
|
||||
Interrupts:
|
||||
Interrupts:
|
||||
0- 15: Software generated interrupts (SGIs)
|
||||
16- 31: On-chip private peripherals (PPIs)
|
||||
19 : generic_timer (virt sec EL2)
|
||||
|
||||
@@ -84,4 +84,3 @@ class A9SCU : public BasicPioDevice
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __DEV_ARM_A9SCU_HH__
|
||||
|
||||
|
||||
@@ -148,4 +148,3 @@ LupioIPI::write(PacketPtr pkt)
|
||||
return pioDelay;
|
||||
}
|
||||
} // namespace gem5
|
||||
|
||||
|
||||
@@ -96,4 +96,3 @@ class LupioIPI : public BasicPioDevice
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __DEV_LUPIO_LUPIO_IPI_HH
|
||||
|
||||
|
||||
@@ -81,4 +81,3 @@ class PS2Mouse : public Device
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __DEV_PS2_MOUSE_hH__
|
||||
|
||||
|
||||
@@ -142,13 +142,11 @@ class HiFive(Platform):
|
||||
terminal = Terminal()
|
||||
|
||||
def _on_chip_devices(self):
|
||||
"""Returns a list of on-chip peripherals
|
||||
"""
|
||||
"""Returns a list of on-chip peripherals"""
|
||||
return [self.clint, self.plic]
|
||||
|
||||
def _off_chip_devices(self):
|
||||
"""Returns a list of off-chip peripherals
|
||||
"""
|
||||
"""Returns a list of off-chip peripherals"""
|
||||
devices = [self.uart]
|
||||
if hasattr(self, "disk"):
|
||||
devices.append(self.disk)
|
||||
@@ -175,8 +173,7 @@ class HiFive(Platform):
|
||||
]
|
||||
|
||||
def attachPlic(self):
|
||||
"""Count number of PLIC interrupt sources
|
||||
"""
|
||||
"""Count number of PLIC interrupt sources"""
|
||||
plic_srcs = [
|
||||
self.uart_int_id,
|
||||
self.pci_host.int_base + self.pci_host.int_count,
|
||||
@@ -201,7 +198,7 @@ class HiFive(Platform):
|
||||
device.pio = bus.mem_side_ports
|
||||
|
||||
def setNumCores(self, num_cpu):
|
||||
""" Sets the PLIC and CLINT to have the right number of threads and
|
||||
"""Sets the PLIC and CLINT to have the right number of threads and
|
||||
contexts. Assumes that the cores have a single hardware thread.
|
||||
"""
|
||||
self.plic.n_contexts = num_cpu * 2
|
||||
|
||||
@@ -52,4 +52,3 @@ static const int RTC_STAT_REGB = 0x0B;
|
||||
|
||||
static const int RTC_STAT_REGC = 0x0C;
|
||||
static const int RTC_STAT_REGD = 0x0D;
|
||||
|
||||
|
||||
1
src/mem/cache/SConscript
vendored
1
src/mem/cache/SConscript
vendored
@@ -56,4 +56,3 @@ DebugFlag('HWPrefetchQueue')
|
||||
# it explicitly even above and beyond CacheAll.
|
||||
CompoundFlag('CacheAll', ['Cache', 'CacheComp', 'CachePort', 'CacheRepl',
|
||||
'CacheVerbose', 'HWPrefetch', 'MSHR'])
|
||||
|
||||
|
||||
@@ -38,4 +38,3 @@ if env['CONF']['PROTOCOL'] == 'None':
|
||||
|
||||
SimObject('FaultModel.py', sim_objects=['FaultModel'])
|
||||
Source('FaultModel.cc')
|
||||
|
||||
|
||||
@@ -76,4 +76,3 @@ instantiated, then the Network Brisge takes over the flit in HeteroGarnet.
|
||||
serializing or deserializing the flits
|
||||
* Check if CDC is enabled and schedule all the flits according
|
||||
to the consumers clock domain.
|
||||
|
||||
|
||||
@@ -2978,5 +2978,3 @@ machine(MachineType:CorePair, "CP-like Core Coherence")
|
||||
|
||||
// END TRANSITIONS
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3008,5 +3008,3 @@ machine(MachineType:CorePair, "CP-like Core Coherence")
|
||||
|
||||
// END TRANSITIONS
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1371,4 +1371,3 @@ machine(MachineType:RegionBuffer, "Region Buffer for AMD_Base-like protocol")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user