StateMachine.py (11061:25b53a7195f7) | StateMachine.py (11084:ee2fcca7b58a) |
---|---|
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# Copyright (c) 2013 Advanced Micro Devices, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 29 unchanged lines hidden (view full) --- 38 "uint32_t" : "UInt32", 39 "std::string": "String", 40 "bool": "Bool", 41 "CacheMemory": "RubyCache", 42 "WireBuffer": "RubyWireBuffer", 43 "Sequencer": "RubySequencer", 44 "DirectoryMemory": "RubyDirectoryMemory", 45 "MemoryControl": "MemoryControl", | 1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# Copyright (c) 2013 Advanced Micro Devices, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 29 unchanged lines hidden (view full) --- 38 "uint32_t" : "UInt32", 39 "std::string": "String", 40 "bool": "Bool", 41 "CacheMemory": "RubyCache", 42 "WireBuffer": "RubyWireBuffer", 43 "Sequencer": "RubySequencer", 44 "DirectoryMemory": "RubyDirectoryMemory", 45 "MemoryControl": "MemoryControl", |
46 "MessageBuffer": "MessageBuffer", |
|
46 "DMASequencer": "DMASequencer", 47 "Prefetcher":"Prefetcher", 48 "Cycles":"Cycles", 49 } 50 51class StateMachine(Symbol): 52 def __init__(self, symtab, ident, location, pairs, config_parameters): 53 super(StateMachine, self).__init__(symtab, ident, location, pairs) --- 175 unchanged lines hidden (view full) --- 229''') 230 code.indent() 231 for param in self.config_parameters: 232 dflt_str = '' 233 234 if param.rvalue is not None: 235 dflt_str = str(param.rvalue.inline()) + ', ' 236 | 47 "DMASequencer": "DMASequencer", 48 "Prefetcher":"Prefetcher", 49 "Cycles":"Cycles", 50 } 51 52class StateMachine(Symbol): 53 def __init__(self, symtab, ident, location, pairs, config_parameters): 54 super(StateMachine, self).__init__(symtab, ident, location, pairs) --- 175 unchanged lines hidden (view full) --- 230''') 231 code.indent() 232 for param in self.config_parameters: 233 dflt_str = '' 234 235 if param.rvalue is not None: 236 dflt_str = str(param.rvalue.inline()) + ', ' 237 |
237 if param.type_ast.type.c_ident == "MessageBuffer": 238 # The MessageBuffer MUST be instantiated in the protocol config 239 code('${{param.ident}} = Param.MessageBuffer("")') 240 241 elif python_class_map.has_key(param.type_ast.type.c_ident): | 238 if python_class_map.has_key(param.type_ast.type.c_ident): |
242 python_type = python_class_map[param.type_ast.type.c_ident] 243 code('${{param.ident}} = Param.${{python_type}}(${dflt_str}"")') 244 245 else: 246 self.error("Unknown c++ to python class conversion for c++ " \ 247 "type: '%s'. Please update the python_class_map " \ 248 "in StateMachine.py", param.type_ast.type.c_ident) 249 | 239 python_type = python_class_map[param.type_ast.type.c_ident] 240 code('${{param.ident}} = Param.${{python_type}}(${dflt_str}"")') 241 242 else: 243 self.error("Unknown c++ to python class conversion for c++ " \ 244 "type: '%s'. Please update the python_class_map " \ 245 "in StateMachine.py", param.type_ast.type.c_ident) 246 |
250 # Also add any MessageBuffers declared internally to the controller 251 # Note: This includes mandatory and memory queues 252 for var in self.objects: 253 if var.type.c_ident == "MessageBuffer": 254 code('${{var.ident}} = Param.MessageBuffer("")') 255 | |
256 code.dedent() 257 code.write(path, '%s.py' % py_ident) 258 259 260 def printControllerHH(self, path): 261 '''Output the method declarations for the class declaration''' 262 code = self.symtab.codeFormatter() 263 ident = self.ident --- 34 unchanged lines hidden (view full) --- 298class $c_ident : public AbstractController 299{ 300 public: 301 typedef ${c_ident}Params Params; 302 $c_ident(const Params *p); 303 static int getNumControllers(); 304 void init(); 305 | 247 code.dedent() 248 code.write(path, '%s.py' % py_ident) 249 250 251 def printControllerHH(self, path): 252 '''Output the method declarations for the class declaration''' 253 code = self.symtab.codeFormatter() 254 ident = self.ident --- 34 unchanged lines hidden (view full) --- 289class $c_ident : public AbstractController 290{ 291 public: 292 typedef ${c_ident}Params Params; 293 $c_ident(const Params *p); 294 static int getNumControllers(); 295 void init(); 296 |
306 MessageBuffer* getMandatoryQueue() const; 307 MessageBuffer* getMemoryQueue() const; | 297 MessageBuffer *getMandatoryQueue() const; 298 MessageBuffer *getMemoryQueue() const; |
308 void initNetQueues(); 309 310 void print(std::ostream& out) const; 311 void wakeup(); 312 void resetStats(); 313 void regStats(); 314 void collateStats(); 315 --- 218 unchanged lines hidden (view full) --- 534 if param.pointer: 535 code('m_${{param.ident}}_ptr = p->${{param.ident}};') 536 else: 537 code('m_${{param.ident}} = p->${{param.ident}};') 538 539 if re.compile("sequencer").search(param.ident): 540 code('m_${{param.ident}}_ptr->setController(this);') 541 | 299 void initNetQueues(); 300 301 void print(std::ostream& out) const; 302 void wakeup(); 303 void resetStats(); 304 void regStats(); 305 void collateStats(); 306 --- 218 unchanged lines hidden (view full) --- 525 if param.pointer: 526 code('m_${{param.ident}}_ptr = p->${{param.ident}};') 527 else: 528 code('m_${{param.ident}} = p->${{param.ident}};') 529 530 if re.compile("sequencer").search(param.ident): 531 code('m_${{param.ident}}_ptr->setController(this);') 532 |
542 for var in self.objects: 543 # Some MessageBuffers (e.g. mandatory and memory queues) are 544 # instantiated internally to StateMachines but exposed to 545 # components outside SLICC, so make sure to set up this 546 # controller as their receivers 547 if var.type.c_ident == "MessageBuffer": 548 code(''' 549m_${{var.ident}}_ptr = p->${{var.ident}}; 550m_${{var.ident}}_ptr->setReceiver(this); 551''') 552 | |
553 code(''' 554 555for (int state = 0; state < ${ident}_State_NUM; state++) { 556 for (int event = 0; event < ${ident}_Event_NUM; event++) { 557 m_possible[state][event] = false; 558 m_counters[state][event] = 0; 559 } 560} --- 15 unchanged lines hidden (view full) --- 576 code.indent() 577 578 # set for maintaining the vnet, direction pairs already seen for this 579 # machine. This map helps in implementing the check for avoiding 580 # multiple message buffers being mapped to the same vnet. 581 vnet_dir_set = set() 582 583 for var in self.config_parameters: | 533 code(''' 534 535for (int state = 0; state < ${ident}_State_NUM; state++) { 536 for (int event = 0; event < ${ident}_Event_NUM; event++) { 537 m_possible[state][event] = false; 538 m_counters[state][event] = 0; 539 } 540} --- 15 unchanged lines hidden (view full) --- 556 code.indent() 557 558 # set for maintaining the vnet, direction pairs already seen for this 559 # machine. This map helps in implementing the check for avoiding 560 # multiple message buffers being mapped to the same vnet. 561 vnet_dir_set = set() 562 563 for var in self.config_parameters: |
564 vid = "m_%s_ptr" % var.ident |
|
584 if "network" in var: 585 vtype = var.type_ast.type | 565 if "network" in var: 566 vtype = var.type_ast.type |
586 vid = "m_%s_ptr" % var.ident 587 | |
588 code('assert($vid != NULL);') 589 590 # Network port object 591 network = var["network"] 592 593 if "virtual_network" in var: 594 vnet = var["virtual_network"] 595 vnet_type = var["vnet_type"] --- 10 unchanged lines hidden (view full) --- 606 code('$vid->setSender(this);') 607 else: 608 code('$vid->setReceiver(this);') 609 610 # Set Priority 611 if "rank" in var: 612 code('$vid->setPriority(${{var["rank"]}})') 613 | 567 code('assert($vid != NULL);') 568 569 # Network port object 570 network = var["network"] 571 572 if "virtual_network" in var: 573 vnet = var["virtual_network"] 574 vnet_type = var["vnet_type"] --- 10 unchanged lines hidden (view full) --- 585 code('$vid->setSender(this);') 586 else: 587 code('$vid->setReceiver(this);') 588 589 # Set Priority 590 if "rank" in var: 591 code('$vid->setPriority(${{var["rank"]}})') 592 |
593 else: 594 if var.type_ast.type.c_ident == "MessageBuffer": 595 code('$vid->setReceiver(this);') 596 if var.ident.find("triggerQueue") >= 0: 597 code('$vid->setSender(this);') 598 elif var.ident.find("optionalQueue") >= 0: 599 code('$vid->setSender(this);') 600 |
|
614 code.dedent() 615 code(''' 616} 617 618void 619$c_ident::init() 620{ 621 // initialize objects --- 8 unchanged lines hidden (view full) --- 630 if "network" not in var: 631 # Not a network port object 632 if "primitive" in vtype: 633 code('$vid = new ${{vtype.c_ident}};') 634 if "default" in var: 635 code('(*$vid) = ${{var["default"]}};') 636 else: 637 # Normal Object | 601 code.dedent() 602 code(''' 603} 604 605void 606$c_ident::init() 607{ 608 // initialize objects --- 8 unchanged lines hidden (view full) --- 617 if "network" not in var: 618 # Not a network port object 619 if "primitive" in vtype: 620 code('$vid = new ${{vtype.c_ident}};') 621 if "default" in var: 622 code('(*$vid) = ${{var["default"]}};') 623 else: 624 # Normal Object |
638 if var.type.c_ident != "MessageBuffer": 639 th = var.get("template", "") 640 expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 641 args = "" 642 if "non_obj" not in vtype and not vtype.isEnumeration: 643 args = var.get("constructor", "") 644 code('$expr($args);') | 625 th = var.get("template", "") 626 expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 627 args = "" 628 if "non_obj" not in vtype and not vtype.isEnumeration: 629 args = var.get("constructor", "") |
645 | 630 |
631 code('$expr($args);') |
|
646 code('assert($vid != NULL);') 647 648 if "default" in var: 649 code('*$vid = ${{var["default"]}}; // Object default') 650 elif "default" in vtype: 651 comment = "Type %s default" % vtype.ident 652 code('*$vid = ${{vtype["default"]}}; // $comment') 653 | 632 code('assert($vid != NULL);') 633 634 if "default" in var: 635 code('*$vid = ${{var["default"]}}; // Object default') 636 elif "default" in vtype: 637 comment = "Type %s default" % vtype.ident 638 code('*$vid = ${{vtype["default"]}}; // $comment') 639 |
654 # Set Priority 655 if vtype.isBuffer and "rank" in var: 656 code('$vid->setPriority(${{var["rank"]}});') 657 658 # Set sender and receiver for trigger queue 659 if var.ident.find("triggerQueue") >= 0: 660 code('$vid->setSender(this);') 661 code('$vid->setReceiver(this);') 662 elif vtype.c_ident == "TimerTable": | 640 if vtype.c_ident == "TimerTable": |
663 code('$vid->setClockObj(this);') | 641 code('$vid->setClockObj(this);') |
664 elif var.ident.find("optionalQueue") >= 0: 665 code('$vid->setSender(this);') 666 code('$vid->setReceiver(this);') | |
667 668 # Set the prefetchers 669 code() 670 for prefetcher in self.prefetchers: 671 code('${{prefetcher.code}}.setController(this);') 672 673 code() 674 for port in self.in_ports: --- 904 unchanged lines hidden --- | 642 643 # Set the prefetchers 644 code() 645 for prefetcher in self.prefetchers: 646 code('${{prefetcher.code}}.setController(this);') 647 648 code() 649 for port in self.in_ports: --- 904 unchanged lines hidden --- |