Skip to content

Commit 3f01e9f

Browse files
openroad-ciCho Moonprecisionmoon
authored
Filter buffer list based on library analsys (#7915)
* added report_buffers command Signed-off-by: Cho Moon <[email protected]> * sorted VT types and added cell site column Signed-off-by: Cho Moon <[email protected]> * clang-tidy and clang-format fix Signed-off-by: Cho Moon <[email protected]> * small man page update Signed-off-by: Cho Moon <[email protected]> * use library analysis to filter buffer list Signed-off-by: Cho Moon <[email protected]> * enhanced findBuffers based on library analysis Signed-off-by: Cho Moon <[email protected]> * fixed clang-tidy and incorporated code review feedback Signed-off-by: Cho Moon <[email protected]> * rebased jepg_sky130hd Signed-off-by: Cho Moon <[email protected]> * More reporting enhancements: 1. Added regressions for 4 PDKS: asap7, gf180, nangate45 and sky130hd 2. Rewrote library analysis data structures to be more intuitive 3. Added -filter option to report_buffers to show filtered buffer list 4. Reformatted rsz::report_fast_buffer_sizes output Signed-off-by: Cho Moon <[email protected]> * clang-format fixes Signed-off-by: Cho Moon <[email protected]> * fixed clang-tidy Signed-off-by: Cho Moon <[email protected]> * moved asap7 to top-level test Signed-off-by: Cho Moon <[email protected]> --------- Signed-off-by: Cho Moon <[email protected]> Signed-off-by: Cho Moon <[email protected]> Co-authored-by: Cho Moon <[email protected]> Co-authored-by: Cho Moon <[email protected]>
1 parent 13839d9 commit 3f01e9f

30 files changed

+40674
-93
lines changed

src/rsz/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,23 @@ report_equiv_cells
589589
| `-match_cell_footprint` | Limit equivalent cell list to include only cells that match library cell_footprint attribute. |
590590
| `-all` | List all equivalent cells, ignoring sizing restrictions and cell_footprint. Cells excluded due to these restrictions are marked with an asterisk. |
591591

592+
### Reporting Buffers
593+
594+
The `report_buffers` command reports all usable buffers to include for optimization.
595+
Usable buffers are standard cell buffers that are not clock buffers, always on buffers,
596+
level shifters, or buffers marked as dont-use. VT type, cell site,
597+
cell footprint and leakage are also reported.
598+
599+
```tcl
600+
report_buffers
601+
[-filtered]
602+
```
603+
#### Options
604+
605+
| Switch Name | Description |
606+
| ----- | ----- |
607+
| `-filtered` | Report buffers after filtering based on threshold voltage, cell footprint, drive strength and cell site. Subset of filtered buffers are used for rebuffering. |
608+
592609
### Optimizing Arithmetic Modules
593610

594611
The `replace_arith_modules` command optimizes design performance by intelligently swapping hierarchical arithmetic modules based on realistic timing models.

src/rsz/include/rsz/Resizer.hh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,73 @@ enum class MoveType
163163
SPLIT
164164
};
165165

166+
// Voltage Threshold (VT) category identifier
167+
struct VTCategory
168+
{
169+
int vt_index;
170+
std::string vt_name;
171+
172+
// Enable use as map key
173+
bool operator<(const VTCategory& other) const
174+
{
175+
if (vt_index != other.vt_index) {
176+
return vt_index < other.vt_index;
177+
}
178+
return vt_name < other.vt_name;
179+
}
180+
};
181+
182+
// Leakage statistics for cells in a single VT category
183+
struct VTLeakageStats
184+
{
185+
int cell_count = 0;
186+
float total_leakage = 0.0f;
187+
188+
float get_average_leakage() const
189+
{
190+
return cell_count > 0 ? total_leakage / cell_count : 0.0f;
191+
}
192+
193+
void add_cell_leakage(std::optional<float> cell_leak)
194+
{
195+
cell_count++;
196+
if (cell_leak.has_value()) {
197+
total_leakage += *cell_leak;
198+
}
199+
}
200+
};
201+
202+
// Complete analysis data for a library
203+
struct LibraryAnalysisData
204+
{
205+
// VT category leakage analysis
206+
std::map<VTCategory, VTLeakageStats> vt_leakage_by_category;
207+
// Cell footprint distribution (footprint_name -> count)
208+
std::map<std::string, int> cells_by_footprint;
209+
// LEF site usage distribution (site -> count)
210+
std::map<odb::dbSite*, int> cells_by_site;
211+
// VT categories sorted by VT type for HVT/RVT/LVT/uLVT ordering
212+
std::vector<std::pair<VTCategory, VTLeakageStats>> sorted_vt_categories;
213+
214+
// Helper methods for common operations
215+
void sort_vt_categories()
216+
{
217+
sorted_vt_categories.clear();
218+
sorted_vt_categories.reserve(vt_leakage_by_category.size());
219+
for (const auto& vt_pair : vt_leakage_by_category) {
220+
sorted_vt_categories.push_back(vt_pair);
221+
}
222+
223+
// Sort by average leakage (ascending order - least leaky to most leaky)
224+
std::sort(sorted_vt_categories.begin(),
225+
sorted_vt_categories.end(),
226+
[](const auto& a, const auto& b) {
227+
return a.second.get_average_leakage()
228+
< b.second.get_average_leakage();
229+
});
230+
}
231+
};
232+
166233
class OdbCallBack;
167234

168235
class Resizer : public dbStaState, public dbNetworkObserver
@@ -435,6 +502,9 @@ class Resizer : public dbStaState, public dbNetworkObserver
435502
void reportEquivalentCells(LibertyCell* base_cell,
436503
bool match_cell_footprint,
437504
bool report_all_cells);
505+
void reportBuffers(bool filtered);
506+
void getBufferList(LibertyCellSeq& buffer_list,
507+
LibraryAnalysisData& lib_data);
438508
void setDebugGraphics(std::shared_ptr<ResizerObserver> graphics);
439509

440510
static MoveType parseMove(const std::string& s);

0 commit comments

Comments
 (0)