diff -r 910a43d7b25e -r b25131489b95 src/mem/protocol/MESI_Two_Level-L1cache.sm --- a/src/mem/protocol/MESI_Two_Level-L1cache.sm Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/protocol/MESI_Two_Level-L1cache.sm Thu Dec 04 12:15:52 2014 -0600 @@ -26,7 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -machine(L1Cache, "MESI Directory L1 Cache CMP") +machine(MachineType:L1Cache, "MESI Directory L1 Cache CMP") : Sequencer * sequencer; CacheMemory * L1Icache; CacheMemory * L1Dcache; diff -r 910a43d7b25e -r b25131489b95 src/mem/protocol/MESI_Two_Level-L2cache.sm --- a/src/mem/protocol/MESI_Two_Level-L2cache.sm Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/protocol/MESI_Two_Level-L2cache.sm Thu Dec 04 12:15:52 2014 -0600 @@ -26,7 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -machine(L2Cache, "MESI Directory L2 Cache CMP") +machine(MachineType:L2Cache, "MESI Directory L2 Cache CMP") : CacheMemory * L2cache; Cycles l2_request_latency := 2; Cycles l2_response_latency := 2; diff -r 910a43d7b25e -r b25131489b95 src/mem/protocol/MESI_Two_Level-dir.sm --- a/src/mem/protocol/MESI_Two_Level-dir.sm Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/protocol/MESI_Two_Level-dir.sm Thu Dec 04 12:15:52 2014 -0600 @@ -26,7 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -machine(Directory, "MESI Two Level directory protocol") +machine(MachineType:Directory, "MESI Two Level directory protocol") : DirectoryMemory * directory; Cycles to_mem_ctrl_latency := 1; Cycles directory_latency := 6; diff -r 910a43d7b25e -r b25131489b95 src/mem/protocol/MESI_Two_Level-dma.sm --- a/src/mem/protocol/MESI_Two_Level-dma.sm Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/protocol/MESI_Two_Level-dma.sm Thu Dec 04 12:15:52 2014 -0600 @@ -27,7 +27,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -machine(DMA, "DMA Controller") +machine(MachineType:DMA, "DMA Controller") : DMASequencer * dma_sequencer; Cycles request_latency := 6; diff -r 910a43d7b25e -r b25131489b95 src/mem/protocol/RubySlicc_Exports.sm --- a/src/mem/protocol/RubySlicc_Exports.sm Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/protocol/RubySlicc_Exports.sm Thu Dec 04 12:15:52 2014 -0600 @@ -168,6 +168,24 @@ Default, desc="Replace this with access_types passed to the DMA Ruby object"; } + +// These are statically defined types of states machines that we can have. +// If you want to add a new machine type, edit this enum. It is not necessary +// for a protocol to have state machines defined for the all types here. But +// you cannot use anything other than the ones defined here. Also, a protocol +// can have only one state machine for a given type. +enumeration(MachineType, desc="...", default="MachineType_NULL") { + L1Cache, desc="L1 Cache Mach"; + L2Cache, desc="L2 Cache Mach"; + L3Cache, desc="L3 Cache Mach"; + Directory, desc="Directory Mach"; + DMA, desc="DMA Mach"; + Collector, desc="Collector Mach"; + L1Cache_wCC, desc="L1 Cache Mach with Cache Coherence (used for miss latency profile)"; + L2Cache_wCC, desc="L1 Cache Mach with Cache Coherence (used for miss latency profile)"; + NULL, desc="null mach type"; +} + // MessageSizeType enumeration(MessageSizeType, desc="...") { Control, desc="Control Message"; diff -r 910a43d7b25e -r b25131489b95 src/mem/slicc/ast/DeclListAST.py --- a/src/mem/slicc/ast/DeclListAST.py Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/slicc/ast/DeclListAST.py Thu Dec 04 12:15:52 2014 -0600 @@ -46,8 +46,5 @@ def generate(self): for decl in self.decls: + decl.findMachines() decl.generate() - - def findMachines(self): - for decl in self.decls: - decl.findMachines() diff -r 910a43d7b25e -r b25131489b95 src/mem/slicc/ast/MachineAST.py --- a/src/mem/slicc/ast/MachineAST.py Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/slicc/ast/MachineAST.py Thu Dec 04 12:15:52 2014 -0600 @@ -29,10 +29,10 @@ from slicc.symbols import StateMachine, Type class MachineAST(DeclAST): - def __init__(self, slicc, ident, pairs_ast, config_parameters, decls): + def __init__(self, slicc, mtype, pairs_ast, config_parameters, decls): super(MachineAST, self).__init__(slicc, pairs_ast) - self.ident = ident + self.ident = mtype.value self.pairs_ast = pairs_ast self.config_parameters = config_parameters self.decls = decls @@ -72,11 +72,5 @@ def findMachines(self): mtype = self.ident machine_type = self.symtab.find("MachineType", Type) - pairs = self.pairs_ast.pairs - - pairs["Primary"] = True - if not machine_type.addEnum(mtype, pairs): + if not machine_type.checkEnum(mtype): self.error("Duplicate machine name: %s:%s" % (machine_type, mtype)) - - # Generate code for all the internal decls - self.decls.findMachines() diff -r 910a43d7b25e -r b25131489b95 src/mem/slicc/parser.py --- a/src/mem/slicc/parser.py Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/slicc/parser.py Thu Dec 04 12:15:52 2014 -0600 @@ -62,7 +62,6 @@ return code def process(self): - self.decl_list.findMachines() self.decl_list.generate() def writeCodeFiles(self, code_path, includes): @@ -72,10 +71,7 @@ self.symtab.writeHTMLFiles(html_path) def files(self): - f = set([ - 'MachineType.cc', - 'MachineType.hh', - 'Types.hh' ]) + f = set(['Types.hh']) f |= self.decl_list.files() @@ -258,11 +254,11 @@ p[0] = self.parse_file(filename) def p_decl__machine0(self, p): - "decl : MACHINE '(' ident ')' ':' obj_decls '{' decls '}'" + "decl : MACHINE '(' enumeration ')' ':' obj_decls '{' decls '}'" p[0] = ast.MachineAST(self, p[3], [], p[7], p[9]) def p_decl__machine1(self, p): - "decl : MACHINE '(' ident pairs ')' ':' obj_decls '{' decls '}'" + "decl : MACHINE '(' enumeration pairs ')' ':' obj_decls '{' decls '}'" p[0] = ast.MachineAST(self, p[3], p[4], p[7], p[9]) def p_decl__action(self, p): diff -r 910a43d7b25e -r b25131489b95 src/mem/slicc/symbols/SymbolTable.py --- a/src/mem/slicc/symbols/SymbolTable.py Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/slicc/symbols/SymbolTable.py Thu Dec 04 12:15:52 2014 -0600 @@ -41,12 +41,6 @@ self.machine_components = {} pairs = {} - pairs["enumeration"] = "yes" - location = Location("init", 0, no_warning=not slicc.verbose) - MachineType = Type(self, "MachineType", location, pairs) - self.newSymbol(MachineType) - - pairs = {} pairs["primitive"] = "yes" pairs["external"] = "yes" location = Location("init", 0, no_warning=not slicc.verbose) diff -r 910a43d7b25e -r b25131489b95 src/mem/slicc/symbols/Type.py --- a/src/mem/slicc/symbols/Type.py Thu Dec 04 12:15:52 2014 -0600 +++ b/src/mem/slicc/symbols/Type.py Thu Dec 04 12:15:52 2014 -0600 @@ -42,6 +42,7 @@ def __init__(self, ident, pairs): super(Enumeration, self).__init__(pairs) self.ident = ident + self.primary = False class Type(Symbol): def __init__(self, table, ident, location, pairs, machine=None): @@ -170,6 +171,14 @@ return True + ## Used to check if an enum has been already used and therefore + ## should not be used again. + def checkEnum(self, ident): + if ident in self.enums and not self.enums[ident].primary: + self.enums[ident].primary = True + return True + return False + def writeCodeFiles(self, path, includes): if self.isExternal: # Do nothing @@ -572,7 +581,7 @@ if self.isMachineType: for enum in self.enums.itervalues(): - if enum.get("Primary"): + if enum.primary: code('#include "mem/protocol/${{enum.ident}}_Controller.hh"') code('#include "mem/ruby/common/MachineID.hh"') @@ -711,7 +720,7 @@ code(' case ${{self.c_ident}}_NUM:') for enum in reversed(self.enums.values()): # Check if there is a defined machine with this type - if enum.get("Primary"): + if enum.primary: code(' base += ${{enum.ident}}_Controller::getNumControllers();') else: code(' base += 0;') @@ -739,7 +748,7 @@ # For each field for enum in self.enums.itervalues(): code('case ${{self.c_ident}}_${{enum.ident}}:') - if enum.get("Primary"): + if enum.primary: code('return ${{enum.ident}}_Controller::getNumControllers();') else: code('return 0;')