Skip to content

Commit 07de461

Browse files
committed
addressed review comments
- changed t_physical_port -> t_physical_tile_port - added strict port checks Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 159877c commit 07de461

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct t_pb_type_power;
5252
struct t_mode_power;
5353
struct t_interconnect_power;
5454
struct t_port_power;
55-
struct t_physical_port;
55+
struct t_physical_tile_port;
5656
struct t_equivalent_site;
5757
struct t_physical_tile_type;
5858
struct t_logical_block_type;
@@ -606,7 +606,7 @@ struct t_physical_tile_type {
606606
int num_class = 0;
607607
t_class* class_inf = nullptr; /* [0..num_class-1] */
608608

609-
std::vector<t_physical_port> ports;
609+
std::vector<t_physical_tile_port> ports;
610610
std::vector<int> pin_width_offset; //[0..num_pins-1]
611611
std::vector<int> pin_height_offset; //[0..num_pins-1]
612612
int* pin_class = nullptr; /* [0..num_pins-1] */
@@ -654,7 +654,7 @@ typedef const t_physical_tile_type* t_physical_tile_type_ptr;
654654
* port_index_by_type index of port by type (index by input, output, or clock)
655655
* equivalence: Applies to logic block I/Os and to primitive inputs only
656656
*/
657-
struct t_physical_port {
657+
struct t_physical_tile_port {
658658
char* name;
659659
enum PORTS type;
660660
bool is_clock;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void ProcessTilePorts(pugi::xml_node Parent,
102102
t_physical_tile_type* PhysicalTileType,
103103
const pugiutil::loc_data& loc_data);
104104
static void ProcessTilePort(pugi::xml_node Node,
105-
t_physical_port* port,
105+
t_physical_tile_port* port,
106106
const pugiutil::loc_data& loc_data);
107107
static void ProcessTileEquivalentSites(pugi::xml_node Parent,
108108
t_physical_tile_type* PhysicalTileType,
@@ -212,7 +212,9 @@ e_side string_to_side(std::string side_str);
212212
static void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTileTypes,
213213
std::vector<t_logical_block_type>& LogicalBlockTypes);
214214

215-
static const t_physical_port* get_port_by_name(t_physical_tile_type_ptr type, const char* port_name);
215+
static void check_port_equivalence(t_physical_tile_type& physical_tile, t_logical_block_type& logical_block);
216+
217+
static const t_physical_tile_port* get_port_by_name(t_physical_tile_type_ptr type, const char* port_name);
216218

217219
/*
218220
*
@@ -550,7 +552,7 @@ static void SetupPinLocationsAndPinClasses(pugi::xml_node Locations,
550552
//Empty range, so full port
551553

552554
//Find the matching pb type to get the total number of pins
553-
const t_physical_port* port = nullptr;
555+
const t_physical_tile_port* port = nullptr;
554556
for (const auto& tmp_port : PhysicalTileType->ports) {
555557
if (tmp_port.name == inst_port.port_name()) {
556558
port = &tmp_port;
@@ -3066,7 +3068,7 @@ static void ProcessTilePorts(pugi::xml_node Parent,
30663068
Cur = get_first_child(Parent, "clock", loc_data, OPTIONAL);
30673069
}
30683070
while (Cur) {
3069-
t_physical_port port;
3071+
t_physical_tile_port port;
30703072

30713073
port.index = iport;
30723074
port.absolute_first_pin_index = absolute_first_pin_index;
@@ -3109,7 +3111,7 @@ static void ProcessTilePorts(pugi::xml_node Parent,
31093111
}
31103112

31113113
static void ProcessTilePort(pugi::xml_node Node,
3112-
t_physical_port* port,
3114+
t_physical_tile_port* port,
31133115
const pugiutil::loc_data& loc_data) {
31143116
std::vector<std::string> expected_attributes = {"name", "num_pins", "equivalent"};
31153117

@@ -4677,31 +4679,54 @@ static void link_physical_logical_types(std::vector<t_physical_tile_type>& Physi
46774679
std::map<t_physical_tile_type*, t_logical_block_type*> check_equivalence;
46784680

46794681
for (auto& physical_tile : PhysicalTileTypes) {
4680-
if (physical_tile.index == 0) continue;
4682+
if (physical_tile.index == EMPTY_TYPE_INDEX) continue;
46814683

46824684
for (auto& equivalent_site : physical_tile.equivalent_sites) {
46834685
for (auto& logical_block : LogicalBlockTypes) {
4684-
if (logical_block.index == 0) continue;
4686+
if (logical_block.index == EMPTY_TYPE_INDEX) continue;
46854687

46864688
// Check the corresponding Logical Block
46874689
if (0 == strcmp(logical_block.pb_type->name, equivalent_site.pb_type_name)) {
46884690
physical_tile.logical_block_index = logical_block.index;
46894691
logical_block.physical_tile_index = physical_tile.index;
46904692

4691-
auto result = check_equivalence.insert(std::pair<t_physical_tile_type*, t_logical_block_type*>(&physical_tile, &logical_block));
4693+
auto result = check_equivalence.emplace(&physical_tile, &logical_block);
46924694
if (!result.second) {
46934695
archfpga_throw(__FILE__, __LINE__,
46944696
"Logical and Physical types do not have a one to one mapping\n");
46954697
}
46964698

4699+
check_port_equivalence(physical_tile, logical_block);
4700+
46974701
break;
46984702
}
46994703
}
47004704
}
47014705
}
47024706
}
47034707

4704-
static const t_physical_port* get_port_by_name(t_physical_tile_type_ptr type, const char* port_name) {
4708+
static void check_port_equivalence(t_physical_tile_type& physical_tile, t_logical_block_type& logical_block) {
4709+
auto pb_type = logical_block.pb_type;
4710+
auto pb_type_ports = pb_type->ports;
4711+
4712+
if (pb_type->num_ports != (int)physical_tile.ports.size()) {
4713+
archfpga_throw(__FILE__, __LINE__,
4714+
"Logical and Physical types have a different number of ports.\n");
4715+
}
4716+
4717+
for (auto& tile_port : physical_tile.ports) {
4718+
auto block_port = pb_type_ports[tile_port.index];
4719+
4720+
if (0 != strcmp(tile_port.name, block_port.name)
4721+
|| tile_port.type != block_port.type
4722+
|| tile_port.num_pins != block_port.num_pins) {
4723+
archfpga_throw(__FILE__, __LINE__,
4724+
"Logical and Physical types do not have equivalent port specifications.\n");
4725+
}
4726+
}
4727+
}
4728+
4729+
static const t_physical_tile_port* get_port_by_name(t_physical_tile_type_ptr type, const char* port_name) {
47054730
for (auto port : type->ports) {
47064731
if (0 == strcmp(port.name, port_name)) {
47074732
return &type->ports[port.index];

vtr_flow/scripts/upgrade_arch.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,17 +530,12 @@ def upgrade_pinlocations(arch):
530530
the yoffset case
531531
"""
532532
modified = False
533-
pinlocations_list = arch.findall(".//pinlocations")
534-
535-
tiles_exists = arch.findall('./tiles')
533+
pinlocations_list = arch.findall(".//pb_type/pinlocations")
536534

537535
for pinlocations in pinlocations_list:
538536
pb_type = pinlocations.find("..")
539537

540-
if not tiles_exists:
541-
assert pb_type.tag == "pb_type"
542-
else:
543-
assert pb_type.tag == "tile"
538+
assert pb_type.tag == "pb_type"
544539

545540
width = 1
546541
height = 1

0 commit comments

Comments
 (0)