Dir('src/python').srcnode().abspath, # gem5 includes
Dir('ext/ply').srcnode().abspath, # ply is used by several files
]
-
+
sys.path[1:1] = extra_python_paths
from m5.util import compareVersions, readCommand
export_vars = []
Export('export_vars')
+# For Ruby
+all_protocols = []
+Export('all_protocols')
+protocol_dirs = []
+Export('protocol_dirs')
+slicc_includes = []
+Export('slicc_includes')
+
# Walk the tree and execute all SConsopts scripts that wil add to the
# above variables
if not GetOption('verbose'):
BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
+ EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
+ all_protocols),
)
# These variables get exported to #defines in config/*.hh (see src/SConscript).
export_vars += ['USE_FENV', 'SS_COMPATIBLE_FP',
- 'TARGET_ISA', 'CP_ANNOTATE', 'USE_POSIX_CLOCK' ]
+ 'TARGET_ISA', 'CP_ANNOTATE', 'USE_POSIX_CLOCK', 'PROTOCOL',
+ ]
###################################################
#
if env['PROTOCOL'] == 'None':
Return()
-protocol_dir = Dir('.')
+output_dir = Dir('.')
html_dir = Dir('html')
slicc_dir = Dir('../slicc')
#
# Use SLICC
#
-env['SLICC_PATH'] = str(protocol_dir)
+env["SLICC_PATH"] = protocol_dirs
slicc_scanner = Classic("SliccScanner", ['.sm', '.slicc'], "SLICC_PATH",
r'''include[ \t]["'](.*)["'];''')
env.Append(SCANNERS=slicc_scanner)
assert len(source) == 1
filepath = source[0].srcnode().abspath
- slicc = SLICC(filepath, verbose=False)
+ slicc = SLICC(filepath, protocol_base.abspath, verbose=False)
slicc.process()
- slicc.writeCodeFiles(protocol_dir.abspath)
+ slicc.writeCodeFiles(output_dir.abspath, slicc_includes)
if env['SLICC_HTML']:
slicc.writeHTMLFiles(html_dir.abspath)
- target.extend([protocol_dir.File(f) for f in sorted(slicc.files())])
+ target.extend([output_dir.File(f) for f in sorted(slicc.files())])
return target, source
def slicc_action(target, source, env):
assert len(source) == 1
filepath = source[0].srcnode().abspath
- slicc = SLICC(filepath, verbose=True)
+ slicc = SLICC(filepath, protocol_base.abspath, verbose=True)
slicc.process()
- slicc.writeCodeFiles(protocol_dir.abspath)
+ slicc.writeCodeFiles(output_dir.abspath, slicc_includes)
if env['SLICC_HTML']:
slicc.writeHTMLFiles(html_dir.abspath)
emitter=slicc_emitter)
protocol = env['PROTOCOL']
+protocol_dir = None
+for path in protocol_dirs:
+ if os.path.exists(os.path.join(path, "%s.slicc" % protocol)):
+ protocol_dir = Dir(path)
+ break
+
+if not protocol_dir:
+ raise ValueError, "Could not find %s.slicc in protocol_dirs" % protocol
+
sources = [ protocol_dir.File("%s.slicc" % protocol) ]
env.Append(BUILDERS={'SLICC' : slicc_builder})
Import('*')
-all_protocols = [
+all_protocols.extend([
'MESI_CMP_directory',
'MI_example',
'MOESI_CMP_directory',
'MOESI_hammer',
'Network_test',
'None'
- ]
-
-opt = EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
- all_protocols)
-
-sticky_vars.AddVariables(opt)
-export_vars += ['PROTOCOL']
+ ])
opt = BoolVariable('SLICC_HTML', 'Create HTML files', False)
sticky_vars.AddVariables(opt)
+
+protocol_dirs.append(Dir('.').abspath)
+
+protocol_base = Dir('.')
+Export('protocol_base')
+
+slicc_includes.append('mem/ruby/slicc_interface/RubySlicc_includes.hh')
from slicc.symbols import SymbolTable
class SLICC(Grammar):
- def __init__(self, filename, verbose=False, traceback=False, **kwargs):
+ def __init__(self, filename, base_dir, verbose=False, traceback=False, **kwargs):
self.protocol = None
self.traceback = traceback
self.verbose = verbose
self.symtab = SymbolTable(self)
+ self.base_dir = base_dir
try:
self.decl_list = self.parse_file(filename, **kwargs)
self.decl_list.findMachines()
self.decl_list.generate()
- def writeCodeFiles(self, code_path):
- self.symtab.writeCodeFiles(code_path)
+ def writeCodeFiles(self, code_path, includes):
+ self.symtab.writeCodeFiles(code_path, includes)
def writeHTMLFiles(self, html_path):
self.symtab.writeHTMLFiles(html_path)
def p_decl__include(self, p):
"decl : INCLUDE STRING SEMI"
dirname = os.path.dirname(self.current_source)
- filename = os.path.join(dirname, p[2])
+ if os.path.exists(os.path.join(dirname, p[2])):
+ filename = os.path.join(dirname, p[2])
+ else:
+ filename = os.path.join(self.base_dir, p[2])
p[0] = self.parse_file(filename)
def p_decl__machine(self, p):
return "%s %s(%s);" % (return_type, self.c_ident,
", ".join(self.param_strings))
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
return
def generateCode(self):
action.warning(error_msg)
self.table = table
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
self.printControllerPython(path)
self.printControllerHH(path)
- self.printControllerCC(path)
+ self.printControllerCC(path, includes)
self.printCSwitch(path)
- self.printCWakeup(path)
+ self.printCWakeup(path, includes)
self.printProfilerCC(path)
self.printProfilerHH(path)
self.printProfileDumperCC(path)
code('#endif // __${ident}_CONTROLLER_H__')
code.write(path, '%s.hh' % c_ident)
- def printControllerCC(self, path):
+ def printControllerCC(self, path, includes):
'''Output the actions for performing the actions'''
code = self.symtab.codeFormatter()
#include "mem/protocol/${ident}_State.hh"
#include "mem/protocol/Types.hh"
#include "mem/ruby/common/Global.hh"
-#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
#include "mem/ruby/system/System.hh"
+''')
+ for include_path in includes:
+ code('#include "${{include_path}}"')
+
+ code('''
using namespace std;
''')
code.write(path, "%s.cc" % c_ident)
- def printCWakeup(self, path):
+ def printCWakeup(self, path, includes):
'''Output the wakeup loop for the events'''
code = self.symtab.codeFormatter()
code('''
#include "mem/protocol/Types.hh"
#include "mem/ruby/common/Global.hh"
-#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
#include "mem/ruby/system/System.hh"
+''')
+
+
+ for include_path in includes:
+ code('#include "${{include_path}}"')
+
+ code('''
using namespace std;
if isinstance(symbol, type):
yield symbol
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
makeDir(path)
code = self.codeFormatter()
- code('''
-/** Auto generated C++ code started by $__file__:$__line__ */
+ code('/** Auto generated C++ code started by $__file__:$__line__ */')
+
+ for include_path in includes:
+ code('#include "${{include_path}}"')
-#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
-''')
for symbol in self.sym_vec:
if isinstance(symbol, Type) and not symbol.isPrimitive:
code('#include "mem/protocol/${{symbol.c_ident}}.hh"')
code.write(path, "Types.hh")
for symbol in self.sym_vec:
- symbol.writeCodeFiles(path)
+ symbol.writeCodeFiles(path, includes)
def writeHTMLFiles(self, path):
makeDir(path)
return True
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
if self.isExternal:
# Do nothing
pass
def __repr__(self):
return "[Var id: %s]" % (self.c_ident)
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
pass
__all__ = [ "Var" ]