/*
- * Copyright (c) 2010,2013,2015 ARM Limited
+ * Copyright (c) 2010, 2013, 2015, 2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
// Temperature reported in uC
ThermalModel * tm = system->getThermalModel();
if (tm) {
- double t = tm->getTemp();
+ double t = tm->getTemperature().toCelsius();
if (t < 0)
warn("Temperature below zero!\n");
return fmax(0, t) * 1000000;
/*
- * Copyright (c) 2016-2017, 2020 ARM Limited
+ * Copyright (c) 2016-2017, 2020-2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
// Automatic variables:
if (name == "temp") {
- return _temp;
+ return _temp.toCelsius();
} else if (name == "voltage") {
return clocked_object->voltage();
} else if (name=="clock_period") {
/*
- * Copyright (c) 2016-2018 ARM Limited
+ * Copyright (c) 2016-2018, 2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
// The temperature passed here will be overwritten, if there is
// a thermal model present
for (auto & pms: states_pm){
- pms->setTemperature(p.ambient_temp.toCelsius());
+ pms->setTemperature(p.ambient_temp);
}
dynamicPower
}
void
-PowerModel::thermalUpdateCallback(const double & temp)
+PowerModel::thermalUpdateCallback(const Temperature &temp)
{
for (auto & pms: states_pm)
pms->setTemperature(temp);
/*
- * Copyright (c) 2016, 2018 ARM Limited
+ * Copyright (c) 2016, 2018, 2021 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#define __SIM_POWER_POWER_MODEL_HH__
#include "base/statistics.hh"
+#include "base/temperature.hh"
#include "enums/PMType.hh"
#include "params/PowerModel.hh"
#include "params/PowerModelState.hh"
/**
* Temperature update.
*
- * @param temp Current temperature of the HW part (Celsius)
+ * @param temp Current temperature of the HW part
*/
- virtual void setTemperature(double temp) { _temp = temp; }
+ virtual void setTemperature(Temperature temp) { _temp = temp; }
void setClockedObject(ClockedObject * clkobj) {
clocked_object = clkobj;
protected:
/** Current temperature */
- double _temp;
+ Temperature _temp;
/** The clocked object we belong to */
ClockedObject * clocked_object;
virtual void regProbePoints();
- void thermalUpdateCallback(const double & temp);
+ void thermalUpdateCallback(const Temperature &temp);
protected:
/** Listener class to catch thermal events */
- class ThermalProbeListener : public ProbeListenerArgBase<double>
+ class ThermalProbeListener : public ProbeListenerArgBase<Temperature>
{
public:
ThermalProbeListener(PowerModel &_pm, ProbeManager *pm,
const std::string &name)
: ProbeListenerArgBase(pm, name), pm(_pm) {}
- void notify(const double &temp)
+ void notify(const Temperature &temp)
{
pm.thermalUpdateCallback(temp);
}
#include "sim/sub_system.hh"
ThermalDomain::ThermalDomain(const Params &p)
- : SimObject(p), _initTemperature(p.initial_temperature.toCelsius()),
+ : SimObject(p), _initTemperature(p.initial_temperature),
node(NULL), subsystem(NULL),
ADD_STAT(currentTemp, "Temperature in centigrade degrees")
{
currentTemp
- .method(this, &ThermalDomain::currentTemperature);
+ .functor([this]() { return currentTemperature().toCelsius(); });
}
-double
+Temperature
ThermalDomain::currentTemperature() const
{
return node->temp;
assert(!this->subsystem);
this->subsystem = ss;
- ppThermalUpdate = new ProbePointArg<double>(subsystem->getProbeManager(),
- "thermalUpdate");
+ ppThermalUpdate = new ProbePointArg<Temperature>(
+ subsystem->getProbeManager(), "thermalUpdate");
}
void
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#include <vector>
#include "base/statistics.hh"
+#include "base/temperature.hh"
#include "params/ThermalDomain.hh"
#include "sim/power/thermal_entity.hh"
#include "sim/power/thermal_node.hh"
*
* @return Initial temperature of the domain
*/
- double initialTemperature() const { return _initTemperature; }
+ Temperature initialTemperature() const { return _initTemperature; }
/**
* Get the current temperature.
*
- * @return Initial temperature of the domain
+ * @return current temperature of the domain
*/
- double currentTemperature() const;
+ Temperature currentTemperature() const;
/** Set/Get circuit node associated with this domain */
void setNode(ThermalNode * n) { node = n; }
void setSubSystem(SubSystem * ss);
private:
- double _initTemperature;
+ const Temperature _initTemperature;
ThermalNode * node;
SubSystem * subsystem;
Stats::Value currentTemp;
/** Probe to signal for temperature changes in this domain */
- ProbePointArg<double> *ppThermalUpdate;
+ ProbePointArg<Temperature> *ppThermalUpdate;
};
* ThermalReference
*/
ThermalReference::ThermalReference(const Params &p)
- : SimObject(p), _temperature(p.temperature.toCelsius()), node(NULL)
+ : SimObject(p), _temperature(p.temperature), node(NULL)
{
}
return eq;
if (node1->isref)
- eq[eq.cnt()] += -node1->temp / _resistance;
+ eq[eq.cnt()] += -node1->temp.toKelvin() / _resistance;
else
eq[node1->id] += -1.0f / _resistance;
if (node2->isref)
- eq[eq.cnt()] += node2->temp / _resistance;
+ eq[eq.cnt()] += node2->temp.toKelvin() / _resistance;
else
eq[node2->id] += 1.0f / _resistance;
if (n != node1 && n != node2)
return eq;
- eq[eq.cnt()] += _capacitance / step * (node1->temp - node2->temp);
+ eq[eq.cnt()] += _capacitance / step *
+ (node1->temp - node2->temp).toKelvin();
if (node1->isref)
- eq[eq.cnt()] += _capacitance / step * (-node1->temp);
+ eq[eq.cnt()] += _capacitance / step * (-node1->temp.toKelvin());
else
eq[node1->id] += -1.0f * _capacitance / step;
if (node2->isref)
- eq[eq.cnt()] += _capacitance / step * (node2->temp);
+ eq[eq.cnt()] += _capacitance / step * (node2->temp.toKelvin());
else
eq[node2->id] += 1.0f * _capacitance / step;
// Get temperatures for this iteration
std::vector <double> temps = ls.solve();
for (unsigned i = 0; i < eq_nodes.size(); i++)
- eq_nodes[i]->temp = temps[i];
+ eq_nodes[i]->temp = Temperature::fromKelvin(temps[i]);
// Schedule next computation
schedule(stepEvent, curTick() + SimClock::Int::s * _step);
entities.push_back(r);
}
-double
-ThermalModel::getTemp() const
+Temperature
+ThermalModel::getTemperature() const
{
// Just pick the highest temperature
- double temp = 0;
+ Temperature temp = Temperature::fromKelvin(0.0);
for (auto & n : eq_nodes)
temp = std::max(temp, n->temp);
return temp;
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#include <vector>
+#include "base/temperature.hh"
#include "sim/clocked_object.hh"
#include "sim/power/thermal_domain.hh"
#include "sim/power/thermal_entity.hh"
LinearEquation getEquation(ThermalNode * tn, unsigned n,
double step) const override;
- /* Fixed temperature value in centigrate degrees */
- const double _temperature;
+ /* Fixed temperature value */
+ const Temperature _temperature;
/* Nodes connected to the resistor */
ThermalNode * node;
};
void addNode(ThermalNode * n) { nodes.push_back(n); }
- double getTemp() const;
+ Temperature getTemperature() const;
void startup() override;
void doStep();
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2021 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#ifndef __SIM_THERMAL_NODE_HH__
#define __SIM_THERMAL_NODE_HH__
+#include "base/temperature.hh"
#include "sim/sim_object.hh"
struct ThermalNodeParams;
int id;
bool isref;
- double temp;
+ Temperature temp;
};
#endif