Skip to content

Commit 1668b7c

Browse files
committed
equivalent: avoid segfaults
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 67fec85 commit 1668b7c

File tree

5 files changed

+31
-30
lines changed

5 files changed

+31
-30
lines changed

libs/libarchfpga/src/echo_arch.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,23 @@ void EchoArch(const char* EchoFile,
102102

103103
int index = Type.index;
104104
fprintf(Echo, "\tindex: %d\n", index);
105-
if (LogicalBlockTypes[Type.index].pb_type) {
106-
PrintPb_types_rec(Echo, LogicalBlockTypes[Type.index].pb_type, 2);
105+
106+
for (auto LogicalBlock : Type.equivalent_sites) {
107+
fprintf(Echo, "\nEquivalent Site: %s\n", LogicalBlock->name);
107108
}
108109
fprintf(Echo, "\n");
109110
}
111+
112+
fprintf(Echo, "*************************************************\n\n");
113+
fprintf(Echo, "*************************************************\n");
114+
115+
for (auto& LogicalBlock : LogicalBlockTypes) {
116+
if (LogicalBlock.pb_type) {
117+
PrintPb_types_rec(Echo, LogicalBlock.pb_type, 2);
118+
}
119+
fprintf(Echo, "\n");
120+
}
121+
110122
fclose(Echo);
111123
}
112124

