@@ -20,40 +20,42 @@ CUGR::CUGR(odb::dbDatabase* db,
2020{
2121}
2222
23+ CUGR::~CUGR () = default ;
24+
2325void CUGR::init (const int min_routing_layer, const int max_routing_layer)
2426{
25- design_ = new Design (
27+ design_ = std::make_unique< Design> (
2628 db_, logger_, constants_, min_routing_layer, max_routing_layer);
27- grid_graph_ = new GridGraph (design_, constants_);
29+ grid_graph_ = std::make_unique< GridGraph> (design_. get () , constants_);
2830 // Instantiate the global routing netlist
2931 const std::vector<CUGRNet>& baseNets = design_->getAllNets ();
3032 gr_nets_.reserve (baseNets.size ());
3133 for (const CUGRNet& baseNet : baseNets) {
32- gr_nets_.push_back (new GRNet (baseNet, design_, grid_graph_));
34+ gr_nets_.push_back (std::make_unique< GRNet> (baseNet, grid_graph_. get () ));
3335 }
3436}
3537
3638void CUGR::route ()
3739{
3840 std::vector<int > netIndices;
3941 netIndices.reserve (gr_nets_.size ());
40- for (GRNet* net : gr_nets_) {
42+ for (const auto & net : gr_nets_) {
4143 netIndices.push_back (net->getIndex ());
4244 }
4345 // Stage 1: Pattern routing
4446 logger_->report (" stage 1: pattern routing" );
4547 sortNetIndices (netIndices);
4648 for (const int netIndex : netIndices) {
4749 PatternRoute patternRoute (
48- gr_nets_[netIndex], grid_graph_, stt_builder_, constants_);
50+ gr_nets_[netIndex]. get () , grid_graph_. get () , stt_builder_, constants_);
4951 patternRoute.constructSteinerTree ();
5052 patternRoute.constructRoutingDAG ();
5153 patternRoute.run ();
5254 grid_graph_->commitTree (gr_nets_[netIndex]->getRoutingTree ());
5355 }
5456
5557 netIndices.clear ();
56- for (GRNet* net : gr_nets_) {
58+ for (const auto & net : gr_nets_) {
5759 if (grid_graph_->checkOverflow (net->getRoutingTree ()) > 0 ) {
5860 netIndices.push_back (net->getIndex ());
5961 }
@@ -73,9 +75,10 @@ void CUGR::route()
7375 // }
7476 sortNetIndices (netIndices);
7577 for (const int netIndex : netIndices) {
76- GRNet* net = gr_nets_[netIndex];
78+ GRNet* net = gr_nets_[netIndex]. get () ;
7779 grid_graph_->commitTree (net->getRoutingTree (), true );
78- PatternRoute patternRoute (net, grid_graph_, stt_builder_, constants_);
80+ PatternRoute patternRoute (
81+ net, grid_graph_.get (), stt_builder_, constants_);
7982 patternRoute.constructSteinerTree ();
8083 patternRoute.constructRoutingDAG ();
8184 patternRoute.constructDetours (
@@ -85,7 +88,7 @@ void CUGR::route()
8588 }
8689
8790 netIndices.clear ();
88- for (GRNet* net : gr_nets_) {
91+ for (const auto & net : gr_nets_) {
8992 if (grid_graph_->checkOverflow (net->getRoutingTree ()) > 0 ) {
9093 netIndices.push_back (net->getIndex ());
9194 }
@@ -98,24 +101,24 @@ void CUGR::route()
98101 if (!netIndices.empty ()) {
99102 std::cout << " stage 3: maze routing on sparsified routing graph\n " ;
100103 for (const int netIndex : netIndices) {
101- GRNet* net = gr_nets_[netIndex];
102- grid_graph_->commitTree (net->getRoutingTree (), true );
104+ grid_graph_->commitTree (gr_nets_[netIndex]->getRoutingTree (), true );
103105 }
104106 GridGraphView<CostT> wireCostView;
105107 grid_graph_->extractWireCostView (wireCostView);
106108 sortNetIndices (netIndices);
107109 SparseGrid grid (10 , 10 , 0 , 0 );
108110 for (const int netIndex : netIndices) {
109- GRNet* net = gr_nets_[netIndex];
111+ GRNet* net = gr_nets_[netIndex]. get () ;
110112 // grid_graph_->commitTree(net->getRoutingTree(), true);
111113 // grid_graph_->updateWireCostView(wireCostView, net->getRoutingTree());
112- MazeRoute mazeRoute (net, grid_graph_);
114+ MazeRoute mazeRoute (net, grid_graph_. get () );
113115 mazeRoute.constructSparsifiedGraph (wireCostView, grid);
114116 mazeRoute.run ();
115117 std::shared_ptr<SteinerTreeNode> tree = mazeRoute.getSteinerTree ();
116118 assert (tree != nullptr );
117119
118- PatternRoute patternRoute (net, grid_graph_, stt_builder_, constants_);
120+ PatternRoute patternRoute (
121+ net, grid_graph_.get (), stt_builder_, constants_);
119122 patternRoute.setSteinerTree (tree);
120123 patternRoute.constructRoutingDAG ();
121124 patternRoute.run ();
@@ -125,7 +128,7 @@ void CUGR::route()
125128 grid.step ();
126129 }
127130 netIndices.clear ();
128- for (GRNet* net : gr_nets_) {
131+ for (const auto & net : gr_nets_) {
129132 if (grid_graph_->checkOverflow (net->getRoutingTree ()) > 0 ) {
130133 netIndices.push_back (net->getIndex ());
131134 }
@@ -145,9 +148,9 @@ void CUGR::write(const std::string& guide_file)
145148 area_of_pin_patches_ = 0 ;
146149 area_of_wire_patches_ = 0 ;
147150 std::stringstream ss;
148- for (const GRNet* net : gr_nets_) {
151+ for (const auto & net : gr_nets_) {
149152 std::vector<std::pair<int , BoxT>> guides;
150- getGuides (net, guides);
153+ getGuides (net. get () , guides);
151154
152155 ss << net->getName () << std::endl;
153156 ss << " (" << std::endl;
@@ -171,7 +174,7 @@ void CUGR::write(const std::string& guide_file)
171174NetRouteMap CUGR::getRoutes ()
172175{
173176 NetRouteMap routes;
174- for (const GRNet* net : gr_nets_) {
177+ for (const auto & net : gr_nets_) {
175178 if (net->getNumPins () < 2 ) {
176179 continue ;
177180 }
@@ -366,7 +369,7 @@ void CUGR::printStatistics() const
366369 std::vector<std::vector<int >>(
367370 grid_graph_->getSize (0 ),
368371 std::vector<int >(grid_graph_->getSize (1 ), 0 )));
369- for (GRNet* net : gr_nets_) {
372+ for (const auto & net : gr_nets_) {
370373 GRTreeNode::preorder (
371374 net->getRoutingTree (), [&](const std::shared_ptr<GRTreeNode>& node) {
372375 for (const auto & child : node->children ) {
0 commit comments