-
Notifications
You must be signed in to change notification settings - Fork 2
/
Precharger.cpp
169 lines (154 loc) · 6.78 KB
/
Precharger.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
//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 "Precharger.h"
#include "formula.h"
#include "global.h"
Precharger::Precharger() {
// TODO Auto-generated constructor stub
initialized = false;
enableLatency = 0;
}
Precharger::~Precharger() {
// TODO Auto-generated destructor stub
}
void Precharger::Initialize(double _voltagePrecharge, int _numColumn, double _capBitline, double _resBitline){
if (initialized)
cout << "[Precharger] Warning: Already initialized!" << endl;
voltagePrecharge = _voltagePrecharge;
numColumn = _numColumn;
capBitline = _capBitline;
resBitline = _resBitline;
capWireLoadPerColumn = cell->widthInFeatureSize * tech->featureSize * localWire->capWirePerUnit;
resWireLoadPerColumn = cell->widthInFeatureSize * tech->featureSize * localWire->resWirePerUnit;
widthInvNmos = MIN_NMOS_SIZE * tech->featureSize;
widthInvPmos = widthInvNmos * tech->pnSizeRatio;
widthPMOSBitlineEqual = MIN_NMOS_SIZE * tech->featureSize;
widthPMOSBitlinePrecharger = 6 * tech->featureSize;
capLoadInv = CalculateGateCap(widthPMOSBitlineEqual, *tech) + 2 * CalculateGateCap(widthPMOSBitlinePrecharger, *tech)
+ CalculateDrainCap(widthInvNmos, NMOS, tech->featureSize*40, *tech)
+ CalculateDrainCap(widthInvPmos, PMOS, tech->featureSize*40, *tech);
capOutputBitlinePrecharger = CalculateDrainCap(widthPMOSBitlinePrecharger, PMOS, tech->featureSize*40, *tech) + CalculateDrainCap(widthPMOSBitlineEqual, PMOS, tech->featureSize*40, *tech);
double capInputInv = CalculateGateCap(widthInvNmos, *tech) + CalculateGateCap(widthInvPmos, *tech);
capLoadPerColumn = capInputInv + capWireLoadPerColumn;
double capLoadOutputDriver = numColumn * capLoadPerColumn;
outputDriver.Initialize(1, capInputInv, capLoadOutputDriver, 0 /* TO-DO */, true, latency_first, 0); /* Always Latency First */
initialized = true;
}
void Precharger::CalculateArea() {
if (!initialized) {
cout << "[Precharger] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateArea();
double hBitlinePrechareger, wBitlinePrechareger;
double hBitlineEqual, wBitlineEqual;
double hInverter, wInverter;
CalculateGateArea(INV, 1, 0, widthPMOSBitlinePrecharger, tech->featureSize*40, *tech, &hBitlinePrechareger, &wBitlinePrechareger);
CalculateGateArea(INV, 1, 0, widthPMOSBitlineEqual, tech->featureSize*40, *tech, &hBitlineEqual, &wBitlineEqual);
CalculateGateArea(INV, 1, widthInvNmos, widthInvPmos, tech->featureSize*40, *tech, &hInverter, &wInverter);
width = 2 * wBitlinePrechareger + wBitlineEqual;
width = MAX(width, wInverter);
width *= numColumn;
width = MAX(width, outputDriver.width);
height = MAX(hBitlinePrechareger, hBitlineEqual);
height += hInverter;
height = MAX(height, outputDriver.height);
area = height * width;
}
}
void Precharger::CalculateRC() {
if (!initialized) {
cout << "[Precharger] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateRC();
//more accurate RC model would include drain Capacitances of Precharger and Equalization PMOS transistors
}
}
void Precharger::CalculateLatency(double _rampInput){
if (!initialized) {
cout << "[Precharger] Error: Require initialization first!" << endl;
} else {
rampInput= _rampInput;
outputDriver.CalculateLatency(rampInput);
enableLatency = outputDriver.readLatency;
double resPullDown;
double tr; /* time constant */
double gm; /* transconductance */
double beta; /* for horowitz calculation */
double temp;
resPullDown = CalculateOnResistance(widthInvNmos, NMOS, inputParameter->temperature, *tech);
tr = resPullDown * capLoadInv;
gm = CalculateTransconductance(widthInvNmos, NMOS, *tech);
beta = 1 / (resPullDown * gm);
enableLatency += horowitz(tr, beta, outputDriver.rampOutput, &temp);
readLatency = 0;
double resPullUp = CalculateOnResistance(widthPMOSBitlinePrecharger, PMOS,
inputParameter->temperature, *tech);
double tau = resPullUp * (capBitline + capOutputBitlinePrecharger) + resBitline * capBitline / 2;
gm = CalculateTransconductance(widthPMOSBitlinePrecharger, PMOS, *tech);
beta = 1 / (resPullUp * gm);
readLatency += horowitz(tau, beta, temp, &rampOutput);
writeLatency = readLatency;
refreshLatency = readLatency;
}
}
void Precharger::CalculatePower() {
if (!initialized) {
cout << "[Precharger] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculatePower();
/* Leakage power */
leakage = outputDriver.leakage;
leakage += numColumn * tech->vdd * CalculateGateLeakage(INV, 1, widthInvNmos, widthInvPmos, inputParameter->temperature, *tech);
leakage += numColumn * voltagePrecharge * CalculateGateLeakage(INV, 1, 0, widthPMOSBitlinePrecharger,
inputParameter->temperature, *tech);
/* Dynamic energy */
/* We don't count bitline precharge energy into account because it is a charging process */
readDynamicEnergy = outputDriver.readDynamicEnergy;
readDynamicEnergy += capLoadInv * tech->vdd * tech->vdd * numColumn;
writeDynamicEnergy = 0; /* No precharging is needed during the write operation */
refreshDynamicEnergy = readDynamicEnergy;
}
}
void Precharger::PrintProperty() {
cout << "Precharger Properties:" << endl;
FunctionUnit::PrintProperty();
}
Precharger & Precharger::operator=(const Precharger &rhs) {
height = rhs.height;
width = rhs.width;
area = rhs.area;
readLatency = rhs.readLatency;
writeLatency = rhs.writeLatency;
refreshLatency = rhs.refreshLatency;
readDynamicEnergy = rhs.readDynamicEnergy;
writeDynamicEnergy = rhs.writeDynamicEnergy;
refreshDynamicEnergy = rhs.refreshDynamicEnergy;
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;
outputDriver = rhs.outputDriver;
capBitline = rhs.capBitline;
resBitline = rhs.resBitline;
capLoadInv = rhs.capLoadInv;
capOutputBitlinePrecharger = rhs.capOutputBitlinePrecharger;
capWireLoadPerColumn = rhs.capWireLoadPerColumn;
resWireLoadPerColumn = rhs.resWireLoadPerColumn;
enableLatency = rhs.enableLatency;
numColumn = rhs.numColumn;
widthPMOSBitlinePrecharger = rhs.widthPMOSBitlinePrecharger;
widthPMOSBitlineEqual = rhs.widthPMOSBitlineEqual;
capLoadPerColumn = rhs.capLoadPerColumn;
rampInput = rhs.rampInput;
rampOutput = rhs.rampOutput;
return *this;
}