-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCAM_DataBuffer.cpp
145 lines (130 loc) · 4.75 KB
/
CAM_DataBuffer.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
#include "CAM_DataBuffer.h"
#include "global.h"
#include "formula.h"
CAM_DataBuffer::CAM_DataBuffer() {
// TODO Auto-generated constructor stub
initialized = false;
capLoad = 0;
resLoad = 0;
capNandIn = 0;
capNandOut = 0;
widthNandN = 0;
widthNandP = 0;
rampInput = 0;
rampOutput = 0;
differential = false;
}
CAM_DataBuffer::~CAM_DataBuffer() {
// TODO Auto-generated destructor stub
}
void CAM_DataBuffer::Initialize(bool _differential, double _capLoad, double _resLoad){
if (initialized)
cout << "[CAM_DataBuffer] Warning: Already initialized!" << endl;
/* structure: D-latch, contains 4 nand */
capLoad = _capLoad;
resLoad = _resLoad;
differential = _differential;
/* gate sizing: built up with 2-input nand */
widthNandN = 2 * MIN_NMOS_SIZE * tech->featureSize;
widthNandP = tech->pnSizeRatio * MIN_NMOS_SIZE * tech->featureSize;
/* logic effort: two stages of nand and then to the driver */
double logicEffort = (2+tech->pnSizeRatio) / (1+tech->pnSizeRatio);
logicEffort *= logicEffort;
/* driver's cap-in: both the input and output of nand */
CalculateGateCapacitance(NAND, 2, widthNandN, widthNandP, tech->featureSize*MAX_TRANSISTOR_HEIGHT, *tech, &capNandIn, &capNandOut);
outputDriver.Initialize(logicEffort, capNandIn+capNandOut, capLoad, resLoad, false, latency_first, 0);
initialized = true;
}
void CAM_DataBuffer::CalculateArea(){
if (!initialized) {
cout << "[CAM_DataBuffer] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateArea();
height = outputDriver.height * (1+differential);
width = outputDriver.width * (1+differential);
double hNand, wNand;
CalculateGateArea(NAND, 2, widthNandN, widthNandP, tech->featureSize*MAX_TRANSISTOR_HEIGHT, *tech, &hNand, &wNand);
width += wNand*2;
height = MAX(height, hNand*2);
area = height * width;
}
}
void CAM_DataBuffer::CalculateRC() {
if (!initialized) {
cout << "[CAM_DataBuffer] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculateRC();
CalculateGateCapacitance(NAND, 2, widthNandN, widthNandP, tech->featureSize*MAX_TRANSISTOR_HEIGHT, *tech, &capNandIn, &capNandOut);
}
}
void CAM_DataBuffer::CalculateLatency(double _rampInput) {
if (!initialized) {
cout << "[DataBuffer] Error: Require initialization first!" << endl;
} else {
rampInput = _rampInput;
double resPullDown;
double cap;
double tr; /* time constant */
double gm; /* transconductance */
double beta; /* for horowitz calculation */
double rampInternal;
/* 2 stage nand and the driver */
resPullDown = CalculateOnResistance(widthNandN, NMOS, inputParameter->temperature, *tech);
cap = capNandOut + capNandIn;
tr = resPullDown * cap;
gm = CalculateTransconductance(widthNandN, NMOS, *tech);
beta = 1 / (resPullDown * gm);
readLatency = horowitz(tr, beta, rampInput, &rampInternal);
cap = capNandOut + outputDriver.capInput[0];
tr = resPullDown * cap;
readLatency += horowitz(tr, beta, rampInternal, &rampInternal);
rampOutput = rampInternal;
if (outputDriver.numStage > 0) {
outputDriver.CalculateLatency(rampInternal);
readLatency += outputDriver.readLatency;
rampOutput = outputDriver.rampOutput;
}
writeLatency = readLatency;
}
}
void CAM_DataBuffer::CalculatePower() {
if (!initialized) {
cout << "[CAM_DataBuffer] Error: Require initialization first!" << endl;
} else {
outputDriver.CalculatePower();
leakage = CalculateGateLeakage(NAND, 2, widthNandN, widthNandP, inputParameter->temperature, *tech) * tech->vdd *4;
leakage += ( outputDriver.leakage * (1+differential) );
/* 2 stage nand and the driver */
double cap;
cap = outputDriver.capInput[0] + capNandOut * 4 + capNandIn * 5;
readDynamicEnergy = cap * tech->vdd * tech->vdd;
readDynamicEnergy += ( outputDriver.readDynamicEnergy * (1+differential) );
writeDynamicEnergy = readDynamicEnergy;
}
}
void CAM_DataBuffer::PrintProperty() {
cout << "CAM_DataBuffer Properties:" << endl;
FunctionUnit::PrintProperty();
}
CAM_DataBuffer & CAM_DataBuffer::operator=(const CAM_DataBuffer &rhs) {
height = rhs.height;
width = rhs.width;
area = rhs.area;
readLatency = rhs.readLatency;
writeLatency = rhs.writeLatency;
readDynamicEnergy = rhs.readDynamicEnergy;
writeDynamicEnergy = rhs.writeDynamicEnergy;
leakage = rhs.leakage;
initialized = rhs.initialized;
capLoad = rhs.capLoad;
rampInput = rhs.rampInput;
rampOutput = rhs.rampOutput;
resLoad = rhs.resLoad;
capNandIn = rhs.capNandIn;
capNandOut = rhs.capNandOut;
widthNandN = rhs.widthNandN;
widthNandP = rhs.widthNandP;
rampInput = rhs.rampInput;
rampOutput = rhs.rampOutput;
return *this;
}