MemoryPowerModel.h revision 10428:0caf62b57dfd
1/* 2 * Copyright (c) 2012-2014, TU Delft 3 * Copyright (c) 2012-2014, TU Eindhoven 4 * Copyright (c) 2012-2014, TU Kaiserslautern 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * 3. Neither the name of the copyright holder nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 23 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * Authors: Karthik Chandrasekar, Matthias Jung, Omar Naji 35 * 36 */ 37 38#ifndef MEMORY_POWER_MODEL_H 39#define MEMORY_POWER_MODEL_H 40 41#include "MemorySpecification.h" 42#include "CommandAnalysis.h" 43 44namespace Data { 45class MemoryPowerModel { 46 public: 47 // Calculate energy and average power consumption for the given memory 48 // command trace 49 void power_calc(MemorySpecification memSpec, 50 const CommandAnalysis& counters, 51 int term); 52 53 // Used to calculate self-refresh active energy 54 static double engy_sref(double idd6, 55 double idd3n, 56 double idd5, 57 double vdd, 58 double sref_cycles, 59 double sref_ref_act_cycles, 60 double sref_ref_pre_cycles, 61 double spup_ref_act_cycles, 62 double spup_ref_pre_cycles, 63 double clk); 64 65 int64_t total_cycles; 66 67 struct Energy { 68 // Total energy of all activates 69 double act_energy; 70 71 // Total energy of all precharges 72 double pre_energy; 73 74 // Total energy of all reads 75 double read_energy; 76 77 // Total energy of all writes 78 double write_energy; 79 80 // Total energy of all refreshes 81 double ref_energy; 82 83 // Total background energy of all active standby cycles 84 double act_stdby_energy; 85 86 // Total background energy of all precharge standby cycles 87 double pre_stdby_energy; 88 89 // Total energy of idle cycles in the active mode 90 double idle_energy_act; 91 92 // Total energy of idle cycles in the precharge mode 93 double idle_energy_pre; 94 95 // Total trace/pattern energy 96 double total_energy; 97 98 // Average Power 99 double average_power; 100 101 // Energy consumed in active/precharged fast/slow-exit modes 102 double f_act_pd_energy; 103 double f_pre_pd_energy; 104 double s_act_pd_energy; 105 double s_pre_pd_energy; 106 107 // Energy consumed in self-refresh mode 108 double sref_energy; 109 110 // Energy consumed in auto-refresh during self-refresh mode 111 double sref_ref_energy; 112 double sref_ref_act_energy; 113 double sref_ref_pre_energy; 114 115 // Energy consumed in powering-up from self-refresh mode 116 double spup_energy; 117 118 // Energy consumed in auto-refresh during self-refresh power-up 119 double spup_ref_energy; 120 double spup_ref_act_energy; 121 double spup_ref_pre_energy; 122 123 // Energy consumed in powering-up from active/precharged power-down modes 124 double pup_act_energy; 125 double pup_pre_energy; 126 127 // Energy consumed by IO and Termination 128 double read_io_energy; // Read IO Energy 129 double write_term_energy; // Write Termination Energy 130 double read_oterm_energy; // Read Termination Energy from idle rank 131 double write_oterm_energy; // Write Termination Energy from idle rank 132 // Total IO and Termination Energy 133 double io_term_energy; 134 }; 135 136 struct Power { 137 // Power measures corresponding to IO and Termination 138 double IO_power; // Read IO Power 139 double WR_ODT_power; // Write ODT Power 140 double TermRD_power; // Read Termination in idle rank (in dual-rank systems) 141 double TermWR_power; // Write Termination in idle rank (in dual-rank systems) 142 143 // Average Power 144 double average_power; 145 }; 146 147 // Print the power and energy 148 void power_print(MemorySpecification memSpec, 149 int term, 150 const CommandAnalysis& counters) const; 151 152 // To derive IO and Termination Power measures using DRAM specification 153 void io_term_power(MemorySpecification memSpec); 154 155 Energy energy; 156 Power power; 157 158 private: 159 double calcIoTermEnergy(int64_t cycles, double period, double power, int64_t numBits) const; 160}; 161 162class EnergyDomain { 163 public: 164 EnergyDomain(double voltage, double clkPeriod) : 165 voltage(voltage), 166 clkPeriod(clkPeriod) 167 {} 168 169 double calcTivEnergy(int64_t cycles, double current) const; 170 private: 171 const double voltage; 172 const double clkPeriod; 173}; 174 175} 176#endif // ifndef MEMORY_POWER_MODEL_H 177