Skip to content

Commit 4420969

Browse files
committed
added an echo file for the NoC and a function that dumps the contents of the NoC model datastructure
1 parent af7b58f commit 4420969

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

vpr/src/base/echo_files.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ void alloc_and_load_echo_file_info() {
123123
setEchoFileName(E_ECHO_LOOKAHEAD_MAP, "lookahead_map.echo");
124124
setEchoFileName(E_ECHO_RR_GRAPH_INDEXED_DATA, "rr_indexed_data.echo");
125125
setEchoFileName(E_ECHO_COMPRESSED_GRIDS, "compressed_grids.echo");
126+
127+
//NoC
128+
setEchoFileName(E_ECHO_NOC_MODEL, "noc_model.echo");
126129
}
127130

128131
void free_echo_file_info() {

vpr/src/base/echo_files.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ enum e_echo_files {
6161
E_ECHO_FINAL_ROUTING_TIMING_GRAPH,
6262
E_ECHO_ANALYSIS_TIMING_GRAPH,
6363

64+
//NoC
65+
E_ECHO_NOC_MODEL,
66+
6467
E_ECHO_END_TOKEN
6568
};
6669

vpr/src/base/setup_noc.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "vtr_assert.h"
88
#include "vpr_error.h"
99
#include "vtr_math.h"
10+
#include "echo_files.h"
1011

1112
static void identify_and_store_noc_router_tile_positions(const DeviceGrid& device_grid, std::vector<t_noc_router_tile_position>& list_of_noc_router_tiles, std::string noc_router_tile_name);
1213

@@ -16,6 +17,8 @@ static void create_noc_routers(const t_noc_inf& noc_info, NocStorage* noc_model,
1617

1718
static void create_noc_links(const t_noc_inf* noc_info, NocStorage* noc_model);
1819

20+
static void echo_noc(char* file_name);
21+
1922

2023
void setup_noc(const t_arch& arch)
2124
{
@@ -53,6 +56,14 @@ void setup_noc(const t_arch& arch)
5356
noc_ctx.noc_link_latency = arch.noc->link_latency;
5457
noc_ctx.noc_router_latency = arch.noc->router_latency;
5558

59+
// echo the noc info
60+
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_NOC_MODEL))
61+
{
62+
echo_noc(getEchoFileName(E_ECHO_NOC_MODEL));
63+
}
64+
65+
exit(1);
66+
5667
return;
5768

5869
}
@@ -283,4 +294,59 @@ static void create_noc_links(const t_noc_inf* noc_info, NocStorage* noc_model){
283294

284295
}
285296

297+
static void echo_noc(char* file_name)
298+
{
299+
FILE* fp;
300+
fp = vtr::fopen(file_name, "w");
301+
302+
fprintf(fp, "--------------------------------------------------------------\n");
303+
fprintf(fp, "NoC\n");
304+
fprintf(fp, "--------------------------------------------------------------\n");
305+
fprintf(fp, "\n");
306+
307+
auto& noc_ctx = g_vpr_ctx.noc();
308+
309+
// print the overall constraints of the NoC
310+
fprintf(fp, "NoC Constraints:\n");
311+
fprintf(fp, "--------------------------------------------------------------\n");
312+
fprintf(fp, "\n");
313+
fprintf(fp, "Maximum NoC Link Bandwidth: %d\n", noc_ctx.noc_link_bandwidth);
314+
fprintf(fp, "\n");
315+
fprintf(fp, "NoC Link Latency: %d\n", noc_ctx.noc_link_latency);
316+
fprintf(fp, "\n");
317+
fprintf(fp, "NoC Router Latency: %d\n", noc_ctx.noc_router_latency);
318+
fprintf(fp, "\n");
319+
320+
// print all the routers and their properties
321+
fprintf(fp, "NoC Router List:\n");
322+
fprintf(fp, "--------------------------------------------------------------\n");
323+
fprintf(fp, "\n");
324+
325+
auto& noc_routers = noc_ctx.noc_model.get_noc_routers();
326+
327+
// go through each router and print its information
328+
for (auto router = noc_routers.begin(); router != noc_routers.end(); router++)
329+
{
330+
fprintf(fp,"Router %d:\n", router->get_router_id());
331+
// if the router tile is larger than a single grid, the position represents the bottom left corner of the tile
332+
fprintf(fp,"Equivalent Physical Tile Grid Position -> (%d,%d)\n", router->get_router_grid_position_x(), router->get_router_grid_position_y());
333+
fprintf(fp, "Router Connections ->");
334+
335+
auto& router_connections = noc_ctx.noc_model.get_noc_router_connections(noc_ctx.noc_model.convert_router_id(router->get_router_id()));
336+
337+
// go through the links of the current router and add the connecting router to the list
338+
for (auto router_link = router_connections.begin(); router_link != router_connections.end(); router_link++)
339+
{
340+
fprintf(fp, " %d", noc_ctx.noc_model.get_noc_router_id(noc_ctx.noc_model.get_noc_link_sink_router(*router_link)));
341+
}
342+
343+
fprintf(fp, "\n\n");
344+
}
345+
346+
fclose(fp);
347+
348+
return;
349+
350+
}
351+
286352

0 commit comments

Comments
 (0)