PowerModel.py revision 12547:3bf3ae601ead
19935Sdam.sunwoo@arm.com# Copyright (c) 2016-2018 ARM Limited 29935Sdam.sunwoo@arm.com# All rights reserved. 39935Sdam.sunwoo@arm.com# 49935Sdam.sunwoo@arm.com# The license below extends only to copyright in the software and shall 59935Sdam.sunwoo@arm.com# not be construed as granting a license to any other intellectual 69935Sdam.sunwoo@arm.com# property including but not limited to intellectual property relating 79935Sdam.sunwoo@arm.com# to a hardware implementation of the functionality of the software 89935Sdam.sunwoo@arm.com# licensed hereunder. You may use the software subject to the license 99935Sdam.sunwoo@arm.com# terms below provided that you ensure that this notice is replicated 109935Sdam.sunwoo@arm.com# unmodified and in its entirety in all distributions of the software, 119935Sdam.sunwoo@arm.com# modified or unmodified, in source code or in binary form. 129935Sdam.sunwoo@arm.com# 139935Sdam.sunwoo@arm.com# Redistribution and use in source and binary forms, with or without 149935Sdam.sunwoo@arm.com# modification, are permitted provided that the following conditions are 159935Sdam.sunwoo@arm.com# met: redistributions of source code must retain the above copyright 169935Sdam.sunwoo@arm.com# notice, this list of conditions and the following disclaimer; 179935Sdam.sunwoo@arm.com# redistributions in binary form must reproduce the above copyright 189935Sdam.sunwoo@arm.com# notice, this list of conditions and the following disclaimer in the 199935Sdam.sunwoo@arm.com# documentation and/or other materials provided with the distribution; 209935Sdam.sunwoo@arm.com# neither the name of the copyright holders nor the names of its 219935Sdam.sunwoo@arm.com# contributors may be used to endorse or promote products derived from 229935Sdam.sunwoo@arm.com# this software without specific prior written permission. 239935Sdam.sunwoo@arm.com# 249935Sdam.sunwoo@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 259935Sdam.sunwoo@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 269935Sdam.sunwoo@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 279935Sdam.sunwoo@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 289935Sdam.sunwoo@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 299935Sdam.sunwoo@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 309935Sdam.sunwoo@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 319935Sdam.sunwoo@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 329935Sdam.sunwoo@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 339935Sdam.sunwoo@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 349935Sdam.sunwoo@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 359935Sdam.sunwoo@arm.com# 369935Sdam.sunwoo@arm.com# Authors: David Guillen Fandos 379935Sdam.sunwoo@arm.com 389935Sdam.sunwoo@arm.comfrom m5.SimObject import * 399935Sdam.sunwoo@arm.comfrom m5.params import * 409935Sdam.sunwoo@arm.comfrom m5.proxy import Parent 419935Sdam.sunwoo@arm.com 429935Sdam.sunwoo@arm.com# Enum for a type of power model 4310354Sdam.sunwoo@arm.comclass PMType(Enum) : vals = ['All', 'Static', 'Dynamic'] 4411686Sshawn.rosti@gmail.com 4511686Sshawn.rosti@gmail.com# Represents a power model for a simobj 469935Sdam.sunwoo@arm.com# The model itself is also a SimObject so we can make use some 4710354Sdam.sunwoo@arm.com# nice features available such as Parent.any 489935Sdam.sunwoo@arm.comclass PowerModel(SimObject): 499935Sdam.sunwoo@arm.com type = 'PowerModel' 509935Sdam.sunwoo@arm.com cxx_header = "sim/power/power_model.hh" 5110354Sdam.sunwoo@arm.com 529935Sdam.sunwoo@arm.com cxx_exports = [ 539935Sdam.sunwoo@arm.com PyBindMethod("getDynamicPower"), 5411686Sshawn.rosti@gmail.com PyBindMethod("getStaticPower"), 5511686Sshawn.rosti@gmail.com ] 569935Sdam.sunwoo@arm.com 579935Sdam.sunwoo@arm.com # Keep a list of every model for every power state 5811686Sshawn.rosti@gmail.com pm = VectorParam.PowerModelState([], "List of per-state power models.") 5911686Sshawn.rosti@gmail.com 609935Sdam.sunwoo@arm.com # Need a reference to the system so we can query the thermal domain 619935Sdam.sunwoo@arm.com # about temperature (temperature is needed for leakage calculation) 6211686Sshawn.rosti@gmail.com subsystem = Param.SubSystem(Parent.any, "subsystem") 6311686Sshawn.rosti@gmail.com 649935Sdam.sunwoo@arm.com # Type of power model 659935Sdam.sunwoo@arm.com pm_type = Param.PMType("All", "Type of power model") 6611686Sshawn.rosti@gmail.com 6711686Sshawn.rosti@gmail.com # Ambient temperature to be used when no thermal model is present 689935Sdam.sunwoo@arm.com ambient_temp = Param.Float(25.0, "Ambient temperature") 699935Sdam.sunwoo@arm.com