2020#include " RDLRouter.h"
2121#include " Utilities.h"
2222#include " boost/icl/interval_set.hpp"
23+ #include " gui/gui.h"
2324#include " odb/db.h"
2425#include " odb/dbTransform.h"
2526#include " odb/dbTypes.h"
@@ -678,7 +679,9 @@ int64_t ICeWall::computePadBumpDistance(odb::dbInst* inst,
678679 return std::numeric_limits<int64_t >::max ();
679680}
680681
681- void ICeWall::placePads (const std::vector<odb::dbInst*>& insts, odb::dbRow* row)
682+ void ICeWall::placePads (const std::vector<odb::dbInst*>& insts,
683+ odb::dbRow* row,
684+ const PlacementStrategy& mode)
682685{
683686 auto * block = getBlock ();
684687 if (block == nullptr ) {
@@ -727,8 +730,18 @@ void ICeWall::placePads(const std::vector<odb::dbInst*>& insts, odb::dbRow* row)
727730 break ;
728731 }
729732
733+ const double dbus = block->getDbUnitsPerMicron ();
734+ debugPrint (logger_,
735+ utl::PAD,
736+ " Place" ,
737+ 1 ,
738+ " {}: Row width ({:.4f} um), total instance ({}) width {:.4f} um)" ,
739+ row->getName (),
740+ row_width / dbus,
741+ inst_widths.size (),
742+ total_width / dbus);
743+
730744 if (total_width > row_width) {
731- const double dbus = block->getDbUnitsPerMicron ();
732745 logger_->error (
733746 utl::PAD,
734747 40 ,
@@ -760,17 +773,34 @@ void ICeWall::placePads(const std::vector<odb::dbInst*>& insts, odb::dbRow* row)
760773 }
761774 }
762775
763- if (!iterm_connections.empty ()) {
764- placePadsBumpAligned (insts,
765- row,
766- inst_widths,
767- total_width,
768- row_width,
769- row_start,
770- iterm_connections);
771- } else {
772- placePadsUniform (
773- insts, row, inst_widths, total_width, row_width, row_start);
776+ PlacementStrategy use_mode = mode;
777+ if (use_mode == PlacementStrategy::DEFAULT) {
778+ if (!iterm_connections.empty ()) {
779+ use_mode = PlacementStrategy::BUMP_ALIGNED;
780+ }
781+ }
782+ if (use_mode == PlacementStrategy::BUMP_ALIGNED
783+ && iterm_connections.empty ()) {
784+ logger_->warn (
785+ utl::PAD, 9 , " Unable to use bump_aligned mode, switching to uniform" );
786+ use_mode = PlacementStrategy::UNIFORM;
787+ }
788+
789+ switch (use_mode) {
790+ case PlacementStrategy::BUMP_ALIGNED:
791+ placePadsBumpAligned (insts,
792+ row,
793+ inst_widths,
794+ total_width,
795+ row_width,
796+ row_start,
797+ iterm_connections);
798+ break ;
799+ case PlacementStrategy::UNIFORM:
800+ case PlacementStrategy::DEFAULT:
801+ placePadsUniform (
802+ insts, row, inst_widths, total_width, row_width, row_start);
803+ break ;
774804 }
775805
776806 logger_->info (
@@ -916,6 +946,9 @@ void ICeWall::placePadsBumpAligned(
916946
917947 int offset = row_start;
918948
949+ const bool gui_debug
950+ = logger_->debugCheck (utl::PAD, " Place" , 1 ) && gui::Gui::enabled ();
951+
919952 int max_travel = row_width - pads_width;
920953 // iterate over pads in order
921954 for (auto itr = insts.begin (); itr != insts.end ();) {
@@ -988,6 +1021,10 @@ void ICeWall::placePadsBumpAligned(
9881021 * row->getSpacing ();
9891022
9901023 performPadFlip (row, ginst, iterm_connections);
1024+
1025+ if (gui_debug) {
1026+ gui::Gui::get ()->pause ();
1027+ }
9911028 }
9921029
9931030 // more iterator to next unplaced pad
@@ -1002,9 +1039,25 @@ void ICeWall::placePadsUniform(const std::vector<odb::dbInst*>& insts,
10021039 int row_width,
10031040 int row_start) const
10041041{
1005- const double dbus = getBlock ()->getDbUnitsPerMicron ();
1006- const int target_spacing = (row_width - pads_width) / (insts.size () + 1 );
1042+ const bool gui_debug
1043+ = logger_->debugCheck (utl::PAD, " Place" , 1 ) && gui::Gui::enabled ();
1044+
1045+ const float initial_target_spacing
1046+ = static_cast <float >(row_width - pads_width) / (insts.size () + 1 );
1047+ const int site_width
1048+ = std::min (row->getSite ()->getWidth (), row->getSite ()->getHeight ());
1049+ const int target_spacing
1050+ = std::floor (initial_target_spacing / site_width) * site_width;
10071051 int offset = row_start + target_spacing;
1052+
1053+ const double dbus = getBlock ()->getDbUnitsPerMicron ();
1054+ debugPrint (logger_,
1055+ utl::PAD,
1056+ " Place" ,
1057+ 1 ,
1058+ " Placing pads with uniform: spacing {:.4f} um" ,
1059+ target_spacing / dbus);
1060+
10081061 for (auto * inst : insts) {
10091062 debugPrint (logger_,
10101063 utl::PAD,
@@ -1022,6 +1075,10 @@ void ICeWall::placePadsUniform(const std::vector<odb::dbInst*>& insts,
10221075 /* allow_shift */ true );
10231076 offset += inst_widths.at (inst);
10241077 offset += target_spacing;
1078+
1079+ if (gui_debug) {
1080+ gui::Gui::get ()->pause ();
1081+ }
10251082 }
10261083}
10271084
0 commit comments