@@ -1390,13 +1390,10 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
13901390 graphics_->setOutline (micronsToDbu (block_, outline));
13911391 }
13921392
1393- // Suppose the region, fence, guide has been mapped to cooresponding macros
1394- // This step is done when we enter the Hier-RTLMP program
1395- std::map<std::string, int > soft_macro_id_map; // cluster_name, macro_id
1393+ SoftMacroNameToIdMap soft_macro_id_map;
13961394 std::map<int , Rect> fences;
13971395 std::map<int , Rect> guides;
13981396 std::vector<SoftMacro> macros;
1399- std::vector<BundledNet> nets;
14001397
14011398 std::vector<Rect> blockages = findBlockagesWithinOutline (outline);
14021399 eliminateOverlaps (blockages);
@@ -1486,39 +1483,7 @@ void HierRTLMP::placeChildren(Cluster* parent, bool ignore_std_cell_area)
14861483
14871484 clustering_engine_->rebuildConnections ();
14881485
1489- // add the virtual connections (the weight related to IOs and macros belong to
1490- // the same cluster)
1491- for (const auto & [cluster1, cluster2] : parent->getVirtualConnections ()) {
1492- BundledNet net (
1493- soft_macro_id_map[tree_->maps .id_to_cluster [cluster1]->getName ()],
1494- soft_macro_id_map[tree_->maps .id_to_cluster [cluster2]->getName ()],
1495- tree_->virtual_weight );
1496- nets.push_back (net);
1497- }
1498-
1499- // convert the connections between clusters to SoftMacros
1500- for (auto & cluster : parent->getChildren ()) {
1501- const int src_id = cluster->getId ();
1502- const std::string src_name = cluster->getName ();
1503- for (auto & [cluster_id, weight] : cluster->getConnectionsMap ()) {
1504- debugPrint (logger_,
1505- MPL,
1506- " hierarchical_macro_placement" ,
1507- 3 ,
1508- " Cluster connection: {} {} {} " ,
1509- cluster->getName (),
1510- tree_->maps .id_to_cluster [cluster_id]->getName (),
1511- weight);
1512- const std::string name = tree_->maps .id_to_cluster [cluster_id]->getName ();
1513- if (src_id > cluster_id) {
1514- BundledNet net (
1515- soft_macro_id_map[src_name], soft_macro_id_map[name], weight);
1516- nets.push_back (net);
1517- }
1518- }
1519- }
1520-
1521- // merge nets to reduce runtime
1486+ BundledNetList nets = buildBundledNets (parent, soft_macro_id_map);
15221487 mergeNets (nets);
15231488
15241489 std::string file_name_prefix
@@ -2113,9 +2078,7 @@ void HierRTLMP::placeMacros(Cluster* cluster)
21132078 clustering_engine_->rebuildConnections ();
21142079
21152080 createFixedTerminals (outline, macro_clusters, cluster_to_macro, sa_macros);
2116-
2117- std::vector<BundledNet> nets
2118- = computeBundledNets (macro_clusters, cluster_to_macro);
2081+ BundledNetList nets = buildBundledNets (macro_clusters, cluster_to_macro);
21192082
21202083 if (graphics_) {
21212084 graphics_->setBundledNets (nets);
@@ -2375,19 +2338,55 @@ void HierRTLMP::createFixedTerminals(const Rect& outline,
23752338 }
23762339}
23772340
2378- std::vector<BundledNet> HierRTLMP::computeBundledNets (
2379- const UniqueClusterVector& macro_clusters,
2380- const std::map<int , int >& cluster_to_macro)
2341+ BundledNetList HierRTLMP::buildBundledNets (
2342+ Cluster* parent,
2343+ const SoftMacroNameToIdMap& soft_macro_id_map) const
2344+ {
2345+ BundledNetList nets;
2346+ const float virtual_connections_weight = 10 .0f ;
2347+
2348+ for (const auto & [a_id, b_id] : parent->getVirtualConnections ()) {
2349+ Cluster* a = tree_->maps .id_to_cluster .at (a_id);
2350+ Cluster* b = tree_->maps .id_to_cluster .at (b_id);
2351+ const int macro_a_id = soft_macro_id_map.at (a->getName ());
2352+ const int macro_b_id = soft_macro_id_map.at (b->getName ());
2353+
2354+ nets.emplace_back (macro_a_id, macro_b_id, virtual_connections_weight);
2355+ }
2356+
2357+ for (const auto & child : parent->getChildren ()) {
2358+ const int source_macro_id = soft_macro_id_map.at (child->getName ());
2359+ const ConnectionsMap& connections_map = child->getConnectionsMap ();
2360+
2361+ for (const auto & [cluster_id, connection_weight] : connections_map) {
2362+ Cluster* target_cluster = tree_->maps .id_to_cluster .at (cluster_id);
2363+ const int target_macro_id
2364+ = soft_macro_id_map.at (target_cluster->getName ());
2365+
2366+ // As connections are undirected and therefore exist in both directions,
2367+ // this check prevents connections from being taken twice into account.
2368+ if (child->getId () > target_cluster->getId ()) {
2369+ nets.emplace_back (source_macro_id, target_macro_id, connection_weight);
2370+ }
2371+ }
2372+ }
2373+
2374+ return nets;
2375+ }
2376+
2377+ BundledNetList HierRTLMP::buildBundledNets (
2378+ const UniqueClusterVector& clusters,
2379+ const ClusterToMacroMap& cluster_to_macro) const
23812380{
23822381 std::vector<BundledNet> nets;
23832382
2384- for (auto & macro_cluster : macro_clusters) {
2385- const int src_id = macro_cluster->getId ();
2383+ for (const auto & cluster : clusters) {
2384+ const int source_macro_id = cluster_to_macro.at (cluster->getId ());
2385+ const ConnectionsMap& connections_map = cluster->getConnectionsMap ();
23862386
2387- for (auto [cluster_id, weight] : macro_cluster->getConnectionsMap ()) {
2388- BundledNet net (
2389- cluster_to_macro.at (src_id), cluster_to_macro.at (cluster_id), weight);
2390- nets.push_back (net);
2387+ for (const auto & [cluster_id, connection_weight] : connections_map) {
2388+ const int target_macro_id = cluster_to_macro.at (cluster_id);
2389+ nets.emplace_back (source_macro_id, target_macro_id, connection_weight);
23912390 }
23922391 }
23932392
0 commit comments