Skip to content

Commit 78ccfcf

Browse files
committed
mpl: split isSegmentEmpty in two functions
Signed-off-by: João Mai <jmai@precisioninno.com>
1 parent c0bc1a3 commit 78ccfcf

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎src/mpl/src/SACoreSoftMacro.cpp‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -716,24 +716,29 @@ SACoreSoftMacro::NotchVicinity SACoreSoftMacro::checkNotchVicinity(
716716
return vicnity;
717717
}
718718

719-
bool SACoreSoftMacro::isSegmentEmpty(const std::vector<std::vector<bool>>& grid,
720-
const int start_row,
721-
const int start_col,
722-
const int end_row,
723-
const int end_col)
719+
bool SACoreSoftMacro::isRowEmpty(const std::vector<std::vector<bool>>& grid,
720+
const int row,
721+
const int start_col,
722+
const int end_col)
724723
{
725-
for (int i = start_row; i <= end_row; i++) {
726-
if (grid[i][end_col]) {
724+
for (int col = start_col; col <= end_col; col++) {
725+
if (grid[row][col]) {
727726
return false;
728727
}
729728
}
729+
return true;
730+
}
730731

731-
for (int j = start_col; j <= end_col; j++) {
732-
if (grid[end_row][j]) {
732+
bool SACoreSoftMacro::isColEmpty(const std::vector<std::vector<bool>>& grid,
733+
const int col,
734+
const int start_row,
735+
const int end_row)
736+
{
737+
for (int row = start_row; row <= end_row; row++) {
738+
if (grid[row][col]) {
733739
return false;
734740
}
735741
}
736-
737742
return true;
738743
}
739744

@@ -821,7 +826,7 @@ void SACoreSoftMacro::calNotchPenalty()
821826
if (expand_rows) {
822827
end_row += 1;
823828
if (end_row < num_y
824-
&& isSegmentEmpty(grid, start_row, start_col, end_row, end_col)) {
829+
&& isRowEmpty(grid, end_row, start_col, end_col)) {
825830
NotchVicinity expanded_vicinity = checkNotchVicinity(
826831
grid, start_row, start_col, end_row, end_col);
827832
if (expanded_vicinity.total() > current_vicinity.total()
@@ -840,7 +845,7 @@ void SACoreSoftMacro::calNotchPenalty()
840845
if (expand_cols) {
841846
end_col += 1;
842847
if (end_col < num_x
843-
&& isSegmentEmpty(grid, start_row, start_col, end_row, end_col)) {
848+
&& isColEmpty(grid, end_col, start_row, end_row)) {
844849
NotchVicinity expanded_vicinity = checkNotchVicinity(
845850
grid, start_row, start_col, end_row, end_col);
846851
if (expanded_vicinity.total() > current_vicinity.total()

‎src/mpl/src/SACoreSoftMacro.h‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ class SACoreSoftMacro : public SimulatedAnnealingCore<SoftMacro>
106106
int start_col,
107107
int end_row,
108108
int end_col);
109-
static bool isSegmentEmpty(const std::vector<std::vector<bool>>& grid,
110-
int start_row,
111-
int tart_col,
112-
int end_row,
113-
int end_col);
109+
static bool isRowEmpty(const std::vector<std::vector<bool>>& grid,
110+
int row,
111+
int start_col,
112+
int end_col);
113+
static bool isColEmpty(const std::vector<std::vector<bool>>& grid,
114+
int col,
115+
int start_row,
116+
int end_row);
114117
float calSingleNotchPenalty(int width, int height);
115118
void calNotchPenalty();
116119
void calMacroBlockagePenalty();

0 commit comments

Comments
 (0)