Deleted Added
sdiff udiff text old ( 6969:1ab268977bbb ) new ( 6999:f226c098c393 )
full compact
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;

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

20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28from m5.util import orderdict
29
30from slicc.symbols.Symbol import Symbol
31from slicc.symbols.Var import Var
32import slicc.generate.html as html
33
34python_class_map = {"int": "Int",
35 "string": "String",
36 "bool": "Bool",

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

145 self.printCWakeup(path)
146 self.printProfilerCC(path)
147 self.printProfilerHH(path)
148
149 for func in self.functions:
150 func.writeCodeFiles(path)
151
152 def printControllerPython(self, path):
153 code = self.symtab.codeFormatter()
154 ident = self.ident
155 py_ident = "%s_Controller" % ident
156 c_ident = "%s_Controller" % self.ident
157 code('''
158from m5.params import *
159from m5.SimObject import SimObject
160from Controller import RubyController
161

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

175 "type: '%s'. Please update the python_class_map " \
176 "in StateMachine.py", param.type_ast.type.c_ident)
177 code.dedent()
178 code.write(path, '%s.py' % py_ident)
179
180
181 def printControllerHH(self, path):
182 '''Output the method declarations for the class declaration'''
183 code = self.symtab.codeFormatter()
184 ident = self.ident
185 c_ident = "%s_Controller" % self.ident
186
187 self.message_buffer_names = []
188
189 code('''
190/** \\file $ident.hh
191 *

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

296 code.dedent()
297 code('};')
298 code('#endif // ${ident}_CONTROLLER_H')
299 code.write(path, '%s.hh' % c_ident)
300
301 def printControllerCC(self, path):
302 '''Output the actions for performing the actions'''
303
304 code = self.symtab.codeFormatter()
305 ident = self.ident
306 c_ident = "%s_Controller" % self.ident
307
308 code('''
309/** \\file $ident.cc
310 *
311 * Auto generated C++ code started by $__file__:$__line__
312 * Created by slicc definition of Module "${{self.short}}"

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

636}
637
638''')
639 code.write(path, "%s.cc" % c_ident)
640
641 def printCWakeup(self, path):
642 '''Output the wakeup loop for the events'''
643
644 code = self.symtab.codeFormatter()
645 ident = self.ident
646
647 code('''
648// Auto generated C++ code started by $__file__:$__line__
649// ${ident}: ${{self.short}}
650
651#include "mem/ruby/common/Global.hh"
652#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"

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

691}
692''')
693
694 code.write(path, "%s_Wakeup.cc" % self.ident)
695
696 def printCSwitch(self, path):
697 '''Output switch statement for transition table'''
698
699 code = self.symtab.codeFormatter()
700 ident = self.ident
701
702 code('''
703// Auto generated C++ code started by $__file__:$__line__
704// ${ident}: ${{self.short}}
705
706#include "mem/ruby/common/Global.hh"
707#include "mem/protocol/${ident}_Controller.hh"

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

773
774 # This map will allow suppress generating duplicate code
775 cases = orderdict()
776
777 for trans in self.transitions:
778 case_string = "%s_State_%s, %s_Event_%s" % \
779 (self.ident, trans.state.ident, self.ident, trans.event.ident)
780
781 case = self.symtab.codeFormatter()
782 # Only set next_state if it changes
783 if trans.state != trans.nextState:
784 ns_ident = trans.nextState.ident
785 case('next_state = ${ident}_State_${ns_ident};')
786
787 actions = trans.actions
788
789 # Check for resources

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

848 ERROR_MSG(\"Invalid transition\");
849 }
850 return TransitionResult_Valid;
851}
852''')
853 code.write(path, "%s_Transitions.cc" % self.ident)
854
855 def printProfilerHH(self, path):
856 code = self.symtab.codeFormatter()
857 ident = self.ident
858
859 code('''
860// Auto generated C++ code started by $__file__:$__line__
861// ${ident}: ${{self.short}}
862
863#ifndef ${ident}_PROFILER_H
864#define ${ident}_PROFILER_H

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

883 int m_version;
884};
885
886#endif // ${ident}_PROFILER_H
887''')
888 code.write(path, "%s_Profiler.hh" % self.ident)
889
890 def printProfilerCC(self, path):
891 code = self.symtab.codeFormatter()
892 ident = self.ident
893
894 code('''
895// Auto generated C++ code started by $__file__:$__line__
896// ${ident}: ${{self.short}}
897
898#include "mem/protocol/${ident}_Profiler.hh"
899

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

962''')
963 code.write(path, "%s_Profiler.cc" % self.ident)
964
965 # **************************
966 # ******* HTML Files *******
967 # **************************
968 def frameRef(self, click_href, click_target, over_href, over_target_num,
969 text):
970 code = self.symtab.codeFormatter(fix_newlines=False)
971 code("""<A href=\"$click_href\" target=\"$click_target\" onMouseOver=\"if (parent.frames[$over_target_num].location != parent.location + '$over_href') { parent.frames[$over_target_num].location='$over_href' }\" >${{html.formatShorthand(text)}}</A>""")
972 return str(code)
973
974 def writeHTMLFiles(self, path):
975 # Create table with no row hilighted
976 self.printHTMLTransitions(path, None)
977
978 # Generate transition tables

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

993
994 # Generate event descriptions
995 for event in self.events.itervalues():
996 name = "%s_Event_%s.html" % (self.ident, event.ident)
997 code = html.createSymbol(event, "Event")
998 code.write(path, name)
999
1000 def printHTMLTransitions(self, path, active_state):
1001 code = self.symtab.codeFormatter()
1002
1003 code('''
1004<HTML><BODY link="blue" vlink="blue">
1005
1006<H1 align="center">${{html.formatShorthand(self.short)}}:
1007''')
1008 code.indent()
1009 for i,machine in enumerate(self.symtab.getAllType(StateMachine)):

--- 131 unchanged lines hidden ---