gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
drampower.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Omar Naji
38  */
39 
40 #include "mem/drampower.hh"
41 
42 #include "base/intmath.hh"
43 #include "sim/core.hh"
44 
45 DRAMPower::DRAMPower(const DRAMCtrlParams* p, bool include_io) :
46  powerlib(libDRAMPower(getMemSpec(p), include_io))
47 {
48 }
49 
50 Data::MemArchitectureSpec
51 DRAMPower::getArchParams(const DRAMCtrlParams* p)
52 {
53  Data::MemArchitectureSpec archSpec;
54  archSpec.burstLength = p->burst_length;
55  archSpec.nbrOfBanks = p->banks_per_rank;
56  // One DRAMPower instance per rank, hence set this to 1
57  archSpec.nbrOfRanks = 1;
58  archSpec.dataRate = getDataRate(p);
59  // For now we can ignore the number of columns and rows as they
60  // are not used in the power calculation.
61  archSpec.nbrOfColumns = 0;
62  archSpec.nbrOfRows = 0;
63  archSpec.width = p->device_bus_width;
64  archSpec.nbrOfBankGroups = p->bank_groups_per_rank;
65  archSpec.dll = p->dll;
66  archSpec.twoVoltageDomains = hasTwoVDD(p);
67  // Keep this disabled for now until the model is firmed up.
68  archSpec.termination = false;
69  return archSpec;
70 }
71 
72 Data::MemTimingSpec
73 DRAMPower::getTimingParams(const DRAMCtrlParams* p)
74 {
75  // Set the values that are used for power calculations and ignore
76  // the ones only used by the controller functionality in DRAMPower
77 
78  // All DRAMPower timings are in clock cycles
79  Data::MemTimingSpec timingSpec;
80  timingSpec.RC = divCeil((p->tRAS + p->tRP), p->tCK);
81  timingSpec.RCD = divCeil(p->tRCD, p->tCK);
82  timingSpec.RL = divCeil(p->tCL, p->tCK);
83  timingSpec.RP = divCeil(p->tRP, p->tCK);
84  timingSpec.RFC = divCeil(p->tRFC, p->tCK);
85  timingSpec.RAS = divCeil(p->tRAS, p->tCK);
86  // Write latency is read latency - 1 cycle
87  // Source: B.Jacob Memory Systems Cache, DRAM, Disk
88  timingSpec.WL = timingSpec.RL - 1;
89  timingSpec.DQSCK = 0; // ignore for now
90  timingSpec.RTP = divCeil(p->tRTP, p->tCK);
91  timingSpec.WR = divCeil(p->tWR, p->tCK);
92  timingSpec.XP = divCeil(p->tXP, p->tCK);
93  timingSpec.XPDLL = divCeil(p->tXPDLL, p->tCK);
94  timingSpec.XS = divCeil(p->tXS, p->tCK);
95  timingSpec.XSDLL = divCeil(p->tXSDLL, p->tCK);
96 
97  // Clock period in ns
98  timingSpec.clkPeriod = (p->tCK / (double)(SimClock::Int::ns));
99  assert(timingSpec.clkPeriod != 0);
100  timingSpec.clkMhz = (1 / timingSpec.clkPeriod) * 1000;
101  return timingSpec;
102 }
103 
104 Data::MemPowerSpec
105 DRAMPower::getPowerParams(const DRAMCtrlParams* p)
106 {
107  // All DRAMPower currents are in mA
108  Data::MemPowerSpec powerSpec;
109  powerSpec.idd0 = p->IDD0 * 1000;
110  powerSpec.idd02 = p->IDD02 * 1000;
111  powerSpec.idd2p0 = p->IDD2P0 * 1000;
112  powerSpec.idd2p02 = p->IDD2P02 * 1000;
113  powerSpec.idd2p1 = p->IDD2P1 * 1000;
114  powerSpec.idd2p12 = p->IDD2P12 * 1000;
115  powerSpec.idd2n = p->IDD2N * 1000;
116  powerSpec.idd2n2 = p->IDD2N2 * 1000;
117  powerSpec.idd3p0 = p->IDD3P0 * 1000;
118  powerSpec.idd3p02 = p->IDD3P02 * 1000;
119  powerSpec.idd3p1 = p->IDD3P1 * 1000;
120  powerSpec.idd3p12 = p->IDD3P12 * 1000;
121  powerSpec.idd3n = p->IDD3N * 1000;
122  powerSpec.idd3n2 = p->IDD3N2 * 1000;
123  powerSpec.idd4r = p->IDD4R * 1000;
124  powerSpec.idd4r2 = p->IDD4R2 * 1000;
125  powerSpec.idd4w = p->IDD4W * 1000;
126  powerSpec.idd4w2 = p->IDD4W2 * 1000;
127  powerSpec.idd5 = p->IDD5 * 1000;
128  powerSpec.idd52 = p->IDD52 * 1000;
129  powerSpec.idd6 = p->IDD6 * 1000;
130  powerSpec.idd62 = p->IDD62 * 1000;
131  powerSpec.vdd = p->VDD;
132  powerSpec.vdd2 = p->VDD2;
133  return powerSpec;
134 }
135 
136 Data::MemorySpecification
137 DRAMPower::getMemSpec(const DRAMCtrlParams* p)
138 {
139  Data::MemorySpecification memSpec;
140  memSpec.memArchSpec = getArchParams(p);
141  memSpec.memTimingSpec = getTimingParams(p);
142  memSpec.memPowerSpec = getPowerParams(p);
143  return memSpec;
144 }
145 
146 bool
147 DRAMPower::hasTwoVDD(const DRAMCtrlParams* p)
148 {
149  return p->VDD2 == 0 ? false : true;
150 }
151 
152 uint8_t
153 DRAMPower::getDataRate(const DRAMCtrlParams* p)
154 {
155  uint32_t burst_cycles = divCeil(p->tBURST, p->tCK);
156  uint8_t data_rate = p->burst_length / burst_cycles;
157  // 4 for GDDR5
158  if (data_rate != 1 && data_rate != 2 && data_rate != 4)
159  fatal("Got unexpected data rate %d, should be 1 or 2 or 4\n");
160  return data_rate;
161 }
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:175
static Data::MemPowerSpec getPowerParams(const DRAMCtrlParams *p)
Transforms the power and current parameters defined in DRAMCtrlParam to the memSpec of DRAMPower...
Definition: drampower.cc:105
static Data::MemArchitectureSpec getArchParams(const DRAMCtrlParams *p)
Transform the architechture parameters defined in DRAMCtrlParams to the memSpec of DRAMPower...
Definition: drampower.cc:51
static uint8_t getDataRate(const DRAMCtrlParams *p)
Determine data rate, either one or two.
Definition: drampower.cc:153
DRAMPower(const DRAMCtrlParams *p, bool include_io)
Definition: drampower.cc:45
DRAMPower declaration.
T divCeil(const T &a, const U &b)
Definition: intmath.hh:153
static Data::MemTimingSpec getTimingParams(const DRAMCtrlParams *p)
Transforms the timing parameters defined in DRAMCtrlParams to the memSpec of DRAMPower.
Definition: drampower.cc:73
Tick ns
nanosecond
Definition: core.cc:68
static bool hasTwoVDD(const DRAMCtrlParams *p)
Determine if DRAM has two voltage domains (or one)
Definition: drampower.cc:147
static Data::MemorySpecification getMemSpec(const DRAMCtrlParams *p)
Return an instance of MemSpec based on the DRAMCtrlParams.
Definition: drampower.cc:137
Bitfield< 0 > p

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13