Skip to content

Commit 0bb4005

Browse files
committed
equivalent tiles: added set to hold available tiles
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 08cfc0f commit 0bb4005

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

libs/libarchfpga/src/physical_types.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,12 @@ std::vector<int> t_type_descriptor::get_clock_pins_indices () const {
140140

141141
return indices;
142142
}
143+
144+
bool t_type_descriptor::is_available_tile_index(int index_to_check) const {
145+
auto search = this->available_tiles_indices.find(index_to_check);
146+
if (search != available_tiles_indices.end()) {
147+
return true;
148+
}
149+
150+
return false;
151+
}

libs/libarchfpga/src/physical_types.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#include <unordered_map>
3232
#include <string>
3333
#include <map>
34-
#include <unordered_map>
3534
#include <limits>
3635
#include <numeric>
36+
#include <unordered_set>
3737

3838
#include "vtr_ndmatrix.h"
3939
#include "vtr_hash.h"
@@ -560,6 +560,7 @@ constexpr int DEFAULT_SWITCH = -2;
560560
* defined with different indeces.
561561
* equivalent_tile_inverse_pin_mapping: Multi-dimensional array that works as the previous one, but the mapping is inverse in this case.
562562
* Example: equivalent_tile_pin_mapping[eq_tile_index][equivalent_pin_index] = pin_index
563+
* available_tiles_indices: unordered map used to have a fast lookup on the available tiles.
563564
*
564565
* area: Describes how much area this logic block takes, if undefined, use default
565566
* type_timing_inf: timing information unique to this type
@@ -605,6 +606,7 @@ struct t_type_descriptor /* TODO rename this. maybe physical type descriptor or
605606
t_type_descriptor **equivalent_tiles = nullptr;
606607
int **equivalent_tile_pin_mapping = nullptr; /* [0..num_equivalent_tiles-1][0..num_pins-1] */
607608
int **equivalent_tile_inverse_pin_mapping = nullptr; /* [0..num_equivalent_tiles-1][0..num_pins-1] */
609+
std::unordered_set<int> available_tiles_indices;
608610

609611
float area = 0;
610612

@@ -614,9 +616,16 @@ struct t_type_descriptor /* TODO rename this. maybe physical type descriptor or
614616

615617
int index = -1; /* index of type descriptor in array (allows for index referencing) */
616618

619+
/***********
620+
* Methods *
621+
***********/
622+
617623
/* Returns the indices of pins that contain a clock for this physical logic block */
618624
std::vector<int> get_clock_pins_indices() const;
619625

626+
/* Returns a boolean set to True if the input index belongs to an available tile, False otherwise */
627+
bool is_available_tile_index(int index_to_check) const;
628+
620629
};
621630
typedef const t_type_descriptor* t_type_ptr;
622631

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,7 @@ static void ProcessTiles(pugi::xml_node Node,
27442744
}
27452745

27462746
Type->index = i;
2747+
Type->available_tiles_indices.insert(i);
27472748

27482749
TypeMap->insert(std::make_pair(Type->name, Type));
27492750

@@ -2849,13 +2850,16 @@ static void ProcessTileExtraModes(pugi::xml_node Node,
28492850
CurType = Node.first_child();
28502851
while(CurType && index < Type->num_equivalent_tiles) {
28512852
const char *equivalent_tile_name = get_attribute(CurType, "name", loc_data).value();
2853+
auto EquivalentTile = get_corresponding_tile(TypeMap, equivalent_tile_name);
28522854

2853-
Type->equivalent_tiles[index] = get_corresponding_tile(TypeMap, equivalent_tile_name);
2854-
if(Type->equivalent_tiles[index] == nullptr) {
2855+
if(EquivalentTile == nullptr) {
28552856
archfpga_throw(loc_data.filename_c_str(), loc_data.line(CurType),
28562857
"No tiles found corresponding to equivalent tile name: '%s'.\n", Type->pb_type->name);
28572858
}
28582859

2860+
Type->equivalent_tiles[index] = EquivalentTile;
2861+
Type->available_tiles_indices.insert(EquivalentTile->index);
2862+
28592863
Type->equivalent_tile_pin_mapping[index] = (int *) vtr::malloc(Type->num_pins * sizeof(int));
28602864
Type->equivalent_tile_inverse_pin_mapping[index] = (int *) vtr::malloc(Type->equivalent_tiles[index]->num_pins * sizeof(int));
28612865
ProcessTileExtraModePinMapping(CurType, Type, Type->equivalent_tiles[index], index, loc_data);

0 commit comments

Comments
 (0)