-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBuffer.cpp
More file actions
214 lines (193 loc) · 6.74 KB
/
Buffer.cpp
File metadata and controls
214 lines (193 loc) · 6.74 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
/*******************************************************************************
* 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.
*
* Contributed by:
* Qing Guo ( qguo@cs.rochester.edu )
* Note:
* To support subarray differential write
*******************************************************************************/
#include "Buffer.h"
#include "formula.h"
#include "global.h"
Buffer::Buffer() {
// TODO Auto-generated constructor stub
initialized = false;
invalid = false;
}
Buffer::~Buffer() {
// TODO Auto-generated destructor stub
}
void Buffer::Initialize(long long _numRow, long long _numColumn) {
if (initialized)
cout << "[Buffer] Warning: Already initialized!" << endl;
numRow = _numRow;
numColumn = _numColumn;
initialized = true;
}
void Buffer::CalculateArea() {
double cellheight, cellwidth;
double xorheight, xorwidth;
if (!initialized) {
cout << "[Buffer] Error: Require initialization first!" << endl;
} else if (invalid) {
height = width = area = 1e41;
} else {
if (tech->featureSize >= 44e-9) { /* 45nm */
cellheight = 1.52e-6;
cellwidth = 1.54375e-6;
xorheight = 2.166e-6;
xorwidth = 2.166e-6;
}
else if (tech->featureSize >= 31e-9) { /* 32nm */
/* scaled from 45nm */
cellheight = 1.081e-6;
cellwidth = 1.098e-6;
xorheight = 1.54e-6;
xorwidth = 1.54e-6;
}
else { /* below 22nm */
/* scaled from 45nm */
cellheight = 0.743e-6;
cellwidth = 0.755e-6;
xorheight = 1.059e-6;
xorwidth = 1.059e-6;
}
height = (cellheight + xorheight) * numRow;
//numColumn = num of data bits + num of control signals. Control signals
//do not need XOR, allowing more room to place XORs.
width = cellwidth * numColumn;
area = height * width;
}
}
void Buffer::CalculateRC() {
if (!initialized) {
cout << "[Buffer] Error: Require initialization first!" << endl;
} else if (invalid) {
readLatency = writeLatency = xorLatency = 1e41;
} else {
/* nothing to do */
}
}
void Buffer::CalculateLatency() {
if (!initialized) {
cout << "[Buffer] Error: Require initialization first!" << endl;
} else {
if (tech->featureSize >= 44e-9) { /* 45nm */
readLatency = 0.043e-9;
writeLatency = readLatency;
xorLatency = 0.381e-9;
}
else if (tech->featureSize >= 31e-9) { /* 32nm */
/* copied from 45nm, need to figure out */
readLatency = 0.043e-9;
writeLatency = readLatency;
xorLatency = 0.381e-9;
}
else { /* below 22nm */
/* scaled from 45nm */
readLatency = 0.024e-9;
writeLatency = readLatency;
xorLatency = 0.21e-9;
}
}
setLatency = resetLatency = writeLatency;
}
void Buffer::CalculatePower() {
if (!initialized) {
cout << "[Buffer] Error: Require initialization first!" << endl;
} else if (invalid) {
readDynamicEnergy = writeDynamicEnergy = leakage = 1e41;
xorDynamicEnergy = xorLeakage = 1e41;
} else {
if (tech->featureSize >= 44e-9) { /* 45nm */
readDynamicEnergy = 0.0002e-18;
writeDynamicEnergy = readDynamicEnergy;
leakage = 19.7536e-9;
xorDynamicEnergy = 0.0034e-18;
xorLeakage = 45.1492e-9;
}
else if (tech->featureSize >= 31e-9) { /* 32nm */
/* copied from 45nm, need to figure out */
readDynamicEnergy = 0.0002e-18;
writeDynamicEnergy = readDynamicEnergy;
leakage = 19.7536e-9;
xorDynamicEnergy = 0.0034e-18;
xorLeakage = 45.1492e-9;
}
else { /* below 22nm */
/* scaled from 45nm */
readDynamicEnergy = 0.00006e-18;
writeDynamicEnergy = readDynamicEnergy;
leakage = 45.796e-9;
xorDynamicEnergy = 0.001e-18;
xorLeakage = 104.67e-9;
}
cellReadEnergy = readDynamicEnergy;
cellSetEnergy = cellResetEnergy = writeDynamicEnergy;
readDynamicEnergy *= numColumn;
writeDynamicEnergy = readDynamicEnergy;
leakage *= numColumn;
xorDynamicEnergy *= numColumn;
xorLeakage *= numColumn;
}
setDynamicEnergy = resetDynamicEnergy = writeDynamicEnergy;
}
void Buffer::PrintProperty() {
cout << "Subarray Buffer Properties:" << endl;
FunctionUnit::PrintProperty();
cout << "XOR Properties:" << endl;
cout << " - Latency = " << xorLatency*1e9 << "ns" << endl;
cout << " - Dynamic Energy = " << xorDynamicEnergy*1e12 << "pJ" << endl;
cout << " - Leakage Power = " << xorLeakage*1e3 << "mW" << endl;
}
Buffer & Buffer::operator=(const Buffer &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;
numRow = rhs.numRow;
numColumn = rhs.numColumn;
xorLatency = rhs.xorLatency;
xorDynamicEnergy = rhs.xorDynamicEnergy;
xorLeakage = rhs.xorLeakage;
return *this;
}