Skip to content

Commit

Permalink
Merge pull request #6156 from gadfort/add-cell-area
Browse files Browse the repository at this point in the history
dbsta: add cell area to metrics to mirror report information and totals
  • Loading branch information
maliberty authored Nov 14, 2024
2 parents d8347db + 6167a90 commit c1b90a6
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/dbSta/src/dbSta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,31 @@ void dbSta::report_cell_usage(odb::dbModule* module, const bool verbose)
module->getName());
}
logger_->report(header_format, "Cell type report:", "Count", "Area");

const std::regex regexp(" |/|-");
std::string metrics_suffix;
if (block->getTopModule() != module) {
metrics_suffix = fmt::format("__in_module:{}", module->getName());
}

for (auto [type, stats] : instances_types) {
std::string type_name = getInstanceTypeText(type);
const std::string type_name = getInstanceTypeText(type);
logger_->report(
format, type_name, stats.count, stats.area / area_to_microns);
total_area += stats.area;

std::regex regexp(" |/|-");
logger_->metric("design__instance__count__class:"
+ toLowerCase(regex_replace(type_name, regexp, "_")),
const std::string type_class
= toLowerCase(regex_replace(type_name, regexp, "_"));
const std::string metric_suffix = type_class + metrics_suffix;

logger_->metric("design__instance__count__class:" + metric_suffix,
stats.count);
logger_->metric("design__instance__area__class:" + metric_suffix,
stats.area / area_to_microns);
}
logger_->metric("design__instance__count" + metrics_suffix, total_usage);
logger_->metric("design__instance__area" + metrics_suffix,
total_area / area_to_microns);
logger_->report(format, "Total", total_usage, total_area / area_to_microns);

if (verbose) {
Expand Down
1 change: 1 addition & 0 deletions src/dbSta/test/regression_tests.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ record_tests {

report_cell_usage
report_cell_usage_modinsts
report_cell_usage_modinsts_metrics

write_verilog1
write_verilog2
Expand Down
20 changes: 20 additions & 0 deletions src/dbSta/test/report_cell_usage_modinsts_metrics.jsonok
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"design__instance__count__class:buffer": 4,
"design__instance__area__class:buffer": 4000,
"design__instance__count__class:sequential_cell": 2,
"design__instance__area__class:sequential_cell": 2000,
"design__instance__count": 6,
"design__instance__area": 6000,
"design__instance__count__class:buffer__in_module:block1": 2,
"design__instance__area__class:buffer__in_module:block1": 2000,
"design__instance__count__class:sequential_cell__in_module:block1": 1,
"design__instance__area__class:sequential_cell__in_module:block1": 1000,
"design__instance__count__in_module:block1": 3,
"design__instance__area__in_module:block1": 3000,
"design__instance__count__class:buffer__in_module:block1-1": 2,
"design__instance__area__class:buffer__in_module:block1-1": 2000,
"design__instance__count__class:sequential_cell__in_module:block1-1": 1,
"design__instance__area__class:sequential_cell__in_module:block1-1": 1000,
"design__instance__count__in_module:block1-1": 3,
"design__instance__area__in_module:block1-1": 3000
}
28 changes: 28 additions & 0 deletions src/dbSta/test/report_cell_usage_modinsts_metrics.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[INFO ODB-0227] LEF file: liberty1.lef, created 2 layers, 6 library cells
Cell type report: Count Area
Buffer 4 4000.00
Sequential cell 2 2000.00
Total 6 6000.00

Cell instance report:
snl_bufx1 4 4000.00
snl_ffqx1 2 2000.00
Cell type report for b1 (block1)
Cell type report: Count Area
Buffer 2 2000.00
Sequential cell 1 1000.00
Total 3 3000.00

Cell instance report:
snl_bufx1 2 2000.00
snl_ffqx1 1 1000.00
Cell type report for b2 (block1-1)
Cell type report: Count Area
Buffer 2 2000.00
Sequential cell 1 1000.00
Total 3 3000.00

Cell instance report:
snl_bufx1 2 2000.00
snl_ffqx1 1 1000.00
No differences found.
20 changes: 20 additions & 0 deletions src/dbSta/test/report_cell_usage_modinsts_metrics.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Report cell usage for modinsts with metrics

source "helpers.tcl"
read_lef liberty1.lef
read_liberty liberty1.lib
read_verilog hier1.v
link_design top

set metrics [make_result_file report_cell_usage_modinsts_metrics.json]

utl::open_metrics $metrics

report_cell_usage -verbose

report_cell_usage -verbose b1
report_cell_usage -verbose b2

utl::close_metrics $metrics

diff_files report_cell_usage_modinsts_metrics.jsonok $metrics

0 comments on commit c1b90a6

Please sign in to comment.