Skip to content

Cts add user clock buffer prefix for list inferring #7231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions src/cts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Perform clock tree synthesis.
clock_tree_synthesis
[-wire_unit wire_unit]
[-buf_list <list_of_buffers>]
[-buf_list_prefix prefix]\
[-root_buf root_buf]
[-clk_nets <list_of_clk_nets>]
[-tree_buf <buf>]
Expand Down Expand Up @@ -71,6 +72,7 @@ clock_tree_synthesis
| Switch Name | Description |
| ----- | ----- |
| `-buf_list` | Tcl list of master cells (buffers) that will be considered when making the wire segments (e.g. `{BUFXX, BUFYY}`). |
| `-buf_list_prefix` | Prefix that will be used to infer the clock buffer list (e.g. `CLKBUF`). If no buffers are found using this prefix it will proceed with the normal buffer list inferring. Should not be used with `-buf_list` |
| `-root_buffer` | The master cell of the buffer that serves as root for the clock tree. If this parameter is omitted, the first master cell from `-buf_list` is taken. |
| `-wire_unit` | Minimum unit distance between buffers for a specific wire. If this parameter is omitted, the code gets the value from ten times the height of `-root_buffer`. |
| `-distance_between_buffers` | Distance (in microns) between buffers that `cts` should use when creating the tree. When using this parameter, the clock tree algorithm is simplified and only uses a fraction of the segments from the LUT. |
Expand Down
3 changes: 3 additions & 0 deletions src/cts/src/CtsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class CtsOptions : public odb::dbBlockCallBackObj
std::string getClockNets() const { return clockNets_; }
void setRootBuffer(const std::string& buffer) { rootBuffer_ = buffer; }
std::string getRootBuffer() const { return rootBuffer_; }
void setBufferListPrefix(const std::string& prefix) { bufferListPrefix_ = prefix; }
std::string getBufferListPrefix() const { return bufferListPrefix_; }
void setBufferList(const std::vector<std::string>& buffers)
{
bufferList_ = buffers;
Expand Down Expand Up @@ -249,6 +251,7 @@ class CtsOptions : public odb::dbBlockCallBackObj
std::string sinkBuffer_ = "";
std::string treeBuffer_ = "";
std::string metricFile_ = "";
std::string bufferListPrefix_ = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: redundant string initialization [readability-redundant-string-init]

Suggested change
std::string bufferListPrefix_ = "";
std::string bufferListPrefix_;

int dbUnits_ = -1;
unsigned wireSegmentUnit_ = 0;
bool plotSolution_ = false;
Expand Down
27 changes: 25 additions & 2 deletions src/cts/src/TritonCTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,30 @@ void TritonCTS::inferBufferList(std::vector<std::string>& buffers)
}
delete lib_iter;

// second, look for all buffers with name CLKBUF or clkbuf
// second, look for buffers with name especified by the user
if (options_->getBufferListPrefix() != "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]

Suggested change
if (options_->getBufferListPrefix() != "") {
if (!options_->getBufferListPrefix().empty()) {
Additional context

/usr/include/c++/11/bits/basic_string.h:1022: method 'basic_string'::empty() defined here

      empty() const _GLIBCXX_NOEXCEPT
      ^

sta::PatternMatch patternClkBuf(options_->getBufferListPrefix().c_str(),
/* is_regexp */ true,
/* nocase */ true,
/* Tcl_interp* */ nullptr);
sta::LibertyLibraryIterator* lib_iter = network_->libertyLibraryIterator();
while (lib_iter->hasNext()) {
sta::LibertyLibrary* lib = lib_iter->next();
if (options_->isCtsLibrarySet()
&& strcmp(lib->name(), options_->getCtsLibrary()) != 0) {
continue;
}
for (sta::LibertyCell* buffer :
lib->findLibertyCellsMatching(&patternClkBuf)) {
if (buffer->isBuffer() && isClockCellCandidate(buffer)) {
selected_buffers.emplace_back(buffer);
}
}
}
delete lib_iter;
}

// third, look for all buffers with name CLKBUF or clkbuf
if (selected_buffers.empty()) {
sta::PatternMatch patternClkBuf(".*CLKBUF.*",
/* is_regexp */ true,
Expand All @@ -690,7 +713,7 @@ void TritonCTS::inferBufferList(std::vector<std::string>& buffers)
delete lib_iter;
}

// third, look for all buffers with name BUF or buf
// fourth, look for all buffers with name BUF or buf
if (selected_buffers.empty()) {
sta::PatternMatch patternBuf(".*BUF.*",
/* is_regexp */ true,
Expand Down
7 changes: 7 additions & 0 deletions src/cts/src/TritonCTS.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

%{
#include <cstdint>
#include <iostream>

#include "cts/TritonCTS.h"
#include "CtsOptions.h"
Expand Down Expand Up @@ -70,6 +71,12 @@ set_root_buffer(const char* buffer)
getTritonCts()->setRootBuffer(buffer);
}

void
set_buffer_list_prefix(const char* prefix)
{
getTritonCts()->getParms()->setBufferListPrefix(prefix);
}

void
set_slew_steps(int steps)
{
Expand Down
13 changes: 11 additions & 2 deletions src/cts/src/TritonCTS.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ proc configure_cts_characterization { args } {

sta::define_cmd_args "clock_tree_synthesis" {[-wire_unit unit]
[-buf_list buflist] \
[-buf_list_prefix prefix]\
[-root_buf buf] \
[-clk_nets nets] \
[-tree_buf buf] \
Expand All @@ -63,8 +64,8 @@ sta::define_cmd_args "clock_tree_synthesis" {[-wire_unit unit]

proc clock_tree_synthesis { args } {
sta::parse_key_args "clock_tree_synthesis" args \
keys {-root_buf -buf_list -wire_unit -clk_nets -sink_clustering_size \
-num_static_layers -sink_clustering_buffer \
keys {-root_buf -buf_list -wire_unit -clk_nets -buf_list_prefix\
-sink_clustering_size -num_static_layers -sink_clustering_buffer \
-distance_between_buffers -branching_point_buffers_distance \
-clustering_exponent \
-clustering_unbalance_ratio -sink_clustering_max_diameter \
Expand Down Expand Up @@ -130,6 +131,14 @@ proc clock_tree_synthesis { args } {
cts::set_clustering_unbalance_ratio $unbalance
}

if { [info exists keys(-buf_list_prefix)] } {
set prefix $keys(-buf_list_prefix)
if { [info exists keys(-buf_list)] } {
utl::warn CTS 129 "-buf_list_prefix will not be used, as -buf_list was already declared"
}
cts::set_buffer_list_prefix ".*${prefix}.*"
}

if { [info exists keys(-buf_list)] } {
set buf_list $keys(-buf_list)
cts::set_buffer_list $buf_list
Expand Down
Loading