@@ -201,17 +201,6 @@ void Graph2D::addCapV(const int x, const int y, const int cap)
201201 v_edges_[x][y].cap += cap;
202202}
203203
204- // Adds estimated usage to a horizontal edge segment.
205- void Graph2D::addEstUsageH (const Interval& xi, const int y, const double usage)
206- {
207- for (int x = xi.lo ; x < xi.hi ; x++) {
208- h_edges_[x][y].est_usage += usage;
209- if (usage > 0 ) {
210- h_used_ggrid_.insert ({x, y});
211- }
212- }
213- }
214-
215204// Updates estimated usage for a horizontal edge segment, considering NDRs.
216205void Graph2D::updateEstUsageH (const Interval& xi,
217206 const int y,
@@ -237,32 +226,12 @@ void Graph2D::updateEstUsageH(const int x,
237226 }
238227}
239228
240- // Adds estimated usage to a horizontal edge.
241- void Graph2D::addEstUsageH (const int x, const int y, const double usage)
242- {
243- h_edges_[x][y].est_usage += usage;
244- if (usage > 0 ) {
245- h_used_ggrid_.insert ({x, y});
246- }
247- }
248-
249229// Adds the estimated usage to the actual usage for all edges.
250230void Graph2D::addEstUsageToUsage ()
251231{
252232 foreachEdge ([](Edge& edge) { edge.usage += edge.est_usage ; });
253233}
254234
255- // Adds estimated usage to a vertical edge segment.
256- void Graph2D::addEstUsageV (const int x, const Interval& yi, const double usage)
257- {
258- for (int y = yi.lo ; y < yi.hi ; y++) {
259- v_edges_[x][y].est_usage += usage;
260- if (usage > 0 ) {
261- v_used_ggrid_.insert ({x, y});
262- }
263- }
264- }
265-
266235// Updates estimated usage for a vertical edge segment, considering NDRs.
267236void Graph2D::updateEstUsageV (const int x,
268237 const Interval& yi,
@@ -288,15 +257,6 @@ void Graph2D::updateEstUsageV(const int x,
288257 }
289258}
290259
291- // Adds estimated usage to a vertical edge.
292- void Graph2D::addEstUsageV (const int x, const int y, const double usage)
293- {
294- v_edges_[x][y].est_usage += usage;
295- if (usage > 0 ) {
296- v_used_ggrid_.insert ({x, y});
297- }
298- }
299-
300260// Adds reduction to a horizontal edge.
301261void Graph2D::addRedH (const int x, const int y, const int red)
302262{
@@ -315,30 +275,33 @@ void Graph2D::addRedV(const int x, const int y, const int red)
315275void Graph2D::addUsageH (const Interval& xi, const int y, const int used)
316276{
317277 for (int x = xi.lo ; x < xi.hi ; x++) {
318- h_edges_[x][y].usage += used;
319- if (used > 0 ) {
320- h_used_ggrid_.insert ({x, y});
321- }
278+ addUsageH (x, y, used);
279+ }
280+ }
281+
282+ // Adds usage to a horizontal edge.
283+ void Graph2D::addUsageH (const int x, const int y, const int used)
284+ {
285+ h_edges_[x][y].usage += used;
286+ if (used > 0 ) {
287+ h_used_ggrid_.insert ({x, y});
322288 }
323289}
324290
325291// Adds usage to a vertical edge segment.
326292void Graph2D::addUsageV (const int x, const Interval& yi, const int used)
327293{
328294 for (int y = yi.lo ; y < yi.hi ; y++) {
329- v_edges_[x][y].usage += used;
330- if (used > 0 ) {
331- v_used_ggrid_.insert ({x, y});
332- }
295+ addUsageV (x, y, used);
333296 }
334297}
335298
336- // Adds usage to a horizontal edge.
337- void Graph2D::addUsageH (const int x, const int y, const int used)
299+ // Adds usage to a vertical edge.
300+ void Graph2D::addUsageV (const int x, const int y, const int used)
338301{
339- h_edges_ [x][y].usage += used;
302+ v_edges_ [x][y].usage += used;
340303 if (used > 0 ) {
341- h_used_ggrid_ .insert ({x, y});
304+ v_used_ggrid_ .insert ({x, y});
342305 }
343306}
344307
@@ -361,13 +324,15 @@ void Graph2D::printAllElements()
361324 return ;
362325 }
363326
364- logger_->report (" Congestion nets ({}):" , congestion_nets_.size ());
327+ logger_->reportLiteral (
328+ fmt::format (" Congestion nets ({}): " , congestion_nets_.size ()));
365329 for (auto it = congestion_nets_.begin (); it != congestion_nets_.end (); ++it) {
366330 if (it != congestion_nets_.begin ()) {
367331 logger_->reportLiteral (" , " );
368332 }
369333 logger_->reportLiteral (fmt::format (" \" {}\" " , *it));
370334 }
335+ logger_->reportLiteral (" \n " );
371336}
372337
373338// Updates usage for a horizontal edge, considering NDRs.
@@ -395,15 +360,6 @@ void Graph2D::updateUsageH(const Interval& xi,
395360 }
396361}
397362
398- // Adds usage to a vertical edge.
399- void Graph2D::addUsageV (const int x, const int y, const int used)
400- {
401- v_edges_[x][y].usage += used;
402- if (used > 0 ) {
403- v_used_ggrid_.insert ({x, y});
404- }
405- }
406-
407363// Updates usage for a vertical edge, considering NDRs.
408364void Graph2D::updateUsageV (const int x,
409365 const int y,
@@ -562,13 +518,13 @@ bool Graph2D::hasNDRCapacity(FrNet* net, int x, int y, EdgeDirection direction)
562518 // capacity
563519 for (int l = net->getMinLayer (); l <= net->getMaxLayer (); l++) {
564520 double layer_cap = 0 ;
565- if (direction == EdgeDirection::Horizontal) {
566- layer_cap = h_cap_3D_[l][x][y]. cap_ndr ;
567- } else {
568- layer_cap = v_cap_3D_ [l][x][y].cap_ndr ;
569- }
521+ int8_t layer_edge_cost = net-> getLayerEdgeCost (l);
522+
523+ layer_cap = (direction == EdgeDirection::Horizontal)
524+ ? h_cap_3D_ [l][x][y].cap_ndr
525+ : v_cap_3D_[l][x][y]. cap_ndr ;
570526
571- if (layer_cap >= edgeCost ) {
527+ if (layer_cap >= layer_edge_cost ) {
572528 return true ;
573529 }
574530 }
@@ -670,20 +626,22 @@ void Graph2D::updateNDRCapLayer(const int x,
670626 }
671627
672628 auto & cap_3D = (dir == EdgeDirection::Horizontal) ? h_cap_3D_ : v_cap_3D_;
629+ int8_t layer_edge_cost = 0 ;
673630
674631 for (int l = net->getMinLayer (); l <= net->getMaxLayer (); l++) {
675632 auto & layer_cap = cap_3D[l][x][y];
633+ layer_edge_cost = net->getLayerEdgeCost (l);
676634 if (edge_cost < 0 ) { // Reducing edge usage
677635 // If we already have a NDR net in this layer, increase the NDR capacity
678636 // available again
679- if (layer_cap.cap - layer_cap.cap_ndr >= edgeCost ) {
680- layer_cap.cap_ndr += edgeCost ;
637+ if (layer_cap.cap - layer_cap.cap_ndr >= layer_edge_cost ) {
638+ layer_cap.cap_ndr += layer_edge_cost ;
681639 return ;
682640 }
683641 } else { // Increasing edge usage
684642 // If there is NDR capacity available, reduce the capacity value
685- if (layer_cap.cap_ndr >= edgeCost ) {
686- layer_cap.cap_ndr -= edgeCost ;
643+ if (layer_cap.cap_ndr >= layer_edge_cost ) {
644+ layer_cap.cap_ndr -= layer_edge_cost ;
687645 return ;
688646 }
689647 }
@@ -693,7 +651,8 @@ void Graph2D::updateNDRCapLayer(const int x,
693651 // in any layer, reduce the capacity available of the first layer.
694652 // When rippin-up, it will be the first to be released
695653 if (edge_cost > 0 ) {
696- cap_3D[net->getMinLayer ()][x][y].cap_ndr -= edgeCost;
654+ layer_edge_cost = net->getLayerEdgeCost (net->getMinLayer ());
655+ cap_3D[net->getMinLayer ()][x][y].cap_ndr -= layer_edge_cost;
697656 }
698657}
699658
0 commit comments