StateMachine.py (6881:5a61a8a9009a) | StateMachine.py (6882:898047a3672c) |
---|---|
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; --- 17 unchanged lines hidden (view full) --- 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28from m5.util import code_formatter, orderdict 29 30from slicc.symbols.Symbol import Symbol 31from slicc.symbols.Var import Var 32import slicc.generate.html as html 33 | 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; --- 17 unchanged lines hidden (view full) --- 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28from m5.util import code_formatter, 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", 37 "CacheMemory": "RubyCache", 38 "Sequencer": "RubySequencer", 39 "DirectoryMemory": "RubyDirectoryMemory", 40 "MemoryControl": "RubyMemoryControl", 41 } 42 |
|
34class StateMachine(Symbol): 35 def __init__(self, symtab, ident, location, pairs, config_parameters): 36 super(StateMachine, self).__init__(symtab, ident, location, pairs) 37 self.table = None 38 self.config_parameters = config_parameters 39 for param in config_parameters: | 43class StateMachine(Symbol): 44 def __init__(self, symtab, ident, location, pairs, config_parameters): 45 super(StateMachine, self).__init__(symtab, ident, location, pairs) 46 self.table = None 47 self.config_parameters = config_parameters 48 for param in config_parameters: |
40 var = Var(symtab, param.name, location, param.type_ast.type, 41 "m_%s" % param.name, {}, self) | 49 if param.pointer: 50 var = Var(symtab, param.name, location, param.type_ast.type, 51 "(*m_%s_ptr)" % param.name, {}, self) 52 else: 53 var = Var(symtab, param.name, location, param.type_ast.type, 54 "m_%s" % param.name, {}, self) |
42 self.symtab.registerSym(param.name, var) 43 44 self.states = orderdict() 45 self.events = orderdict() 46 self.actions = orderdict() 47 self.transitions = [] 48 self.in_ports = [] 49 self.functions = [] --- 98 unchanged lines hidden (view full) --- 148class $py_ident(RubyController): 149 type = '$py_ident' 150''') 151 code.indent() 152 for param in self.config_parameters: 153 dflt_str = '' 154 if param.default is not None: 155 dflt_str = str(param.default) + ', ' | 55 self.symtab.registerSym(param.name, var) 56 57 self.states = orderdict() 58 self.events = orderdict() 59 self.actions = orderdict() 60 self.transitions = [] 61 self.in_ports = [] 62 self.functions = [] --- 98 unchanged lines hidden (view full) --- 161class $py_ident(RubyController): 162 type = '$py_ident' 163''') 164 code.indent() 165 for param in self.config_parameters: 166 dflt_str = '' 167 if param.default is not None: 168 dflt_str = str(param.default) + ', ' |
156 code('${{param.name}} = Param.Int(${dflt_str}"")') | 169 if python_class_map.has_key(param.type_ast.type.c_ident): 170 python_type = python_class_map[param.type_ast.type.c_ident] 171 code('${{param.name}} = Param.${{python_type}}(${dflt_str}"")') 172 else: 173 self.error("Unknown c++ to python class conversion for c++ " \ 174 "type: '%s'. Please update the python_class_map " \ 175 "in StateMachine.py", param.type_ast.type.c_ident) |
157 code.dedent() 158 code.write(path, '%s.py' % py_ident) 159 160 161 def printControllerHH(self, path): 162 '''Output the method declarations for the class declaration''' 163 code = code_formatter() 164 ident = self.ident --- 53 unchanged lines hidden (view full) --- 218 void blockOnQueue(Address addr, MessageBuffer* port); 219 void unblock(Address addr); 220private: 221''') 222 223 code.indent() 224 # added by SS 225 for param in self.config_parameters: | 176 code.dedent() 177 code.write(path, '%s.py' % py_ident) 178 179 180 def printControllerHH(self, path): 181 '''Output the method declarations for the class declaration''' 182 code = code_formatter() 183 ident = self.ident --- 53 unchanged lines hidden (view full) --- 237 void blockOnQueue(Address addr, MessageBuffer* port); 238 void unblock(Address addr); 239private: 240''') 241 242 code.indent() 243 # added by SS 244 for param in self.config_parameters: |
226 code('int m_${{param.ident}};') | 245 if param.pointer: 246 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;') 247 else: 248 code('${{param.type_ast.type}} m_${{param.ident}};') |
227 228 code(''' 229int m_number_of_TBEs; 230 231TransitionResult doTransition(${ident}_Event event, ${ident}_State state, const Address& addr); // in ${ident}_Transitions.cc 232TransitionResult doTransitionWorker(${ident}_Event event, ${ident}_State state, ${ident}_State& next_state, const Address& addr); // in ${ident}_Transitions.cc 233string m_name; 234int m_transitions_per_cycle; --- 88 unchanged lines hidden (view full) --- 323{ 324 m_version = p->version; 325 m_transitions_per_cycle = p->transitions_per_cycle; 326 m_buffer_size = p->buffer_size; 327 m_recycle_latency = p->recycle_latency; 328 m_number_of_TBEs = p->number_of_TBEs; 329''') 330 code.indent() | 249 250 code(''' 251int m_number_of_TBEs; 252 253TransitionResult doTransition(${ident}_Event event, ${ident}_State state, const Address& addr); // in ${ident}_Transitions.cc 254TransitionResult doTransitionWorker(${ident}_Event event, ${ident}_State state, ${ident}_State& next_state, const Address& addr); // in ${ident}_Transitions.cc 255string m_name; 256int m_transitions_per_cycle; --- 88 unchanged lines hidden (view full) --- 345{ 346 m_version = p->version; 347 m_transitions_per_cycle = p->transitions_per_cycle; 348 m_buffer_size = p->buffer_size; 349 m_recycle_latency = p->recycle_latency; 350 m_number_of_TBEs = p->number_of_TBEs; 351''') 352 code.indent() |
353 354 # 355 # After initializing the universal machine parameters, initialize the 356 # this machines config parameters. Also detemine if these configuration 357 # params include a sequencer. This information will be used later for 358 # contecting the sequencer back to the L1 cache controller. 359 # 360 contains_sequencer = False |
|
331 for param in self.config_parameters: | 361 for param in self.config_parameters: |
332 code('m_${{param.name}} = p->${{param.name}};') | 362 if param.name == "sequencer": 363 contains_sequencer = True 364 if param.pointer: 365 code('m_${{param.name}}_ptr = p->${{param.name}};') 366 else: 367 code('m_${{param.name}} = p->${{param.name}};') |
333 | 368 |
369 # 370 # For the l1 cache controller, add the special atomic support which 371 # includes passing the sequencer a pointer to the controller. 372 # 373 if self.ident == "L1Cache": 374 if not contains_sequencer: 375 self.error("The L1Cache controller must include the sequencer " \ 376 "configuration parameter") 377 378 code(''' 379m_sequencer_ptr->setController(this); 380''') 381 |
|
334 code('m_num_controllers++;') 335 for var in self.objects: 336 if var.ident.find("mandatoryQueue") >= 0: 337 code('m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();') 338 339 code.dedent() 340 code(''' 341} --- 705 unchanged lines hidden --- | 382 code('m_num_controllers++;') 383 for var in self.objects: 384 if var.ident.find("mandatoryQueue") >= 0: 385 code('m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();') 386 387 code.dedent() 388 code(''' 389} --- 705 unchanged lines hidden --- |