1# Copyright (c) 2015 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Redistribution and use in source and binary forms, with or without 14# modification, are permitted provided that the following conditions are 15# met: redistributions of source code must retain the above copyright 16# notice, this list of conditions and the following disclaimer; 17# redistributions in binary form must reproduce the above copyright 18# notice, this list of conditions and the following disclaimer in the 19# documentation and/or other materials provided with the distribution; 20# neither the name of the copyright holders nor the names of its 21# contributors may be used to endorse or promote products derived from 22# this software without specific prior written permission. 23# 24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# 36# Authors: David Guillen Fandos 37
| 1# Copyright (c) 2015 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Redistribution and use in source and binary forms, with or without 14# modification, are permitted provided that the following conditions are 15# met: redistributions of source code must retain the above copyright 16# notice, this list of conditions and the following disclaimer; 17# redistributions in binary form must reproduce the above copyright 18# notice, this list of conditions and the following disclaimer in the 19# documentation and/or other materials provided with the distribution; 20# neither the name of the copyright holders nor the names of its 21# contributors may be used to endorse or promote products derived from 22# this software without specific prior written permission. 23# 24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# 36# Authors: David Guillen Fandos 37
|
38from m5.SimObject import SimObject
| 38from m5.SimObject import *
|
39from ClockedObject import ClockedObject 40 41from m5.params import * 42from m5.objects import ThermalDomain 43 44 45# Represents a thermal node 46class ThermalNode(SimObject): 47 type = 'ThermalNode' 48 cxx_header = "sim/power/thermal_node.hh" 49 50# Represents a thermal resistor 51class ThermalResistor(SimObject): 52 type = 'ThermalResistor' 53 cxx_header = "sim/power/thermal_model.hh" 54
| 39from ClockedObject import ClockedObject 40 41from m5.params import * 42from m5.objects import ThermalDomain 43 44 45# Represents a thermal node 46class ThermalNode(SimObject): 47 type = 'ThermalNode' 48 cxx_header = "sim/power/thermal_node.hh" 49 50# Represents a thermal resistor 51class ThermalResistor(SimObject): 52 type = 'ThermalResistor' 53 cxx_header = "sim/power/thermal_model.hh" 54
|
55 @classmethod 56 def export_methods(cls, code): 57 code(''' 58 void setNodes(ThermalNode * node1, ThermalNode * node2); 59''')
| 55 cxx_exports = [ 56 PyBindMethod("setNodes"), 57 ]
|
60 61 resistance = Param.Float(1.0, "Thermal resistance, expressed in Kelvin per Watt") 62 63# Represents a thermal capacitor 64class ThermalCapacitor(SimObject): 65 type = 'ThermalCapacitor' 66 cxx_header = "sim/power/thermal_model.hh" 67
| 58 59 resistance = Param.Float(1.0, "Thermal resistance, expressed in Kelvin per Watt") 60 61# Represents a thermal capacitor 62class ThermalCapacitor(SimObject): 63 type = 'ThermalCapacitor' 64 cxx_header = "sim/power/thermal_model.hh" 65
|
68 @classmethod 69 def export_methods(cls, code): 70 code(''' 71 void setNodes(ThermalNode * node1, ThermalNode * node2); 72''')
| 66 cxx_exports = [ 67 PyBindMethod("setNodes"), 68 ]
|
73 74 capacitance = Param.Float(1.0, "Thermal capacitance, expressed in Joules per Kelvin") 75 76# Represents a fixed temperature node (ie. air) 77class ThermalReference(SimObject, object): 78 type = 'ThermalReference' 79 cxx_header = "sim/power/thermal_model.hh" 80
| 69 70 capacitance = Param.Float(1.0, "Thermal capacitance, expressed in Joules per Kelvin") 71 72# Represents a fixed temperature node (ie. air) 73class ThermalReference(SimObject, object): 74 type = 'ThermalReference' 75 cxx_header = "sim/power/thermal_model.hh" 76
|
81 @classmethod 82 def export_methods(cls, code): 83 code(''' 84 void setNode(ThermalNode * node); 85''')
| 77 cxx_exports = [ 78 PyBindMethod("setNode"), 79 ]
|
86 87 # Static temperature which may change over time 88 temperature = Param.Float(25.0, "Operational temperature in Celsius") 89 90 91# Represents a thermal capacitor 92class ThermalModel(ClockedObject): 93 type = 'ThermalModel' 94 cxx_header = "sim/power/thermal_model.hh" 95
| 80 81 # Static temperature which may change over time 82 temperature = Param.Float(25.0, "Operational temperature in Celsius") 83 84 85# Represents a thermal capacitor 86class ThermalModel(ClockedObject): 87 type = 'ThermalModel' 88 cxx_header = "sim/power/thermal_model.hh" 89
|
96 @classmethod 97 def export_methods(cls, code): 98 code(''' 99 void addCapacitor(ThermalCapacitor *obj); 100 void addResistor(ThermalResistor *obj); 101 void addReference(ThermalReference *obj); 102 void addDomain(ThermalDomain *obj); 103 void addNode(ThermalNode *obj); 104 void doStep(); 105''')
| 90 cxx_exports = [ 91 PyBindMethod("addCapacitor"), 92 PyBindMethod("addResistor"), 93 PyBindMethod("addReference"), 94 PyBindMethod("addDomain"), 95 PyBindMethod("addNode"), 96 PyBindMethod("doStep"), 97 ]
|
106 107 step = Param.Float(0.01, "Simulation step (in seconds) for thermal simulation") 108 109 def populate(self): 110 if not hasattr(self,"_capacitors"): self._capacitors = [] 111 if not hasattr(self,"_resistors"): self._resistors = [] 112 if not hasattr(self,"_domains"): self._domains = [] 113 if not hasattr(self,"_references"): self._references = [] 114 if not hasattr(self,"_nodes"): self._nodes = [] 115 116 def init(self): 117 self.populate() 118 119 for ref, node in self._references: 120 ref.getCCObject().setNode(node.getCCObject()) 121 self.getCCObject().addReference(ref.getCCObject()) 122 123 for dom, node in self._domains: 124 dom.getCCObject().setNode(node.getCCObject()) 125 self.getCCObject().addDomain(dom.getCCObject()) 126 127 for cap, node1, node2 in self._capacitors: 128 cap.getCCObject().setNodes(node1.getCCObject(), node2.getCCObject()) 129 self.getCCObject().addCapacitor(cap.getCCObject()) 130 131 for res, node1, node2 in self._resistors: 132 res.getCCObject().setNodes(node1.getCCObject(), node2.getCCObject()) 133 self.getCCObject().addResistor(res.getCCObject()) 134 135 for node in self._nodes: 136 self.getCCObject().addNode(node.getCCObject()) 137 138 def addCapacitor(self, cap, node1, node2): 139 self.populate() 140 self._capacitors.append( (cap, node1, node2) ) 141 self._parent.thermal_components.append(cap) 142 self.addNodes(node1,node2) 143 144 def addResistor(self, res, node1, node2): 145 self.populate() 146 self._resistors.append( (res, node1, node2) ) 147 self._parent.thermal_components.append(res) 148 self.addNodes(node1,node2) 149 150 def addReference(self, ref, node): 151 self.populate() 152 self._references.append( (ref, node) ) 153 self._parent.thermal_components.append(ref) 154 self.addNodes(node) 155 156 def addDomain(self, dom, node): 157 self.populate() 158 self._domains.append( (dom, node) ) 159 self.addNodes(node) 160 161 def addNodes(self, *nodes): 162 for node in nodes: 163 if node not in self._nodes: 164 self._nodes.append(node) 165 self._parent.thermal_components.append(node) 166 167 def doStep(self): 168 self.getCCObject().doStep()
| 98 99 step = Param.Float(0.01, "Simulation step (in seconds) for thermal simulation") 100 101 def populate(self): 102 if not hasattr(self,"_capacitors"): self._capacitors = [] 103 if not hasattr(self,"_resistors"): self._resistors = [] 104 if not hasattr(self,"_domains"): self._domains = [] 105 if not hasattr(self,"_references"): self._references = [] 106 if not hasattr(self,"_nodes"): self._nodes = [] 107 108 def init(self): 109 self.populate() 110 111 for ref, node in self._references: 112 ref.getCCObject().setNode(node.getCCObject()) 113 self.getCCObject().addReference(ref.getCCObject()) 114 115 for dom, node in self._domains: 116 dom.getCCObject().setNode(node.getCCObject()) 117 self.getCCObject().addDomain(dom.getCCObject()) 118 119 for cap, node1, node2 in self._capacitors: 120 cap.getCCObject().setNodes(node1.getCCObject(), node2.getCCObject()) 121 self.getCCObject().addCapacitor(cap.getCCObject()) 122 123 for res, node1, node2 in self._resistors: 124 res.getCCObject().setNodes(node1.getCCObject(), node2.getCCObject()) 125 self.getCCObject().addResistor(res.getCCObject()) 126 127 for node in self._nodes: 128 self.getCCObject().addNode(node.getCCObject()) 129 130 def addCapacitor(self, cap, node1, node2): 131 self.populate() 132 self._capacitors.append( (cap, node1, node2) ) 133 self._parent.thermal_components.append(cap) 134 self.addNodes(node1,node2) 135 136 def addResistor(self, res, node1, node2): 137 self.populate() 138 self._resistors.append( (res, node1, node2) ) 139 self._parent.thermal_components.append(res) 140 self.addNodes(node1,node2) 141 142 def addReference(self, ref, node): 143 self.populate() 144 self._references.append( (ref, node) ) 145 self._parent.thermal_components.append(ref) 146 self.addNodes(node) 147 148 def addDomain(self, dom, node): 149 self.populate() 150 self._domains.append( (dom, node) ) 151 self.addNodes(node) 152 153 def addNodes(self, *nodes): 154 for node in nodes: 155 if node not in self._nodes: 156 self._nodes.append(node) 157 self._parent.thermal_components.append(node) 158 159 def doStep(self): 160 self.getCCObject().doStep()
|