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
19 changes: 9 additions & 10 deletions src/rsz/src/RepairDesign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void RepairDesign::performEarlySizingRound(int& repaired_net_count)
2,
"Annotating slew for driver {}",
network_->pathName(drvr->pin()));
for (auto rf : {sta::RiseFall::rise(), sta::RiseFall::fall()}) {
for (auto rf : sta::RiseFall::range()) {
if (!drvr->slewAnnotated(rf, min_) && !drvr->slewAnnotated(rf, max_)) {
sta_->setAnnotatedSlew(drvr,
resizer_->tgt_slew_corner_,
Expand Down Expand Up @@ -271,12 +271,12 @@ void RepairDesign::performEarlySizingRound(int& repaired_net_count)
}
}

for (auto mm : sta::MinMaxAll::all()->range()) {
for (auto rf : sta::RiseFallBoth::riseFall()->range()) {
if (!slew_user_annotated.contains(std::make_pair(drvr, rf->index()))) {
drvr->setSlewAnnotated(
false, rf, resizer_->tgt_slew_corner_->dcalcAnalysisPtIndex(mm));
}
for (auto rf : sta::RiseFall::range()) {
if (!slew_user_annotated.contains(std::make_pair(drvr, rf->index()))) {
sta_->unsetAnnotatedSlew(drvr,
resizer_->tgt_slew_corner_,
sta::MinMaxAll::all(),
rf->asRiseFallBoth());
}
}
}
Expand Down Expand Up @@ -428,12 +428,11 @@ void RepairDesign::repairDesign(
for (auto vertex : annotations_to_clean_up) {
for (auto corner : sta_->scenes()) {
for (const sta::RiseFall* rf : sta::RiseFall::range()) {
vertex->setSlewAnnotated(
false, rf, corner->dcalcAnalysisPtIndex(max_));
sta_->unsetAnnotatedSlew(
vertex, corner, sta::MinMaxAll::max(), rf->asRiseFallBoth());
}
}
}
sta_->delaysInvalid();
}

printProgress(print_iteration,
Expand Down
158 changes: 84 additions & 74 deletions src/rsz/src/RepairTargetCollector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,39 +436,47 @@ sta::Slack RepairTargetCollector::getPathSlackByIndex(
const sta::Pin* endpoint_pin,
int path_index)
{
// Worst path only: pure read via vertexWorstSlackPath, no findPathEnds /
// ExceptionTo. All shipping callers pass 0; findPathEnds path below is k>1.
if (path_index == 0) {
sta::Path* path = worstSlackPathForPin(endpoint_pin);
return path ? path->slack(search_) : static_cast<sta::Slack>(sta::INF);
}

// Create ExceptionTo for this endpoint
sta::PinSet* to_pins = new sta::PinSet(network_);
to_pins->insert(endpoint_pin);
sta::ExceptionTo* to = sdc_->makeExceptionTo(to_pins,
sta::ExceptionTo* to = sta_->makeExceptionTo(to_pins,
nullptr,
nullptr,
sta::RiseFallBoth::riseFall(),
sta::RiseFallBoth::riseFall());
sta::RiseFallBoth::riseFall(),
sdc_);

// Find paths to the endpoint - request only up to path_index+1 paths
sta::StringSeq group_names;
int num_paths_needed = path_index + 1;
sta::PathEndSeq path_ends
= search_->findPathEnds(nullptr, // from
nullptr, // thrus
to, // to
false, // unconstrained
sta_->scenes(), // scene
sta::MinMaxAll::all(), // min_max
num_paths_needed, // group_path_count
num_paths_needed, // endpoint_path_count
false, // unique_pins
false, // unique_edges
-sta::INF, // slack_min
sta::INF, // slack_max
true, // sort_by_slack
group_names, // group_names
true,
false,
true,
true,
true,
true); // checks
= sta_->findPathEnds(nullptr, // from
nullptr, // thrus
to, // to
false, // unconstrained
sta_->scenes(), // scene
sta::MinMaxAll::all(), // min_max
num_paths_needed, // group_path_count
num_paths_needed, // endpoint_path_count
false, // unique_pins
false, // unique_edges
-sta::INF, // slack_min
sta::INF, // slack_max
true, // sort_by_slack
group_names, // group_names
true,
false,
true,
true,
true,
true); // checks

// Return the slack of the requested path index
if (std::cmp_less(path_index, path_ends.size())) {
Expand Down Expand Up @@ -919,6 +927,13 @@ void RepairTargetCollector::collectExpandedPathDriverPins(
}
}

sta::Path* RepairTargetCollector::worstSlackPathForPin(
const sta::Pin* endpoint_pin) const
{
sta::Vertex* endpoint = graph_->pinLoadVertex(endpoint_pin);
return endpoint ? findWorstSlackPath(endpoint) : nullptr;
}

std::vector<Target> RepairTargetCollector::collectPathDriverTargets(
sta::Path* path,
const sta::Slack path_slack) const
Expand Down Expand Up @@ -1138,74 +1153,69 @@ set<const sta::Pin*> RepairTargetCollector::collectPinsByPathEndpoint(
// Create a set to remove duplciates
set<const sta::Pin*> viol_pins;

// This uses the old method for a single path at a time
/*if (paths_per_endpoint == 1) {
Vertex* end = graph_->pinDrvrVertex(endpoint_pin);
Path* end_path = sta_->vertexWorstSlackPath(end, max_);
PathExpanded expanded(end_path, sta_);
if (expanded.size() > 1) {
const int path_length = expanded.size();
const int start_index = expanded.startIndex();
for (int i = start_index; i < path_length; i++) {
const Path* path = expanded.path(i);
const Pin* path_pin = path->pin(sta_);
Vertex* path_vertex = path->vertex(sta_);
if (!path_vertex->isDriver(network_)
|| network_->isTopLevelPort(path_pin)) {
continue;
}
viol_pins.insert(path_pin);
debugPrint(logger_,
RSZ,
"violator_collector",
3,
" - Pin: {}",
network_->pathName(path_pin));
}
// Worst path only: pure read via vertexWorstSlackPath, no findPathEnds /
// ExceptionTo. All shipping callers pass 1; findPathEnds path below is k>1.
if (paths_per_endpoint == 1) {
sta::Path* path = worstSlackPathForPin(endpoint_pin);
if (path == nullptr || path->slack(search_) > 0.0) {
return viol_pins;
}
} else {
// FIXME later
sta::PathExpanded expanded(path, sta_);
for (size_t i = 0; i < expanded.size(); i++) {
const sta::Pin* pin = expanded.path(i)->pin(graph_);
if (!network_->direction(pin)->isOutput() || network_->isTopLevelPort(pin)
|| sta_->isClock(pin, sta_->cmdMode())) {
continue;
}
viol_pins.insert(pin);
}
// A latch-through path starts at latch Q in OpenSTA; expand the latch D
// fanin paths as well, matching the k>1 branch below.
visitLatchFaninSegments(
expanded, sta_, [&](const sta::Path*, sta::PathExpanded& d_expanded) {
collectExpandedPathDriverPins(d_expanded, viol_pins);
return false;
});
return viol_pins;
}
*/

// This code does not behave properly for single path case. At some points it
// does not match the above vertexWorstSlackPath method. It seems to be
// related to the use of the ExceptionTo object.
// The k>1 path below does not behave properly for the single path case: at
// some points it does not match the vertexWorstSlackPath fast path above. It
// seems to be related to the use of the ExceptionTo object.
// 1. Define the single endpoint for the path search.
sta::PinSet* to_pins = new sta::PinSet(network_);
to_pins->insert(endpoint_pin);
// The ExceptionTo object will be owned and deleted by the SDC.
sta::ExceptionTo* to = sdc_->makeExceptionTo(to_pins,
sta::ExceptionTo* to = sta_->makeExceptionTo(to_pins,
nullptr,
nullptr,
sta::RiseFallBoth::riseFall(),
sta::RiseFallBoth::riseFall());
sta::RiseFallBoth::riseFall(),
sdc_);

// 2. Find paths to the endpoint.
sta::StringSeq group_names;
sta::PathEndSeq path_ends
= search_->findPathEnds(nullptr, // from
nullptr, // thrus
to, // to
false, // unconstrained
sta_->scenes(), // scene
sta::MinMaxAll::all(), // min_max
paths_per_endpoint, // group_path_count
paths_per_endpoint, // endpoint_path_count
false, // unique_pins
false, // unique_edges
-sta::INF, // slack_min
sta::INF, // slack_max
true, // sort_by_slack
group_names, // group_names
true,
false,
true,
true,
true,
true); // checks
= sta_->findPathEnds(nullptr, // from
nullptr, // thrus
to, // to
false, // unconstrained
sta_->scenes(), // scene
sta::MinMaxAll::all(), // min_max
paths_per_endpoint, // group_path_count
paths_per_endpoint, // endpoint_path_count
false, // unique_pins
false, // unique_edges
-sta::INF, // slack_min
sta::INF, // slack_max
true, // sort_by_slack
group_names, // group_names
true,
false,
true,
true,
true,
true); // checks

int path_num = 1;
for (const sta::PathEnd* path_end : path_ends) {
Expand Down
2 changes: 2 additions & 0 deletions src/rsz/src/RepairTargetCollector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class RepairTargetCollector
// === Internal collection helpers =========================================
set<const sta::Pin*> collectPinsByPathEndpoint(const sta::Pin* endpoint_pin,
size_t paths_per_endpoint = 1);
// Worst-slack path to an endpoint pin (pure read, nullptr if none).
sta::Path* worstSlackPathForPin(const sta::Pin* endpoint_pin) const;
void collectBySlack();
void collectByPaths(int endPointIndex = 1,
int numEndpoints = 1,
Expand Down
1 change: 1 addition & 0 deletions src/rsz/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TESTS = [
"gain_buffering1",
"gain_buffering1_hier",
"gain_buffering2",
"gain_buffering3",
"gcd_resize",
"insert_buffer",
"insert_buffer_hier",
Expand Down
1 change: 1 addition & 0 deletions src/rsz/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ or_integration_tests(
fanin_fanout1
gain_buffering1
gain_buffering2
gain_buffering3
gcd_resize
insert_buffer
insert_buffer_hier
Expand Down
44 changes: 44 additions & 0 deletions src/rsz/test/gain_buffering3.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[INFO ODB-0227] LEF file: sky130hd/sky130hd.tlef, created 13 layers, 25 vias
[INFO ODB-0227] LEF file: sky130hd/sky130hd_std_cell.lef, created 437 library cells
[WARNING EST-0027] no estimated parasitics. Using wire load models.
Iteration | Area | Resized | Buffers | Nets repaired | Remaining
---------------------------------------------------------------------
0 | +1.1% | 0 | 1 | 2 | 53
final | +1.1% | 0 | 1 | 2 | 0
---------------------------------------------------------------------
[INFO RSZ-0038] Inserted 1 buffers in 2 nets.
Startpoint: f_src (rising edge-triggered flip-flop clocked by clk)
Endpoint: fa0 (rising edge-triggered flip-flop clocked by clk)
Path Group: clk
Path Type: max

Fanout Delay Time Description
---------------------------------------------------------------
0.00 0.00 clock clk (rise edge)
0.00 0.00 clock network delay (ideal)
0.00 0.00 ^ f_src/CLK (sky130_fd_sc_hd__dfxtp_1)
1 0.27 0.27 v f_src/Q (sky130_fd_sc_hd__dfxtp_1)
2 0.05 0.32 ^ GB/Y (sky130_fd_sc_hd__inv_1)
8 0.21 0.53 ^ gain1/X (sky130_fd_sc_hd__buf_1)
1 0.08 0.61 v s_thru/Y (sky130_fd_sc_hd__inv_1)
8 0.15 0.76 ^ GA/Y (sky130_fd_sc_hd__clkinvlp_2)
1 0.05 0.81 v a0/Y (sky130_fd_sc_hd__inv_1)
0.00 0.81 v fa0/D (sky130_fd_sc_hd__dfxtp_1)
0.81 data arrival time

1.00 1.00 clock clk (rise edge)
0.00 1.00 clock network delay (ideal)
0.00 1.00 clock reconvergence pessimism
1.00 ^ fa0/CLK (sky130_fd_sc_hd__dfxtp_1)
-0.12 0.88 library setup time
0.88 data required time
---------------------------------------------------------------
0.88 data required time
-0.81 data arrival time
---------------------------------------------------------------
0.07 slack (MET)


s_thru/A net: net1
d7/A net: nb
No differences found.
75 changes: 75 additions & 0 deletions src/rsz/test/gain_buffering3.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Gain buffering sink-required ordering vs incremental STA update discipline.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Register the gain_buffering3 regression

The new test files are never referenced by either test list: src/rsz/test/CMakeLists.txt and src/rsz/test/BUILD both omit gain_buffering3. In this state CI never runs this regression, so the STA/QoR behavior this testcase is meant to guard can regress without signal; please add it to both CMake and Bazel lists.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will add

#
# performGainBuffering() sorts the sinks of each net by required time and
# buffers the least-critical prefix (bounded here by set_max_fanout 8), so
# the sink at the group boundary is decided by the required times seen at
# that moment. Net "nb" has nine sinks: s_thru, whose required path runs
# through GA and the buffer tree inserted on net "na" earlier in the same
# early-sizing pass, and d0-d7, whose paths run through private inverter
# chains. The required times of s_thru and d7 are close enough that the
# choice of which one joins the buffered group depends on how fresh the
# delays behind them are (bounded cone refresh vs full findAllArrivals
# refresh between nets).
#
# Expected behavior (no golden files yet -- inspect the output):
#
# current code (bounded incremental STA: upfront findAllArrivals seed,
# per-driver findRequireds(level+1), end-of-net cone-bounded
# findDelays/findArrivals -- the fdedc4be STA-discipline changes were
# reverted; see rebuffer_sta_findings.md sections 9-10):
# - buffered group on nb = {d0..d6, s_thru}: s_thru is buffered,
# d7 stays directly on nb
# - report_checks: worst slack 0.07 (endpoint fa0; the nb gain buffer
# stacks onto the s_thru -> GA -> na path)
#
# with a per-net full refresh instead (sta_->findRequired(drvr), as in
# commit fdedc4be):
# - buffered group on nb = {d0..d7}: d7 is buffered,
# s_thru stays directly on nb
# - report_checks: worst slack 0.16 (endpoint fd7)
#
# The 90 ps WNS delta between the two disciplines is the QoR deviation.
source "helpers.tcl"
read_lef sky130hd/sky130hd.tlef
read_lef sky130hd/sky130hd_std_cell.lef
read_liberty sky130hd/sky130hd_tt.lib

read_verilog gain_buffering3.v
link_design top

create_clock -name clk -period 1.0 [get_ports clk]

set_dont_use {sky130_fd_sc_hd__probe_*
sky130_fd_sc_hd__lpflow_*
sky130_fd_sc_hd__clkdly*
sky130_fd_sc_hd__dlygate*
sky130_fd_sc_hd__dlymetal*
sky130_fd_sc_hd__clkbuf_*
sky130_fd_sc_hd__bufbuf_*
sky130_fd_sc_hd__buf_2
sky130_fd_sc_hd__buf_4
sky130_fd_sc_hd__buf_6
sky130_fd_sc_hd__buf_8
sky130_fd_sc_hd__buf_12
sky130_fd_sc_hd__buf_16
sky130_fd_sc_hd__inv_2
sky130_fd_sc_hd__inv_4
sky130_fd_sc_hd__inv_6
sky130_fd_sc_hd__inv_8
sky130_fd_sc_hd__inv_12
sky130_fd_sc_hd__inv_16}

set_max_fanout 8 [current_design]

repair_design -pre_placement
report_checks -fields {fanout}

# Show which sink ended up behind the gain buffer (d7 with current code,
# s_thru with the legacy bounded-refresh code).
puts "s_thru/A net: [get_full_name [get_nets -of_objects [get_pins s_thru/A]]]"
puts "d7/A net: [get_full_name [get_nets -of_objects [get_pins d7/A]]]"

set test_name "gain_buffering3"
set verilog_file [make_result_file "${test_name}.v"]
write_verilog $verilog_file
diff_files ${test_name}.vok $verilog_file
Loading
Loading