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; --- 148 unchanged lines hidden (view full) --- 157 for action in self.actions.itervalues(): 158 if not action.used: 159 error_msg = "Unused action: %s" % action.ident 160 if "desc" in action: 161 error_msg += ", " + action.desc 162 action.warning(error_msg) 163 self.table = table 164 |
165 def writeCodeFiles(self, path, includes): |
166 self.printControllerPython(path) 167 self.printControllerHH(path) |
168 self.printControllerCC(path, includes) |
169 self.printCSwitch(path) |
170 self.printCWakeup(path, includes) |
171 self.printProfilerCC(path) 172 self.printProfilerHH(path) 173 self.printProfileDumperCC(path) 174 self.printProfileDumperHH(path) 175 176 def printControllerPython(self, path): 177 code = self.symtab.codeFormatter() 178 ident = self.ident --- 215 unchanged lines hidden (view full) --- 394 if var.type.ident == "MessageBuffer": 395 self.message_buffer_names.append("m_%s_ptr" % var.c_ident) 396 397 code.dedent() 398 code('};') 399 code('#endif // __${ident}_CONTROLLER_H__') 400 code.write(path, '%s.hh' % c_ident) 401 |
402 def printControllerCC(self, path, includes): |
403 '''Output the actions for performing the actions''' 404 405 code = self.symtab.codeFormatter() 406 ident = self.ident 407 c_ident = "%s_Controller" % self.ident 408 409 code(''' 410/** \\file $c_ident.cc --- 13 unchanged lines hidden (view full) --- 424#include "base/cprintf.hh" 425#include "debug/RubyGenerated.hh" 426#include "debug/RubySlicc.hh" 427#include "mem/protocol/${ident}_Controller.hh" 428#include "mem/protocol/${ident}_Event.hh" 429#include "mem/protocol/${ident}_State.hh" 430#include "mem/protocol/Types.hh" 431#include "mem/ruby/common/Global.hh" |
432#include "mem/ruby/system/System.hh" |
433''') 434 for include_path in includes: 435 code('#include "${{include_path}}"') |
436 |
437 code(''' 438 |
439using namespace std; 440''') 441 442 # include object classes 443 seen_types = set() 444 for var in self.objects: 445 if var.type.ident not in seen_types and not var.type.isPrimitive: 446 code('#include "mem/protocol/${{var.type.c_ident}}.hh"') --- 540 unchanged lines hidden (view full) --- 987} 988 989''') 990 for func in self.functions: 991 code(func.generateCode()) 992 993 code.write(path, "%s.cc" % c_ident) 994 |
995 def printCWakeup(self, path, includes): |
996 '''Output the wakeup loop for the events''' 997 998 code = self.symtab.codeFormatter() 999 ident = self.ident 1000 1001 outputRequest_types = True 1002 if len(self.request_types) == 0: 1003 outputRequest_types = False --- 15 unchanged lines hidden (view full) --- 1019''') 1020 1021 if outputRequest_types: 1022 code('''#include "mem/protocol/${ident}_RequestType.hh"''') 1023 1024 code(''' 1025#include "mem/protocol/Types.hh" 1026#include "mem/ruby/common/Global.hh" |
1027#include "mem/ruby/system/System.hh" |
1028''') |
1029 |
1030 1031 for include_path in includes: 1032 code('#include "${{include_path}}"') 1033 1034 code(''' 1035 |
1036using namespace std; 1037 1038void 1039${ident}_Controller::wakeup() 1040{ 1041 int counter = 0; 1042 while (true) { 1043 // Some cases will put us into an infinite loop without this limit --- 671 unchanged lines hidden --- |