@@ -386,12 +386,11 @@ std::unique_ptr<int[]> get_ordered_seg_track_counts(const std::vector<t_segment_
386
386
return ordered_seg_track_counts;
387
387
}
388
388
389
- t_seg_details* alloc_and_load_seg_details (int * max_chan_width,
390
- const int max_len,
391
- const std::vector<t_segment_inf>& segment_inf,
392
- const bool use_full_seg_groups,
393
- const enum e_directionality directionality,
394
- int * num_seg_details) {
389
+ std::vector<t_seg_details> alloc_and_load_seg_details (int * max_chan_width,
390
+ int max_len,
391
+ const std::vector<t_segment_inf>& segment_inf,
392
+ bool use_full_seg_groups,
393
+ enum e_directionality directionality) {
395
394
/* Allocates and loads the seg_details data structure. Max_len gives the *
396
395
* maximum length of a segment (dimension of array). The code below tries *
397
396
* to: *
@@ -401,14 +400,9 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width,
401
400
* (3) stagger the connection and switch boxes on different long lines, *
402
401
* as they will not be staggered by different segment start points. */
403
402
404
- int cur_track, ntracks, itrack, length, j, index;
405
- int fac, num_sets, tmp;
406
- int arch_wire_switch, arch_opin_switch, arch_wire_switch_dec, arch_opin_switch_dec;
407
- int arch_opin_between_dice_switch;
408
- int group_start, first_track;
409
- std::unique_ptr<int []> sets_per_seg_type;
410
- t_seg_details* seg_details = nullptr ;
411
- bool longline;
403
+ int cur_track;
404
+ int fac;
405
+ std::vector<t_seg_details> seg_details;
412
406
413
407
/* Unidir tracks are assigned in pairs, and bidir tracks individually */
414
408
if (directionality == BI_DIRECTIONAL) {
@@ -423,46 +417,46 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width,
423
417
}
424
418
425
419
/* Map segment type fractions and groupings to counts of tracks */
426
- sets_per_seg_type = get_seg_track_counts ((*max_chan_width / fac),
427
- segment_inf, use_full_seg_groups);
420
+ std::unique_ptr< int []> sets_per_seg_type = get_seg_track_counts ((*max_chan_width / fac),
421
+ segment_inf, use_full_seg_groups);
428
422
429
423
/* Count the number tracks actually assigned. */
430
- tmp = 0 ;
424
+ int tmp = 0 ;
431
425
for (size_t i = 0 ; i < segment_inf.size (); ++i) {
432
426
tmp += sets_per_seg_type[i] * fac;
433
427
}
434
428
VTR_ASSERT (use_full_seg_groups || (tmp == *max_chan_width));
435
429
*max_chan_width = tmp;
436
430
437
- seg_details = new t_seg_details[ *max_chan_width] ;
431
+ seg_details. resize ( *max_chan_width) ;
438
432
439
433
/* Setup the seg_details data */
440
434
cur_track = 0 ;
441
435
for (size_t i = 0 ; i < segment_inf.size (); ++i) {
442
- first_track = cur_track;
436
+ int first_track = cur_track;
443
437
444
- num_sets = sets_per_seg_type[i];
445
- ntracks = fac * num_sets;
438
+ int num_sets = sets_per_seg_type[i];
439
+ int ntracks = fac * num_sets;
446
440
if (ntracks < 1 ) {
447
441
continue ;
448
442
}
449
443
/* Avoid divide by 0 if ntracks */
450
- longline = segment_inf[i].longline ;
451
- length = segment_inf[i].length ;
444
+ bool longline = segment_inf[i].longline ;
445
+ int length = segment_inf[i].length ;
452
446
if (longline) {
453
447
length = max_len;
454
448
}
455
449
456
- arch_wire_switch = segment_inf[i].arch_wire_switch ;
457
- arch_opin_switch = segment_inf[i].arch_opin_switch ;
458
- arch_wire_switch_dec = segment_inf[i].arch_wire_switch_dec ;
459
- arch_opin_switch_dec = segment_inf[i].arch_opin_switch_dec ;
460
- arch_opin_between_dice_switch = segment_inf[i].arch_opin_between_dice_switch ;
450
+ int arch_wire_switch = segment_inf[i].arch_wire_switch ;
451
+ int arch_opin_switch = segment_inf[i].arch_opin_switch ;
452
+ int arch_wire_switch_dec = segment_inf[i].arch_wire_switch_dec ;
453
+ int arch_opin_switch_dec = segment_inf[i].arch_opin_switch_dec ;
454
+ int arch_opin_between_dice_switch = segment_inf[i].arch_opin_between_dice_switch ;
461
455
VTR_ASSERT ((arch_wire_switch == arch_opin_switch && arch_wire_switch_dec == arch_opin_switch_dec) || (directionality != UNI_DIRECTIONAL));
462
456
463
457
/* Set up the tracks of same type */
464
- group_start = 0 ;
465
- for (itrack = 0 ; itrack < ntracks; itrack++) {
458
+ int group_start = 0 ;
459
+ for (int itrack = 0 ; itrack < ntracks; itrack++) {
466
460
/* set the name of the segment type this track belongs to */
467
461
seg_details[cur_track].type_name = segment_inf[i].name ;
468
462
@@ -498,21 +492,21 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width,
498
492
* since this is a property of a detailed route. */
499
493
seg_details[cur_track].cb = std::make_unique<bool []>(length);
500
494
seg_details[cur_track].sb = std::make_unique<bool []>(length + 1 );
501
- for (j = 0 ; j < length; ++j) {
495
+ for (int j = 0 ; j < length; ++j) {
502
496
if (seg_details[cur_track].longline ) {
503
497
seg_details[cur_track].cb [j] = true ;
504
498
} else {
505
499
/* Use the segment's pattern. */
506
- index = j % segment_inf[i].cb .size ();
500
+ int index = j % segment_inf[i].cb .size ();
507
501
seg_details[cur_track].cb [j] = segment_inf[i].cb [index];
508
502
}
509
503
}
510
- for (j = 0 ; j < (length + 1 ); ++j) {
504
+ for (int j = 0 ; j < (length + 1 ); ++j) {
511
505
if (seg_details[cur_track].longline ) {
512
506
seg_details[cur_track].sb [j] = true ;
513
507
} else {
514
508
/* Use the segment's pattern. */
515
- index = j % segment_inf[i].sb .size ();
509
+ int index = j % segment_inf[i].sb .size ();
516
510
seg_details[cur_track].sb [j] = segment_inf[i].sb [index];
517
511
}
518
512
}
@@ -549,9 +543,7 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width,
549
543
}
550
544
} /* End for each segment type. */
551
545
552
- if (num_seg_details) {
553
- *num_seg_details = cur_track;
554
- }
546
+ VTR_ASSERT_DEBUG (seg_details.size () == cur_track);
555
547
return seg_details;
556
548
}
557
549
@@ -560,32 +552,28 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width,
560
552
* (ie. channel segments) for each horizontal and vertical channel. */
561
553
562
554
void alloc_and_load_chan_details (const DeviceGrid& grid,
563
- const t_chan_width* nodes_per_chan,
564
- const int num_seg_details_x,
565
- const int num_seg_details_y,
566
- const t_seg_details* seg_details_x,
567
- const t_seg_details* seg_details_y,
555
+ const t_chan_width& nodes_per_chan,
556
+ const std::vector<t_seg_details>& seg_details_x,
557
+ const std::vector<t_seg_details>& seg_details_y,
568
558
t_chan_details& chan_details_x,
569
559
t_chan_details& chan_details_y) {
570
- chan_details_x = init_chan_details (grid, nodes_per_chan,
571
- num_seg_details_x, seg_details_x, X_AXIS);
572
- chan_details_y = init_chan_details (grid, nodes_per_chan,
573
- num_seg_details_y, seg_details_y, Y_AXIS);
560
+ chan_details_x = init_chan_details (grid, nodes_per_chan, seg_details_x, X_AXIS);
561
+ chan_details_y = init_chan_details (grid, nodes_per_chan, seg_details_y, Y_AXIS);
574
562
575
563
/* Adjust segment start/end based on obstructed channels, if any */
576
564
adjust_chan_details (grid, nodes_per_chan,
577
565
chan_details_x, chan_details_y);
578
566
}
579
567
580
568
t_chan_details init_chan_details (const DeviceGrid& grid,
581
- const t_chan_width* nodes_per_chan,
582
- const int num_seg_details ,
583
- const t_seg_details* seg_details,
584
- const enum e_parallel_axis seg_parallel_axis) {
569
+ const t_chan_width& nodes_per_chan,
570
+ const std::vector<t_seg_details>& seg_details ,
571
+ enum e_parallel_axis seg_parallel_axis) {
572
+ const int num_seg_details = ( int )seg_details. size ();
585
573
if (seg_parallel_axis == X_AXIS) {
586
- VTR_ASSERT (num_seg_details <= nodes_per_chan-> x_max );
574
+ VTR_ASSERT (num_seg_details <= nodes_per_chan. x_max );
587
575
} else if (seg_parallel_axis == Y_AXIS) {
588
- VTR_ASSERT (num_seg_details <= nodes_per_chan-> y_max );
576
+ VTR_ASSERT (num_seg_details <= nodes_per_chan. y_max );
589
577
}
590
578
591
579
t_chan_details chan_details ({grid.width (), grid.height (), size_t (num_seg_details)});
@@ -611,11 +599,11 @@ t_chan_details init_chan_details(const DeviceGrid& grid,
611
599
p_seg_details[i].set_seg_end (seg_end);
612
600
613
601
if (seg_parallel_axis == X_AXIS) {
614
- if (i >= nodes_per_chan-> x_list [y]) {
602
+ if (i >= nodes_per_chan. x_list [y]) {
615
603
p_seg_details[i].set_length (0 );
616
604
}
617
605
} else if (seg_parallel_axis == Y_AXIS) {
618
- if (i >= nodes_per_chan-> y_list [x]) {
606
+ if (i >= nodes_per_chan. y_list [x]) {
619
607
p_seg_details[i].set_length (0 );
620
608
}
621
609
}
@@ -626,7 +614,7 @@ t_chan_details init_chan_details(const DeviceGrid& grid,
626
614
}
627
615
628
616
void adjust_chan_details (const DeviceGrid& grid,
629
- const t_chan_width* nodes_per_chan,
617
+ const t_chan_width& nodes_per_chan,
630
618
t_chan_details& chan_details_x,
631
619
t_chan_details& chan_details_y) {
632
620
for (size_t y = 0 ; y <= grid.height () - 2 ; ++y) { // -2 for no perim channels
@@ -657,18 +645,18 @@ void adjust_chan_details(const DeviceGrid& grid,
657
645
void adjust_seg_details (const int x,
658
646
const int y,
659
647
const DeviceGrid& grid,
660
- const t_chan_width* nodes_per_chan,
648
+ const t_chan_width& nodes_per_chan,
661
649
t_chan_details& chan_details,
662
650
const enum e_parallel_axis seg_parallel_axis) {
663
651
int seg_index = (seg_parallel_axis == X_AXIS ? x : y);
664
652
int max_chan_width = 0 ;
665
653
if (seg_parallel_axis == X_AXIS) {
666
- max_chan_width = nodes_per_chan-> x_max ;
654
+ max_chan_width = nodes_per_chan. x_max ;
667
655
} else if (seg_parallel_axis == Y_AXIS) {
668
- max_chan_width = nodes_per_chan-> y_max ;
656
+ max_chan_width = nodes_per_chan. y_max ;
669
657
} else {
670
658
VTR_ASSERT (seg_parallel_axis == BOTH_AXIS);
671
- max_chan_width = nodes_per_chan-> max ;
659
+ max_chan_width = nodes_per_chan. max ;
672
660
}
673
661
674
662
for (int track = 0 ; track < max_chan_width; ++track) {
0 commit comments