StateMachine.py revision 9745
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 36657Snate@binkert.org# All rights reserved. 46657Snate@binkert.org# 56657Snate@binkert.org# Redistribution and use in source and binary forms, with or without 66657Snate@binkert.org# modification, are permitted provided that the following conditions are 76657Snate@binkert.org# met: redistributions of source code must retain the above copyright 86657Snate@binkert.org# notice, this list of conditions and the following disclaimer; 96657Snate@binkert.org# redistributions in binary form must reproduce the above copyright 106657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 116657Snate@binkert.org# documentation and/or other materials provided with the distribution; 126657Snate@binkert.org# neither the name of the copyright holders nor the names of its 136657Snate@binkert.org# contributors may be used to endorse or promote products derived from 146657Snate@binkert.org# this software without specific prior written permission. 156657Snate@binkert.org# 166657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276657Snate@binkert.org 286999Snate@binkert.orgfrom m5.util import orderdict 296657Snate@binkert.org 306657Snate@binkert.orgfrom slicc.symbols.Symbol import Symbol 316657Snate@binkert.orgfrom slicc.symbols.Var import Var 326657Snate@binkert.orgimport slicc.generate.html as html 338189SLisa.Hsu@amd.comimport re 346657Snate@binkert.org 359499Snilay@cs.wisc.edupython_class_map = { 369499Snilay@cs.wisc.edu "int": "Int", 379364Snilay@cs.wisc.edu "uint32_t" : "UInt32", 387055Snate@binkert.org "std::string": "String", 396882SBrad.Beckmann@amd.com "bool": "Bool", 406882SBrad.Beckmann@amd.com "CacheMemory": "RubyCache", 418191SLisa.Hsu@amd.com "WireBuffer": "RubyWireBuffer", 426882SBrad.Beckmann@amd.com "Sequencer": "RubySequencer", 436882SBrad.Beckmann@amd.com "DirectoryMemory": "RubyDirectoryMemory", 449102SNuwan.Jayasena@amd.com "MemoryControl": "MemoryControl", 459366Snilay@cs.wisc.edu "DMASequencer": "DMASequencer", 469499Snilay@cs.wisc.edu "Prefetcher":"Prefetcher", 479499Snilay@cs.wisc.edu "Cycles":"Cycles", 489499Snilay@cs.wisc.edu } 496882SBrad.Beckmann@amd.com 506657Snate@binkert.orgclass StateMachine(Symbol): 516657Snate@binkert.org def __init__(self, symtab, ident, location, pairs, config_parameters): 526657Snate@binkert.org super(StateMachine, self).__init__(symtab, ident, location, pairs) 536657Snate@binkert.org self.table = None 546657Snate@binkert.org self.config_parameters = config_parameters 559366Snilay@cs.wisc.edu self.prefetchers = [] 567839Snilay@cs.wisc.edu 576657Snate@binkert.org for param in config_parameters: 586882SBrad.Beckmann@amd.com if param.pointer: 596882SBrad.Beckmann@amd.com var = Var(symtab, param.name, location, param.type_ast.type, 606882SBrad.Beckmann@amd.com "(*m_%s_ptr)" % param.name, {}, self) 616882SBrad.Beckmann@amd.com else: 626882SBrad.Beckmann@amd.com var = Var(symtab, param.name, location, param.type_ast.type, 636882SBrad.Beckmann@amd.com "m_%s" % param.name, {}, self) 646657Snate@binkert.org self.symtab.registerSym(param.name, var) 659366Snilay@cs.wisc.edu if str(param.type_ast.type) == "Prefetcher": 669366Snilay@cs.wisc.edu self.prefetchers.append(var) 676657Snate@binkert.org 686657Snate@binkert.org self.states = orderdict() 696657Snate@binkert.org self.events = orderdict() 706657Snate@binkert.org self.actions = orderdict() 719104Shestness@cs.utexas.edu self.request_types = orderdict() 726657Snate@binkert.org self.transitions = [] 736657Snate@binkert.org self.in_ports = [] 746657Snate@binkert.org self.functions = [] 756657Snate@binkert.org self.objects = [] 767839Snilay@cs.wisc.edu self.TBEType = None 777839Snilay@cs.wisc.edu self.EntryType = None 786657Snate@binkert.org 796657Snate@binkert.org def __repr__(self): 806657Snate@binkert.org return "[StateMachine: %s]" % self.ident 816657Snate@binkert.org 826657Snate@binkert.org def addState(self, state): 836657Snate@binkert.org assert self.table is None 846657Snate@binkert.org self.states[state.ident] = state 856657Snate@binkert.org 866657Snate@binkert.org def addEvent(self, event): 876657Snate@binkert.org assert self.table is None 886657Snate@binkert.org self.events[event.ident] = event 896657Snate@binkert.org 906657Snate@binkert.org def addAction(self, action): 916657Snate@binkert.org assert self.table is None 926657Snate@binkert.org 936657Snate@binkert.org # Check for duplicate action 946657Snate@binkert.org for other in self.actions.itervalues(): 956657Snate@binkert.org if action.ident == other.ident: 966779SBrad.Beckmann@amd.com action.warning("Duplicate action definition: %s" % action.ident) 976657Snate@binkert.org action.error("Duplicate action definition: %s" % action.ident) 986657Snate@binkert.org if action.short == other.short: 996657Snate@binkert.org other.warning("Duplicate action shorthand: %s" % other.ident) 1006657Snate@binkert.org other.warning(" shorthand = %s" % other.short) 1016657Snate@binkert.org action.warning("Duplicate action shorthand: %s" % action.ident) 1026657Snate@binkert.org action.error(" shorthand = %s" % action.short) 1036657Snate@binkert.org 1046657Snate@binkert.org self.actions[action.ident] = action 1056657Snate@binkert.org 1069104Shestness@cs.utexas.edu def addRequestType(self, request_type): 1079104Shestness@cs.utexas.edu assert self.table is None 1089104Shestness@cs.utexas.edu self.request_types[request_type.ident] = request_type 1099104Shestness@cs.utexas.edu 1106657Snate@binkert.org def addTransition(self, trans): 1116657Snate@binkert.org assert self.table is None 1126657Snate@binkert.org self.transitions.append(trans) 1136657Snate@binkert.org 1146657Snate@binkert.org def addInPort(self, var): 1156657Snate@binkert.org self.in_ports.append(var) 1166657Snate@binkert.org 1176657Snate@binkert.org def addFunc(self, func): 1186657Snate@binkert.org # register func in the symbol table 1196657Snate@binkert.org self.symtab.registerSym(str(func), func) 1206657Snate@binkert.org self.functions.append(func) 1216657Snate@binkert.org 1226657Snate@binkert.org def addObject(self, obj): 1236657Snate@binkert.org self.objects.append(obj) 1246657Snate@binkert.org 1257839Snilay@cs.wisc.edu def addType(self, type): 1267839Snilay@cs.wisc.edu type_ident = '%s' % type.c_ident 1277839Snilay@cs.wisc.edu 1287839Snilay@cs.wisc.edu if type_ident == "%s_TBE" %self.ident: 1297839Snilay@cs.wisc.edu if self.TBEType != None: 1307839Snilay@cs.wisc.edu self.error("Multiple Transaction Buffer types in a " \ 1317839Snilay@cs.wisc.edu "single machine."); 1327839Snilay@cs.wisc.edu self.TBEType = type 1337839Snilay@cs.wisc.edu 1347839Snilay@cs.wisc.edu elif "interface" in type and "AbstractCacheEntry" == type["interface"]: 1357839Snilay@cs.wisc.edu if self.EntryType != None: 1367839Snilay@cs.wisc.edu self.error("Multiple AbstractCacheEntry types in a " \ 1377839Snilay@cs.wisc.edu "single machine."); 1387839Snilay@cs.wisc.edu self.EntryType = type 1397839Snilay@cs.wisc.edu 1406657Snate@binkert.org # Needs to be called before accessing the table 1416657Snate@binkert.org def buildTable(self): 1426657Snate@binkert.org assert self.table is None 1436657Snate@binkert.org 1446657Snate@binkert.org table = {} 1456657Snate@binkert.org 1466657Snate@binkert.org for trans in self.transitions: 1476657Snate@binkert.org # Track which actions we touch so we know if we use them 1486657Snate@binkert.org # all -- really this should be done for all symbols as 1496657Snate@binkert.org # part of the symbol table, then only trigger it for 1506657Snate@binkert.org # Actions, States, Events, etc. 1516657Snate@binkert.org 1526657Snate@binkert.org for action in trans.actions: 1536657Snate@binkert.org action.used = True 1546657Snate@binkert.org 1556657Snate@binkert.org index = (trans.state, trans.event) 1566657Snate@binkert.org if index in table: 1576657Snate@binkert.org table[index].warning("Duplicate transition: %s" % table[index]) 1586657Snate@binkert.org trans.error("Duplicate transition: %s" % trans) 1596657Snate@binkert.org table[index] = trans 1606657Snate@binkert.org 1616657Snate@binkert.org # Look at all actions to make sure we used them all 1626657Snate@binkert.org for action in self.actions.itervalues(): 1636657Snate@binkert.org if not action.used: 1646657Snate@binkert.org error_msg = "Unused action: %s" % action.ident 1656657Snate@binkert.org if "desc" in action: 1666657Snate@binkert.org error_msg += ", " + action.desc 1676657Snate@binkert.org action.warning(error_msg) 1686657Snate@binkert.org self.table = table 1696657Snate@binkert.org 1709219Spower.jg@gmail.com def writeCodeFiles(self, path, includes): 1716877Ssteve.reinhardt@amd.com self.printControllerPython(path) 1726657Snate@binkert.org self.printControllerHH(path) 1739219Spower.jg@gmail.com self.printControllerCC(path, includes) 1746657Snate@binkert.org self.printCSwitch(path) 1759219Spower.jg@gmail.com self.printCWakeup(path, includes) 1766657Snate@binkert.org 1776877Ssteve.reinhardt@amd.com def printControllerPython(self, path): 1786999Snate@binkert.org code = self.symtab.codeFormatter() 1796877Ssteve.reinhardt@amd.com ident = self.ident 1806877Ssteve.reinhardt@amd.com py_ident = "%s_Controller" % ident 1816877Ssteve.reinhardt@amd.com c_ident = "%s_Controller" % self.ident 1826877Ssteve.reinhardt@amd.com code(''' 1836877Ssteve.reinhardt@amd.comfrom m5.params import * 1846877Ssteve.reinhardt@amd.comfrom m5.SimObject import SimObject 1856877Ssteve.reinhardt@amd.comfrom Controller import RubyController 1866877Ssteve.reinhardt@amd.com 1876877Ssteve.reinhardt@amd.comclass $py_ident(RubyController): 1886877Ssteve.reinhardt@amd.com type = '$py_ident' 1899338SAndreas.Sandberg@arm.com cxx_header = 'mem/protocol/${c_ident}.hh' 1906877Ssteve.reinhardt@amd.com''') 1916877Ssteve.reinhardt@amd.com code.indent() 1926877Ssteve.reinhardt@amd.com for param in self.config_parameters: 1936877Ssteve.reinhardt@amd.com dflt_str = '' 1946877Ssteve.reinhardt@amd.com if param.default is not None: 1956877Ssteve.reinhardt@amd.com dflt_str = str(param.default) + ', ' 1966882SBrad.Beckmann@amd.com if python_class_map.has_key(param.type_ast.type.c_ident): 1976882SBrad.Beckmann@amd.com python_type = python_class_map[param.type_ast.type.c_ident] 1986882SBrad.Beckmann@amd.com code('${{param.name}} = Param.${{python_type}}(${dflt_str}"")') 1996882SBrad.Beckmann@amd.com else: 2006882SBrad.Beckmann@amd.com self.error("Unknown c++ to python class conversion for c++ " \ 2016882SBrad.Beckmann@amd.com "type: '%s'. Please update the python_class_map " \ 2026882SBrad.Beckmann@amd.com "in StateMachine.py", param.type_ast.type.c_ident) 2036877Ssteve.reinhardt@amd.com code.dedent() 2046877Ssteve.reinhardt@amd.com code.write(path, '%s.py' % py_ident) 2056877Ssteve.reinhardt@amd.com 2066877Ssteve.reinhardt@amd.com 2076657Snate@binkert.org def printControllerHH(self, path): 2086657Snate@binkert.org '''Output the method declarations for the class declaration''' 2096999Snate@binkert.org code = self.symtab.codeFormatter() 2106657Snate@binkert.org ident = self.ident 2116657Snate@binkert.org c_ident = "%s_Controller" % self.ident 2126657Snate@binkert.org 2136657Snate@binkert.org code(''' 2147007Snate@binkert.org/** \\file $c_ident.hh 2156657Snate@binkert.org * 2166657Snate@binkert.org * Auto generated C++ code started by $__file__:$__line__ 2176657Snate@binkert.org * Created by slicc definition of Module "${{self.short}}" 2186657Snate@binkert.org */ 2196657Snate@binkert.org 2207007Snate@binkert.org#ifndef __${ident}_CONTROLLER_HH__ 2217007Snate@binkert.org#define __${ident}_CONTROLLER_HH__ 2226657Snate@binkert.org 2237002Snate@binkert.org#include <iostream> 2247002Snate@binkert.org#include <sstream> 2257002Snate@binkert.org#include <string> 2267002Snate@binkert.org 2276657Snate@binkert.org#include "mem/protocol/TransitionResult.hh" 2286657Snate@binkert.org#include "mem/protocol/Types.hh" 2298229Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 2308229Snate@binkert.org#include "mem/ruby/common/Global.hh" 2318229Snate@binkert.org#include "mem/ruby/slicc_interface/AbstractController.hh" 2328229Snate@binkert.org#include "params/$c_ident.hh" 2336657Snate@binkert.org''') 2346657Snate@binkert.org 2356657Snate@binkert.org seen_types = set() 2369595Snilay@cs.wisc.edu has_peer = False 2376657Snate@binkert.org for var in self.objects: 2386793SBrad.Beckmann@amd.com if var.type.ident not in seen_types and not var.type.isPrimitive: 2396657Snate@binkert.org code('#include "mem/protocol/${{var.type.c_ident}}.hh"') 2409595Snilay@cs.wisc.edu if "network" in var and "physical_network" in var: 2419595Snilay@cs.wisc.edu has_peer = True 2426657Snate@binkert.org seen_types.add(var.type.ident) 2436657Snate@binkert.org 2446657Snate@binkert.org # for adding information to the protocol debug trace 2456657Snate@binkert.org code(''' 2467002Snate@binkert.orgextern std::stringstream ${ident}_transitionComment; 2476657Snate@binkert.org 2487007Snate@binkert.orgclass $c_ident : public AbstractController 2497007Snate@binkert.org{ 2509271Snilay@cs.wisc.edu public: 2516877Ssteve.reinhardt@amd.com typedef ${c_ident}Params Params; 2526877Ssteve.reinhardt@amd.com $c_ident(const Params *p); 2536657Snate@binkert.org static int getNumControllers(); 2546877Ssteve.reinhardt@amd.com void init(); 2556657Snate@binkert.org MessageBuffer* getMandatoryQueue() const; 2566657Snate@binkert.org const int & getVersion() const; 2577002Snate@binkert.org const std::string toString() const; 2587002Snate@binkert.org const std::string getName() const; 2596881SBrad.Beckmann@amd.com void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; } 2609745Snilay@cs.wisc.edu 2617002Snate@binkert.org void print(std::ostream& out) const; 2626657Snate@binkert.org void wakeup(); 2637002Snate@binkert.org void printStats(std::ostream& out) const; 2646902SBrad.Beckmann@amd.com void clearStats(); 2659745Snilay@cs.wisc.edu void regStats(); 2669745Snilay@cs.wisc.edu void collateStats(); 2679745Snilay@cs.wisc.edu 2686863Sdrh5@cs.wisc.edu void blockOnQueue(Address addr, MessageBuffer* port); 2696863Sdrh5@cs.wisc.edu void unblock(Address addr); 2708683Snilay@cs.wisc.edu void recordCacheTrace(int cntrl, CacheRecorder* tr); 2718683Snilay@cs.wisc.edu Sequencer* getSequencer() const; 2727007Snate@binkert.org 2739302Snilay@cs.wisc.edu bool functionalReadBuffers(PacketPtr&); 2749302Snilay@cs.wisc.edu uint32_t functionalWriteBuffers(PacketPtr&); 2759302Snilay@cs.wisc.edu 2769745Snilay@cs.wisc.edu void countTransition(${ident}_State state, ${ident}_Event event); 2779745Snilay@cs.wisc.edu void possibleTransition(${ident}_State state, ${ident}_Event event); 2789745Snilay@cs.wisc.edu uint64 getEventCount(${ident}_Event event); 2799745Snilay@cs.wisc.edu bool isPossible(${ident}_State state, ${ident}_Event event); 2809745Snilay@cs.wisc.edu uint64 getTransitionCount(${ident}_State state, ${ident}_Event event); 2819745Snilay@cs.wisc.edu 2826657Snate@binkert.orgprivate: 2836657Snate@binkert.org''') 2846657Snate@binkert.org 2856657Snate@binkert.org code.indent() 2866657Snate@binkert.org # added by SS 2876657Snate@binkert.org for param in self.config_parameters: 2886882SBrad.Beckmann@amd.com if param.pointer: 2896882SBrad.Beckmann@amd.com code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;') 2906882SBrad.Beckmann@amd.com else: 2916882SBrad.Beckmann@amd.com code('${{param.type_ast.type}} m_${{param.ident}};') 2926657Snate@binkert.org 2936657Snate@binkert.org code(''' 2947007Snate@binkert.orgTransitionResult doTransition(${ident}_Event event, 2957839Snilay@cs.wisc.edu''') 2967839Snilay@cs.wisc.edu 2977839Snilay@cs.wisc.edu if self.EntryType != None: 2987839Snilay@cs.wisc.edu code(''' 2997839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}* m_cache_entry_ptr, 3007839Snilay@cs.wisc.edu''') 3017839Snilay@cs.wisc.edu if self.TBEType != None: 3027839Snilay@cs.wisc.edu code(''' 3037839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}* m_tbe_ptr, 3047839Snilay@cs.wisc.edu''') 3057839Snilay@cs.wisc.edu 3067839Snilay@cs.wisc.edu code(''' 3077007Snate@binkert.org const Address& addr); 3087007Snate@binkert.org 3097007Snate@binkert.orgTransitionResult doTransitionWorker(${ident}_Event event, 3107007Snate@binkert.org ${ident}_State state, 3117007Snate@binkert.org ${ident}_State& next_state, 3127839Snilay@cs.wisc.edu''') 3137839Snilay@cs.wisc.edu 3147839Snilay@cs.wisc.edu if self.TBEType != None: 3157839Snilay@cs.wisc.edu code(''' 3167839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}*& m_tbe_ptr, 3177839Snilay@cs.wisc.edu''') 3187839Snilay@cs.wisc.edu if self.EntryType != None: 3197839Snilay@cs.wisc.edu code(''' 3207839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, 3217839Snilay@cs.wisc.edu''') 3227839Snilay@cs.wisc.edu 3237839Snilay@cs.wisc.edu code(''' 3247007Snate@binkert.org const Address& addr); 3257007Snate@binkert.org 3269745Snilay@cs.wisc.eduint m_counters[${ident}_State_NUM][${ident}_Event_NUM]; 3279745Snilay@cs.wisc.eduint m_event_counters[${ident}_Event_NUM]; 3289745Snilay@cs.wisc.edubool m_possible[${ident}_State_NUM][${ident}_Event_NUM]; 3299745Snilay@cs.wisc.edu 3309745Snilay@cs.wisc.edustatic std::vector<Stats::Vector *> eventVec; 3319745Snilay@cs.wisc.edustatic std::vector<std::vector<Stats::Vector *> > transVec; 3326657Snate@binkert.orgstatic int m_num_controllers; 3337007Snate@binkert.org 3346657Snate@binkert.org// Internal functions 3356657Snate@binkert.org''') 3366657Snate@binkert.org 3376657Snate@binkert.org for func in self.functions: 3386657Snate@binkert.org proto = func.prototype 3396657Snate@binkert.org if proto: 3406657Snate@binkert.org code('$proto') 3416657Snate@binkert.org 3429595Snilay@cs.wisc.edu if has_peer: 3439595Snilay@cs.wisc.edu code('void getQueuesFromPeer(AbstractController *);') 3447839Snilay@cs.wisc.edu if self.EntryType != None: 3457839Snilay@cs.wisc.edu code(''' 3467839Snilay@cs.wisc.edu 3477839Snilay@cs.wisc.edu// Set and Reset for cache_entry variable 3487839Snilay@cs.wisc.eduvoid set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry); 3497839Snilay@cs.wisc.eduvoid unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr); 3507839Snilay@cs.wisc.edu''') 3517839Snilay@cs.wisc.edu 3527839Snilay@cs.wisc.edu if self.TBEType != None: 3537839Snilay@cs.wisc.edu code(''' 3547839Snilay@cs.wisc.edu 3557839Snilay@cs.wisc.edu// Set and Reset for tbe variable 3567839Snilay@cs.wisc.eduvoid set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${ident}_TBE* m_new_tbe); 3577839Snilay@cs.wisc.eduvoid unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr); 3587839Snilay@cs.wisc.edu''') 3597839Snilay@cs.wisc.edu 3606657Snate@binkert.org code(''' 3616657Snate@binkert.org 3626657Snate@binkert.org// Actions 3636657Snate@binkert.org''') 3647839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 3657839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 3667839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 3677839Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);') 3687839Snilay@cs.wisc.edu elif self.TBEType != None: 3697839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 3707839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 3717839Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, const Address& addr);') 3727839Snilay@cs.wisc.edu elif self.EntryType != None: 3737839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 3747839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 3757839Snilay@cs.wisc.edu code('void ${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);') 3767839Snilay@cs.wisc.edu else: 3777839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 3787839Snilay@cs.wisc.edu code('/** \\brief ${{action.desc}} */') 3797839Snilay@cs.wisc.edu code('void ${{action.ident}}(const Address& addr);') 3806657Snate@binkert.org 3816657Snate@binkert.org # the controller internal variables 3826657Snate@binkert.org code(''' 3836657Snate@binkert.org 3847007Snate@binkert.org// Objects 3856657Snate@binkert.org''') 3866657Snate@binkert.org for var in self.objects: 3879273Snilay@cs.wisc.edu th = var.get("template", "") 3886657Snate@binkert.org code('${{var.type.c_ident}}$th* m_${{var.c_ident}}_ptr;') 3896657Snate@binkert.org 3906657Snate@binkert.org code.dedent() 3916657Snate@binkert.org code('};') 3927007Snate@binkert.org code('#endif // __${ident}_CONTROLLER_H__') 3936657Snate@binkert.org code.write(path, '%s.hh' % c_ident) 3946657Snate@binkert.org 3959219Spower.jg@gmail.com def printControllerCC(self, path, includes): 3966657Snate@binkert.org '''Output the actions for performing the actions''' 3976657Snate@binkert.org 3986999Snate@binkert.org code = self.symtab.codeFormatter() 3996657Snate@binkert.org ident = self.ident 4006657Snate@binkert.org c_ident = "%s_Controller" % self.ident 4019595Snilay@cs.wisc.edu has_peer = False 4026657Snate@binkert.org 4036657Snate@binkert.org code(''' 4047007Snate@binkert.org/** \\file $c_ident.cc 4056657Snate@binkert.org * 4066657Snate@binkert.org * Auto generated C++ code started by $__file__:$__line__ 4076657Snate@binkert.org * Created by slicc definition of Module "${{self.short}}" 4086657Snate@binkert.org */ 4096657Snate@binkert.org 4108946Sandreas.hansson@arm.com#include <sys/types.h> 4118946Sandreas.hansson@arm.com#include <unistd.h> 4128946Sandreas.hansson@arm.com 4137832Snate@binkert.org#include <cassert> 4147002Snate@binkert.org#include <sstream> 4157002Snate@binkert.org#include <string> 4167002Snate@binkert.org 4178641Snate@binkert.org#include "base/compiler.hh" 4187056Snate@binkert.org#include "base/cprintf.hh" 4198232Snate@binkert.org#include "debug/RubyGenerated.hh" 4208232Snate@binkert.org#include "debug/RubySlicc.hh" 4216657Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 4228229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 4236657Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 4246657Snate@binkert.org#include "mem/protocol/Types.hh" 4257056Snate@binkert.org#include "mem/ruby/common/Global.hh" 4266657Snate@binkert.org#include "mem/ruby/system/System.hh" 4279219Spower.jg@gmail.com''') 4289219Spower.jg@gmail.com for include_path in includes: 4299219Spower.jg@gmail.com code('#include "${{include_path}}"') 4309219Spower.jg@gmail.com 4319219Spower.jg@gmail.com code(''' 4327002Snate@binkert.org 4337002Snate@binkert.orgusing namespace std; 4346657Snate@binkert.org''') 4356657Snate@binkert.org 4366657Snate@binkert.org # include object classes 4376657Snate@binkert.org seen_types = set() 4386657Snate@binkert.org for var in self.objects: 4396793SBrad.Beckmann@amd.com if var.type.ident not in seen_types and not var.type.isPrimitive: 4406657Snate@binkert.org code('#include "mem/protocol/${{var.type.c_ident}}.hh"') 4416657Snate@binkert.org seen_types.add(var.type.ident) 4426657Snate@binkert.org 4436657Snate@binkert.org code(''' 4446877Ssteve.reinhardt@amd.com$c_ident * 4456877Ssteve.reinhardt@amd.com${c_ident}Params::create() 4466877Ssteve.reinhardt@amd.com{ 4476877Ssteve.reinhardt@amd.com return new $c_ident(this); 4486877Ssteve.reinhardt@amd.com} 4496877Ssteve.reinhardt@amd.com 4506657Snate@binkert.orgint $c_ident::m_num_controllers = 0; 4519745Snilay@cs.wisc.edustd::vector<Stats::Vector *> $c_ident::eventVec; 4529745Snilay@cs.wisc.edustd::vector<std::vector<Stats::Vector *> > $c_ident::transVec; 4536657Snate@binkert.org 4547007Snate@binkert.org// for adding information to the protocol debug trace 4556657Snate@binkert.orgstringstream ${ident}_transitionComment; 4566657Snate@binkert.org#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str) 4577007Snate@binkert.org 4586657Snate@binkert.org/** \\brief constructor */ 4596877Ssteve.reinhardt@amd.com$c_ident::$c_ident(const Params *p) 4606877Ssteve.reinhardt@amd.com : AbstractController(p) 4616657Snate@binkert.org{ 4628532SLisa.Hsu@amd.com m_name = "${ident}"; 4636657Snate@binkert.org''') 4647567SBrad.Beckmann@amd.com # 4657567SBrad.Beckmann@amd.com # max_port_rank is used to size vectors and thus should be one plus the 4667567SBrad.Beckmann@amd.com # largest port rank 4677567SBrad.Beckmann@amd.com # 4687567SBrad.Beckmann@amd.com max_port_rank = self.in_ports[0].pairs["max_port_rank"] + 1 4697567SBrad.Beckmann@amd.com code(' m_max_in_port_rank = $max_port_rank;') 4706657Snate@binkert.org code.indent() 4716882SBrad.Beckmann@amd.com 4726882SBrad.Beckmann@amd.com # 4736882SBrad.Beckmann@amd.com # After initializing the universal machine parameters, initialize the 4746882SBrad.Beckmann@amd.com # this machines config parameters. Also detemine if these configuration 4756882SBrad.Beckmann@amd.com # params include a sequencer. This information will be used later for 4766882SBrad.Beckmann@amd.com # contecting the sequencer back to the L1 cache controller. 4776882SBrad.Beckmann@amd.com # 4788189SLisa.Hsu@amd.com contains_dma_sequencer = False 4798189SLisa.Hsu@amd.com sequencers = [] 4806877Ssteve.reinhardt@amd.com for param in self.config_parameters: 4818189SLisa.Hsu@amd.com if param.name == "dma_sequencer": 4828189SLisa.Hsu@amd.com contains_dma_sequencer = True 4838189SLisa.Hsu@amd.com elif re.compile("sequencer").search(param.name): 4848189SLisa.Hsu@amd.com sequencers.append(param.name) 4856882SBrad.Beckmann@amd.com if param.pointer: 4866882SBrad.Beckmann@amd.com code('m_${{param.name}}_ptr = p->${{param.name}};') 4876882SBrad.Beckmann@amd.com else: 4886882SBrad.Beckmann@amd.com code('m_${{param.name}} = p->${{param.name}};') 4896882SBrad.Beckmann@amd.com 4906882SBrad.Beckmann@amd.com # 4916882SBrad.Beckmann@amd.com # For the l1 cache controller, add the special atomic support which 4926882SBrad.Beckmann@amd.com # includes passing the sequencer a pointer to the controller. 4936882SBrad.Beckmann@amd.com # 4949597Snilay@cs.wisc.edu for seq in sequencers: 4959597Snilay@cs.wisc.edu code(''' 4968938SLisa.Hsu@amd.comm_${{seq}}_ptr->setController(this); 4978938SLisa.Hsu@amd.com ''') 4988938SLisa.Hsu@amd.com 4996888SBrad.Beckmann@amd.com # 5006888SBrad.Beckmann@amd.com # For the DMA controller, pass the sequencer a pointer to the 5016888SBrad.Beckmann@amd.com # controller. 5026888SBrad.Beckmann@amd.com # 5036888SBrad.Beckmann@amd.com if self.ident == "DMA": 5048189SLisa.Hsu@amd.com if not contains_dma_sequencer: 5056888SBrad.Beckmann@amd.com self.error("The DMA controller must include the sequencer " \ 5066888SBrad.Beckmann@amd.com "configuration parameter") 5076657Snate@binkert.org 5086888SBrad.Beckmann@amd.com code(''' 5096888SBrad.Beckmann@amd.comm_dma_sequencer_ptr->setController(this); 5106888SBrad.Beckmann@amd.com''') 5116888SBrad.Beckmann@amd.com 5126657Snate@binkert.org code('m_num_controllers++;') 5136657Snate@binkert.org for var in self.objects: 5146657Snate@binkert.org if var.ident.find("mandatoryQueue") >= 0: 5159508Snilay@cs.wisc.edu code(''' 5169508Snilay@cs.wisc.edum_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 5179508Snilay@cs.wisc.edum_${{var.c_ident}}_ptr->setReceiver(this); 5189508Snilay@cs.wisc.edu''') 5199595Snilay@cs.wisc.edu else: 5209595Snilay@cs.wisc.edu if "network" in var and "physical_network" in var and \ 5219595Snilay@cs.wisc.edu var["network"] == "To": 5229595Snilay@cs.wisc.edu has_peer = True 5239595Snilay@cs.wisc.edu code(''' 5249595Snilay@cs.wisc.edum_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 5259595Snilay@cs.wisc.edupeerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr; 5269595Snilay@cs.wisc.edum_${{var.c_ident}}_ptr->setSender(this); 5279595Snilay@cs.wisc.edu''') 5286657Snate@binkert.org 5299595Snilay@cs.wisc.edu code(''' 5309595Snilay@cs.wisc.eduif (p->peer != NULL) 5319595Snilay@cs.wisc.edu connectWithPeer(p->peer); 5329745Snilay@cs.wisc.edu 5339745Snilay@cs.wisc.edufor (int state = 0; state < ${ident}_State_NUM; state++) { 5349745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 5359745Snilay@cs.wisc.edu m_possible[state][event] = false; 5369745Snilay@cs.wisc.edu m_counters[state][event] = 0; 5379745Snilay@cs.wisc.edu } 5389745Snilay@cs.wisc.edu} 5399745Snilay@cs.wisc.edufor (int event = 0; event < ${ident}_Event_NUM; event++) { 5409745Snilay@cs.wisc.edu m_event_counters[event] = 0; 5419745Snilay@cs.wisc.edu} 5429595Snilay@cs.wisc.edu''') 5436657Snate@binkert.org code.dedent() 5446657Snate@binkert.org code(''' 5456657Snate@binkert.org} 5466657Snate@binkert.org 5477007Snate@binkert.orgvoid 5487007Snate@binkert.org$c_ident::init() 5496657Snate@binkert.org{ 5509745Snilay@cs.wisc.edu MachineType machine_type = string_to_MachineType("${{var.machine.ident}}"); 5519745Snilay@cs.wisc.edu int base = MachineType_base_number(machine_type); 5527007Snate@binkert.org 5536657Snate@binkert.org m_machineID.type = MachineType_${ident}; 5546657Snate@binkert.org m_machineID.num = m_version; 5556657Snate@binkert.org 5567007Snate@binkert.org // initialize objects 5577007Snate@binkert.org 5586657Snate@binkert.org''') 5596657Snate@binkert.org 5606657Snate@binkert.org code.indent() 5616657Snate@binkert.org for var in self.objects: 5626657Snate@binkert.org vtype = var.type 5636657Snate@binkert.org vid = "m_%s_ptr" % var.c_ident 5646657Snate@binkert.org if "network" not in var: 5656657Snate@binkert.org # Not a network port object 5666657Snate@binkert.org if "primitive" in vtype: 5676657Snate@binkert.org code('$vid = new ${{vtype.c_ident}};') 5686657Snate@binkert.org if "default" in var: 5696657Snate@binkert.org code('(*$vid) = ${{var["default"]}};') 5706657Snate@binkert.org else: 5716657Snate@binkert.org # Normal Object 5729595Snilay@cs.wisc.edu if var.ident.find("mandatoryQueue") < 0: 5739273Snilay@cs.wisc.edu th = var.get("template", "") 5746657Snate@binkert.org expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 5756657Snate@binkert.org args = "" 5766657Snate@binkert.org if "non_obj" not in vtype and not vtype.isEnumeration: 5779364Snilay@cs.wisc.edu args = var.get("constructor", "") 5787007Snate@binkert.org code('$expr($args);') 5796657Snate@binkert.org 5806657Snate@binkert.org code('assert($vid != NULL);') 5816657Snate@binkert.org 5826657Snate@binkert.org if "default" in var: 5837007Snate@binkert.org code('*$vid = ${{var["default"]}}; // Object default') 5846657Snate@binkert.org elif "default" in vtype: 5857007Snate@binkert.org comment = "Type %s default" % vtype.ident 5867007Snate@binkert.org code('*$vid = ${{vtype["default"]}}; // $comment') 5876657Snate@binkert.org 5886657Snate@binkert.org # Set ordering 5899508Snilay@cs.wisc.edu if "ordered" in var: 5906657Snate@binkert.org # A buffer 5916657Snate@binkert.org code('$vid->setOrdering(${{var["ordered"]}});') 5926657Snate@binkert.org 5936657Snate@binkert.org # Set randomization 5946657Snate@binkert.org if "random" in var: 5956657Snate@binkert.org # A buffer 5966657Snate@binkert.org code('$vid->setRandomization(${{var["random"]}});') 5976657Snate@binkert.org 5986657Snate@binkert.org # Set Priority 5999508Snilay@cs.wisc.edu if vtype.isBuffer and "rank" in var: 6006657Snate@binkert.org code('$vid->setPriority(${{var["rank"]}});') 6017566SBrad.Beckmann@amd.com 6029508Snilay@cs.wisc.edu # Set sender and receiver for trigger queue 6039508Snilay@cs.wisc.edu if var.ident.find("triggerQueue") >= 0: 6049508Snilay@cs.wisc.edu code('$vid->setSender(this);') 6059508Snilay@cs.wisc.edu code('$vid->setReceiver(this);') 6069508Snilay@cs.wisc.edu elif vtype.c_ident == "TimerTable": 6079508Snilay@cs.wisc.edu code('$vid->setClockObj(this);') 6089604Snilay@cs.wisc.edu elif var.ident.find("optionalQueue") >= 0: 6099604Snilay@cs.wisc.edu code('$vid->setSender(this);') 6109604Snilay@cs.wisc.edu code('$vid->setReceiver(this);') 6119508Snilay@cs.wisc.edu 6126657Snate@binkert.org else: 6136657Snate@binkert.org # Network port object 6146657Snate@binkert.org network = var["network"] 6156657Snate@binkert.org ordered = var["ordered"] 6166657Snate@binkert.org 6179595Snilay@cs.wisc.edu if "virtual_network" in var: 6189595Snilay@cs.wisc.edu vnet = var["virtual_network"] 6199595Snilay@cs.wisc.edu vnet_type = var["vnet_type"] 6209595Snilay@cs.wisc.edu 6219595Snilay@cs.wisc.edu assert var.machine is not None 6229595Snilay@cs.wisc.edu code(''' 6238308Stushar@csail.mit.edu$vid = m_net_ptr->get${network}NetQueue(m_version + base, $ordered, $vnet, "$vnet_type"); 6249595Snilay@cs.wisc.eduassert($vid != NULL); 6256657Snate@binkert.org''') 6266657Snate@binkert.org 6279595Snilay@cs.wisc.edu # Set the end 6289595Snilay@cs.wisc.edu if network == "To": 6299595Snilay@cs.wisc.edu code('$vid->setSender(this);') 6309595Snilay@cs.wisc.edu else: 6319595Snilay@cs.wisc.edu code('$vid->setReceiver(this);') 6329508Snilay@cs.wisc.edu 6336657Snate@binkert.org # Set ordering 6346657Snate@binkert.org if "ordered" in var: 6356657Snate@binkert.org # A buffer 6366657Snate@binkert.org code('$vid->setOrdering(${{var["ordered"]}});') 6376657Snate@binkert.org 6386657Snate@binkert.org # Set randomization 6396657Snate@binkert.org if "random" in var: 6406657Snate@binkert.org # A buffer 6418187SLisa.Hsu@amd.com code('$vid->setRandomization(${{var["random"]}});') 6426657Snate@binkert.org 6436657Snate@binkert.org # Set Priority 6446657Snate@binkert.org if "rank" in var: 6456657Snate@binkert.org code('$vid->setPriority(${{var["rank"]}})') 6466657Snate@binkert.org 6476657Snate@binkert.org # Set buffer size 6486657Snate@binkert.org if vtype.isBuffer: 6496657Snate@binkert.org code(''' 6506657Snate@binkert.orgif (m_buffer_size > 0) { 6517454Snate@binkert.org $vid->resize(m_buffer_size); 6526657Snate@binkert.org} 6536657Snate@binkert.org''') 6546657Snate@binkert.org 6556657Snate@binkert.org # set description (may be overriden later by port def) 6567007Snate@binkert.org code(''' 6577056Snate@binkert.org$vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.c_ident}}]"); 6587007Snate@binkert.org 6597007Snate@binkert.org''') 6606657Snate@binkert.org 6617566SBrad.Beckmann@amd.com if vtype.isBuffer: 6627566SBrad.Beckmann@amd.com if "recycle_latency" in var: 6639499Snilay@cs.wisc.edu code('$vid->setRecycleLatency( ' \ 6649499Snilay@cs.wisc.edu 'Cycles(${{var["recycle_latency"]}}));') 6657566SBrad.Beckmann@amd.com else: 6667566SBrad.Beckmann@amd.com code('$vid->setRecycleLatency(m_recycle_latency);') 6677566SBrad.Beckmann@amd.com 6689366Snilay@cs.wisc.edu # Set the prefetchers 6699366Snilay@cs.wisc.edu code() 6709366Snilay@cs.wisc.edu for prefetcher in self.prefetchers: 6719366Snilay@cs.wisc.edu code('${{prefetcher.code}}.setController(this);') 6727566SBrad.Beckmann@amd.com 6737672Snate@binkert.org code() 6746657Snate@binkert.org for port in self.in_ports: 6759465Snilay@cs.wisc.edu # Set the queue consumers 6766657Snate@binkert.org code('${{port.code}}.setConsumer(this);') 6779465Snilay@cs.wisc.edu # Set the queue descriptions 6787056Snate@binkert.org code('${{port.code}}.setDescription("[Version " + to_string(m_version) + ", $ident, $port]");') 6796657Snate@binkert.org 6806657Snate@binkert.org # Initialize the transition profiling 6817672Snate@binkert.org code() 6826657Snate@binkert.org for trans in self.transitions: 6836657Snate@binkert.org # Figure out if we stall 6846657Snate@binkert.org stall = False 6856657Snate@binkert.org for action in trans.actions: 6866657Snate@binkert.org if action.ident == "z_stall": 6876657Snate@binkert.org stall = True 6886657Snate@binkert.org 6896657Snate@binkert.org # Only possible if it is not a 'z' case 6906657Snate@binkert.org if not stall: 6916657Snate@binkert.org state = "%s_State_%s" % (self.ident, trans.state.ident) 6926657Snate@binkert.org event = "%s_Event_%s" % (self.ident, trans.event.ident) 6939745Snilay@cs.wisc.edu code('possibleTransition($state, $event);') 6946657Snate@binkert.org 6956657Snate@binkert.org code.dedent() 6969496Snilay@cs.wisc.edu code(''' 6979496Snilay@cs.wisc.edu AbstractController::init(); 6989496Snilay@cs.wisc.edu clearStats(); 6999496Snilay@cs.wisc.edu} 7009496Snilay@cs.wisc.edu''') 7016657Snate@binkert.org 7026657Snate@binkert.org has_mandatory_q = False 7036657Snate@binkert.org for port in self.in_ports: 7046657Snate@binkert.org if port.code.find("mandatoryQueue_ptr") >= 0: 7056657Snate@binkert.org has_mandatory_q = True 7066657Snate@binkert.org 7076657Snate@binkert.org if has_mandatory_q: 7086657Snate@binkert.org mq_ident = "m_%s_mandatoryQueue_ptr" % self.ident 7096657Snate@binkert.org else: 7106657Snate@binkert.org mq_ident = "NULL" 7116657Snate@binkert.org 7128683Snilay@cs.wisc.edu seq_ident = "NULL" 7138683Snilay@cs.wisc.edu for param in self.config_parameters: 7148683Snilay@cs.wisc.edu if param.name == "sequencer": 7158683Snilay@cs.wisc.edu assert(param.pointer) 7168683Snilay@cs.wisc.edu seq_ident = "m_%s_ptr" % param.name 7178683Snilay@cs.wisc.edu 7186657Snate@binkert.org code(''' 7199745Snilay@cs.wisc.edu 7209745Snilay@cs.wisc.eduvoid 7219745Snilay@cs.wisc.edu$c_ident::regStats() 7229745Snilay@cs.wisc.edu{ 7239745Snilay@cs.wisc.edu if (m_version == 0) { 7249745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7259745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7269745Snilay@cs.wisc.edu Stats::Vector *t = new Stats::Vector(); 7279745Snilay@cs.wisc.edu t->init(m_num_controllers); 7289745Snilay@cs.wisc.edu t->name(name() + "." + ${ident}_Event_to_string(event)); 7299745Snilay@cs.wisc.edu t->flags(Stats::pdf | Stats::total | Stats::oneline | 7309745Snilay@cs.wisc.edu Stats::nozero); 7319745Snilay@cs.wisc.edu 7329745Snilay@cs.wisc.edu eventVec.push_back(t); 7339745Snilay@cs.wisc.edu } 7349745Snilay@cs.wisc.edu 7359745Snilay@cs.wisc.edu for (${ident}_State state = ${ident}_State_FIRST; 7369745Snilay@cs.wisc.edu state < ${ident}_State_NUM; ++state) { 7379745Snilay@cs.wisc.edu 7389745Snilay@cs.wisc.edu transVec.push_back(std::vector<Stats::Vector *>()); 7399745Snilay@cs.wisc.edu 7409745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7419745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7429745Snilay@cs.wisc.edu 7439745Snilay@cs.wisc.edu Stats::Vector *t = new Stats::Vector(); 7449745Snilay@cs.wisc.edu t->init(m_num_controllers); 7459745Snilay@cs.wisc.edu t->name(name() + "." + ${ident}_State_to_string(state) + 7469745Snilay@cs.wisc.edu "." + ${ident}_Event_to_string(event)); 7479745Snilay@cs.wisc.edu 7489745Snilay@cs.wisc.edu t->flags(Stats::pdf | Stats::total | Stats::oneline | 7499745Snilay@cs.wisc.edu Stats::nozero); 7509745Snilay@cs.wisc.edu transVec[state].push_back(t); 7519745Snilay@cs.wisc.edu } 7529745Snilay@cs.wisc.edu } 7539745Snilay@cs.wisc.edu } 7549745Snilay@cs.wisc.edu} 7559745Snilay@cs.wisc.edu 7569745Snilay@cs.wisc.eduvoid 7579745Snilay@cs.wisc.edu$c_ident::collateStats() 7589745Snilay@cs.wisc.edu{ 7599745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7609745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7619745Snilay@cs.wisc.edu for (unsigned int i = 0; i < m_num_controllers; ++i) { 7629745Snilay@cs.wisc.edu std::map<uint32_t, AbstractController *>::iterator it = 7639745Snilay@cs.wisc.edu g_abs_controls[MachineType_${ident}].find(i); 7649745Snilay@cs.wisc.edu assert(it != g_abs_controls[MachineType_${ident}].end()); 7659745Snilay@cs.wisc.edu (*eventVec[event])[i] = 7669745Snilay@cs.wisc.edu (($c_ident *)(*it).second)->getEventCount(event); 7679745Snilay@cs.wisc.edu } 7689745Snilay@cs.wisc.edu } 7699745Snilay@cs.wisc.edu 7709745Snilay@cs.wisc.edu for (${ident}_State state = ${ident}_State_FIRST; 7719745Snilay@cs.wisc.edu state < ${ident}_State_NUM; ++state) { 7729745Snilay@cs.wisc.edu 7739745Snilay@cs.wisc.edu for (${ident}_Event event = ${ident}_Event_FIRST; 7749745Snilay@cs.wisc.edu event < ${ident}_Event_NUM; ++event) { 7759745Snilay@cs.wisc.edu 7769745Snilay@cs.wisc.edu for (unsigned int i = 0; i < m_num_controllers; ++i) { 7779745Snilay@cs.wisc.edu std::map<uint32_t, AbstractController *>::iterator it = 7789745Snilay@cs.wisc.edu g_abs_controls[MachineType_${ident}].find(i); 7799745Snilay@cs.wisc.edu assert(it != g_abs_controls[MachineType_${ident}].end()); 7809745Snilay@cs.wisc.edu (*transVec[state][event])[i] = 7819745Snilay@cs.wisc.edu (($c_ident *)(*it).second)->getTransitionCount(state, event); 7829745Snilay@cs.wisc.edu } 7839745Snilay@cs.wisc.edu } 7849745Snilay@cs.wisc.edu } 7859745Snilay@cs.wisc.edu} 7869745Snilay@cs.wisc.edu 7879745Snilay@cs.wisc.eduvoid 7889745Snilay@cs.wisc.edu$c_ident::countTransition(${ident}_State state, ${ident}_Event event) 7899745Snilay@cs.wisc.edu{ 7909745Snilay@cs.wisc.edu assert(m_possible[state][event]); 7919745Snilay@cs.wisc.edu m_counters[state][event]++; 7929745Snilay@cs.wisc.edu m_event_counters[event]++; 7939745Snilay@cs.wisc.edu} 7949745Snilay@cs.wisc.eduvoid 7959745Snilay@cs.wisc.edu$c_ident::possibleTransition(${ident}_State state, 7969745Snilay@cs.wisc.edu ${ident}_Event event) 7979745Snilay@cs.wisc.edu{ 7989745Snilay@cs.wisc.edu m_possible[state][event] = true; 7999745Snilay@cs.wisc.edu} 8009745Snilay@cs.wisc.edu 8019745Snilay@cs.wisc.eduuint64 8029745Snilay@cs.wisc.edu$c_ident::getEventCount(${ident}_Event event) 8039745Snilay@cs.wisc.edu{ 8049745Snilay@cs.wisc.edu return m_event_counters[event]; 8059745Snilay@cs.wisc.edu} 8069745Snilay@cs.wisc.edu 8079745Snilay@cs.wisc.edubool 8089745Snilay@cs.wisc.edu$c_ident::isPossible(${ident}_State state, ${ident}_Event event) 8099745Snilay@cs.wisc.edu{ 8109745Snilay@cs.wisc.edu return m_possible[state][event]; 8119745Snilay@cs.wisc.edu} 8129745Snilay@cs.wisc.edu 8139745Snilay@cs.wisc.eduuint64 8149745Snilay@cs.wisc.edu$c_ident::getTransitionCount(${ident}_State state, 8159745Snilay@cs.wisc.edu ${ident}_Event event) 8169745Snilay@cs.wisc.edu{ 8179745Snilay@cs.wisc.edu return m_counters[state][event]; 8189745Snilay@cs.wisc.edu} 8199745Snilay@cs.wisc.edu 8207007Snate@binkert.orgint 8217007Snate@binkert.org$c_ident::getNumControllers() 8227007Snate@binkert.org{ 8236657Snate@binkert.org return m_num_controllers; 8246657Snate@binkert.org} 8256657Snate@binkert.org 8267007Snate@binkert.orgMessageBuffer* 8277007Snate@binkert.org$c_ident::getMandatoryQueue() const 8287007Snate@binkert.org{ 8296657Snate@binkert.org return $mq_ident; 8306657Snate@binkert.org} 8316657Snate@binkert.org 8328683Snilay@cs.wisc.eduSequencer* 8338683Snilay@cs.wisc.edu$c_ident::getSequencer() const 8348683Snilay@cs.wisc.edu{ 8358683Snilay@cs.wisc.edu return $seq_ident; 8368683Snilay@cs.wisc.edu} 8378683Snilay@cs.wisc.edu 8387007Snate@binkert.orgconst int & 8397007Snate@binkert.org$c_ident::getVersion() const 8407007Snate@binkert.org{ 8416657Snate@binkert.org return m_version; 8426657Snate@binkert.org} 8436657Snate@binkert.org 8447007Snate@binkert.orgconst string 8457007Snate@binkert.org$c_ident::toString() const 8467007Snate@binkert.org{ 8476657Snate@binkert.org return "$c_ident"; 8486657Snate@binkert.org} 8496657Snate@binkert.org 8507007Snate@binkert.orgconst string 8517007Snate@binkert.org$c_ident::getName() const 8527007Snate@binkert.org{ 8536657Snate@binkert.org return m_name; 8546657Snate@binkert.org} 8557007Snate@binkert.org 8567007Snate@binkert.orgvoid 8577007Snate@binkert.org$c_ident::blockOnQueue(Address addr, MessageBuffer* port) 8587007Snate@binkert.org{ 8596863Sdrh5@cs.wisc.edu m_is_blocking = true; 8606863Sdrh5@cs.wisc.edu m_block_map[addr] = port; 8616863Sdrh5@cs.wisc.edu} 8627007Snate@binkert.org 8637007Snate@binkert.orgvoid 8647007Snate@binkert.org$c_ident::unblock(Address addr) 8657007Snate@binkert.org{ 8666863Sdrh5@cs.wisc.edu m_block_map.erase(addr); 8676863Sdrh5@cs.wisc.edu if (m_block_map.size() == 0) { 8686863Sdrh5@cs.wisc.edu m_is_blocking = false; 8696863Sdrh5@cs.wisc.edu } 8706863Sdrh5@cs.wisc.edu} 8716863Sdrh5@cs.wisc.edu 8727007Snate@binkert.orgvoid 8737007Snate@binkert.org$c_ident::print(ostream& out) const 8747007Snate@binkert.org{ 8757007Snate@binkert.org out << "[$c_ident " << m_version << "]"; 8767007Snate@binkert.org} 8776657Snate@binkert.org 8787007Snate@binkert.orgvoid 8797007Snate@binkert.org$c_ident::printStats(ostream& out) const 8807007Snate@binkert.org{ 8816902SBrad.Beckmann@amd.com''') 8826902SBrad.Beckmann@amd.com # 8836902SBrad.Beckmann@amd.com # Cache and Memory Controllers have specific profilers associated with 8846902SBrad.Beckmann@amd.com # them. Print out these stats before dumping state transition stats. 8856902SBrad.Beckmann@amd.com # 8866902SBrad.Beckmann@amd.com for param in self.config_parameters: 8879745Snilay@cs.wisc.edu if param.type_ast.type.ident == "DirectoryMemory": 8886902SBrad.Beckmann@amd.com assert(param.pointer) 8896902SBrad.Beckmann@amd.com code(' m_${{param.ident}}_ptr->printStats(out);') 8906902SBrad.Beckmann@amd.com 8916902SBrad.Beckmann@amd.com code(''' 8926902SBrad.Beckmann@amd.com} 8936902SBrad.Beckmann@amd.com 8949745Snilay@cs.wisc.eduvoid $c_ident::clearStats() 8959745Snilay@cs.wisc.edu{ 8969745Snilay@cs.wisc.edu for (int state = 0; state < ${ident}_State_NUM; state++) { 8979745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 8989745Snilay@cs.wisc.edu m_counters[state][event] = 0; 8999745Snilay@cs.wisc.edu } 9009745Snilay@cs.wisc.edu } 9016902SBrad.Beckmann@amd.com 9029745Snilay@cs.wisc.edu for (int event = 0; event < ${ident}_Event_NUM; event++) { 9039745Snilay@cs.wisc.edu m_event_counters[event] = 0; 9049745Snilay@cs.wisc.edu } 9059745Snilay@cs.wisc.edu 9069496Snilay@cs.wisc.edu AbstractController::clearStats(); 9076902SBrad.Beckmann@amd.com} 9087839Snilay@cs.wisc.edu''') 9097839Snilay@cs.wisc.edu 9107839Snilay@cs.wisc.edu if self.EntryType != None: 9117839Snilay@cs.wisc.edu code(''' 9127839Snilay@cs.wisc.edu 9137839Snilay@cs.wisc.edu// Set and Reset for cache_entry variable 9147839Snilay@cs.wisc.eduvoid 9157839Snilay@cs.wisc.edu$c_ident::set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry) 9167839Snilay@cs.wisc.edu{ 9177839Snilay@cs.wisc.edu m_cache_entry_ptr = (${{self.EntryType.c_ident}}*)m_new_cache_entry; 9187839Snilay@cs.wisc.edu} 9197839Snilay@cs.wisc.edu 9207839Snilay@cs.wisc.eduvoid 9217839Snilay@cs.wisc.edu$c_ident::unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr) 9227839Snilay@cs.wisc.edu{ 9237839Snilay@cs.wisc.edu m_cache_entry_ptr = 0; 9247839Snilay@cs.wisc.edu} 9257839Snilay@cs.wisc.edu''') 9267839Snilay@cs.wisc.edu 9277839Snilay@cs.wisc.edu if self.TBEType != None: 9287839Snilay@cs.wisc.edu code(''' 9297839Snilay@cs.wisc.edu 9307839Snilay@cs.wisc.edu// Set and Reset for tbe variable 9317839Snilay@cs.wisc.eduvoid 9327839Snilay@cs.wisc.edu$c_ident::set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.TBEType.c_ident}}* m_new_tbe) 9337839Snilay@cs.wisc.edu{ 9347839Snilay@cs.wisc.edu m_tbe_ptr = m_new_tbe; 9357839Snilay@cs.wisc.edu} 9367839Snilay@cs.wisc.edu 9377839Snilay@cs.wisc.eduvoid 9387839Snilay@cs.wisc.edu$c_ident::unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr) 9397839Snilay@cs.wisc.edu{ 9407839Snilay@cs.wisc.edu m_tbe_ptr = NULL; 9417839Snilay@cs.wisc.edu} 9427839Snilay@cs.wisc.edu''') 9437839Snilay@cs.wisc.edu 9447839Snilay@cs.wisc.edu code(''' 9456902SBrad.Beckmann@amd.com 9468683Snilay@cs.wisc.eduvoid 9478683Snilay@cs.wisc.edu$c_ident::recordCacheTrace(int cntrl, CacheRecorder* tr) 9488683Snilay@cs.wisc.edu{ 9498683Snilay@cs.wisc.edu''') 9508683Snilay@cs.wisc.edu # 9518683Snilay@cs.wisc.edu # Record cache contents for all associated caches. 9528683Snilay@cs.wisc.edu # 9538683Snilay@cs.wisc.edu code.indent() 9548683Snilay@cs.wisc.edu for param in self.config_parameters: 9558683Snilay@cs.wisc.edu if param.type_ast.type.ident == "CacheMemory": 9568683Snilay@cs.wisc.edu assert(param.pointer) 9578683Snilay@cs.wisc.edu code('m_${{param.ident}}_ptr->recordCacheContents(cntrl, tr);') 9588683Snilay@cs.wisc.edu 9598683Snilay@cs.wisc.edu code.dedent() 9608683Snilay@cs.wisc.edu code(''' 9618683Snilay@cs.wisc.edu} 9628683Snilay@cs.wisc.edu 9636657Snate@binkert.org// Actions 9646657Snate@binkert.org''') 9657839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 9667839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9677839Snilay@cs.wisc.edu if "c_code" not in action: 9687839Snilay@cs.wisc.edu continue 9696657Snate@binkert.org 9707839Snilay@cs.wisc.edu code(''' 9717839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 9727839Snilay@cs.wisc.eduvoid 9737839Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr) 9747839Snilay@cs.wisc.edu{ 9758055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 9767839Snilay@cs.wisc.edu ${{action["c_code"]}} 9777839Snilay@cs.wisc.edu} 9786657Snate@binkert.org 9797839Snilay@cs.wisc.edu''') 9807839Snilay@cs.wisc.edu elif self.TBEType != None: 9817839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9827839Snilay@cs.wisc.edu if "c_code" not in action: 9837839Snilay@cs.wisc.edu continue 9847839Snilay@cs.wisc.edu 9857839Snilay@cs.wisc.edu code(''' 9867839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 9877839Snilay@cs.wisc.eduvoid 9887839Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, const Address& addr) 9897839Snilay@cs.wisc.edu{ 9908055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 9917839Snilay@cs.wisc.edu ${{action["c_code"]}} 9927839Snilay@cs.wisc.edu} 9937839Snilay@cs.wisc.edu 9947839Snilay@cs.wisc.edu''') 9957839Snilay@cs.wisc.edu elif self.EntryType != None: 9967839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 9977839Snilay@cs.wisc.edu if "c_code" not in action: 9987839Snilay@cs.wisc.edu continue 9997839Snilay@cs.wisc.edu 10007839Snilay@cs.wisc.edu code(''' 10017839Snilay@cs.wisc.edu/** \\brief ${{action.desc}} */ 10027839Snilay@cs.wisc.eduvoid 10037839Snilay@cs.wisc.edu$c_ident::${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr) 10047839Snilay@cs.wisc.edu{ 10058055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 10067839Snilay@cs.wisc.edu ${{action["c_code"]}} 10077839Snilay@cs.wisc.edu} 10087839Snilay@cs.wisc.edu 10097839Snilay@cs.wisc.edu''') 10107839Snilay@cs.wisc.edu else: 10117839Snilay@cs.wisc.edu for action in self.actions.itervalues(): 10127839Snilay@cs.wisc.edu if "c_code" not in action: 10137839Snilay@cs.wisc.edu continue 10147839Snilay@cs.wisc.edu 10157839Snilay@cs.wisc.edu code(''' 10166657Snate@binkert.org/** \\brief ${{action.desc}} */ 10177007Snate@binkert.orgvoid 10187007Snate@binkert.org$c_ident::${{action.ident}}(const Address& addr) 10196657Snate@binkert.org{ 10208055Sksewell@umich.edu DPRINTF(RubyGenerated, "executing ${{action.ident}}\\n"); 10216657Snate@binkert.org ${{action["c_code"]}} 10226657Snate@binkert.org} 10236657Snate@binkert.org 10246657Snate@binkert.org''') 10258478Snilay@cs.wisc.edu for func in self.functions: 10268478Snilay@cs.wisc.edu code(func.generateCode()) 10278478Snilay@cs.wisc.edu 10289302Snilay@cs.wisc.edu # Function for functional reads from messages buffered in the controller 10299302Snilay@cs.wisc.edu code(''' 10309302Snilay@cs.wisc.edubool 10319302Snilay@cs.wisc.edu$c_ident::functionalReadBuffers(PacketPtr& pkt) 10329302Snilay@cs.wisc.edu{ 10339302Snilay@cs.wisc.edu''') 10349302Snilay@cs.wisc.edu for var in self.objects: 10359302Snilay@cs.wisc.edu vtype = var.type 10369302Snilay@cs.wisc.edu if vtype.isBuffer: 10379302Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.c_ident 10389302Snilay@cs.wisc.edu code('if ($vid->functionalRead(pkt)) { return true; }') 10399302Snilay@cs.wisc.edu code(''' 10409302Snilay@cs.wisc.edu return false; 10419302Snilay@cs.wisc.edu} 10429302Snilay@cs.wisc.edu''') 10439302Snilay@cs.wisc.edu 10449302Snilay@cs.wisc.edu # Function for functional writes to messages buffered in the controller 10459302Snilay@cs.wisc.edu code(''' 10469302Snilay@cs.wisc.eduuint32_t 10479302Snilay@cs.wisc.edu$c_ident::functionalWriteBuffers(PacketPtr& pkt) 10489302Snilay@cs.wisc.edu{ 10499302Snilay@cs.wisc.edu uint32_t num_functional_writes = 0; 10509302Snilay@cs.wisc.edu''') 10519302Snilay@cs.wisc.edu for var in self.objects: 10529302Snilay@cs.wisc.edu vtype = var.type 10539302Snilay@cs.wisc.edu if vtype.isBuffer: 10549302Snilay@cs.wisc.edu vid = "m_%s_ptr" % var.c_ident 10559302Snilay@cs.wisc.edu code('num_functional_writes += $vid->functionalWrite(pkt);') 10569302Snilay@cs.wisc.edu code(''' 10579302Snilay@cs.wisc.edu return num_functional_writes; 10589302Snilay@cs.wisc.edu} 10599302Snilay@cs.wisc.edu''') 10609302Snilay@cs.wisc.edu 10619595Snilay@cs.wisc.edu # Check if this controller has a peer, if yes then write the 10629595Snilay@cs.wisc.edu # function for connecting to the peer. 10639595Snilay@cs.wisc.edu if has_peer: 10649595Snilay@cs.wisc.edu code(''' 10659595Snilay@cs.wisc.edu 10669595Snilay@cs.wisc.eduvoid 10679595Snilay@cs.wisc.edu$c_ident::getQueuesFromPeer(AbstractController *peer) 10689595Snilay@cs.wisc.edu{ 10699595Snilay@cs.wisc.edu''') 10709595Snilay@cs.wisc.edu for var in self.objects: 10719595Snilay@cs.wisc.edu if "network" in var and "physical_network" in var and \ 10729595Snilay@cs.wisc.edu var["network"] == "From": 10739595Snilay@cs.wisc.edu code(''' 10749595Snilay@cs.wisc.edum_${{var.c_ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}}); 10759595Snilay@cs.wisc.eduassert(m_${{var.c_ident}}_ptr != NULL); 10769595Snilay@cs.wisc.edum_${{var.c_ident}}_ptr->setReceiver(this); 10779595Snilay@cs.wisc.edu 10789595Snilay@cs.wisc.edu''') 10799595Snilay@cs.wisc.edu code('}') 10809595Snilay@cs.wisc.edu 10816657Snate@binkert.org code.write(path, "%s.cc" % c_ident) 10826657Snate@binkert.org 10839219Spower.jg@gmail.com def printCWakeup(self, path, includes): 10846657Snate@binkert.org '''Output the wakeup loop for the events''' 10856657Snate@binkert.org 10866999Snate@binkert.org code = self.symtab.codeFormatter() 10876657Snate@binkert.org ident = self.ident 10886657Snate@binkert.org 10899104Shestness@cs.utexas.edu outputRequest_types = True 10909104Shestness@cs.utexas.edu if len(self.request_types) == 0: 10919104Shestness@cs.utexas.edu outputRequest_types = False 10929104Shestness@cs.utexas.edu 10936657Snate@binkert.org code(''' 10946657Snate@binkert.org// Auto generated C++ code started by $__file__:$__line__ 10956657Snate@binkert.org// ${ident}: ${{self.short}} 10966657Snate@binkert.org 10978946Sandreas.hansson@arm.com#include <sys/types.h> 10988946Sandreas.hansson@arm.com#include <unistd.h> 10998946Sandreas.hansson@arm.com 11007832Snate@binkert.org#include <cassert> 11017832Snate@binkert.org 11027007Snate@binkert.org#include "base/misc.hh" 11038232Snate@binkert.org#include "debug/RubySlicc.hh" 11048229Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 11058229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 11068229Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 11079104Shestness@cs.utexas.edu''') 11089104Shestness@cs.utexas.edu 11099104Shestness@cs.utexas.edu if outputRequest_types: 11109104Shestness@cs.utexas.edu code('''#include "mem/protocol/${ident}_RequestType.hh"''') 11119104Shestness@cs.utexas.edu 11129104Shestness@cs.utexas.edu code(''' 11138229Snate@binkert.org#include "mem/protocol/Types.hh" 11146657Snate@binkert.org#include "mem/ruby/common/Global.hh" 11156657Snate@binkert.org#include "mem/ruby/system/System.hh" 11169219Spower.jg@gmail.com''') 11179219Spower.jg@gmail.com 11189219Spower.jg@gmail.com 11199219Spower.jg@gmail.com for include_path in includes: 11209219Spower.jg@gmail.com code('#include "${{include_path}}"') 11219219Spower.jg@gmail.com 11229219Spower.jg@gmail.com code(''' 11236657Snate@binkert.org 11247055Snate@binkert.orgusing namespace std; 11257055Snate@binkert.org 11267007Snate@binkert.orgvoid 11277007Snate@binkert.org${ident}_Controller::wakeup() 11286657Snate@binkert.org{ 11296657Snate@binkert.org int counter = 0; 11306657Snate@binkert.org while (true) { 11316657Snate@binkert.org // Some cases will put us into an infinite loop without this limit 11326657Snate@binkert.org assert(counter <= m_transitions_per_cycle); 11336657Snate@binkert.org if (counter == m_transitions_per_cycle) { 11347007Snate@binkert.org // Count how often we are fully utilized 11359496Snilay@cs.wisc.edu m_fully_busy_cycles++; 11367007Snate@binkert.org 11377007Snate@binkert.org // Wakeup in another cycle and try again 11389499Snilay@cs.wisc.edu scheduleEvent(Cycles(1)); 11396657Snate@binkert.org break; 11406657Snate@binkert.org } 11416657Snate@binkert.org''') 11426657Snate@binkert.org 11436657Snate@binkert.org code.indent() 11446657Snate@binkert.org code.indent() 11456657Snate@binkert.org 11466657Snate@binkert.org # InPorts 11476657Snate@binkert.org # 11486657Snate@binkert.org for port in self.in_ports: 11496657Snate@binkert.org code.indent() 11506657Snate@binkert.org code('// ${ident}InPort $port') 11517567SBrad.Beckmann@amd.com if port.pairs.has_key("rank"): 11527567SBrad.Beckmann@amd.com code('m_cur_in_port_rank = ${{port.pairs["rank"]}};') 11537567SBrad.Beckmann@amd.com else: 11547567SBrad.Beckmann@amd.com code('m_cur_in_port_rank = 0;') 11556657Snate@binkert.org code('${{port["c_code_in_port"]}}') 11566657Snate@binkert.org code.dedent() 11576657Snate@binkert.org 11586657Snate@binkert.org code('') 11596657Snate@binkert.org 11606657Snate@binkert.org code.dedent() 11616657Snate@binkert.org code.dedent() 11626657Snate@binkert.org code(''' 11636657Snate@binkert.org break; // If we got this far, we have nothing left todo 11646657Snate@binkert.org } 11656657Snate@binkert.org} 11666657Snate@binkert.org''') 11676657Snate@binkert.org 11686657Snate@binkert.org code.write(path, "%s_Wakeup.cc" % self.ident) 11696657Snate@binkert.org 11706657Snate@binkert.org def printCSwitch(self, path): 11716657Snate@binkert.org '''Output switch statement for transition table''' 11726657Snate@binkert.org 11736999Snate@binkert.org code = self.symtab.codeFormatter() 11746657Snate@binkert.org ident = self.ident 11756657Snate@binkert.org 11766657Snate@binkert.org code(''' 11776657Snate@binkert.org// Auto generated C++ code started by $__file__:$__line__ 11786657Snate@binkert.org// ${ident}: ${{self.short}} 11796657Snate@binkert.org 11807832Snate@binkert.org#include <cassert> 11817832Snate@binkert.org 11827805Snilay@cs.wisc.edu#include "base/misc.hh" 11837832Snate@binkert.org#include "base/trace.hh" 11848232Snate@binkert.org#include "debug/ProtocolTrace.hh" 11858232Snate@binkert.org#include "debug/RubyGenerated.hh" 11868229Snate@binkert.org#include "mem/protocol/${ident}_Controller.hh" 11878229Snate@binkert.org#include "mem/protocol/${ident}_Event.hh" 11888229Snate@binkert.org#include "mem/protocol/${ident}_State.hh" 11898229Snate@binkert.org#include "mem/protocol/Types.hh" 11906657Snate@binkert.org#include "mem/ruby/common/Global.hh" 11916657Snate@binkert.org#include "mem/ruby/system/System.hh" 11926657Snate@binkert.org 11936657Snate@binkert.org#define HASH_FUN(state, event) ((int(state)*${ident}_Event_NUM)+int(event)) 11946657Snate@binkert.org 11956657Snate@binkert.org#define GET_TRANSITION_COMMENT() (${ident}_transitionComment.str()) 11966657Snate@binkert.org#define CLEAR_TRANSITION_COMMENT() (${ident}_transitionComment.str("")) 11976657Snate@binkert.org 11987007Snate@binkert.orgTransitionResult 11997007Snate@binkert.org${ident}_Controller::doTransition(${ident}_Event event, 12007839Snilay@cs.wisc.edu''') 12017839Snilay@cs.wisc.edu if self.EntryType != None: 12027839Snilay@cs.wisc.edu code(''' 12037839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}* m_cache_entry_ptr, 12047839Snilay@cs.wisc.edu''') 12057839Snilay@cs.wisc.edu if self.TBEType != None: 12067839Snilay@cs.wisc.edu code(''' 12077839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}* m_tbe_ptr, 12087839Snilay@cs.wisc.edu''') 12097839Snilay@cs.wisc.edu code(''' 12107007Snate@binkert.org const Address &addr) 12116657Snate@binkert.org{ 12127839Snilay@cs.wisc.edu''') 12137839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 12148337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);') 12157839Snilay@cs.wisc.edu elif self.TBEType != None: 12168337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_tbe_ptr, addr);') 12177839Snilay@cs.wisc.edu elif self.EntryType != None: 12188337Snilay@cs.wisc.edu code('${ident}_State state = getState(m_cache_entry_ptr, addr);') 12197839Snilay@cs.wisc.edu else: 12208337Snilay@cs.wisc.edu code('${ident}_State state = getState(addr);') 12217839Snilay@cs.wisc.edu 12227839Snilay@cs.wisc.edu code(''' 12236657Snate@binkert.org ${ident}_State next_state = state; 12246657Snate@binkert.org 12257780Snilay@cs.wisc.edu DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n", 12269465Snilay@cs.wisc.edu *this, curCycle(), ${ident}_State_to_string(state), 12279171Snilay@cs.wisc.edu ${ident}_Event_to_string(event), addr); 12286657Snate@binkert.org 12297007Snate@binkert.org TransitionResult result = 12307839Snilay@cs.wisc.edu''') 12317839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 12327839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);') 12337839Snilay@cs.wisc.edu elif self.TBEType != None: 12347839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_tbe_ptr, addr);') 12357839Snilay@cs.wisc.edu elif self.EntryType != None: 12367839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);') 12377839Snilay@cs.wisc.edu else: 12387839Snilay@cs.wisc.edu code('doTransitionWorker(event, state, next_state, addr);') 12396657Snate@binkert.org 12407839Snilay@cs.wisc.edu code(''' 12416657Snate@binkert.org if (result == TransitionResult_Valid) { 12427780Snilay@cs.wisc.edu DPRINTF(RubyGenerated, "next_state: %s\\n", 12437780Snilay@cs.wisc.edu ${ident}_State_to_string(next_state)); 12449745Snilay@cs.wisc.edu countTransition(state, event); 12458266Sksewell@umich.edu DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n", 12468266Sksewell@umich.edu curTick(), m_version, "${ident}", 12478266Sksewell@umich.edu ${ident}_Event_to_string(event), 12488266Sksewell@umich.edu ${ident}_State_to_string(state), 12498266Sksewell@umich.edu ${ident}_State_to_string(next_state), 12508266Sksewell@umich.edu addr, GET_TRANSITION_COMMENT()); 12516657Snate@binkert.org 12527832Snate@binkert.org CLEAR_TRANSITION_COMMENT(); 12537839Snilay@cs.wisc.edu''') 12547839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 12558337Snilay@cs.wisc.edu code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);') 12568341Snilay@cs.wisc.edu code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 12577839Snilay@cs.wisc.edu elif self.TBEType != None: 12588337Snilay@cs.wisc.edu code('setState(m_tbe_ptr, addr, next_state);') 12598341Snilay@cs.wisc.edu code('setAccessPermission(addr, next_state);') 12607839Snilay@cs.wisc.edu elif self.EntryType != None: 12618337Snilay@cs.wisc.edu code('setState(m_cache_entry_ptr, addr, next_state);') 12628341Snilay@cs.wisc.edu code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 12637839Snilay@cs.wisc.edu else: 12648337Snilay@cs.wisc.edu code('setState(addr, next_state);') 12658341Snilay@cs.wisc.edu code('setAccessPermission(addr, next_state);') 12667839Snilay@cs.wisc.edu 12677839Snilay@cs.wisc.edu code(''' 12686657Snate@binkert.org } else if (result == TransitionResult_ResourceStall) { 12698266Sksewell@umich.edu DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 12708266Sksewell@umich.edu curTick(), m_version, "${ident}", 12718266Sksewell@umich.edu ${ident}_Event_to_string(event), 12728266Sksewell@umich.edu ${ident}_State_to_string(state), 12738266Sksewell@umich.edu ${ident}_State_to_string(next_state), 12748266Sksewell@umich.edu addr, "Resource Stall"); 12756657Snate@binkert.org } else if (result == TransitionResult_ProtocolStall) { 12767780Snilay@cs.wisc.edu DPRINTF(RubyGenerated, "stalling\\n"); 12778266Sksewell@umich.edu DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 12788266Sksewell@umich.edu curTick(), m_version, "${ident}", 12798266Sksewell@umich.edu ${ident}_Event_to_string(event), 12808266Sksewell@umich.edu ${ident}_State_to_string(state), 12818266Sksewell@umich.edu ${ident}_State_to_string(next_state), 12828266Sksewell@umich.edu addr, "Protocol Stall"); 12836657Snate@binkert.org } 12846657Snate@binkert.org 12856657Snate@binkert.org return result; 12866657Snate@binkert.org} 12876657Snate@binkert.org 12887007Snate@binkert.orgTransitionResult 12897007Snate@binkert.org${ident}_Controller::doTransitionWorker(${ident}_Event event, 12907007Snate@binkert.org ${ident}_State state, 12917007Snate@binkert.org ${ident}_State& next_state, 12927839Snilay@cs.wisc.edu''') 12937839Snilay@cs.wisc.edu 12947839Snilay@cs.wisc.edu if self.TBEType != None: 12957839Snilay@cs.wisc.edu code(''' 12967839Snilay@cs.wisc.edu ${{self.TBEType.c_ident}}*& m_tbe_ptr, 12977839Snilay@cs.wisc.edu''') 12987839Snilay@cs.wisc.edu if self.EntryType != None: 12997839Snilay@cs.wisc.edu code(''' 13007839Snilay@cs.wisc.edu ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, 13017839Snilay@cs.wisc.edu''') 13027839Snilay@cs.wisc.edu code(''' 13037007Snate@binkert.org const Address& addr) 13046657Snate@binkert.org{ 13056657Snate@binkert.org switch(HASH_FUN(state, event)) { 13066657Snate@binkert.org''') 13076657Snate@binkert.org 13086657Snate@binkert.org # This map will allow suppress generating duplicate code 13096657Snate@binkert.org cases = orderdict() 13106657Snate@binkert.org 13116657Snate@binkert.org for trans in self.transitions: 13126657Snate@binkert.org case_string = "%s_State_%s, %s_Event_%s" % \ 13136657Snate@binkert.org (self.ident, trans.state.ident, self.ident, trans.event.ident) 13146657Snate@binkert.org 13156999Snate@binkert.org case = self.symtab.codeFormatter() 13166657Snate@binkert.org # Only set next_state if it changes 13176657Snate@binkert.org if trans.state != trans.nextState: 13186657Snate@binkert.org ns_ident = trans.nextState.ident 13196657Snate@binkert.org case('next_state = ${ident}_State_${ns_ident};') 13206657Snate@binkert.org 13216657Snate@binkert.org actions = trans.actions 13229104Shestness@cs.utexas.edu request_types = trans.request_types 13236657Snate@binkert.org 13246657Snate@binkert.org # Check for resources 13256657Snate@binkert.org case_sorter = [] 13266657Snate@binkert.org res = trans.resources 13276657Snate@binkert.org for key,val in res.iteritems(): 13286657Snate@binkert.org if key.type.ident != "DNUCAStopTable": 13296657Snate@binkert.org val = ''' 13307007Snate@binkert.orgif (!%s.areNSlotsAvailable(%s)) 13316657Snate@binkert.org return TransitionResult_ResourceStall; 13326657Snate@binkert.org''' % (key.code, val) 13336657Snate@binkert.org case_sorter.append(val) 13346657Snate@binkert.org 13359105SBrad.Beckmann@amd.com # Check all of the request_types for resource constraints 13369105SBrad.Beckmann@amd.com for request_type in request_types: 13379105SBrad.Beckmann@amd.com val = ''' 13389105SBrad.Beckmann@amd.comif (!checkResourceAvailable(%s_RequestType_%s, addr)) { 13399105SBrad.Beckmann@amd.com return TransitionResult_ResourceStall; 13409105SBrad.Beckmann@amd.com} 13419105SBrad.Beckmann@amd.com''' % (self.ident, request_type.ident) 13429105SBrad.Beckmann@amd.com case_sorter.append(val) 13436657Snate@binkert.org 13446657Snate@binkert.org # Emit the code sequences in a sorted order. This makes the 13456657Snate@binkert.org # output deterministic (without this the output order can vary 13466657Snate@binkert.org # since Map's keys() on a vector of pointers is not deterministic 13476657Snate@binkert.org for c in sorted(case_sorter): 13486657Snate@binkert.org case("$c") 13496657Snate@binkert.org 13509104Shestness@cs.utexas.edu # Record access types for this transition 13519104Shestness@cs.utexas.edu for request_type in request_types: 13529104Shestness@cs.utexas.edu case('recordRequestType(${ident}_RequestType_${{request_type.ident}}, addr);') 13539104Shestness@cs.utexas.edu 13546657Snate@binkert.org # Figure out if we stall 13556657Snate@binkert.org stall = False 13566657Snate@binkert.org for action in actions: 13576657Snate@binkert.org if action.ident == "z_stall": 13586657Snate@binkert.org stall = True 13596657Snate@binkert.org break 13606657Snate@binkert.org 13616657Snate@binkert.org if stall: 13626657Snate@binkert.org case('return TransitionResult_ProtocolStall;') 13636657Snate@binkert.org else: 13647839Snilay@cs.wisc.edu if self.TBEType != None and self.EntryType != None: 13657839Snilay@cs.wisc.edu for action in actions: 13667839Snilay@cs.wisc.edu case('${{action.ident}}(m_tbe_ptr, m_cache_entry_ptr, addr);') 13677839Snilay@cs.wisc.edu elif self.TBEType != None: 13687839Snilay@cs.wisc.edu for action in actions: 13697839Snilay@cs.wisc.edu case('${{action.ident}}(m_tbe_ptr, addr);') 13707839Snilay@cs.wisc.edu elif self.EntryType != None: 13717839Snilay@cs.wisc.edu for action in actions: 13727839Snilay@cs.wisc.edu case('${{action.ident}}(m_cache_entry_ptr, addr);') 13737839Snilay@cs.wisc.edu else: 13747839Snilay@cs.wisc.edu for action in actions: 13757839Snilay@cs.wisc.edu case('${{action.ident}}(addr);') 13766657Snate@binkert.org case('return TransitionResult_Valid;') 13776657Snate@binkert.org 13786657Snate@binkert.org case = str(case) 13796657Snate@binkert.org 13806657Snate@binkert.org # Look to see if this transition code is unique. 13816657Snate@binkert.org if case not in cases: 13826657Snate@binkert.org cases[case] = [] 13836657Snate@binkert.org 13846657Snate@binkert.org cases[case].append(case_string) 13856657Snate@binkert.org 13866657Snate@binkert.org # Walk through all of the unique code blocks and spit out the 13876657Snate@binkert.org # corresponding case statement elements 13886657Snate@binkert.org for case,transitions in cases.iteritems(): 13896657Snate@binkert.org # Iterative over all the multiple transitions that share 13906657Snate@binkert.org # the same code 13916657Snate@binkert.org for trans in transitions: 13926657Snate@binkert.org code(' case HASH_FUN($trans):') 13936657Snate@binkert.org code(' $case') 13946657Snate@binkert.org 13956657Snate@binkert.org code(''' 13966657Snate@binkert.org default: 13977805Snilay@cs.wisc.edu fatal("Invalid transition\\n" 13988159SBrad.Beckmann@amd.com "%s time: %d addr: %s event: %s state: %s\\n", 13999465Snilay@cs.wisc.edu name(), curCycle(), addr, event, state); 14006657Snate@binkert.org } 14016657Snate@binkert.org return TransitionResult_Valid; 14026657Snate@binkert.org} 14036657Snate@binkert.org''') 14046657Snate@binkert.org code.write(path, "%s_Transitions.cc" % self.ident) 14056657Snate@binkert.org 14066657Snate@binkert.org 14076657Snate@binkert.org # ************************** 14086657Snate@binkert.org # ******* HTML Files ******* 14096657Snate@binkert.org # ************************** 14107007Snate@binkert.org def frameRef(self, click_href, click_target, over_href, over_num, text): 14116999Snate@binkert.org code = self.symtab.codeFormatter(fix_newlines=False) 14127007Snate@binkert.org code("""<A href=\"$click_href\" target=\"$click_target\" onmouseover=\" 14137007Snate@binkert.org if (parent.frames[$over_num].location != parent.location + '$over_href') { 14147007Snate@binkert.org parent.frames[$over_num].location='$over_href' 14157007Snate@binkert.org }\"> 14167007Snate@binkert.org ${{html.formatShorthand(text)}} 14177007Snate@binkert.org </A>""") 14186657Snate@binkert.org return str(code) 14196657Snate@binkert.org 14206657Snate@binkert.org def writeHTMLFiles(self, path): 14216657Snate@binkert.org # Create table with no row hilighted 14226657Snate@binkert.org self.printHTMLTransitions(path, None) 14236657Snate@binkert.org 14246657Snate@binkert.org # Generate transition tables 14256657Snate@binkert.org for state in self.states.itervalues(): 14266657Snate@binkert.org self.printHTMLTransitions(path, state) 14276657Snate@binkert.org 14286657Snate@binkert.org # Generate action descriptions 14296657Snate@binkert.org for action in self.actions.itervalues(): 14306657Snate@binkert.org name = "%s_action_%s.html" % (self.ident, action.ident) 14316657Snate@binkert.org code = html.createSymbol(action, "Action") 14326657Snate@binkert.org code.write(path, name) 14336657Snate@binkert.org 14346657Snate@binkert.org # Generate state descriptions 14356657Snate@binkert.org for state in self.states.itervalues(): 14366657Snate@binkert.org name = "%s_State_%s.html" % (self.ident, state.ident) 14376657Snate@binkert.org code = html.createSymbol(state, "State") 14386657Snate@binkert.org code.write(path, name) 14396657Snate@binkert.org 14406657Snate@binkert.org # Generate event descriptions 14416657Snate@binkert.org for event in self.events.itervalues(): 14426657Snate@binkert.org name = "%s_Event_%s.html" % (self.ident, event.ident) 14436657Snate@binkert.org code = html.createSymbol(event, "Event") 14446657Snate@binkert.org code.write(path, name) 14456657Snate@binkert.org 14466657Snate@binkert.org def printHTMLTransitions(self, path, active_state): 14476999Snate@binkert.org code = self.symtab.codeFormatter() 14486657Snate@binkert.org 14496657Snate@binkert.org code(''' 14507007Snate@binkert.org<HTML> 14517007Snate@binkert.org<BODY link="blue" vlink="blue"> 14526657Snate@binkert.org 14536657Snate@binkert.org<H1 align="center">${{html.formatShorthand(self.short)}}: 14546657Snate@binkert.org''') 14556657Snate@binkert.org code.indent() 14566657Snate@binkert.org for i,machine in enumerate(self.symtab.getAllType(StateMachine)): 14576657Snate@binkert.org mid = machine.ident 14586657Snate@binkert.org if i != 0: 14596657Snate@binkert.org extra = " - " 14606657Snate@binkert.org else: 14616657Snate@binkert.org extra = "" 14626657Snate@binkert.org if machine == self: 14636657Snate@binkert.org code('$extra$mid') 14646657Snate@binkert.org else: 14656657Snate@binkert.org code('$extra<A target="Table" href="${mid}_table.html">$mid</A>') 14666657Snate@binkert.org code.dedent() 14676657Snate@binkert.org 14686657Snate@binkert.org code(""" 14696657Snate@binkert.org</H1> 14706657Snate@binkert.org 14716657Snate@binkert.org<TABLE border=1> 14726657Snate@binkert.org<TR> 14736657Snate@binkert.org <TH> </TH> 14746657Snate@binkert.org""") 14756657Snate@binkert.org 14766657Snate@binkert.org for event in self.events.itervalues(): 14776657Snate@binkert.org href = "%s_Event_%s.html" % (self.ident, event.ident) 14786657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", event.short) 14796657Snate@binkert.org code('<TH bgcolor=white>$ref</TH>') 14806657Snate@binkert.org 14816657Snate@binkert.org code('</TR>') 14826657Snate@binkert.org # -- Body of table 14836657Snate@binkert.org for state in self.states.itervalues(): 14846657Snate@binkert.org # -- Each row 14856657Snate@binkert.org if state == active_state: 14866657Snate@binkert.org color = "yellow" 14876657Snate@binkert.org else: 14886657Snate@binkert.org color = "white" 14896657Snate@binkert.org 14906657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, state.ident) 14916657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, state.ident) 14926657Snate@binkert.org text = html.formatShorthand(state.short) 14936657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", state.short) 14946657Snate@binkert.org code(''' 14956657Snate@binkert.org<TR> 14966657Snate@binkert.org <TH bgcolor=$color>$ref</TH> 14976657Snate@binkert.org''') 14986657Snate@binkert.org 14996657Snate@binkert.org # -- One column for each event 15006657Snate@binkert.org for event in self.events.itervalues(): 15016657Snate@binkert.org trans = self.table.get((state,event), None) 15026657Snate@binkert.org if trans is None: 15036657Snate@binkert.org # This is the no transition case 15046657Snate@binkert.org if state == active_state: 15056657Snate@binkert.org color = "#C0C000" 15066657Snate@binkert.org else: 15076657Snate@binkert.org color = "lightgrey" 15086657Snate@binkert.org 15096657Snate@binkert.org code('<TD bgcolor=$color> </TD>') 15106657Snate@binkert.org continue 15116657Snate@binkert.org 15126657Snate@binkert.org next = trans.nextState 15136657Snate@binkert.org stall_action = False 15146657Snate@binkert.org 15156657Snate@binkert.org # -- Get the actions 15166657Snate@binkert.org for action in trans.actions: 15176657Snate@binkert.org if action.ident == "z_stall" or \ 15186657Snate@binkert.org action.ident == "zz_recycleMandatoryQueue": 15196657Snate@binkert.org stall_action = True 15206657Snate@binkert.org 15216657Snate@binkert.org # -- Print out "actions/next-state" 15226657Snate@binkert.org if stall_action: 15236657Snate@binkert.org if state == active_state: 15246657Snate@binkert.org color = "#C0C000" 15256657Snate@binkert.org else: 15266657Snate@binkert.org color = "lightgrey" 15276657Snate@binkert.org 15286657Snate@binkert.org elif active_state and next.ident == active_state.ident: 15296657Snate@binkert.org color = "aqua" 15306657Snate@binkert.org elif state == active_state: 15316657Snate@binkert.org color = "yellow" 15326657Snate@binkert.org else: 15336657Snate@binkert.org color = "white" 15346657Snate@binkert.org 15356657Snate@binkert.org code('<TD bgcolor=$color>') 15366657Snate@binkert.org for action in trans.actions: 15376657Snate@binkert.org href = "%s_action_%s.html" % (self.ident, action.ident) 15386657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", 15396657Snate@binkert.org action.short) 15407007Snate@binkert.org code(' $ref') 15416657Snate@binkert.org if next != state: 15426657Snate@binkert.org if trans.actions: 15436657Snate@binkert.org code('/') 15446657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, next.ident) 15456657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, next.ident) 15466657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", next.short) 15476657Snate@binkert.org code("$ref") 15487007Snate@binkert.org code("</TD>") 15496657Snate@binkert.org 15506657Snate@binkert.org # -- Each row 15516657Snate@binkert.org if state == active_state: 15526657Snate@binkert.org color = "yellow" 15536657Snate@binkert.org else: 15546657Snate@binkert.org color = "white" 15556657Snate@binkert.org 15566657Snate@binkert.org click = "%s_table_%s.html" % (self.ident, state.ident) 15576657Snate@binkert.org over = "%s_State_%s.html" % (self.ident, state.ident) 15586657Snate@binkert.org ref = self.frameRef(click, "Table", over, "1", state.short) 15596657Snate@binkert.org code(''' 15606657Snate@binkert.org <TH bgcolor=$color>$ref</TH> 15616657Snate@binkert.org</TR> 15626657Snate@binkert.org''') 15636657Snate@binkert.org code(''' 15647007Snate@binkert.org<!- Column footer-> 15656657Snate@binkert.org<TR> 15666657Snate@binkert.org <TH> </TH> 15676657Snate@binkert.org''') 15686657Snate@binkert.org 15696657Snate@binkert.org for event in self.events.itervalues(): 15706657Snate@binkert.org href = "%s_Event_%s.html" % (self.ident, event.ident) 15716657Snate@binkert.org ref = self.frameRef(href, "Status", href, "1", event.short) 15726657Snate@binkert.org code('<TH bgcolor=white>$ref</TH>') 15736657Snate@binkert.org code(''' 15746657Snate@binkert.org</TR> 15756657Snate@binkert.org</TABLE> 15766657Snate@binkert.org</BODY></HTML> 15776657Snate@binkert.org''') 15786657Snate@binkert.org 15796657Snate@binkert.org 15806657Snate@binkert.org if active_state: 15816657Snate@binkert.org name = "%s_table_%s.html" % (self.ident, active_state.ident) 15826657Snate@binkert.org else: 15836657Snate@binkert.org name = "%s_table.html" % self.ident 15846657Snate@binkert.org code.write(path, name) 15856657Snate@binkert.org 15866657Snate@binkert.org__all__ = [ "StateMachine" ] 1587