@@ -118,26 +118,24 @@ static void ProcessDevice(pugi::xml_node Node, t_arch *arch, t_default_fc_spec &
118
118
static void ProcessTiles (pugi::xml_node Node,
119
119
t_type_descriptor ** Types,
120
120
int *NumTypes,
121
+ std::unordered_map<std::string, t_type_descriptor *> *TypeMap,
121
122
const pugiutil::loc_data& loc_data);
122
123
static void ProcessTilesTags (pugi::xml_node Node,
123
- t_type_descriptor ** Types,
124
- int NumTypes,
124
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
125
125
t_arch& arch,
126
126
const t_default_fc_spec &arch_def_fc,
127
127
const pugiutil::loc_data& loc_data);
128
128
static void ProcessTileExtraModes (pugi::xml_node Node,
129
129
t_type_descriptor *Type,
130
- t_type_descriptor **Types,
131
- int NumTypes,
130
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
132
131
const pugiutil::loc_data& loc_data);
133
132
static void ProcessTileExtraModePinMapping (pugi::xml_node Node,
134
133
t_type_descriptor *Type,
135
134
t_type_descriptor *EquivalentType,
136
135
int imode,
137
136
const pugiutil::loc_data& loc_data);
138
137
static void ProcessComplexBlocks (pugi::xml_node Node,
139
- t_type_descriptor ** Types,
140
- int NumTypes,
138
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
141
139
t_arch& arch,
142
140
const bool timing_enabled,
143
141
const pugiutil::loc_data& loc_data);
@@ -205,7 +203,7 @@ int find_switch_by_name(const t_arch& arch, std::string switch_name);
205
203
206
204
e_side string_to_side (std::string side_str);
207
205
208
- static t_type_descriptor* get_correspondent_tile ( t_type_descriptor ** Types, int NumTypes , const char * type_name);
206
+ static t_type_descriptor* get_corresponding_tile (std::unordered_map<std::string, t_type_descriptor *> TypeMap , const char * type_name);
209
207
static int get_pin_index_by_name (t_type_descriptor *Type, const char * port_name, int offset);
210
208
/*
211
209
*
@@ -291,16 +289,17 @@ void XmlReadArch(const char *ArchFile, const bool timing_enabled,
291
289
}
292
290
293
291
/* Process tiles */
292
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap;
294
293
Next = get_single_child (architecture, " tiles" , loc_data);
295
- ProcessTiles (Next, Types, NumTypes, loc_data);
294
+ ProcessTiles (Next, Types, NumTypes, &TypeMap, loc_data);
296
295
297
296
/* Process pb_types */
298
297
Next = get_single_child (architecture, " complexblocklist" , loc_data);
299
- ProcessComplexBlocks (Next, Types, *NumTypes , *arch, timing_enabled, loc_data);
298
+ ProcessComplexBlocks (Next, TypeMap , *arch, timing_enabled, loc_data);
300
299
301
300
/* Process tile tags that after pb_type have been parsed */
302
301
Next = get_single_child (architecture, " tiles" , loc_data);
303
- ProcessTilesTags (Next, Types, *NumTypes , *arch, arch_def_fc, loc_data);
302
+ ProcessTilesTags (Next, TypeMap , *arch, arch_def_fc, loc_data);
304
303
305
304
/* Process directs */
306
305
Next = get_single_child (architecture, " directlist" , loc_data, OPTIONAL);
@@ -2702,6 +2701,7 @@ static void ProcessTileProps(pugi::xml_node Node, t_type_descriptor * Type, cons
2702
2701
static void ProcessTiles (pugi::xml_node Node,
2703
2702
t_type_descriptor ** Types,
2704
2703
int *NumTypes,
2704
+ std::unordered_map<std::string, t_type_descriptor *> *TypeMap,
2705
2705
const pugiutil::loc_data& loc_data) {
2706
2706
pugi::xml_node CurType;
2707
2707
pugi::xml_node Cur;
@@ -2745,6 +2745,8 @@ static void ProcessTiles(pugi::xml_node Node,
2745
2745
2746
2746
Type->index = i;
2747
2747
2748
+ TypeMap->insert (std::make_pair (Type->name , Type));
2749
+
2748
2750
/* Type fully read */
2749
2751
++i;
2750
2752
@@ -2757,8 +2759,7 @@ static void ProcessTiles(pugi::xml_node Node,
2757
2759
2758
2760
// This step has to be performed after the root pb_type has been parsed
2759
2761
static void ProcessTilesTags (pugi::xml_node Node,
2760
- t_type_descriptor ** Types,
2761
- int NumTypes,
2762
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
2762
2763
t_arch& arch,
2763
2764
const t_default_fc_spec &arch_def_fc,
2764
2765
const pugiutil::loc_data& loc_data) {
@@ -2774,10 +2775,10 @@ static void ProcessTilesTags(pugi::xml_node Node,
2774
2775
const char * NameProp = get_attribute (CurType, " name" , loc_data).value ();
2775
2776
2776
2777
/* Alias to current type */
2777
- Type = get_correspondent_tile (Types, NumTypes , vtr::strdup (NameProp));
2778
+ Type = get_corresponding_tile (TypeMap , vtr::strdup (NameProp));
2778
2779
if (Type == nullptr ) {
2779
2780
archfpga_throw (loc_data.filename_c_str (), loc_data.line (CurType),
2780
- " No tiles found correspondent to current root level pb type: '%s'.\n " , Type->pb_type ->name );
2781
+ " No tiles found corresponding to current root level pb type: '%s'.\n " , Type->pb_type ->name );
2781
2782
}
2782
2783
2783
2784
VTR_ASSERT (Type->pb_type != nullptr );
@@ -2808,7 +2809,7 @@ static void ProcessTilesTags(pugi::xml_node Node,
2808
2809
/* Load possible modes (pb_types which are compatible with the current tile) */
2809
2810
Cur = get_single_child (CurType, " equivalent_tiles" , loc_data, OPTIONAL);
2810
2811
if (Cur) {
2811
- ProcessTileExtraModes (Cur, Type, Types, NumTypes , loc_data);
2812
+ ProcessTileExtraModes (Cur, Type, TypeMap , loc_data);
2812
2813
}
2813
2814
2814
2815
/* Free this node and get its next sibling node */
@@ -2836,8 +2837,7 @@ static void ProcessTilesTags(pugi::xml_node Node,
2836
2837
*/
2837
2838
static void ProcessTileExtraModes (pugi::xml_node Node,
2838
2839
t_type_descriptor *Type,
2839
- t_type_descriptor **Types,
2840
- int NumTypes,
2840
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
2841
2841
const pugiutil::loc_data& loc_data) {
2842
2842
pugi::xml_node CurType;
2843
2843
@@ -2850,10 +2850,10 @@ static void ProcessTileExtraModes(pugi::xml_node Node,
2850
2850
while (CurType && index < Type->num_equivalent_tiles ) {
2851
2851
const char *equivalent_tile_name = get_attribute (CurType, " name" , loc_data).value ();
2852
2852
2853
- Type->equivalent_tiles [index ] = get_correspondent_tile (Types, NumTypes , equivalent_tile_name);
2853
+ Type->equivalent_tiles [index ] = get_corresponding_tile (TypeMap , equivalent_tile_name);
2854
2854
if (Type->equivalent_tiles [index ] == nullptr ) {
2855
2855
archfpga_throw (loc_data.filename_c_str (), loc_data.line (CurType),
2856
- " No tiles found correspondent to equivalent tile name: '%s'.\n " , Type->pb_type ->name );
2856
+ " No tiles found corresponding to equivalent tile name: '%s'.\n " , Type->pb_type ->name );
2857
2857
}
2858
2858
2859
2859
Type->equivalent_tile_pin_mapping [index ] = (int *) vtr::malloc (Type->num_pins * sizeof (int ));
@@ -2903,8 +2903,7 @@ static void ProcessTileExtraModePinMapping(pugi::xml_node Node,
2903
2903
}
2904
2904
2905
2905
static void ProcessComplexBlocks (pugi::xml_node Node,
2906
- t_type_descriptor ** Types,
2907
- int NumTypes,
2906
+ std::unordered_map<std::string, t_type_descriptor *> TypeMap,
2908
2907
t_arch& arch,
2909
2908
const bool timing_enabled,
2910
2909
const pugiutil::loc_data& loc_data) {
@@ -2928,10 +2927,10 @@ static void ProcessComplexBlocks(pugi::xml_node Node,
2928
2927
}
2929
2928
}
2930
2929
2931
- Type = get_correspondent_tile (Types, NumTypes , type_name);
2930
+ Type = get_corresponding_tile (TypeMap , type_name);
2932
2931
if (Type == nullptr ) {
2933
2932
archfpga_throw (loc_data.filename_c_str (), loc_data.line (CurPbType),
2934
- " No tiles found correspondent to current root level pb type: '%s'.\n " , type_name);
2933
+ " No tiles found corresponding to current root level pb type: '%s'.\n " , type_name);
2935
2934
}
2936
2935
2937
2936
Type->pb_type = new t_pb_type;
@@ -4407,19 +4406,16 @@ e_side string_to_side(std::string side_str) {
4407
4406
return side;
4408
4407
}
4409
4408
4410
- static t_type_descriptor* get_correspondent_tile (t_type_descriptor ** Types, int NumTypes, const char *type_name) {
4411
- t_type_descriptor *Type;
4409
+ static t_type_descriptor* get_corresponding_tile (std::unordered_map<std::string, t_type_descriptor *> TypeMap,
4410
+ const char *type_name) {
4412
4411
4413
- for (int i = 1 /* Skip empty tile */ ; i < NumTypes; i++) {
4414
- /* Alias to current type */
4415
- Type = &(*Types)[i];
4412
+ auto result = TypeMap.find (type_name);
4416
4413
4417
- if (0 == strcmp (Type->name , type_name)){
4418
- return Type;
4419
- }
4414
+ if (result == TypeMap.end ()) {
4415
+ return nullptr ;
4420
4416
}
4421
4417
4422
- return nullptr ;
4418
+ return result-> second ;
4423
4419
}
4424
4420
4425
4421
static int get_pin_index_by_name (t_type_descriptor *Type, const char * port_name, int pin_index_in_port) {
@@ -4428,6 +4424,7 @@ static int get_pin_index_by_name(t_type_descriptor *Type, const char * port_name
4428
4424
t_pb_type *pb_type = Type->pb_type ;
4429
4425
t_port *matched_port = nullptr ;
4430
4426
int port_base_ipin = 0 ;
4427
+
4431
4428
for (int iport = 0 ; iport < pb_type->num_ports ; ++iport) {
4432
4429
t_port* port = &pb_type->ports [iport];
4433
4430
0 commit comments