1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 159 unchanged lines hidden (view full) --- 168 self.table = table 169 170 def writeCodeFiles(self, path, includes): 171 self.printControllerPython(path) 172 self.printControllerHH(path) 173 self.printControllerCC(path, includes) 174 self.printCSwitch(path) 175 self.printCWakeup(path, includes) |
176 177 def printControllerPython(self, path): 178 code = self.symtab.codeFormatter() 179 ident = self.ident 180 py_ident = "%s_Controller" % ident 181 c_ident = "%s_Controller" % self.ident 182 code(''' 183from m5.params import * --- 35 unchanged lines hidden (view full) --- 219 220#ifndef __${ident}_CONTROLLER_HH__ 221#define __${ident}_CONTROLLER_HH__ 222 223#include <iostream> 224#include <sstream> 225#include <string> 226 |
227#include "mem/protocol/TransitionResult.hh" 228#include "mem/protocol/Types.hh" 229#include "mem/ruby/common/Consumer.hh" 230#include "mem/ruby/common/Global.hh" 231#include "mem/ruby/slicc_interface/AbstractController.hh" 232#include "params/$c_ident.hh" 233''') 234 --- 17 unchanged lines hidden (view full) --- 252 $c_ident(const Params *p); 253 static int getNumControllers(); 254 void init(); 255 MessageBuffer* getMandatoryQueue() const; 256 const int & getVersion() const; 257 const std::string toString() const; 258 const std::string getName() const; 259 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; } |
260 |
261 void print(std::ostream& out) const; 262 void wakeup(); 263 void printStats(std::ostream& out) const; 264 void clearStats(); |
265 void regStats(); 266 void collateStats(); 267 |
268 void blockOnQueue(Address addr, MessageBuffer* port); 269 void unblock(Address addr); 270 void recordCacheTrace(int cntrl, CacheRecorder* tr); 271 Sequencer* getSequencer() const; 272 273 bool functionalReadBuffers(PacketPtr&); 274 uint32_t functionalWriteBuffers(PacketPtr&); 275 |
276 void countTransition(${ident}_State state, ${ident}_Event event); 277 void possibleTransition(${ident}_State state, ${ident}_Event event); 278 uint64 getEventCount(${ident}_Event event); 279 bool isPossible(${ident}_State state, ${ident}_Event event); 280 uint64 getTransitionCount(${ident}_State state, ${ident}_Event event); 281 |
282private: 283''') 284 285 code.indent() 286 # added by SS 287 for param in self.config_parameters: 288 if param.pointer: 289 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;') --- 28 unchanged lines hidden (view full) --- 318 if self.EntryType != None: 319 code(''' 320 ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, 321''') 322 323 code(''' 324 const Address& addr); 325 |
326int m_counters[${ident}_State_NUM][${ident}_Event_NUM]; 327int m_event_counters[${ident}_Event_NUM]; 328bool m_possible[${ident}_State_NUM][${ident}_Event_NUM]; 329 330static std::vector<Stats::Vector *> eventVec; 331static std::vector<std::vector<Stats::Vector *> > transVec; |
332static int m_num_controllers; 333 334// Internal functions 335''') 336 337 for func in self.functions: 338 proto = func.prototype 339 if proto: --- 103 unchanged lines hidden (view full) --- 443 code(''' 444$c_ident * 445${c_ident}Params::create() 446{ 447 return new $c_ident(this); 448} 449 450int $c_ident::m_num_controllers = 0; |
451std::vector<Stats::Vector *> $c_ident::eventVec; 452std::vector<std::vector<Stats::Vector *> > $c_ident::transVec; |
453 454// for adding information to the protocol debug trace 455stringstream ${ident}_transitionComment; 456#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str) 457 458/** \\brief constructor */ 459$c_ident::$c_ident(const Params *p) 460 : AbstractController(p) --- 63 unchanged lines hidden (view full) --- 524m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 525peerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr; 526m_${{var.c_ident}}_ptr->setSender(this); 527''') 528 529 code(''' 530if (p->peer != NULL) 531 connectWithPeer(p->peer); |
532 533for (int state = 0; state < ${ident}_State_NUM; state++) { 534 for (int event = 0; event < ${ident}_Event_NUM; event++) { 535 m_possible[state][event] = false; 536 m_counters[state][event] = 0; 537 } 538} 539for (int event = 0; event < ${ident}_Event_NUM; event++) { 540 m_event_counters[event] = 0; 541} |
542''') 543 code.dedent() 544 code(''' 545} 546 547void 548$c_ident::init() 549{ |
550 MachineType machine_type = string_to_MachineType("${{var.machine.ident}}"); 551 int base = MachineType_base_number(machine_type); |
552 553 m_machineID.type = MachineType_${ident}; 554 m_machineID.num = m_version; 555 556 // initialize objects |
557 558''') 559 560 code.indent() 561 for var in self.objects: 562 vtype = var.type 563 vid = "m_%s_ptr" % var.c_ident 564 if "network" not in var: --- 120 unchanged lines hidden (view full) --- 685 for action in trans.actions: 686 if action.ident == "z_stall": 687 stall = True 688 689 # Only possible if it is not a 'z' case 690 if not stall: 691 state = "%s_State_%s" % (self.ident, trans.state.ident) 692 event = "%s_Event_%s" % (self.ident, trans.event.ident) |
693 code('possibleTransition($state, $event);') |
694 695 code.dedent() 696 code(''' 697 AbstractController::init(); 698 clearStats(); 699} 700''') 701 --- 9 unchanged lines hidden (view full) --- 711 712 seq_ident = "NULL" 713 for param in self.config_parameters: 714 if param.name == "sequencer": 715 assert(param.pointer) 716 seq_ident = "m_%s_ptr" % param.name 717 718 code(''' |
719 720void 721$c_ident::regStats() 722{ 723 if (m_version == 0) { 724 for (${ident}_Event event = ${ident}_Event_FIRST; 725 event < ${ident}_Event_NUM; ++event) { 726 Stats::Vector *t = new Stats::Vector(); 727 t->init(m_num_controllers); 728 t->name(name() + "." + ${ident}_Event_to_string(event)); 729 t->flags(Stats::pdf | Stats::total | Stats::oneline | 730 Stats::nozero); 731 732 eventVec.push_back(t); 733 } 734 735 for (${ident}_State state = ${ident}_State_FIRST; 736 state < ${ident}_State_NUM; ++state) { 737 738 transVec.push_back(std::vector<Stats::Vector *>()); 739 740 for (${ident}_Event event = ${ident}_Event_FIRST; 741 event < ${ident}_Event_NUM; ++event) { 742 743 Stats::Vector *t = new Stats::Vector(); 744 t->init(m_num_controllers); 745 t->name(name() + "." + ${ident}_State_to_string(state) + 746 "." + ${ident}_Event_to_string(event)); 747 748 t->flags(Stats::pdf | Stats::total | Stats::oneline | 749 Stats::nozero); 750 transVec[state].push_back(t); 751 } 752 } 753 } 754} 755 756void 757$c_ident::collateStats() 758{ 759 for (${ident}_Event event = ${ident}_Event_FIRST; 760 event < ${ident}_Event_NUM; ++event) { 761 for (unsigned int i = 0; i < m_num_controllers; ++i) { 762 std::map<uint32_t, AbstractController *>::iterator it = 763 g_abs_controls[MachineType_${ident}].find(i); 764 assert(it != g_abs_controls[MachineType_${ident}].end()); 765 (*eventVec[event])[i] = 766 (($c_ident *)(*it).second)->getEventCount(event); 767 } 768 } 769 770 for (${ident}_State state = ${ident}_State_FIRST; 771 state < ${ident}_State_NUM; ++state) { 772 773 for (${ident}_Event event = ${ident}_Event_FIRST; 774 event < ${ident}_Event_NUM; ++event) { 775 776 for (unsigned int i = 0; i < m_num_controllers; ++i) { 777 std::map<uint32_t, AbstractController *>::iterator it = 778 g_abs_controls[MachineType_${ident}].find(i); 779 assert(it != g_abs_controls[MachineType_${ident}].end()); 780 (*transVec[state][event])[i] = 781 (($c_ident *)(*it).second)->getTransitionCount(state, event); 782 } 783 } 784 } 785} 786 787void 788$c_ident::countTransition(${ident}_State state, ${ident}_Event event) 789{ 790 assert(m_possible[state][event]); 791 m_counters[state][event]++; 792 m_event_counters[event]++; 793} 794void 795$c_ident::possibleTransition(${ident}_State state, 796 ${ident}_Event event) 797{ 798 m_possible[state][event] = true; 799} 800 801uint64 802$c_ident::getEventCount(${ident}_Event event) 803{ 804 return m_event_counters[event]; 805} 806 807bool 808$c_ident::isPossible(${ident}_State state, ${ident}_Event event) 809{ 810 return m_possible[state][event]; 811} 812 813uint64 814$c_ident::getTransitionCount(${ident}_State state, 815 ${ident}_Event event) 816{ 817 return m_counters[state][event]; 818} 819 |
820int 821$c_ident::getNumControllers() 822{ 823 return m_num_controllers; 824} 825 826MessageBuffer* 827$c_ident::getMandatoryQueue() const --- 51 unchanged lines hidden (view full) --- 879$c_ident::printStats(ostream& out) const 880{ 881''') 882 # 883 # Cache and Memory Controllers have specific profilers associated with 884 # them. Print out these stats before dumping state transition stats. 885 # 886 for param in self.config_parameters: |
887 if param.type_ast.type.ident == "DirectoryMemory": |
888 assert(param.pointer) 889 code(' m_${{param.ident}}_ptr->printStats(out);') 890 891 code(''' |
892} 893 |
894void $c_ident::clearStats() 895{ 896 for (int state = 0; state < ${ident}_State_NUM; state++) { 897 for (int event = 0; event < ${ident}_Event_NUM; event++) { 898 m_counters[state][event] = 0; 899 } 900 } |
901 |
902 for (int event = 0; event < ${ident}_Event_NUM; event++) { 903 m_event_counters[event] = 0; 904 } 905 |
906 AbstractController::clearStats(); 907} 908''') 909 910 if self.EntryType != None: 911 code(''' 912 913// Set and Reset for cache_entry variable --- 322 unchanged lines hidden (view full) --- 1236 code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);') 1237 else: 1238 code('doTransitionWorker(event, state, next_state, addr);') 1239 1240 code(''' 1241 if (result == TransitionResult_Valid) { 1242 DPRINTF(RubyGenerated, "next_state: %s\\n", 1243 ${ident}_State_to_string(next_state)); |
1244 countTransition(state, event); |
1245 DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n", 1246 curTick(), m_version, "${ident}", 1247 ${ident}_Event_to_string(event), 1248 ${ident}_State_to_string(state), 1249 ${ident}_State_to_string(next_state), 1250 addr, GET_TRANSITION_COMMENT()); 1251 1252 CLEAR_TRANSITION_COMMENT(); --- 145 unchanged lines hidden (view full) --- 1398 "%s time: %d addr: %s event: %s state: %s\\n", 1399 name(), curCycle(), addr, event, state); 1400 } 1401 return TransitionResult_Valid; 1402} 1403''') 1404 code.write(path, "%s_Transitions.cc" % self.ident) 1405 |
1406 |
1407 # ************************** 1408 # ******* HTML Files ******* 1409 # ************************** 1410 def frameRef(self, click_href, click_target, over_href, over_num, text): 1411 code = self.symtab.codeFormatter(fix_newlines=False) 1412 code("""<A href=\"$click_href\" target=\"$click_target\" onmouseover=\" 1413 if (parent.frames[$over_num].location != parent.location + '$over_href') { 1414 parent.frames[$over_num].location='$over_href' --- 172 unchanged lines hidden --- |