thermal_model.hh (11442:b31738224fb0) | thermal_model.hh (11800:54436a1784dc) |
---|---|
1/* 2 * Copyright (c) 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are 16 * met: redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer; 18 * redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution; 21 * neither the name of the copyright holders nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: David Guillen Fandos 38 */ 39 40#ifndef __SIM_THERMAL_MODEL_HH__ 41#define __SIM_THERMAL_MODEL_HH__ 42 43#include <vector> 44 | 1/* 2 * Copyright (c) 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are 16 * met: redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer; 18 * redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution; 21 * neither the name of the copyright holders nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: David Guillen Fandos 38 */ 39 40#ifndef __SIM_THERMAL_MODEL_HH__ 41#define __SIM_THERMAL_MODEL_HH__ 42 43#include <vector> 44 |
45#include "base/statistics.hh" | |
46#include "params/ThermalCapacitor.hh" 47#include "params/ThermalModel.hh" 48#include "params/ThermalReference.hh" 49#include "params/ThermalResistor.hh" 50#include "sim/clocked_object.hh" 51#include "sim/power/thermal_entity.hh" 52#include "sim/sim_object.hh" 53 54class ThermalDomain; 55 56 57/** 58 * A ThermalNode is used to connect thermal entities, such as 59 * resistors, capacitors, references and domains. It is the circuital 60 * equivalent to a voltage node. 61 */ 62class ThermalNode : public SimObject 63{ 64 public: 65 typedef SimObjectParams Params; 66 ThermalNode(const Params *p); 67 68 int id; 69 bool isref; 70 double temp; 71}; 72 73/** 74 * A ThermalResistor is used to model a thermal resistance between two 75 * thermal domains. This domains can be either a reference (fixed temp.) or 76 * a heat producer (power source). 77 */ 78class ThermalResistor : public SimObject, public ThermalEntity 79{ 80 public: 81 typedef ThermalResistorParams Params; 82 ThermalResistor(const Params *p); 83 84 void serialize(CheckpointOut &cp) const override; 85 void unserialize(CheckpointIn &cp) override; 86 87 void setNodes(ThermalNode * n1, ThermalNode * n2) { 88 node1 = n1; 89 node2 = n2; 90 } 91 92 LinearEquation getEquation(ThermalNode * tn, unsigned n, 93 double step) const override; 94 95 private: 96 /* Resistance value in K/W */ 97 double _resistance; 98 /* Nodes connected to the resistor */ 99 ThermalNode * node1, * node2; 100}; 101 102/** 103 * A ThermalCapacitor is used to model a thermal capacitance between two 104 * thermal domains. This domains can be either a reference (fixed temp.) or 105 * a heat producer (power source). 106 */ 107class ThermalCapacitor : public SimObject, public ThermalEntity 108{ 109 public: 110 typedef ThermalCapacitorParams Params; 111 ThermalCapacitor(const Params *p); 112 113 void serialize(CheckpointOut &cp) const override; 114 void unserialize(CheckpointIn &cp) override; 115 116 LinearEquation getEquation(ThermalNode * tn, unsigned n, 117 double step) const override; 118 119 void setNodes(ThermalNode * n1, ThermalNode * n2) { 120 node1 = n1; 121 node2 = n2; 122 } 123 124 private: 125 /* Capacitance value in J/K */ 126 double _capacitance; 127 /* Nodes connected to the resistor */ 128 ThermalNode * node1, * node2; 129}; 130 131/** 132 * A ThermalReference is a thermal domain with fixed temperature. 133 * It's the homologue to the voltage source in a circuit. 134 */ 135class ThermalReference : public SimObject, public ThermalEntity 136{ 137 public: 138 typedef ThermalReferenceParams Params; 139 ThermalReference(const Params *p); 140 141 void setNode(ThermalNode * n) { 142 node = n; 143 } 144 145 LinearEquation getEquation(ThermalNode * tn, unsigned n, 146 double step) const override; 147 148 void serialize(CheckpointOut &cp) const override; 149 void unserialize(CheckpointIn &cp) override; 150 151 /* Fixed temperature value in centigrate degrees */ 152 double _temperature; 153 /* Nodes connected to the resistor */ 154 ThermalNode * node; 155}; 156 157 158/** 159 * A ThermalModel is the element which ties all thermal objects 160 * together and provides the thermal solver to the system. 161 * It is reponsible for updating temperature for all Thermal 162 * Domains over time by reading power from simobjects. 163 */ 164class ThermalModel : public ClockedObject 165{ 166 public: 167 typedef ThermalModelParams Params; 168 ThermalModel(const Params *p); 169 170 void addDomain(ThermalDomain * d); 171 void addReference(ThermalReference * r); 172 void addCapacitor(ThermalCapacitor * c); 173 void addResistor(ThermalResistor * r); 174 175 void addNode(ThermalNode * n) { nodes.push_back(n); } 176 177 double getTemp() const; 178 179 void startup() override; 180 void doStep(); 181 182 void serialize(CheckpointOut &cp) const override; 183 void unserialize(CheckpointIn &cp) override; 184 private: 185 186 /* Keep track of all components used for the thermal model */ 187 std::vector <ThermalDomain *> domains; 188 std::vector <ThermalReference *> references; 189 std::vector <ThermalCapacitor *> capacitors; 190 std::vector <ThermalResistor *> resistors; 191 192 std::vector <ThermalEntity *> entities; 193 194 /* Keep a list of the instantiated nodes */ 195 std::vector <ThermalNode*> nodes; 196 std::vector <ThermalNode*> eq_nodes; 197 198 /** Stepping event to update the model values */ 199 EventWrapper<ThermalModel, &ThermalModel::doStep> stepEvent; 200 201 /** Step in seconds for thermal updates */ 202 double _step; 203 204}; 205 206#endif | 45#include "params/ThermalCapacitor.hh" 46#include "params/ThermalModel.hh" 47#include "params/ThermalReference.hh" 48#include "params/ThermalResistor.hh" 49#include "sim/clocked_object.hh" 50#include "sim/power/thermal_entity.hh" 51#include "sim/sim_object.hh" 52 53class ThermalDomain; 54 55 56/** 57 * A ThermalNode is used to connect thermal entities, such as 58 * resistors, capacitors, references and domains. It is the circuital 59 * equivalent to a voltage node. 60 */ 61class ThermalNode : public SimObject 62{ 63 public: 64 typedef SimObjectParams Params; 65 ThermalNode(const Params *p); 66 67 int id; 68 bool isref; 69 double temp; 70}; 71 72/** 73 * A ThermalResistor is used to model a thermal resistance between two 74 * thermal domains. This domains can be either a reference (fixed temp.) or 75 * a heat producer (power source). 76 */ 77class ThermalResistor : public SimObject, public ThermalEntity 78{ 79 public: 80 typedef ThermalResistorParams Params; 81 ThermalResistor(const Params *p); 82 83 void serialize(CheckpointOut &cp) const override; 84 void unserialize(CheckpointIn &cp) override; 85 86 void setNodes(ThermalNode * n1, ThermalNode * n2) { 87 node1 = n1; 88 node2 = n2; 89 } 90 91 LinearEquation getEquation(ThermalNode * tn, unsigned n, 92 double step) const override; 93 94 private: 95 /* Resistance value in K/W */ 96 double _resistance; 97 /* Nodes connected to the resistor */ 98 ThermalNode * node1, * node2; 99}; 100 101/** 102 * A ThermalCapacitor is used to model a thermal capacitance between two 103 * thermal domains. This domains can be either a reference (fixed temp.) or 104 * a heat producer (power source). 105 */ 106class ThermalCapacitor : public SimObject, public ThermalEntity 107{ 108 public: 109 typedef ThermalCapacitorParams Params; 110 ThermalCapacitor(const Params *p); 111 112 void serialize(CheckpointOut &cp) const override; 113 void unserialize(CheckpointIn &cp) override; 114 115 LinearEquation getEquation(ThermalNode * tn, unsigned n, 116 double step) const override; 117 118 void setNodes(ThermalNode * n1, ThermalNode * n2) { 119 node1 = n1; 120 node2 = n2; 121 } 122 123 private: 124 /* Capacitance value in J/K */ 125 double _capacitance; 126 /* Nodes connected to the resistor */ 127 ThermalNode * node1, * node2; 128}; 129 130/** 131 * A ThermalReference is a thermal domain with fixed temperature. 132 * It's the homologue to the voltage source in a circuit. 133 */ 134class ThermalReference : public SimObject, public ThermalEntity 135{ 136 public: 137 typedef ThermalReferenceParams Params; 138 ThermalReference(const Params *p); 139 140 void setNode(ThermalNode * n) { 141 node = n; 142 } 143 144 LinearEquation getEquation(ThermalNode * tn, unsigned n, 145 double step) const override; 146 147 void serialize(CheckpointOut &cp) const override; 148 void unserialize(CheckpointIn &cp) override; 149 150 /* Fixed temperature value in centigrate degrees */ 151 double _temperature; 152 /* Nodes connected to the resistor */ 153 ThermalNode * node; 154}; 155 156 157/** 158 * A ThermalModel is the element which ties all thermal objects 159 * together and provides the thermal solver to the system. 160 * It is reponsible for updating temperature for all Thermal 161 * Domains over time by reading power from simobjects. 162 */ 163class ThermalModel : public ClockedObject 164{ 165 public: 166 typedef ThermalModelParams Params; 167 ThermalModel(const Params *p); 168 169 void addDomain(ThermalDomain * d); 170 void addReference(ThermalReference * r); 171 void addCapacitor(ThermalCapacitor * c); 172 void addResistor(ThermalResistor * r); 173 174 void addNode(ThermalNode * n) { nodes.push_back(n); } 175 176 double getTemp() const; 177 178 void startup() override; 179 void doStep(); 180 181 void serialize(CheckpointOut &cp) const override; 182 void unserialize(CheckpointIn &cp) override; 183 private: 184 185 /* Keep track of all components used for the thermal model */ 186 std::vector <ThermalDomain *> domains; 187 std::vector <ThermalReference *> references; 188 std::vector <ThermalCapacitor *> capacitors; 189 std::vector <ThermalResistor *> resistors; 190 191 std::vector <ThermalEntity *> entities; 192 193 /* Keep a list of the instantiated nodes */ 194 std::vector <ThermalNode*> nodes; 195 std::vector <ThermalNode*> eq_nodes; 196 197 /** Stepping event to update the model values */ 198 EventWrapper<ThermalModel, &ThermalModel::doStep> stepEvent; 199 200 /** Step in seconds for thermal updates */ 201 double _step; 202 203}; 204 205#endif |