Skip to content

Commit feec365

Browse files
committed
Fix unit test as testarch has 2 lut bels
Small improvements to RR graph generation Signed-off-by: Maciej Dudek <[email protected]>
1 parent bc11218 commit feec365

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

vpr/src/route/rr_graph_fpga_interchange.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ struct RR_Graph_Builder {
770770
for (intermediate_node* root : roots) {
771771
if (root == last)
772772
continue;
773+
VTR_ASSERT(redirect_.find(std::make_tuple(node_id, last->loc)) != redirect_.end());
773774
auto key1 = redirect_[std::make_tuple(node_id, last->loc)];
775+
VTR_ASSERT(redirect_.find(std::make_tuple(node_id, root->loc)) != redirect_.end());
774776
auto key2 = redirect_[std::make_tuple(node_id, root->loc)];
775777

776778
shorts_.emplace_back(std::get<0>(key1), std::get<1>(key1), std::get<2>(key1),
@@ -1074,6 +1076,7 @@ struct RR_Graph_Builder {
10741076
bool input;
10751077
int node_id;
10761078
std::tie(input, std::ignore, node_id) = pin_vec[j];
1079+
VTR_ASSERT(redirect_.find(std::make_tuple(node_id, loc)) != redirect_.end());
10771080
auto chan_key = redirect_[std::make_tuple(node_id, loc)];
10781081
e_rr_type pin = input ? e_rr_type::SINK : e_rr_type::SOURCE;
10791082
e_rr_type mux = input ? e_rr_type::IPIN : e_rr_type::OPIN;
@@ -1116,6 +1119,14 @@ struct RR_Graph_Builder {
11161119
}
11171120
}
11181121

1122+
char* int_to_string(char* buff, int value) {
1123+
if (value < 10) {
1124+
return &(*buff = '0' + value) + 1;
1125+
} else {
1126+
return &(*int_to_string(buff, value / 10) = '0' + value % 10) + 1;
1127+
}
1128+
}
1129+
11191130
void pack_pips() {
11201131
for (auto& i : pips_) {
11211132
int node1, node2;
@@ -1128,7 +1139,9 @@ struct RR_Graph_Builder {
11281139
bool forward;
11291140
std::tie(name, wire0, wire1, forward) = metadata;
11301141
location loc = tile_to_loc_[tile_id];
1142+
VTR_ASSERT(redirect_.find(std::make_tuple(node1, loc)) != redirect_.end());
11311143
auto key1 = redirect_[std::make_tuple(node1, loc)];
1144+
VTR_ASSERT(redirect_.find(std::make_tuple(node2, loc)) != redirect_.end());
11321145
auto key2 = redirect_[std::make_tuple(node2, loc)];
11331146

11341147
VTR_ASSERT(loc_type_idx_to_rr_idx_.find(key1) != loc_type_idx_to_rr_idx_.end());
@@ -1139,14 +1152,19 @@ struct RR_Graph_Builder {
11391152
sink = loc_type_idx_to_rr_idx_[key2];
11401153
device_ctx_.rr_graph_builder.emplace_back_edge(RRNodeId(src), RRNodeId(sink), sw_id);
11411154

1142-
vtr::interned_string name_(empty_);
1143-
vtr::interned_string value_(empty_);
1144-
11451155
char metadata_[100];
1146-
sprintf(metadata_, "%d,%d,%d,%d", name, wire0, wire1, forward ? 1 : 0);
1156+
char* temp = int_to_string(metadata_, name);
1157+
*temp++ = ',';
1158+
temp = int_to_string(temp, wire0);
1159+
*temp++ = ',';
1160+
temp = int_to_string(temp, wire1);
1161+
*temp++ = ',';
1162+
temp = int_to_string(temp, forward ? 1 : 0);
1163+
*temp++ = 0;
1164+
1165+
vtr::interned_string name_(device_ctx_.arch->strings.intern_string(vtr::string_view("FPGAInterchange")));
1166+
vtr::interned_string value_(device_ctx_.arch->strings.intern_string(vtr::string_view(metadata_)));
11471167

1148-
name_ = device_ctx_.arch->strings.intern_string(vtr::string_view("FPGAInterchange"));
1149-
value_ = device_ctx_.arch->strings.intern_string(vtr::string_view(metadata_));
11501168
vpr::add_rr_edge_metadata(src, sink, sw_id, name_, value_);
11511169
}
11521170
}

0 commit comments

Comments
 (0)