Skip to content
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

utl: add mechanism to make it easier to handle operation-specific settings #5995

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@ struct BufferData

class OdbCallBack;

// RAII mechanism to facilitate using operation-specific settings.
AcKoucher marked this conversation as resolved.
Show resolved Hide resolved
template <typename T>
class SetAndRestore
{
public:
SetAndRestore(T& storage, const T& new_value);
~SetAndRestore();

private:
T& storage_;
T old_value_;
};

class Resizer : public dbStaState
{
public:
Expand Down
44 changes: 23 additions & 21 deletions src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2689,14 +2689,9 @@ void Resizer::repairNet(Net* net,
void Resizer::repairClkNets(double max_wire_length)
{
resizePreamble();

// Use the buffers that were selected by CTS.
buffer_cells_ = clk_buffers_;
SetAndRestore<LibertyCellSeq> set_buffers(buffer_cells_, clk_buffers_);

repair_design_->repairClkNets(max_wire_length);

// Reset so that the next preamble select data buffers again.
buffer_cells_.clear();
}

////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2855,6 +2850,21 @@ void Resizer::rebufferNet(const Pin* drvr_pin)

////////////////////////////////////////////////////////////////

template <typename T>
SetAndRestore<T>::SetAndRestore(T& storage, const T& new_value)
: storage_(storage), old_value_(storage)
{
storage_ = new_value;
}

template <typename T>
SetAndRestore<T>::~SetAndRestore()
{
storage_ = old_value_;
}

////////////////////////////////////////////////////////////////

void Resizer::repairHold(
double setup_margin,
double hold_margin,
Expand All @@ -2864,13 +2874,14 @@ void Resizer::repairHold(
int max_passes,
bool verbose)
{
buffer_cells_.clear();

// Some technologies such as nangate45 don't have delay cells. Hence,
// until we have a better approach, it's better to consider clock buffers
// for hold violation repairing as these buffers' delay may be slighty
// higher and we'll need fewer insertions.
exclude_clock_buffers_ = false;
// Obs: We need to clear the buffer list for the preamble to select
// buffers again excluding the clock ones.
SetAndRestore<bool> set_exclude_clk_buffers(exclude_clock_buffers_, false);
SetAndRestore<LibertyCellSeq> set_buffers(buffer_cells_, LibertyCellSeq());

resizePreamble();
if (parasitics_src_ == ParasiticsSrc::global_routing) {
Expand All @@ -2882,10 +2893,6 @@ void Resizer::repairHold(
max_buffer_percent,
max_passes,
verbose);

// Reset buffer selection strategy for the subsequent RSZ operation.
exclude_clock_buffers_ = true;
buffer_cells_.clear();
}

void Resizer::repairHold(const Pin* end_pin,
Expand All @@ -2895,10 +2902,9 @@ void Resizer::repairHold(const Pin* end_pin,
float max_buffer_percent,
int max_passes)
{
buffer_cells_.clear();

// See comments on previous method.
exclude_clock_buffers_ = false;
// See comment on the method above.
SetAndRestore<bool> set_exclude_clk_buffers(exclude_clock_buffers_, false);
SetAndRestore<LibertyCellSeq> set_buffers(buffer_cells_, LibertyCellSeq());

resizePreamble();
repair_hold_->repairHold(end_pin,
Expand All @@ -2907,10 +2913,6 @@ void Resizer::repairHold(const Pin* end_pin,
allow_setup_violations,
max_buffer_percent,
max_passes);

// Ditto.
exclude_clock_buffers_ = true;
buffer_cells_.clear();
}

int Resizer::holdBufferCount() const
Expand Down
Loading