111524Sdavid.guillen@arm.com# Copyright (c) 2012, 2015-2016 ARM Limited
29157Sandreas.hansson@arm.com# All rights reserved.
39157Sandreas.hansson@arm.com#
49157Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall
59157Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual
69157Sandreas.hansson@arm.com# property including but not limited to intellectual property relating
79157Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software
89157Sandreas.hansson@arm.com# licensed hereunder.  You may use the software subject to the license
99157Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated
109157Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software,
119157Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form.
129157Sandreas.hansson@arm.com#
139157Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
149157Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
159157Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
169157Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
179157Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
189157Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
199157Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
209157Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
219157Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from
229157Sandreas.hansson@arm.com# this software without specific prior written permission.
239157Sandreas.hansson@arm.com#
249157Sandreas.hansson@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
259157Sandreas.hansson@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
269157Sandreas.hansson@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
279157Sandreas.hansson@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
289157Sandreas.hansson@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
299157Sandreas.hansson@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
309157Sandreas.hansson@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
319157Sandreas.hansson@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
329157Sandreas.hansson@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
339157Sandreas.hansson@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
349157Sandreas.hansson@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
359157Sandreas.hansson@arm.com#
369157Sandreas.hansson@arm.com# Authors: Andreas Hansson
379157Sandreas.hansson@arm.com
389157Sandreas.hansson@arm.comfrom m5.SimObject import SimObject
399157Sandreas.hansson@arm.comfrom m5.params import *
409281Sandreas.hansson@arm.comfrom m5.proxy import *
419157Sandreas.hansson@arm.com
4211524Sdavid.guillen@arm.com# Enumerate set of allowed power states that can be used by a clocked object.
4311524Sdavid.guillen@arm.com# The list is kept generic to express a base minimal set.
4411524Sdavid.guillen@arm.com# State definition :-
4511524Sdavid.guillen@arm.com#   Undefined: Invalid state, no power state derived information is available.
4611524Sdavid.guillen@arm.com#   On: The logic block is actively running and consuming dynamic and leakage
4711524Sdavid.guillen@arm.com#       energy depending on the amount of processing required.
4811524Sdavid.guillen@arm.com#   Clk_gated: The clock circuity within the block is gated to save dynamic
4911524Sdavid.guillen@arm.com#              energy, the power supply to the block is still on and leakage
5011524Sdavid.guillen@arm.com#              energy is being consumed by the block.
5111524Sdavid.guillen@arm.com#   Sram_retention: The SRAMs within the logic blocks are pulled into retention
5211524Sdavid.guillen@arm.com#                   state to reduce leakage energy further.
5311524Sdavid.guillen@arm.com#   Off: The logic block is power gated and is not consuming any energy.
5411524Sdavid.guillen@arm.comclass PwrState(Enum): vals = ['UNDEFINED',
5511524Sdavid.guillen@arm.com                             'ON',
5611524Sdavid.guillen@arm.com                             'CLK_GATED',
5711524Sdavid.guillen@arm.com                             'SRAM_RETENTION',
5811524Sdavid.guillen@arm.com                             'OFF']
5911524Sdavid.guillen@arm.com
609157Sandreas.hansson@arm.comclass ClockedObject(SimObject):
619157Sandreas.hansson@arm.com    type = 'ClockedObject'
629157Sandreas.hansson@arm.com    abstract = True
639338SAndreas.Sandberg@arm.com    cxx_header = "sim/clocked_object.hh"
649157Sandreas.hansson@arm.com
659793Sakash.bagdia@arm.com    # The clock domain this clocked object belongs to, inheriting the
669793Sakash.bagdia@arm.com    # parent's clock domain by default
679793Sakash.bagdia@arm.com    clk_domain = Param.ClockDomain(Parent.clk_domain, "Clock domain")
6811524Sdavid.guillen@arm.com
6911527Sdavid.guillen@arm.com    # Power model for this ClockedObject
7012265Sdavid.guillen@arm.com    power_model = VectorParam.PowerModel([], "Power models")
7111527Sdavid.guillen@arm.com
7211524Sdavid.guillen@arm.com    # Provide initial power state, should ideally get redefined in startup
7311524Sdavid.guillen@arm.com    # routine
7411524Sdavid.guillen@arm.com    default_p_state = Param.PwrState("UNDEFINED", "Default Power State")
7511524Sdavid.guillen@arm.com
7611524Sdavid.guillen@arm.com    p_state_clk_gate_min = Param.Latency('1ns',"Min value of the distribution")
7711524Sdavid.guillen@arm.com    p_state_clk_gate_max = Param.Latency('1s',"Max value of the distribution")
7811524Sdavid.guillen@arm.com    p_state_clk_gate_bins = Param.Unsigned('20',
7911524Sdavid.guillen@arm.com        "# bins in clk gated distribution")
80