-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSenseAmp.cpp
197 lines (173 loc) · 6.45 KB
/
SenseAmp.cpp
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
#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 {
height = width = area = 0;
double tempHeight = 0;
double tempWidth = 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 */
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;
}
}
void SenseAmp::CalculateRC() {
if (!initialized) {
cout << "[Sense Amp] Error: Require initialization first!" << endl;
} else if (invalid) {
readLatency = writeLatency = 1e41;
} else {
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);
}
}
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;
if (currentSense) { /* current-sensing needs IV converter */
/* 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
readLatency += 1.45e-9; /* below 22nm */
}
/* 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);
}
}
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;
if (currentSense) { /* current-sensing needs IV converter */
/* 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 */
readDynamicEnergy += 15e-14;
leakage += 15e-8;
}
}
/* 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;
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;
}