|
4 | 4 | #include "PreChecks.hh" |
5 | 5 |
|
6 | 6 | #include <algorithm> |
| 7 | +#include <memory> |
7 | 8 |
|
8 | 9 | #include "db_sta/dbNetwork.hh" |
| 10 | +#include "db_sta/dbSta.hh" |
9 | 11 | #include "rsz/Resizer.hh" |
10 | 12 | #include "sta/Corner.hh" |
11 | 13 | #include "sta/LibertyClass.hh" |
| 14 | +#include "sta/MinMax.hh" |
| 15 | +#include "sta/NetworkClass.hh" |
12 | 16 | #include "sta/Units.hh" |
13 | 17 | #include "utl/Logger.h" |
14 | 18 |
|
@@ -59,4 +63,66 @@ void PreChecks::checkSlewLimit(float ref_cap, float max_load_slew) |
59 | 63 | cap_unit->scaleAbbreviation()); |
60 | 64 | } |
61 | 65 | } |
| 66 | + |
| 67 | +void PreChecks::checkCapLimit(const Pin* drvr_pin) |
| 68 | +{ |
| 69 | + if (!min_cap_load_computed_) { |
| 70 | + min_cap_load_computed_ = true; |
| 71 | + // Find the smallest buffer/inverter input cap |
| 72 | + min_cap_load_ = sta::INF; |
| 73 | + dbNetwork* network = resizer_->getDbNetwork(); |
| 74 | + std::unique_ptr<sta::LibertyLibraryIterator> lib_iter{ |
| 75 | + network->libertyLibraryIterator()}; |
| 76 | + |
| 77 | + auto update_min_cap = [&](const auto& cells) { |
| 78 | + for (sta::LibertyCell* cell : cells) { |
| 79 | + sta::LibertyPort* input; |
| 80 | + sta::LibertyPort* output; |
| 81 | + cell->bufferPorts(input, output); |
| 82 | + min_cap_load_ = std::min(min_cap_load_, input->capacitance()); |
| 83 | + } |
| 84 | + }; |
| 85 | + |
| 86 | + while (lib_iter->hasNext()) { |
| 87 | + sta::LibertyLibrary* lib = lib_iter->next(); |
| 88 | + update_min_cap(*lib->buffers()); |
| 89 | + update_min_cap(*lib->inverters()); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + float cap1, max_cap1, cap_slack1; |
| 94 | + const Corner* corner1; |
| 95 | + const RiseFall* tr1; |
| 96 | + sta_->checkCapacitance(drvr_pin, |
| 97 | + nullptr, |
| 98 | + sta::MinMax::max(), |
| 99 | + corner1, |
| 100 | + tr1, |
| 101 | + cap1, |
| 102 | + max_cap1, |
| 103 | + cap_slack1); |
| 104 | + if (max_cap1 > 0 && max_cap1 < min_cap_load_) { |
| 105 | + dbNetwork* network = resizer_->getDbNetwork(); |
| 106 | + const sta::Unit* cap_unit = sta_->units()->capacitanceUnit(); |
| 107 | + std::string master_name = "-"; |
| 108 | + if (sta::Instance* inst = network->instance(drvr_pin)) { |
| 109 | + sta::Cell* cell = network->cell(inst); |
| 110 | + if (cell) { |
| 111 | + master_name = network->name(cell); |
| 112 | + } |
| 113 | + } |
| 114 | + logger_->error( |
| 115 | + RSZ, |
| 116 | + 169, |
| 117 | + "Max cap for driver {} of type {} is unreasonably small {}{}F. " |
| 118 | + "Min buffer or inverter input cap is {}{}F", |
| 119 | + network->name(drvr_pin), |
| 120 | + master_name, |
| 121 | + cap_unit->asString(max_cap1), |
| 122 | + cap_unit->scaleAbbreviation(), |
| 123 | + cap_unit->asString(min_cap_load_), |
| 124 | + cap_unit->scaleAbbreviation()); |
| 125 | + } |
| 126 | +} |
| 127 | + |
62 | 128 | } // namespace rsz |
0 commit comments