@@ -152,17 +152,11 @@ void free_arch(t_arch* arch) {
152
152
return ;
153
153
}
154
154
155
- delete[] arch->Switches ;
156
- arch->Switches = nullptr ;
157
-
158
155
free_arch_models (arch->models );
159
156
160
- for (int i = 0 ; i < arch->num_directs ; ++i) {
161
- vtr::free (arch->Directs [i].name );
162
- vtr::free (arch->Directs [i].from_pin );
163
- vtr::free (arch->Directs [i].to_pin );
164
- }
165
- vtr::free (arch->Directs );
157
+ vtr::release_memory (arch->switches );
158
+
159
+ vtr::release_memory (arch->directs );
166
160
167
161
vtr::free (arch->architecture_id );
168
162
@@ -235,7 +229,7 @@ t_model* free_arch_model(t_model* model) {
235
229
return next_model;
236
230
}
237
231
238
- // Frees all the model portss in a linked list
232
+ // Frees all the model ports in a linked list
239
233
void free_arch_model_ports (t_model_ports* model_ports) {
240
234
t_model_ports* model_port = model_ports;
241
235
while (model_port) {
@@ -256,16 +250,17 @@ t_model_ports* free_arch_model_port(t_model_ports* model_port) {
256
250
}
257
251
258
252
void free_type_descriptors (std::vector<t_physical_tile_type>& type_descriptors) {
259
- for (auto & type : type_descriptors) {
260
- vtr::free (type.name );
253
+ for (t_physical_tile_type& type : type_descriptors) {
254
+ vtr::release_memory (type.name );
255
+
261
256
if (type.index == EMPTY_TYPE_INDEX) {
262
257
continue ;
263
258
}
264
259
265
- for (auto & sub_tile : type.sub_tiles ) {
266
- vtr::free (sub_tile.name );
260
+ for (t_sub_tile & sub_tile : type.sub_tiles ) {
261
+ vtr::release_memory (sub_tile.name );
267
262
268
- for (auto port : sub_tile.ports ) {
263
+ for (t_physical_tile_port& port : sub_tile.ports ) {
269
264
vtr::free (port.name );
270
265
}
271
266
}
@@ -276,8 +271,8 @@ void free_type_descriptors(std::vector<t_physical_tile_type>& type_descriptors)
276
271
void free_type_descriptors (std::vector<t_logical_block_type>& type_descriptors) {
277
272
free_all_pb_graph_nodes (type_descriptors);
278
273
279
- for (auto & type : type_descriptors) {
280
- vtr::free (type.name );
274
+ for (t_logical_block_type & type : type_descriptors) {
275
+ vtr::release_memory (type.name );
281
276
if (type.index == EMPTY_TYPE_INDEX) {
282
277
continue ;
283
278
}
@@ -522,7 +517,7 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
522
517
523
518
t_physical_tile_type get_empty_physical_type (const char * name /* = EMPTY_BLOCK_NAME*/ ) {
524
519
t_physical_tile_type type;
525
- type.name = vtr::strdup ( name) ;
520
+ type.name = name;
526
521
type.num_pins = 0 ;
527
522
type.width = 1 ;
528
523
type.height = 1 ;
@@ -540,7 +535,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
540
535
541
536
t_logical_block_type get_empty_logical_type (const char * name /* =EMPTY_BLOCK_NAME*/ ) {
542
537
t_logical_block_type type;
543
- type.name = vtr::strdup ( name) ;
538
+ type.name = name;
544
539
type.pb_type = nullptr ;
545
540
546
541
return type;
@@ -1104,7 +1099,6 @@ void SyncModelsPbTypes(t_arch* arch,
1104
1099
1105
1100
void SyncModelsPbTypes_rec (t_arch* arch,
1106
1101
t_pb_type* pb_type) {
1107
- int i, j, p;
1108
1102
t_model *model_match_prim, *cur_model;
1109
1103
t_model_ports* model_port;
1110
1104
vtr::t_linked_vptr* old;
@@ -1143,7 +1137,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
1143
1137
}
1144
1138
cur_model = cur_model->next ;
1145
1139
}
1146
- if (found != true ) {
1140
+ if (!found ) {
1147
1141
archfpga_throw (get_arch_file_name (), 0 ,
1148
1142
" No matching model for pb_type %s\n " , pb_type->blif_model );
1149
1143
}
@@ -1154,7 +1148,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
1154
1148
model_match_prim->pb_types ->next = old;
1155
1149
model_match_prim->pb_types ->data_vptr = pb_type;
1156
1150
1157
- for (p = 0 ; p < pb_type->num_ports ; p++) {
1151
+ for (int p = 0 ; p < pb_type->num_ports ; p++) {
1158
1152
found = false ;
1159
1153
/* TODO: Parse error checking - check if INPUT matches INPUT and OUTPUT matches OUTPUT (not yet done) */
1160
1154
model_port = model_match_prim->inputs ;
@@ -1203,17 +1197,16 @@ void SyncModelsPbTypes_rec(t_arch* arch,
1203
1197
}
1204
1198
model_port = model_port->next ;
1205
1199
}
1206
- if (found != true ) {
1200
+ if (!found ) {
1207
1201
archfpga_throw (get_arch_file_name (), 0 ,
1208
1202
" No matching model port for port %s in pb_type %s\n " ,
1209
1203
pb_type->ports [p].name , pb_type->name );
1210
1204
}
1211
1205
}
1212
1206
} else {
1213
- for (i = 0 ; i < pb_type->num_modes ; i++) {
1214
- for (j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
1215
- SyncModelsPbTypes_rec (arch,
1216
- &(pb_type->modes [i].pb_type_children [j]));
1207
+ for (int i = 0 ; i < pb_type->num_modes ; i++) {
1208
+ for (int j = 0 ; j < pb_type->modes [i].num_pb_type_children ; j++) {
1209
+ SyncModelsPbTypes_rec (arch, &(pb_type->modes [i].pb_type_children [j]));
1217
1210
}
1218
1211
}
1219
1212
}
@@ -1229,11 +1222,11 @@ void SyncModelsPbTypes_rec(t_arch* arch,
1229
1222
void primitives_annotation_clock_match (t_pin_to_pin_annotation* annotation,
1230
1223
t_pb_type* parent_pb_type) {
1231
1224
int i_port;
1232
- bool clock_valid = false ; // Determine if annotation's clock is same as primtive 's clock
1225
+ bool clock_valid = false ; // Determine if annotation's clock is same as primitive 's clock
1233
1226
1234
1227
if (!parent_pb_type || !annotation) {
1235
1228
archfpga_throw (__FILE__, __LINE__,
1236
- " Annotation_clock check encouters invalid annotation or primitive.\n " );
1229
+ " Annotation_clock check encounters invalid annotation or primitive.\n " );
1237
1230
}
1238
1231
1239
1232
for (i_port = 0 ; i_port < parent_pb_type->num_ports ; i_port++) {
@@ -1253,18 +1246,17 @@ void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
1253
1246
}
1254
1247
}
1255
1248
1256
- const t_segment_inf* find_segment (const t_arch* arch, std::string name) {
1257
- for (size_t i = 0 ; i < (arch->Segments ).size (); ++i) {
1258
- const t_segment_inf* seg = &arch->Segments [i];
1259
- if (seg->name == name) {
1260
- return seg;
1249
+ const t_segment_inf* find_segment (const t_arch* arch, std::string_view name) {
1250
+ for (const auto & segment : arch->Segments ) {
1251
+ if (segment.name == name) {
1252
+ return &segment;
1261
1253
}
1262
1254
}
1263
1255
1264
1256
return nullptr ;
1265
1257
}
1266
1258
1267
- bool segment_exists (const t_arch* arch, std::string name) {
1259
+ bool segment_exists (const t_arch* arch, std::string_view name) {
1268
1260
return find_segment (arch, name) != nullptr ;
1269
1261
}
1270
1262
@@ -1342,7 +1334,7 @@ const t_pin_to_pin_annotation* find_sequential_annotation(const t_pb_type* pb_ty
1342
1334
return nullptr ;
1343
1335
}
1344
1336
1345
- const t_pin_to_pin_annotation* find_combinational_annotation (const t_pb_type* pb_type, std::string in_port, std::string out_port) {
1337
+ const t_pin_to_pin_annotation* find_combinational_annotation (const t_pb_type* pb_type, std::string_view in_port, std::string_view out_port) {
1346
1338
for (int iannot = 0 ; iannot < pb_type->num_annotations ; ++iannot) {
1347
1339
const t_pin_to_pin_annotation* annot = &pb_type->annotations [iannot];
1348
1340
for (const auto & annot_in_str : vtr::split (annot->input_pins )) {
@@ -1386,24 +1378,24 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
1386
1378
1387
1379
std::sort (equivalent_sites.begin (), equivalent_sites.end (), criteria);
1388
1380
1389
- for (auto & logical_block : LogicalBlockTypes) {
1381
+ for (t_logical_block_type & logical_block : LogicalBlockTypes) {
1390
1382
for (auto site : equivalent_sites) {
1391
- if (0 == strcmp ( logical_block.name , site->pb_type ->name ) ) {
1383
+ if (logical_block.name == site->pb_type ->name ) {
1392
1384
logical_block.equivalent_tiles .push_back (&physical_tile);
1393
1385
break ;
1394
1386
}
1395
1387
}
1396
1388
}
1397
1389
}
1398
1390
1399
- for (auto & logical_block : LogicalBlockTypes) {
1391
+ for (t_logical_block_type & logical_block : LogicalBlockTypes) {
1400
1392
if (logical_block.index == EMPTY_TYPE_INDEX) continue ;
1401
1393
1402
1394
auto & equivalent_tiles = logical_block.equivalent_tiles ;
1403
1395
1404
1396
if ((int )equivalent_tiles.size () <= 0 ) {
1405
1397
archfpga_throw (__FILE__, __LINE__,
1406
- " Logical Block %s does not have any equivalent tiles.\n " , logical_block.name );
1398
+ " Logical Block %s does not have any equivalent tiles.\n " , logical_block.name . c_str () );
1407
1399
}
1408
1400
1409
1401
std::unordered_map<int , bool > ignored_pins_check_map;
@@ -1439,7 +1431,7 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
1439
1431
if (result == direct_map.end ()) {
1440
1432
archfpga_throw (__FILE__, __LINE__,
1441
1433
" Logical pin %d not present in pin mapping between Tile %s and Block %s.\n " ,
1442
- pin, tile->name , logical_block.name );
1434
+ pin, tile->name . c_str () , logical_block.name . c_str () );
1443
1435
}
1444
1436
1445
1437
int sub_tile_pin_index = result->second .pin ;
@@ -1453,15 +1445,15 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
1453
1445
archfpga_throw (__FILE__, __LINE__,
1454
1446
" Physical Tile %s has a different value for the ignored pin (physical pin: %d, logical pin: %d) "
1455
1447
" different from the corresponding pins of the other equivalent site %s\n ." ,
1456
- tile->name , phy_index, pin, logical_block.name );
1448
+ tile->name . c_str () , phy_index, pin, logical_block.name . c_str () );
1457
1449
}
1458
1450
1459
1451
auto global_result = global_pins_check_map.insert (std::pair<int , bool >(pin, is_global));
1460
1452
if (!global_result.second && global_result.first ->second != is_global) {
1461
1453
archfpga_throw (__FILE__, __LINE__,
1462
1454
" Physical Tile %s has a different value for the global pin (physical pin: %d, logical pin: %d) "
1463
1455
" different from the corresponding pins of the other equivalent sites\n ." ,
1464
- tile->name , phy_index, pin);
1456
+ tile->name . c_str () , phy_index, pin);
1465
1457
}
1466
1458
}
1467
1459
}
@@ -1471,27 +1463,25 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
1471
1463
1472
1464
/* Sets up the pin classes for the type. */
1473
1465
void setup_pin_classes (t_physical_tile_type* type) {
1474
- int i, k;
1475
- int pin_count;
1476
1466
int num_class;
1477
1467
1478
- for (i = 0 ; i < type->num_pins ; i++) {
1468
+ for (int i = 0 ; i < type->num_pins ; i++) {
1479
1469
type->pin_class .push_back (OPEN);
1480
1470
type->is_ignored_pin .push_back (true );
1481
1471
type->is_pin_global .push_back (true );
1482
1472
}
1483
1473
1484
- pin_count = 0 ;
1474
+ int pin_count = 0 ;
1485
1475
1486
1476
t_class_range class_range;
1487
1477
1488
1478
/* Equivalent pins share the same class, non-equivalent pins belong to different pin classes */
1489
- for (auto & sub_tile : type->sub_tiles ) {
1479
+ for (const t_sub_tile & sub_tile : type->sub_tiles ) {
1490
1480
int capacity = sub_tile.capacity .total ();
1491
1481
class_range.low = type->class_inf .size ();
1492
1482
class_range.high = class_range.low - 1 ;
1493
- for (i = 0 ; i < capacity; ++i) {
1494
- for (const auto & port : sub_tile.ports ) {
1483
+ for (int i = 0 ; i < capacity; ++i) {
1484
+ for (const t_physical_tile_port & port : sub_tile.ports ) {
1495
1485
if (port.equivalent != PortEquivalence::NONE) {
1496
1486
t_class class_inf;
1497
1487
num_class = (int )type->class_inf .size ();
@@ -1505,7 +1495,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
1505
1495
class_inf.type = DRIVER;
1506
1496
}
1507
1497
1508
- for (k = 0 ; k < port.num_pins ; ++k) {
1498
+ for (int k = 0 ; k < port.num_pins ; ++k) {
1509
1499
class_inf.pinlist .push_back (pin_count);
1510
1500
type->pin_class [pin_count] = num_class;
1511
1501
// clock pins and other specified global ports are initially specified
@@ -1525,7 +1515,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
1525
1515
type->class_inf .push_back (class_inf);
1526
1516
class_range.high ++;
1527
1517
} else if (port.equivalent == PortEquivalence::NONE) {
1528
- for (k = 0 ; k < port.num_pins ; ++k) {
1518
+ for (int k = 0 ; k < port.num_pins ; ++k) {
1529
1519
t_class class_inf;
1530
1520
num_class = (int )type->class_inf .size ();
1531
1521
class_inf.num_pins = 1 ;
@@ -1544,7 +1534,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
1544
1534
// as ignored pins (i.e. connections are not created in the rr_graph and
1545
1535
// nets connected to the port are ignored as well).
1546
1536
type->is_ignored_pin [pin_count] = port.is_clock || port.is_non_clock_global ;
1547
- // clock pins and other specified global ports are flaged as global
1537
+ // clock pins and other specified global ports are flagged as global
1548
1538
type->is_pin_global [pin_count] = port.is_clock || port.is_non_clock_global ;
1549
1539
1550
1540
if (port.is_clock ) {
0 commit comments