sim: Delete authors lists from files in sim.
[gem5.git] / src / sim / voltage_domain.cc
index b5673feda249d920347d7fd5c2777fe6d06b1ddd..5a973fa5f359877abc6d86d5ebfc32d28cd6549e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014 ARM Limited
+ * Copyright (c) 2012-2014, 2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Vasileios Spiliopoulos
- *          Akash Bagdia
  */
 
+#include "sim/voltage_domain.hh"
+
 #include <algorithm>
 
 #include "base/statistics.hh"
+#include "base/trace.hh"
 #include "debug/VoltageDomain.hh"
 #include "params/VoltageDomain.hh"
 #include "sim/sim_object.hh"
-#include "sim/voltage_domain.hh"
 
 VoltageDomain::VoltageDomain(const Params *p)
-    : SimObject(p), voltageOpPoints(p->voltage), _perfLevel(0)
+    : SimObject(p), voltageOpPoints(p->voltage), _perfLevel(0), stats(*this)
 {
     fatal_if(voltageOpPoints.empty(), "DVFS: Empty set of voltages for "\
              "voltage domain %s\n", name());
 
     // Voltages must be sorted in descending order.
     fatal_if(!std::is_sorted(voltageOpPoints.begin(), voltageOpPoints.end(),
-             std::greater_equal<Voltages::value_type>()), "DVFS: Voltage "\
-             "operation points not in descending order for voltage domain "\
-             "%s\n", name());
+             std::greater<Voltages::value_type>()), "DVFS: Voltage operation "\
+             "points not in descending order for voltage domain %s\n",
+             name());
 }
 
 void
@@ -66,6 +65,11 @@ VoltageDomain::perfLevel(PerfLevel perf_level)
                   "DVFS: Requested voltage ID %d is outside the known "\
                   "range for domain %s.\n", perf_level, name());
 
+    if (perf_level == _perfLevel) {
+        // Silently ignore identical overwrites
+        return;
+    }
+
     _perfLevel = perf_level;
 
     DPRINTF(VoltageDomain, "Setting voltage to %.3fV idx: %d for domain %s\n",
@@ -120,16 +124,6 @@ VoltageDomain::startup() {
     }
 }
 
-void
-VoltageDomain::regStats()
-{
-    currentVoltage
-        .method(this, &VoltageDomain::voltage)
-        .name(params()->name + ".voltage")
-        .desc("Voltage in Volts")
-        ;
-}
-
 VoltageDomain *
 VoltageDomainParams::create()
 {
@@ -137,12 +131,21 @@ VoltageDomainParams::create()
 }
 
 void
-VoltageDomain::serialize(std::ostream &os) {
+VoltageDomain::serialize(CheckpointOut &cp) const
+{
     SERIALIZE_SCALAR(_perfLevel);
 }
 
 void
-VoltageDomain::unserialize(Checkpoint *cp, const std::string &section) {
+VoltageDomain::unserialize(CheckpointIn &cp)
+{
     UNSERIALIZE_SCALAR(_perfLevel);
     perfLevel(_perfLevel);
 }
+
+VoltageDomain::VoltageDomainStats::VoltageDomainStats(VoltageDomain &vd)
+    : Stats::Group(&vd),
+    ADD_STAT(voltage, "Voltage in Volts")
+{
+    voltage.method(&vd, &VoltageDomain::voltage);
+}