StateMachine.py (9692:67d9da312ef0) StateMachine.py (9745:884ad4638236)
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)
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 self.printProfilerCC(path)
177 self.printProfilerHH(path)
178 self.printProfileDumperCC(path)
179 self.printProfileDumperHH(path)
180
181 def printControllerPython(self, path):
182 code = self.symtab.codeFormatter()
183 ident = self.ident
184 py_ident = "%s_Controller" % ident
185 c_ident = "%s_Controller" % self.ident
186 code('''
187from m5.params import *

--- 35 unchanged lines hidden (view full) ---

223
224#ifndef __${ident}_CONTROLLER_HH__
225#define __${ident}_CONTROLLER_HH__
226
227#include <iostream>
228#include <sstream>
229#include <string>
230
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
231#include "mem/protocol/${ident}_ProfileDumper.hh"
232#include "mem/protocol/${ident}_Profiler.hh"
233#include "mem/protocol/TransitionResult.hh"
234#include "mem/protocol/Types.hh"
235#include "mem/ruby/common/Consumer.hh"
236#include "mem/ruby/common/Global.hh"
237#include "mem/ruby/slicc_interface/AbstractController.hh"
238#include "params/$c_ident.hh"
239''')
240

--- 17 unchanged lines hidden (view full) ---

258 $c_ident(const Params *p);
259 static int getNumControllers();
260 void init();
261 MessageBuffer* getMandatoryQueue() const;
262 const int & getVersion() const;
263 const std::string toString() const;
264 const std::string getName() const;
265 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
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
266 void print(std::ostream& out) const;
267 void wakeup();
268 void printStats(std::ostream& out) const;
269 void clearStats();
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
270 void blockOnQueue(Address addr, MessageBuffer* port);
271 void unblock(Address addr);
272 void recordCacheTrace(int cntrl, CacheRecorder* tr);
273 Sequencer* getSequencer() const;
274
275 bool functionalReadBuffers(PacketPtr&);
276 uint32_t functionalWriteBuffers(PacketPtr&);
277
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
278private:
279''')
280
281 code.indent()
282 # added by SS
283 for param in self.config_parameters:
284 if param.pointer:
285 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;')

--- 28 unchanged lines hidden (view full) ---

314 if self.EntryType != None:
315 code('''
316 ${{self.EntryType.c_ident}}*& m_cache_entry_ptr,
317''')
318
319 code('''
320 const Address& addr);
321
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
322static ${ident}_ProfileDumper s_profileDumper;
323${ident}_Profiler m_profiler;
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;
324static int m_num_controllers;
325
326// Internal functions
327''')
328
329 for func in self.functions:
330 proto = func.prototype
331 if proto:

--- 103 unchanged lines hidden (view full) ---

435 code('''
436$c_ident *
437${c_ident}Params::create()
438{
439 return new $c_ident(this);
440}
441
442int $c_ident::m_num_controllers = 0;
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;
443${ident}_ProfileDumper $c_ident::s_profileDumper;
451std::vector<Stats::Vector *> $c_ident::eventVec;
452std::vector<std::vector<Stats::Vector *> > $c_ident::transVec;
444
445// for adding information to the protocol debug trace
446stringstream ${ident}_transitionComment;
447#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str)
448
449/** \\brief constructor */
450$c_ident::$c_ident(const Params *p)
451 : AbstractController(p)

--- 63 unchanged lines hidden (view full) ---

