@@ -90,8 +90,11 @@ struct NetlistReader {
90
90
std::string name = str_list[port.getName ()];
91
91
auto dir = port.getDir ();
92
92
93
- int bus_size, start_bit;
94
- std::tie (bus_size, start_bit) = get_bus_size (port);
93
+ int start, end;
94
+ std::tie (start, end) = get_bus_range (port);
95
+
96
+ int bus_size = std::abs (end - start) + 1 ;
97
+ int start_bit = start < end ? start : end;
95
98
96
99
for (int bit = start_bit; bit < start_bit + bus_size; bit++) {
97
100
auto port_name = name;
@@ -431,38 +434,40 @@ struct NetlistReader {
431
434
return nullptr ;
432
435
}
433
436
434
- std::pair<int , int > get_bus_size (LogicalNetlist::Netlist::Port::Reader port_reader) {
437
+ std::pair<int , int > get_bus_range (LogicalNetlist::Netlist::Port::Reader port_reader) {
435
438
if (port_reader.isBus ()) {
436
439
int s = port_reader.getBus ().getBusStart ();
437
440
int e = port_reader.getBus ().getBusEnd ();
438
441
439
- if (e < s)
440
- return std::make_pair (s - e + 1 , e);
441
- else
442
- return std::make_pair (e - s + 1 , s);
442
+ return std::make_pair (s, e);
443
443
}
444
444
445
- return std::make_pair (1 , 0 );
445
+ return std::make_pair (0 , 0 );
446
446
}
447
447
448
448
unsigned int get_port_bit (LogicalNetlist::Netlist::PortInstance::Reader port_inst_reader) {
449
+ unsigned int port_bit = 0 ;
449
450
if (port_inst_reader.getBusIdx ().which () == LogicalNetlist::Netlist::PortInstance::BusIdx::IDX)
450
- return port_inst_reader.getBusIdx ().getIdx ();
451
+ port_bit = port_inst_reader.getBusIdx ().getIdx ();
451
452
452
- return 0 ;
453
+ return port_bit ;
453
454
}
454
455
455
456
std::unordered_map<std::pair<unsigned int , unsigned int >, std::string, vtr::hash_pair> get_port_net_map (unsigned int inst_idx) {
456
457
auto inst_list = nr_.getInstList ();
457
458
auto decl_list = nr_.getCellDecls ();
458
459
auto str_list = nr_.getStrList ();
460
+ auto port_list = nr_.getPortList ();
459
461
460
462
auto top_cell = nr_.getCellList ()[nr_.getTopInst ().getCell ()];
461
463
std::unordered_map<std::pair<unsigned int , unsigned int >, std::string, vtr::hash_pair> map;
462
464
for (auto net : top_cell.getNets ()) {
463
465
std::string net_name = str_list[net.getName ()];
464
466
465
467
for (auto port : net.getPortInsts ()) {
468
+ if (port.isExtPort ())
469
+ continue ;
470
+
466
471
auto port_inst = port.getInst ();
467
472
auto cell = inst_list[port_inst].getCell ();
468
473
if (str_list[decl_list[cell].getName ()] == arch_.gnd_cell .first )
@@ -477,7 +482,16 @@ struct NetlistReader {
477
482
continue ;
478
483
479
484
unsigned int port_bit = get_port_bit (port);
480
- auto pair = std::make_pair (port.getPort (), port_bit);
485
+
486
+ auto port_idx = port.getPort ();
487
+ int start, end;
488
+ std::tie (start, end) = get_bus_range (port_list[port_idx]);
489
+
490
+ int bus_size = std::abs (end - start);
491
+
492
+ port_bit = start < end ? port_bit : bus_size - port_bit;
493
+
494
+ auto pair = std::make_pair (port_idx, port_bit);
481
495
map.emplace (pair, net_name);
482
496
}
483
497
}
0 commit comments