summaryrefslogtreecommitdiff
path: root/src/mem/protocol
diff options
context:
space:
mode:
authorJason Power <power.jg@gmail.com>2012-09-12 14:52:04 -0500
committerJason Power <power.jg@gmail.com>2012-09-12 14:52:04 -0500
commitaa8bcd15ec1ba916f3e750f41697a65e06b3c2ac (patch)
treeef66477d4b1904699ab751a841ff465768ab158e /src/mem/protocol
parentc6927ed13868c096a60df6a217f92857799b5be6 (diff)
downloadgem5-aa8bcd15ec1ba916f3e750f41697a65e06b3c2ac.tar.xz
Ruby: Modify Scons so that we can put .sm files in extras
Also allows for header files which are required in slicc generated code to be in a directory other than src/mem/ruby/slicc_interface.
Diffstat (limited to 'src/mem/protocol')
-rw-r--r--src/mem/protocol/SConscript23
-rw-r--r--src/mem/protocol/SConsopts17
2 files changed, 25 insertions, 15 deletions
diff --git a/src/mem/protocol/SConscript b/src/mem/protocol/SConscript
index 9ef38d289..0eccdf3e5 100644
--- a/src/mem/protocol/SConscript
+++ b/src/mem/protocol/SConscript
@@ -41,7 +41,7 @@ Import('*')
if env['PROTOCOL'] == 'None':
Return()
-protocol_dir = Dir('.')
+output_dir = Dir('.')
html_dir = Dir('html')
slicc_dir = Dir('../slicc')
@@ -57,7 +57,7 @@ for root,dirs,files in os.walk(slicc_dir.srcnode().abspath):
#
# 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)
@@ -66,22 +66,22 @@ def slicc_emitter(target, source, env):
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)
@@ -89,6 +89,15 @@ slicc_builder = Builder(action=MakeAction(slicc_action, Transform("SLICC")),
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})
diff --git a/src/mem/protocol/SConsopts b/src/mem/protocol/SConsopts
index 78b93c40e..95b043bc5 100644
--- a/src/mem/protocol/SConsopts
+++ b/src/mem/protocol/SConsopts
@@ -32,7 +32,7 @@ import os
Import('*')
-all_protocols = [
+all_protocols.extend([
'MESI_CMP_directory',
'MI_example',
'MOESI_CMP_directory',
@@ -40,13 +40,14 @@ all_protocols = [
'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')