@@ -197,17 +197,6 @@ void Graph2D::addCapV(const int x, const int y, const int cap)
197197 v_edges_[x][y].cap += cap;
198198}
199199
200- // Adds estimated usage to a horizontal edge segment.
201- void Graph2D::addEstUsageH (const Interval& xi, const int y, const double usage)
202- {
203- for (int x = xi.lo ; x < xi.hi ; x++) {
204- h_edges_[x][y].est_usage += usage;
205- if (usage > 0 ) {
206- h_used_ggrid_.insert ({x, y});
207- }
208- }
209- }
210-
211200// Updates estimated usage for a horizontal edge segment, considering NDRs.
212201void Graph2D::updateEstUsageH (const Interval& xi,
213202 const int y,
@@ -233,32 +222,12 @@ void Graph2D::updateEstUsageH(const int x,
233222 }
234223}
235224
236- // Adds estimated usage to a horizontal edge.
237- void Graph2D::addEstUsageH (const int x, const int y, const double usage)
238- {
239- h_edges_[x][y].est_usage += usage;
240- if (usage > 0 ) {
241- h_used_ggrid_.insert ({x, y});
242- }
243- }
244-
245225// Adds the estimated usage to the actual usage for all edges.
246226void Graph2D::addEstUsageToUsage ()
247227{
248228 foreachEdge ([](Edge& edge) { edge.usage += edge.est_usage ; });
249229}
250230
251- // Adds estimated usage to a vertical edge segment.
252- void Graph2D::addEstUsageV (const int x, const Interval& yi, const double usage)
253- {
254- for (int y = yi.lo ; y < yi.hi ; y++) {
255- v_edges_[x][y].est_usage += usage;
256- if (usage > 0 ) {
257- v_used_ggrid_.insert ({x, y});
258- }
259- }
260- }
261-
262231// Updates estimated usage for a vertical edge segment, considering NDRs.
263232void Graph2D::updateEstUsageV (const int x,
264233 const Interval& yi,
@@ -284,15 +253,6 @@ void Graph2D::updateEstUsageV(const int x,
284253 }
285254}
286255
287- // Adds estimated usage to a vertical edge.
288- void Graph2D::addEstUsageV (const int x, const int y, const double usage)
289- {
290- v_edges_[x][y].est_usage += usage;
291- if (usage > 0 ) {
292- v_used_ggrid_.insert ({x, y});
293- }
294- }
295-
296256// Adds reduction to a horizontal edge.
297257void Graph2D::addRedH (const int x, const int y, const int red)
298258{
@@ -311,30 +271,33 @@ void Graph2D::addRedV(const int x, const int y, const int red)
311271void Graph2D::addUsageH (const Interval& xi, const int y, const int used)
312272{
313273 for (int x = xi.lo ; x < xi.hi ; x++) {
314- h_edges_[x][y].usage += used;
315- if (used > 0 ) {
316- h_used_ggrid_.insert ({x, y});
317- }
274+ addUsageH (x, y, used);
275+ }
276+ }
277+
278+ // Adds usage to a horizontal edge.
279+ void Graph2D::addUsageH (const int x, const int y, const int used)
280+ {
281+ h_edges_[x][y].usage += used;
282+ if (used > 0 ) {
283+ h_used_ggrid_.insert ({x, y});
318284 }
319285}
320286
321287// Adds usage to a vertical edge segment.
322288void Graph2D::addUsageV (const int x, const Interval& yi, const int used)
323289{
324290 for (int y = yi.lo ; y < yi.hi ; y++) {
325- v_edges_[x][y].usage += used;
326- if (used > 0 ) {
327- v_used_ggrid_.insert ({x, y});
328- }
291+ addUsageV (x, y, used);
329292 }
330293}
331294
332- // Adds usage to a horizontal edge.
333- void Graph2D::addUsageH (const int x, const int y, const int used)
295+ // Adds usage to a vertical edge.
296+ void Graph2D::addUsageV (const int x, const int y, const int used)
334297{
335- h_edges_ [x][y].usage += used;
298+ v_edges_ [x][y].usage += used;
336299 if (used > 0 ) {
337- h_used_ggrid_ .insert ({x, y});
300+ v_used_ggrid_ .insert ({x, y});
338301 }
339302}
340303
@@ -357,13 +320,15 @@ void Graph2D::printAllElements()
357320 return ;
358321 }
359322
360- logger_->report (" Congestion nets ({}):" , congestion_nets_.size ());
323+ logger_->reportLiteral (
324+ fmt::format (" Congestion nets ({}): " , congestion_nets_.size ()));
361325 for (auto it = congestion_nets_.begin (); it != congestion_nets_.end (); ++it) {
362326 if (it != congestion_nets_.begin ()) {
363327 logger_->reportLiteral (" , " );
364328 }
365329 logger_->reportLiteral (fmt::format (" \" {}\" " , *it));
366330 }
331+ logger_->reportLiteral (" \n " );
367332}
368333
369334// Updates usage for a horizontal edge, considering NDRs.
@@ -391,15 +356,6 @@ void Graph2D::updateUsageH(const Interval& xi,
391356 }
392357}
393358
394- // Adds usage to a vertical edge.
395- void Graph2D::addUsageV (const int x, const int y, const int used)
396- {
397- v_edges_[x][y].usage += used;
398- if (used > 0 ) {
399- v_used_ggrid_.insert ({x, y});
400- }
401- }
402-
403359// Updates usage for a vertical edge, considering NDRs.
404360void Graph2D::updateUsageV (const int x,
405361 const int y,
@@ -558,13 +514,13 @@ bool Graph2D::hasNDRCapacity(FrNet* net, int x, int y, EdgeDirection direction)
558514 // capacity
559515 for (int l = net->getMinLayer (); l <= net->getMaxLayer (); l++) {
560516 double layer_cap = 0 ;
561- if (direction == EdgeDirection::Horizontal) {
562- layer_cap = h_cap_3D_[l][x][y]. cap_ndr ;
563- } else {
564- layer_cap = v_cap_3D_ [l][x][y].cap_ndr ;
565- }
517+ int8_t layer_edge_cost = net-> getLayerEdgeCost (l);
518+
519+ layer_cap = (direction == EdgeDirection::Horizontal)
520+ ? h_cap_3D_ [l][x][y].cap_ndr
521+ : v_cap_3D_[l][x][y]. cap_ndr ;
566522
567- if (layer_cap >= edgeCost ) {
523+ if (layer_cap >= layer_edge_cost ) {
568524 return true ;
569525 }
570526 }
@@ -666,20 +622,22 @@ void Graph2D::updateNDRCapLayer(const int x,
666622 }
667623
668624 auto & cap_3D = (dir == EdgeDirection::Horizontal) ? h_cap_3D_ : v_cap_3D_;
625+ int8_t layer_edge_cost = 0 ;
669626
670627 for (int l = net->getMinLayer (); l <= net->getMaxLayer (); l++) {
671628 auto & layer_cap = cap_3D[l][x][y];
629+ layer_edge_cost = net->getLayerEdgeCost (l);
672630 if (edge_cost < 0 ) { // Reducing edge usage
673631 // If we already have a NDR net in this layer, increase the NDR capacity
674632 // available again
675- if (layer_cap.cap - layer_cap.cap_ndr >= edgeCost ) {
676- layer_cap.cap_ndr += edgeCost ;
633+ if (layer_cap.cap - layer_cap.cap_ndr >= layer_edge_cost ) {
634+ layer_cap.cap_ndr += layer_edge_cost ;
677635 return ;
678636 }
679637 } else { // Increasing edge usage
680638 // If there is NDR capacity available, reduce the capacity value
681- if (layer_cap.cap_ndr >= edgeCost ) {
682- layer_cap.cap_ndr -= edgeCost ;
639+ if (layer_cap.cap_ndr >= layer_edge_cost ) {
640+ layer_cap.cap_ndr -= layer_edge_cost ;
683641 return ;
684642 }
685643 }
@@ -689,7 +647,8 @@ void Graph2D::updateNDRCapLayer(const int x,
689647 // in any layer, reduce the capacity available of the first layer.
690648 // When rippin-up, it will be the first to be released
691649 if (edge_cost > 0 ) {
692- cap_3D[net->getMinLayer ()][x][y].cap_ndr -= edgeCost;
650+ layer_edge_cost = net->getLayerEdgeCost (net->getMinLayer ());
651+ cap_3D[net->getMinLayer ()][x][y].cap_ndr -= layer_edge_cost;
693652 }
694653}
695654
0 commit comments