Skip to content

Commit c13e09f

Browse files
committed
Fix bugs in reading explicit pin definitions.
Signed-off-by: Keith Rothman <[email protected]>
1 parent 27b1160 commit c13e09f

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,14 @@ static void LoadPinLoc(pugi::xml_node Locations,
816816
VTR_ASSERT(ipin == output_pins.size());
817817

818818
} else {
819+
int capacity;
820+
if (type->capacity_type == e_capacity_type::DUPLICATE) {
821+
capacity = type->capacity;
822+
} else {
823+
VTR_ASSERT(type->capacity_type == e_capacity_type::EXPLICIT);
824+
capacity = 1;
825+
}
826+
819827
VTR_ASSERT(type->pin_location_distribution == E_CUSTOM_PIN_DISTR);
820828
for (int width = 0; width < type->width; ++width) {
821829
for (int height = 0; height < type->height; ++height) {
@@ -836,12 +844,12 @@ static void LoadPinLoc(pugi::xml_node Locations,
836844
}
837845

838846
for (int pin_num = pin_range.first; pin_num < pin_range.second; ++pin_num) {
839-
VTR_ASSERT(pin_num < type->num_pins / type->capacity);
840-
for (int capacity = 0; capacity < type->capacity; ++capacity) {
841-
type->pinloc[width][height][side][pin_num + capacity * type->num_pins / type->capacity] = true;
842-
type->pin_width_offset[pin_num + capacity * type->num_pins / type->capacity] += width;
843-
type->pin_height_offset[pin_num + capacity * type->num_pins / type->capacity] += height;
844-
physical_pin_counts[pin_num + capacity * type->num_pins / type->capacity] += 1;
847+
VTR_ASSERT(pin_num < type->num_pins / capacity);
848+
for (int icapacity = 0; icapacity < capacity; ++icapacity) {
849+
type->pinloc[width][height][side][pin_num + icapacity * type->num_pins / capacity] = true;
850+
type->pin_width_offset[pin_num + icapacity * type->num_pins / capacity] += width;
851+
type->pin_height_offset[pin_num + icapacity * type->num_pins / capacity] += height;
852+
physical_pin_counts[pin_num + icapacity * type->num_pins / capacity] += 1;
845853
}
846854
}
847855
}
@@ -891,6 +899,8 @@ static std::pair<int, std::pair<int, int>> ProcessPinString(pugi::xml_node Locat
891899
pin_loc_string);
892900
}
893901

902+
instance_idx = vtr::atoi(token.data);
903+
894904
token_index++;
895905
token = tokens[token_index];
896906

@@ -903,7 +913,6 @@ static std::pair<int, std::pair<int, int>> ProcessPinString(pugi::xml_node Locat
903913
token_index++;
904914
token = tokens[token_index];
905915

906-
instance_idx = vtr::atoi(token.data);
907916
}
908917

909918
if (token.type != TOKEN_DOT) {
@@ -3331,7 +3340,7 @@ static void ProcessEquivalentSiteDirectConnection(pugi::xml_node Parent,
33313340
"Pin definition differ between site %s and tile %s. User-defined pin mapping is required.\n", LogicalBlockType->pb_type->name, PhysicalTileType->name);
33323341
}
33333342

3334-
if (PhysicalTileType->capacity_type == e_capacity_type::EXPLICIT) {
3343+
if (PhysicalTileType->capacity_type != e_capacity_type::DUPLICATE) {
33353344
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Parent),
33363345
"Custom site pins are required if capacity_type == explicit\n");
33373346
}
@@ -5017,7 +5026,15 @@ static void check_port_direct_mappings(t_physical_tile_type_ptr physical_tile, t
50175026

50185027
auto& pin_direct_mapping = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
50195028

5020-
if (pb_type->num_pins != (int)pin_direct_mapping.size()) {
5029+
int capacity;
5030+
if (physical_tile->capacity_type == e_capacity_type::DUPLICATE) {
5031+
capacity = 1;
5032+
} else {
5033+
VTR_ASSERT(physical_tile->capacity_type == e_capacity_type::EXPLICIT);
5034+
capacity = physical_tile->capacity;
5035+
}
5036+
5037+
if (pb_type->num_pins * capacity != (int)pin_direct_mapping.size()) {
50215038
archfpga_throw(__FILE__, __LINE__,
50225039
"Logical block (%s) and Physical tile (%s) have a different number of ports.\n",
50235040
logical_block->name, physical_tile->name);

0 commit comments

Comments
 (0)