@@ -43,6 +43,18 @@ double NocStorage::get_noc_router_latency(void) const {
4343 return noc_router_latency;
4444}
4545
46+ bool NocStorage::get_detailed_router_latency () const {
47+ return detailed_router_latency_;
48+ }
49+
50+ bool NocStorage::get_detailed_link_latency () const {
51+ return detailed_link_latency_;
52+ }
53+
54+ bool NocStorage::get_detailed_link_bandwidth () const {
55+ return detailed_link_bandwidth_;
56+ }
57+
4658const NocRouter& NocStorage::get_single_noc_router (NocRouterId id) const {
4759 return router_storage[id];
4860}
@@ -130,29 +142,23 @@ void NocStorage::set_noc_link_bandwidth(double link_bandwidth) {
130142 for (auto & link : link_storage) {
131143 link.set_bandwidth (noc_link_bandwidth);
132144 }
133-
134- return ;
135145}
136146
137147void NocStorage::set_noc_link_latency (double link_latency) {
138148 noc_link_latency = link_latency;
139- return ;
140149}
141150
142151void NocStorage::set_noc_router_latency (double router_latency) {
143152 noc_router_latency = router_latency;
144- return ;
145153}
146154
147155void NocStorage::set_device_grid_width (int grid_width) {
148156 device_grid_width = grid_width;
149- return ;
150157}
151158
152159void NocStorage::set_device_grid_spec (int grid_width, int grid_height) {
153160 device_grid_width = grid_width;
154161 layer_num_grid_locs = grid_width * grid_height;
155- return ;
156162}
157163
158164bool NocStorage::remove_link (NocRouterId src_router_id, NocRouterId sink_router_id) {
@@ -161,7 +167,7 @@ bool NocStorage::remove_link(NocRouterId src_router_id, NocRouterId sink_router_
161167
162168 // check if the src router for the link to remove exists (within the id ranges). Otherwise, there is no point looking for the link
163169 if ((size_t )src_router_id < router_storage.size ()) {
164- // get all the outgoing links of the provided sourcer router
170+ // get all the outgoing links of the provided source router
165171 std::vector<NocLinkId>* source_router_outgoing_links = &router_link_list[src_router_id];
166172
167173 // keeps track of the position of each outgoing link for the provided src router. When the id of the link to remove is found, this index can be used to remove it from the outgoing link vector.
@@ -199,26 +205,48 @@ bool NocStorage::remove_link(NocRouterId src_router_id, NocRouterId sink_router_
199205 return link_removed_status;
200206}
201207
202- void NocStorage::finished_building_noc (void ) {
208+ void NocStorage::finished_building_noc () {
203209 VTR_ASSERT_MSG (!built_noc, " NoC already built, cannot modify further." );
204210 built_noc = true ;
205211
206- return ;
212+ /* We go through all NoC routers in the router_storage and check if there are any
213+ * two consecutive NoC routers whose latency is different. If such two routers are
214+ * found, we set detailed_router_latency_ to True.
215+ *
216+ * The values of detailed_link_latency_ and detailed_link_bandwidth_ are determined
217+ * in a similar way.
218+ */
219+
220+ auto router_latency_it = std::adjacent_find (router_storage.begin (), router_storage.end (),
221+ [](const NocRouter& a, const NocRouter& b) {
222+ return a.get_latency () != b.get_latency ();
223+ });
224+ detailed_router_latency_ = (router_latency_it != router_storage.end ());
225+
226+ auto link_latency_it = std::adjacent_find (link_storage.begin (), link_storage.end (),
227+ [](const NocLink& a, const NocLink& b) {
228+ return a.get_latency () != b.get_latency ();
229+ });
230+ detailed_link_latency_ = (link_latency_it != link_storage.end ());
231+
232+ auto link_bandwidth_it = std::adjacent_find (link_storage.begin (), link_storage.end (),
233+ [](const NocLink& a, const NocLink& b) {
234+ return a.get_bandwidth () != b.get_bandwidth ();
235+ });
236+ detailed_link_bandwidth_ = (link_bandwidth_it != link_storage.end ());
207237}
208238
209- void NocStorage::clear_noc (void ) {
239+ void NocStorage::clear_noc () {
210240 router_storage.clear ();
211241 link_storage.clear ();
212242 router_link_list.clear ();
213243 grid_location_to_router_id.clear ();
214244
215245 built_noc = false ;
216-
217- return ;
218246}
219247
220248NocRouterId NocStorage::convert_router_id (int id) const {
221- std::unordered_map< int , NocRouterId>::const_iterator result = router_id_conversion_table.find (id);
249+ auto result = router_id_conversion_table.find (id);
222250
223251 if (result == router_id_conversion_table.end ()) {
224252 VPR_FATAL_ERROR (VPR_ERROR_OTHER, " Cannot convert router with id:%d. The router was not found within the NoC." , id);
0 commit comments