forked from eva-cam/EvaCAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CAM_CustomSA.cpp
204 lines (179 loc) · 8.88 KB
/
CAM_CustomSA.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
198
199
200
201
202
203
204
#include "formula.h"
#include "global.h"
#include "constant.h"
#include <math.h>
void CalcAreaForCostomSA(int designNum, double widthTransistorRegion, Technology tech, double *_width, double *_height){
double width = 0;
double height = 0;
double tempHeight = 0;
double tempWidth = 0;
double tempParallelWidth = 0;
double tempParallelHeight = 0;
//**************************************************************************************************************
// [Shuangchen] DASR-VSA (3k-7.5k)
//**************************************************************************************************************
if(designNum == 1){
//////////////////////////////////////////////////////////
double W_ref_P = 0.5;
double W_ref_n = 25;
double W_refpre_p = 30;
double W_pre_p = 20;
double W_amp_p = 2;
double W_amp_n = 20;
double W_amppre_p = 40;
double W_ampen_n = 30;
//////////////////////////////////////////////////////////
// from pre-running we see the width constraint is 47F
// Mrefp + Mrefn (0.5+20<47), horizental
tempParallelWidth = 0;
CalculateGateArea(INV, 1, 0, W_ref_P * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth = tempWidth;
tempParallelHeight = tempHeight;
tempParallelWidth += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, W_ref_n * tech.featureSize, 0, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth += tempWidth;
tempParallelHeight = MAX(tempParallelHeight, tempHeight);
width = MAX(width, tempParallelWidth);
height += tempParallelHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
// Mrefpre (30<47)
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 0, W_refpre_p * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += tempHeight;
// Mpre + Mampp (20+2<47) x2
height += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 0, W_pre_p * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth = tempWidth;
tempParallelHeight = tempHeight;
tempParallelWidth += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 0, W_amp_p * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth += tempWidth;
tempParallelHeight = MAX(tempParallelHeight, tempHeight);
width = MAX(width, tempParallelWidth);
height += tempParallelHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
height += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
height += tempParallelHeight;
// Mampn x2 (20+20<47)
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, W_amp_n * tech.featureSize, 0, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth = tempWidth;
tempParallelHeight = tempHeight;
tempParallelWidth += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, W_amp_n * tech.featureSize, 0, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth += tempWidth;
tempParallelHeight = MAX(tempParallelHeight, tempHeight);
width = MAX(width, tempParallelWidth);
height += tempParallelHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
// W_amppre_p (40<47)
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 0, W_amppre_p * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += tempHeight;
// W_ampen_n (30<47)
height += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, W_ampen_n * tech.featureSize, 0, widthTransistorRegion, tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += tempHeight;
// second amplifier with inv x2 & MUX all in horizental
CalculateGateArea(INV, 1, 1 * tech.featureSize, 2 * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
width = MAX(width, tempWidth);
height += tempHeight;
}
//**************************************************************************************************************
//**************************************************************************************************************
// [Shuangchen] CSB-SA (3k-7.5k)
//**************************************************************************************************************
if(designNum == 2){
//////////////////////////////////////////////////////////
double W_ref_P = 20;
double Cs = 1/1e15;
//////////////////////////////////////////////////////////
// from pre-running we see the width constraint is 47F
// Mrefp + Mrefn (20+20<47), horizental
CalculateGateArea(INV, 1, 0, W_ref_P * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempParallelWidth += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
width = MAX(width, tempWidth);
height += tempHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
tempHeight = Cs / CalculateGateCap(widthTransistorRegion, tech) * tech.featureSize;
height += 2*tempHeight;
// latch and enable in one line
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 1 * tech.featureSize, 0, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempWidth *= 3;
tempWidth += MIN_GAP_BET_SAME_TYPE_DIFFS * tech.featureSize;
width = MAX(width, tempWidth);
height += tempHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
// switches, 4 in one line
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 1 * tech.featureSize, 2 * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempWidth *= 4;
tempWidth += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
width = MAX(width, tempWidth);
height += tempHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
// 2-stage amplify, in one line
height += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
CalculateGateArea(INV, 1, 1 * tech.featureSize, 2 * tech.featureSize, widthTransistorRegion, tech, &tempWidth, &tempHeight);
tempWidth *= 2;
tempWidth += MIN_GAP_BET_P_AND_N_DIFFS * tech.featureSize;
width = MAX(width, tempWidth);
height += tempHeight;
if(width > widthTransistorRegion) {
cout << "[Custom SA Area Calculation Error]: Exceed the width constraint, needs fold!" << endl;
}
}
//**************************************************************************************************************
*_width = width;
*_height = height;
}
void CalcCapForCostomSA(int designNum, double widthTransistorRegion, Technology tech, double *CapLoad) {
if(designNum == 1){
//////////////////////////////////////////////////////////
double W_ref_P = 0.5;
double W_ref_n = 25;
double W_refpre_p = 30;
double W_pre_p = 20;
double W_amp_p = 2;
double W_amp_n = 20;
double W_amppre_p = 40;
double W_ampen_n = 30;
//////////////////////////////////////////////////////////
*CapLoad = CalculateGateCap((W_amp_p + W_amp_n) * tech.featureSize, tech)
+ CalculateGateCap((W_ref_n) * tech.featureSize, tech)
+ CalculateDrainCap(W_amp_p * tech.featureSize, PMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(W_pre_p * tech.featureSize, PMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(W_pre_p * tech.featureSize, PMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(1 * tech.featureSize, NMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(2 * tech.featureSize, PMOS, widthTransistorRegion, tech)
+ CalculateGateCap((1 + 2) * tech.featureSize, tech);
}
if(designNum == 2){
//////////////////////////////////////////////////////////
double W_ref_P = 20;
double Cs = 1/1e15;
//////////////////////////////////////////////////////////
*CapLoad = Cs
+ CalculateGateCap(1 * tech.featureSize, tech)
+ CalculateDrainCap(1 * tech.featureSize, NMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(2 * tech.featureSize, PMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(1 * tech.featureSize, NMOS, widthTransistorRegion, tech)
+ CalculateDrainCap(W_ref_P * tech.featureSize, PMOS, widthTransistorRegion, tech);
}
}