diff --git a/pycoloquinte/module.cpp b/pycoloquinte/module.cpp index e4529e6..a0acaab 100644 --- a/pycoloquinte/module.cpp +++ b/pycoloquinte/module.cpp @@ -317,7 +317,8 @@ Construct a circuit. .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 the standard cells by an individual factor") + "Expand the standard cells by an individual factor, up to a maximum " + "density") .def("compute_cell_expansion", &Circuit::computeCellExpansion, py::arg("congestion_map"), py::arg("fixed_penalty") = 0.0, py::arg("penalty_factor") = 1.0, @@ -325,7 +326,7 @@ Construct a circuit. .def("check", &Circuit::check, "Check the datastructure") .def("report", &Circuit::report) .def("export_ispd", &Circuit::exportIspd, - "Export the circuit to ISPD benchmark files") + py::arg("filename") "Export the circuit to ISPD benchmark files") .def("__str__", &Circuit::toString) .def("__repr__", &Circuit::toString); } diff --git a/src/coloquinte.cpp b/src/coloquinte.cpp index 8e5302c..22fa00e 100644 --- a/src/coloquinte.cpp +++ b/src/coloquinte.cpp @@ -669,8 +669,8 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) { } } -void Circuit::expandCellsByFactor(const std::vector &expansionFactor, - double maxDensity, double rowSideMargin) { +double Circuit::expandCellsByFactor(const std::vector &expansionFactor, + double maxDensity, double rowSideMargin) { // Setup the target expansion if not done explicitly if ((int)expansionFactor.size() != nbCells()) { throw std::runtime_error( @@ -697,14 +697,14 @@ void Circuit::expandCellsByFactor(const std::vector &expansionFactor, // Compute the density and return if no further work is needed if (cellArea == 0LL || rowArea == 0LL) { - return; + return 1.0; } std::vector expansion = expansionFactor; double density = (double)cellArea / (double)rowArea; if (density >= maxDensity) { // No point in applying any expansion - return; + return 1.0; } double expandedDensity = (double)expandedArea / (double)rowArea; @@ -724,6 +724,8 @@ void Circuit::expandCellsByFactor(const std::vector &expansionFactor, cellWidth_[i] *= expansion[i]; } } + + return expandedDensity / density; } std::vector Circuit::computeCellExpansion( diff --git a/src/coloquinte.hpp b/src/coloquinte.hpp index 1eb9305..76742ff 100644 --- a/src/coloquinte.hpp +++ b/src/coloquinte.hpp @@ -1014,9 +1014,12 @@ class Circuit { * will be adjusted to not go over this. * @param rowSideMargin Margin applied to each row before computing available * area, in standard cell heights. + * + * @return Average expansion */ - void expandCellsByFactor(const std::vector &expansionFactor, - double maxDensity = 1.0, double rowSideMargin = 0.0); + double expandCellsByFactor(const std::vector &expansionFactor, + double maxDensity = 1.0, + double rowSideMargin = 0.0); /* * TODO: find a way that the expansion could happen on both sides (cleaner),