Skip to content

Commit

Permalink
rsz: make new mechanism more generic
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Koucher <[email protected]>
  • Loading branch information
AcKoucher committed Oct 22, 2024
1 parent d4748ce commit 7d2f82d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 59 deletions.
29 changes: 7 additions & 22 deletions src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -182,32 +182,17 @@ struct BufferData

class OdbCallBack;

// RAII mechanism to facilitate using operation specific settings, e.g.,
// use only the clock buffers from cts when doing repairClkNets, don't
// use buffers marked as "clock" in hold repairing, etc.
// Can be instantiated in two ways:
// - Before resizePreamble(): set the "filters" used by the preamble.
// - After resizePreamble(): enforce the variables we want.
class OperationSettings
// RAII mechanism to facilitate using operation-specific settings.
template <typename T>
class SetAndRestore
{
public:
// Call before preamble:
OperationSettings(bool* exclude_clock_buffers,
bool new_exclude_clock_buffers,
sta::LibertyCellSeq* buffer_cells);

// Call after preamble:
OperationSettings(sta::LibertyCellSeq* buffer_cells,
const sta::LibertyCellSeq& new_buffer_cells);

~OperationSettings();
SetAndRestore(T& storage, const T& new_value);
~SetAndRestore();

private:
bool* exclude_clock_buffers_{nullptr};
sta::LibertyCellSeq* buffer_cells_{nullptr};

// Previous settings (initialized to default):
bool prev_exclude_clock_buffers_{true};
T& storage_;
T old_value_;
};

class Resizer : public dbStaState
Expand Down
54 changes: 17 additions & 37 deletions src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,7 @@ void Resizer::repairNet(Net* net,
void Resizer::repairClkNets(double max_wire_length)
{
resizePreamble();
OperationSettings operation_settings(&buffer_cells_, clk_buffers_);
SetAndRestore<LibertyCellSeq> set_buffers(buffer_cells_, clk_buffers_);

repair_design_->repairClkNets(max_wire_length);
}
Expand Down Expand Up @@ -2850,42 +2850,20 @@ void Resizer::rebufferNet(const Pin* drvr_pin)

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

OperationSettings::OperationSettings(bool* exclude_clock_buffers,
const bool new_exclude_clock_buffers,
sta::LibertyCellSeq* buffer_cells)
template <typename T>
SetAndRestore<T>::SetAndRestore(T& storage, const T& new_value)
: storage_(storage), old_value_(storage)
{
if (exclude_clock_buffers) {
exclude_clock_buffers_ = exclude_clock_buffers;
prev_exclude_clock_buffers_ = *exclude_clock_buffers_;
*exclude_clock_buffers_ = new_exclude_clock_buffers;
}

if (buffer_cells) {
buffer_cells_ = buffer_cells;
buffer_cells_->clear();
}
storage_ = new_value;
}

OperationSettings::OperationSettings(
sta::LibertyCellSeq* buffer_cells,
const sta::LibertyCellSeq& new_buffer_cells)
template <typename T>
SetAndRestore<T>::~SetAndRestore()
{
if (buffer_cells) {
buffer_cells_ = buffer_cells;
*buffer_cells_ = new_buffer_cells;
}
storage_ = old_value_;
}

OperationSettings::~OperationSettings()
{
if (exclude_clock_buffers_) {
*exclude_clock_buffers_ = prev_exclude_clock_buffers_;
}

if (buffer_cells_) {
buffer_cells_->clear();
}
}
////////////////////////////////////////////////////////////////

void Resizer::repairHold(
double setup_margin,
Expand All @@ -2900,9 +2878,11 @@ void Resizer::repairHold(
// 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.
OperationSettings operation_settings(&exclude_clock_buffers_,
false /*new_exclude_clock_buffers*/,
&buffer_cells_);
// 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) {
opendp_->initMacrosAndGrid();
Expand All @@ -2923,9 +2903,9 @@ void Resizer::repairHold(const Pin* end_pin,
int max_passes)
{
// See comment on the method above.
OperationSettings operation_settings(&exclude_clock_buffers_,
false /*new_exclude_clock_buffers*/,
&buffer_cells_);
SetAndRestore<bool> set_exclude_clk_buffers(exclude_clock_buffers_, false);
SetAndRestore<LibertyCellSeq> set_buffers(buffer_cells_, LibertyCellSeq());

resizePreamble();
repair_hold_->repairHold(end_pin,
setup_margin,
Expand Down

0 comments on commit 7d2f82d

Please sign in to comment.