515m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();
516peerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr;
517m_${{var.c_ident}}_ptr->setSender(this);
518''')
519
520 code('''
521if (p->peer != NULL)
522 connectWithPeer(p->peer);
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}
523''')
524 code.dedent()
525 code('''
526}
527
528void
529$c_ident::init()
530{
542''')
543 code.dedent()
544 code('''
545}
546
547void
548$c_ident::init()
549{
531 MachineType machine_type;
532 int base;
533 machine_type = string_to_MachineType("${{var.machine.ident}}");
534 base = MachineType_base_number(machine_type);
550 MachineType machine_type = string_to_MachineType("${{var.machine.ident}}");
551 int base = MachineType_base_number(machine_type);
535
536 m_machineID.type = MachineType_${ident};
537 m_machineID.num = m_version;
538
539 // initialize objects
552
553 m_machineID.type = MachineType_${ident};
554 m_machineID.num = m_version;
555
556 // initialize objects
540 m_profiler.setVersion(m_version);
541 s_profileDumper.registerProfiler(&m_profiler);
542
543''')
544
545 code.indent()
546 for var in self.objects:
547 vtype = var.type
548 vid = "m_%s_ptr" % var.c_ident
549 if "network" not in var:

--- 120 unchanged lines hidden (view full) ---

670 for action in trans.actions:
671 if action.ident == "z_stall":
672 stall = True
673
674 # Only possible if it is not a 'z' case
675 if not stall:
676 state = "%s_State_%s" % (self.ident, trans.state.ident)
677 event = "%s_Event_%s" % (self.ident, trans.event.ident)
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)
678 code('m_profiler.possibleTransition($state, $event);')
693 code('possibleTransition($state, $event);')
679
680 code.dedent()
681 code('''
682 AbstractController::init();
683 clearStats();
684}
685''')
686

--- 9 unchanged lines hidden (view full) ---

696
697 seq_ident = "NULL"
698 for param in self.config_parameters:
699 if param.name == "sequencer":
700 assert(param.pointer)
701 seq_ident = "m_%s_ptr" % param.name
702
703 code('''
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
704int
705$c_ident::getNumControllers()
706{
707 return m_num_controllers;
708}
709
710MessageBuffer*
711$c_ident::getMandatoryQueue() const

--- 51 unchanged lines hidden (view full) ---

763$c_ident::printStats(ostream& out) const
764{
765''')
766 #
767 # Cache and Memory Controllers have specific profilers associated with
768 # them. Print out these stats before dumping state transition stats.
769 #
770 for param in self.config_parameters:
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:
771 if param.type_ast.type.ident == "DirectoryMemory" or \
772 param.type_ast.type.ident == "MemoryControl":
887 if param.type_ast.type.ident == "DirectoryMemory":
773 assert(param.pointer)
774 code(' m_${{param.ident}}_ptr->printStats(out);')
775
776 code('''
888 assert(param.pointer)
889 code(' m_${{param.ident}}_ptr->printStats(out);')
890
891 code('''
777 if (m_version == 0) {
778 s_profileDumper.dumpStats(out);
779 }
780}
781
892}
893
782void $c_ident::clearStats() {
783''')
784 #
785 # Cache and Memory Controllers have specific profilers associated with
786 # them. These stats must be cleared too.
787 #
788 for param in self.config_parameters:
789 if param.type_ast.type.ident == "MemoryControl":
790 assert(param.pointer)
791 code(' m_${{param.ident}}_ptr->clearStats();')
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 }
792
901
793 code('''
794 m_profiler.clearStats();
902 for (int event = 0; event < ${ident}_Event_NUM; event++) {
903 m_event_counters[event] = 0;
904 }
905
795 AbstractController::clearStats();
796}
797''')
798
799 if self.EntryType != None:
800 code('''
801
802// Set and Reset for cache_entry variable

--- 322 unchanged lines hidden (view full) ---

1125 code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);')
1126 else:
1127 code('doTransitionWorker(event, state, next_state, addr);')
1128
1129 code('''
1130 if (result == TransitionResult_Valid) {
1131 DPRINTF(RubyGenerated, "next_state: %s\\n",
1132 ${ident}_State_to_string(next_state));
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));
1133 m_profiler.countTransition(state, event);
1244 countTransition(state, event);
1134 DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n",
1135 curTick(), m_version, "${ident}",
1136 ${ident}_Event_to_string(event),
1137 ${ident}_State_to_string(state),
1138 ${ident}_State_to_string(next_state),
1139 addr, GET_TRANSITION_COMMENT());
1140
1141 CLEAR_TRANSITION_COMMENT();

--- 145 unchanged lines hidden (view full) ---

