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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
/* Copyright (c) 2012 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "model/std_cells/CellMacros.h"
#include <cmath>
#include <vector>
#include "model/std_cells/StdCell.h"
#include "model/timing_graph/ElectricalNet.h"
#include "model/timing_graph/ElectricalDriver.h"
#include "model/timing_graph/ElectricalLoad.h"
namespace DSENT
{
//-------------------------------------------------------------------------
// NOR2 Macro (TODO: Generalize to N-input macro once leakage calc is done)
//-------------------------------------------------------------------------
void CellMacros::addNor2(StdCell* cell_, const String& name_,
bool sizable_, bool a1_to_zn_path_, bool a2_to_zn_path_,
const String& a1_net_, const String& a2_net_, const String& zn_net_)
{
//Create electrical timing model for the nand
// Construct loads and drivers
cell_->createLoad(name_ + "_CgA1");
cell_->createLoad(name_ + "_CgA2");
cell_->createLoad(name_ + "_CdZN");
cell_->createDriver(name_ + "_RonZN", sizable_);
//Get references to loads and drivers
ElectricalLoad* gate_a1_load = cell_->getLoad(name_ + "_CgA1");
ElectricalLoad* gate_a2_load = cell_->getLoad(name_ + "_CgA2");
ElectricalLoad* drain_load = cell_->getLoad(name_ + "_CdZN");
ElectricalDriver* zn_drive = cell_->getDriver(name_ + "_RonZN");
ElectricalNet* a1_net = cell_->getNet(a1_net_);
ElectricalNet* a2_net = cell_->getNet(a2_net_);
ElectricalNet* zn_net = cell_->getNet(zn_net_);
//Add loads and drivers to the specified nets
a1_net->addDownstreamNode(gate_a1_load);
a2_net->addDownstreamNode(gate_a2_load);
zn_net->addDownstreamNode(drain_load);
if (a1_to_zn_path_) gate_a1_load->addDownstreamNode(zn_drive);
if (a2_to_zn_path_) gate_a2_load->addDownstreamNode(zn_drive);
zn_drive->addDownstreamNode(zn_net);
return;
}
void CellMacros::updateNor2(StdCell* cell_, const String& name_, double normalized_size_)
{
ASSERT(normalized_size_ >= 0.0, "[Error] " + cell_->getInstanceName() +
" -> Cannot update a macro with a negative normalized size!");
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
// Get technology parameters
double vdd = tech->get("Vdd");
double gate_cap = tech->get("Gate->CapPerWidth");
double drain_cap = tech->get("Drain->CapPerWidth");
double nmos_eff_res = tech->get("Nmos->EffResWidth");
double pmos_eff_res = tech->get("Pmos->EffResWidth");
double pmos_eff_res_stack_ratio = tech->get("Pmos->EffResStackRatio");
double gate_pitch_contacted = tech->get("Gate->PitchContacted");
double metal1_wire_min_width = tech->get("Wire->Metal1->MinWidth");
//Calculate number of folds and gate pitches needed
unsigned int folds = (normalized_size_ < 1.0) ? 1 : (unsigned int)ceil(normalized_size_);
cell_->getGenProperties()->set(name_ + "_GatePitches", 2 * folds);
//Calculate widths, making sure they are above the minimum width
double nmos_width = std::max(calculateNmosWidth(cell_, 1, 2, 1) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
double pmos_width = std::max(calculatePmosWidth(cell_, 1, 2, 2) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
//Calculate leakage power for each given input state
double leakage_power_00 = vdd * folds * 2 * tech->calculateNmosLeakageCurrent(1, nmos_width, 0x0);
double leakage_power_01 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x1);
double leakage_power_10 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x2);
double leakage_power_11 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x3);
cell_->getGenProperties()->set(name_ + "_LeakagePower_00", leakage_power_00);
cell_->getGenProperties()->set(name_ + "_LeakagePower_01", leakage_power_01);
cell_->getGenProperties()->set(name_ + "_LeakagePower_10", leakage_power_10);
cell_->getGenProperties()->set(name_ + "_LeakagePower_11", leakage_power_11);
//Calculate R_on and capacitances
double pmos_stack2_balance = 1.0 + pmos_eff_res_stack_ratio;
double c_g = (nmos_width + pmos_width) * gate_cap * folds;
double c_d = (2 * pmos_width + 2 * nmos_width) * drain_cap * folds;
double r_on = (nmos_eff_res / nmos_width + pmos_stack2_balance * pmos_eff_res / pmos_width) / (folds * 2.0);
// Estimate the wire cap and add them all at the output
double cell_height = cell_->getTotalHeight();
double wire_width = metal1_wire_min_width;
double wire_spacing = gate_pitch_contacted - metal1_wire_min_width;
double wire_length = 2.0 * folds * cell_height;
double wire_cap = tech->calculateWireCapacitance("Metal1", wire_width, wire_spacing, wire_length);
// Construct equivalent load and drive strength
cell_->getLoad(name_ + "_CgA1")->setLoadCap(c_g);
cell_->getLoad(name_ + "_CgA2")->setLoadCap(c_g);
cell_->getLoad(name_ + "_CdZN")->setLoadCap(c_d + wire_cap);
cell_->getDriver(name_ + "_RonZN")->setOutputRes(r_on);
// Calculate flip energies
double zn_flip_energy = 0.5 * (c_d + wire_cap) * vdd * vdd;
double a1_flip_energy = 0.5 * c_g * vdd * vdd;
double a2_flip_energy = 0.5 * c_g * vdd * vdd;
cell_->getGenProperties()->set(name_ + "_ZN_Flip", zn_flip_energy);
cell_->getGenProperties()->set(name_ + "_A1_Flip", a1_flip_energy);
cell_->getGenProperties()->set(name_ + "_A2_Flip", a2_flip_energy);
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// NAND2 Macro (TODO: Generalize to N-input macro once leakage calc is done)
//-------------------------------------------------------------------------
//Adds a NAND2 to the standard cell, normalized to some size
void CellMacros::addNand2(StdCell* cell_, const String& name_,
bool sizable_, bool a1_to_zn_path_, bool a2_to_zn_path_,
const String& a1_net_, const String& a2_net_, const String& zn_net_)
{
//Create electrical timing model for the nor
// Construct loads and drivers
cell_->createLoad(name_ + "_CgA1");
cell_->createLoad(name_ + "_CgA2");
cell_->createLoad(name_ + "_CdZN");
cell_->createDriver(name_ + "_RonZN", sizable_);
//Get references to loads and drivers
ElectricalLoad* gate_a1_load = cell_->getLoad(name_ + "_CgA1");
ElectricalLoad* gate_a2_load = cell_->getLoad(name_ + "_CgA2");
ElectricalLoad* drain_load = cell_->getLoad(name_ + "_CdZN");
ElectricalDriver* zn_drive = cell_->getDriver(name_ + "_RonZN");
ElectricalNet* a1_net = cell_->getNet(a1_net_);
ElectricalNet* a2_net = cell_->getNet(a2_net_);
ElectricalNet* zn_net = cell_->getNet(zn_net_);
a1_net->addDownstreamNode(gate_a1_load);
a2_net->addDownstreamNode(gate_a2_load);
zn_net->addDownstreamNode(drain_load);
if (a1_to_zn_path_) gate_a1_load->addDownstreamNode(zn_drive);
if (a2_to_zn_path_) gate_a2_load->addDownstreamNode(zn_drive);
zn_drive->addDownstreamNode(zn_net);
return;
}
//Updates a NAND2 to to the standard cell, normalized to some size
void CellMacros::updateNand2(StdCell* cell_, const String& name_, double normalized_size_)
{
ASSERT(normalized_size_ >= 0.0, "[Error] " + cell_->getInstanceName() +
" -> Cannot update a macro with a negative normalized size!");
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
// Get technology parameters
double vdd = tech->get("Vdd");
double gate_cap = tech->get("Gate->CapPerWidth");
double drain_cap = tech->get("Drain->CapPerWidth");
double nmos_eff_res = tech->get("Nmos->EffResWidth");
double pmos_eff_res = tech->get("Pmos->EffResWidth");
double nmos_eff_res_stack_ratio = tech->get("Nmos->EffResStackRatio");
double gate_pitch_contacted = tech->get("Gate->PitchContacted");
double metal1_wire_min_width = tech->get("Wire->Metal1->MinWidth");
//Calculate number of folds needed
unsigned int folds = (normalized_size_ < 1.0) ? 1 : (unsigned int)ceil(normalized_size_);
cell_->getGenProperties()->set(name_ + "_GatePitches", 2 * folds);
//Calculate widths, making sure they are above the minimum width
double nmos_width = std::max(calculateNmosWidth(cell_, 2, 1, 2) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
double pmos_width = std::max(calculatePmosWidth(cell_, 2, 1, 1) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
// Leakage power calculation
double leakage_power_00 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x0);
double leakage_power_01 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x1);
double leakage_power_10 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x2);
double leakage_power_11 = vdd * folds * 2 * tech->calculatePmosLeakageCurrent(1, pmos_width, ~0x3);
cell_->getGenProperties()->set(name_ + "_LeakagePower_00", leakage_power_00);
cell_->getGenProperties()->set(name_ + "_LeakagePower_01", leakage_power_01);
cell_->getGenProperties()->set(name_ + "_LeakagePower_10", leakage_power_10);
cell_->getGenProperties()->set(name_ + "_LeakagePower_11", leakage_power_11);
// Get input parameters
double nmos_stack2_balance = 1.0 + nmos_eff_res_stack_ratio;
//Calculate caps
double c_g = (nmos_width + pmos_width) * gate_cap * folds;
double c_d = (2 * pmos_width + 2 * nmos_width) * drain_cap * folds;
double r_on = (nmos_stack2_balance * nmos_eff_res / nmos_width + pmos_eff_res / pmos_width) / (folds * 2.0);
// Estimate the wire cap and add them all at the output
double cell_height = cell_->getTotalHeight();
double wire_width = metal1_wire_min_width;
double wire_spacing = gate_pitch_contacted - metal1_wire_min_width;
double wire_length = 2.0 * folds * cell_height;
double wire_cap = tech->calculateWireCapacitance("Metal1", wire_width, wire_spacing, wire_length);
// Construct equivalent load and drive strength
cell_->getLoad(name_ + "_CgA1")->setLoadCap(c_g);
cell_->getLoad(name_ + "_CgA2")->setLoadCap(c_g);
cell_->getLoad(name_ + "_CdZN")->setLoadCap(c_d + wire_cap);
cell_->getDriver(name_ + "_RonZN")->setOutputRes(r_on);
// Calculate flip energies
double zn_flip_energy = 0.5 * (c_d + wire_cap) * vdd * vdd;
double a1_flip_energy = 0.5 * c_g * vdd * vdd;
double a2_flip_energy = 0.5 * c_g * vdd * vdd;
cell_->getGenProperties()->set(name_ + "_ZN_Flip", zn_flip_energy);
cell_->getGenProperties()->set(name_ + "_A1_Flip", a1_flip_energy);
cell_->getGenProperties()->set(name_ + "_A2_Flip", a2_flip_energy);
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// INV Macro
//-------------------------------------------------------------------------
//Adds an inverter to the model, normalized to some size
void CellMacros::addInverter(StdCell* cell_, const String& name_,
bool sizable_, bool a_to_zn_path_,
const String& a_net_, const String& zn_net_)
{
//Create electrical timing model for the inverter
// Construct loads and drivers
cell_->createLoad(name_ + "_CgA");
cell_->createLoad(name_ + "_CdZN");
cell_->createDriver(name_ + "_RonZN", sizable_);
//Get references to loads and drivers
ElectricalLoad* gate_load = cell_->getLoad(name_ + "_CgA");
ElectricalLoad* drain_load = cell_->getLoad(name_ + "_CdZN");
ElectricalDriver* out_drive = cell_->getDriver(name_ + "_RonZN");
ElectricalNet* a_net = cell_->getNet(a_net_);
ElectricalNet* zn_net = cell_->getNet(zn_net_);
// Setup connectivity of loads and drivers
a_net->addDownstreamNode(gate_load);
if (a_to_zn_path_) gate_load->addDownstreamNode(out_drive);
zn_net->addDownstreamNode(drain_load);
out_drive->addDownstreamNode(zn_net);
return;
}
//Updates the numbers of an inverter for some normalized size
void CellMacros::updateInverter(StdCell* cell_, const String& name_, double normalized_size_)
{
ASSERT(normalized_size_ >= 0.0, "[Error] " + cell_->getInstanceName() +
" -> Cannot update a macro with a negative normalized size!");
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
//Get values from technology library
double vdd = tech->get("Vdd");
double gate_cap = tech->get("Gate->CapPerWidth");
double drain_cap = tech->get("Drain->CapPerWidth");
double nmos_eff_res = tech->get("Nmos->EffResWidth");
double pmos_eff_res = tech->get("Pmos->EffResWidth");
double gate_pitch_contacted = tech->get("Gate->PitchContacted");
double metal1_wire_min_width = tech->get("Wire->Metal1->MinWidth");
//Calculate number of folds needed
unsigned int folds = (normalized_size_ < 1.0) ? 1 : (unsigned int)ceil(normalized_size_);
cell_->getGenProperties()->set(name_ + "_GatePitches", folds);
//Calculate widths, making sure they are above the minimum width
double nmos_width = std::max(calculateNmosWidth(cell_, 1, 1, 1) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
double pmos_width = std::max(calculatePmosWidth(cell_, 1, 1, 1) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
//Calculate leakage power for each given input state
double leakage_power_0 = vdd * folds * tech->calculateNmosLeakageCurrent(1, nmos_width, 0x0);
double leakage_power_1 = vdd * folds * tech->calculatePmosLeakageCurrent(1, pmos_width, ~0x1);
cell_->getGenProperties()->set(name_ + "_LeakagePower_0", leakage_power_0);
cell_->getGenProperties()->set(name_ + "_LeakagePower_1", leakage_power_1);
//Calculate caps
double c_g = (nmos_width + pmos_width) * gate_cap * folds;
double c_d = (pmos_width + nmos_width) * drain_cap * folds;
double r_on = (nmos_eff_res / nmos_width + pmos_eff_res / pmos_width) / (folds * 2.0);
// Estimate the wire cap and add them all at the output
double cell_height = cell_->getTotalHeight();
double wire_width = metal1_wire_min_width;
double wire_spacing = gate_pitch_contacted - metal1_wire_min_width;
double wire_length = folds * cell_height;
double wire_cap = tech->calculateWireCapacitance("Metal1", wire_width, wire_spacing, wire_length);
// Construct equivalent load and drive strength
cell_->getLoad(name_ + "_CgA")->setLoadCap(c_g);
cell_->getLoad(name_ + "_CdZN")->setLoadCap(c_d + wire_cap);
cell_->getDriver(name_ + "_RonZN")->setOutputRes(r_on);
// Calculate flip energy (output flip)
// Calculate flip energies
double zn_flip_energy = 0.5 * (c_d + wire_cap) * vdd * vdd;
double a_flip_energy = 0.5 * c_g * vdd * vdd;
cell_->getGenProperties()->set(name_ + "_ZN_Flip", zn_flip_energy);
cell_->getGenProperties()->set(name_ + "_A_Flip", a_flip_energy);
return;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// INVZ Macro
//-------------------------------------------------------------------------
//Adds a tristated inverter to the model, normalized to some size
void CellMacros::addTristate(StdCell* cell_, const String& name_,
bool sizable_, bool a_to_zn_path_, bool oe_to_zn_path_, bool oen_to_zn_path_,
const String& a_net_, const String& oe_net_, const String& oen_net_, const String& zn_net_)
{
// Construct loads and drivers
cell_->createLoad(name_ + "_CgA");
cell_->createLoad(name_ + "_CgOE");
cell_->createLoad(name_ + "_CgOEN");
cell_->createLoad(name_ + "_CdZN");
cell_->createDriver(name_ + "_RonZN", sizable_);
// Get references to loads, nets and drivers
ElectricalLoad* gate_a_load = cell_->getLoad(name_ + "_CgA");
ElectricalLoad* gate_oe_load = cell_->getLoad(name_ + "_CgOE");
ElectricalLoad* gate_oen_load = cell_->getLoad(name_ + "_CgOEN");
ElectricalLoad* drain_load = cell_->getLoad(name_ + "_CdZN");
ElectricalDriver* out_drive = cell_->getDriver(name_ + "_RonZN");
ElectricalNet* a_net = cell_->getNet(a_net_);
ElectricalNet* oe_net = cell_->getNet(oe_net_);
ElectricalNet* oen_net = cell_->getNet(oen_net_);
ElectricalNet* zn_net = cell_->getNet(zn_net_);
// Setup connectivity of loads and drivers
a_net->addDownstreamNode(gate_a_load);
oe_net->addDownstreamNode(gate_oe_load);
oen_net->addDownstreamNode(gate_oen_load);
if (a_to_zn_path_) gate_a_load->addDownstreamNode(out_drive);
if (oe_to_zn_path_) gate_oe_load->addDownstreamNode(out_drive);
if (oen_to_zn_path_) gate_oen_load->addDownstreamNode(out_drive);
zn_net->addDownstreamNode(drain_load);
out_drive->addDownstreamNode(zn_net);
return;
}
//Updates the numbers of an inverter for some normalized size
void CellMacros::updateTristate(StdCell* cell_, const String& name_, double normalized_size_)
{
ASSERT(normalized_size_ >= 0.0, "[Error] " + cell_->getInstanceName() +
" -> Cannot update a macro with a negative normalized size!");
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
//Get values from technology library
double vdd = tech->get("Vdd");
double gate_cap = tech->get("Gate->CapPerWidth");
double drain_cap = tech->get("Drain->CapPerWidth");
double nmos_eff_res = tech->get("Nmos->EffResWidth");
double pmos_eff_res = tech->get("Pmos->EffResWidth");
double pmos_eff_res_stack_ratio = tech->get("Pmos->EffResStackRatio");
double nmos_eff_res_stack_ratio = tech->get("Nmos->EffResStackRatio");
double gate_pitch_contacted = tech->get("Gate->PitchContacted");
double metal1_wire_min_width = tech->get("Wire->Metal1->MinWidth");
//Calculate number of folds and gate pitches needed
unsigned int folds = (normalized_size_ < 1.0) ? 1 : (unsigned int)ceil(normalized_size_);
cell_->getGenProperties()->set(name_ + "_GatePitches", 2 * folds);
//Calculate widths, making sure they are above the minimum width
double nmos_width = std::max(calculateNmosWidth(cell_, 2, 2, 2) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
double pmos_width = std::max(calculatePmosWidth(cell_, 2, 2, 2) * normalized_size_ / folds, (double) tech->get("Gate->MinWidth"));
//Calculate leakage power for each given input state
//if output_enable = 0, then it is possible that the PMOS may leak (if output = 0),
//or the NMOS will leak (if output = 1)
//OE OEN A _ ZN
double leakage_power_010_0 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x2);
double leakage_power_010_1 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x0);
double leakage_power_011_0 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x3);
double leakage_power_011_1 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x1);
double leakage_power_100_1 = vdd * folds * tech->calculateNmosLeakageCurrent(2, nmos_width, 0x2);
double leakage_power_101_0 = vdd * folds * tech->calculatePmosLeakageCurrent(2, pmos_width, ~0x1);
cell_->getGenProperties()->set(name_ + "_LeakagePower_010_0", leakage_power_010_0);
cell_->getGenProperties()->set(name_ + "_LeakagePower_010_1", leakage_power_010_1);
cell_->getGenProperties()->set(name_ + "_LeakagePower_011_0", leakage_power_011_0);
cell_->getGenProperties()->set(name_ + "_LeakagePower_011_1", leakage_power_011_1);
cell_->getGenProperties()->set(name_ + "_LeakagePower_100_1", leakage_power_100_1);
cell_->getGenProperties()->set(name_ + "_LeakagePower_101_0", leakage_power_101_0);
//Caculate stack balance
double pmos_stack2_balance = 1.0 + pmos_eff_res_stack_ratio;
double nmos_stack2_balance = 1.0 + nmos_eff_res_stack_ratio;
//Calculate caps
double c_g_a = (nmos_width + pmos_width) * gate_cap * folds;
double c_g_oe = nmos_width * gate_cap * folds;
double c_g_oen = pmos_width * gate_cap * folds;
double c_d = (2 * pmos_width + 2 * nmos_width) * drain_cap * folds;
double r_on = (nmos_stack2_balance * nmos_eff_res / nmos_width + pmos_stack2_balance * pmos_eff_res / pmos_width) / (folds * 2.0);
// Estimate the wire cap and add them all at the output
double cell_height = cell_->getTotalHeight();
double wire_width = metal1_wire_min_width;
double wire_spacing = gate_pitch_contacted - metal1_wire_min_width;
double wire_length = 2.0 * folds * cell_height;
double wire_cap = tech->calculateWireCapacitance("Metal1", wire_width, wire_spacing, wire_length);
// Construct equivalent load and drive strength
cell_->getLoad(name_ + "_CgA")->setLoadCap(c_g_a);
cell_->getLoad(name_ + "_CgOE")->setLoadCap(c_g_oe);
cell_->getLoad(name_ + "_CgOEN")->setLoadCap(c_g_oen);
cell_->getLoad(name_ + "_CdZN")->setLoadCap(c_d + wire_cap);
cell_->getDriver(name_ + "_RonZN")->setOutputRes(r_on);
// Calculate flip energy (output flip)
double zn_flip_energy = 0.5 * (c_d + wire_cap) * vdd * vdd;
double a_flip_energy = 0.5 * c_g_a * vdd * vdd;
double oe_flip_energy = 0.5 * c_g_oe * vdd * vdd;
double oen_flip_energy = 0.5 * c_g_oen * vdd * vdd;
cell_->getGenProperties()->set(name_ + "_ZN_Flip", zn_flip_energy);
cell_->getGenProperties()->set(name_ + "_A_Flip", a_flip_energy);
cell_->getGenProperties()->set(name_ + "_OE_Flip", oe_flip_energy);
cell_->getGenProperties()->set(name_ + "_OEN_Flip", oen_flip_energy);
return;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Helper Functions
//-------------------------------------------------------------------------
//Returns the width of NMOS transistors, given the NMOS and PMOS stacking
double CellMacros::calculateNmosWidth(const StdCell* cell_, unsigned int max_stacked_nmos_, unsigned int max_stacked_pmos_, unsigned int current_stacked_nmos_)
{
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
double nmos_eff_res_stack_ratio = tech->get("Nmos->EffResStackRatio");
double pmos_eff_res_stack_ratio = tech->get("Pmos->EffResStackRatio");
double nmos_stack_balance = 1.0 + nmos_eff_res_stack_ratio * (double) (max_stacked_nmos_ - 1);
double pmos_stack_balance = 1.0 + pmos_eff_res_stack_ratio * (double) (max_stacked_pmos_ - 1);
double current_nmos_stack_balance = 1.0 + nmos_eff_res_stack_ratio * (double) (current_stacked_nmos_ - 1);
double pn_ratio = cell_->getPToNRatio();
double active_height = cell_->getActiveHeight();
//Calculate the width of the current device
double nmos_width = active_height * current_nmos_stack_balance / (nmos_stack_balance + pn_ratio * pmos_stack_balance);
return nmos_width;
}
//Returns the width of PMOS transistors, given the NMOS and PMOS stacking
double CellMacros::calculatePmosWidth(const StdCell* cell_, unsigned int max_stacked_nmos_, unsigned int max_stacked_pmos_, unsigned int current_stacked_pmos_)
{
//Grab pointer to tech model
const TechModel* tech = cell_->getTechModel();
double nmos_eff_res_stack_ratio = tech->get("Nmos->EffResStackRatio");
double pmos_eff_res_stack_ratio = tech->get("Pmos->EffResStackRatio");
double nmos_stack_balance = 1.0 + nmos_eff_res_stack_ratio * (double) (max_stacked_nmos_ - 1);
double pmos_stack_balance = 1.0 + pmos_eff_res_stack_ratio * (double) (max_stacked_pmos_ - 1);
double current_pmos_stack_balance = 1.0 + pmos_eff_res_stack_ratio * (double) (current_stacked_pmos_ - 1);
double pn_ratio = cell_->getPToNRatio();
double active_height = cell_->getActiveHeight();
//Calculate the width of the current device
double pmos_width = active_height * current_pmos_stack_balance * pn_ratio / (nmos_stack_balance + pn_ratio * pmos_stack_balance);
return pmos_width;
}
//-------------------------------------------------------------------------
} // namespace DSENT
|