StateMachine.py revision 11084
16657Snate@binkert.org# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 26657Snate@binkert.org# Copyright (c) 2009 The Hewlett-Packard Development Company 310972Sdavid.hashe@amd.com# Copyright (c) 2013 Advanced Micro Devices, Inc. 46657Snate@binkert.org# All rights reserved. 56657Snate@binkert.org# 66657Snate@binkert.org# Redistribution and use in source and binary forms, with or without 76657Snate@binkert.org# modification, are permitted provided that the following conditions are 86657Snate@binkert.org# met: redistributions of source code must retain the above copyright 96657Snate@binkert.org# notice, this list of conditions and the following disclaimer; 106657Snate@binkert.org# redistributions in binary form must reproduce the above copyright 116657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 126657Snate@binkert.org# documentation and/or other materials provided with the distribution; 136657Snate@binkert.org# neither the name of the copyright holders nor the names of its 146657Snate@binkert.org# contributors may be used to endorse or promote products derived from 156657Snate@binkert.org# this software without specific prior written permission. 166657Snate@binkert.org# 176657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286657Snate@binkert.org 296999Snate@binkert.orgfrom m5.util import orderdict 306657Snate@binkert.org 316657Snate@binkert.orgfrom slicc.symbols.Symbol import Symbol 326657Snate@binkert.orgfrom slicc.symbols.Var import Var 336657Snate@binkert.orgimport slicc.generate.html as html 348189SLisa.Hsu@amd.comimport re 356657Snate@binkert.org 369499Snilay@cs.wisc.edupython_class_map = { 379499Snilay@cs.wisc.edu "int": "Int", 389364Snilay@cs.wisc.edu "uint32_t" : "UInt32", 397055Snate@binkert.org "std::string": "String", 406882SBrad.Beckmann@amd.com "bool": "Bool", 416882SBrad.Beckmann@amd.com "CacheMemory": "RubyCache", 428191SLisa.Hsu@amd.com "WireBuffer": "RubyWireBuffer", 436882SBrad.Beckmann@amd.com "Sequencer": "RubySequencer", 446882SBrad.Beckmann@amd.com "DirectoryMemory": "RubyDirectoryMemory", 459102SNuwan.Jayasena@amd.com "MemoryControl": "MemoryControl", 4611084Snilay@cs.wisc.edu "MessageBuffer": "MessageBuffer", 479366Snilay@cs.wisc.edu "DMASequencer": "DMASequencer", 489499Snilay@cs.wisc.edu "Prefetcher":"Prefetcher", 499499Snilay@cs.wisc.edu "Cycles":"Cycles", 509499Snilay@cs.wisc.edu } 516882SBrad.Beckmann@amd.com 526657Snate@binkert.orgclass StateMachine(Symbol): 536657Snate@binkert.org def __init__(self, symtab, ident, location, pairs, config_parameters): 546657Snate@binkert.org super(StateMachine, self).__init__(symtab, ident, location, pairs) 556657Snate@binkert.org self.table = None 5610311Snilay@cs.wisc.edu 5710311Snilay@cs.wisc.edu # Data members in the State Machine that have been declared before 5810311Snilay@cs.wisc.edu # the opening brace '{' of the machine. Note that these along with 5910311Snilay@cs.wisc.edu # the members in self.objects form the entire set of data members. 606657Snate@binkert.org self.config_parameters = config_parameters 6110311Snilay@cs.wisc.edu 629366Snilay@cs.wisc.edu self.prefetchers = [] 637839Snilay@cs.wisc.edu 646657Snate@binkert.org for param in config_parameters: 656882SBrad.Beckmann@amd.com if param.pointer: 6610308Snilay@cs.wisc.edu var = Var(symtab, param.ident, location, param.type_ast.type, 6710308Snilay@cs.wisc.edu "(*m_%s_ptr)" % param.ident, {}, self) 686882SBrad.Beckmann@amd.com else: 6910308Snilay@cs.wisc.edu var = Var(symtab, param.ident, location, param.type_ast.type, 7010308Snilay@cs.wisc.edu "m_%s" % param.ident, {}, self) 7110308Snilay@cs.wisc.edu 7210308Snilay@cs.wisc.edu self.symtab.registerSym(param.ident, var) 7310308Snilay@cs.wisc.edu 749366Snilay@cs.wisc.edu if str(param.type_ast.type) == "Prefetcher": 759366Snilay@cs.wisc.edu self.prefetchers.append(var) 766657Snate@binkert.org 776657Snate@binkert.org self.states = orderdict() 786657Snate@binkert.org self.events = orderdict() 796657Snate@binkert.org self.actions = orderdict() 809104Shestness@cs.utexas.edu self.request_types = orderdict() 816657Snate@binkert.org self.transitions = [] 826657Snate@binkert.org self.in_ports = [] 836657Snate@binkert.org self.functions = [] 8410311Snilay@cs.wisc.edu 8510311Snilay@cs.wisc.edu # Data members in the State Machine that have been declared inside 8610311Snilay@cs.wisc.edu # the {} machine. Note that these along with the config params 8710311Snilay@cs.wisc.edu # form the entire set of data members of the machine. 886657Snate@binkert.org self.objects = [] 897839Snilay@cs.wisc.edu self.TBEType = None 907839Snilay@cs.wisc.edu self.EntryType = None 9110972Sdavid.hashe@amd.com self.debug_flags = set() 9210972Sdavid.hashe@amd.com self.debug_flags.add('RubyGenerated') 9310972Sdavid.hashe@amd.com self.debug_flags.add('RubySlicc') 946657Snate@binkert.org 956657Snate@binkert.org def __repr__(self): 966657Snate@binkert.org return "[StateMachine: %s]" % self.ident 976657Snate@binkert.org 986657Snate@binkert.org def addState(self, state): 996657Snate@binkert.org assert self.table is None 1006657Snate@binkert.org self.states[state.ident] = state 1016657Snate@binkert.org 1026657Snate@binkert.org def addEvent(self, event): 1036657Snate@binkert.org assert self.table is None 1046657Snate@binkert.org self.events[event.ident] = event 1056657Snate@binkert.org 1066657Snate@binkert.org def addAction(self, action): 1076657Snate@binkert.org assert self.table is None 1086657Snate@binkert.org 1096657Snate@binkert.org # Check for duplicate action 1106657Snate@binkert.org for other in self.actions.itervalues(): 1116657Snate@binkert.org if action.ident == other.ident: 1126779SBrad.Beckmann@amd.com action.warning("Duplicate action definition: %s" % action.ident) 1136657Snate@binkert.org action.error("Duplicate action definition: %s" % action.ident) 1146657Snate@binkert.org if action.short == other.short: 1156657Snate@binkert.org other.warning("Duplicate action shorthand: %s" % other.ident) 1166657Snate@binkert.org other.warning(" shorthand = %s" % other.short) 1176657Snate@binkert.org action.warning("Duplicate action shorthand: %s" % action.ident) 1186657Snate@binkert.org action.error(" shorthand = %s" % action.short) 1196657Snate@binkert.org 1206657Snate@binkert.org self.actions[action.ident] = action 1216657Snate@binkert.org 12210972Sdavid.hashe@amd.com def addDebugFlag(self, flag): 12310972Sdavid.hashe@amd.com self.debug_flags.add(flag) 12410972Sdavid.hashe@amd.com 1259104Shestness@cs.utexas.edu def addRequestType(self, request_type): 1269104Shestness@cs.utexas.edu assert self.table is None 1279104Shestness@cs.utexas.edu self.request_types[request_type.ident] = request_type 1289104Shestness@cs.utexas.edu 1296657Snate@binkert.org def addTransition(self, trans): 1306657Snate@binkert.org assert self.table is None 1316657Snate@binkert.org self.transitions.append(trans) 1326657Snate@binkert.org 1336657Snate@binkert.org def addInPort(self, var): 1346657Snate@binkert.org self.in_ports.append(var) 1356657Snate@binkert.org 1366657Snate@binkert.org def addFunc(self, func): 1376657Snate@binkert.org # register func in the symbol table 1386657Snate@binkert.org self.symtab.registerSym(str(func), func) 1396657Snate@binkert.org self.functions.append(func) 1406657Snate@binkert.org 1416657Snate@binkert.org def addObject(self, obj): 14210307Snilay@cs.wisc.edu self.symtab.registerSym(str(obj), obj) 1436657Snate@binkert.org self.objects.append(obj) 1446657Snate@binkert.org 1457839Snilay@cs.wisc.edu def addType(self, type): 1467839Snilay@cs.wisc.edu type_ident = '%s' % type.c_ident 1477839Snilay@cs.wisc.edu 1487839Snilay@cs.wisc.edu if type_ident == "%s_TBE" %self.ident: 1497839Snilay@cs.wisc.edu if self.TBEType != None: 1507839Snilay@cs.wisc.edu self.error("Multiple Transaction Buffer types in a " \ 1517839Snilay@cs.wisc.edu "single machine."); 1527839Snilay@cs.wisc.edu self.TBEType = type 1537839Snilay@cs.wisc.edu 1547839Snilay@cs.wisc.edu elif "interface" in type and "AbstractCacheEntry" == type["interface"]: 15510968Sdavid.hashe@amd.com if "main" in type and "false" == type["main"].lower(): 15610968Sdavid.hashe@amd.com pass # this isn't the EntryType 15710968Sdavid.hashe@amd.com else: 15810968Sdavid.hashe@amd.com if self.EntryType != None: 15910968Sdavid.hashe@amd.com self.error("Multiple AbstractCacheEntry types in a " \ 16010968Sdavid.hashe@amd.com "single machine."); 16110968Sdavid.hashe@amd.com self.EntryType = type 1627839Snilay@cs.wisc.edu 1636657Snate@binkert.org # Needs to be called before accessing the table 1646657Snate@binkert.org def buildTable(self): 1656657Snate@binkert.org assert self.table is None 1666657Snate@binkert.org 1676657Snate@binkert.org table = {} 1686657Snate@binkert.org 1696657Snate@binkert.org for trans in self.transitions: 1706657Snate@binkert.org # Track which actions we touch so we know if we use them 1716657Snate@binkert.org # all -- really this should be done for all symbols as 1726657Snate@binkert.org # part of the symbol table, then only trigger it for 1736657Snate@binkert.org # Actions, States, Events, etc. 1746657Snate@binkert.org 1756657Snate@binkert.org for action in trans.actions: 1766657Snate@binkert.org action.used = True 1776657Snate@binkert.org 1786657Snate@binkert.org index = (trans.state, trans.event) 1796657Snate@binkert.org if index in table: 1806657Snate@binkert.org table[index].warning("Duplicate transition: %s" % table[index]) 1816657Snate@binkert.org trans.error("Duplicate transition: %s" % trans) 1826657Snate@binkert.org table[index] = trans 1836657Snate@binkert.org 1846657Snate@binkert.org # Look at all actions to make sure we used them all 1856657Snate@binkert.org for action in self.actions.itervalues(): 1866657Snate@binkert.org if not action.used: 1876657Snate@binkert.org error_msg = "Unused action: %s" % action.ident 1886657Snate@binkert.org if "desc" in action: 1896657Snate@binkert.org error_msg += ", " + action.desc 1906657Snate@binkert.org action.warning(error_msg) 1916657Snate@binkert.org self.table = table 1926657Snate@binkert.org 19310963Sdavid.hashe@amd.com # determine the port->msg buffer mappings 19410963Sdavid.hashe@amd.com def getBufferMaps(self, ident): 19510963Sdavid.hashe@amd.com msg_bufs = [] 19610963Sdavid.hashe@amd.com port_to_buf_map = {} 19710963Sdavid.hashe@amd.com in_msg_bufs = {} 19810963Sdavid.hashe@amd.com for port in self.in_ports: 19910963Sdavid.hashe@amd.com buf_name = "m_%s_ptr" % port.buffer_expr.name 20010963Sdavid.hashe@amd.com msg_bufs.append(buf_name) 20110963Sdavid.hashe@amd.com port_to_buf_map[port] = msg_bufs.index(buf_name) 20210963Sdavid.hashe@amd.com if buf_name not in in_msg_bufs: 20310963Sdavid.hashe@amd.com in_msg_bufs[buf_name] = [port] 20410963Sdavid.hashe@amd.com else: 20510963Sdavid.hashe@amd.com in_msg_bufs[buf_name].append(port) 20610963Sdavid.hashe@amd.com return port_to_buf_map, in_msg_bufs, msg_bufs 20710963Sdavid.hashe@amd.com 2089219Spower.jg@gmail.com def writeCodeFiles(self, path, includes): 2096877Ssteve.reinhardt@amd.com self.printControllerPython(path) 2106657Snate@binkert.org self.printControllerHH(path) 2119219Spower.jg@gmail.com self.printControllerCC(path, includes) 2126657Snate@binkert.org self.printCSwitch(path) 2139219Spower.jg@gmail.com self.printCWakeup(path, includes) 2146657Snate@binkert.org 2156877Ssteve.reinhardt@amd.com def printControllerPython(self, path): 2166999Snate@binkert.org code = self.symtab.codeFormatter() 2176877Ssteve.reinhardt@amd.com ident = self.ident 21810308Snilay@cs.wisc.edu 2196877Ssteve.reinhardt@amd.com py_ident = "%s_Controller" % ident 2206877Ssteve.reinhardt@amd.com c_ident = "%s_Controller" % self.ident 22110308Snilay@cs.wisc.edu 2226877Ssteve.reinhardt@amd.com code(''' 2236877Ssteve.reinhardt@amd.comfrom m5.params import * 2246877Ssteve.reinhardt@amd.comfrom m5.SimObject import SimObject 2256877Ssteve.reinhardt@amd.comfrom Controller import RubyController 2266877Ssteve.reinhardt@amd.com 2276877Ssteve.reinhardt@amd.comclass $py_ident(RubyController): 2286877Ssteve.reinhardt@amd.com type = '$py_ident' 2299338SAndreas.Sandberg@arm.com cxx_header = 'mem/protocol/${c_ident}.hh' 2306877Ssteve.reinhardt@amd.com''') 2316877Ssteve.reinhardt@amd.com code.indent() 2326877Ssteve.reinhardt@amd.com for param in self.config_parameters: 2336877Ssteve.reinhardt@amd.com dflt_str = '' 23410308Snilay@cs.wisc.edu 23510308Snilay@cs.wisc.edu if param.rvalue is not None: 23610308Snilay@cs.wisc.edu dflt_str = str(param.rvalue.inline()) + ', ' 23710308Snilay@cs.wisc.edu 23811084Snilay@cs.wisc.edu if python_class_map.has_key(param.type_ast.type.c_ident): 2396882SBrad.Beckmann@amd.com python_type = python_class_map[param.type_ast.type.c_ident] 24010308Snilay@cs.wisc.edu code('${{param.ident}} = Param.${{python_type}}(${dflt_str}"")') 24110308Snilay@cs.wisc.edu 2426882SBrad.Beckmann@amd.com else: 2436882SBrad.Beckmann@amd.com self.error("Unknown c++ to python class conversion for c++ " \ 2446882SBrad.Beckmann@amd.com "type: '%s'. Please update the python_class_map " \ 2456882SBrad.Beckmann@amd.com "in StateMachine.py", param.type_ast.type.c_ident) 24611021Sjthestness@gmail.com 2476877Ssteve.reinhardt@amd.com code.dedent() 2486877Ssteve.reinhardt@amd.com code.write(path, '%s.py' % py_ident) 24910917Sbrandon.potter@amd.com 2506877Ssteve.reinhardt@amd.com 2516657Snate@binkert.org def printControllerHH(self, path): 2526657Snate@binkert.org '''Output the method declarations for the class declaration''' 2536999Snate@binkert.org code = self.symtab.codeFormatter() 2546657Snate@binkert.org ident = self.ident 2556657Snate@binkert.org c_ident = "%s_Controller" % self.ident 2566657Snate@binkert.org 2576657Snate@binkert.org code(''' 2587007Snate@binkert.org/** \\file $c_ident.hh 2596657Snate@binkert.org * 2606657Snate@binkert.org * Auto generated C++ code started by $__file__:$__line__ 2616657Snate@binkert.org * Created by slicc definition of Module "${{self.short}}" 2626657Snate@binkert.org */ 2636657Snate@binkert.org 2647007Snate@binkert.org#ifndef __${ident}_CONTROLLER_HH__ 2657007Snate@binkert.org#define __${ident}_CONTROLLER_HH__ 2666657Snate@binkert.org 2677002Snate@binkert.org#include <iostream> 2687002Snate@binkert.org#include <sstream> 2697002Snate@binkert.org#include <string> 2707002Snate@binkert.org 2716657Snate@binkert.org#include "mem/protocol/TransitionResult.hh" 2726657Snate@binkert.org#include "mem/protocol/Types.hh" 2738229Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 2748229Snate@binkert.org#include "mem/ruby/slicc_interface/AbstractController.hh" 2758229Snate@binkert.org#include "params/$c_ident.hh" 27610972Sdavid.hashe@amd.com 2776657Snate@binkert.org''') 2786657Snate@binkert.org 2796657Snate@binkert.org seen_types = set() 2806657Snate@binkert.org for var in self.objects: 2816793SBrad.Beckmann@amd.com if var.type.ident not in seen_types and not var.type.isPrimitive: 2826657Snate@binkert.org code('#include "mem/protocol/${{var.type.c_ident}}.hh"') 28310311Snilay@cs.wisc.edu seen_types.add(var.type.ident) 2846657Snate@binkert.org 2856657Snate@binkert.org # for adding information to the protocol debug trace 2866657Snate@binkert.org code(''' 2877002Snate@binkert.orgextern std::stringstream ${ident}_transitionComment; 2886657Snate@binkert.org 2897007Snate@binkert.orgclass $c_ident : public AbstractController 2907007Snate@binkert.org{ 2919271Snilay@cs.wisc.edu public: 2926877Ssteve.reinhardt@amd.com typedef ${c_ident}Params Params; 2936877Ssteve.reinhardt@amd.com $c_ident(const Params *p); 2946657Snate@binkert.org static int getNumControllers(); 2956877Ssteve.reinhardt@amd.com void init(); 29610311Snilay@cs.wisc.edu 29711084Snilay@cs.wisc.edu MessageBuffer *getMandatoryQueue() const; 29811084Snilay@cs.wisc.edu MessageBuffer *getMemoryQueue() const; 29911021Sjthestness@gmail.com void initNetQueues(); 3009745Snilay@cs.wisc.edu 3017002Snate@binkert.org void print(std::ostream& out) const; 3026657Snate@binkert.org void wakeup(); 30310012Snilay@cs.wisc.edu void resetStats(); 3049745Snilay@cs.wisc.edu void regStats(); 3059745Snilay@cs.wisc.edu void collateStats(); 3069745Snilay@cs.wisc.edu 3078683Snilay@cs.wisc.edu void recordCacheTrace(int cntrl, CacheRecorder* tr); 3088683Snilay@cs.wisc.edu Sequencer* getSequencer() const; 3097007Snate@binkert.org 31010524Snilay@cs.wisc.edu int functionalWriteBuffers(PacketPtr&); 3119302Snilay@cs.wisc.edu 3129745Snilay@cs.wisc.edu void countTransition(${ident}_State state, ${ident}_Event event); 3139745Snilay@cs.wisc.edu void possibleTransition(${ident}_State state, ${ident}_Event event); 31411061Snilay@cs.wisc.edu uint64_t getEventCount(${ident}_Event event); 3159745Snilay@cs.wisc.edu bool isPossible(${ident}_State state, ${ident}_Event event); 31611061Snilay@cs.wisc.edu uint64_t getTransitionCount(${ident}_State state, ${ident}_Event event); 3179745Snilay@cs.wisc.edu 3186657Snate@binkert.orgprivate: 3196657Snate@binkert.org''') 3206657Snate@binkert.org 3216657Snate@binkert.org code.indent() 3226657Snate@binkert.org # added by SS 3236657Snate@binkert.org for param in self.config_parameters: 3246882SBrad.Beckmann@amd.com if param.pointer: 3256882SBrad.Beckmann@amd.com code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;') 3266882SBrad.Beckmann@amd.com else: 3276882SBrad.Beckmann@amd.com code('${{param.type_ast.type}} m_${{param.ident}};') 3286657Snate@binkert.org 3296657Snate@binkert.org code(''' 3307007Snate@binkert.orgTransitionResult doTransition(${ident}_Event event, 3317839Snilay@cs.wisc.edu''') 3327839Snilay@cs.wisc.edu 3337839Snilay@cs.wisc.edu if self.EntryType != None: 3347839Snilay@cs.wisc.edu code(''' 3357839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}* m_cache_entry_ptr, 3367839Snilay@cs.wisc.edu''') 3377839Snilay@cs.wisc.edu if self.TBEType != None: 3387839Snilay@cs.wisc.edu code(''' 3397839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}* m_tbe_ptr, 3407839Snilay@cs.wisc.edu''') 3417839Snilay@cs.wisc.edu 3427839Snilay@cs.wisc.edu code(''' 34311025Snilay@cs.wisc.edu Addr addr); 3447007Snate@binkert.org 3457007Snate@binkert.orgTransitionResult doTransitionWorker(${ident}_Event event, 3467007Snate@binkert.org ${ident}_State state, 3477007Snate@binkert.org ${ident}_State& next_state, 3487839Snilay@cs.wisc.edu''') 3497839Snilay@cs.wisc.edu 3507839Snilay@cs.wisc.edu if self.TBEType != None: 3517839Snilay@cs.wisc.edu code(''' 3527839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}*& m_tbe_ptr, 3537839Snilay@cs.wisc.edu''') 3547839Snilay@cs.wisc.edu if self.EntryType != None: 3557839Snilay@cs.wisc.edu code(''' 3567839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, 3577839Snilay@cs.wisc.edu''') 3587839Snilay@cs.wisc.edu 3597839Snilay@cs.wisc.edu code(''' 36011025Snilay@cs.wisc.edu Addr addr); 3617007Snate@binkert.org 3629745Snilay@cs.wisc.eduint m_counters[${ident}_State_NUM][${ident}_Event_NUM]; 3639745Snilay@cs.wisc.eduint m_event_counters[${ident}_Event_NUM]; 3649745Snilay@cs.wisc.edubool m_possible[${ident}_State_NUM][${ident}_Event_NUM]; 3659745Snilay@cs.wisc.edu 3669745Snilay@cs.wisc.edustatic std::vector<Stats::Vector *> eventVec; 3679745Snilay@cs.wisc.edustatic std::vector<std::vector<Stats::Vector *> > transVec; 3686657Snate@binkert.orgstatic int m_num_controllers; 3697007Snate@binkert.org 3706657Snate@binkert.org// Internal functions 3716657Snate@binkert.org''') 3726657Snate@binkert.org 3736657Snate@binkert.org for func in self.functions: 3746657Snate@binkert.org proto = func.prototype 3756657Snate@binkert.org if proto: 3766657Snate@binkert.org code('$proto') 3776657Snate@binkert.org 3787839Snilay@cs.wisc.edu if self.EntryType != None: 3797839Snilay@cs.wisc.edu code(''' 3807839Snilay@cs.wisc.edu 3817839Snilay@cs.wisc.edu// Set and Reset for cache_entry variable 3827839Snilay@cs.wisc.eduvoid set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry); 3837839Snilay@cs.wisc.eduvoid unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr); 3847839Snilay@cs.wisc.edu''') 3857839Snilay@cs.wisc.edu 3867839Snilay@cs.wisc.edu if self.TBEType != None: 3877839Snilay@cs.wisc.edu code(''' 3887839Snilay@cs.wisc.edu 3897839Snilay@cs.wisc.edu// Set and Reset for tbe variable 3907839Snilay@cs.wisc.eduvoid set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${ident}_TBE* m_new_tbe); 3917839Snilay@cs.wisc.eduvoid unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr); 3927839Snilay@cs.wisc.edu''') 3937839Snilay@cs.wisc.edu 39410121Snilay@cs.wisc.edu # Prototype the actions that the controller can take 3956657Snate@binkert.org code(''' 3966657Snate@binkert.org 3976657Snate@binkert.org// Actions 3986657Snate@binkert.org''') 3997839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 4007839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 4017839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 40210121Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& ' 40310121Snilay@cs.wisc.edu 'm_tbe_ptr, ${{self.EntryType.c_ident}}*& ' 40411025Snilay@cs.wisc.edu 'm_cache_entry_ptr, Addr addr);') 4057839Snilay@cs.wisc.edu elif self.TBEType != None: 4067839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 4077839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 40810121Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& ' 40911025Snilay@cs.wisc.edu 'm_tbe_ptr, Addr addr);') 4107839Snilay@cs.wisc.edu elif self.EntryType != None: 4117839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 4127839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 41310121Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.EntryType.c_ident}}*& ' 41411025Snilay@cs.wisc.edu 'm_cache_entry_ptr, Addr addr);') 4157839Snilay@cs.wisc.edu else: 4167839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 4177839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 41811025Snilay@cs.wisc.edu code('void ${{action.ident}}(Addr addr);') 4196657Snate@binkert.org 4206657Snate@binkert.org # the controller internal variables 4216657Snate@binkert.org code(''' 4226657Snate@binkert.org 4237007Snate@binkert.org// Objects 4246657Snate@binkert.org''') 4256657Snate@binkert.org for var in self.objects: 4269273Snilay@cs.wisc.edu th = var.get("template", "") 42710305Snilay@cs.wisc.edu code('${{var.type.c_ident}}$th* m_${{var.ident}}_ptr;') 4286657Snate@binkert.org 4296657Snate@binkert.org code.dedent() 4306657Snate@binkert.org code('};') 4317007Snate@binkert.org code('#endif // __${ident}_CONTROLLER_H__') 4326657Snate@binkert.org code.write(path, '%s.hh' % c_ident) 4336657Snate@binkert.org 4349219Spower.jg@gmail.com def printControllerCC(self, path, includes): 4356657Snate@binkert.org '''Output the actions for performing the actions''' 4366657Snate@binkert.org 4376999Snate@binkert.org code = self.symtab.codeFormatter() 4386657Snate@binkert.org ident = self.ident 4396657Snate@binkert.org c_ident = "%s_Controller" % self.ident 4406657Snate@binkert.org 4416657Snate@binkert.org code(''' 4427007Snate@binkert.org/** \\file $c_ident.cc 4436657Snate@binkert.org * 4446657Snate@binkert.org * Auto generated C++ code started by $__file__:$__line__ 4456657Snate@binkert.org * Created by slicc definition of Module "${{self.short}}" 4466657Snate@binkert.org */ 4476657Snate@binkert.org 4488946Sandreas.hansson@arm.com#include <sys/types.h> 4498946Sandreas.hansson@arm.com#include <unistd.h> 4508946Sandreas.hansson@arm.com 4517832Snate@binkert.org#include <cassert> 4527002Snate@binkert.org#include <sstream> 4537002Snate@binkert.org#include <string> 45410972Sdavid.hashe@amd.com#include <typeinfo> 4557002Snate@binkert.org 4568641Snate@binkert.org#include "base/compiler.hh" 4577056Snate@binkert.org#include "base/cprintf.hh" 45810972Sdavid.hashe@amd.com 45910972Sdavid.hashe@amd.com''') 46010972Sdavid.hashe@amd.com for f in self.debug_flags: 46110972Sdavid.hashe@amd.com code('#include "debug/${{f}}.hh"') 46210972Sdavid.hashe@amd.com code(''' 4636657Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 4648229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 4656657Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 4666657Snate@binkert.org#include "mem/protocol/Types.hh" 4676657Snate@binkert.org#include "mem/ruby/system/System.hh" 46810972Sdavid.hashe@amd.com 4699219Spower.jg@gmail.com''') 4709219Spower.jg@gmail.com for include_path in includes: 4719219Spower.jg@gmail.com code('#include "${{include_path}}"') 4729219Spower.jg@gmail.com 4739219Spower.jg@gmail.com code(''' 4747002Snate@binkert.org 4757002Snate@binkert.orgusing namespace std; 4766657Snate@binkert.org''') 4776657Snate@binkert.org 4786657Snate@binkert.org # include object classes 4796657Snate@binkert.org seen_types = set() 4806657Snate@binkert.org for var in self.objects: 4816793SBrad.Beckmann@amd.com if var.type.ident not in seen_types and not var.type.isPrimitive: 4826657Snate@binkert.org code('#include "mem/protocol/${{var.type.c_ident}}.hh"') 4836657Snate@binkert.org seen_types.add(var.type.ident) 4846657Snate@binkert.org 48510121Snilay@cs.wisc.edu num_in_ports = len(self.in_ports) 48610121Snilay@cs.wisc.edu 4876657Snate@binkert.org code(''' 4886877Ssteve.reinhardt@amd.com$c_ident * 4896877Ssteve.reinhardt@amd.com${c_ident}Params::create() 4906877Ssteve.reinhardt@amd.com{ 4916877Ssteve.reinhardt@amd.com return new $c_ident(this); 4926877Ssteve.reinhardt@amd.com} 4936877Ssteve.reinhardt@amd.com 4946657Snate@binkert.orgint $c_ident::m_num_controllers = 0; 4959745Snilay@cs.wisc.edustd::vector<Stats::Vector *> $c_ident::eventVec; 4969745Snilay@cs.wisc.edustd::vector<std::vector<Stats::Vector *> > $c_ident::transVec; 4976657Snate@binkert.org 4987007Snate@binkert.org// for adding information to the protocol debug trace 4996657Snate@binkert.orgstringstream ${ident}_transitionComment; 5009801Snilay@cs.wisc.edu 5019801Snilay@cs.wisc.edu#ifndef NDEBUG 5026657Snate@binkert.org#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str) 5039801Snilay@cs.wisc.edu#else 5049801Snilay@cs.wisc.edu#define APPEND_TRANSITION_COMMENT(str) do {} while (0) 5059801Snilay@cs.wisc.edu#endif 5067007Snate@binkert.org 5076657Snate@binkert.org/** \\brief constructor */ 5086877Ssteve.reinhardt@amd.com$c_ident::$c_ident(const Params *p) 5096877Ssteve.reinhardt@amd.com : AbstractController(p) 5106657Snate@binkert.org{ 51110078Snilay@cs.wisc.edu m_machineID.type = MachineType_${ident}; 51210078Snilay@cs.wisc.edu m_machineID.num = m_version; 51310121Snilay@cs.wisc.edu m_num_controllers++; 51410121Snilay@cs.wisc.edu 51510121Snilay@cs.wisc.edu m_in_ports = $num_in_ports; 5166657Snate@binkert.org''') 5176657Snate@binkert.org code.indent() 5186882SBrad.Beckmann@amd.com 5196882SBrad.Beckmann@amd.com # 5206882SBrad.Beckmann@amd.com # After initializing the universal machine parameters, initialize the 52110121Snilay@cs.wisc.edu # this machines config parameters. Also if these configuration params 52210121Snilay@cs.wisc.edu # include a sequencer, connect the it to the controller. 5236882SBrad.Beckmann@amd.com # 5246877Ssteve.reinhardt@amd.com for param in self.config_parameters: 5256882SBrad.Beckmann@amd.com if param.pointer: 52610308Snilay@cs.wisc.edu code('m_${{param.ident}}_ptr = p->${{param.ident}};') 5276882SBrad.Beckmann@amd.com else: 52810308Snilay@cs.wisc.edu code('m_${{param.ident}} = p->${{param.ident}};') 52910311Snilay@cs.wisc.edu 53010308Snilay@cs.wisc.edu if re.compile("sequencer").search(param.ident): 53110308Snilay@cs.wisc.edu code('m_${{param.ident}}_ptr->setController(this);') 53210917Sbrandon.potter@amd.com 5339595Snilay@cs.wisc.edu code(''' 5349745Snilay@cs.wisc.edu 5359745Snilay@cs.wisc.edufor (int state = 0; state < ${ident}_State_NUM; state++) { 5369745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 5379745Snilay@cs.wisc.edu m_possible[state][event] = false; 5389745Snilay@cs.wisc.edu m_counters[state][event] = 0; 5399745Snilay@cs.wisc.edu } 5409745Snilay@cs.wisc.edu} 5419745Snilay@cs.wisc.edufor (int event = 0; event < ${ident}_Event_NUM; event++) { 5429745Snilay@cs.wisc.edu m_event_counters[event] = 0; 5439745Snilay@cs.wisc.edu} 5449595Snilay@cs.wisc.edu''') 5456657Snate@binkert.org code.dedent() 5466657Snate@binkert.org code(''' 5476657Snate@binkert.org} 5486657Snate@binkert.org 5497007Snate@binkert.orgvoid 55011021Sjthestness@gmail.com$c_ident::initNetQueues() 55110311Snilay@cs.wisc.edu{ 55210311Snilay@cs.wisc.edu MachineType machine_type = string_to_MachineType("${{self.ident}}"); 55310311Snilay@cs.wisc.edu int base M5_VAR_USED = MachineType_base_number(machine_type); 55410311Snilay@cs.wisc.edu 55510311Snilay@cs.wisc.edu''') 55610311Snilay@cs.wisc.edu code.indent() 55710311Snilay@cs.wisc.edu 55810311Snilay@cs.wisc.edu # set for maintaining the vnet, direction pairs already seen for this 55910311Snilay@cs.wisc.edu # machine. This map helps in implementing the check for avoiding 56010311Snilay@cs.wisc.edu # multiple message buffers being mapped to the same vnet. 56110311Snilay@cs.wisc.edu vnet_dir_set = set() 56210311Snilay@cs.wisc.edu 56310311Snilay@cs.wisc.edu for var in self.config_parameters: 56411084Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.ident 56510311Snilay@cs.wisc.edu if "network" in var: 56610311Snilay@cs.wisc.edu vtype = var.type_ast.type 56711021Sjthestness@gmail.com code('assert($vid != NULL);') 56811021Sjthestness@gmail.com 56910311Snilay@cs.wisc.edu # Network port object 57010311Snilay@cs.wisc.edu network = var["network"] 57110311Snilay@cs.wisc.edu 57210311Snilay@cs.wisc.edu if "virtual_network" in var: 57310311Snilay@cs.wisc.edu vnet = var["virtual_network"] 57410311Snilay@cs.wisc.edu vnet_type = var["vnet_type"] 57510311Snilay@cs.wisc.edu 57610311Snilay@cs.wisc.edu assert (vnet, network) not in vnet_dir_set 57710311Snilay@cs.wisc.edu vnet_dir_set.add((vnet,network)) 57810311Snilay@cs.wisc.edu 57910311Snilay@cs.wisc.edu code(''' 58011021Sjthestness@gmail.comm_net_ptr->set${network}NetQueue(m_version + base, $vid->getOrdered(), $vnet, 58111021Sjthestness@gmail.com "$vnet_type", $vid); 58210311Snilay@cs.wisc.edu''') 58310311Snilay@cs.wisc.edu # Set the end 58410311Snilay@cs.wisc.edu if network == "To": 58510311Snilay@cs.wisc.edu code('$vid->setSender(this);') 58610311Snilay@cs.wisc.edu else: 58710311Snilay@cs.wisc.edu code('$vid->setReceiver(this);') 58810311Snilay@cs.wisc.edu 58910311Snilay@cs.wisc.edu # Set Priority 59010311Snilay@cs.wisc.edu if "rank" in var: 59110311Snilay@cs.wisc.edu code('$vid->setPriority(${{var["rank"]}})') 59210311Snilay@cs.wisc.edu 59311084Snilay@cs.wisc.edu else: 59411084Snilay@cs.wisc.edu if var.type_ast.type.c_ident == "MessageBuffer": 59511084Snilay@cs.wisc.edu code('$vid->setReceiver(this);') 59611084Snilay@cs.wisc.edu if var.ident.find("triggerQueue") >= 0: 59711084Snilay@cs.wisc.edu code('$vid->setSender(this);') 59811084Snilay@cs.wisc.edu elif var.ident.find("optionalQueue") >= 0: 59911084Snilay@cs.wisc.edu code('$vid->setSender(this);') 60011084Snilay@cs.wisc.edu 60110311Snilay@cs.wisc.edu code.dedent() 60210311Snilay@cs.wisc.edu code(''' 60310311Snilay@cs.wisc.edu} 60410311Snilay@cs.wisc.edu 60510311Snilay@cs.wisc.eduvoid 6067007Snate@binkert.org$c_ident::init() 6076657Snate@binkert.org{ 6087007Snate@binkert.org // initialize objects 60911021Sjthestness@gmail.com initNetQueues(); 6106657Snate@binkert.org''') 6116657Snate@binkert.org 6126657Snate@binkert.org code.indent() 61310311Snilay@cs.wisc.edu 6146657Snate@binkert.org for var in self.objects: 6156657Snate@binkert.org vtype = var.type 61610305Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.ident 6176657Snate@binkert.org if "network" not in var: 6186657Snate@binkert.org # Not a network port object 6196657Snate@binkert.org if "primitive" in vtype: 6206657Snate@binkert.org code('$vid = new ${{vtype.c_ident}};') 6216657Snate@binkert.org if "default" in var: 6226657Snate@binkert.org code('(*$vid) = ${{var["default"]}};') 6236657Snate@binkert.org else: 6246657Snate@binkert.org # Normal Object 62511084Snilay@cs.wisc.edu th = var.get("template", "") 62611084Snilay@cs.wisc.edu expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 62711084Snilay@cs.wisc.edu args = "" 62811084Snilay@cs.wisc.edu if "non_obj" not in vtype and not vtype.isEnumeration: 62911084Snilay@cs.wisc.edu args = var.get("constructor", "") 6306657Snate@binkert.org 63111084Snilay@cs.wisc.edu code('$expr($args);') 6326657Snate@binkert.org code('assert($vid != NULL);') 6336657Snate@binkert.org 6346657Snate@binkert.org if "default" in var: 6357007Snate@binkert.org code('*$vid = ${{var["default"]}}; // Object default') 6366657Snate@binkert.org elif "default" in vtype: 6377007Snate@binkert.org comment = "Type %s default" % vtype.ident 6387007Snate@binkert.org code('*$vid = ${{vtype["default"]}}; // $comment') 6396657Snate@binkert.org 64011084Snilay@cs.wisc.edu if vtype.c_ident == "TimerTable": 6419508Snilay@cs.wisc.edu code('$vid->setClockObj(this);') 6429508Snilay@cs.wisc.edu 6439366Snilay@cs.wisc.edu # Set the prefetchers 6449366Snilay@cs.wisc.edu code() 6459366Snilay@cs.wisc.edu for prefetcher in self.prefetchers: 6469366Snilay@cs.wisc.edu code('${{prefetcher.code}}.setController(this);') 6477566SBrad.Beckmann@amd.com 6487672Snate@binkert.org code() 6496657Snate@binkert.org for port in self.in_ports: 6509465Snilay@cs.wisc.edu # Set the queue consumers 6516657Snate@binkert.org code('${{port.code}}.setConsumer(this);') 6526657Snate@binkert.org 6536657Snate@binkert.org # Initialize the transition profiling 6547672Snate@binkert.org code() 6556657Snate@binkert.org for trans in self.transitions: 6566657Snate@binkert.org # Figure out if we stall 6576657Snate@binkert.org stall = False 6586657Snate@binkert.org for action in trans.actions: 6596657Snate@binkert.org if action.ident == "z_stall": 6606657Snate@binkert.org stall = True 6616657Snate@binkert.org 6626657Snate@binkert.org # Only possible if it is not a 'z' case 6636657Snate@binkert.org if not stall: 6646657Snate@binkert.org state = "%s_State_%s" % (self.ident, trans.state.ident) 6656657Snate@binkert.org event = "%s_Event_%s" % (self.ident, trans.event.ident) 6669745Snilay@cs.wisc.edu code('possibleTransition($state, $event);') 6676657Snate@binkert.org 6686657Snate@binkert.org code.dedent() 6699496Snilay@cs.wisc.edu code(''' 6709496Snilay@cs.wisc.edu AbstractController::init(); 67110012Snilay@cs.wisc.edu resetStats(); 6729496Snilay@cs.wisc.edu} 6739496Snilay@cs.wisc.edu''') 6746657Snate@binkert.org 67510121Snilay@cs.wisc.edu mq_ident = "NULL" 6766657Snate@binkert.org for port in self.in_ports: 6776657Snate@binkert.org if port.code.find("mandatoryQueue_ptr") >= 0: 67810305Snilay@cs.wisc.edu mq_ident = "m_mandatoryQueue_ptr" 6796657Snate@binkert.org 68011021Sjthestness@gmail.com memq_ident = "NULL" 68111021Sjthestness@gmail.com for port in self.in_ports: 68211021Sjthestness@gmail.com if port.code.find("responseFromMemory_ptr") >= 0: 68311021Sjthestness@gmail.com memq_ident = "m_responseFromMemory_ptr" 68411021Sjthestness@gmail.com 6858683Snilay@cs.wisc.edu seq_ident = "NULL" 6868683Snilay@cs.wisc.edu for param in self.config_parameters: 68710308Snilay@cs.wisc.edu if param.ident == "sequencer": 6888683Snilay@cs.wisc.edu assert(param.pointer) 68910308Snilay@cs.wisc.edu seq_ident = "m_%s_ptr" % param.ident 6908683Snilay@cs.wisc.edu 6916657Snate@binkert.org code(''' 6929745Snilay@cs.wisc.edu 6939745Snilay@cs.wisc.eduvoid 6949745Snilay@cs.wisc.edu$c_ident::regStats() 6959745Snilay@cs.wisc.edu{ 69610012Snilay@cs.wisc.edu AbstractController::regStats(); 69710012Snilay@cs.wisc.edu 6989745Snilay@cs.wisc.edu if (m_version == 0) { 6999745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7009745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7019745Snilay@cs.wisc.edu Stats::Vector *t = new Stats::Vector(); 7029745Snilay@cs.wisc.edu t->init(m_num_controllers); 70310919Sbrandon.potter@amd.com t->name(params()->ruby_system->name() + ".${c_ident}." + 70410012Snilay@cs.wisc.edu ${ident}_Event_to_string(event)); 7059745Snilay@cs.wisc.edu t->flags(Stats::pdf | Stats::total | Stats::oneline | 7069745Snilay@cs.wisc.edu Stats::nozero); 7079745Snilay@cs.wisc.edu 7089745Snilay@cs.wisc.edu eventVec.push_back(t); 7099745Snilay@cs.wisc.edu } 7109745Snilay@cs.wisc.edu 7119745Snilay@cs.wisc.edu for (${ident}_State state = ${ident}_State_FIRST; 7129745Snilay@cs.wisc.edu state < ${ident}_State_NUM; ++state) { 7139745Snilay@cs.wisc.edu 7149745Snilay@cs.wisc.edu transVec.push_back(std::vector<Stats::Vector *>()); 7159745Snilay@cs.wisc.edu 7169745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7179745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7189745Snilay@cs.wisc.edu 7199745Snilay@cs.wisc.edu Stats::Vector *t = new Stats::Vector(); 7209745Snilay@cs.wisc.edu t->init(m_num_controllers); 72110919Sbrandon.potter@amd.com t->name(params()->ruby_system->name() + ".${c_ident}." + 72210012Snilay@cs.wisc.edu ${ident}_State_to_string(state) + 7239745Snilay@cs.wisc.edu "." + ${ident}_Event_to_string(event)); 7249745Snilay@cs.wisc.edu 7259745Snilay@cs.wisc.edu t->flags(Stats::pdf | Stats::total | Stats::oneline | 7269745Snilay@cs.wisc.edu Stats::nozero); 7279745Snilay@cs.wisc.edu transVec[state].push_back(t); 7289745Snilay@cs.wisc.edu } 7299745Snilay@cs.wisc.edu } 7309745Snilay@cs.wisc.edu } 7319745Snilay@cs.wisc.edu} 7329745Snilay@cs.wisc.edu 7339745Snilay@cs.wisc.eduvoid 7349745Snilay@cs.wisc.edu$c_ident::collateStats() 7359745Snilay@cs.wisc.edu{ 7369745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7379745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7389745Snilay@cs.wisc.edu for (unsigned int i = 0; i < m_num_controllers; ++i) { 73910920Sbrandon.potter@amd.com RubySystem *rs = params()->ruby_system; 7409745Snilay@cs.wisc.edu std::map<uint32_t, AbstractController *>::iterator it = 74110920Sbrandon.potter@amd.com rs->m_abstract_controls[MachineType_${ident}].find(i); 74210920Sbrandon.potter@amd.com assert(it != rs->m_abstract_controls[MachineType_${ident}].end()); 7439745Snilay@cs.wisc.edu (*eventVec[event])[i] = 7449745Snilay@cs.wisc.edu (($c_ident *)(*it).second)->getEventCount(event); 7459745Snilay@cs.wisc.edu } 7469745Snilay@cs.wisc.edu } 7479745Snilay@cs.wisc.edu 7489745Snilay@cs.wisc.edu for (${ident}_State state = ${ident}_State_FIRST; 7499745Snilay@cs.wisc.edu state < ${ident}_State_NUM; ++state) { 7509745Snilay@cs.wisc.edu 7519745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7529745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7539745Snilay@cs.wisc.edu 7549745Snilay@cs.wisc.edu for (unsigned int i = 0; i < m_num_controllers; ++i) { 75510920Sbrandon.potter@amd.com RubySystem *rs = params()->ruby_system; 7569745Snilay@cs.wisc.edu std::map<uint32_t, AbstractController *>::iterator it = 75710920Sbrandon.potter@amd.com rs->m_abstract_controls[MachineType_${ident}].find(i); 75810920Sbrandon.potter@amd.com assert(it != rs->m_abstract_controls[MachineType_${ident}].end()); 7599745Snilay@cs.wisc.edu (*transVec[state][event])[i] = 7609745Snilay@cs.wisc.edu (($c_ident *)(*it).second)->getTransitionCount(state, event); 7619745Snilay@cs.wisc.edu } 7629745Snilay@cs.wisc.edu } 7639745Snilay@cs.wisc.edu } 7649745Snilay@cs.wisc.edu} 7659745Snilay@cs.wisc.edu 7669745Snilay@cs.wisc.eduvoid 7679745Snilay@cs.wisc.edu$c_ident::countTransition(${ident}_State state, ${ident}_Event event) 7689745Snilay@cs.wisc.edu{ 7699745Snilay@cs.wisc.edu assert(m_possible[state][event]); 7709745Snilay@cs.wisc.edu m_counters[state][event]++; 7719745Snilay@cs.wisc.edu m_event_counters[event]++; 7729745Snilay@cs.wisc.edu} 7739745Snilay@cs.wisc.eduvoid 7749745Snilay@cs.wisc.edu$c_ident::possibleTransition(${ident}_State state, 7759745Snilay@cs.wisc.edu ${ident}_Event event) 7769745Snilay@cs.wisc.edu{ 7779745Snilay@cs.wisc.edu m_possible[state][event] = true; 7789745Snilay@cs.wisc.edu} 7799745Snilay@cs.wisc.edu 78011061Snilay@cs.wisc.eduuint64_t 7819745Snilay@cs.wisc.edu$c_ident::getEventCount(${ident}_Event event) 7829745Snilay@cs.wisc.edu{ 7839745Snilay@cs.wisc.edu return m_event_counters[event]; 7849745Snilay@cs.wisc.edu} 7859745Snilay@cs.wisc.edu 7869745Snilay@cs.wisc.edubool 7879745Snilay@cs.wisc.edu$c_ident::isPossible(${ident}_State state, ${ident}_Event event) 7889745Snilay@cs.wisc.edu{ 7899745Snilay@cs.wisc.edu return m_possible[state][event]; 7909745Snilay@cs.wisc.edu} 7919745Snilay@cs.wisc.edu 79211061Snilay@cs.wisc.eduuint64_t 7939745Snilay@cs.wisc.edu$c_ident::getTransitionCount(${ident}_State state, 7949745Snilay@cs.wisc.edu ${ident}_Event event) 7959745Snilay@cs.wisc.edu{ 7969745Snilay@cs.wisc.edu return m_counters[state][event]; 7979745Snilay@cs.wisc.edu} 7989745Snilay@cs.wisc.edu 7997007Snate@binkert.orgint 8007007Snate@binkert.org$c_ident::getNumControllers() 8017007Snate@binkert.org{ 8026657Snate@binkert.org return m_num_controllers; 8036657Snate@binkert.org} 8046657Snate@binkert.org 8057007Snate@binkert.orgMessageBuffer* 8067007Snate@binkert.org$c_ident::getMandatoryQueue() const 8077007Snate@binkert.org{ 8086657Snate@binkert.org return $mq_ident; 8096657Snate@binkert.org} 8106657Snate@binkert.org 81111021Sjthestness@gmail.comMessageBuffer* 81211021Sjthestness@gmail.com$c_ident::getMemoryQueue() const 81311021Sjthestness@gmail.com{ 81411021Sjthestness@gmail.com return $memq_ident; 81511021Sjthestness@gmail.com} 81611021Sjthestness@gmail.com 8178683Snilay@cs.wisc.eduSequencer* 8188683Snilay@cs.wisc.edu$c_ident::getSequencer() const 8198683Snilay@cs.wisc.edu{ 8208683Snilay@cs.wisc.edu return $seq_ident; 8218683Snilay@cs.wisc.edu} 8228683Snilay@cs.wisc.edu 8237007Snate@binkert.orgvoid 8247007Snate@binkert.org$c_ident::print(ostream& out) const 8257007Snate@binkert.org{ 8267007Snate@binkert.org out << "[$c_ident " << m_version << "]"; 8277007Snate@binkert.org} 8286657Snate@binkert.org 82910012Snilay@cs.wisc.eduvoid $c_ident::resetStats() 8309745Snilay@cs.wisc.edu{ 8319745Snilay@cs.wisc.edu for (int state = 0; state < ${ident}_State_NUM; state++) { 8329745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 8339745Snilay@cs.wisc.edu m_counters[state][event] = 0; 8349745Snilay@cs.wisc.edu } 8359745Snilay@cs.wisc.edu } 8366902SBrad.Beckmann@amd.com 8379745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 8389745Snilay@cs.wisc.edu m_event_counters[event] = 0; 8399745Snilay@cs.wisc.edu } 8409745Snilay@cs.wisc.edu 84110012Snilay@cs.wisc.edu AbstractController::resetStats(); 8426902SBrad.Beckmann@amd.com} 8437839Snilay@cs.wisc.edu''') 8447839Snilay@cs.wisc.edu 8457839Snilay@cs.wisc.edu if self.EntryType != None: 8467839Snilay@cs.wisc.edu code(''' 8477839Snilay@cs.wisc.edu 8487839Snilay@cs.wisc.edu// Set and Reset for cache_entry variable 8497839Snilay@cs.wisc.eduvoid 8507839Snilay@cs.wisc.edu$c_ident::set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry) 8517839Snilay@cs.wisc.edu{ 8527839Snilay@cs.wisc.edu m_cache_entry_ptr = (${{self.EntryType.c_ident}}*)m_new_cache_entry; 8537839Snilay@cs.wisc.edu} 8547839Snilay@cs.wisc.edu 8557839Snilay@cs.wisc.eduvoid 8567839Snilay@cs.wisc.edu$c_ident::unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr) 8577839Snilay@cs.wisc.edu{ 8587839Snilay@cs.wisc.edu m_cache_entry_ptr = 0; 8597839Snilay@cs.wisc.edu} 8607839Snilay@cs.wisc.edu''') 8617839Snilay@cs.wisc.edu 8627839Snilay@cs.wisc.edu if self.TBEType != None: 8637839Snilay@cs.wisc.edu code(''' 8647839Snilay@cs.wisc.edu 8657839Snilay@cs.wisc.edu// Set and Reset for tbe variable 8667839Snilay@cs.wisc.eduvoid 8677839Snilay@cs.wisc.edu$c_ident::set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.TBEType.c_ident}}* m_new_tbe) 8687839Snilay@cs.wisc.edu{ 8697839Snilay@cs.wisc.edu m_tbe_ptr = m_new_tbe; 8707839Snilay@cs.wisc.edu} 8717839Snilay@cs.wisc.edu 8727839Snilay@cs.wisc.eduvoid 8737839Snilay@cs.wisc.edu$c_ident::unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr) 8747839Snilay@cs.wisc.edu{ 8757839Snilay@cs.wisc.edu m_tbe_ptr = NULL; 8767839Snilay@cs.wisc.edu} 8777839Snilay@cs.wisc.edu''') 8787839Snilay@cs.wisc.edu 8797839Snilay@cs.wisc.edu code(''' 8806902SBrad.Beckmann@amd.com 8818683Snilay@cs.wisc.eduvoid 8828683Snilay@cs.wisc.edu$c_ident::recordCacheTrace(int cntrl, CacheRecorder* tr) 8838683Snilay@cs.wisc.edu{ 8848683Snilay@cs.wisc.edu''') 8858683Snilay@cs.wisc.edu # 8868683Snilay@cs.wisc.edu # Record cache contents for all associated caches. 8878683Snilay@cs.wisc.edu # 8888683Snilay@cs.wisc.edu code.indent() 8898683Snilay@cs.wisc.edu for param in self.config_parameters: 8908683Snilay@cs.wisc.edu if param.type_ast.type.ident == "CacheMemory": 8918683Snilay@cs.wisc.edu assert(param.pointer) 8928683Snilay@cs.wisc.edu code('m_${{param.ident}}_ptr->recordCacheContents(cntrl, tr);') 8938683Snilay@cs.wisc.edu 8948683Snilay@cs.wisc.edu code.dedent() 8958683Snilay@cs.wisc.edu code(''' 8968683Snilay@cs.wisc.edu} 8978683Snilay@cs.wisc.edu 8986657Snate@binkert.org// Actions 8996657Snate@binkert.org''') 9007839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 9017839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9027839Snilay@cs.wisc.edu if "c_code" not in action: 9037839Snilay@cs.wisc.edu continue 9046657Snate@binkert.org 9057839Snilay@cs.wisc.edu code(''' 9067839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 9077839Snilay@cs.wisc.eduvoid 90811025Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, Addr addr) 9097839Snilay@cs.wisc.edu{ 9108055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 91110963Sdavid.hashe@amd.com try { 91210963Sdavid.hashe@amd.com ${{action["c_code"]}} 91310963Sdavid.hashe@amd.com } catch (const RejectException & e) { 91410963Sdavid.hashe@amd.com fatal("Error in action ${{ident}}:${{action.ident}}: " 91510963Sdavid.hashe@amd.com "executed a peek statement with the wrong message " 91610963Sdavid.hashe@amd.com "type specified. "); 91710963Sdavid.hashe@amd.com } 9187839Snilay@cs.wisc.edu} 9196657Snate@binkert.org 9207839Snilay@cs.wisc.edu''') 9217839Snilay@cs.wisc.edu elif self.TBEType != None: 9227839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9237839Snilay@cs.wisc.edu if "c_code" not in action: 9247839Snilay@cs.wisc.edu continue 9257839Snilay@cs.wisc.edu 9267839Snilay@cs.wisc.edu code(''' 9277839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 9287839Snilay@cs.wisc.eduvoid 92911025Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, Addr addr) 9307839Snilay@cs.wisc.edu{ 9318055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 9327839Snilay@cs.wisc.edu ${{action["c_code"]}} 9337839Snilay@cs.wisc.edu} 9347839Snilay@cs.wisc.edu 9357839Snilay@cs.wisc.edu''') 9367839Snilay@cs.wisc.edu elif self.EntryType != None: 9377839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9387839Snilay@cs.wisc.edu if "c_code" not in action: 9397839Snilay@cs.wisc.edu continue 9407839Snilay@cs.wisc.edu 9417839Snilay@cs.wisc.edu code(''' 9427839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 9437839Snilay@cs.wisc.eduvoid 94411025Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, Addr addr) 9457839Snilay@cs.wisc.edu{ 9468055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 9477839Snilay@cs.wisc.edu ${{action["c_code"]}} 9487839Snilay@cs.wisc.edu} 9497839Snilay@cs.wisc.edu 9507839Snilay@cs.wisc.edu''') 9517839Snilay@cs.wisc.edu else: 9527839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9537839Snilay@cs.wisc.edu if "c_code" not in action: 9547839Snilay@cs.wisc.edu continue 9557839Snilay@cs.wisc.edu 9567839Snilay@cs.wisc.edu code(''' 9576657Snate@binkert.org/** \\brief ${{action.desc}} */ 9587007Snate@binkert.orgvoid 95911025Snilay@cs.wisc.edu$c_ident::${{action.ident}}(Addr addr) 9606657Snate@binkert.org{ 9618055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 9626657Snate@binkert.org ${{action["c_code"]}} 9636657Snate@binkert.org} 9646657Snate@binkert.org 9656657Snate@binkert.org''') 9668478Snilay@cs.wisc.edu for func in self.functions: 9678478Snilay@cs.wisc.edu code(func.generateCode()) 9688478Snilay@cs.wisc.edu 9699302Snilay@cs.wisc.edu # Function for functional writes to messages buffered in the controller 9709302Snilay@cs.wisc.edu code(''' 97110524Snilay@cs.wisc.eduint 9729302Snilay@cs.wisc.edu$c_ident::functionalWriteBuffers(PacketPtr& pkt) 9739302Snilay@cs.wisc.edu{ 97410524Snilay@cs.wisc.edu int num_functional_writes = 0; 9759302Snilay@cs.wisc.edu''') 9769302Snilay@cs.wisc.edu for var in self.objects: 9779302Snilay@cs.wisc.edu vtype = var.type 9789302Snilay@cs.wisc.edu if vtype.isBuffer: 97910305Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.ident 9809302Snilay@cs.wisc.edu code('num_functional_writes += $vid->functionalWrite(pkt);') 98110311Snilay@cs.wisc.edu 98210311Snilay@cs.wisc.edu for var in self.config_parameters: 98310311Snilay@cs.wisc.edu vtype = var.type_ast.type 98410311Snilay@cs.wisc.edu if vtype.isBuffer: 98510311Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.ident 98610311Snilay@cs.wisc.edu code('num_functional_writes += $vid->functionalWrite(pkt);') 98710311Snilay@cs.wisc.edu 9889302Snilay@cs.wisc.edu code(''' 9899302Snilay@cs.wisc.edu return num_functional_writes; 9909302Snilay@cs.wisc.edu} 9919302Snilay@cs.wisc.edu''') 9929302Snilay@cs.wisc.edu 9936657Snate@binkert.org code.write(path, "%s.cc" % c_ident) 9946657Snate@binkert.org 9959219Spower.jg@gmail.com def printCWakeup(self, path, includes): 9966657Snate@binkert.org '''Output the wakeup loop for the events''' 9976657Snate@binkert.org 9986999Snate@binkert.org code = self.symtab.codeFormatter() 9996657Snate@binkert.org ident = self.ident 10006657Snate@binkert.org 10019104Shestness@cs.utexas.edu outputRequest_types = True 10029104Shestness@cs.utexas.edu if len(self.request_types) == 0: 10039104Shestness@cs.utexas.edu outputRequest_types = False 10049104Shestness@cs.utexas.edu 10056657Snate@binkert.org code(''' 10066657Snate@binkert.org// Auto generated C++ code started by $__file__:$__line__ 10076657Snate@binkert.org// ${ident}: ${{self.short}} 10086657Snate@binkert.org 10098946Sandreas.hansson@arm.com#include <sys/types.h> 10108946Sandreas.hansson@arm.com#include <unistd.h> 10118946Sandreas.hansson@arm.com 10127832Snate@binkert.org#include <cassert> 101310972Sdavid.hashe@amd.com#include <typeinfo> 10147832Snate@binkert.org 10157007Snate@binkert.org#include "base/misc.hh" 101610972Sdavid.hashe@amd.com 101710972Sdavid.hashe@amd.com''') 101810972Sdavid.hashe@amd.com for f in self.debug_flags: 101910972Sdavid.hashe@amd.com code('#include "debug/${{f}}.hh"') 102010972Sdavid.hashe@amd.com code(''' 10218229Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 10228229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 10238229Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 102410972Sdavid.hashe@amd.com 10259104Shestness@cs.utexas.edu''') 10269104Shestness@cs.utexas.edu 10279104Shestness@cs.utexas.edu if outputRequest_types: 10289104Shestness@cs.utexas.edu code('''#include "mem/protocol/${ident}_RequestType.hh"''') 10299104Shestness@cs.utexas.edu 10309104Shestness@cs.utexas.edu code(''' 10318229Snate@binkert.org#include "mem/protocol/Types.hh" 10326657Snate@binkert.org#include "mem/ruby/system/System.hh" 103310972Sdavid.hashe@amd.com 10349219Spower.jg@gmail.com''') 10359219Spower.jg@gmail.com 10369219Spower.jg@gmail.com 10379219Spower.jg@gmail.com for include_path in includes: 10389219Spower.jg@gmail.com code('#include "${{include_path}}"') 10399219Spower.jg@gmail.com 104010963Sdavid.hashe@amd.com port_to_buf_map, in_msg_bufs, msg_bufs = self.getBufferMaps(ident) 104110963Sdavid.hashe@amd.com 10429219Spower.jg@gmail.com code(''' 10436657Snate@binkert.org 10447055Snate@binkert.orgusing namespace std; 10457055Snate@binkert.org 10467007Snate@binkert.orgvoid 10477007Snate@binkert.org${ident}_Controller::wakeup() 10486657Snate@binkert.org{ 10496657Snate@binkert.org int counter = 0; 10506657Snate@binkert.org while (true) { 105110963Sdavid.hashe@amd.com unsigned char rejected[${{len(msg_bufs)}}]; 105210963Sdavid.hashe@amd.com memset(rejected, 0, sizeof(unsigned char)*${{len(msg_bufs)}}); 10536657Snate@binkert.org // Some cases will put us into an infinite loop without this limit 10546657Snate@binkert.org assert(counter <= m_transitions_per_cycle); 10556657Snate@binkert.org if (counter == m_transitions_per_cycle) { 10567007Snate@binkert.org // Count how often we are fully utilized 10579496Snilay@cs.wisc.edu m_fully_busy_cycles++; 10587007Snate@binkert.org 10597007Snate@binkert.org // Wakeup in another cycle and try again 10609499Snilay@cs.wisc.edu scheduleEvent(Cycles(1)); 10616657Snate@binkert.org break; 10626657Snate@binkert.org } 10636657Snate@binkert.org''') 10646657Snate@binkert.org 10656657Snate@binkert.org code.indent() 10666657Snate@binkert.org code.indent() 10676657Snate@binkert.org 10686657Snate@binkert.org # InPorts 10696657Snate@binkert.org # 10706657Snate@binkert.org for port in self.in_ports: 10716657Snate@binkert.org code.indent() 10726657Snate@binkert.org code('// ${ident}InPort $port') 10737567SBrad.Beckmann@amd.com if port.pairs.has_key("rank"): 10749996Snilay@cs.wisc.edu code('m_cur_in_port = ${{port.pairs["rank"]}};') 10757567SBrad.Beckmann@amd.com else: 10769996Snilay@cs.wisc.edu code('m_cur_in_port = 0;') 107710963Sdavid.hashe@amd.com if port in port_to_buf_map: 107810963Sdavid.hashe@amd.com code('try {') 107910963Sdavid.hashe@amd.com code.indent() 10806657Snate@binkert.org code('${{port["c_code_in_port"]}}') 108110963Sdavid.hashe@amd.com 108210963Sdavid.hashe@amd.com if port in port_to_buf_map: 108310963Sdavid.hashe@amd.com code.dedent() 108410963Sdavid.hashe@amd.com code(''' 108510963Sdavid.hashe@amd.com } catch (const RejectException & e) { 108610963Sdavid.hashe@amd.com rejected[${{port_to_buf_map[port]}}]++; 108710963Sdavid.hashe@amd.com } 108810963Sdavid.hashe@amd.com''') 10896657Snate@binkert.org code.dedent() 10906657Snate@binkert.org code('') 10916657Snate@binkert.org 10926657Snate@binkert.org code.dedent() 10936657Snate@binkert.org code.dedent() 10946657Snate@binkert.org code(''' 109510963Sdavid.hashe@amd.com // If we got this far, we have nothing left todo or something went 109610963Sdavid.hashe@amd.com // wrong''') 109710963Sdavid.hashe@amd.com for buf_name, ports in in_msg_bufs.items(): 109810963Sdavid.hashe@amd.com if len(ports) > 1: 109910963Sdavid.hashe@amd.com # only produce checks when a buffer is shared by multiple ports 110010963Sdavid.hashe@amd.com code(''' 110110963Sdavid.hashe@amd.com if (${{buf_name}}->isReady() && rejected[${{port_to_buf_map[ports[0]]}}] == ${{len(ports)}}) 110210963Sdavid.hashe@amd.com { 110310963Sdavid.hashe@amd.com // no port claimed the message on the top of this buffer 110410963Sdavid.hashe@amd.com panic("Runtime Error at Ruby Time: %d. " 110510963Sdavid.hashe@amd.com "All ports rejected a message. " 110610963Sdavid.hashe@amd.com "You are probably sending a message type to this controller " 110710963Sdavid.hashe@amd.com "over a virtual network that do not define an in_port for " 110810963Sdavid.hashe@amd.com "the incoming message type.\\n", 110910963Sdavid.hashe@amd.com Cycles(1)); 111010963Sdavid.hashe@amd.com } 111110963Sdavid.hashe@amd.com''') 111210963Sdavid.hashe@amd.com code(''' 111310963Sdavid.hashe@amd.com break; 11146657Snate@binkert.org } 11156657Snate@binkert.org} 11166657Snate@binkert.org''') 11176657Snate@binkert.org 11186657Snate@binkert.org code.write(path, "%s_Wakeup.cc" % self.ident) 11196657Snate@binkert.org 11206657Snate@binkert.org def printCSwitch(self, path): 11216657Snate@binkert.org '''Output switch statement for transition table''' 11226657Snate@binkert.org 11236999Snate@binkert.org code = self.symtab.codeFormatter() 11246657Snate@binkert.org ident = self.ident 11256657Snate@binkert.org 11266657Snate@binkert.org code(''' 11276657Snate@binkert.org// Auto generated C++ code started by $__file__:$__line__ 11286657Snate@binkert.org// ${ident}: ${{self.short}} 11296657Snate@binkert.org 11307832Snate@binkert.org#include <cassert> 11317832Snate@binkert.org 11327805Snilay@cs.wisc.edu#include "base/misc.hh" 11337832Snate@binkert.org#include "base/trace.hh" 11348232Snate@binkert.org#include "debug/ProtocolTrace.hh" 11358232Snate@binkert.org#include "debug/RubyGenerated.hh" 11368229Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 11378229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 11388229Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 11398229Snate@binkert.org#include "mem/protocol/Types.hh" 11406657Snate@binkert.org#include "mem/ruby/system/System.hh" 11416657Snate@binkert.org 11426657Snate@binkert.org#define HASH_FUN(state, event) ((int(state)*${ident}_Event_NUM)+int(event)) 11436657Snate@binkert.org 11446657Snate@binkert.org#define GET_TRANSITION_COMMENT() (${ident}_transitionComment.str()) 11456657Snate@binkert.org#define CLEAR_TRANSITION_COMMENT() (${ident}_transitionComment.str("")) 11466657Snate@binkert.org 11477007Snate@binkert.orgTransitionResult 11487007Snate@binkert.org${ident}_Controller::doTransition(${ident}_Event event, 11497839Snilay@cs.wisc.edu''') 11507839Snilay@cs.wisc.edu if self.EntryType != None: 11517839Snilay@cs.wisc.edu code(''' 11527839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}* m_cache_entry_ptr, 11537839Snilay@cs.wisc.edu''') 11547839Snilay@cs.wisc.edu if self.TBEType != None: 11557839Snilay@cs.wisc.edu code(''' 11567839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}* m_tbe_ptr, 11577839Snilay@cs.wisc.edu''') 11587839Snilay@cs.wisc.edu code(''' 115911025Snilay@cs.wisc.edu Addr addr) 11606657Snate@binkert.org{ 11617839Snilay@cs.wisc.edu''') 116210305Snilay@cs.wisc.edu code.indent() 116310305Snilay@cs.wisc.edu 11647839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 11658337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);') 11667839Snilay@cs.wisc.edu elif self.TBEType != None: 11678337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_tbe_ptr, addr);') 11687839Snilay@cs.wisc.edu elif self.EntryType != None: 11698337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_cache_entry_ptr, addr);') 11707839Snilay@cs.wisc.edu else: 11718337Snilay@cs.wisc.edu code('${ident}_State state = getState(addr);') 11727839Snilay@cs.wisc.edu 11737839Snilay@cs.wisc.edu code(''' 117410305Snilay@cs.wisc.edu${ident}_State next_state = state; 11756657Snate@binkert.org 117610305Snilay@cs.wisc.eduDPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n", 117710305Snilay@cs.wisc.edu *this, curCycle(), ${ident}_State_to_string(state), 117810305Snilay@cs.wisc.edu ${ident}_Event_to_string(event), addr); 11796657Snate@binkert.org 118010305Snilay@cs.wisc.eduTransitionResult result = 11817839Snilay@cs.wisc.edu''') 11827839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 11837839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);') 11847839Snilay@cs.wisc.edu elif self.TBEType != None: 11857839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_tbe_ptr, addr);') 11867839Snilay@cs.wisc.edu elif self.EntryType != None: 11877839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);') 11887839Snilay@cs.wisc.edu else: 11897839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, addr);') 11906657Snate@binkert.org 119111049Snilay@cs.wisc.edu port_to_buf_map, in_msg_bufs, msg_bufs = self.getBufferMaps(ident) 119211049Snilay@cs.wisc.edu 11937839Snilay@cs.wisc.edu code(''' 11946657Snate@binkert.org 119510305Snilay@cs.wisc.eduif (result == TransitionResult_Valid) { 119610305Snilay@cs.wisc.edu DPRINTF(RubyGenerated, "next_state: %s\\n", 119710305Snilay@cs.wisc.edu ${ident}_State_to_string(next_state)); 119810305Snilay@cs.wisc.edu countTransition(state, event); 119910305Snilay@cs.wisc.edu 120011025Snilay@cs.wisc.edu DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %#x %s\\n", 120110305Snilay@cs.wisc.edu curTick(), m_version, "${ident}", 120210305Snilay@cs.wisc.edu ${ident}_Event_to_string(event), 120310305Snilay@cs.wisc.edu ${ident}_State_to_string(state), 120410305Snilay@cs.wisc.edu ${ident}_State_to_string(next_state), 120510305Snilay@cs.wisc.edu addr, GET_TRANSITION_COMMENT()); 120610305Snilay@cs.wisc.edu 120710305Snilay@cs.wisc.edu CLEAR_TRANSITION_COMMENT(); 12087839Snilay@cs.wisc.edu''') 12097839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 12108337Snilay@cs.wisc.edu code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);') 12118341Snilay@cs.wisc.edu code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 12127839Snilay@cs.wisc.edu elif self.TBEType != None: 12138337Snilay@cs.wisc.edu code('setState(m_tbe_ptr, addr, next_state);') 12148341Snilay@cs.wisc.edu code('setAccessPermission(addr, next_state);') 12157839Snilay@cs.wisc.edu elif self.EntryType != None: 12168337Snilay@cs.wisc.edu code('setState(m_cache_entry_ptr, addr, next_state);') 12178341Snilay@cs.wisc.edu code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 12187839Snilay@cs.wisc.edu else: 12198337Snilay@cs.wisc.edu code('setState(addr, next_state);') 12208341Snilay@cs.wisc.edu code('setAccessPermission(addr, next_state);') 12217839Snilay@cs.wisc.edu 12227839Snilay@cs.wisc.edu code(''' 122310305Snilay@cs.wisc.edu} else if (result == TransitionResult_ResourceStall) { 122411025Snilay@cs.wisc.edu DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %#x %s\\n", 122510305Snilay@cs.wisc.edu curTick(), m_version, "${ident}", 122610305Snilay@cs.wisc.edu ${ident}_Event_to_string(event), 122710305Snilay@cs.wisc.edu ${ident}_State_to_string(state), 122810305Snilay@cs.wisc.edu ${ident}_State_to_string(next_state), 122910305Snilay@cs.wisc.edu addr, "Resource Stall"); 123010305Snilay@cs.wisc.edu} else if (result == TransitionResult_ProtocolStall) { 123110305Snilay@cs.wisc.edu DPRINTF(RubyGenerated, "stalling\\n"); 123211025Snilay@cs.wisc.edu DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %#x %s\\n", 123310305Snilay@cs.wisc.edu curTick(), m_version, "${ident}", 123410305Snilay@cs.wisc.edu ${ident}_Event_to_string(event), 123510305Snilay@cs.wisc.edu ${ident}_State_to_string(state), 123610305Snilay@cs.wisc.edu ${ident}_State_to_string(next_state), 123710305Snilay@cs.wisc.edu addr, "Protocol Stall"); 123810305Snilay@cs.wisc.edu} 12396657Snate@binkert.org 124010305Snilay@cs.wisc.edureturn result; 124110305Snilay@cs.wisc.edu''') 124210305Snilay@cs.wisc.edu code.dedent() 124310305Snilay@cs.wisc.edu code(''' 12446657Snate@binkert.org} 12456657Snate@binkert.org 12467007Snate@binkert.orgTransitionResult 12477007Snate@binkert.org${ident}_Controller::doTransitionWorker(${ident}_Event event, 12487007Snate@binkert.org ${ident}_State state, 12497007Snate@binkert.org ${ident}_State& next_state, 12507839Snilay@cs.wisc.edu''') 12517839Snilay@cs.wisc.edu 12527839Snilay@cs.wisc.edu if self.TBEType != None: 12537839Snilay@cs.wisc.edu code(''' 12547839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}*& m_tbe_ptr, 12557839Snilay@cs.wisc.edu''') 12567839Snilay@cs.wisc.edu if self.EntryType != None: 12577839Snilay@cs.wisc.edu code(''' 12587839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, 12597839Snilay@cs.wisc.edu''') 12607839Snilay@cs.wisc.edu code(''' 126111025Snilay@cs.wisc.edu Addr addr) 12626657Snate@binkert.org{ 12636657Snate@binkert.org switch(HASH_FUN(state, event)) { 12646657Snate@binkert.org''') 12656657Snate@binkert.org 12666657Snate@binkert.org # This map will allow suppress generating duplicate code 12676657Snate@binkert.org cases = orderdict() 12686657Snate@binkert.org 12696657Snate@binkert.org for trans in self.transitions: 12706657Snate@binkert.org case_string = "%s_State_%s, %s_Event_%s" % \ 12716657Snate@binkert.org (self.ident, trans.state.ident, self.ident, trans.event.ident) 12726657Snate@binkert.org 12736999Snate@binkert.org case = self.symtab.codeFormatter() 12746657Snate@binkert.org # Only set next_state if it changes 12756657Snate@binkert.org if trans.state != trans.nextState: 127610964Sdavid.hashe@amd.com if trans.nextState.isWildcard(): 127710964Sdavid.hashe@amd.com # When * is encountered as an end state of a transition, 127810964Sdavid.hashe@amd.com # the next state is determined by calling the 127910964Sdavid.hashe@amd.com # machine-specific getNextState function. The next state 128010964Sdavid.hashe@amd.com # is determined before any actions of the transition 128110964Sdavid.hashe@amd.com # execute, and therefore the next state calculation cannot 128210964Sdavid.hashe@amd.com # depend on any of the transitionactions. 128310964Sdavid.hashe@amd.com case('next_state = getNextState(addr);') 128410964Sdavid.hashe@amd.com else: 128510964Sdavid.hashe@amd.com ns_ident = trans.nextState.ident 128610964Sdavid.hashe@amd.com case('next_state = ${ident}_State_${ns_ident};') 12876657Snate@binkert.org 12886657Snate@binkert.org actions = trans.actions 12899104Shestness@cs.utexas.edu request_types = trans.request_types 12906657Snate@binkert.org 12916657Snate@binkert.org # Check for resources 12926657Snate@binkert.org case_sorter = [] 12936657Snate@binkert.org res = trans.resources 12946657Snate@binkert.org for key,val in res.iteritems(): 129510228Snilay@cs.wisc.edu val = ''' 12967007Snate@binkert.orgif (!%s.areNSlotsAvailable(%s)) 12976657Snate@binkert.org return TransitionResult_ResourceStall; 12986657Snate@binkert.org''' % (key.code, val) 12996657Snate@binkert.org case_sorter.append(val) 13006657Snate@binkert.org 13019105SBrad.Beckmann@amd.com # Check all of the request_types for resource constraints 13029105SBrad.Beckmann@amd.com for request_type in request_types: 13039105SBrad.Beckmann@amd.com val = ''' 13049105SBrad.Beckmann@amd.comif (!checkResourceAvailable(%s_RequestType_%s, addr)) { 13059105SBrad.Beckmann@amd.com return TransitionResult_ResourceStall; 13069105SBrad.Beckmann@amd.com} 13079105SBrad.Beckmann@amd.com''' % (self.ident, request_type.ident) 13089105SBrad.Beckmann@amd.com case_sorter.append(val) 13096657Snate@binkert.org 13106657Snate@binkert.org # Emit the code sequences in a sorted order. This makes the 13116657Snate@binkert.org # output deterministic (without this the output order can vary 13126657Snate@binkert.org # since Map's keys() on a vector of pointers is not deterministic 13136657Snate@binkert.org for c in sorted(case_sorter): 13146657Snate@binkert.org case("$c") 13156657Snate@binkert.org 13169104Shestness@cs.utexas.edu # Record access types for this transition 13179104Shestness@cs.utexas.edu for request_type in request_types: 13189104Shestness@cs.utexas.edu case('recordRequestType(${ident}_RequestType_${{request_type.ident}}, addr);') 13199104Shestness@cs.utexas.edu 13206657Snate@binkert.org # Figure out if we stall 13216657Snate@binkert.org stall = False 13226657Snate@binkert.org for action in actions: 13236657Snate@binkert.org if action.ident == "z_stall": 13246657Snate@binkert.org stall = True 13256657Snate@binkert.org break 13266657Snate@binkert.org 13276657Snate@binkert.org if stall: 13286657Snate@binkert.org case('return TransitionResult_ProtocolStall;') 13296657Snate@binkert.org else: 13307839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 13317839Snilay@cs.wisc.edu for action in actions: 13327839Snilay@cs.wisc.edu case('${{action.ident}}(m_tbe_ptr, m_cache_entry_ptr, addr);') 13337839Snilay@cs.wisc.edu elif self.TBEType != None: 13347839Snilay@cs.wisc.edu for action in actions: 13357839Snilay@cs.wisc.edu case('${{action.ident}}(m_tbe_ptr, addr);') 13367839Snilay@cs.wisc.edu elif self.EntryType != None: 13377839Snilay@cs.wisc.edu for action in actions: 13387839Snilay@cs.wisc.edu case('${{action.ident}}(m_cache_entry_ptr, addr);') 13397839Snilay@cs.wisc.edu else: 13407839Snilay@cs.wisc.edu for action in actions: 13417839Snilay@cs.wisc.edu case('${{action.ident}}(addr);') 13426657Snate@binkert.org case('return TransitionResult_Valid;') 13436657Snate@binkert.org 13446657Snate@binkert.org case = str(case) 13456657Snate@binkert.org 13466657Snate@binkert.org # Look to see if this transition code is unique. 13476657Snate@binkert.org if case not in cases: 13486657Snate@binkert.org cases[case] = [] 13496657Snate@binkert.org 13506657Snate@binkert.org cases[case].append(case_string) 13516657Snate@binkert.org 13526657Snate@binkert.org # Walk through all of the unique code blocks and spit out the 13536657Snate@binkert.org # corresponding case statement elements 13546657Snate@binkert.org for case,transitions in cases.iteritems(): 13556657Snate@binkert.org # Iterative over all the multiple transitions that share 13566657Snate@binkert.org # the same code 13576657Snate@binkert.org for trans in transitions: 13586657Snate@binkert.org code(' case HASH_FUN($trans):') 135910305Snilay@cs.wisc.edu code(' $case\n') 13606657Snate@binkert.org 13616657Snate@binkert.org code(''' 13626657Snate@binkert.org default: 136310962SBrad.Beckmann@amd.com panic("Invalid transition\\n" 13648159SBrad.Beckmann@amd.com "%s time: %d addr: %s event: %s state: %s\\n", 13659465Snilay@cs.wisc.edu name(), curCycle(), addr, event, state); 13666657Snate@binkert.org } 136710305Snilay@cs.wisc.edu 13686657Snate@binkert.org return TransitionResult_Valid; 13696657Snate@binkert.org} 13706657Snate@binkert.org''') 13716657Snate@binkert.org code.write(path, "%s_Transitions.cc" % self.ident) 13726657Snate@binkert.org 13736657Snate@binkert.org 13746657Snate@binkert.org # ************************** 13756657Snate@binkert.org # ******* HTML Files ******* 13766657Snate@binkert.org # ************************** 13777007Snate@binkert.org def frameRef(self, click_href, click_target, over_href, over_num, text): 13786999Snate@binkert.org code = self.symtab.codeFormatter(fix_newlines=False) 13797007Snate@binkert.org code("""<A href=\"$click_href\" target=\"$click_target\" onmouseover=\" 13807007Snate@binkert.org if (parent.frames[$over_num].location != parent.location + '$over_href') { 13817007Snate@binkert.org parent.frames[$over_num].location='$over_href' 13827007Snate@binkert.org }\"> 13837007Snate@binkert.org ${{html.formatShorthand(text)}} 13847007Snate@binkert.org </A>""") 13856657Snate@binkert.org return str(code) 13866657Snate@binkert.org 13876657Snate@binkert.org def writeHTMLFiles(self, path): 13886657Snate@binkert.org # Create table with no row hilighted 13896657Snate@binkert.org self.printHTMLTransitions(path, None) 13906657Snate@binkert.org 13916657Snate@binkert.org # Generate transition tables 13926657Snate@binkert.org for state in self.states.itervalues(): 13936657Snate@binkert.org self.printHTMLTransitions(path, state) 13946657Snate@binkert.org 13956657Snate@binkert.org # Generate action descriptions 13966657Snate@binkert.org for action in self.actions.itervalues(): 13976657Snate@binkert.org name = "%s_action_%s.html" % (self.ident, action.ident) 13986657Snate@binkert.org code = html.createSymbol(action, "Action") 13996657Snate@binkert.org code.write(path, name) 14006657Snate@binkert.org 14016657Snate@binkert.org # Generate state descriptions 14026657Snate@binkert.org for state in self.states.itervalues(): 14036657Snate@binkert.org name = "%s_State_%s.html" % (self.ident, state.ident) 14046657Snate@binkert.org code = html.createSymbol(state, "State") 14056657Snate@binkert.org code.write(path, name) 14066657Snate@binkert.org 14076657Snate@binkert.org # Generate event descriptions 14086657Snate@binkert.org for event in self.events.itervalues(): 14096657Snate@binkert.org name = "%s_Event_%s.html" % (self.ident, event.ident) 14106657Snate@binkert.org code = html.createSymbol(event, "Event") 14116657Snate@binkert.org code.write(path, name) 14126657Snate@binkert.org 14136657Snate@binkert.org def printHTMLTransitions(self, path, active_state): 14146999Snate@binkert.org code = self.symtab.codeFormatter() 14156657Snate@binkert.org 14166657Snate@binkert.org code(''' 14177007Snate@binkert.org<HTML> 14187007Snate@binkert.org<BODY link="blue" vlink="blue"> 14196657Snate@binkert.org 14206657Snate@binkert.org<H1 align="center">${{html.formatShorthand(self.short)}}: 14216657Snate@binkert.org''') 14226657Snate@binkert.org code.indent() 14236657Snate@binkert.org for i,machine in enumerate(self.symtab.getAllType(StateMachine)): 14246657Snate@binkert.org mid = machine.ident 14256657Snate@binkert.org if i != 0: 14266657Snate@binkert.org extra = " - " 14276657Snate@binkert.org else: 14286657Snate@binkert.org extra = "" 14296657Snate@binkert.org if machine == self: 14306657Snate@binkert.org code('$extra$mid') 14316657Snate@binkert.org else: 14326657Snate@binkert.org code('$extra<A target="Table" href="${mid}_table.html">$mid</A>') 14336657Snate@binkert.org code.dedent() 14346657Snate@binkert.org 14356657Snate@binkert.org code(""" 14366657Snate@binkert.org</H1> 14376657Snate@binkert.org 14386657Snate@binkert.org<TABLE border=1> 14396657Snate@binkert.org<TR> 14406657Snate@binkert.org <TH> </TH> 14416657Snate@binkert.org""") 14426657Snate@binkert.org 14436657Snate@binkert.org for event in self.events.itervalues(): 14446657Snate@binkert.org href = "%s_Event_%s.html" % (self.ident, event.ident) 14456657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", event.short) 14466657Snate@binkert.org code('<TH bgcolor=white>$ref</TH>') 14476657Snate@binkert.org 14486657Snate@binkert.org code('</TR>') 14496657Snate@binkert.org # -- Body of table 14506657Snate@binkert.org for state in self.states.itervalues(): 14516657Snate@binkert.org # -- Each row 14526657Snate@binkert.org if state == active_state: 14536657Snate@binkert.org color = "yellow" 14546657Snate@binkert.org else: 14556657Snate@binkert.org color = "white" 14566657Snate@binkert.org 14576657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, state.ident) 14586657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, state.ident) 14596657Snate@binkert.org text = html.formatShorthand(state.short) 14606657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", state.short) 14616657Snate@binkert.org code(''' 14626657Snate@binkert.org<TR> 14636657Snate@binkert.org <TH bgcolor=$color>$ref</TH> 14646657Snate@binkert.org''') 14656657Snate@binkert.org 14666657Snate@binkert.org # -- One column for each event 14676657Snate@binkert.org for event in self.events.itervalues(): 14686657Snate@binkert.org trans = self.table.get((state,event), None) 14696657Snate@binkert.org if trans is None: 14706657Snate@binkert.org # This is the no transition case 14716657Snate@binkert.org if state == active_state: 14726657Snate@binkert.org color = "#C0C000" 14736657Snate@binkert.org else: 14746657Snate@binkert.org color = "lightgrey" 14756657Snate@binkert.org 14766657Snate@binkert.org code('<TD bgcolor=$color> </TD>') 14776657Snate@binkert.org continue 14786657Snate@binkert.org 14796657Snate@binkert.org next = trans.nextState 14806657Snate@binkert.org stall_action = False 14816657Snate@binkert.org 14826657Snate@binkert.org # -- Get the actions 14836657Snate@binkert.org for action in trans.actions: 14846657Snate@binkert.org if action.ident == "z_stall" or \ 14856657Snate@binkert.org action.ident == "zz_recycleMandatoryQueue": 14866657Snate@binkert.org stall_action = True 14876657Snate@binkert.org 14886657Snate@binkert.org # -- Print out "actions/next-state" 14896657Snate@binkert.org if stall_action: 14906657Snate@binkert.org if state == active_state: 14916657Snate@binkert.org color = "#C0C000" 14926657Snate@binkert.org else: 14936657Snate@binkert.org color = "lightgrey" 14946657Snate@binkert.org 14956657Snate@binkert.org elif active_state and next.ident == active_state.ident: 14966657Snate@binkert.org color = "aqua" 14976657Snate@binkert.org elif state == active_state: 14986657Snate@binkert.org color = "yellow" 14996657Snate@binkert.org else: 15006657Snate@binkert.org color = "white" 15016657Snate@binkert.org 15026657Snate@binkert.org code('<TD bgcolor=$color>') 15036657Snate@binkert.org for action in trans.actions: 15046657Snate@binkert.org href = "%s_action_%s.html" % (self.ident, action.ident) 15056657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", 15066657Snate@binkert.org action.short) 15077007Snate@binkert.org code(' $ref') 15086657Snate@binkert.org if next != state: 15096657Snate@binkert.org if trans.actions: 15106657Snate@binkert.org code('/') 15116657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, next.ident) 15126657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, next.ident) 15136657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", next.short) 15146657Snate@binkert.org code("$ref") 15157007Snate@binkert.org code("</TD>") 15166657Snate@binkert.org 15176657Snate@binkert.org # -- Each row 15186657Snate@binkert.org if state == active_state: 15196657Snate@binkert.org color = "yellow" 15206657Snate@binkert.org else: 15216657Snate@binkert.org color = "white" 15226657Snate@binkert.org 15236657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, state.ident) 15246657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, state.ident) 15256657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", state.short) 15266657Snate@binkert.org code(''' 15276657Snate@binkert.org <TH bgcolor=$color>$ref</TH> 15286657Snate@binkert.org</TR> 15296657Snate@binkert.org''') 15306657Snate@binkert.org code(''' 153110917Sbrandon.potter@amd.com<!- Column footer-> 15326657Snate@binkert.org<TR> 15336657Snate@binkert.org <TH> </TH> 15346657Snate@binkert.org''') 15356657Snate@binkert.org 15366657Snate@binkert.org for event in self.events.itervalues(): 15376657Snate@binkert.org href = "%s_Event_%s.html" % (self.ident, event.ident) 15386657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", event.short) 15396657Snate@binkert.org code('<TH bgcolor=white>$ref</TH>') 15406657Snate@binkert.org code(''' 15416657Snate@binkert.org</TR> 15426657Snate@binkert.org</TABLE> 15436657Snate@binkert.org</BODY></HTML> 15446657Snate@binkert.org''') 15456657Snate@binkert.org 15466657Snate@binkert.org 15476657Snate@binkert.org if active_state: 15486657Snate@binkert.org name = "%s_table_%s.html" % (self.ident, active_state.ident) 15496657Snate@binkert.org else: 15506657Snate@binkert.org name = "%s_table.html" % self.ident 15516657Snate@binkert.org code.write(path, name) 15526657Snate@binkert.org 15536657Snate@binkert.org__all__ = [ "StateMachine" ] 1554