Skip to content

Commit

Permalink
Return average expansion for easier reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloquinte committed Nov 6, 2023
1 parent 4a869b6 commit b57a321
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions pycoloquinte/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ 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,
"Compute an expansion factor given a congestion map")
.def("check", &Circuit::check, "Check the datastructure")
.def("report", &Circuit::report)
.def("export_ispd", &Circuit::exportIspd,
.def("export_ispd", &Circuit::exportIspd, py::arg("filename"),
"Export the circuit to ISPD benchmark files")
.def("__str__", &Circuit::toString)
.def("__repr__", &Circuit::toString);
Expand Down
10 changes: 6 additions & 4 deletions src/coloquinte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ void Circuit::expandCellsToDensity(double targetDensity, double rowSideMargin) {
}
}

void Circuit::expandCellsByFactor(const std::vector<float> &expansionFactor,
double maxDensity, double rowSideMargin) {
double Circuit::expandCellsByFactor(const std::vector<float> &expansionFactor,
double maxDensity, double rowSideMargin) {
// Setup the target expansion if not done explicitly
if ((int)expansionFactor.size() != nbCells()) {
throw std::runtime_error(
Expand All @@ -697,14 +697,14 @@ void Circuit::expandCellsByFactor(const std::vector<float> &expansionFactor,

// Compute the density and return if no further work is needed
if (cellArea == 0LL || rowArea == 0LL) {
return;
return 1.0;
}

std::vector<float> 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;
Expand All @@ -724,6 +724,8 @@ void Circuit::expandCellsByFactor(const std::vector<float> &expansionFactor,
cellWidth_[i] *= expansion[i];
}
}

return expandedDensity / density;
}

std::vector<float> Circuit::computeCellExpansion(
Expand Down
7 changes: 5 additions & 2 deletions src/coloquinte.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> &expansionFactor,
double maxDensity = 1.0, double rowSideMargin = 0.0);
double expandCellsByFactor(const std::vector<float> &expansionFactor,
double maxDensity = 1.0,
double rowSideMargin = 0.0);

/*
* TODO: find a way that the expansion could happen on both sides (cleaner),
Expand Down

0 comments on commit b57a321

Please sign in to comment.