Skip to content

Commit

Permalink
Compute expansion factor given a congestion map
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloquinte committed Nov 3, 2023
1 parent 655ba6f commit b3f4078
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/coloquinte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,36 @@ void Circuit::expandCellsByFactor(const std::vector<float> &expansionFactor,
}
}

std::vector<float> Circuit::computeCellExpansion(
const std::vector<std::pair<Rectangle, float> > &congestionMap) const {
std::vector<std::pair<Rectangle, float> > expansionMap;
for (auto [r, c] : congestionMap) {
if (c > 0.0f) {
expansionMap.emplace_back(r, c + 1.0f);
}
}
//std::sort(expansionMap.begin(), expansionMap.end());

// Now analyze the expansion for each cell; use the maximum of the expansion
// maps it intersects
std::vector<float> expansions;
for (int i = 0; i < nbCells(); ++i) {
if (isFixed(i)) {
expansions.push_back(1.0f);
} else {
Rectangle place = placement(i);
float expansion = 1.0;
for (auto [r, e] : expansionMap) {
if (r.intersects(place)) {
expansion = std::max(expansion, e);
}
}
expansions.push_back(expansion);
}
}
return expansions;
}

float Circuit::meanDisruption(const PlacementSolution &a,
const PlacementSolution &b,
LegalizationModel costModel) {
Expand Down
10 changes: 10 additions & 0 deletions src/coloquinte.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,16 @@ class Circuit {
* coordinates from the original circuit.
*/

/**
* @brief Compute the cell expansion required for a given congestion map
*
* @param congestionMap Region and associated congestion, as a proportion of
* the available routing resources (0.0 -> not congested; 0.5 -> 50% over
* routing capacity).
*/
std::vector<float> computeCellExpansion(
const std::vector<std::pair<Rectangle, float> > &congestionMap) const;

/**
* @brief Return a brief description of the circuit
*/
Expand Down
12 changes: 12 additions & 0 deletions test/test_expansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ BOOST_AUTO_TEST_CASE(TestFactorExpansionMultiple) {
BOOST_CHECK_EQUAL(circuit.cellWidth()[0], 30);
BOOST_CHECK_EQUAL(circuit.cellWidth()[1], 16);
}

BOOST_AUTO_TEST_CASE(TestExpansionComputation) {
Circuit circuit(1);
circuit.setCellWidth({20});
circuit.setCellHeight({10});
circuit.setCellX({40});
circuit.setCellY({-100});
std::vector<std::pair<Rectangle, float> > congestionMap;
std::vector<float> expansion = circuit.computeCellExpansion(congestionMap);
BOOST_CHECK_EQUAL(expansion.size(), circuit.nbCells());
BOOST_CHECK_EQUAL(expansion[0], 1.0f);
}

0 comments on commit b3f4078

Please sign in to comment.