@@ -2151,14 +2151,21 @@ void HierRTLMP::placeMacros(Cluster* cluster)
21512151 : minimum_perturbations_per_step;
21522152
21532153 SequencePair initial_seq_pair;
2154- if (cluster->isArrayOfInterconnectedMacros ()) {
2155- setArrayTilingSequencePair (
2156- cluster, number_of_sequence_pair_macros, initial_seq_pair);
2154+ bool invalid_states_allowed = true ;
2155+ if (cluster->isMacroArray ()) {
2156+ bool array_has_empty_space = false ;
2157+ initial_seq_pair = computeArraySequencePair (cluster, array_has_empty_space);
21572158
2158- pos_swap_prob = 0 .0f ;
2159- neg_swap_prob = 0 .0f ;
2160- double_swap_prob = 0 .0f ;
2161- exchange_swap_prob = 1 .0f ;
2159+ if (array_has_empty_space) {
2160+ invalid_states_allowed = false ;
2161+ } else {
2162+ // We don't need to explore different shapes, so we just swap
2163+ // macros until we find the best wire length.
2164+ pos_swap_prob = 0 .0f ;
2165+ neg_swap_prob = 0 .0f ;
2166+ double_swap_prob = 0 .0f ;
2167+ exchange_swap_prob = 1 .0f ;
2168+ }
21622169
21632170 // Large arrays need more steps to properly converge.
21642171 if (large_macro_cluster) {
@@ -2208,6 +2215,9 @@ void HierRTLMP::placeMacros(Cluster* cluster)
22082215 sa->setFences (fences);
22092216 sa->setGuides (guides);
22102217 sa->setInitialSequencePair (initial_seq_pair);
2218+ if (!invalid_states_allowed) {
2219+ sa->disallowInvalidStates ();
2220+ }
22112221
22122222 sa_batch.push_back (std::move (sa));
22132223
@@ -2292,26 +2302,33 @@ void HierRTLMP::placeMacros(Cluster* cluster)
22922302//
22932303// Obs: Doing this will still keep the IO clusters at the end
22942304// of the sequence pair, which is needed for the way SA handles it.
2295- void HierRTLMP::setArrayTilingSequencePair (Cluster* cluster,
2296- const int macros_to_place,
2297- SequencePair& initial_seq_pair)
2305+ SequencePair HierRTLMP::computeArraySequencePair (Cluster* cluster,
2306+ bool & array_has_empty_space)
22982307{
2299- // Set positive sequence
2300- for (int i = 0 ; i < macros_to_place; ++i) {
2301- initial_seq_pair.pos_sequence .push_back (i);
2308+ SequencePair sequence_pair;
2309+ const std::vector<HardMacro*>& hard_macros = cluster->getHardMacros ();
2310+ const int number_of_macros = static_cast <int >(hard_macros.size ());
2311+
2312+ for (int id = 0 ; id < number_of_macros; ++id) {
2313+ sequence_pair.pos_sequence .push_back (id);
23022314 }
23032315
2304- // Set negative sequence
2305- const int columns
2306- = cluster->getWidth () / cluster->getHardMacros ().front ()->getWidth ();
2307- const int rows
2308- = cluster->getHeight () / cluster->getHardMacros ().front ()->getHeight ();
2316+ const HardMacro* hard_macro = hard_macros.front ();
2317+ const int columns = std::round (cluster->getWidth () / hard_macro->getWidth ());
2318+ const int rows = std::round (cluster->getHeight () / hard_macro->getHeight ());
23092319
23102320 for (int i = 1 ; i <= columns; ++i) {
23112321 for (int j = 1 ; j <= rows; j++) {
2312- initial_seq_pair.neg_sequence .push_back (rows * i - j);
2322+ const int macro_id = (rows * i) - j;
2323+ if (macro_id < number_of_macros) {
2324+ sequence_pair.neg_sequence .push_back (macro_id);
2325+ } else {
2326+ array_has_empty_space = true ;
2327+ }
23132328 }
23142329 }
2330+
2331+ return sequence_pair;
23152332}
23162333
23172334void HierRTLMP::computeFencesAndGuides (
0 commit comments