Skip to content

Commit 2451a92

Browse files
committed
link physical/logical tiles with correct index
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent c182f64 commit 2451a92

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ int find_switch_by_name(const t_arch& arch, std::string switch_name);
199199

200200
e_side string_to_side(std::string side_str);
201201

202+
static void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTileTypes,
203+
std::vector<t_logical_block_type>& LogicalBlockTypes);
204+
202205
/*
203206
*
204207
*
@@ -289,6 +292,9 @@ void XmlReadArch(const char* ArchFile,
289292
Next = get_single_child(architecture, "complexblocklist", loc_data);
290293
ProcessComplexBlocks(Next, LogicalBlockTypes, *arch, timing_enabled, loc_data);
291294

295+
/* Link Physical Tiles with Logical Blocks */
296+
link_physical_logical_types(PhysicalTileTypes, LogicalBlockTypes);
297+
292298
/* Process directs */
293299
Next = get_single_child(architecture, "directlist", loc_data, OPTIONAL);
294300
if (Next) {
@@ -2734,7 +2740,7 @@ static void ProcessTileProps(pugi::xml_node Node,
27342740
PhysicalTileType->height = get_attribute(Node, "height", loc_data, OPTIONAL).as_uint(1);
27352741
PhysicalTileType->area = get_attribute(Node, "area", loc_data, OPTIONAL).as_float(UNDEFINED);
27362742

2737-
if (PhysicalTileType->area < 0) {
2743+
if (atof(Prop) < 0) {
27382744
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Node),
27392745
"Area for type %s must be non-negative\n", PhysicalTileType->name);
27402746
}
@@ -2894,9 +2900,9 @@ static void ProcessTileEquivalentSites(pugi::xml_node Parent,
28942900

28952901
t_equivalent_site equivalent_site;
28962902

2897-
expect_only_attributes(CurSite, {"name"}, loc_data);
2903+
expect_only_attributes(CurSite, {"pb_type"}, loc_data);
28982904
/* Load equivalent site name */
2899-
auto Prop = get_attribute(CurSite, "name", loc_data).value();
2905+
auto Prop = get_attribute(CurSite, "pb_type", loc_data).value();
29002906
equivalent_site.pb_type_name = vtr::strdup(Prop);
29012907

29022908
PhysicalTileType->equivalent_sites.push_back(equivalent_site);
@@ -4372,3 +4378,32 @@ e_side string_to_side(std::string side_str) {
43724378
}
43734379
return side;
43744380
}
4381+
4382+
static void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTileTypes,
4383+
std::vector<t_logical_block_type>& LogicalBlockTypes) {
4384+
std::map<t_physical_tile_type*, t_logical_block_type*> check_equivalence;
4385+
4386+
for (auto& physical_tile : PhysicalTileTypes) {
4387+
if (physical_tile.index == 0) continue;
4388+
4389+
for (auto& equivalent_site : physical_tile.equivalent_sites) {
4390+
for (auto& logical_block : LogicalBlockTypes) {
4391+
if (logical_block.index == 0) continue;
4392+
4393+
// Check the corresponding Logical Block
4394+
if (0 == strcmp(logical_block.pb_type->name, equivalent_site.pb_type_name)) {
4395+
physical_tile.logical_block_index = logical_block.index;
4396+
logical_block.physical_tile_index = physical_tile.index;
4397+
4398+
auto result = check_equivalence.insert(std::pair<t_physical_tile_type*, t_logical_block_type*>(&physical_tile, &logical_block));
4399+
if(!result.second) {
4400+
archfpga_throw(__FILE__, __LINE__,
4401+
"Logical and Physical types do not have a one to one mapping\n");
4402+
}
4403+
4404+
break;
4405+
}
4406+
}
4407+
}
4408+
}
4409+
}

0 commit comments

Comments
 (0)