vpr/src/place/place_macro.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,13 @@ static void write_place_macros(std::string filename, const std::vector<t_pl_macr
454454
fprintf(f, "type type_pin is_direct direct_type\n");
455455
fprintf(f, "------------------------------------------\n");
456456
auto& device_ctx = g_vpr_ctx.device();
457-
for (const auto& type : device_ctx.logical_block_types) {
457+
for (const auto& type : device_ctx.physical_tile_types) {
458458
if (is_empty_type(&type)) {
459459
continue;
460460
}
461461

462462
int itype = type.index;
463-
for (int ipin = 0; ipin < type.pb_type->num_pins; ++ipin) {
463+
for (int ipin = 0; ipin < type.num_pins; ++ipin) {
464464
if (f_idirect_from_blk_pin[itype][ipin] != OPEN) {
465465
if (f_direct_type_from_blk_pin[itype][ipin] == SOURCE) {
466466
fprintf(f, "%-9s %-9d true SOURCE \n", type.name, ipin);

vpr/src/place/timing_place_lookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,8 @@ void OverrideDelayModel::compute_override_delay_model(const RouterDelayProfiler&
867867
InstPort from_port = parse_inst_port(direct->from_pin);
868868
InstPort to_port = parse_inst_port(direct->to_pin);
869869

870-
t_physical_tile_type_ptr from_type = find_block_type_by_name(from_port.instance_name(), device_ctx.logical_block_types);
871-
t_physical_tile_type_ptr to_type = find_block_type_by_name(to_port.instance_name(), device_ctx.logical_block_types);
870+
t_physical_tile_type_ptr from_type = find_tile_type_by_name(from_port.instance_name(), device_ctx.physical_tile_types);
871+
t_physical_tile_type_ptr to_type = find_tile_type_by_name(to_port.instance_name(), device_ctx.physical_tile_types);
872872

873873
int num_conns = from_port.port_high_index() - from_port.port_low_index() + 1;
874874
VTR_ASSERT_MSG(num_conns == to_port.port_high_index() - to_port.port_low_index() + 1, "Directs must have the same size to/from");

vpr/src/util/vpr_utils.cpp

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ static int** f_port_from_blk_pin = nullptr;
4242

4343
/* f_port_pin_from_blk_pin array allow us to quickly find what port pin a*
4444
* block pin corresponds to. *
45-
* [0...device_ctx.logical_block_types.size()-1][0...blk_pin_count-1] */
45+
* [0...device_ctx.physical_tile_types.size()-1][0...blk_pin_count-1] */
4646
static int** f_port_pin_from_blk_pin = nullptr;
4747

4848
/* f_port_pin_to_block_pin array allows us to quickly find what block *
4949
* pin a port pin corresponds to. *
50-
* [0...device_ctx.logical_block_types.size()-1][0...num_ports-1][0...num_port_pins-1] */
50+
* [0...device_ctx.physical_tile_types.size()-1][0...num_ports-1][0...num_port_pins-1] */
5151
static int*** f_blk_pin_from_port_pin = nullptr;
5252

5353
//Regular expressions used to determine register and logic primitives
@@ -731,15 +731,6 @@ void get_pin_range_for_block(const ClusterBlockId blk_id,
731731
*pin_high = (place_ctx.block_locs[blk_id].loc.z + 1) * (type->num_pins / type->capacity) - 1;
732732
}
733733

734-
t_physical_tile_type_ptr find_block_type_by_name(std::string name, const std::vector<t_logical_block_type>& types) {
735-
for (auto const& type : types) {
736-
if (type.name == name) {
737-
return physical_tile_type(&type);
738-
}
739-
}
740-
return nullptr; //Not found
741-
}
742-
743734
t_physical_tile_type_ptr find_tile_type_by_name(std::string name, const std::vector<t_physical_tile_type>& types) {
744735
for (auto const& type : types) {
745736
if (type.name == name) {
@@ -843,7 +834,7 @@ InstPort parse_inst_port(std::string str) {
843834
InstPort inst_port(str);
844835

845836
auto& device_ctx = g_vpr_ctx.device();
846-
auto blk_type = find_block_type_by_name(inst_port.instance_name(), device_ctx.logical_block_types);
837+
auto blk_type = find_tile_type_by_name(inst_port.instance_name(), device_ctx.physical_tile_types);
847838
if (blk_type == nullptr) {
848839
VPR_FATAL_ERROR(VPR_ERROR_ARCH, "Failed to find block type named %s", inst_port.instance_name().c_str());
849840
}
@@ -1993,14 +1984,15 @@ static void mark_direct_of_ports(int idirect, int direct_type, char* pb_type_nam
19931984
auto& device_ctx = g_vpr_ctx.device();
19941985

19951986
// Go through all the block types
1996-
for (itype = 1; itype < device_ctx.logical_block_types.size(); itype++) {
1987+
for (itype = 1; itype < device_ctx.physical_tile_types.size(); itype++) {
1988+
auto& physical_tile = device_ctx.physical_tile_types[itype];
19971989
// Find blocks with the same pb_type_name
1998-
if (strcmp(device_ctx.logical_block_types[itype].pb_type->name, pb_type_name) == 0) {
1999-
num_ports = device_ctx.logical_block_types[itype].pb_type->num_ports;
1990+
if (strcmp(physical_tile.name, pb_type_name) == 0) {
1991+
num_ports = physical_tile.ports.size();
20001992
for (iport = 0; iport < num_ports; iport++) {
20011993
// Find ports with the same port_name
2002-
if (strcmp(device_ctx.logical_block_types[itype].pb_type->ports[iport].name, port_name) == 0) {
2003-
num_port_pins = device_ctx.logical_block_types[itype].pb_type->ports[iport].num_pins;
1994+
if (strcmp(physical_tile.ports[iport].name, port_name) == 0) {
1995+
num_port_pins = physical_tile.ports[iport].num_pins;
20041996

20051997
// Check whether the end_pin_index is valid
20061998
if (end_pin_index > num_port_pins) {
@@ -2057,13 +2049,13 @@ void alloc_and_load_idirect_from_blk_pin(t_direct_inf* directs, int num_directs,
20572049
auto& device_ctx = g_vpr_ctx.device();
20582050

20592051
/* Allocate and initialize the values to OPEN (-1). */
2060-
temp_idirect_from_blk_pin = (int**)vtr::malloc(device_ctx.logical_block_types.size() * sizeof(int*));
2061-
temp_direct_type_from_blk_pin = (int**)vtr::malloc(device_ctx.logical_block_types.size() * sizeof(int*));
2062-
for (const auto& type : device_ctx.logical_block_types) {
2052+
temp_idirect_from_blk_pin = (int**)vtr::malloc(device_ctx.physical_tile_types.size() * sizeof(int*));
2053+
temp_direct_type_from_blk_pin = (int**)vtr::malloc(device_ctx.physical_tile_types.size() * sizeof(int*));
2054+
for (const auto& type : device_ctx.physical_tile_types) {
20632055
if (is_empty_type(&type)) continue;
20642056

20652057
int itype = type.index;
2066-
num_type_pins = type.pb_type->num_pins;
2058+
num_type_pins = type.num_pins;
20672059

20682060
temp_idirect_from_blk_pin[itype] = (int*)vtr::malloc(num_type_pins * sizeof(int));
20692061
temp_direct_type_from_blk_pin[itype] = (int*)vtr::malloc(num_type_pins * sizeof(int));

vpr/src/util/vpr_utils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ const t_pb_graph_pin* find_pb_graph_pin(const t_pb_graph_node* pb_gnode, std::st
111111

112112
AtomPinId find_atom_pin(ClusterBlockId blk_id, const t_pb_graph_pin* pb_gpin);
113113

114-
//Returns the physical tile type matching a given logical block type name, or nullptr (if not found)
115-
t_physical_tile_type_ptr find_block_type_by_name(std::string name, const std::vector<t_logical_block_type>& types);
116-
117114
//Returns the physical tile type matching a given physical tile type name, or nullptr (if not found)
118115
t_physical_tile_type_ptr find_tile_type_by_name(std::string name, const std::vector<t_physical_tile_type>& types);
119116

0 commit comments

Comments
 (0)