StateMachine.py (9561:bc043a0455e3) | StateMachine.py (9595:470016acf37d) |
---|---|
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; --- 225 unchanged lines hidden (view full) --- 234#include "mem/protocol/Types.hh" 235#include "mem/ruby/common/Consumer.hh" 236#include "mem/ruby/common/Global.hh" 237#include "mem/ruby/slicc_interface/AbstractController.hh" 238#include "params/$c_ident.hh" 239''') 240 241 seen_types = set() | 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; --- 225 unchanged lines hidden (view full) --- 234#include "mem/protocol/Types.hh" 235#include "mem/ruby/common/Consumer.hh" 236#include "mem/ruby/common/Global.hh" 237#include "mem/ruby/slicc_interface/AbstractController.hh" 238#include "params/$c_ident.hh" 239''') 240 241 seen_types = set() |
242 has_peer = False |
|
242 for var in self.objects: 243 if var.type.ident not in seen_types and not var.type.isPrimitive: 244 code('#include "mem/protocol/${{var.type.c_ident}}.hh"') | 243 for var in self.objects: 244 if var.type.ident not in seen_types and not var.type.isPrimitive: 245 code('#include "mem/protocol/${{var.type.c_ident}}.hh"') |
246 if "network" in var and "physical_network" in var: 247 has_peer = True |
|
245 seen_types.add(var.type.ident) 246 247 # for adding information to the protocol debug trace 248 code(''' 249extern std::stringstream ${ident}_transitionComment; 250 251class $c_ident : public AbstractController 252{ --- 73 unchanged lines hidden (view full) --- 326// Internal functions 327''') 328 329 for func in self.functions: 330 proto = func.prototype 331 if proto: 332 code('$proto') 333 | 248 seen_types.add(var.type.ident) 249 250 # for adding information to the protocol debug trace 251 code(''' 252extern std::stringstream ${ident}_transitionComment; 253 254class $c_ident : public AbstractController 255{ --- 73 unchanged lines hidden (view full) --- 329// Internal functions 330''') 331 332 for func in self.functions: 333 proto = func.prototype 334 if proto: 335 code('$proto') 336 |
337 if has_peer: 338 code('void getQueuesFromPeer(AbstractController *);') |
|
334 if self.EntryType != None: 335 code(''' 336 337// Set and Reset for cache_entry variable 338void set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry); 339void unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr); 340''') 341 --- 41 unchanged lines hidden (view full) --- 383 code.write(path, '%s.hh' % c_ident) 384 385 def printControllerCC(self, path, includes): 386 '''Output the actions for performing the actions''' 387 388 code = self.symtab.codeFormatter() 389 ident = self.ident 390 c_ident = "%s_Controller" % self.ident | 339 if self.EntryType != None: 340 code(''' 341 342// Set and Reset for cache_entry variable 343void set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry); 344void unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr); 345''') 346 --- 41 unchanged lines hidden (view full) --- 388 code.write(path, '%s.hh' % c_ident) 389 390 def printControllerCC(self, path, includes): 391 '''Output the actions for performing the actions''' 392 393 code = self.symtab.codeFormatter() 394 ident = self.ident 395 c_ident = "%s_Controller" % self.ident |
396 has_peer = False |
|
391 392 code(''' 393/** \\file $c_ident.cc 394 * 395 * Auto generated C++ code started by $__file__:$__line__ 396 * Created by slicc definition of Module "${{self.short}}" 397 */ 398 --- 111 unchanged lines hidden (view full) --- 510 511 code('m_num_controllers++;') 512 for var in self.objects: 513 if var.ident.find("mandatoryQueue") >= 0: 514 code(''' 515m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 516m_${{var.c_ident}}_ptr->setReceiver(this); 517''') | 397 398 code(''' 399/** \\file $c_ident.cc 400 * 401 * Auto generated C++ code started by $__file__:$__line__ 402 * Created by slicc definition of Module "${{self.short}}" 403 */ 404 --- 111 unchanged lines hidden (view full) --- 516 517 code('m_num_controllers++;') 518 for var in self.objects: 519 if var.ident.find("mandatoryQueue") >= 0: 520 code(''' 521m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 522m_${{var.c_ident}}_ptr->setReceiver(this); 523''') |
524 else: 525 if "network" in var and "physical_network" in var and \ 526 var["network"] == "To": 527 has_peer = True 528 code(''' 529m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 530peerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr; 531m_${{var.c_ident}}_ptr->setSender(this); 532''') |
|
518 | 533 |
534 code(''' 535if (p->peer != NULL) 536 connectWithPeer(p->peer); 537''') |
|
519 code.dedent() 520 code(''' 521} 522 523void 524$c_ident::init() 525{ 526 MachineType machine_type; --- 17 unchanged lines hidden (view full) --- 544 if "network" not in var: 545 # Not a network port object 546 if "primitive" in vtype: 547 code('$vid = new ${{vtype.c_ident}};') 548 if "default" in var: 549 code('(*$vid) = ${{var["default"]}};') 550 else: 551 # Normal Object | 538 code.dedent() 539 code(''' 540} 541 542void 543$c_ident::init() 544{ 545 MachineType machine_type; --- 17 unchanged lines hidden (view full) --- 563 if "network" not in var: 564 # Not a network port object 565 if "primitive" in vtype: 566 code('$vid = new ${{vtype.c_ident}};') 567 if "default" in var: 568 code('(*$vid) = ${{var["default"]}};') 569 else: 570 # Normal Object |
552 # added by SS 553 if "factory" in var: 554 code('$vid = ${{var["factory"]}};') 555 elif var.ident.find("mandatoryQueue") < 0: | 571 if var.ident.find("mandatoryQueue") < 0: |
556 th = var.get("template", "") 557 expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 558 args = "" 559 if "non_obj" not in vtype and not vtype.isEnumeration: 560 args = var.get("constructor", "") 561 code('$expr($args);') 562 563 code('assert($vid != NULL);') --- 24 unchanged lines hidden (view full) --- 588 code('$vid->setReceiver(this);') 589 elif vtype.c_ident == "TimerTable": 590 code('$vid->setClockObj(this);') 591 592 else: 593 # Network port object 594 network = var["network"] 595 ordered = var["ordered"] | 572 th = var.get("template", "") 573 expr = "%s = new %s%s" % (vid, vtype.c_ident, th) 574 args = "" 575 if "non_obj" not in vtype and not vtype.isEnumeration: 576 args = var.get("constructor", "") 577 code('$expr($args);') 578 579 code('assert($vid != NULL);') --- 24 unchanged lines hidden (view full) --- 604 code('$vid->setReceiver(this);') 605 elif vtype.c_ident == "TimerTable": 606 code('$vid->setClockObj(this);') 607 608 else: 609 # Network port object 610 network = var["network"] 611 ordered = var["ordered"] |
596 vnet = var["virtual_network"] 597 vnet_type = var["vnet_type"] | |
598 | 612 |
599 assert var.machine is not None 600 code(''' | 613 if "virtual_network" in var: 614 vnet = var["virtual_network"] 615 vnet_type = var["vnet_type"] 616 617 assert var.machine is not None 618 code(''' |
601$vid = m_net_ptr->get${network}NetQueue(m_version + base, $ordered, $vnet, "$vnet_type"); | 619$vid = m_net_ptr->get${network}NetQueue(m_version + base, $ordered, $vnet, "$vnet_type"); |
620assert($vid != NULL); |
|
602''') 603 | 621''') 622 |
604 code('assert($vid != NULL);') | 623 # Set the end 624 if network == "To": 625 code('$vid->setSender(this);') 626 else: 627 code('$vid->setReceiver(this);') |
605 | 628 |
606 # Set the end 607 if network == "To": 608 code('$vid->setSender(this);') 609 else: 610 code('$vid->setReceiver(this);') 611 | |
612 # Set ordering 613 if "ordered" in var: 614 # A buffer 615 code('$vid->setOrdering(${{var["ordered"]}});') 616 617 # Set randomization 618 if "random" in var: 619 # A buffer --- 382 unchanged lines hidden (view full) --- 1002 if vtype.isBuffer: 1003 vid = "m_%s_ptr" % var.c_ident 1004 code('num_functional_writes += $vid->functionalWrite(pkt);') 1005 code(''' 1006 return num_functional_writes; 1007} 1008''') 1009 | 629 # Set ordering 630 if "ordered" in var: 631 # A buffer 632 code('$vid->setOrdering(${{var["ordered"]}});') 633 634 # Set randomization 635 if "random" in var: 636 # A buffer --- 382 unchanged lines hidden (view full) --- 1019 if vtype.isBuffer: 1020 vid = "m_%s_ptr" % var.c_ident 1021 code('num_functional_writes += $vid->functionalWrite(pkt);') 1022 code(''' 1023 return num_functional_writes; 1024} 1025''') 1026 |
1027 # Check if this controller has a peer, if yes then write the 1028 # function for connecting to the peer. 1029 if has_peer: 1030 code(''' 1031 1032void 1033$c_ident::getQueuesFromPeer(AbstractController *peer) 1034{ 1035''') 1036 for var in self.objects: 1037 if "network" in var and "physical_network" in var and \ 1038 var["network"] == "From": 1039 code(''' 1040m_${{var.c_ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}}); 1041assert(m_${{var.c_ident}}_ptr != NULL); 1042m_${{var.c_ident}}_ptr->setReceiver(this); 1043 1044''') 1045 code('}') 1046 |
|
1010 code.write(path, "%s.cc" % c_ident) 1011 1012 def printCWakeup(self, path, includes): 1013 '''Output the wakeup loop for the events''' 1014 1015 code = self.symtab.codeFormatter() 1016 ident = self.ident 1017 --- 714 unchanged lines hidden --- | 1047 code.write(path, "%s.cc" % c_ident) 1048 1049 def printCWakeup(self, path, includes): 1050 '''Output the wakeup loop for the events''' 1051 1052 code = self.symtab.codeFormatter() 1053 ident = self.ident 1054 --- 714 unchanged lines hidden --- |