StateMachine.py (9171:ae88ecf37145) StateMachine.py (9219:258753d3bc47)
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
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):
165 def writeCodeFiles(self, path, includes):
166 self.printControllerPython(path)
167 self.printControllerHH(path)
166 self.printControllerPython(path)
167 self.printControllerHH(path)
168 self.printControllerCC(path)
168 self.printControllerCC(path, includes)
169 self.printCSwitch(path)
169 self.printCSwitch(path)
170 self.printCWakeup(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
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):
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"
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/slicc_interface/RubySlicc_includes.hh"
433#include "mem/ruby/system/System.hh"
432#include "mem/ruby/system/System.hh"
433''')
434 for include_path in includes:
435 code('#include "${{include_path}}"')
434
436
437 code('''
438
435using namespace std;
436''')
437
438 # include object classes
439 seen_types = set()
440 for var in self.objects:
441 if var.type.ident not in seen_types and not var.type.isPrimitive:
442 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')

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

983}
984
985''')
986 for func in self.functions:
987 code(func.generateCode())
988
989 code.write(path, "%s.cc" % c_ident)
990
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
991 def printCWakeup(self, path):
995 def printCWakeup(self, path, includes):
992 '''Output the wakeup loop for the events'''
993
994 code = self.symtab.codeFormatter()
995 ident = self.ident
996
997 outputRequest_types = True
998 if len(self.request_types) == 0:
999 outputRequest_types = False

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

1015''')
1016
1017 if outputRequest_types:
1018 code('''#include "mem/protocol/${ident}_RequestType.hh"''')
1019
1020 code('''
1021#include "mem/protocol/Types.hh"
1022#include "mem/ruby/common/Global.hh"
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"
1023#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
1024#include "mem/ruby/system/System.hh"
1027#include "mem/ruby/system/System.hh"
1028''')
1025
1029
1030
1031 for include_path in includes:
1032 code('#include "${{include_path}}"')
1033
1034 code('''
1035
1026using namespace std;
1027
1028void
1029${ident}_Controller::wakeup()
1030{
1031 int counter = 0;
1032 while (true) {
1033 // Some cases will put us into an infinite loop without this limit

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