summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-07-06 15:49:47 -0700
committerNathan Binkert <nate@binkert.org>2009-07-06 15:49:47 -0700
commit5b080ae0463c9644eb81bd923e25139dfe787e6e (patch)
treedb07d5fb459728b34a7877532955a7af47b87c98 /src/mem
parent1f6933503d3e0fb088345175cc1cae9610b98ce2 (diff)
downloadgem5-5b080ae0463c9644eb81bd923e25139dfe787e6e.tar.xz
slicc: update parser.py for changes in slicc language.
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/protocol/SConscript15
-rw-r--r--src/mem/slicc/parser/parser.py128
2 files changed, 64 insertions, 79 deletions
diff --git a/src/mem/protocol/SConscript b/src/mem/protocol/SConscript
index f7f7afdcd..9630c685a 100644
--- a/src/mem/protocol/SConscript
+++ b/src/mem/protocol/SConscript
@@ -73,21 +73,12 @@ protocol = env['PROTOCOL']
sources = [ protocol_dir.File("RubySlicc_interfaces.slicc"),
protocol_dir.File("%s.slicc" % protocol) ]
-sm_files = []
-for s in sources:
- for sm_file in file(File(s).srcnode().abspath, "r"):
- sm_file = sm_file.strip()
- if not sm_file:
- continue
- if sm_file.startswith("#"):
- continue
- sm_file = protocol_dir.File(sm_file)
- sm_file.srcnode().abspath
- sm_files.append(sm_file)
-
sys.path[0:0] = [env['ENV']['M5_PLY']]
execfile(slicc_dir.File('parser/parser.py').srcnode().abspath)
+sm_files = read_slicc([s.srcnode().abspath for s in sources])
+sm_files = [ protocol_dir.File(f) for f in sm_files ]
+
hh, cc = scan([s.srcnode().abspath for s in sm_files])
hh = [ protocol_dir.File(f) for f in hh ]
cc = [ protocol_dir.File(f) for f in cc ]
diff --git a/src/mem/slicc/parser/parser.py b/src/mem/slicc/parser/parser.py
index ac2dd294a..1c7d582ec 100644
--- a/src/mem/slicc/parser/parser.py
+++ b/src/mem/slicc/parser/parser.py
@@ -66,6 +66,7 @@ reserved = {
'THIS' : 'THIS',
'CHIP' : 'CHIP',
'void' : 'VOID',
+ 'new' : 'NEW',
}
literals = ':[]{}(),='
@@ -75,7 +76,7 @@ tokens = [ 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE',
'NOT', 'AND', 'OR',
'PLUS', 'DASH', 'STAR', 'SLASH',
'DOUBLE_COLON', 'SEMICOLON',
- 'ASSIGN', 'DOT',
+ 'ASSIGN', 'DOT', 'LATENCY',
'IDENT', 'LIT_BOOL', 'FLOATNUMBER', 'NUMBER', 'STRING' ]
tokens += reserved.values()
@@ -117,6 +118,10 @@ def t_IDENT(t):
t.value = False
return t
+ if t.value.startswith('LATENCY_'):
+ t.type = 'LATENCY'
+ return t
+
t.type = reserved.get(t.value, 'IDENT') # Check for reserved words
return t
@@ -185,9 +190,25 @@ def p_decl(p):
| d_func_def"""
p[0] = p[1]
+def p_latency(p):
+ """latency : LATENCY"""
+ pass
+
+def p_latencies(p):
+ """latencies : latency latencies
+ | empty"""
+ return []
+
def p_d_machine(p):
- "d_machine : MACHINE '(' ident pair_l ')' '{' decl_l '}'"
- decls = [ x for x in p[7] if x is not None ]
+ """d_machine : MACHINE '(' ident pair_l ')' '{' decl_l '}'
+ | MACHINE '(' ident pair_l ')' ':' type_members '{' decl_l '}'
+ | MACHINE '(' ident pair_l ')' ':' latencies '{' decl_l '}'"""
+
+ if len(p) == 9:
+ decl_l = p[7]
+ elif len(p) == 11:
+ decl_l = p[9]
+ decls = [ x for x in decl_l if x is not None ]
p[0] = Machine(p[3], decls)
def p_d_action(p):
@@ -391,6 +412,7 @@ def p_expr(p):
| literal
| enumeration
| ident '(' expr_l ')'
+ | NEW type
| THIS DOT var '[' expr ']' DOT var DOT ident '(' expr_l ')'
| THIS DOT var '[' expr ']' DOT var DOT ident
| CHIP '[' expr ']' DOT var '[' expr ']' DOT var DOT ident '(' expr_l ')'
@@ -436,72 +458,12 @@ lex.lex()
yacc.yacc(write_tables=0)
slicc_generated_cc = set([
- 'AccessModeType.cc',
- 'AccessPermission.cc',
- 'AccessType.cc',
- 'AllocationStrategy.cc',
- 'CacheMsg.cc',
- 'CacheRequestType.cc',
- 'Chip.cc',
- 'CoherenceRequestType.cc',
- 'DetermGETXGeneratorStatus.cc',
- 'DetermInvGeneratorStatus.cc',
- 'DetermSeriesGETSGeneratorStatus.cc',
- 'GenericMachineType.cc',
- 'GenericRequestType.cc',
- 'LinkType.cc',
- 'LockStatus.cc',
- 'MachineType.cc',
- 'MaskPredictorIndex.cc',
- 'MaskPredictorTraining.cc',
- 'MaskPredictorType.cc',
- 'MemoryMsg.cc',
- 'MemoryRequestType.cc',
- 'MessageSizeType.cc',
- 'PrefetchBit.cc',
- 'Protocol.cc',
- 'RequestGeneratorStatus.cc',
- 'SearchMechanism.cc',
- 'SequencerStatus.cc',
- 'SpecifiedGeneratorType.cc',
- 'TesterStatus.cc',
- 'TopologyType.cc',
- 'TransientRequestType.cc',
- 'TransitionResult.cc'])
+ 'ControllerFactory.cc',
+ 'MachineType.cc'])
slicc_generated_hh = set([
- 'AccessType.hh',
- 'AccessModeType.hh',
- 'AccessPermission.hh',
- 'AllocationStrategy.hh',
- 'CacheMsg.hh',
- 'CacheRequestType.hh',
- 'Chip.hh',
- 'CoherenceRequestType.hh',
- 'DetermGETXGeneratorStatus.hh',
- 'DetermInvGeneratorStatus.hh',
- 'DetermSeriesGETSGeneratorStatus.hh',
- 'GenericMachineType.hh',
- 'GenericRequestType.hh',
- 'LinkType.hh',
- 'LockStatus.hh',
+ 'ControllerFactory.hh',
'MachineType.hh',
- 'MaskPredictorIndex.hh',
- 'MaskPredictorTraining.hh',
- 'MaskPredictorType.hh',
- 'MemoryMsg.hh',
- 'MemoryRequestType.hh',
- 'MessageSizeType.hh',
- 'PrefetchBit.hh',
- 'Protocol.hh',
- 'RequestGeneratorStatus.hh',
- 'SearchMechanism.hh',
- 'SequencerStatus.hh',
- 'SpecifiedGeneratorType.hh',
- 'TesterStatus.hh',
- 'TopologyType.hh',
- 'TransientRequestType.hh',
- 'TransitionResult.hh',
'Types.hh',
'protocol_name.hh' ])
@@ -544,7 +506,9 @@ class InPort(Declaration): pass
class OutPort(Declaration): pass
class Transition(Declaration): pass
class Extern(Declaration): pass
-class Global(Declaration): pass
+class Global(Declaration):
+ hh = True
+ cc = True
class Struct(Declaration):
hh = True
cc = True
@@ -555,6 +519,22 @@ class Object(Declaration): pass
class Function(Declaration):
cc = True
+def read_slicc(sources):
+ if not isinstance(sources, (list,tuple)):
+ sources = [ sources ]
+
+ sm_files = []
+ for source in sources:
+ for sm_file in file(source, "r"):
+ sm_file = sm_file.strip()
+ if not sm_file:
+ continue
+ if sm_file.startswith("#"):
+ continue
+ sm_files.append(sm_file)
+
+ return sm_files
+
def scan(filenames):
hh = slicc_generated_hh.copy()
cc = slicc_generated_cc.copy()
@@ -570,3 +550,17 @@ def scan(filenames):
result.add(hh, cc)
return list(hh), list(cc)
+
+if __name__ == '__main__':
+ import sys
+
+ hh, cc = scan(read_slicc(sys.argv[1:]))
+ hh.sort()
+ cc.sort()
+ print 'Headers:'
+ for i in hh:
+ print ' %s' % i
+
+ print 'Sources:'
+ for i in cc:
+ print ' %s' % i