Skip to content

Commit ab91d2a

Browse files
add comments
1 parent dba632b commit ab91d2a

File tree

7 files changed

+99
-30
lines changed

7 files changed

+99
-30
lines changed

libs/libarchfpga/src/arch_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
/* Value for UNDEFINED data */
1919
constexpr int UNDEFINED = -1;
2020

21+
/** The total number of predefined blif models */
2122
constexpr int NUM_MODELS_IN_LIBRARY = 4;
2223

23-
/* Maximum value for mininum channel width to avoid overflows of short data type. */
24+
/* Maximum value for minimum channel width to avoid overflows of short data type. */
2425
constexpr int MAX_CHANNEL_WIDTH = 8000;
2526

2627
/* Built-in library models */

libs/libarchfpga/src/physical_types.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,8 +1947,14 @@ struct t_noc_inf {
19471947
/** A list of all routers in the NoC*/
19481948
std::vector<t_router> router_list;
19491949

1950+
/** Stores NoC routers that have a different latency than the NoC-wide router latency.
1951+
* (router_user_id, overridden router latency)*/
19501952
std::map<int, double> router_latency_overrides;
1953+
/** Stores NoC links that have a different latency than the NoC-wide link latency.
1954+
* ((source router id, destination router id), overridden link latency)*/
19511955
std::map<std::pair<int, int>, double> link_latency_overrides;
1956+
/** Stores NoC links that have a different bandwidth than the NoC-wide link bandwidth.
1957+
* ((source router id, destination router id), overridden link bandwidth)*/
19521958
std::map<std::pair<int, int>, double> link_bandwidth_overrides;
19531959

19541960
/** Represents the name of a router tile on the FPGA device. This should match the name used in the arch file when
@@ -1958,7 +1964,8 @@ struct t_noc_inf {
19581964

19591965
/* Detailed routing architecture */
19601966
struct t_arch {
1961-
/** Stores unique strings used as key and values in <metadata> tags*/
1967+
/** Stores unique strings used as key and values in <metadata> tags,
1968+
* i.e. implements a flyweight pattern to save memory.*/
19621969
mutable vtr::string_internment strings;
19631970
std::vector<vtr::interned_string> interned_strings;
19641971

libs/libarchfpga/src/read_xml_arch_file_noc_tag.cpp

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,65 @@
66
#include "vtr_log.h"
77
#include "arch_error.h"
88

9+
/**
10+
* @brief Process the <topology> tag under <noc> tag.
11+
*
12+
* Using <topology> tag, the user can specify a custom
13+
* topology.
14+
*
15+
* @param topology_tag An XML node pointing to a <topology> tag.
16+
* @param loc_data Points to the location in the xml file where the parser is reading.
17+
* @param noc_ref To be filled with NoC router locations and their connectivity.
18+
*/
919
static void process_topology(pugi::xml_node topology_tag,
1020
const pugiutil::loc_data& loc_data,
1121
t_noc_inf* noc_ref);
1222

13-
static void process_mesh_topology(pugi::xml_node mesh_topology_tag,
14-
const pugiutil::loc_data& loc_data, t_noc_inf* noc_ref);
15-
23+
/**
24+
* @brief Process a <router> tag under a <topology> tag.
25+
*
26+
* A <topology> tag contains multiple <router> tags. Each <router> tag has
27+
* attributes that specify its location and connectivity to other NoC routers.
28+
*
29+
* @param router_tag An XML node pointing to a <router> tag.
30+
* @param loc_data Points to the location in the xml file where the parser is reading.
31+
* @param noc_ref To be filled with the given router's location and connectivity information.
32+
* @param routers_in_arch_info Stores router information that includes the number of connections
33+
* a router has within a given topology and also the number of times a router was declared
34+
* in the arch file using the <router> tag. [router_id, [n_declarations, n_connections]]
35+
*/
1636
static void process_router(pugi::xml_node router_tag,
1737
const pugiutil::loc_data& loc_data,
1838
t_noc_inf* noc_ref,
19-
std::map<int, std::pair<int, int>>& routers_info_in_arch);
39+
std::map<int, std::pair<int, int>>& routers_in_arch_info);
40+
41+
/**
42+
* @brief Processes the <mesh> tag under <noc> tag.
43+
*
44+
* Using the <mesh> tag, the user can describe a NoC with
45+
* mesh topology.
46+
*
47+
* @param mesh_topology_tag An XML tag pointing to a <mesh> tag.
48+
* @param loc_data Points to the location in the xml file where the parser is reading.
49+
* @param noc_ref To be filled with NoC router locations and their connectivity.
50+
*/
51+
static void process_mesh_topology(pugi::xml_node mesh_topology_tag,
52+
const pugiutil::loc_data& loc_data, t_noc_inf* noc_ref);
2053

54+
55+
/**
56+
* Create routers and set their properties so that a mesh grid of routers is created.
57+
* Then connect the routers together so that a mesh topology is created.
58+
*
59+
* @param mesh_topology_tag An XML tag pointing to a <mesh> tag.
60+
* @param loc_data Points to the location in the xml file where the parser is reading.
61+
* @param noc_ref To be filled with NoC router locations and their connectivity.
62+
* @param mesh_region_start_x The location the bottom left NoC router on the X-axis.
63+
* @param mesh_region_end_x The location the top right NoC router on the X-axis.
64+
* @param mesh_region_start_y The location the bottom left NoC router on the Y-axis.
65+
* @param mesh_region_end_y The location the top right NoC router on the Y-axis.
66+
* @param mesh_size The number of NoC routers in each row or column.
67+
*/
2168
static void generate_noc_mesh(pugi::xml_node mesh_topology_tag,
2269
const pugiutil::loc_data& loc_data,
2370
t_noc_inf* noc_ref,
@@ -81,12 +128,21 @@ static void update_router_info_in_arch(int router_id,
81128
bool router_updated_as_a_connection,
82129
std::map<int, std::pair<int, int>>& routers_in_arch_info);
83130

84-
131+
/**
132+
* @brief Process <overrides> tag under <noc> tag.
133+
*
134+
* The user can override the default latency and bandwidth values
135+
* for specific NoC routers and links using <router> and <link>
136+
* tags under <overrides> tag.
137+
*
138+
* @param noc_overrides_tag An XML node pointing to a <overrides> tag.
139+
* @param loc_data Points to the location in the xml file where the parser is reading.
140+
* @param noc_ref To be filled with parsed overridden latencies and bandwidths.
141+
*/
85142
static void process_noc_overrides(pugi::xml_node noc_overrides_tag,
86143
const pugiutil::loc_data& loc_data,
87144
t_noc_inf& noc_ref);
88145

89-
90146
void process_noc_tag(pugi::xml_node noc_tag,
91147
t_arch* arch,
92148
const pugiutil::loc_data& loc_data) {
@@ -195,10 +251,6 @@ static void process_mesh_topology(pugi::xml_node mesh_topology_tag,
195251
generate_noc_mesh(mesh_topology_tag, loc_data, noc_ref, mesh_region_start_x, mesh_region_end_x, mesh_region_start_y, mesh_region_end_y, mesh_size);
196252
}
197253

198-
/*
199-
* Create routers and set their properties so that a mesh grid of routers is created.
200-
* Then connect the routers together so that a mesh topology is created.
201-
*/
202254
static void generate_noc_mesh(pugi::xml_node mesh_topology_tag,
203255
const pugiutil::loc_data& loc_data,
204256
t_noc_inf* noc_ref,

vpr/src/base/setup_noc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,14 @@ void create_noc_links(const t_noc_inf& noc_info, NocStorage* noc_model) {
246246
// get the converted id of the currently connected sink router
247247
sink_router = noc_model->convert_router_id(conn_router_id);
248248

249+
// check if this link has an overridden latency
249250
auto lat_it = noc_info.link_latency_overrides.find({router.id, conn_router_id});
251+
// use the link-specific latency if it has an overridden latency, otherwise use the NoC-wide link latency
250252
double link_lat = (lat_it == noc_info.link_latency_overrides.end()) ? noc_info.link_latency : lat_it->second;
251253

254+
// check if this link has an overridden bandwidth
252255
auto bw_it = noc_info.link_bandwidth_overrides.find({router.id, conn_router_id});
256+
// use the link-specific bandwidth if it has an overridden bandwidth, otherwise use the NoC-wide link bandwidth
253257
double link_bw = (bw_it == noc_info.link_bandwidth_overrides.end()) ? noc_info.link_bandwidth : bw_it->second;
254258

255259
// add the link to the Noc

vpr/src/noc/noc_link.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class NocLink {
5151

5252
double bandwidth_usage; /*!< Represents the bandwidth of the data being transmitted on the link. Units in bits-per-second(bps)*/
5353
double bandwidth; /*!< Represents the maximum bits per second that can be transmitted over the link without causing congestion*/
54-
double latency;
54+
double latency; /*!< The zero-load latency of this link in seconds.*/
5555

5656
public:
5757
NocLink(NocLinkId link_id, NocRouterId source_router, NocRouterId sink_router,
@@ -64,33 +64,33 @@ class NocLink {
6464
* edge
6565
* @return A unique id (NocRouterId) that identifies the source router of the link
6666
*/
67-
NocRouterId get_source_router(void) const;
67+
NocRouterId get_source_router() const;
6868

6969
/**
7070
* @brief Provides the id of the router that has this link as an incoming
7171
* edge
7272
* @return A unique id (NocRouterId) that identifies the sink router of the link
7373
*/
74-
NocRouterId get_sink_router(void) const;
74+
NocRouterId get_sink_router() const;
7575

7676
/**
7777
* @brief Provides the size of the data (bandwidth) being currently transmitted using the link.
7878
* @return A numeric value of the bandwidth usage of the link
7979
*/
80-
double get_bandwidth_usage(void) const;
80+
double get_bandwidth_usage() const;
8181

8282
/**
8383
* @brief Returns the maximum bandwidth that the link can carry without congestion.
8484
* @return A numeric value of the bandwidth capacity of the link
8585
*/
86-
double get_bandwidth(void) const;
86+
double get_bandwidth() const;
8787

8888
/**
8989
* @brief Calculates the extent to which the current bandwidth utilization
9090
* exceeds the link capacity. Any positive value means the link is congested.
9191
* @return A numeric value of the bandwidth over-utilization in the link
9292
*/
93-
double get_congested_bandwidth(void) const;
93+
double get_congested_bandwidth() const;
9494

9595
/**
9696
* @brief Computes the congested bandwidth to bandwidth capacity ratio.

vpr/src/noc/noc_router.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ NocRouter::NocRouter(int id,
1414
}
1515

1616
// getters
17-
int NocRouter::get_router_user_id(void) const {
17+
int NocRouter::get_router_user_id() const {
1818
return router_user_id;
1919
}
2020

21-
int NocRouter::get_router_grid_position_x(void) const {
21+
int NocRouter::get_router_grid_position_x() const {
2222
return router_grid_position_x;
2323
}
2424

25-
int NocRouter::get_router_grid_position_y(void) const {
25+
int NocRouter::get_router_grid_position_y() const {
2626
return router_grid_position_y;
2727
}
2828

29-
int NocRouter::get_router_layer_position(void) const {
29+
int NocRouter::get_router_layer_position() const {
3030
return router_layer_position;
3131
}
3232

33-
t_physical_tile_loc NocRouter::get_router_physical_location(void) const {
33+
t_physical_tile_loc NocRouter::get_router_physical_location() const {
3434
const int x = get_router_grid_position_x();
3535
const int y = get_router_grid_position_y();
3636
const int layer = get_router_layer_position();
@@ -43,7 +43,7 @@ double NocRouter::get_latency() const {
4343
return router_latency;
4444
}
4545

46-
ClusterBlockId NocRouter::get_router_block_ref(void) const {
46+
ClusterBlockId NocRouter::get_router_block_ref() const {
4747
return router_block_ref;
4848
}
4949

vpr/src/noc/noc_router.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class NocRouter {
5353
* that the physical router is located*/
5454
int router_layer_position;
5555

56+
/** The zero-load latency of this NoC router. */
5657
double router_latency;
5758

5859
/** A unique identifier that represents a router block in the
@@ -70,39 +71,43 @@ class NocRouter {
7071
* @brief Gets the unique id assigned by the user for the physical router
7172
* @return A numerical value (integer) that represents the physical router id
7273
*/
73-
int get_router_user_id(void) const;
74+
int get_router_user_id() const;
7475

7576
/**
7677
* @brief Gets the horizontal position on the FPGA device that the physical router is located
7778
* @return A numerical value (integer) that represents horizontal position of the physical router
7879
*/
79-
int get_router_grid_position_x(void) const;
80+
int get_router_grid_position_x() const;
8081

8182
/**
8283
* @brief Gets the vertical position on the FPGA device that the physical router is located
8384
* @return A numerical value (integer) that represents vertical position of the physical router
8485
*/
85-
int get_router_grid_position_y(void) const;
86+
int get_router_grid_position_y() const;
8687

8788
/**
8889
* @brief Gets the layer number of the die the the physical router is located
8990
* @return A numerical value (integer) that represents layer position of the physical router
9091
*/
91-
int get_router_layer_position(void) const;
92+
int get_router_layer_position() const;
9293

9394
/**
9495
* @brief Gets the physical location where the the physical router is located
9596
* @return t_physical_tile_loc that contains x-y coordinates and the layer number
9697
*/
97-
t_physical_tile_loc get_router_physical_location(void) const;
98+
t_physical_tile_loc get_router_physical_location() const;
9899

100+
/**
101+
* @brief Gets the zero-load latency of this NoC router.
102+
* @return The zero-load latency in seconds.
103+
*/
99104
double get_latency() const;
100105

101106
/**
102107
* @brief Gets the unique id of the router block that is current placed on the physical router
103108
* @return A ClusterBlockId that identifies a router block in the clustered netlist
104109
*/
105-
ClusterBlockId get_router_block_ref(void) const;
110+
ClusterBlockId get_router_block_ref() const;
106111

107112
// setters
108113
/**

0 commit comments

Comments
 (0)