forked from xpsair/NVSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSenseAmp.cpp
More file actions
290 lines (257 loc) · 10.1 KB
/
SenseAmp.cpp
File metadata and controls
290 lines (257 loc) · 10.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*******************************************************************************
* Copyright (c) 2012-2013, The Microsystems Design Labratory (MDL)
* Department of Computer Science and Engineering, The Pennsylvania State University
* Exascale Computing Lab, Hewlett-Packard Company
* All rights reserved.
*
* This source code is part of NVSim - An area, timing and power model for both
* volatile (e.g., SRAM, DRAM) and non-volatile memory (e.g., PCRAM, STT-RAM, ReRAM,
* SLC NAND Flash). The source code is free and you can redistribute and/or modify it
* by providing that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Author list:
* Cong Xu ( Email: czx102 at psu dot edu
* Website: http://www.cse.psu.edu/~czx102/ )
* Xiangyu Dong ( Email: xydong at cse dot psu dot edu
* Website: http://www.cse.psu.edu/~xydong/ )
*******************************************************************************/
#include "SenseAmp.h"
#include "formula.h"
#include "global.h"
SenseAmp::SenseAmp() {
// TODO Auto-generated constructor stub
initialized = false;
invalid = false;
}
SenseAmp::~SenseAmp() {
// TODO Auto-generated destructor stub
}
void SenseAmp::Initialize(long long _numColumn, bool _currentSense, double _senseVoltage, double _pitchSenseAmp) {
if (initialized)
cout << "[Sense Amp] Warning: Already initialized!" << endl;
numColumn = _numColumn;
currentSense = _currentSense;
senseVoltage = _senseVoltage;
pitchSenseAmp = _pitchSenseAmp;
if (pitchSenseAmp <= tech->featureSize * 2) {
/* too small, cannot do the layout */
invalid = true;
}
initialized = true;
}
void SenseAmp::CalculateArea() {
if (!initialized) {
cout << "[Sense Amp] Error: Require initialization first!" << endl;
} else if (invalid) {
height = width = area = 1e41;
} else {
//Qing: replace the default SA
#if 0
height = width = area = 0;
if (currentSense) { /* current-sensing needs IV converter */
area += IV_CONVERTER_AREA * tech->featureSize * tech->featureSize;
}
/* the following codes are transformed from CACTI 6.5 */
double tempHeight = 0;
double tempWidth = 0;
CalculateGateArea(INV, 1, 0, W_SENSE_P * tech->featureSize,
pitchSenseAmp, *tech, &tempWidth, &tempHeight); /* exchange width and height for senseamp layout */
width = MAX(width, tempWidth);
height += 2 * tempHeight;
CalculateGateArea(INV, 1, 0, W_SENSE_ISO * tech->featureSize,
pitchSenseAmp, *tech, &tempWidth, &tempHeight); /* exchange width and height for senseamp layout */
width = MAX(width, tempWidth);
height += tempHeight;
height += 2 * MIN_GAP_BET_SAME_TYPE_DIFFS * tech->featureSize;
CalculateGateArea(INV, 1, W_SENSE_N * tech->featureSize, 0,
pitchSenseAmp, *tech, &tempWidth, &tempHeight); /* exchange width and height for senseamp layout */
width = MAX(width, tempWidth);
height += 2 * tempHeight;
CalculateGateArea(INV, 1, W_SENSE_EN * tech->featureSize, 0,
pitchSenseAmp, *tech, &tempWidth, &tempHeight); /* exchange width and height for senseamp layout */
width = MAX(width, tempWidth);
height += tempHeight;
height += 2 * MIN_GAP_BET_SAME_TYPE_DIFFS * tech->featureSize;
height += MIN_GAP_BET_P_AND_N_DIFFS * tech->featureSize;
/* transformation so that width meets the pitch */
height = height * width / pitchSenseAmp;
width = pitchSenseAmp;
/* Add additional area if IV converter exists */
height += area / width;
width *= numColumn;
area = height * width;
#endif
height = width = area = 0;
double tempHeight = 0;
double tempWidth = 0;
CalculateGateArea(INV, 1, 0, W_SA_TOP * tech->featureSize,
pitchSenseAmp, *tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += tempHeight;
CalculateGateArea(INV, 1, 0, W_SA_P * tech->featureSize,
pitchSenseAmp, *tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += 2 * tempHeight;
CalculateGateArea(INV, 1, W_SA_N * tech->featureSize, 0,
pitchSenseAmp, *tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += 2 * tempHeight;
CalculateGateArea(INV, 1, W_SA_BOT * tech->featureSize, 0,
pitchSenseAmp, *tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += 2 * tempHeight;
/* transformation so that width meets the pitch */
height = height * width / pitchSenseAmp;
width = pitchSenseAmp * numColumn;
area = height * width;
//Qing.
}
}
void SenseAmp::CalculateRC() {
if (!initialized) {
cout << "[Sense Amp] Error: Require initialization first!" << endl;
} else if (invalid) {
readLatency = writeLatency = 1e41;
} else {
//Qing: replace the default SA
#if 0
capLoad = CalculateGateCap((W_SENSE_P + W_SENSE_N) * tech->featureSize, *tech)
+ CalculateDrainCap(W_SENSE_N * tech->featureSize, NMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SENSE_P * tech->featureSize, PMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SENSE_ISO * tech->featureSize, PMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SENSE_MUX * tech->featureSize, NMOS, pitchSenseAmp, *tech);
#endif
capLoad = CalculateGateCap((W_SA_P + W_SA_N) * tech->featureSize, *tech)
+ CalculateDrainCap(W_SA_N * tech->featureSize, NMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SA_P * tech->featureSize, PMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SA_TOP * tech->featureSize, PMOS, pitchSenseAmp, *tech)
+ CalculateDrainCap(W_SA_BOT * tech->featureSize, NMOS, pitchSenseAmp, *tech);
//Qing.
}
}
void SenseAmp::CalculateLatency(double _rampInput) { /* _rampInput is actually no use in SenseAmp */
if (!initialized) {
cout << "[Sense Amp] Error: Require initialization first!" << endl;
} else {
readLatency = writeLatency = 0;
//Qing: re-model the current S/A
if (currentSense) {
/* all the following values achieved from HSPICE */
if (tech->featureSize >= 119e-9)
readLatency += 0.49e-9; /* 120nm */
else if (tech->featureSize >= 89e-9)
readLatency += 0.53e-9; /* 90nm */
else if (tech->featureSize >= 64e-9)
readLatency += 0.62e-9; /* 65nm */
else if (tech->featureSize >= 44e-9)
readLatency += 0.80e-9; /* 45nm */
else if (tech->featureSize >= 31e-9)
readLatency += 1.07e-9; /* 32nm */
else
//Qing: use new S/A number
//readLatency += 1.45e-9; /* below 22nm */
readLatency += 1.0e-10; /* below 22nm */
}
else {
/* Voltage sense amplifier */
double gm = CalculateTransconductance(W_SENSE_N * tech->featureSize, NMOS, *tech)
+ CalculateTransconductance(W_SENSE_P * tech->featureSize, PMOS, *tech);
double tau = capLoad / gm;
readLatency += tau * log(tech->vdd / senseVoltage);
}
//Qing.
}
}
void SenseAmp::CalculatePower() {
if (!initialized) {
cout << "[Sense Amp] Error: Require initialization first!" << endl;
} else if (invalid) {
readDynamicEnergy = writeDynamicEnergy = leakage = 1e41;
} else {
readDynamicEnergy = writeDynamicEnergy = 0;
leakage = 0;
//Qing: re-model the current S/A
if (currentSense) {
/* all the following values achieved from HSPICE */
if (tech->featureSize >= 119e-9) { /* 120nm */
readDynamicEnergy += 8.52e-14; /* Unit: J */
leakage += 1.40e-8; /* Unit: W */
} else if (tech->featureSize >= 89e-9) { /* 90nm */
readDynamicEnergy += 8.72e-14;
leakage += 1.87e-8;
} else if (tech->featureSize >= 64e-9) { /* 65nm */
readDynamicEnergy += 9.00e-14;
leakage += 2.57e-8;
} else if (tech->featureSize >= 44e-9) { /* 45nm */
readDynamicEnergy += 10.26e-14;
leakage += 4.41e-9;
} else if (tech->featureSize >= 31e-9) { /* 32nm */
readDynamicEnergy += 12.56e-14;
leakage += 12.54e-8;
} else { /* TO-DO, need calibration below 22nm */
//Qing: use new S/A numbers
//readDynamicEnergy += 15e-14;
readDynamicEnergy += 8e-15;
//leakage += 15e-8;
leakage += 0;
}
}
else {
/* Voltage sense amplifier */
readDynamicEnergy += capLoad * tech->vdd * tech->vdd;
double idleCurrent = CalculateGateLeakage(INV, 1, W_SENSE_EN * tech->featureSize, 0,
inputParameter->temperature, *tech) * tech->vdd;
leakage += idleCurrent * tech->vdd;
}
//Qing.
readDynamicEnergy *= numColumn;
leakage *= numColumn;
}
}
void SenseAmp::PrintProperty() {
cout << "Sense Amplifier Properties:" << endl;
FunctionUnit::PrintProperty();
}
SenseAmp & SenseAmp::operator=(const SenseAmp &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;
numColumn = rhs.numColumn;
currentSense = rhs.currentSense;
senseVoltage = rhs.senseVoltage;
capLoad = rhs.capLoad;
pitchSenseAmp = rhs.pitchSenseAmp;
return *this;
}