Skip to content

Commit 6f6b5d9

Browse files
mtdudekacomodi
authored andcommitted
interchange: arch: add alternative sites types
Signed-off-by: Maciej Dudek <[email protected]>
1 parent 95f28e6 commit 6f6b5d9

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,13 @@ struct ArchReader {
393393
* - equivalent_sites
394394
* - tile_block_pin_directs_map
395395
**/
396-
void fill_sub_tile(t_physical_tile_type& type, t_sub_tile& sub_tile, int num_pins, int input_count, int output_count) {
396+
void fill_sub_tile(t_physical_tile_type& type,
397+
t_sub_tile& sub_tile,
398+
int num_pins,
399+
int input_count,
400+
int output_count,
401+
std::unordered_map<std::string, int>* port_name_to_sub_tile_idx = nullptr,
402+
Device::SiteTypeInTileType::Reader* site_in_tile = nullptr) {
397403
sub_tile.num_phy_pins += num_pins;
398404
type.num_pins += num_pins;
399405
type.num_inst_pins += num_pins;
@@ -417,18 +423,45 @@ struct ArchReader {
417423

418424
vtr::bimap<t_logical_pin, t_physical_pin> directs_map;
419425

420-
for (int npin = 0; npin < type.num_pins; npin++) {
426+
for (int npin = 0; npin < num_pins; npin++) {
421427
t_physical_pin physical_pin(npin);
422428
t_logical_pin logical_pin(npin);
423429

424430
directs_map.insert(logical_pin, physical_pin);
425431
}
426432

427433
auto ltype = get_type_by_name<t_logical_block_type>(sub_tile.name, ltypes_);
428-
sub_tile.equivalent_sites.push_back(ltype);
429434

430435
type.tile_block_pin_directs_map[ltype->index][sub_tile.index] = directs_map;
436+
sub_tile.equivalent_sites.push_back(ltype);
437+
438+
if (site_in_tile) {
439+
auto site_types = ar_.getSiteTypeList();
440+
auto site_type = site_types[site_in_tile->getPrimaryType()];
441+
auto alt_sites_pins = site_in_tile->getAltPinsToPrimaryPins();
442+
443+
for (int i = 0; i < site_type.getAltSiteTypes().size(); ++i) {
444+
auto alt_site = site_types[site_type.getAltSiteTypes()[i]];
445+
if (take_sites_.count(alt_site.getName()) == 0)
446+
continue;
447+
448+
auto ltype = get_type_by_name<t_logical_block_type>(str(alt_site.getName()).c_str(), ltypes_);
449+
sub_tile.equivalent_sites.push_back(ltype);
450+
451+
vtr::bimap<t_logical_pin, t_physical_pin> directs_map;
452+
auto pin_map = alt_sites_pins[i];
431453

454+
for (int npin = 0; npin < ltype->pb_type->num_ports; npin++) {
455+
auto pin = site_type.getPins()[pin_map.getPins()[npin]];
456+
auto idx = (*port_name_to_sub_tile_idx)[str(pin.getName())];
457+
t_physical_pin physical_pin(idx);
458+
t_logical_pin logical_pin(npin);
459+
460+
directs_map.insert(logical_pin, physical_pin);
461+
}
462+
type.tile_block_pin_directs_map[ltype->index][sub_tile.index] = directs_map;
463+
}
464+
}
432465
// Assign FC specs
433466
int iblk_pin = 0;
434467
for (const auto& port : sub_tile.ports) {
@@ -1876,8 +1909,6 @@ struct ArchReader {
18761909
if (take_sites_.count(site.getName()) == 0)
18771910
continue;
18781911

1879-
auto pins_to_wires = site_in_tile.getPrimaryPinsToTileWires();
1880-
18811912
sub_tile.index = type.capacity;
18821913
sub_tile.name = vtr::strdup(str(site.getName()).c_str());
18831914
sub_tile.capacity.set(type.capacity, type.capacity);
@@ -1888,8 +1919,7 @@ struct ArchReader {
18881919
int icount = 0;
18891920
int ocount = 0;
18901921

1891-
std::unordered_map<std::string, std::string> port_name_to_wire_name;
1892-
int idx = 0;
1922+
std::unordered_map<std::string, int> port_name_to_sub_tile_idx;
18931923
for (auto dir : {INPUT, OUTPUT}) {
18941924
int port_idx_by_type = 0;
18951925
for (auto pin : site.getPins()) {
@@ -1900,9 +1930,9 @@ struct ArchReader {
19001930

19011931
port.name = vtr::strdup(str(pin.getName()).c_str());
19021932

1903-
port_name_to_wire_name[std::string(port.name)] = str(pins_to_wires[idx++]);
1904-
19051933
sub_tile.sub_tile_to_tile_pin_indices.push_back(type.num_pins + port_idx);
1934+
1935+
port_name_to_sub_tile_idx[str(pin.getName())] = port_idx;
19061936
port.index = port_idx++;
19071937

19081938
port.absolute_first_pin_index = abs_first_pin_idx++;
@@ -1921,9 +1951,9 @@ struct ArchReader {
19211951
}
19221952

19231953
auto pins_size = site.getPins().size();
1924-
fill_sub_tile(type, sub_tile, pins_size, icount, ocount);
1954+
fill_sub_tile(type, sub_tile, pins_size, icount, ocount, &port_name_to_sub_tile_idx, &site_in_tile);
19251955

1926-
type.sub_tiles.push_back(sub_tile);
1956+
type.sub_tiles.emplace_back(sub_tile);
19271957
}
19281958
}
19291959

0 commit comments

Comments
 (0)