forked from sampsyo/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extio.cc
506 lines (379 loc) · 17 KB
/
extio.cc
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
499
500
501
502
503
504
505
506
#include "extio.h"
#include <cassert>
Extio::Extio(IOTechParam *iot):
io_param(iot){}
//External IO AREA. Does not include PHY or decap, includes only IO active circuit. More details can be found in the CACTI-IO technical report (), Chapter 2.3.
void Extio::extio_area()
{
//Area per IO, assuming drive stage and ODT are shared
double single_io_area = io_param->ioarea_c +
(io_param->ioarea_k0/io_param->r_on)+(1/io_param->r_on)*
(io_param->ioarea_k1*io_param->frequency +
io_param->ioarea_k2*io_param->frequency*io_param->frequency +
io_param->ioarea_k3*io_param->frequency*
io_param->frequency*io_param->frequency); // IO Area in sq.mm.
//Area per IO if ODT requirements are more stringent than the Ron
//requirements in determining size of driver
if (2*io_param->rtt1_dq_read < io_param->r_on) {
single_io_area = io_param->ioarea_c +
(io_param->ioarea_k0/(2*io_param->rtt1_dq_read))+
(1/io_param->r_on)*(io_param->ioarea_k1*io_param->frequency +
io_param->ioarea_k2*io_param->frequency*io_param->frequency +
io_param->ioarea_k3*io_param->frequency*io_param->frequency*io_param->frequency);
}
//Total IO area
io_area = (g_ip->num_dq + g_ip->num_dqs + g_ip->num_ca + g_ip->num_clk) *
single_io_area;
printf("IO Area (sq.mm) = ");
cout << io_area << endl;
}
//External IO Termination Power. More details can be found in the CACTI-IO technical report (), Chapter 2.1.
void Extio::extio_power_term()
{
//IO Termination and Bias Power
//Bias and Leakage Power
power_bias = io_param->i_bias * io_param->vdd_io +
io_param->i_leak * (g_ip->num_dq +
g_ip->num_dqs +
g_ip->num_clk +
g_ip->num_ca) * io_param->vdd_io/1000000;
//Termination Power
power_termination_read = 1000 * (g_ip->num_dq + g_ip->num_dqs) *
io_param->vdd_io * io_param->vdd_io * 0.25 *
(1/(io_param->r_on + io_param->rpar_read + io_param->rs1_dq) +
1/(io_param->rtt1_dq_read) + 1/(io_param->rtt2_dq_read)) +
1000 * g_ip->num_ca * io_param->vdd_io * io_param->vdd_io *
(0.5 / (2 * (io_param->r_on_ca + io_param->rtt_ca)));
power_termination_write = 1000 * (g_ip->num_dq + g_ip->num_dqs) *
io_param->vdd_io * io_param->vdd_io * 0.25 *
(1/(io_param->r_on + io_param->rpar_write) +
1/(io_param->rtt1_dq_write) + 1/(io_param->rtt2_dq_write)) +
1000 * g_ip->num_ca * io_param->vdd_io * io_param->vdd_io *
(0.5 / (2 * (io_param->r_on_ca + io_param->rtt_ca)));
power_clk_bias = io_param->vdd_io * io_param->v_sw_clk / io_param->r_diff_term * 1000;
if (io_param->io_type == Serial)
{ power_termination_read= 1000*(g_ip->num_dq)*io_param->vdd_io*io_param->v_sw_clk/io_param->r_diff_term;
power_termination_write= 1000*(g_ip->num_dq)*io_param->vdd_io*io_param->v_sw_clk/io_param->r_diff_term;
power_clk_bias=0;
}
if (io_param->io_type == DDR4)
{
power_termination_read=1000 * (g_ip->num_dq + g_ip->num_dqs) *
io_param->vdd_io * io_param->vdd_io *0.5 * (1/(io_param->r_on + io_param->rpar_read + io_param->rs1_dq))
+ 1000 * g_ip->num_ca * io_param->vdd_io * io_param->vdd_io *
(0.5 / (2 * (io_param->r_on_ca + io_param->rtt_ca)));
power_termination_write = 1000 * (g_ip->num_dq + g_ip->num_dqs) *
io_param->vdd_io * io_param->vdd_io * 0.5 *
(1/(io_param->r_on + io_param->rpar_write)) +
1000 * g_ip->num_ca * io_param->vdd_io * io_param->vdd_io *
(0.5 / (2 * (io_param->r_on_ca + io_param->rtt_ca)));
}
//Combining the power terms based on STATE (READ/WRITE/IDLE/SLEEP)
if (g_ip->iostate == READ)
{
io_power_term = g_ip->duty_cycle *
(power_termination_read + power_bias + power_clk_bias);
}
else if (g_ip->iostate == WRITE)
{
io_power_term = g_ip->duty_cycle *
(power_termination_write + power_bias + power_clk_bias);
}
else if (g_ip->iostate == IDLE)
{
io_power_term = g_ip->duty_cycle *
(power_termination_write + power_bias + power_clk_bias);
if (io_param->io_type == DDR4)
{ io_power_term = 1e-6*io_param->i_leak*io_param->vdd_io; // IDLE IO power for DDR4 is leakage since bus can be parked at VDDQ
}
}
else if (g_ip->iostate == SLEEP)
{
io_power_term = 1e-6*io_param->i_leak*io_param->vdd_io; //nA to mW
}
else
{
io_power_term = 0;
}
printf("IO Termination and Bias Power (mW) = ");
cout << io_power_term << endl;
}
//External PHY Power and Wakeup Times. More details can be found in the CACTI-IO technical report (), Chapter 2.1.
void Extio::extio_power_phy ()
{
phy_static_power = io_param->phy_datapath_s + io_param->phy_phase_rotator_s +
io_param->phy_clock_tree_s + io_param->phy_rx_s + io_param->phy_dcc_s +
io_param->phy_deskew_s + io_param->phy_leveling_s + io_param->phy_pll_s; // in mW
phy_dynamic_power = io_param->phy_datapath_d + io_param->phy_phase_rotator_d +
io_param->phy_clock_tree_d + io_param->phy_rx_d + io_param->phy_dcc_d +
io_param->phy_deskew_d + io_param->phy_leveling_d +
io_param->phy_pll_d; // in mW/Gbps
//Combining the power terms based on STATE (READ/WRITE/IDLE/SLEEP)
if (g_ip->iostate == READ)
{
phy_power = phy_static_power + 2 * io_param->frequency * g_ip->num_dq * phy_dynamic_power / 1000; // Total PHY power in mW
}
else if (g_ip->iostate == WRITE)
{
phy_power = phy_static_power + 2 * io_param->frequency * g_ip->num_dq * phy_dynamic_power / 1000; // Total PHY power in mW
}
else if (g_ip->iostate == IDLE)
{
phy_power = phy_static_power; // Total PHY power in mW
}
else if (g_ip->iostate == SLEEP)
{
phy_power = 0; // Total PHY power in mW;
}
else
{
phy_power = 0; // Total PHY power in mW;
}
phy_wtime = io_param->phy_pll_wtime + io_param->phy_phase_rotator_wtime + io_param->phy_rx_wtime + io_param->phy_bandgap_wtime + io_param->phy_deskew_wtime + io_param->phy_vrefgen_wtime; // Total Wakeup time from SLEEP to ACTIVE. Some of the Wakeup time can be hidden if all components do not need to be serially brought out of SLEEP. This depends on the implementation and user can modify the Wakeup times accordingly.
printf("PHY Power (mW) = ");
cout << phy_power << " ";
printf("PHY Wakeup Time (us) = ");
cout << phy_wtime << endl;
}
//External IO Dynamic Power. Does not include termination or PHY. More details can be found in the CACTI-IO technical report (), Chapter 2.1.
void Extio::extio_power_dynamic()
{
if (io_param->io_type == Serial)
{
power_dq_write = 0;
power_dqs_write = 0;
power_ca_write = 0;
power_dq_read = 0;
power_dqs_read = 0;
power_ca_read = 0;
power_clk = 0;
}
else
{
//Line capacitance calculations for effective c_line
double c_line =1e6/(io_param->z0*2*io_param->frequency); //For DDR signals: DQ, DQS, CLK
double c_line_ca=c_line; //For DDR CA
double c_line_sdr=1e6/(io_param->z0*io_param->frequency); //For SDR CA
double c_line_2T=1e6*2/(io_param->z0*io_param->frequency); //For 2T timing
double c_line_3T=1e6*3/(io_param->z0*io_param->frequency); //For 3T timing
//Line capacitance if flight time is less than half the bit period
if (io_param->t_flight < 1e3/(4*io_param->frequency)){
c_line = 1e3*io_param->t_flight/io_param->z0;
}
if (io_param->t_flight_ca < 1e3/(4*io_param->frequency)){
c_line_ca = 1e3*io_param->t_flight/io_param->z0;
}
if (io_param->t_flight_ca < 1e3/(2*io_param->frequency)){
c_line_sdr = 1e3*io_param->t_flight/io_param->z0;
}
if (io_param->t_flight_ca < 1e3*2/(2*io_param->frequency)){
c_line_2T = 1e3*io_param->t_flight/io_param->z0;
}
if (io_param->t_flight_ca < 1e3*3/(2*io_param->frequency)){
c_line_3T = 1e3*io_param->t_flight/io_param->z0;
}
//Line capacitance calculation for the address bus, depending on what address timing is chosen (DDR/SDR/2T/3T)
if (g_ip->addr_timing==1.0) {
c_line_ca = c_line_sdr;
}
else if (g_ip->addr_timing==2.0){
c_line_ca = c_line_2T;
}
else if (g_ip->addr_timing==3.0){
c_line_ca = c_line_3T;
}
//Dynamic power per signal group for WRITE and READ modes
power_dq_write = g_ip->num_dq * g_ip->activity_dq *
(io_param->c_tx + c_line) * io_param->vdd_io *
io_param->v_sw_data_write_line * io_param->frequency / 1000 +
g_ip->num_dq * g_ip->activity_dq * io_param->c_data *
io_param->vdd_io * io_param->v_sw_data_write_load1 *
io_param->frequency / 1000 +
g_ip->num_dq * g_ip->activity_dq * ((g_ip->num_mem_dq-1) *
io_param->c_data) * io_param->vdd_io *
io_param->v_sw_data_write_load2 * io_param->frequency / 1000 +
g_ip->num_dq * g_ip->activity_dq * io_param->c_int *
io_param->vdd_io * io_param->vdd_io * io_param->frequency / 1000;
power_dqs_write = g_ip->num_dqs * (io_param->c_tx + c_line) *
io_param->vdd_io * io_param->v_sw_data_write_line *
io_param->frequency / 1000 +
g_ip->num_dqs * io_param->c_data * io_param->vdd_io *
io_param->v_sw_data_write_load1 * io_param->frequency / 1000 +
g_ip->num_dqs * ((g_ip->num_mem_dq-1) * io_param->c_data) *
io_param->vdd_io * io_param->v_sw_data_write_load2 *
io_param->frequency / 1000 +
g_ip->num_dqs * io_param->c_int * io_param->vdd_io *
io_param->vdd_io * io_param->frequency / 1000;
power_ca_write = g_ip->num_ca * g_ip->activity_ca *
(io_param->c_tx + io_param->num_mem_ca * io_param->c_addr +
c_line_ca) *
io_param->vdd_io * io_param->v_sw_addr * io_param->frequency / 1000 +
g_ip->num_ca * g_ip->activity_ca * io_param->c_int *
io_param->vdd_io * io_param->vdd_io * io_param->frequency / 1000;
power_dq_read = g_ip->num_dq * g_ip->activity_dq *
(io_param->c_tx + c_line) * io_param->vdd_io *
io_param->v_sw_data_read_line * io_param->frequency / 1000.0 +
g_ip->num_dq * g_ip->activity_dq * io_param->c_data *
io_param->vdd_io * io_param->v_sw_data_read_load1 * io_param->frequency / 1000.0 +
g_ip->num_dq *g_ip->activity_dq * ((g_ip->num_mem_dq-1) * io_param->c_data) *
io_param->vdd_io * io_param->v_sw_data_read_load2 * io_param->frequency / 1000.0 +
g_ip->num_dq * g_ip->activity_dq * io_param->c_int * io_param->vdd_io *
io_param->vdd_io * io_param->frequency / 1000.0;
power_dqs_read = g_ip->num_dqs * (io_param->c_tx + c_line) *
io_param->vdd_io * io_param->v_sw_data_read_line *
io_param->frequency / 1000.0 +
g_ip->num_dqs * io_param->c_data * io_param->vdd_io *
io_param->v_sw_data_read_load1 * io_param->frequency / 1000.0 +
g_ip->num_dqs * ((g_ip->num_mem_dq-1) * io_param->c_data) *
io_param->vdd_io * io_param->v_sw_data_read_load2 * io_param->frequency / 1000.0 +
g_ip->num_dqs * io_param->c_int * io_param->vdd_io * io_param->vdd_io *
io_param->frequency / 1000.0;
power_ca_read = g_ip->num_ca * g_ip->activity_ca *
(io_param->c_tx + io_param->num_mem_ca *
io_param->c_addr + c_line_ca) *
io_param->vdd_io * io_param->v_sw_addr * io_param->frequency / 1000 +
g_ip->num_ca * g_ip->activity_ca * io_param->c_int *
io_param->vdd_io * io_param->vdd_io * io_param->frequency / 1000;
power_clk = g_ip->num_clk *
(io_param->c_tx + io_param->num_mem_clk *
io_param->c_data + c_line) *
io_param->vdd_io * io_param->v_sw_clk *io_param->frequency / 1000 +
g_ip->num_clk * io_param->c_int * io_param->vdd_io *
io_param->vdd_io * io_param->frequency / 1000;
}
//Combining the power terms based on STATE (READ/WRITE/IDLE/SLEEP)
if (g_ip->iostate == READ) {
io_power_dynamic = g_ip->duty_cycle * (power_dq_read +
power_ca_read + power_dqs_read + power_clk);
}
else if (g_ip->iostate == WRITE) {
io_power_dynamic = g_ip->duty_cycle *
(power_dq_write + power_ca_write + power_dqs_write + power_clk);
}
else if (g_ip->iostate == IDLE) {
io_power_dynamic = g_ip->duty_cycle * (power_clk);
}
else if (g_ip->iostate == SLEEP) {
io_power_dynamic = 0;
}
else {
io_power_dynamic = 0;
}
printf("IO Dynamic Power (mW) = ");
cout << io_power_dynamic << " ";
}
//External IO Timing and Voltage Margins. More details can be found in the CACTI-IO technical report (), Chapter 2.2.
void Extio::extio_eye()
{
if (io_param->io_type == Serial)
{io_vmargin=0;
}
else
{
//VOLTAGE MARGINS
//Voltage noise calculations based on proportional and independent noise
//sources for WRITE, READ and CA
double v_noise_write = io_param->k_noise_write_sen * io_param->v_sw_data_write_line +
io_param->v_noise_independent_write;
double v_noise_read = io_param->k_noise_read_sen * io_param->v_sw_data_read_line +
io_param->v_noise_independent_read;
double v_noise_addr = io_param->k_noise_addr_sen * io_param->v_sw_addr +
io_param->v_noise_independent_addr;
//Worst-case voltage margin (Swing/2 - Voltage noise) calculations per state
//depending on DQ voltage margin and CA voltage margin (lesser or the two is
//reported)
if (g_ip->iostate == READ)
{
if ((io_param->v_sw_data_read_line/2 - v_noise_read) <
(io_param->v_sw_addr/2 - v_noise_addr)) {
io_vmargin = io_param->v_sw_data_read_line/2 - v_noise_read;
}
else {
io_vmargin = io_param->v_sw_addr/2 - v_noise_addr;
}
}
else if (g_ip->iostate == WRITE) {
if ((io_param->v_sw_data_write_line/2 - v_noise_write) <
(io_param->v_sw_addr/2 - v_noise_addr)) {
io_vmargin = io_param->v_sw_data_write_line/2 - v_noise_write;
}
else {
io_vmargin = io_param->v_sw_addr/2 - v_noise_addr;
}
}
else {
io_vmargin = 0;
}
}
//TIMING MARGINS
double t_margin_write_setup,t_margin_write_hold,t_margin_read_setup
,t_margin_read_hold,t_margin_addr_setup,t_margin_addr_hold;
if (io_param->io_type == Serial)
{
t_margin_write_setup = (1e6/(4*io_param->frequency)) -
io_param->t_ds -
io_param->t_jitter_setup_sen;
t_margin_write_hold = (1e6/(4*io_param->frequency)) -
io_param->t_dh - io_param->t_dcd_soc -
io_param->t_jitter_hold_sen;
t_margin_read_setup = (1e6/(4*io_param->frequency)) -
io_param->t_soc_setup -
io_param->t_jitter_setup_sen;
t_margin_read_hold = (1e6/(4*io_param->frequency)) -
io_param->t_soc_hold - io_param->t_dcd_dram -
io_param->t_dcd_soc -
io_param->t_jitter_hold_sen;
t_margin_addr_setup = (1e6*g_ip->addr_timing/(2*io_param->frequency));
t_margin_addr_hold = (1e6*g_ip->addr_timing/(2*io_param->frequency));
}
else
{
//Setup and Hold timing margins for DQ WRITE, DQ READ and CA based on timing
//budget
t_margin_write_setup = (1e6/(4*io_param->frequency)) -
io_param->t_ds - io_param->t_error_soc -
io_param->t_jitter_setup_sen - io_param->t_skew_setup + io_param->t_cor_margin;
t_margin_write_hold = (1e6/(4*io_param->frequency)) -
io_param->t_dh - io_param->t_dcd_soc - io_param->t_error_soc -
io_param->t_jitter_hold_sen - io_param->t_skew_hold + io_param->t_cor_margin;
t_margin_read_setup = (1e6/(4*io_param->frequency)) -
io_param->t_soc_setup - io_param->t_error_soc -
io_param->t_jitter_setup_sen - io_param->t_skew_setup -
io_param->t_dqsq + io_param->t_cor_margin;
t_margin_read_hold = (1e6/(4*io_param->frequency)) -
io_param->t_soc_hold - io_param->t_dcd_dram -
io_param->t_dcd_soc - io_param->t_error_soc -
io_param->t_jitter_hold_sen - io_param->t_skew_hold + io_param->t_cor_margin;
t_margin_addr_setup = (1e6*g_ip->addr_timing/(2*io_param->frequency)) -
io_param->t_is - io_param->t_error_soc -
io_param->t_jitter_addr_setup_sen - io_param->t_skew_setup + io_param->t_cor_margin;
t_margin_addr_hold = (1e6*g_ip->addr_timing/(2*io_param->frequency)) -
io_param->t_ih - io_param->t_dcd_soc - io_param->t_error_soc -
io_param->t_jitter_addr_hold_sen - io_param->t_skew_hold + io_param->t_cor_margin;
}
//Worst-case timing margin per state depending on DQ and CA timing margins
if (g_ip->iostate == READ) {
io_tmargin = t_margin_read_setup < t_margin_read_hold ?
t_margin_read_setup : t_margin_read_hold;
io_tmargin = io_tmargin < t_margin_addr_setup ?
io_tmargin : t_margin_addr_setup;
io_tmargin = io_tmargin < t_margin_addr_hold ?
io_tmargin : t_margin_addr_hold;
}
else if (g_ip->iostate == WRITE) {
io_tmargin = t_margin_write_setup < t_margin_write_hold ?
t_margin_write_setup : t_margin_write_hold;
io_tmargin = io_tmargin < t_margin_addr_setup ?
io_tmargin : t_margin_addr_setup;
io_tmargin = io_tmargin < t_margin_addr_hold ?
io_tmargin : t_margin_addr_hold;
}
else {
io_tmargin = 0;
}
//OUTPUTS
printf("IO Timing Margin (ps) = ");
cout << io_tmargin <<endl;
printf("IO Votlage Margin (V) = ");
cout << io_vmargin << endl;
}