From 07d8cc6d5c8490e5e0dde066144a93268a6371ee Mon Sep 17 00:00:00 2001 From: Gabriel Gouvine Date: Wed, 6 Dec 2023 11:19:11 +0000 Subject: [PATCH] Add a maximum width for expansion to help small cells in Coriolis --- pycoloquinte/coloquinte.py | 2 +- pycoloquinte/module.cpp | 5 ++++- src/coloquinte.cpp | 17 ++++++++++++++++- src/coloquinte.hpp | 5 ++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pycoloquinte/coloquinte.py b/pycoloquinte/coloquinte.py index 5cdd295..6767118 100644 --- a/pycoloquinte/coloquinte.py +++ b/pycoloquinte/coloquinte.py @@ -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() diff --git a/pycoloquinte/module.cpp b/pycoloquinte/module.cpp index 7a08d36..cfb29d8 100644 --- a/pycoloquinte/module.cpp +++ b/pycoloquinte/module.cpp @@ -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, diff --git a/src/coloquinte.cpp b/src/coloquinte.cpp index 22fa00e..a1ff8c9 100644 --- a/src/coloquinte.cpp +++ b/src/coloquinte.cpp @@ -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) { @@ -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 @@ -645,6 +647,14 @@ 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 maxCellWidth = maxRowWidth * maxExpandedWidth; + double expansionFactor = targetDensity / density; // Apply the expansion @@ -657,6 +667,11 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) { continue; } double fracW = w * expansionFactor; + // Force the expansion to a maximum + if (fracW > (double)maxCellWidth) { + fracW = (double)maxCellWidth; + } + int newW = (int)fracW; // Now, since we round down, we got some area missing missingArea += h * (fracW - newW); diff --git a/src/coloquinte.hpp b/src/coloquinte.hpp index 76742ff..91f4ad2 100644 --- a/src/coloquinte.hpp +++ b/src/coloquinte.hpp @@ -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