1287 "%s time: %d addr: %s event: %s state: %s\\n",
1288 name(), curCycle(), addr, event, state);
1289 }
1290 return TransitionResult_Valid;
1291}
1292''')
1293 code.write(path, "%s_Transitions.cc" % self.ident)
1294
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
1295 def printProfileDumperHH(self, path):
1296 code = self.symtab.codeFormatter()
1297 ident = self.ident
1298
1406
1299 code('''
1300// Auto generated C++ code started by $__file__:$__line__
1301// ${ident}: ${{self.short}}
1302
1303#ifndef __${ident}_PROFILE_DUMPER_HH__
1304#define __${ident}_PROFILE_DUMPER_HH__
1305
1306#include <cassert>
1307#include <iostream>
1308#include <vector>
1309
1310#include "${ident}_Event.hh"
1311#include "${ident}_Profiler.hh"
1312
1313typedef std::vector<${ident}_Profiler *> ${ident}_profilers;
1314
1315class ${ident}_ProfileDumper
1316{
1317 public:
1318 ${ident}_ProfileDumper();
1319 void registerProfiler(${ident}_Profiler* profiler);
1320 void dumpStats(std::ostream& out) const;
1321
1322 private:
1323 ${ident}_profilers m_profilers;
1324};
1325
1326#endif // __${ident}_PROFILE_DUMPER_HH__
1327''')
1328 code.write(path, "%s_ProfileDumper.hh" % self.ident)
1329
1330 def printProfileDumperCC(self, path):
1331 code = self.symtab.codeFormatter()
1332 ident = self.ident
1333
1334 code('''
1335// Auto generated C++ code started by $__file__:$__line__
1336// ${ident}: ${{self.short}}
1337
1338#include "mem/protocol/${ident}_ProfileDumper.hh"
1339
1340${ident}_ProfileDumper::${ident}_ProfileDumper()
1341{
1342}
1343
1344void
1345${ident}_ProfileDumper::registerProfiler(${ident}_Profiler* profiler)
1346{
1347 if (profiler->getVersion() >= m_profilers.size())
1348 m_profilers.resize(profiler->getVersion() + 1);
1349 m_profilers[profiler->getVersion()] = profiler;
1350}
1351
1352void
1353${ident}_ProfileDumper::dumpStats(std::ostream& out) const
1354{
1355 out << " --- ${ident} ---\\n";
1356 out << " - Event Counts -\\n";
1357 for (${ident}_Event event = ${ident}_Event_FIRST;
1358 event < ${ident}_Event_NUM;
1359 ++event) {
1360 out << (${ident}_Event) event << " [";
1361 uint64 total = 0;
1362 for (int i = 0; i < m_profilers.size(); i++) {
1363 out << m_profilers[i]->getEventCount(event) << " ";
1364 total += m_profilers[i]->getEventCount(event);
1365 }
1366 out << "] " << total << "\\n";
1367 }
1368 out << "\\n";
1369 out << " - Transitions -\\n";
1370 for (${ident}_State state = ${ident}_State_FIRST;
1371 state < ${ident}_State_NUM;
1372 ++state) {
1373 for (${ident}_Event event = ${ident}_Event_FIRST;
1374 event < ${ident}_Event_NUM;
1375 ++event) {
1376 if (m_profilers[0]->isPossible(state, event)) {
1377 out << (${ident}_State) state << " "
1378 << (${ident}_Event) event << " [";
1379 uint64 total = 0;
1380 for (int i = 0; i < m_profilers.size(); i++) {
1381 out << m_profilers[i]->getTransitionCount(state, event) << " ";
1382 total += m_profilers[i]->getTransitionCount(state, event);
1383 }
1384 out << "] " << total << "\\n";
1385 }
1386 }
1387 out << "\\n";
1388 }
1389}
1390''')
1391 code.write(path, "%s_ProfileDumper.cc" % self.ident)
1392
1393 def printProfilerHH(self, path):
1394 code = self.symtab.codeFormatter()
1395 ident = self.ident
1396
1397 code('''
1398// Auto generated C++ code started by $__file__:$__line__
1399// ${ident}: ${{self.short}}
1400
1401#ifndef __${ident}_PROFILER_HH__
1402#define __${ident}_PROFILER_HH__
1403
1404#include <cassert>
1405#include <iostream>
1406
1407#include "mem/protocol/${ident}_Event.hh"
1408#include "mem/protocol/${ident}_State.hh"
1409#include "mem/ruby/common/TypeDefines.hh"
1410
1411class ${ident}_Profiler
1412{
1413 public:
1414 ${ident}_Profiler();
1415 void setVersion(int version);
1416 int getVersion();
1417 void countTransition(${ident}_State state, ${ident}_Event event);
1418 void possibleTransition(${ident}_State state, ${ident}_Event event);
1419 uint64 getEventCount(${ident}_Event event);
1420 bool isPossible(${ident}_State state, ${ident}_Event event);
1421 uint64 getTransitionCount(${ident}_State state, ${ident}_Event event);
1422 void clearStats();
1423
1424 private:
1425 int m_counters[${ident}_State_NUM][${ident}_Event_NUM];
1426 int m_event_counters[${ident}_Event_NUM];
1427 bool m_possible[${ident}_State_NUM][${ident}_Event_NUM];
1428 int m_version;
1429};
1430
1431#endif // __${ident}_PROFILER_HH__
1432''')
1433 code.write(path, "%s_Profiler.hh" % self.ident)
1434
1435 def printProfilerCC(self, path):
1436 code = self.symtab.codeFormatter()
1437 ident = self.ident
1438
1439 code('''
1440// Auto generated C++ code started by $__file__:$__line__
1441// ${ident}: ${{self.short}}
1442
1443#include <cassert>
1444
1445#include "mem/protocol/${ident}_Profiler.hh"
1446
1447${ident}_Profiler::${ident}_Profiler()
1448{
1449 for (int state = 0; state < ${ident}_State_NUM; state++) {
1450 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1451 m_possible[state][event] = false;
1452 m_counters[state][event] = 0;
1453 }
1454 }
1455 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1456 m_event_counters[event] = 0;
1457 }
1458}
1459
1460void
1461${ident}_Profiler::setVersion(int version)
1462{
1463 m_version = version;
1464}
1465
1466int
1467${ident}_Profiler::getVersion()
1468{
1469 return m_version;
1470}
1471
1472void
1473${ident}_Profiler::clearStats()
1474{
1475 for (int state = 0; state < ${ident}_State_NUM; state++) {
1476 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1477 m_counters[state][event] = 0;
1478 }
1479 }
1480
1481 for (int event = 0; event < ${ident}_Event_NUM; event++) {
1482 m_event_counters[event] = 0;
1483 }
1484}
1485void
1486${ident}_Profiler::countTransition(${ident}_State state, ${ident}_Event event)
1487{
1488 assert(m_possible[state][event]);
1489 m_counters[state][event]++;
1490 m_event_counters[event]++;
1491}
1492void
1493${ident}_Profiler::possibleTransition(${ident}_State state,
1494 ${ident}_Event event)
1495{
1496 m_possible[state][event] = true;
1497}
1498
1499uint64
1500${ident}_Profiler::getEventCount(${ident}_Event event)
1501{
1502 return m_event_counters[event];
1503}
1504
1505bool
1506${ident}_Profiler::isPossible(${ident}_State state, ${ident}_Event event)
1507{
1508 return m_possible[state][event];
1509}
1510
1511uint64
1512${ident}_Profiler::getTransitionCount(${ident}_State state,
1513 ${ident}_Event event)
1514{
1515 return m_counters[state][event];
1516}
1517
1518''')
1519 code.write(path, "%s_Profiler.cc" % self.ident)
1520
1521 # **************************
1522 # ******* HTML Files *******
1523 # **************************
1524 def frameRef(self, click_href, click_target, over_href, over_num, text):
1525 code = self.symtab.codeFormatter(fix_newlines=False)
1526 code("""<A href=\"$click_href\" target=\"$click_target\" onmouseover=\"
1527 if (parent.frames[$over_num].location != parent.location + '$over_href') {
1528 parent.frames[$over_num].location='$over_href'

--- 172 unchanged lines hidden ---
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 ---