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 |
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 |
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 *);') |
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 |
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''') |
533 |
534 code(''' 535if (p->peer != NULL) 536 connectWithPeer(p->peer); 537''') |
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 |
571 if var.ident.find("mandatoryQueue") < 0: |
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"] |
612 |
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(''' |
619$vid = m_net_ptr->get${network}NetQueue(m_version + base, $ordered, $vnet, "$vnet_type"); |
620assert($vid != NULL); |
621''') 622 |
623 # Set the end 624 if network == "To": 625 code('$vid->setSender(this);') 626 else: 627 code('$vid->setReceiver(this);') |
628 |
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 |
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 --- |