voltage_domain.hh revision 11168:f98eb2da15a4
110623Smitch.hayenga@arm.com/* 29288Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited 39288Sandreas.hansson@arm.com * All rights reserved 49288Sandreas.hansson@arm.com * 59288Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 69288Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 79288Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 89288Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 99288Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 109288Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 119288Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 129288Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 139288Sandreas.hansson@arm.com * 149288Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 159288Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 169288Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 179288Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 189288Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 199288Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 209288Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 219288Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 229288Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 239288Sandreas.hansson@arm.com * this software without specific prior written permission. 249288Sandreas.hansson@arm.com * 259288Sandreas.hansson@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 269288Sandreas.hansson@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 279288Sandreas.hansson@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 289288Sandreas.hansson@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 299288Sandreas.hansson@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 309288Sandreas.hansson@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 319288Sandreas.hansson@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 329288Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 339288Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 349288Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 359288Sandreas.hansson@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 369288Sandreas.hansson@arm.com * 379288Sandreas.hansson@arm.com * Authors: Vasileios Spiliopoulos 389288Sandreas.hansson@arm.com * Akash Bagdia 399288Sandreas.hansson@arm.com */ 4010623Smitch.hayenga@arm.com 419288Sandreas.hansson@arm.com#ifndef __SIM_VOLTAGE_DOMAIN_HH__ 4213416Sjavier.bueno@metempsy.com#define __SIM_VOLTAGE_DOMAIN_HH__ 438831Smrinmoy.ghosh@arm.com 448832SAli.Saidi@ARM.com#include <vector> 4513665Sandreas.sandberg@arm.com 4613665Sandreas.sandberg@arm.com#include "base/statistics.hh" 4713665Sandreas.sandberg@arm.com#include "params/VoltageDomain.hh" 4813665Sandreas.sandberg@arm.com#include "sim/clock_domain.hh" 498832SAli.Saidi@ARM.com#include "sim/sim_object.hh" 5013416Sjavier.bueno@metempsy.com 5113416Sjavier.bueno@metempsy.com/** 5213416Sjavier.bueno@metempsy.com * A VoltageDomain is used to group clock domains that operate under 5313416Sjavier.bueno@metempsy.com * the same voltage. The class provides methods for setting and 5413416Sjavier.bueno@metempsy.com * getting the voltage. 5513416Sjavier.bueno@metempsy.com */ 5613416Sjavier.bueno@metempsy.comclass VoltageDomain : public SimObject 5713416Sjavier.bueno@metempsy.com{ 5813416Sjavier.bueno@metempsy.com public: 5913416Sjavier.bueno@metempsy.com 6013416Sjavier.bueno@metempsy.com typedef VoltageDomainParams Params; 6113416Sjavier.bueno@metempsy.com VoltageDomain(const Params *p); 629288Sandreas.hansson@arm.com 638831Smrinmoy.ghosh@arm.com typedef SrcClockDomain::PerfLevel PerfLevel; 648831Smrinmoy.ghosh@arm.com 659338SAndreas.Sandberg@arm.com /** 6613416Sjavier.bueno@metempsy.com * Get the current voltage. 6713416Sjavier.bueno@metempsy.com * 6813416Sjavier.bueno@metempsy.com * @return Voltage of the domain 6910466Sandreas.hansson@arm.com */ 708831Smrinmoy.ghosh@arm.com double voltage() const { return voltageOpPoints[_perfLevel]; } 7113422Sodanrc@yahoo.com.br 7213422Sodanrc@yahoo.com.br /** 7313422Sodanrc@yahoo.com.br * Get the voltage at specified performance level. 7410623Smitch.hayenga@arm.com * 7510623Smitch.hayenga@arm.com * @param perf_level Performance level for which the voltage is requested 7610623Smitch.hayenga@arm.com * @return Voltage of the domain at specified performance level 7710623Smitch.hayenga@arm.com */ 7810623Smitch.hayenga@arm.com double voltage(PerfLevel perf_level) const 7913416Sjavier.bueno@metempsy.com { 8013416Sjavier.bueno@metempsy.com chatty_assert(perf_level < numVoltages(), "VoltageDomain %s "\ 8113551Sjavier.bueno@metempsy.com "request for voltage perf level %u is outside "\ 8213551Sjavier.bueno@metempsy.com "of numVoltages %u", name(), perf_level, 8313416Sjavier.bueno@metempsy.com numVoltages()); 8413416Sjavier.bueno@metempsy.com return voltageOpPoints[perf_level]; 8513416Sjavier.bueno@metempsy.com } 8613416Sjavier.bueno@metempsy.com 8713416Sjavier.bueno@metempsy.com uint32_t numVoltages() const { return (uint32_t)voltageOpPoints.size(); } 8813416Sjavier.bueno@metempsy.com 8913416Sjavier.bueno@metempsy.com /** 9013416Sjavier.bueno@metempsy.com * Set the voltage point of the domain. 9113416Sjavier.bueno@metempsy.com * @param Voltage value to be set 9213416Sjavier.bueno@metempsy.com */ 9313416Sjavier.bueno@metempsy.com void perfLevel(PerfLevel perf_level); 9413416Sjavier.bueno@metempsy.com 9513416Sjavier.bueno@metempsy.com /** 9613416Sjavier.bueno@metempsy.com * Get the voltage point of the domain. 9713416Sjavier.bueno@metempsy.com * @param Voltage value to be set 9813416Sjavier.bueno@metempsy.com */ 9913416Sjavier.bueno@metempsy.com PerfLevel perfLevel() const { return _perfLevel; } 10013416Sjavier.bueno@metempsy.com 10110623Smitch.hayenga@arm.com /** 10210623Smitch.hayenga@arm.com * Register a SrcClockDomain with this voltage domain. 10310623Smitch.hayenga@arm.com * @param src_clock_domain The SrcClockDomain to register. 10410623Smitch.hayenga@arm.com */ 10510623Smitch.hayenga@arm.com void registerSrcClockDom(SrcClockDomain *src_clock_dom) { 10610623Smitch.hayenga@arm.com assert(src_clock_dom->voltageDomain() == this); 10710623Smitch.hayenga@arm.com srcClockChildren.push_back(src_clock_dom); 10810623Smitch.hayenga@arm.com } 10910623Smitch.hayenga@arm.com 11010623Smitch.hayenga@arm.com /** 11110623Smitch.hayenga@arm.com * Startup has all SrcClockDomains registered with this voltage domain, so 11210623Smitch.hayenga@arm.com * try to make sure that all perf level requests from them are met. 11310623Smitch.hayenga@arm.com */ 11410623Smitch.hayenga@arm.com void startup(); 11510623Smitch.hayenga@arm.com 1168831Smrinmoy.ghosh@arm.com /** 1178831Smrinmoy.ghosh@arm.com * Recomputes the highest (fastest, i.e., numerically lowest) requested 1189338SAndreas.Sandberg@arm.com * performance level of all associated clock domains, and updates the 1198831Smrinmoy.ghosh@arm.com * performance level of this voltage domain to match. This means that for 12013422Sodanrc@yahoo.com.br * two connected clock domains, one fast and one slow, the voltage domain 12113422Sodanrc@yahoo.com.br * will provide the voltage associated with the fast DVFS operation point. 12213422Sodanrc@yahoo.com.br * Must be called whenever a clock domain decides to swtich its performance 12310623Smitch.hayenga@arm.com * level. 12410623Smitch.hayenga@arm.com * 12510623Smitch.hayenga@arm.com * @return True, if the voltage was actually changed. 12610623Smitch.hayenga@arm.com */ 12710623Smitch.hayenga@arm.com bool sanitiseVoltages(); 12810623Smitch.hayenga@arm.com 12910623Smitch.hayenga@arm.com void regStats(); 13010623Smitch.hayenga@arm.com 13110623Smitch.hayenga@arm.com void serialize(CheckpointOut &cp) const override; 13210623Smitch.hayenga@arm.com void unserialize(CheckpointIn &cp) override; 13310623Smitch.hayenga@arm.com 13413427Sodanrc@yahoo.com.br private: 13513427Sodanrc@yahoo.com.br typedef std::vector<double> Voltages; 13613427Sodanrc@yahoo.com.br /** 13713427Sodanrc@yahoo.com.br * List of possible minimum voltage at each of the frequency operational 13810623Smitch.hayenga@arm.com * points, should be in descending order and same size as freqOpPoints. 1398831Smrinmoy.ghosh@arm.com * An empty list corresponds to default voltage specified for the voltage 1408831Smrinmoy.ghosh@arm.com * domain its clock domain belongs. The same voltage is applied for each 1419338SAndreas.Sandberg@arm.com * freqOpPoints, overall implying NO DVS 1428831Smrinmoy.ghosh@arm.com */ 14310623Smitch.hayenga@arm.com const Voltages voltageOpPoints; 14413553Sjavier.bueno@metempsy.com PerfLevel _perfLevel; 14513553Sjavier.bueno@metempsy.com 14613553Sjavier.bueno@metempsy.com /** 14713553Sjavier.bueno@metempsy.com * Stat for reporting voltage of the domain 14813553Sjavier.bueno@metempsy.com */ 14913553Sjavier.bueno@metempsy.com Stats::Value currentVoltage; 15013553Sjavier.bueno@metempsy.com 15113553Sjavier.bueno@metempsy.com /** 15213553Sjavier.bueno@metempsy.com * List of associated SrcClockDomains that are connected to this voltage 15313553Sjavier.bueno@metempsy.com * domain. 15413553Sjavier.bueno@metempsy.com */ 15513553Sjavier.bueno@metempsy.com typedef std::vector<SrcClockDomain *> SrcClockChildren; 15613553Sjavier.bueno@metempsy.com SrcClockChildren srcClockChildren; 15713553Sjavier.bueno@metempsy.com}; 15813553Sjavier.bueno@metempsy.com 15913553Sjavier.bueno@metempsy.com#endif 16013553Sjavier.bueno@metempsy.com