Fix tileable rr graph read/write issue.
This commit is contained in:
parent
70e2330f17
commit
f8e049c73d
|
@ -47,6 +47,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
|
|||
static void process_nets(std::ifstream& fp, ClusterNetId inet, std::string name, std::vector<std::string> input_tokens, const char* filename, int& lineno);
|
||||
static void process_global_blocks(std::ifstream& fp, ClusterNetId inet, const char* filename, int& lineno);
|
||||
static void format_coordinates(int& x, int& y, std::string coord, ClusterNetId net, const char* filename, const int lineno);
|
||||
static void format_ptc_num(int& n0, int& n1, int& n2, int& n3, std::string coord, ClusterNetId net, const char* filename, const int lineno);
|
||||
static void format_pin_info(std::string& pb_name, std::string& port_name, int& pb_pin_num, std::string input);
|
||||
static std::string format_name(std::string name);
|
||||
|
||||
|
@ -201,7 +202,7 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
|
|||
|
||||
/*remember the position of the last line in order to go back*/
|
||||
std::streampos oldpos = fp.tellg();
|
||||
int inode, x, y, x2, y2, ptc, switch_id, offset;
|
||||
int inode, x, y, x2, y2, switch_id, offset;
|
||||
int node_count = 0;
|
||||
std::string input;
|
||||
std::vector<std::string> tokens;
|
||||
|
@ -281,8 +282,9 @@ static void process_nodes(std::ifstream& fp, ClusterNetId inet, const char* file
|
|||
}
|
||||
}
|
||||
|
||||
ptc = atoi(tokens[5 + offset].c_str());
|
||||
if (device_ctx.rr_graph.node_ptc_num(node) != ptc) {
|
||||
int ptc0, ptc1, ptc2, ptc3;
|
||||
format_ptc_num(ptc0, ptc1, ptc2, ptc3, tokens[5 + offset], inet, filename, lineno);
|
||||
if (device_ctx.rr_graph.node_ptc_num(node) != ptc0) {
|
||||
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
|
||||
"The ptc num of node %d does not match the rr graph", inode);
|
||||
}
|
||||
|
@ -411,6 +413,35 @@ static void format_coordinates(int& x, int& y, std::string coord, ClusterNetId n
|
|||
}
|
||||
}
|
||||
|
||||
// ptc (Pin-Track-Class) can be one of below patterns in route graph
|
||||
// Node: 714 SOURCE (4,1) Class: 18 Switch: 0
|
||||
// Node: 728 OPIN (4,1) Pin: 57 clb.O[17] Switch: 2
|
||||
// Node: 16733 CHANX (6,2) to (9,2) Track: (56,58,60,62) Switch: 1
|
||||
// Node: 23176 CHANY (4,1) to (4,3) Track: (69,67,65) Switch: 1
|
||||
static void format_ptc_num(int& n0, int& n1, int& n2, int& n3, std::string ptc_str, ClusterNetId net, const char* filename, const int lineno) {
|
||||
// detect how many number needs to be extracted
|
||||
size_t ptc_count = std::count(ptc_str.begin(), ptc_str.end(), ',') + 1;
|
||||
// detect and remove the parenthesis
|
||||
std::stringstream ptc_stream(ptc_count > 1? format_name(ptc_str) : ptc_str);
|
||||
for (size_t i = 0; i < ptc_count; i++) {
|
||||
if (i == 0) {
|
||||
ptc_stream >> n0;
|
||||
} else if (i == 1) {
|
||||
ptc_stream >> n1;
|
||||
} else if (i == 2) {
|
||||
ptc_stream >> n2;
|
||||
} else if (i == 3) {
|
||||
ptc_stream >> n3;
|
||||
}
|
||||
if (ptc_stream.fail()) {
|
||||
vpr_throw(VPR_ERROR_ROUTE, filename, lineno,
|
||||
"Net %lu has bad ptc info in the form (n0,...,n3)", size_t(net));
|
||||
}
|
||||
ptc_stream.ignore(1, ' ');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void format_pin_info(std::string& pb_name, std::string& port_name, int& pb_pin_num, std::string input) {
|
||||
/*Parse the pin info in the form of pb_name.port_name[pb_pin_num]
|
||||
*into its appropriate variables*/
|
||||
|
|
|
@ -1510,7 +1510,7 @@ void print_route(FILE* fp, const vtr::vector<ClusterNetId, t_traceback>& traceba
|
|||
fprintf(fp, "(");
|
||||
for (size_t itrack = 0; itrack < device_ctx.rr_graph.node_track_ids(inode).size(); ++itrack) {
|
||||
if (0 < itrack) {
|
||||
fprintf(fp, ", ");
|
||||
fprintf(fp, ",");
|
||||
}
|
||||
fprintf(fp, "%d", device_ctx.rr_graph.node_track_ids(inode)[itrack]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue