Skip to content

Commit 0195849

Browse files
committed
Merge branch 'rr-graph-binary-read-write' into master+wip
Signed-off-by: Alessandro Comodi <[email protected]>
2 parents 5f9d494 + 540c9ea commit 0195849

File tree

6 files changed

+326
-81
lines changed

6 files changed

+326
-81
lines changed

vpr/src/route/rr_graph.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,54 @@ static vtr::NdMatrix<std::vector<int>, 4> alloc_and_load_track_to_pin_lookup(vtr
25082508
return track_to_pin_lookup;
25092509
}
25102510

2511+
/* Writes out data (excludes fasm metadata) about node inode to binary in file fp *
2512+
* Writes data in the following order: int inode, t_rr_type type, e_direction *
2513+
* direction (if CHANX or CHANY), uint16_t capacity, length 5 uint16_t array pos, *
2514+
* e_side side (if IPIN or OPIN), float R, float C, uint16_t num_edges.Then loops *
2515+
* through every edge writing out int edge_sink node and uint16_t edge_switch. */
2516+
void write_rr_node(FILE* fp, const std::vector<t_rr_node>& L_rr_node, int inode) {
2517+
const auto& rr_node = L_rr_node[inode];
2518+
t_rr_type type = rr_node.type();
2519+
uint16_t num_edges = rr_node.num_edges();
2520+
int edge_sink_node;
2521+
uint16_t edge_switch;
2522+
uint16_t capacity = (uint16_t)rr_node.capacity();
2523+
float R = rr_node.R();
2524+
float C = rr_node.C();
2525+
uint16_t pos[5];
2526+
2527+
pos[0] = rr_node.xlow();
2528+
pos[1] = rr_node.ylow();
2529+
pos[2] = rr_node.xhigh();
2530+
pos[3] = rr_node.yhigh();
2531+
pos[4] = rr_node.ptc_num();
2532+
2533+
fwrite(&inode, sizeof(inode), 1, fp);
2534+
fwrite(&type, sizeof(type), 1, fp);
2535+
if (rr_node.type() == CHANX || rr_node.type() == CHANY) {
2536+
e_direction direction = rr_node.direction();
2537+
fwrite(&direction, sizeof(direction), 1, fp);
2538+
}
2539+
fwrite(&capacity, sizeof(capacity), 1, fp);
2540+
fwrite(pos, sizeof(*pos), 5, fp);
2541+
2542+
if (rr_node.type() == IPIN || rr_node.type() == OPIN) {
2543+
e_side side = rr_node.side();
2544+
fwrite(&side, sizeof(side), 1, fp);
2545+
}
2546+
2547+
fwrite(&R, sizeof(R), 1, fp);
2548+
fwrite(&C, sizeof(C), 1, fp);
2549+
fwrite(&num_edges, sizeof(num_edges), 1, fp);
2550+
2551+
for (int iedge = 0; iedge < rr_node.num_edges(); ++iedge) {
2552+
edge_sink_node = rr_node.edge_sink_node(iedge);
2553+
edge_switch = rr_node.edge_switch(iedge);
2554+
fwrite(&edge_sink_node, sizeof(edge_sink_node), 1, fp);
2555+
fwrite(&edge_switch, sizeof(edge_switch), 1, fp);
2556+
}
2557+
}
2558+
25112559
std::string describe_rr_node(int inode) {
25122560
auto& device_ctx = g_vpr_ctx.device();
25132561

vpr/src/route/rr_graph.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* and so are not currently used in commercial architectures. */
77
#define INCLUDE_TRACK_BUFFERS false
88

9+
#define BINARY_MAGIC_NUM 0x42525247
10+
#define BINARY_FILE_VERSION 1
11+
912
#include "device_grid.h"
1013

1114
enum e_graph_type {
@@ -47,6 +50,9 @@ void free_rr_graph();
4750
//Returns a brief one-line summary of an RR node
4851
std::string describe_rr_node(int inode);
4952

53+
void print_rr_node(FILE* fp, const std::vector<t_rr_node>& L_rr_node, int inode);
54+
void write_rr_node(FILE* fp, const std::vector<t_rr_node>& L_rr_node, int inode);
55+
5056
void init_fan_in(std::vector<t_rr_node>& L_rr_node, const int num_rr_nodes);
5157

5258
// Sets the spec for the rr_switch based on the arch switch

0 commit comments

Comments
 (0)