|
18 | 18 | #include "odb/dbObject.h" |
19 | 19 | #include "odb/geom.h" |
20 | 20 | #include "rsz/Resizer.hh" |
| 21 | +#include "sta/ClkNetwork.hh" |
21 | 22 | #include "sta/ContainerHelpers.hh" |
22 | 23 | #include "sta/Delay.hh" |
23 | 24 | #include "sta/Fuzzy.hh" |
@@ -60,6 +61,8 @@ void RepairHold::init() |
60 | 61 | db_network_ = resizer_->db_network_; |
61 | 62 | estimate_parasitics_ = resizer_->estimate_parasitics_; |
62 | 63 | initial_design_area_ = resizer_->computeDesignArea(); |
| 64 | + clk_tree_pins_.clear(); |
| 65 | + clk_tree_pins_valid_ = false; |
63 | 66 | } |
64 | 67 |
|
65 | 68 | bool RepairHold::repairHold( |
@@ -503,7 +506,18 @@ void RepairHold::findHoldViolations(sta::VertexSeq& ends, |
503 | 506 | debugPrint(logger_, RSZ, "repair_hold", 3, "Hold violations"); |
504 | 507 | for (sta::Vertex* end : ends) { |
505 | 508 | const sta::Slack slack = holdSlack(end); |
506 | | - if (!sta_->isClock(end->pin(), sta_->cmdMode()) && slack < hold_margin) { |
| 509 | + // Skip endpoints that lie on the clock network so we do not try to fix |
| 510 | + // hold on the clock tree itself. isClock() reports any pin in a clock |
| 511 | + // network's combinational fanout, which incorrectly includes register |
| 512 | + // data (D) pins that sample a signal sourced from a clock (e.g. a clock |
| 513 | + // used as data crossing into a different sampling-clock domain). Such |
| 514 | + // register data pins are genuine hold endpoints: they carry a timing |
| 515 | + // check (hasChecks()). Only exclude clock pins that are NOT data check |
| 516 | + // endpoints, so real cross-clock-domain hold violations are not silently |
| 517 | + // skipped. See OpenROAD issue #8075. |
| 518 | + const bool clk_tree_endpoint |
| 519 | + = sta_->isClock(end->pin(), sta_->cmdMode()) && !end->hasChecks(); |
| 520 | + if (!clk_tree_endpoint && slack < hold_margin) { |
507 | 521 | debugPrint(logger_, |
508 | 522 | RSZ, |
509 | 523 | "repair_hold", |
@@ -568,6 +582,76 @@ class RepairHoldPredicate : public sta::SearchPred1 |
568 | 582 | } |
569 | 583 | }; |
570 | 584 |
|
| 585 | +bool RepairHold::isClockTreeDriver(const sta::Pin* drvr_pin) |
| 586 | +{ |
| 587 | + if (!sta_->isClock(drvr_pin, sta_->cmdMode())) { |
| 588 | + return false; |
| 589 | + } |
| 590 | + if (!clk_tree_pins_valid_) { |
| 591 | + findClockTreePins(); |
| 592 | + } |
| 593 | + return clk_tree_pins_.contains(drvr_pin); |
| 594 | +} |
| 595 | + |
| 596 | +// Walk backward from every clock sink in the clock network (register or |
| 597 | +// timing-check clock pins and clock output ports) through clock-network |
| 598 | +// fanin. The pins reached form the clock tree proper. Clock-network pins |
| 599 | +// that only feed data pins (clock used as data) are not included. |
| 600 | +void RepairHold::findClockTreePins() |
| 601 | +{ |
| 602 | + clk_tree_pins_.clear(); |
| 603 | + const sta::Mode* mode = sta_->cmdMode(); |
| 604 | + sta_->ensureClkNetwork(mode); |
| 605 | + sta::ClkNetwork* clk_network = mode->clkNetwork(); |
| 606 | + std::vector<const sta::Pin*> queue; |
| 607 | + for (const sta::Clock* clk : mode->sdc()->clocks()) { |
| 608 | + const sta::PinSet* clk_pins = clk_network->pins(clk); |
| 609 | + if (clk_pins == nullptr) { |
| 610 | + continue; |
| 611 | + } |
| 612 | + for (const sta::Pin* pin : *clk_pins) { |
| 613 | + const bool clk_sink = network_->isRegClkPin(pin) |
| 614 | + || network_->isCheckClk(pin) |
| 615 | + || (network_->isTopLevelPort(pin) |
| 616 | + && network_->direction(pin)->isAnyOutput()); |
| 617 | + if (clk_sink && clk_tree_pins_.insert(pin).second) { |
| 618 | + queue.push_back(pin); |
| 619 | + } |
| 620 | + } |
| 621 | + } |
| 622 | + while (!queue.empty()) { |
| 623 | + const sta::Pin* pin = queue.back(); |
| 624 | + queue.pop_back(); |
| 625 | + sta::Vertex* vertex; |
| 626 | + sta::Vertex* bidir_drvr_vertex; |
| 627 | + graph_->pinVertices(pin, vertex, bidir_drvr_vertex); |
| 628 | + for (sta::Vertex* to_vertex : {vertex, bidir_drvr_vertex}) { |
| 629 | + if (to_vertex == nullptr) { |
| 630 | + continue; |
| 631 | + } |
| 632 | + sta::VertexInEdgeIterator edge_iter(to_vertex, graph_); |
| 633 | + while (edge_iter.hasNext()) { |
| 634 | + sta::Edge* edge = edge_iter.next(); |
| 635 | + if (edge->role()->isTimingCheck()) { |
| 636 | + continue; |
| 637 | + } |
| 638 | + const sta::Pin* from_pin = edge->from(graph_)->pin(); |
| 639 | + if (clk_network->isClock(from_pin) |
| 640 | + && clk_tree_pins_.insert(from_pin).second) { |
| 641 | + queue.push_back(from_pin); |
| 642 | + } |
| 643 | + } |
| 644 | + } |
| 645 | + } |
| 646 | + clk_tree_pins_valid_ = true; |
| 647 | + debugPrint(logger_, |
| 648 | + RSZ, |
| 649 | + "repair_hold", |
| 650 | + 2, |
| 651 | + "found {} clock tree pins", |
| 652 | + clk_tree_pins_.size()); |
| 653 | +} |
| 654 | + |
571 | 655 | void RepairHold::repairEndHold(sta::Vertex* end_vertex, |
572 | 656 | sta::LibertyCell* buffer_cell, |
573 | 657 | const double setup_margin, |
@@ -613,8 +697,11 @@ void RepairHold::repairEndHold(sta::Vertex* end_vertex, |
613 | 697 | if (group_only && !(group_hold_slack < hold_margin)) { |
614 | 698 | break; |
615 | 699 | } |
616 | | - if (path_vertex->isDriver(network_) |
617 | | - && resizer_->okToBufferNet(path_pin)) { |
| 700 | + // Hold paths that start at a clock source (clock used as data) |
| 701 | + // run through clock-network drivers. Only buffer on the data |
| 702 | + // side so the clock latency of other sinks is not changed. |
| 703 | + if (path_vertex->isDriver(network_) && resizer_->okToBufferNet(path_pin) |
| 704 | + && !isClockTreeDriver(path_pin)) { |
618 | 705 | sta::PinSeq load_pins; |
619 | 706 | Slacks slacks; |
620 | 707 | mergeInit(slacks); |
|
0 commit comments