-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCAM_PriorityEncoder.cpp
124 lines (106 loc) · 3.43 KB
/
CAM_PriorityEncoder.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
/*
* CAM_PriorityEncoder.cpp
*
*/
#include "CAM_PriorityEncoder.h"
#include "global.h"
#include "formula.h"
CAM_PriorityEncoder::CAM_PriorityEncoder() {
// TODO Auto-generated constructor stub
initialized = false;
capLoad = 0;
resLoad = 0;
numInputBits = 0;
rampInput = rampOutput = 0;
areaOptimizationLevel = latency_first;
capNorInput = capNorOutput = 0;
widthNorN = widthNorP = 0;
}
CAM_PriorityEncoder::~CAM_PriorityEncoder() {
// TODO Auto-generated destructor stub
}
void CAM_PriorityEncoder::Initialize(int _numInputBits, BufferDesignTarget _areaOptimizationLevel, double _capLoad, double _resLoad){
if (initialized)
cout << "[CAM_MMR] Warning: Already initialized!" << endl;
capLoad = _capLoad;
resLoad = _resLoad;
numInputBits = _numInputBits;
areaOptimizationLevel = _areaOptimizationLevel;
Encoder.Initialize(numInputBits, areaOptimizationLevel, capLoad, resLoad);
widthNorN = MIN_NMOS_SIZE * tech->featureSize;
widthNorP = tech->pnSizeRatio * MIN_NMOS_SIZE * tech->featureSize;
CalculateGateCapacitance(NOR, 2, widthNorN, widthNorP, tech->featureSize*MAX_TRANSISTOR_HEIGHT, *tech, &capNorInput, &capNorOutput);
MMR.Initialize(numInputBits, areaOptimizationLevel, capNorInput, 0 /*TODO gate resistance */);
initialized = true;
}
void CAM_PriorityEncoder::CalculateArea(){
if (!initialized) {
cout << "[CAM_MMR] Error: Require initialization first!" << endl;
} else {
area = 0;
Encoder.CalculateArea();
MMR.CalculateArea();
area = Encoder.area + MMR.area;
// TODO: a better layout may needed
height = MMR.height;
width = area / height;
}
}
void CAM_PriorityEncoder::CalculateRC() {
if (!initialized) {
cout << "[CAM_MMR] Error: Require initialization first!" << endl;
} else {
MMR.CalculateRC();
Encoder.CalculateRC();
}
}
void CAM_PriorityEncoder::CalculateLatency(double _rampInput) {
if (!initialized) {
cout << "[CAM_MMR] Error: Require initialization first!" << endl;
} else {
rampInput = _rampInput;
MMR.CalculateLatency(rampInput);
Encoder.CalculateLatency(MMR.rampOutput);
readLatency = MMR.readLatency + Encoder.readLatency;
writeLatency = readLatency;
rampOutput = Encoder.rampOutput;
}
}
void CAM_PriorityEncoder::CalculatePower() {
if (!initialized) {
cout << "[CAM_MMR] Error: Require initialization first!" << endl;
} else {
readDynamicEnergy = 0;
MMR.CalculatePower();
Encoder.CalculatePower();
leakage = MMR.leakage + Encoder.leakage;
readDynamicEnergy = MMR.readDynamicEnergy + Encoder.readDynamicEnergy;
writeDynamicEnergy = readDynamicEnergy;
}
}
void CAM_PriorityEncoder::PrintProperty() {
cout << "CAM_MMR Properties:" << endl;
FunctionUnit::PrintProperty();
}
CAM_PriorityEncoder & CAM_PriorityEncoder::operator=(const CAM_PriorityEncoder &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;
resLoad = rhs.resLoad;
numInputBits = rhs.numInputBits;
rampInput = rhs.rampInput;
rampOutput = rhs.rampOutput;
areaOptimizationLevel = rhs.areaOptimizationLevel;
widthNorN = rhs.widthNorN;
widthNorP = rhs.widthNorP;
capNorInput = rhs.capNorInput;
capNorOutput = rhs.capNorOutput;
return *this;
}