Skip to content

Commit

Permalink
Add a maximum width for expansion to help small cells in Coriolis
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloquinte committed Dec 6, 2023
1 parent a54c3df commit 0afcc09
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pycoloquinte/coloquinte.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def main():
if args.density <= 0.0 or args.density >= 1.0:
raise RuntimeError(
"Target density should be strictly between 0 and 1.")
circuit.expand_cells_to_density(args.density, 0.0)
circuit.expand_cells_to_density(args.density, 0.0, 1.0)
print(circuit.report())

sys.stdout.flush()
Expand Down
5 changes: 4 additions & 1 deletion pycoloquinte/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ Construct a circuit.
"Run the detailed placement algorithm")
.def("expand_cells_to_density", &Circuit::expandCellsToDensity,
py::arg("target_density"), py::arg("row_side_margin") = 0.0,
"Expand the standard cells to reach the target density")
py::arg("max_expanded_size") = 1.0,
"Expand the standard cells to reach the target density, "
"with a margin in each row (in cell heights) and a maximum cell "
"expansion (in row widths)")
.def("expand_cells_by_factor", &Circuit::expandCellsByFactor,
py::arg("expansion_factor"), py::arg("max_density") = 1.0,
py::arg("row_side_margin") = 0.0,
Expand Down
16 changes: 15 additions & 1 deletion src/coloquinte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ long long Circuit::computeRowPlacementArea(double rowSideMargin) const {
return rowArea;
}

void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) {
void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin,
double maxExpandedWidth) {
// Compute placeable cell area
long long cellArea = 0LL;
for (int i = 0; i < nbCells(); ++i) {
Expand All @@ -635,6 +636,7 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) {
}
}

// Compute available area
long long rowArea = computeRowPlacementArea(rowSideMargin);

// Compute the density and return if no further work is needed
Expand All @@ -645,6 +647,13 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) {
if (density >= targetDensity) {
return;
}

// Compute maximum width of the rows
int maxRowWidth = 0;
for (const Row &row : rows_) {
maxRowWidth = std::max(maxRowWidth, row.width());
}

double expansionFactor = targetDensity / density;

// Apply the expansion
Expand All @@ -657,6 +666,11 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) {
continue;
}
double fracW = w * expansionFactor;
// Force the expansion to a maximum
if (fracW > (double)maxRowWidth) {
fracW = (double)maxRowWidth;
}

int newW = (int)fracW;
// Now, since we round down, we got some area missing
missingArea += h * (fracW - newW);
Expand Down
5 changes: 4 additions & 1 deletion src/coloquinte.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,11 @@ class Circuit {
* @param rowSideMargin Margin applied to each row before computing available
* area, in standard cell heights. Usually better than tweaking the density to
* make the placement feasible.
* @param maxExpandedWidth Maximum width of a cell after expansion, in maximum
* row width.
*/
void expandCellsToDensity(double targetDensity, double rowSideMargin = 0.0);
void expandCellsToDensity(double targetDensity, double rowSideMargin = 0.0,
double maxExpandedWidth = 1.0);

/**
* @brief Apply cell size modifications to the circuit, with individual
Expand Down

0 comments on commit 0afcc09

Please sign in to comment.