SimObject.py (7526:4bb5f5207617) | SimObject.py (7527:fe90827a663f) |
---|---|
1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 516 unchanged lines hidden (view full) --- 525 return self._get_port_ref(attr) 526 527 if self._values.has_key(attr): 528 return self._values[attr] 529 530 # If the attribute exists on the C++ object, transparently 531 # forward the reference there. This is typically used for 532 # SWIG-wrapped methods such as init(), regStats(), | 1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 516 unchanged lines hidden (view full) --- 525 return self._get_port_ref(attr) 526 527 if self._values.has_key(attr): 528 return self._values[attr] 529 530 # If the attribute exists on the C++ object, transparently 531 # forward the reference there. This is typically used for 532 # SWIG-wrapped methods such as init(), regStats(), |
533 # regFormulas(), resetStats(), and startup(). | 533 # regFormulas(), resetStats(), startup(), drain(), and 534 # resume(). |
534 if self._ccObject and hasattr(self._ccObject, attr): 535 return getattr(self._ccObject, attr) 536 537 raise AttributeError, "object '%s' has no attribute '%s'" \ 538 % (self.__class__.__name__, attr) 539 540 # Set attribute (called on foo.attr = value when foo is an 541 # instance of class cls). --- 113 unchanged lines hidden (view full) --- 655 raise AttributeError, \ 656 'parent.any matched more than one: %s and %s' % (found_obj.path, match_obj.path) 657 found_obj = match_obj 658 return found_obj, found_obj != None 659 660 def unproxy(self, base): 661 return self 662 | 535 if self._ccObject and hasattr(self._ccObject, attr): 536 return getattr(self._ccObject, attr) 537 538 raise AttributeError, "object '%s' has no attribute '%s'" \ 539 % (self.__class__.__name__, attr) 540 541 # Set attribute (called on foo.attr = value when foo is an 542 # instance of class cls). --- 113 unchanged lines hidden (view full) --- 656 raise AttributeError, \ 657 'parent.any matched more than one: %s and %s' % (found_obj.path, match_obj.path) 658 found_obj = match_obj 659 return found_obj, found_obj != None 660 661 def unproxy(self, base): 662 return self 663 |
663 def unproxy_all(self): | 664 def unproxyParams(self): |
664 for param in self._params.iterkeys(): 665 value = self._values.get(param) 666 if value != None and isproxy(value): 667 try: 668 value = value.unproxy(self) 669 except: 670 print "Error in unproxying param '%s' of %s" % \ 671 (param, self.path()) --- 4 unchanged lines hidden (view full) --- 676 # vector ports are done in a deterministic fashion. 677 port_names = self._ports.keys() 678 port_names.sort() 679 for port_name in port_names: 680 port = self._port_refs.get(port_name) 681 if port != None: 682 port.unproxy(self) 683 | 665 for param in self._params.iterkeys(): 666 value = self._values.get(param) 667 if value != None and isproxy(value): 668 try: 669 value = value.unproxy(self) 670 except: 671 print "Error in unproxying param '%s' of %s" % \ 672 (param, self.path()) --- 4 unchanged lines hidden (view full) --- 677 # vector ports are done in a deterministic fashion. 678 port_names = self._ports.keys() 679 port_names.sort() 680 for port_name in port_names: 681 port = self._port_refs.get(port_name) 682 if port != None: 683 port.unproxy(self) 684 |
684 # Unproxy children in sorted order for determinism also. 685 child_names = self._children.keys() 686 child_names.sort() 687 for child in child_names: 688 self._children[child].unproxy_all() 689 | |
690 def print_ini(self, ini_file): 691 print >>ini_file, '[' + self.path() + ']' # .ini section header 692 693 instanceDict[self.path()] = self 694 695 if hasattr(self, 'type'): 696 print >>ini_file, 'type=%s' % self.type 697 --- 14 unchanged lines hidden (view full) --- 712 port_names.sort() 713 for port_name in port_names: 714 port = self._port_refs.get(port_name, None) 715 if port != None: 716 print >>ini_file, '%s=%s' % (port_name, port.ini_str()) 717 718 print >>ini_file # blank line between objects 719 | 685 def print_ini(self, ini_file): 686 print >>ini_file, '[' + self.path() + ']' # .ini section header 687 688 instanceDict[self.path()] = self 689 690 if hasattr(self, 'type'): 691 print >>ini_file, 'type=%s' % self.type 692 --- 14 unchanged lines hidden (view full) --- 707 port_names.sort() 708 for port_name in port_names: 709 port = self._port_refs.get(port_name, None) 710 if port != None: 711 print >>ini_file, '%s=%s' % (port_name, port.ini_str()) 712 713 print >>ini_file # blank line between objects 714 |
720 for child in child_names: 721 self._children[child].print_ini(ini_file) 722 | |
723 def getCCParams(self): 724 if self._ccParams: 725 return self._ccParams 726 727 cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type) 728 cc_params = cc_params_struct() 729 cc_params.pyobj = self 730 cc_params.name = str(self) --- 38 unchanged lines hidden (view full) --- 769 self._ccObject = -1 770 params = self.getCCParams() 771 self._ccObject = params.create() 772 elif self._ccObject == -1: 773 raise RuntimeError, "%s: Cycle found in configuration hierarchy." \ 774 % self.path() 775 return self._ccObject 776 | 715 def getCCParams(self): 716 if self._ccParams: 717 return self._ccParams 718 719 cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type) 720 cc_params = cc_params_struct() 721 cc_params.pyobj = self 722 cc_params.name = str(self) --- 38 unchanged lines hidden (view full) --- 761 self._ccObject = -1 762 params = self.getCCParams() 763 self._ccObject = params.create() 764 elif self._ccObject == -1: 765 raise RuntimeError, "%s: Cycle found in configuration hierarchy." \ 766 % self.path() 767 return self._ccObject 768 |
777 # Call C++ to create C++ object corresponding to this object and 778 # (recursively) all its children | 769 def descendants(self): 770 yield self 771 for child in self._children.itervalues(): 772 for obj in child.descendants(): 773 yield obj 774 775 # Call C++ to create C++ object corresponding to this object |
779 def createCCObject(self): 780 self.getCCParams() 781 self.getCCObject() # force creation | 776 def createCCObject(self): 777 self.getCCParams() 778 self.getCCObject() # force creation |
782 for child in self._children.itervalues(): 783 child.createCCObject() | |
784 785 def getValue(self): 786 return self.getCCObject() 787 788 # Create C++ port connections corresponding to the connections in | 779 780 def getValue(self): 781 return self.getCCObject() 782 783 # Create C++ port connections corresponding to the connections in |
789 # _port_refs (& recursively for all children) | 784 # _port_refs |
790 def connectPorts(self): 791 for portRef in self._port_refs.itervalues(): 792 portRef.ccConnect() | 785 def connectPorts(self): 786 for portRef in self._port_refs.itervalues(): 787 portRef.ccConnect() |
793 for child in self._children.itervalues(): 794 child.connectPorts() | |
795 | 788 |
796 def startDrain(self, drain_event, recursive): 797 count = 0 798 if isinstance(self, SimObject): 799 count += self._ccObject.drain(drain_event) 800 if recursive: 801 for child in self._children.itervalues(): 802 count += child.startDrain(drain_event, True) 803 return count 804 805 def resume(self): 806 if isinstance(self, SimObject): 807 self._ccObject.resume() 808 for child in self._children.itervalues(): 809 child.resume() 810 | |
811 def getMemoryMode(self): 812 if not isinstance(self, m5.objects.System): 813 return None 814 815 return self._ccObject.getMemoryMode() 816 817 def changeTiming(self, mode): 818 if isinstance(self, m5.objects.System): 819 # i don't know if there's a better way to do this - calling 820 # setMemoryMode directly from self._ccObject results in calling 821 # SimObject::setMemoryMode, not the System::setMemoryMode 822 self._ccObject.setMemoryMode(mode) | 789 def getMemoryMode(self): 790 if not isinstance(self, m5.objects.System): 791 return None 792 793 return self._ccObject.getMemoryMode() 794 795 def changeTiming(self, mode): 796 if isinstance(self, m5.objects.System): 797 # i don't know if there's a better way to do this - calling 798 # setMemoryMode directly from self._ccObject results in calling 799 # SimObject::setMemoryMode, not the System::setMemoryMode 800 self._ccObject.setMemoryMode(mode) |
823 for child in self._children.itervalues(): 824 child.changeTiming(mode) | |
825 826 def takeOverFrom(self, old_cpu): 827 self._ccObject.takeOverFrom(old_cpu._ccObject) 828 829 # generate output file for 'dot' to display as a pretty graph. 830 # this code is currently broken. 831 def outputDot(self, dot): 832 label = "{%s|" % self.path --- 80 unchanged lines hidden --- | 801 802 def takeOverFrom(self, old_cpu): 803 self._ccObject.takeOverFrom(old_cpu._ccObject) 804 805 # generate output file for 'dot' to display as a pretty graph. 806 # this code is currently broken. 807 def outputDot(self, dot): 808 label = "{%s|" % self.path --- 80 unchanged lines hidden --- |