Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/cts/include/cts/TritonCTS.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@ class TritonCTS
void incrementNumClocks() { ++numberOfClocks_; }
void clearNumClocks() { numberOfClocks_ = 0; }
unsigned getNumClocks() const { return numberOfClocks_; }
void cloneClockGaters(odb::dbNet* clkNet);
void cloneClockGaters(odb::dbNet* clkNet,
std::set<odb::Point>& occupiedPositions);
void findLongEdges(
stt::Tree& clkSteiner,
odb::Point driverPt,
std::map<odb::Point, std::vector<odb::dbITerm*>>& point2pin);
std::map<odb::Point, std::vector<odb::dbITerm*>>& point2pin,
std::set<odb::Point>& occupiedPositions);
void resolveLocationCollision(odb::dbInst* clone,
odb::Point location,
std::set<odb::Point>& occupiedPositions);
void initOneClockTree(odb::dbNet* driverNet,
odb::dbNet* clkInputNet,
const std::string& sdcClockName,
Expand Down
49 changes: 40 additions & 9 deletions src/cts/src/TritonCTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ std::string TritonCTS::selectBestMaxCapBuffer(

// db functions

void TritonCTS::cloneClockGaters(odb::dbNet* clkNet)
void TritonCTS::cloneClockGaters(odb::dbNet* clkNet,
std::set<odb::Point>& occupiedPositions)
{
odb::dbITerm* driver = clkNet->getFirstOutput();
std::vector<int> xs;
Expand Down Expand Up @@ -888,7 +889,7 @@ void TritonCTS::cloneClockGaters(odb::dbNet* clkNet)
if (libertyCell->isInverter() || libertyCell->isBuffer()) {
continue;
}
cloneClockGaters(outputNet);
cloneClockGaters(outputNet, occupiedPositions);
}
}
if (!driver) {
Expand All @@ -906,13 +907,14 @@ void TritonCTS::cloneClockGaters(odb::dbNet* clkNet)
point2pin[{drvrX, drvrY}].push_back(driver);
stt::Tree ftree
= options_->getSttBuilder()->makeSteinerTree(clkNet, xs, ys, 0);
findLongEdges(ftree, {drvrX, drvrY}, point2pin);
findLongEdges(ftree, {drvrX, drvrY}, point2pin, occupiedPositions);
}

void TritonCTS::findLongEdges(
stt::Tree& clkSteiner,
odb::Point driverPt,
std::map<odb::Point, std::vector<odb::dbITerm*>>& point2pin)
std::map<odb::Point, std::vector<odb::dbITerm*>>& point2pin,
std::set<odb::Point>& occupiedPositions)
{
const int threshold = options_->getMaxWl();
debugPrint(
Expand Down Expand Up @@ -1031,7 +1033,7 @@ void TritonCTS::findLongEdges(
validClusters);

// Insert original ICG to its closest cluster, create clones to drive the
// other clusters
// other clusters.
int nClones = 0;
// hierarchy fix, make the clone net in the right scope
sta::Pin* driver = nullptr;
Expand Down Expand Up @@ -1162,14 +1164,33 @@ void TritonCTS::findLongEdges(
}
}

// Move ICG (clone or original) to the center of its sinks
clone->setLocation(sinksBbox.xCenter(), sinksBbox.yCenter());
clone->setPlacementStatus(odb::dbPlacementStatus::PLACED);
// Resolve location collision and finalize placement.
resolveLocationCollision(
clone, {sinksBbox.xCenter(), sinksBbox.yCenter()}, occupiedPositions);
}
debugPrint(
logger_, CTS, "clock gate cloning", 1, "Created {} clones", nClones);
}

void TritonCTS::resolveLocationCollision(
odb::dbInst* clone,
odb::Point location,
std::set<odb::Point>& occupiedPositions)
{
// Ensure position is unique among both other clones and pre-existing
// instances to prevent mapLocationToSink_ key collision.
odb::Point cloneLoc = location;
// Shift by 1 DBU to guarantee unique coordinates on collision case.
// Site-legal placement is handled by downstream DPL.
int shift = 1;
while (occupiedPositions.contains(cloneLoc)) {
cloneLoc.setX(cloneLoc.getX() + shift);
}
occupiedPositions.insert(cloneLoc);
clone->setLocation(cloneLoc.getX(), cloneLoc.getY());
clone->setPlacementStatus(odb::dbPlacementStatus::PLACED);
}

void TritonCTS::populateTritonCTS()
{
clearNumClocks();
Expand Down Expand Up @@ -1207,13 +1228,23 @@ void TritonCTS::populateTritonCTS()
allClkNets.insert(clkNets.begin(), clkNets.end());
}
}
// Seed with all existing instance positions to prevent clones from
// landing on a pre-existing cell and causing mapLocationToSink_
// key collision in HTreeBuilder.
std::set<odb::Point> occupiedPositions;
for (odb::dbInst* inst : block_->getInsts()) {
int x, y;
inst->getLocation(x, y);
occupiedPositions.emplace(x, y);
}

// Iterate over all the nets found by the user-input and dbSta
for (const auto& clockInfo : clockNetsInfo) {
std::set<odb::dbNet*> clockNets = clockInfo.first;
std::string clkName = clockInfo.second;
for (odb::dbNet* net : clockNets) {
if (net != nullptr) {
cloneClockGaters(net);
cloneClockGaters(net, occupiedPositions);
if (clkName.empty()) {
logger_->info(CTS, 95, "Net \"{}\" found.", net->getName());
} else {
Expand Down
1 change: 1 addition & 0 deletions src/cts/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ COMPULSORY_TESTS = [
"check_max_fanout3",
"check_wire_rc_cts",
"clock_buffer_footprint",
"colocated_sinks",
"dummy_load",
"find_clock",
# cmake gives 17.47 um ave sink WL vs. bazel 11.54 um
Expand Down
1 change: 1 addition & 0 deletions src/cts/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ or_integration_tests(
array_repair_clock_nets
check_buffers
check_buffers_blockages
colocated_sinks
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to BUILD

check_buffers_blockages_merge
check_buffer_inference1
check_buffer_inference2
Expand Down
Loading
Loading