forked from sparsh0mittal/destiny_3d_cache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRowDecoder.cpp
More file actions
210 lines (189 loc) · 7.1 KB
/
RowDecoder.cpp
File metadata and controls
210 lines (189 loc) · 7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//Copyright (c) 2015-2016, UT-Battelle, LLC. See LICENSE file in the top-level directory
// This file contains code from NVSim, (c) 2012-2013, Pennsylvania State University
//and Hewlett-Packard Company. See LICENSE_NVSim file in the top-level directory.
//No part of DESTINY Project, including this file, may be copied,
//modified, propagated, or distributed except according to the terms
//contained in the LICENSE file.
#include "RowDecoder.h"
#include "formula.h"
#include "global.h"
RowDecoder::RowDecoder() : FunctionUnit(){
// TODO Auto-generated constructor stub
initialized = false;
invalid = false;
}
RowDecoder::~RowDecoder() {
// TODO Auto-generated destructor stub
}
void RowDecoder::Initialize(int _numRow, double _capLoad, double _resLoad,
bool _multipleRowPerSet, BufferDesignTarget _areaOptimizationLevel, double _minDriverCurrent) {
if (initialized)
cout << "[Row Decoder] Warning: Already initialized!" << endl;
numRow = _numRow;
capLoad = _capLoad;
resLoad = _resLoad;
multipleRowPerSet = _multipleRowPerSet;
areaOptimizationLevel = _areaOptimizationLevel;
minDriverCurrent = _minDriverCurrent;
if (numRow <= 8) { /* The predecoder output is used directly */
if (multipleRowPerSet)
numNandInput = 2; /* NAND way-select with predecoder output */
else
numNandInput = 0; /* no circuit needed */
} else {
if (multipleRowPerSet)
numNandInput = 3; /* NAND way-select with two predecoder outputs */
else
numNandInput = 2; /* just NAND two predecoder outputs */
}
if (numNandInput > 0) {
double logicEffortNand;
double capNand;
if (numNandInput == 2) { /* NAND2 */
widthNandN = 2 * MIN_NMOS_SIZE * tech->featureSize;
logicEffortNand = (2+tech->pnSizeRatio) / (1+tech->pnSizeRatio);
} else { /* NAND3 */
widthNandN = 3 * MIN_NMOS_SIZE * tech->featureSize;
logicEffortNand = (3+tech->pnSizeRatio) / (1+tech->pnSizeRatio);
}
widthNandP = tech->pnSizeRatio * MIN_NMOS_SIZE * tech->featureSize;
capNand = CalculateGateCap(widthNandN, *tech) + CalculateGateCap(widthNandP, *tech);
outputDriver.Initialize(logicEffortNand, capNand, capLoad, resLoad, true, areaOptimizationLevel, minDriverCurrent);
} else {
/* we only need an 1-level output buffer to driver the wordline */
double capInv;
widthNandN = MIN_NMOS_SIZE * tech->featureSize;
widthNandP = tech->pnSizeRatio * MIN_NMOS_SIZE * tech->featureSize;
capInv = CalculateGateCap(widthNandN, *tech) + CalculateGateCap(widthNandP, *tech);
outputDriver.Initialize(1, capInv, capLoad, resLoad, true, areaOptimizationLevel, minDriverCurrent);
}
if (outputDriver.invalid) {
invalid = true;
return;
}
initialized = true;
}
void RowDecoder::CalculateArea() {
if (!initialized) {
cout << "[Row Decoder Area] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateArea();
if (numNandInput == 0) { /* no circuit needed, use predecoder outputs directly */
height = outputDriver.height;
width = outputDriver.width;
} else {
double hNand, wNand;
CalculateGateArea(NAND, numNandInput, widthNandN, widthNandP, tech->featureSize*40, *tech, &hNand, &wNand);
height = MAX(hNand, outputDriver.height);
width = wNand + outputDriver.width;
}
height *= numRow;
area = height * width;
}
}
void RowDecoder::CalculateRC() {
if (!initialized) {
cout << "[Row Decoder RC] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateRC();
if (numNandInput == 0) { /* no circuit needed, use predecoder outputs directly */
capNandInput = capNandOutput = 0;
} else {
CalculateGateCapacitance(NAND, numNandInput, widthNandN, widthNandP, tech->featureSize * MAX_TRANSISTOR_HEIGHT, *tech, &capNandInput, &capNandOutput);
}
}
}
void RowDecoder::CalculateLatency(double _rampInput) {
if (!initialized) {
cout << "[Row Decoder Latency] Error: Require initialization first!" << endl;
} else {
if (numNandInput == 0) { /* no circuit needed, use predecoder outputs directly */
outputDriver.CalculateLatency(_rampInput);
readLatency = writeLatency = outputDriver.readLatency;
rampOutput = outputDriver.rampOutput;
} else {
rampInput = _rampInput;
double resPullDown;
double capLoad;
double tr; /* time constant */
double gm; /* transconductance */
double beta; /* for horowitz calculation */
double rampInputForDriver;
resPullDown = CalculateOnResistance(widthNandN, NMOS, inputParameter->temperature, *tech) * numNandInput;
capLoad = capNandOutput + outputDriver.capInput[0];
tr = resPullDown * capLoad;
gm = CalculateTransconductance(widthNandN, NMOS, *tech);
beta = 1 / (resPullDown * gm);
readLatency = horowitz(tr, beta, rampInput, &rampInputForDriver);
outputDriver.CalculateLatency(rampInputForDriver);
readLatency += outputDriver.readLatency;
writeLatency = readLatency;
rampOutput = outputDriver.rampOutput;
}
}
}
void RowDecoder::CalculatePower() {
if (!initialized) {
cout << "[Row Decoder Power] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculatePower();
leakage = outputDriver.leakage;
if (numNandInput == 0) { /* no circuit needed, use predecoder outputs directly */
readDynamicEnergy = writeDynamicEnergy = outputDriver.readDynamicEnergy;
} else {
/* Leakage power */
leakage += CalculateGateLeakage(NAND, numNandInput, widthNandN, widthNandP,
inputParameter->temperature, *tech) * tech->vdd;
/* Dynamic energy */
double capLoad = capNandOutput + outputDriver.capInput[0];
/* For DRAM types account for overdriven wordline. */
if (cell->memCellType == DRAM || cell->memCellType == eDRAM) {
readDynamicEnergy = capLoad * tech->vpp * tech->vpp;
} else {
readDynamicEnergy = capLoad * tech->vdd * tech->vdd;
}
readDynamicEnergy += outputDriver.readDynamicEnergy;
readDynamicEnergy *= 1; /* only one row is activated each time */
writeDynamicEnergy = readDynamicEnergy;
}
leakage *= numRow;
}
}
void RowDecoder::PrintProperty() {
cout << "Row Decoder Properties:" << endl;
FunctionUnit::PrintProperty();
}
RowDecoder & RowDecoder::operator=(const RowDecoder &rhs) {
height = rhs.height;
width = rhs.width;
area = rhs.area;
readLatency = rhs.readLatency;
writeLatency = rhs.writeLatency;
readDynamicEnergy = rhs.readDynamicEnergy;
writeDynamicEnergy = rhs.writeDynamicEnergy;
resetLatency = rhs.resetLatency;
setLatency = rhs.setLatency;
resetDynamicEnergy = rhs.resetDynamicEnergy;
setDynamicEnergy = rhs.setDynamicEnergy;
cellReadEnergy = rhs.cellReadEnergy;
cellSetEnergy = rhs.cellSetEnergy;
cellResetEnergy = rhs.cellResetEnergy;
leakage = rhs.leakage;
initialized = rhs.initialized;
invalid = rhs.invalid;
outputDriver = rhs.outputDriver;
numRow = rhs.numRow;
multipleRowPerSet = rhs.multipleRowPerSet;
numNandInput = rhs.numNandInput;
capLoad = rhs.capLoad;
resLoad = rhs.resLoad;
areaOptimizationLevel = rhs.areaOptimizationLevel;
minDriverCurrent = rhs.minDriverCurrent;
widthNandN = rhs.widthNandN;
widthNandP = rhs.widthNandP;
capNandInput = rhs.capNandInput;
capNandOutput = rhs.capNandOutput;
rampInput = rhs.rampInput;
rampOutput = rhs.rampOutput;
return *this;
}